mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
apparmor-util: shortcut mac_apparmor_use() if compile-time disabled
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user