]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
nsenter: fix minor issues with namespace ID support
authorKarel Zak <kzak@redhat.com>
Wed, 18 Feb 2026 09:47:19 +0000 (10:47 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 18 Feb 2026 09:47:19 +0000 (10:47 +0100)
- 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 <kzak@redhat.com>
sys-utils/nsenter.1.adoc
sys-utils/nsenter.c

index 3dec46d665c07e9927a612aa5cf01503682222c4..9e5bc81dab5e2f1d33fda68e759f71a5198c0de3 100644 (file)
@@ -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
 
index 2820a7123bc5fc09303c94a1d98ba4f5e63a92b4..d6d9a58cd905d4b27d10ea362f451e539b46ac17 100644 (file)
@@ -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,