]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
nsenter: keep semantic consistent
authorKarel Zak <kzak@redhat.com>
Thu, 8 Jan 2015 11:27:59 +0000 (12:27 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 9 Jan 2015 09:36:01 +0000 (10:36 +0100)
The current nseneter behavior is inconsistent and depends on way how
namespace is specified on command line

    # nsenter --user
vs.
    # nseneter --user=filename

if the namespace is specified by <filename> than nsenter does not do
additinal setting and actions (e.g. does not call setgroups, setuid).
This is bug.

Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/nsenter.c

index e00a3e47273b9db4dc6d7e3e694e125a1f018faf..50f77f3819d1d792d6622a0d8566cd9aae05f9b4 100644 (file)
@@ -283,6 +283,15 @@ int main(int argc, char *argv[])
        if (do_wd)
                open_target_fd(&wd_fd, "cwd", NULL);
 
+       /*
+        * Update namespaces variable to contain all requested namespaces
+        */
+       for (nsfile = namespace_files; nsfile->nstype; nsfile++) {
+               if (nsfile->fd < 0)
+                       continue;
+               namespaces |= nsfile->nstype;
+       }
+
        /*
         * Now that we know which namespaces we want to enter, enter them.
         */