ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
923a60
From 201006fa521199ebf109016c9dd22812c435dfe9 Mon Sep 17 00:00:00 2001
923a60
From: Ismo Puustinen <ismo.puustinen@intel.com>
923a60
Date: Fri, 8 Jan 2016 00:00:04 +0200
923a60
Subject: [PATCH] capabilities: keep bounding set in non-inverted format.
923a60
923a60
Change the capability bounding set parser and logic so that the bounding
923a60
set is kept as a positive set internally. This means that the set
923a60
reflects those capabilities that we want to keep instead of drop.
923a60
923a60
Resolves: #1387398
923a60
---
923a60
 src/core/dbus-execute.c               |  4 +-
923a60
 src/core/execute.c                    |  9 +--
923a60
 src/core/execute.h                    |  2 +-
923a60
 src/core/load-fragment-gperf.gperf.m4 |  2 +-
923a60
 src/core/load-fragment.c              | 25 ++++----
923a60
 src/core/load-fragment.h              |  2 +-
923a60
 src/core/main.c                       | 10 +--
923a60
 src/core/unit.c                       |  2 +-
923a60
 src/import/import-common.c            |  2 +-
923a60
 src/nspawn/nspawn.c                   |  2 +-
923a60
 src/shared/capability.c               | 16 ++---
923a60
 src/shared/capability.h               | 12 +++-
923a60
 src/test/test-unit-file.c             | 89 +++++++++++++++------------
923a60
 13 files changed, 96 insertions(+), 81 deletions(-)
923a60
923a60
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
923a60
index da8b10d2b3..a564c53fae 100644
923a60
--- a/src/core/dbus-execute.c
923a60
+++ b/src/core/dbus-execute.c
923a60
@@ -324,9 +324,7 @@ static int property_get_capability_bounding_set(
923a60
         assert(reply);
923a60
         assert(c);
923a60
 
923a60
-        /* We store this negated internally, to match the kernel, but
923a60
-         * we expose it normalized. */
923a60
-        return sd_bus_message_append(reply, "t", ~c->capability_bounding_set_drop);
923a60
+        return sd_bus_message_append(reply, "t", c->capability_bounding_set);
923a60
 }
923a60
 
923a60
 static int property_get_capabilities(
923a60
diff --git a/src/core/execute.c b/src/core/execute.c
923a60
index f72b20966f..40db11e284 100644
923a60
--- a/src/core/execute.c
923a60
+++ b/src/core/execute.c
923a60
@@ -1733,8 +1733,8 @@ static int exec_child(
923a60
                         }
923a60
                 }
923a60
 
