From: Christian Brauner Date: Mon, 1 Feb 2021 11:23:26 +0000 (+0100) Subject: attach: simplify opening of /proc/self X-Git-Tag: lxc-5.0.0~309^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=595798bbcae788d38390ccd457269c6632344928;p=thirdparty%2Flxc.git attach: simplify opening of /proc/self Signed-off-by: Christian Brauner --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index 6af3bdf64..3543ad331 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -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");