]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
import,home: update $SYSTEMD_EXEC_PID= if it is set
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 31 Jan 2021 15:52:59 +0000 (00:52 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 31 Jan 2021 16:19:52 +0000 (01:19 +0900)
The subsequent execv() or execl() always calls tools provided by
systemd. So, it is safe to update the variable.

src/home/homed-home.c
src/import/importd.c

index 38b7e20ca61fdde19fe1d1ae41b89a41b679af31..2ea0f7c81d951a9815584e282e78de454a9ca091 100644 (file)
@@ -1038,6 +1038,10 @@ static int home_start_work(Home *h, const char *verb, UserRecord *hr, UserRecord
                                 _exit(EXIT_FAILURE);
                         }
 
+                r = setenv_systemd_exec_pid(true);
+                if (r < 0)
+                        log_warning_errno(r, "Failed to update $SYSTEMD_EXEC_PID, ignoring: %m");
+
                 r = rearrange_stdio(stdin_fd, stdout_fd, STDERR_FILENO);
                 if (r < 0) {
                         log_error_errno(r, "Failed to rearrange stdin/stdout/stderr: %m");
index 345fc7c2cb204544e42cc961ca6a7b3144aa564a..65fe3701c6250d535730788d5dfc28a0406b2818 100644 (file)
@@ -11,6 +11,7 @@
 #include "bus-log-control-api.h"
 #include "bus-polkit.h"
 #include "def.h"
+#include "env-util.h"
 #include "fd-util.h"
 #include "float.h"
 #include "hostname-util.h"
@@ -403,6 +404,10 @@ static int transfer_start(Transfer *t) {
                         _exit(EXIT_FAILURE);
                 }
 
+                r = setenv_systemd_exec_pid(true);
+                if (r < 0)
+                        log_warning_errno(r, "Failed to update $SYSTEMD_EXEC_PID, ignoring: %m");
+
                 switch (t->type) {
 
                 case TRANSFER_IMPORT_TAR: