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