]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: pass EBADF to fd params of namespace_fork()
authorLennart Poettering <lennart@poettering.net>
Thu, 6 Feb 2025 22:01:37 +0000 (23:01 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 18 Feb 2025 11:11:00 +0000 (12:11 +0100)
src/machine/machined-core.c
src/shared/mount-util.c

index 90fd91f134c816448571ec30f9a046bafad9e99f..5c6d225051901b60473f4278501772dbbbec8ca5 100644 (file)
@@ -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)
index 75a18051bc1184052a4e8331f14901f9d1fbdf87..d4718251623f4f3ccf2a3bb1b3722de95e119075 100644 (file)
@@ -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) {