]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
apparmor-util: shortcut mac_apparmor_use() if compile-time disabled 39826/head
authorLennart Poettering <lennart@poettering.net>
Thu, 20 Nov 2025 13:20:37 +0000 (14:20 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 20 Nov 2025 13:21:56 +0000 (14:21 +0100)
src/shared/apparmor-util.c
src/shared/apparmor-util.h

index b29534c47161f259b1d28b9b6d5eda8863b15849..74a03817bda9cc99a5bca7dd2b8437540aec12c3 100644 (file)
@@ -39,7 +39,6 @@ int dlopen_libapparmor(void) {
                         DLSYM_ARG(aa_policy_cache_replace_all),
                         DLSYM_ARG(aa_policy_cache_unref));
 }
-#endif
 
 bool mac_apparmor_use(void) {
         static int cached_use = -1;
@@ -57,14 +56,14 @@ bool mac_apparmor_use(void) {
         }
 
         r = parse_boolean(p);
-        if (r <= 0) {
-                if (r < 0)
-                        log_debug_errno(r, "Failed to parse /sys/module/apparmor/parameters/enabled, assuming AppArmor is not available: %m");
+        if (r < 0)
+                log_debug_errno(r, "Failed to parse /sys/module/apparmor/parameters/enabled, assuming AppArmor is not available: %m");
+        if (r <= 0)
                 return (cached_use = false);
-        }
 
         if (dlopen_libapparmor() < 0)
                 return (cached_use = false);
 
         return (cached_use = true);
 }
+#endif
index c3f97ceaafc958ea7adc8ad0b4f53c4f76029aa3..06d6bf30e27c22e9e474311aad8ecd9e2b760a70 100644 (file)
@@ -21,10 +21,12 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(aa_features*, sym_aa_features_unref, aa_
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(aa_policy_cache*, sym_aa_policy_cache_unref, aa_policy_cache_unrefp, NULL);
 
 int dlopen_libapparmor(void);
+bool mac_apparmor_use(void);
 #else
 static inline int dlopen_libapparmor(void) {
         return -EOPNOTSUPP;
 }
+static inline bool mac_apparmor_use(void) {
+        return false;
+}
 #endif
-
-bool mac_apparmor_use(void);