]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: do not fail on non-existing namespaces
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 4 Dec 2017 11:26:55 +0000 (12:26 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 15 Dec 2017 11:42:33 +0000 (12:42 +0100)
Closes #1993.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c
src/lxc/utils.c

index 44ac31edd039c40cc934046aa4e5a81caf3aaa3b..afe9ab8afb6f2bd8f961df1ebf0c4edd493d1f0f 100644 (file)
@@ -281,8 +281,15 @@ static int in_same_namespace(pid_t pid1, pid_t pid2, const char *ns)
        struct stat ns_st1, ns_st2;
 
        ns_fd1 = lxc_preserve_ns(pid1, ns);
-       if (ns_fd1 < 0)
+       if (ns_fd1 < 0) {
+               /* The kernel does not support this namespace. This is not an
+                * error.
+                */
+               if (errno == ENOENT)
+                       return -EINVAL;
+
                goto out;
+       }
 
        ns_fd2 = lxc_preserve_ns(pid2, ns);
        if (ns_fd2 < 0)
index bfacbf45f30fccfb7a91eedee91edac87c97374b..086e28f4bd8586d620204112f62a7d659dc02f50 100644 (file)
@@ -1967,8 +1967,9 @@ int lxc_preserve_ns(const int pid, const char *ns)
        ret = snprintf(path, __NS_PATH_LEN, "/proc/%d/ns%s%s", pid,
                       !ns || strcmp(ns, "") == 0 ? "" : "/",
                       !ns || strcmp(ns, "") == 0 ? "" : ns);
+       errno = EFBIG;
        if (ret < 0 || (size_t)ret >= __NS_PATH_LEN)
-               return -1;
+               return -EFBIG;
 
        return open(path, O_RDONLY | O_CLOEXEC);
 }