[systemd-devel] [PATCH] Do not cache use_smack() value unless /sys is mounted

Łukasz Stelmach l.stelmach at samsung.com
Fri Feb 28 08:09:21 PST 2014


use_smack() is called very early via mkdir_p_label(). This happens
before /sys is mounted and hence before the authoritative information
about smack is even available. To prevent caching of the invalid value
check whether /sys/fs exists.
---
 src/shared/smack-util.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c
index df194e0..96f365c 100644
--- a/src/shared/smack-util.c
+++ b/src/shared/smack-util.c
@@ -33,6 +33,9 @@ bool use_smack(void) {
 #ifdef HAVE_SMACK
         static int use_smack_cached = -1;
 
+        if (use_smack_cached < 0 && access("/sys/fs/", F_OK) < 0)
+                return false;
+
         if (use_smack_cached < 0)
                 use_smack_cached = access("/sys/fs/smackfs/", F_OK) >= 0;
 
-- 
1.7.9.5



More information about the systemd-devel mailing list