]> 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>
Sun, 17 Dec 2017 14:50:40 +0000 (15:50 +0100)
Closes #1993.

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

index 611432416ebd9578191d689f260cb36ba4982649..4ccf5c4a5d9993f24c9e336c7c8c50412a8f8699 100644 (file)
@@ -273,8 +273,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 936603d8252d7f71beb9994e1d521c92a0f8d471..148f23429e7c7fcae6e494a3c96c13567cdf8ef5 100644 (file)
@@ -1964,8 +1964,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);
 }