From dbeced963e620d4b5231363dd7cf1e7252dd6073 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Tue, 9 Apr 2013 18:30:24 +0530 Subject: [PATCH] condition, man: Add support for ConditionSecurity=apparmor Checking for the apparmor directory in securityfs means the apparmor module is loaded and enabled, and hence should suffice as a test. https://bugs.freedesktop.org/show_bug.cgi?id=63312 --- man/systemd.unit.xml | 3 ++- src/core/condition.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index 26c16de..18e6aef 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -1013,7 +1013,8 @@ may be used to check whether the given security module is enabled on the system. Currently the only recognized - value is selinux. + values are selinux + and apparmor. The test may be negated by prepending an exclamation mark. diff --git a/src/core/condition.c b/src/core/condition.c index 30199c1..4aa5530 100644 --- a/src/core/condition.c +++ b/src/core/condition.c @@ -162,6 +162,8 @@ static bool test_security(const char *parameter) { if (streq(parameter, "selinux")) return is_selinux_enabled() > 0; #endif + if (streq(parameter, "apparmor")) + return access("/sys/kernel/security/apparmor/", F_OK) == 0; return false; } -- 1.8.1.5