]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
daemon-util: remove existing fds with the same name from fdstore 37162/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 18 Apr 2025 00:00:35 +0000 (09:00 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 18 Apr 2025 00:12:43 +0000 (09:12 +0900)
Currently, all use cases of notify_push_fd()/notify_push_fdf()
assume that the name of each fd in the fdstore is unique.
For safety, let's remove the existing fds before pushing a new one
to avoid multiple fds with the same name stored in the fdstore.

src/shared/daemon-util.c
src/udev/udev-config.c

index e83ca8f663782c26ee3714829386ad8bb48dca1a..85d94336263cc2e86f07bf8f321d58d3c370c00b 100644 (file)
@@ -56,6 +56,9 @@ int notify_push_fd(int fd, const char *name) {
         if (!state)
                 return -ENOMEM;
 
+        /* Remove existing fds with the same name in fdstore. */
+        (void) notify_remove_fd_warn(name);
+
         return sd_pid_notify_with_fds(0, /* unset_environment = */ false, state, &fd, 1);
 }
 
index 52855145da7071f1a6d8d742b4f696f75a2a2cb5..ef0ee0abd691206ba7089c66fc14fa2ad14f7517 100644 (file)
@@ -553,9 +553,6 @@ int manager_serialize_config(Manager *manager) {
         if (r < 0)
                 return log_warning_errno(r, "Failed to finalize serialization file: %m");
 
-        /* Remove the previous serialization to make it replaced with the new one. */
-        (void) notify_remove_fd_warn("config-serialization");
-
         r = notify_push_fd(fileno(f), "config-serialization");
         if (r < 0)
                 return log_warning_errno(r, "Failed to push serialization fd to service manager: %m");