If we're not running as root, bubblewrap will unshare a user namespace
in which it gets a full set of capabilities, even if the user on the
host doesn't have them, so let's only do the CAP_NET_ADMIN check if
we're running as root.
cmdline += [
"bwrap",
- *(["--unshare-net"] if not network and have_effective_cap(Capability.CAP_NET_ADMIN) else []),
+ *(
+ ["--unshare-net"]
+ if not network and (os.getuid() != 0 or have_effective_cap(Capability.CAP_NET_ADMIN))
+ else []
+ ),
"--die-with-parent",
"--proc", "/proc",
"--setenv", "SYSTEMD_OFFLINE", one_zero(network),