]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: use lxc_preserve_ns()
authorChristian Brauner <christian.brauner@canonical.com>
Fri, 28 Oct 2016 10:33:30 +0000 (12:33 +0200)
committerChristian Brauner <christian.brauner@canonical.com>
Sat, 19 Nov 2016 04:11:25 +0000 (05:11 +0100)
Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
src/lxc/attach.c

index 99b07fa429a1a6191726821c1c2d49902c2fe600..9fe66a8e9962b21faaba7b6761dae1c53f2c2fdf 100644 (file)
@@ -222,7 +222,7 @@ static int lxc_attach_to_ns(pid_t pid, int which)
 {
        char path[MAXPATHLEN];
        /* according to <http://article.gmane.org/gmane.linux.kernel.containers.lxc.devel/1429>,
-        * the file for user namepsaces in /proc/$pid/ns will be called
+        * the file for user namespaces in /proc/$pid/ns will be called
         * 'user' once the kernel supports it
         */
        static char *ns[] = { "user", "mnt", "pid", "uts", "ipc", "net", "cgroup" };
@@ -250,8 +250,7 @@ static int lxc_attach_to_ns(pid_t pid, int which)
                        continue;
                }
 
-               snprintf(path, MAXPATHLEN, "/proc/%d/ns/%s", pid, ns[i]);
-               fd[i] = open(path, O_RDONLY | O_CLOEXEC);
+               fd[i] = lxc_preserve_ns(pid, ns[i]);
                if (fd[i] < 0) {
                        saved_errno = errno;