From: Vladimir Riabchun Date: Wed, 10 Jun 2026 13:28:48 +0000 (+0200) Subject: nsenter: Fix invalid fd check in enter_namespaces X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40449fc62d803917bdee0908eab2f174065c5cf9;p=thirdparty%2Futil-linux.git nsenter: Fix invalid fd check in enter_namespaces When nsenter is executed with closed stdin, one pid_fd will be 0, which is a valid file descriptor. But with current code namespace switch is skipped, leading to incorrect results. Fixes: f18be0ca5aa7 ("nsenter: use pidfd to enter target namespaces") Signed-off-by: Vladimir Riabchun --- diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c index b10c5773f..c1706cef9 100644 --- a/sys-utils/nsenter.c +++ b/sys-utils/nsenter.c @@ -356,7 +356,7 @@ static void enter_namespaces(int pid_fd, int namespaces, bool ignore_errors) { struct namespace_file *n = NULL; - if (pid_fd) { + if (pid_fd >= 0) { int ns = 0; while ((n = next_enabled_nsfile(n, namespaces))) { if (n->fd < 0)