From: Yu Watanabe Date: Sun, 31 Jan 2021 15:52:59 +0000 (+0900) Subject: import,home: update $SYSTEMD_EXEC_PID= if it is set X-Git-Tag: v248-rc1~187^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d754890843db3c2784b4299fc9b9b6968e2ad533;p=thirdparty%2Fsystemd.git import,home: update $SYSTEMD_EXEC_PID= if it is set The subsequent execv() or execl() always calls tools provided by systemd. So, it is safe to update the variable. --- diff --git a/src/home/homed-home.c b/src/home/homed-home.c index 38b7e20ca61..2ea0f7c81d9 100644 --- a/src/home/homed-home.c +++ b/src/home/homed-home.c @@ -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"); diff --git a/src/import/importd.c b/src/import/importd.c index 345fc7c2cb2..65fe3701c62 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -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: