From: Karel Zak Date: Wed, 18 Feb 2026 09:47:19 +0000 (+0100) Subject: nsenter: fix minor issues with namespace ID support X-Git-Tag: v2.43-devel~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=611a54c76e813bfe18ff013efd1f984822d60a1d;p=thirdparty%2Futil-linux.git nsenter: fix minor issues with namespace ID support - fix pidfd_self FD leak when ioctl(PIDFD_GET_MNT_NAMESPACE) fails - fix "namesapces" typo in man page - document "./" disambiguation for files starting with ":" - use standard C initializer = { 0 } instead of = {} Addresses: https://github.com/util-linux/util-linux/pull/4044 Signed-off-by: Karel Zak --- diff --git a/sys-utils/nsenter.1.adoc b/sys-utils/nsenter.1.adoc index 3dec46d66..9e5bc81da 100644 --- a/sys-utils/nsenter.1.adoc +++ b/sys-utils/nsenter.1.adoc @@ -161,7 +161,8 @@ include::man-common/help-version.adoc[] The *--user-parent* option requires Linux 4.9 or higher, older kernels will raise inappropriate ioctl for device error. -Specifying namesapces by _nsid_ requires Linux 6.19 or higher. +Specifying namespaces by _nsid_ requires Linux 6.19 or higher. If a namespace +file name starts with a colon, prepend "./" for disambiguation. == AUTHORS diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c index 2820a7123..d6d9a58cd 100644 --- a/sys-utils/nsenter.c +++ b/sys-utils/nsenter.c @@ -179,7 +179,7 @@ static void open_target_fd(int *fd, const char *type, const char *path) #ifdef HAVE_STRUCT_NSFS_FILE_HANDLE -static struct file_handle nsfs_fh_tmpl = {}; +static struct file_handle nsfs_fh_tmpl = { 0 }; static int nsfs_fd = -1; static int fill_nsfs_file_handle(struct file_handle *fh, uint64_t ns_id) @@ -210,9 +210,9 @@ static int fill_nsfs_file_handle(struct file_handle *fh, uint64_t ns_id) /* Mount namespace can not be disabled by kernel config */ nsfs_fd = ioctl(pidfd_self, PIDFD_GET_MNT_NAMESPACE, 0); + close(pidfd_self); if (nsfs_fd < 0) return -errno; - close(pidfd_self); fh->handle_bytes = sizeof(struct nsfs_file_handle); if (name_to_handle_at(nsfs_fd, "", fh, &mount_id,