nspawn: Allow Capability= to overrule private network setting
authorTorsten Hilbrich <torsten.hilbrich@secunet.com>
Tue, 12 Nov 2019 07:36:06 +0000 (08:36 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 15 Nov 2019 09:13:51 +0000 (10:13 +0100)
commit7be830c6e8cd3852e3468203812445115f5ea183
tree1cf4abae7ed2bdbd55909ac6329c5c35ce613bb8
parent7edd8fb198f3e8a95677df8a8f5016ed40dcff54
nspawn: Allow Capability= to overrule private network setting

The commit:

a3fc6b55ac nspawn: mask out CAP_NET_ADMIN again if settings file turns off private networking

turned off the CAP_NET_ADMIN capability whenever no private networking
feature was enabled. This broke configurations where the CAP_NET_ADMIN
capability was explicitly requested in the configuration.

Changing the order of evalution here to allow the Capability= setting
to overrule this implicit setting:

Order of evaluation:

1. if no private network setting is enabled, CAP_NET_ADMIN is removed
2. if a private network setting is enabled, CAP_NET_ADMIN is added
3. the settings of Capability= are added
4. the settings of DropCapability= are removed

This allows the fix for #11755 to be retained and to still allow the
admin to specify CAP_NET_ADMIN as additional capability.

Fixes: a3fc6b55acd3f37e50915304d87bed100efa9d9d
Fixes: #13995
src/nspawn/nspawn.c