r/linuxadmin • u/lescuer97 • Jan 15 '26
systemd user-space daemon capabilities problems
Hi! I have encountered an issue while trying to run a user-space daemon using a binary with cap_net_admin capabilities. This binary is intended to bring network interfaces up and down and perform certain modifications.
When I run the binary directly, it works perfectly. However, when I run it as a systemd user service, I receive an 'operation not permitted' error. I would like to avoid using a system-level service for this if possible.
Is there a way to fix this, or are there any other alternatives? Thank you!
5
Upvotes
View all comments
Show parent comment
3
u/aioeu Jan 16 '26 edited Jan 16 '26
NoNewPrivileges=falseis the default (at least, if you haven't set this totruethrough/etc/systemd/user.confsay), so it's very surprising that removing that would make any difference.But the other directives imply the use of mount namespaces, and when that is done by the user systemd manager it has to create a new user namespace as well.
Capabilities are always tested with respect to a particular user namespace. For instance, when the kernel is asked to bring a network link up or down, it tests the process's
CAP_NET_ADMINcapability, but the user namespace it uses for that test is the user namespace that owns the link's network namespace. If that network namespace is not owned by process's user namespace, then that process cannot manipulate the network link, even if it has theCAP_NET_ADMINcapability in its own user namespace.We can see this in action:
In the first command, we can see all the non-user namespaces are owned by a single user namespace. In the second command, the new mount namespace is owned by the new user namespace. The other namespaces are owned by the old user namespace ... but that namespace isn't actually accessible, of course, so they appear to have no owner namespace.