923a60
-                if (context->capability_bounding_set_drop) {
923a60
-                        r = capability_bounding_set_drop(context->capability_bounding_set_drop, false);
923a60
+                if (!cap_test_all(context->capability_bounding_set)) {
923a60
+                        r = capability_bounding_set_drop(context->capability_bounding_set, false);
923a60
                         if (r < 0) {
923a60
                                 *exit_status = EXIT_CAPABILITIES;
923a60
                                 return r;
923a60
@@ -1988,6 +1988,7 @@ void exec_context_init(ExecContext *c) {
923a60
         c->timer_slack_nsec = NSEC_INFINITY;
923a60
         c->personality = 0xffffffffUL;
923a60
         c->runtime_directory_mode = 0755;
923a60
+        c->capability_bounding_set = CAP_ALL;
923a60
 }
923a60
 
923a60
 void exec_context_done(ExecContext *c) {
923a60
@@ -2419,12 +2420,12 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
923a60
                         (c->secure_bits & 1<
923a60
                         (c->secure_bits & 1<
923a60
 
923a60
-        if (c->capability_bounding_set_drop) {
923a60
+        if (c->capability_bounding_set != CAP_ALL) {
923a60
                 unsigned long l;
923a60
                 fprintf(f, "%sCapabilityBoundingSet:", prefix);
923a60
 
923a60
                 for (l = 0; l <= cap_last_cap(); l++)
923a60
-                        if (!(c->capability_bounding_set_drop & ((uint64_t) 1ULL << (uint64_t) l)))
923a60
+                        if (c->capability_bounding_set & (UINT64_C(1) << l))
923a60
                                 fprintf(f, " %s", strna(capability_to_name(l)));
923a60
 
923a60
                 fputs("\n", f);
923a60
diff --git a/src/core/execute.h b/src/core/execute.h
923a60
index cadd0e6b47..40f7b794c5 100644
923a60
--- a/src/core/execute.h
923a60
+++ b/src/core/execute.h
923a60
@@ -150,7 +150,7 @@ struct ExecContext {
923a60
         char **read_write_dirs, **read_only_dirs, **inaccessible_dirs;
923a60
         unsigned long mount_flags;
923a60
 
923a60
-        uint64_t capability_bounding_set_drop;
923a60
+        uint64_t capability_bounding_set;
923a60
 
923a60
         cap_t capabilities;
923a60
         int secure_bits;
923a60
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
923a60
index b50fe45b47..e4ce292100 100644
923a60
--- a/src/core/load-fragment-gperf.gperf.m4
923a60
+++ b/src/core/load-fragment-gperf.gperf.m4
923a60
@@ -47,7 +47,7 @@ $1.SyslogLevel,                  config_parse_log_level,             0,
923a60
 $1.SyslogLevelPrefix,            config_parse_bool,                  0,                             offsetof($1, exec_context.syslog_level_prefix)
923a60
 $1.Capabilities,                 config_parse_exec_capabilities,     0,                             offsetof($1, exec_context)
923a60
 $1.SecureBits,                   config_parse_exec_secure_bits,      0,                             offsetof($1, exec_context)
923a60
-$1.CapabilityBoundingSet,        config_parse_bounding_set,          0,                             offsetof($1, exec_context.capability_bounding_set_drop)
923a60
+$1.CapabilityBoundingSet,        config_parse_capability_set,        0,                             offsetof($1, exec_context.capability_bounding_set)
923a60
 $1.TimerSlackNSec,               config_parse_nsec,                  0,                             offsetof($1, exec_context.timer_slack_nsec)
923a60
 $1.NoNewPrivileges,              config_parse_no_new_privileges,     0,                             offsetof($1, exec_context)
923a60
 m4_ifdef(`HAVE_SECCOMP',
923a60
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
923a60
index ab3b0c2e92..dbaaf2fee7 100644
923a60
--- a/src/core/load-fragment.c
923a60
+++ b/src/core/load-fragment.c
923a60
@@ -1015,7 +1015,7 @@ int config_parse_exec_secure_bits(const char *unit,
923a60
         return 0;
923a60
 }
923a60
 
923a60
-int config_parse_bounding_set(
923a60
+int config_parse_capability_set(
923a60
                 const char *unit,
923a60
                 const char *filename,
923a60
                 unsigned line,
923a60
@@ -1027,8 +1027,8 @@ int config_parse_bounding_set(
923a60
                 void *data,
923a60
                 void *userdata) {
923a60
 
923a60
-        uint64_t *capability_bounding_set_drop = data;
923a60
-        uint64_t capability_bounding_set, sum = 0;
923a60
+        uint64_t *capability_set = data;
923a60
+        uint64_t sum = 0, initial = 0;
923a60
         bool invert = false;
923a60
         const char *p;
923a60
 
923a60
@@ -1042,10 +1042,8 @@ int config_parse_bounding_set(
923a60
                 rvalue++;
923a60
         }
923a60
 
923a60
-        /* Note that we store this inverted internally, since the
923a60
-         * kernel wants it like this. But we actually expose it
923a60
-         * non-inverted everywhere to have a fully normalized
923a60
-         * interface. */
923a60
+        if (strcmp(lvalue, "CapabilityBoundingSet") == 0)
923a60
+                initial = CAP_ALL; /* initialized to all bits on */
923a60
 
923a60
         p = rvalue;
923a60
         for (;;) {
923a60
@@ -1071,11 +1069,14 @@ int config_parse_bounding_set(
923a60
                 sum |= ((uint64_t) UINT64_C(1)) << (uint64_t) cap;
923a60
         }
923a60
 
923a60
-        capability_bounding_set = invert ? ~sum : sum;
923a60
-        if (*capability_bounding_set_drop != 0 && capability_bounding_set != 0)
923a60
-                *capability_bounding_set_drop = ~(~*capability_bounding_set_drop | capability_bounding_set);
923a60
+        sum = invert ? ~sum : sum;
923a60
+
923a60
+        if (sum == 0 || *capability_set == initial)
923a60
+                /* "" or uninitialized data -> replace */
923a60
+                *capability_set = sum;
923a60
         else
923a60
-                *capability_bounding_set_drop = ~capability_bounding_set;
923a60
+                /* previous data -> merge */
923a60
+                *capability_set |= sum;
923a60
 
923a60
         return 0;
923a60
 }
923a60
@@ -4050,7 +4051,7 @@ void unit_dump_config_items(FILE *f) {
923a60
                 { config_parse_log_level,             "LEVEL" },
923a60
                 { config_parse_exec_capabilities,     "CAPABILITIES" },
923a60
                 { config_parse_exec_secure_bits,      "SECUREBITS" },
923a60
-                { config_parse_bounding_set,          "BOUNDINGSET" },
923a60
+                { config_parse_capability_set,        "BOUNDINGSET" },
923a60
                 { config_parse_limit,                 "LIMIT" },
923a60
                 { config_parse_unit_deps,             "UNIT [...]" },
923a60
                 { config_parse_exec,                  "PATH [ARGUMENT [...]]" },
923a60
diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h
923a60
index 9dd7d1bda0..2059353d38 100644
923a60
--- a/src/core/load-fragment.h
923a60
+++ b/src/core/load-fragment.h
923a60
@@ -54,7 +54,7 @@ int config_parse_exec_cpu_sched_prio(const char *unit, const char *filename, uns
923a60
 int config_parse_exec_cpu_affinity(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
923a60
 int config_parse_exec_capabilities(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
923a60
 int config_parse_exec_secure_bits(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
923a60
-int config_parse_bounding_set(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
923a60
+int config_parse_capability_set(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
923a60
 int config_parse_limit(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
923a60
 int config_parse_bytes_limit(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
923a60
 int config_parse_sec_limit(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
923a60
diff --git a/src/core/main.c b/src/core/main.c
923a60
index a0df1e5cec..cba992cea2 100644
923a60
--- a/src/core/main.c
923a60
+++ b/src/core/main.c
923a60
@@ -108,7 +108,7 @@ static usec_t arg_runtime_watchdog = 0;
923a60
 static usec_t arg_shutdown_watchdog = 10 * USEC_PER_MINUTE;
923a60
 static char **arg_default_environment = NULL;
923a60
 static struct rlimit *arg_default_rlimit[_RLIMIT_MAX] = {};
923a60
-static uint64_t arg_capability_bounding_set_drop = 0;
923a60
+static uint64_t arg_capability_bounding_set = CAP_ALL;
923a60
 static nsec_t arg_timer_slack_nsec = NSEC_INFINITY;
923a60
 static usec_t arg_default_timer_accuracy_usec = 1 * USEC_PER_MINUTE;
923a60
 static Set* arg_syscall_archs = NULL;
923a60
@@ -642,7 +642,7 @@ static int parse_config_file(void) {
923a60
                 { "Manager", "JoinControllers",           config_parse_join_controllers, 0, &arg_join_controllers                  },
923a60
                 { "Manager", "RuntimeWatchdogSec",        config_parse_sec,              0, &arg_runtime_watchdog                  },
923a60
                 { "Manager", "ShutdownWatchdogSec",       config_parse_sec,              0, &arg_shutdown_watchdog                 },
923a60
-                { "Manager", "CapabilityBoundingSet",     config_parse_bounding_set,     0, &arg_capability_bounding_set_drop      },
923a60
+                { "Manager", "CapabilityBoundingSet",     config_parse_capability_set,   0, &arg_capability_bounding_set           },
923a60
 #ifdef HAVE_SECCOMP
923a60
                 { "Manager", "SystemCallArchitectures",   config_parse_syscall_archs,    0, &arg_syscall_archs                     },
923a60
 #endif
923a60
@@ -1622,14 +1622,14 @@ int main(int argc, char *argv[]) {
923a60
                 if (prctl(PR_SET_TIMERSLACK, arg_timer_slack_nsec) < 0)
923a60
                         log_error_errno(errno, "Failed to adjust timer slack: %m");
923a60
 
923a60
-        if (arg_capability_bounding_set_drop) {
923a60
-                r = capability_bounding_set_drop_usermode(arg_capability_bounding_set_drop);
923a60
+        if (!cap_test_all(arg_capability_bounding_set)) {
923a60
+                r = capability_bounding_set_drop_usermode(arg_capability_bounding_set);
923a60
                 if (r < 0) {
923a60
                         log_emergency_errno(r, "Failed to drop capability bounding set of usermode helpers: %m");
923a60
                         error_message = "Failed to drop capability bounding set of usermode helpers";
923a60
                         goto finish;
923a60
                 }
923a60
-                r = capability_bounding_set_drop(arg_capability_bounding_set_drop, true);
923a60
+                r = capability_bounding_set_drop(arg_capability_bounding_set, true);
923a60
                 if (r < 0) {
923a60
                         log_emergency_errno(r, "Failed to drop capability bounding set: %m");
923a60
                         error_message = "Failed to drop capability bounding set";
923a60
diff --git a/src/core/unit.c b/src/core/unit.c
923a60
index 4eb0d78f44..103f92084c 100644
923a60
--- a/src/core/unit.c
923a60
+++ b/src/core/unit.c
923a60
@@ -3213,7 +3213,7 @@ int unit_patch_contexts(Unit *u) {
923a60
                         ec->no_new_privileges = true;
923a60
 
923a60
                 if (ec->private_devices)
923a60
-                        ec->capability_bounding_set_drop |= (uint64_t) 1ULL << (uint64_t) CAP_MKNOD;
923a60
+                        ec->capability_bounding_set &= ~(UINT64_C(1) << CAP_MKNOD);
923a60
         }
923a60
 
923a60
         cc = unit_get_cgroup_context(u);
923a60
diff --git a/src/import/import-common.c b/src/import/import-common.c
923a60
index f10a453eed..243e657c56 100644
923a60
--- a/src/import/import-common.c
923a60
+++ b/src/import/import-common.c
923a60
@@ -526,7 +526,7 @@ int import_fork_tar(const char *path, pid_t *ret) {
923a60
                 if (unshare(CLONE_NEWNET) < 0)
923a60
                         log_error_errno(errno, "Failed to lock tar into network namespace, ignoring: %m");
923a60
 
923a60
-                r = capability_bounding_set_drop(~retain, true);
923a60
+                r = capability_bounding_set_drop(retain, true);
923a60
                 if (r < 0)
923a60
                         log_error_errno(r, "Failed to drop capabilities, ignoring: %m");
923a60
 
923a60
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
923a60
index a37b64094b..d0003d3790 100644
923a60
--- a/src/nspawn/nspawn.c
923a60
+++ b/src/nspawn/nspawn.c
923a60
@@ -1863,7 +1863,7 @@ static int setup_journal(const char *directory) {
923a60
 }
923a60
 
923a60
 static int drop_capabilities(void) {
923a60
-        return capability_bounding_set_drop(~arg_retain, false);
923a60
+        return capability_bounding_set_drop(arg_retain, false);
923a60
 }
923a60
 
923a60
 static int register_machine(pid_t pid, int local_ifindex) {
923a60
diff --git a/src/shared/capability.c b/src/shared/capability.c
923a60
index 2b963fde3f..3ed31df5ab 100644
923a60
--- a/src/shared/capability.c
923a60
+++ b/src/shared/capability.c
923a60
@@ -98,7 +98,7 @@ unsigned long cap_last_cap(void) {
923a60
         return p;
923a60
 }
923a60
 
923a60
-int capability_bounding_set_drop(uint64_t drop, bool right_now) {
923a60
+int capability_bounding_set_drop(uint64_t keep, bool right_now) {
923a60
         _cleanup_cap_free_ cap_t after_cap = NULL;
923a60
         cap_flag_value_t fv;
923a60
         unsigned long i;
923a60
@@ -139,7 +139,7 @@ int capability_bounding_set_drop(uint64_t drop, bool right_now) {
923a60
 
923a60
         for (i = 0; i <= cap_last_cap(); i++) {
923a60
 
923a60
-                if (drop & ((uint64_t) 1ULL << (uint64_t) i)) {
923a60
+                if (!(keep & (UINT64_C(1) << i))) {
923a60
                         cap_value_t v;
923a60
 
923a60
                         /* Drop it from the bounding set */
923a60
@@ -178,7 +178,7 @@ finish:
923a60
         return r;
923a60
 }
923a60
 
923a60
-static int drop_from_file(const char *fn, uint64_t drop) {
923a60
+static int drop_from_file(const char *fn, uint64_t keep) {
923a60
         int r, k;
923a60
         uint32_t hi, lo;
923a60
         uint64_t current, after;
923a60
@@ -198,7 +198,7 @@ static int drop_from_file(const char *fn, uint64_t drop) {
923a60
                 return -EIO;
923a60
 
923a60
         current = (uint64_t) lo | ((uint64_t) hi << 32ULL);
923a60
-        after = current & ~drop;
923a60
+        after = current & keep;
923a60
 
923a60
         if (current == after)
923a60
                 return 0;
923a60
@@ -215,14 +215,14 @@ static int drop_from_file(const char *fn, uint64_t drop) {
923a60
         return r;
923a60
 }
923a60
 
923a60
-int capability_bounding_set_drop_usermode(uint64_t drop) {
923a60
+int capability_bounding_set_drop_usermode(uint64_t keep) {
923a60
         int r;
923a60
 
923a60
-        r = drop_from_file("/proc/sys/kernel/usermodehelper/inheritable", drop);
923a60
+        r = drop_from_file("/proc/sys/kernel/usermodehelper/inheritable", keep);
923a60
         if (r < 0)
923a60
                 return r;
923a60
 
923a60
-        r = drop_from_file("/proc/sys/kernel/usermodehelper/bset", drop);
923a60
+        r = drop_from_file("/proc/sys/kernel/usermodehelper/bset", keep);
923a60
         if (r < 0)
923a60
                 return r;
923a60
 
923a60
@@ -259,7 +259,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
923a60
                 return log_error_errno(errno, "Failed to disable keep capabilities flag: %m");
923a60
 
923a60
         /* Drop all caps from the bounding set, except the ones we want */
923a60
-        r = capability_bounding_set_drop(~keep_capabilities, true);
923a60
+        r = capability_bounding_set_drop(keep_capabilities, true);
923a60
         if (r < 0)
923a60
                 return log_error_errno(r, "Failed to drop capabilities: %m");
923a60
 
923a60
diff --git a/src/shared/capability.h b/src/shared/capability.h
923a60
index 6f2f6f997d..04cd6e54e2 100644
923a60
--- a/src/shared/capability.h
923a60
+++ b/src/shared/capability.h
923a60
@@ -27,10 +27,12 @@
923a60
 
923a60
 #include "util.h"
923a60
 
923a60
+#define CAP_ALL (uint64_t) -1
923a60
+
923a60
 unsigned long cap_last_cap(void);
923a60
 int have_effective_cap(int value);
923a60
-int capability_bounding_set_drop(uint64_t drop, bool right_now);
923a60
-int capability_bounding_set_drop_usermode(uint64_t drop);
923a60
+int capability_bounding_set_drop(uint64_t keep, bool right_now);
923a60
+int capability_bounding_set_drop_usermode(uint64_t keep);
923a60
 
923a60
 int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilites);
923a60
 
923a60
@@ -44,3 +46,9 @@ static inline void cap_free_charpp(char **p) {
923a60
                 cap_free(*p);
923a60
 }
923a60
 #define _cleanup_cap_free_charp_ _cleanup_(cap_free_charpp)
923a60
+
923a60
+static inline bool cap_test_all(uint64_t caps) {
923a60
+        uint64_t m;
923a60
+        m = (UINT64_C(1) << (cap_last_cap() + 1)) - 1;
923a60
+        return (caps & m) == m;
923a60
+}
923a60
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
923a60
index 0f00a8fff1..38ecfe972e 100644
923a60
--- a/src/test/test-unit-file.c
923a60
+++ b/src/test/test-unit-file.c
923a60
@@ -550,6 +550,53 @@ static uint64_t make_cap(int cap) {
923a60
         return ((uint64_t) 1ULL << (uint64_t) cap);
923a60
 }
923a60
 
923a60
+static void test_config_parse_capability_set(void) {
923a60
+        /* int config_parse_capability_set(
923a60
+                 const char *unit,
923a60
+                 const char *filename,
923a60
+                 unsigned line,
923a60
+                 const char *section,
923a60
+                 unsigned section_line,
923a60
+                 const char *lvalue,
923a60
+                 int ltype,
923a60
+                 const char *rvalue,
923a60
+                 void *data,
923a60
+                 void *userdata) */
923a60
+        int r;
923a60
+        uint64_t capability_bounding_set = 0;
923a60
+
923a60
+        r = config_parse_capability_set(NULL, "fake", 1, "section", 1,
923a60
+                              "CapabilityBoundingSet", 0, "CAP_NET_RAW",
923a60
+                              &capability_bounding_set, NULL);
923a60
+        assert_se(r >= 0);
923a60
+        assert_se(capability_bounding_set == make_cap(CAP_NET_RAW));
923a60
+
923a60
+        r = config_parse_capability_set(NULL, "fake", 1, "section", 1,
923a60
+                              "CapabilityBoundingSet", 0, "CAP_NET_ADMIN",
923a60
+                              &capability_bounding_set, NULL);
923a60
+        assert_se(r >= 0);
923a60
+        assert_se(capability_bounding_set == (make_cap(CAP_NET_RAW) | make_cap(CAP_NET_ADMIN)));
923a60
+
923a60
+        r = config_parse_capability_set(NULL, "fake", 1, "section", 1,
923a60
+                              "CapabilityBoundingSet", 0, "",
923a60
+                              &capability_bounding_set, NULL);
923a60
+        assert_se(r >= 0);
923a60
+        assert_se(capability_bounding_set == UINT64_C(0));
923a60
+
923a60
+        r = config_parse_capability_set(NULL, "fake", 1, "section", 1,
923a60
+                              "CapabilityBoundingSet", 0, "~",
923a60
+                              &capability_bounding_set, NULL);
923a60
+        assert_se(r >= 0);
923a60
+        assert_se(cap_test_all(capability_bounding_set));
923a60
+
923a60
+        capability_bounding_set = 0;
923a60
+        r = config_parse_capability_set(NULL, "fake", 1, "section", 1,
923a60
+                              "CapabilityBoundingSet", 0, "  'CAP_NET_RAW' WAT_CAP??? CAP_NET_ADMIN CAP'_trailing_garbage",
923a60
+                              &capability_bounding_set, NULL);
923a60
+        assert_se(r >= 0);
923a60
+        assert_se(capability_bounding_set == (make_cap(CAP_NET_RAW) | make_cap(CAP_NET_ADMIN)));
923a60
+}
923a60
+
923a60
 static void test_config_parse_rlimit(void) {
923a60
         struct rlimit * rl[_RLIMIT_MAX] = {};
923a60
 
923a60
@@ -665,46 +712,6 @@ static void test_config_parse_rlimit(void) {
923a60
         free(rl[RLIMIT_RTTIME]);
923a60
 }
923a60
 
923a60
-static void test_config_parse_bounding_set(void) {
923a60
-        /* int config_parse_bounding_set(
923a60
-                 const char *unit,
923a60
-                 const char *filename,
923a60
-                 unsigned line,
923a60
-                 const char *section,
923a60
-                 unsigned section_line,
923a60
-                 const char *lvalue,
923a60
-                 int ltype,
923a60
-                 const char *rvalue,
923a60
-                 void *data,
923a60
-                 void *userdata) */
923a60
-        int r;
923a60
-        uint64_t capability_bounding_set_drop = 0;
923a60
-
923a60
-        r = config_parse_bounding_set(NULL, "fake", 1, "section", 1,
923a60
-                              "CapabilityBoundingSet", 0, "CAP_NET_RAW",
923a60
-                              &capability_bounding_set_drop, NULL);
923a60
-        assert_se(r >= 0);
923a60
-        assert_se(capability_bounding_set_drop == ~make_cap(CAP_NET_RAW));
923a60
-
923a60
-        r = config_parse_bounding_set(NULL, "fake", 1, "section", 1,
923a60
-                              "CapabilityBoundingSet", 0, "CAP_NET_ADMIN",
923a60
-                              &capability_bounding_set_drop, NULL);
923a60
-        assert_se(r >= 0);
923a60
-        assert_se(capability_bounding_set_drop == ~(make_cap(CAP_NET_RAW) | make_cap(CAP_NET_ADMIN)));
923a60
-
923a60
-        r = config_parse_bounding_set(NULL, "fake", 1, "section", 1,
923a60
-                              "CapabilityBoundingSet", 0, "",
923a60
-                              &capability_bounding_set_drop, NULL);
923a60
-        assert_se(r >= 0);
923a60
-        assert_se(capability_bounding_set_drop == ~((uint64_t) 0ULL));
923a60
-
923a60
-        r = config_parse_bounding_set(NULL, "fake", 1, "section", 1,
923a60
-                              "CapabilityBoundingSet", 0, "~",
923a60
-                              &capability_bounding_set_drop, NULL);
923a60
-        assert_se(r >= 0);
923a60
-        assert_se(capability_bounding_set_drop == (uint64_t) 0ULL);
923a60
-}
923a60
-
923a60
 int main(int argc, char *argv[]) {
923a60
         int r;
923a60
 
923a60
@@ -713,8 +720,8 @@ int main(int argc, char *argv[]) {
923a60
 
923a60
         r = test_unit_file_get_set();
923a60
         test_config_parse_exec();
923a60
+        test_config_parse_capability_set();
923a60
         test_config_parse_rlimit();
923a60
-        test_config_parse_bounding_set();
923a60
         test_load_env_file_1();
923a60
         test_load_env_file_2();
923a60
         test_load_env_file_3();