about summary refs log tree commit diff
path: root/nixpkgs/pkgs/os-specific/linux/systemd/0012-inherit-systemd-environment-when-calling-generators.patch
blob: 0576f7a62f2c9cc6c7260174c4f4df4a4e781898 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From ecdf0c5d9f88f526521f093cc9ee85f43efab4b7 Mon Sep 17 00:00:00 2001
From: Andreas Rammhold <andreas@rammhold.de>
Date: Fri, 2 Nov 2018 21:15:42 +0100
Subject: [PATCH 12/21] inherit systemd environment when calling generators.

Systemd generators need access to the environment configured in
stage-2-init.sh since it schedules fsck and mkfs executions based on
being able to find an appropriate binary for the target filesystem.

With this commit I am altering the systemd behaviour since upstream
tries to gather environments with that they call
"environment-generators" and then seems to pass that on to all the other
executables that are being called from managers.
---
 src/core/manager.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/core/manager.c b/src/core/manager.c
index b9b4789720..79239afe4a 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -4149,10 +4149,15 @@ static int manager_run_generators(Manager *m) {
         argv[4] = NULL;
 
         RUN_WITH_UMASK(0022)
-                (void) execute_directories((const char* const*) paths, DEFAULT_TIMEOUT_USEC, NULL, NULL,
-                                           (char**) argv, m->transient_environment,
-                                           EXEC_DIR_PARALLEL | EXEC_DIR_IGNORE_ERRORS | EXEC_DIR_SET_SYSTEMD_EXEC_PID);
-
+                (void) execute_directories((const char* const*) paths, DEFAULT_TIMEOUT_USEC,
+                                    // On NixOS we must propagate PATH to generators so they are
+                                    // able to find binaries such as `fsck.${fstype}` and
+                                    // `mkfs.${fstype}`. That is why the last argument of the
+                                    // function (envp) is set to NULL. This propagates systemd's
+                                    // environment (e.g. PATH) that was setup
+                                    // before calling systemd from stage-2-init.sh.
+                                    NULL, NULL, (char**) argv, /* NixOS: use inherited env */ NULL,
+                                    EXEC_DIR_PARALLEL | EXEC_DIR_IGNORE_ERRORS | EXEC_DIR_SET_SYSTEMD_EXEC_PID);
         r = 0;
 
 finish:
-- 
2.33.0