summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-02-01 00:52:59 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-02-01 01:19:52 +0900
commitd754890843db3c2784b4299fc9b9b6968e2ad533 (patch)
tree3b4a2225beeeb40f6b231bc3ddad768dd481435c
parent43f565c6770f940a978a5325fea8b0e6d8ee4c99 (diff)
downloadsystemd-d754890843db3c2784b4299fc9b9b6968e2ad533.tar.gz
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.
-rw-r--r--src/home/homed-home.c4
-rw-r--r--src/import/importd.c5
2 files changed, 9 insertions, 0 deletions
diff --git a/src/home/homed-home.c b/src/home/homed-home.c
index 38b7e20ca6..2ea0f7c81d 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 345fc7c2cb..65fe3701c6 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: