On Tue, Oct 6, 2015 at 5:16 AM, Han-Wen Nienhuys <
han...@google.com> wrote:
> Since we default to sandboxed execution wrt files, let's also make the
> default cut off network access, with some option,
>
> tags = [ "network-access" ]
>
> to switch it on again.
>
> Setting the UID to root is a little tricky: we have seen a bunch of
> code that uses (getuid() == 0) and then assumes it has certain
> capabilities.
According to Linux manual
page(
http://man7.org/linux/man-pages/man7/user_namespaces.7.html) and
my test, creating a new namespace will give the user full
capabilities, but "Having a capability inside a user namespace permits
a process to perform operations (that require privilege) *only on
resources governed by that namespace*".
So without creating network namespace, the user won't be able to
perform privileged network operation, after being dropped in a new
network namespace, the user should be able perform privileged network
operation, like bringing up interface(which is done in the code too),
creating new virtual interface, capturing packet, etc. Since the check
is based on capability list, the UID/GID shouldn't really matter this
case, but I couldn't explain why ping program doesn't work as nobody,
unless setuid-ed program has special check based on whether it's
nobody.