]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
execute: also control the SYSTEMD_NSS_BYPASS_BUS through an ExecFlags field
authorLennart Poettering <lennart@poettering.net>
Tue, 1 Aug 2017 08:43:04 +0000 (10:43 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 10 Aug 2017 13:02:49 +0000 (15:02 +0200)
Also, correct the logic while we are at it: the variable is only
required for system services, not user services.

src/core/execute.c
src/core/execute.h
src/core/service.c

index 2453cb298c81a177561faa5f4edc4cc18e9a1992..9498ebe09876f1eb11483bd9853b0255f3abee10 100644 (file)
@@ -1536,7 +1536,7 @@ static int build_environment(
         /* If this is D-Bus, tell the nss-systemd module, since it relies on being able to use D-Bus look up dynamic
          * users via PID 1, possibly dead-locking the dbus daemon. This way it will not use D-Bus to resolve names, but
          * check the database directly. */
-        if (unit_has_name(u, SPECIAL_DBUS_SERVICE)) {
+        if (p->flags & EXEC_NSS_BYPASS_BUS) {
                 x = strdup("SYSTEMD_NSS_BYPASS_BUS=1");
                 if (!x)
                         return -ENOMEM;
index 1560aff7fd073e69f1fa375c1b40ee8a2bb96ce7..14a3bdde1f5dfdaabf9d831e32d8110213a2d13d 100644 (file)
@@ -261,12 +261,13 @@ typedef enum ExecFlags {
         EXEC_NEW_KEYRING       = 1U << 3,
         EXEC_PASS_LOG_UNIT     = 1U << 4, /* Whether to pass the unit name to the service's journal stream connection */
         EXEC_CHOWN_DIRECTORIES = 1U << 5, /* chown() the runtime/state/cache/log directories to the user we run as, under all conditions */
+        EXEC_NSS_BYPASS_BUS    = 1U << 6, /* Set the SYSTEMD_NSS_BYPASS_BUS environment variable, to disable nss-systemd for dbus */
 
         /* The following are not used by execute.c, but by consumers internally */
-        EXEC_PASS_FDS          = 1U << 6,
-        EXEC_IS_CONTROL        = 1U << 7,
-        EXEC_SETENV_RESULT     = 1U << 8,
-        EXEC_SET_WATCHDOG      = 1U << 9,
+        EXEC_PASS_FDS          = 1U << 7,
+        EXEC_IS_CONTROL        = 1U << 8,
+        EXEC_SETENV_RESULT     = 1U << 9,
+        EXEC_SET_WATCHDOG      = 1U << 10,
 } ExecFlags;
 
 struct ExecParameters {
index 04ec3ac90eba9629adacb7f0e9603189bc5997d0..01cc0a5d2a32b40b0518f094d77297020834f89c 100644 (file)
@@ -1360,6 +1360,11 @@ static int service_spawn(
 
         /* System services should get a new keyring by default. */
         SET_FLAG(exec_params.flags, EXEC_NEW_KEYRING, MANAGER_IS_SYSTEM(UNIT(s)->manager));
+
+        /* System D-Bus needs nss-systemd disabled, so that we don't deadlock */
+        SET_FLAG(exec_params.flags, EXEC_NSS_BYPASS_BUS,
+                 MANAGER_IS_SYSTEM(UNIT(s)->manager) && unit_has_name(UNIT(s), SPECIAL_DBUS_SERVICE));
+
         exec_params.argv = c->argv;
         exec_params.environment = final_env;
         exec_params.fds = fds;