]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: simplify opening of /proc/self
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 1 Feb 2021 11:23:26 +0000 (12:23 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 1 Feb 2021 13:41:09 +0000 (14:41 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c

index 6af3bdf64d8c7e311cdf6bd2be15a0b38b6b1900..3543ad331a523d4574fd054fc27d978b8d802237 100644 (file)
@@ -361,11 +361,7 @@ static int get_attach_context(struct attach_context *ctx,
        if (ctx->init_pid < 0)
                return log_error(-1, "Failed to get init pid");
 
-       ret = snprintf(path, sizeof(path), "/proc/%d", lxc_raw_getpid());
-       if (ret < 0 || ret >= sizeof(path))
-               return ret_errno(EIO);
-
-       ctx->dfd_self_pid = openat(-EBADF, path, O_CLOEXEC | O_NOCTTY | O_NOFOLLOW | O_PATH | O_DIRECTORY);
+       ctx->dfd_self_pid = openat(-EBADF, "/proc/self", O_CLOEXEC | O_NOCTTY | O_PATH | O_DIRECTORY);
        if (ctx->dfd_self_pid < 0)
                return log_error_errno(-errno, errno, "Failed to open /proc/self");