Skip to content

Commit

Permalink
attach: use lxc_preserve_ns()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
  • Loading branch information
Christian Brauner committed Nov 19, 2016
1 parent 64d2fcb commit 383613c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/lxc/attach.c
Expand Up @@ -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" };
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 383613c

Please sign in to comment.