]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: do not fail on non-existing namespaces 1994/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 4 Dec 2017 11:26:55 +0000 (12:26 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 4 Dec 2017 11:26:55 +0000 (12:26 +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 67c475e78a4d4b9d21bf01b64a6e6871d2c9e03b..c597be8fa16176db67667598a4eccd29367bfb39 100644 (file)
@@ -1906,8 +1906,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);
 }