summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-02-13 14:07:59 +0100
committerLennart Poettering <lennart@poettering.net>2014-02-13 14:07:59 +0100
commita42c8b54b1619078c02f5e439bd2564c6d0f901f (patch)
treed22e4c62c4c254bbdc1eb2c356a7bfbe10a79d70 /src
parentd595c5cc9e894c3608ed634052b0ba93aa94bf2f (diff)
nspawn: --private-network should imply CAP_NET_ADMIN
Diffstat (limited to 'src')
-rw-r--r--src/nspawn/nspawn.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 679c005071..9ce1fa9b49 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -216,6 +216,7 @@ static int parse_argv(int argc, char *argv[]) {
};
int c, r;
+ uint64_t plus = 0, minus = 0;
assert(argc >= 0);
assert(argv);
@@ -325,9 +326,9 @@ static int parse_argv(int argc, char *argv[]) {
if (streq(t, "all")) {
if (c == ARG_CAPABILITY)
- arg_retain = (uint64_t) -1;
+ plus = (uint64_t) -1;
else
- arg_retain = 0;
+ minus = (uint64_t) -1;
} else {
if (cap_from_name(t, &cap) < 0) {
log_error("Failed to parse capability %s.", t);
@@ -335,9 +336,9 @@ static int parse_argv(int argc, char *argv[]) {
}
if (c == ARG_CAPABILITY)
- arg_retain |= 1ULL << (uint64_t) cap;
+ plus |= 1ULL << (uint64_t) cap;
else
- arg_retain &= ~(1ULL << (uint64_t) cap);
+ minus |= 1ULL << (uint64_t) cap;
}
}
@@ -460,6 +461,8 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
}
+ arg_retain = (arg_retain | plus | (arg_private_network ? 1ULL << CAP_NET_ADMIN : 0)) & ~minus;
+
return 1;
}