From: Lennart Poettering Date: Thu, 6 Feb 2025 22:01:37 +0000 (+0100) Subject: tree-wide: pass EBADF to fd params of namespace_fork() X-Git-Tag: v258-rc1~1299^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e0193aabf8de15a9e7d424bf774618f5853886f;p=thirdparty%2Fsystemd.git tree-wide: pass EBADF to fd params of namespace_fork() --- diff --git a/src/machine/machined-core.c b/src/machine/machined-core.c index 90fd91f134c..5c6d2250519 100644 --- a/src/machine/machined-core.c +++ b/src/machine/machined-core.c @@ -230,11 +230,11 @@ int machine_get_addresses(Machine *machine, struct local_address **ret_addresses /* except_fds = */ NULL, /* n_except_fds = */ 0, FORK_RESET_SIGNALS|FORK_DEATHSIG_SIGKILL, - /* pidns_fd = */ -1, - /* mntns_fd = */ -1, + /* pidns_fd = */ -EBADF, + /* mntns_fd = */ -EBADF, netns_fd, - /* userns_fd = */ -1, - /* root_fd = */ -1, + /* userns_fd = */ -EBADF, + /* root_fd = */ -EBADF, &child); if (r < 0) return log_debug_errno(r, "Failed to fork(): %m"); @@ -347,8 +347,8 @@ int machine_get_os_release(Machine *machine, char ***ret_os_release) { FORK_RESET_SIGNALS|FORK_DEATHSIG_SIGKILL, pidns_fd, mntns_fd, - /* netns_fd = */ -1, - /* userns_fd = */ -1, + /* netns_fd = */ -EBADF, + /* userns_fd = */ -EBADF, root_fd, &child); if (r < 0) diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c index 75a18051bc1..d4718251623 100644 --- a/src/shared/mount-util.c +++ b/src/shared/mount-util.c @@ -1038,8 +1038,18 @@ static int mount_in_namespace_legacy( goto finish; } - r = namespace_fork("(sd-bindmnt)", "(sd-bindmnt-inner)", NULL, 0, FORK_RESET_SIGNALS|FORK_DEATHSIG_SIGTERM, - pidns_fd, mntns_fd, -1, -1, root_fd, &child); + r = namespace_fork( + "(sd-bindmnt)", + "(sd-bindmnt-inner)", + /* except_fds= */ NULL, + /* n_except_fds= */ 0, + FORK_RESET_SIGNALS|FORK_DEATHSIG_SIGTERM, + pidns_fd, + mntns_fd, + /* netns_fd= */ -EBADF, + /* userns_fd= */ -EBADF, + root_fd, + &child); if (r < 0) goto finish; if (r == 0) {