From 5b93b025d577bc23dee3c40097d4efcad15e1c77 Mon Sep 17 00:00:00 2001 From: Ronan Le Martret Date: Fri, 18 Apr 2014 15:24:15 +0200 Subject: [PATCH] Fix-use_smack-corrupt-cached-result Change-Id: Id4666fe61980442e30cd5dd5b8d80517fb46157f --- .../0001-Fix-use_smack-corrupt-cached-result.patch | 45 ++++++++++++++++++++++ recipes-core/systemd/systemd_211.bbappend | 4 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 recipes-core/systemd/files/0001-Fix-use_smack-corrupt-cached-result.patch diff --git a/recipes-core/systemd/files/0001-Fix-use_smack-corrupt-cached-result.patch b/recipes-core/systemd/files/0001-Fix-use_smack-corrupt-cached-result.patch new file mode 100644 index 0000000..ce588a3 --- /dev/null +++ b/recipes-core/systemd/files/0001-Fix-use_smack-corrupt-cached-result.patch @@ -0,0 +1,45 @@ +From 82cd5f55a9cae6a5cd8ca82b2d386ac27fbc62d7 Mon Sep 17 00:00:00 2001 +From: Ronan Le Martret +Date: Fri, 18 Apr 2014 15:11:47 +0200 +Subject: [PATCH 1/1] Fix use_smack corrupt cached result. + +You can not put the cached result of use_smack fct, +as we are not sure the "/sys" is mounted. +So for the two first mount from mount_table, +"/proc" and "/sys" result from use_smack should not be cached. + +Change-Id: I730b94a28bf6c5dd60d15dccc0409cd9e1a8a67c +Signed-off-by: Ronan Le Martret +--- + src/shared/smack-util.c | 15 ++++++++++----- + 1 file changed, 10 insertions(+), 5 deletions(-) + +diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c +index df194e0..db35be5 100644 +--- a/src/shared/smack-util.c ++++ b/src/shared/smack-util.c +@@ -32,11 +32,16 @@ + bool use_smack(void) { + #ifdef HAVE_SMACK + static int use_smack_cached = -1; +- +- if (use_smack_cached < 0) +- use_smack_cached = access("/sys/fs/smackfs/", F_OK) >= 0; +- +- return use_smack_cached; ++ int res = false; ++ if (use_smack_cached < 0) { ++ if (access("/sys/fs", F_OK) >= 0) { ++ use_smack_cached = access("/sys/fs/smackfs/", F_OK) >= 0; ++ res = use_smack_cached; ++ } ++ } else ++ res = use_smack_cached; ++ ++ return res; + #else + return false; + #endif +-- +1.8.1.4 + diff --git a/recipes-core/systemd/systemd_211.bbappend b/recipes-core/systemd/systemd_211.bbappend index afd8cc6..b858f4f 100644 --- a/recipes-core/systemd/systemd_211.bbappend +++ b/recipes-core/systemd/systemd_211.bbappend @@ -1,8 +1,10 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/files:" +SRC_URI += "file://0001-Fix-use_smack-corrupt-cached-result.patch" + DEPENDS += "smack" RDEPENDS_${PN} += "smack" DEPENDS += "attr" -EXTRA_OECONF += ' --enable-smack ' \ No newline at end of file +EXTRA_OECONF += ' --enable-smack --with-smack-run-label=System ' \ No newline at end of file -- 2.7.4