]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Revert "pam_systemd: drop setting DBUS_SESSION_BUS_ADDRESS"
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 4 Jan 2019 10:19:10 +0000 (11:19 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 4 Jan 2019 10:19:10 +0000 (11:19 +0100)
This reverts commit 2b2b7228bffef626fe8e9f131095995f3d50ee3b.

Fixes #11293.

Removing the environment variable causes problems, e.g. Xfce and Chromium and
... don't communicate with the running dbus instance. If they attempt to start their
own instance, things become even more confusing. Those packages could be fixed
one by one, but removing the variable right now is causing too many problems.

README
src/login/pam_systemd.c

diff --git a/README b/README
index 4439be11f034c1b0b0bd03981498b2fa09619766..baabf69c7ca4c4667693a2687a7dcd3afcbe3cee 100644 (file)
--- a/README
+++ b/README
@@ -170,7 +170,7 @@ REQUIREMENTS:
         dependencies:
 
         util-linux >= v2.27.1 required
-        dbus >= 1.9.14 (strictly speaking optional, but recommended)
+        dbus >= 1.4.0 (strictly speaking optional, but recommended)
                 NOTE: If using dbus < 1.9.18, you should override the default
                 policy directory (--with-dbuspolicydir=/etc/dbus-1/system.d).
         dracut (optional)
index c7d9dcf4e207a6d7f6fb7f19484d865dbd2d1b59..cdec102cea16a238b5c60fa3c702c5d7c8934bf3 100644 (file)
@@ -190,6 +190,40 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_
         return 0;
 }
 
+static int export_legacy_dbus_address(
+                pam_handle_t *handle,
+                uid_t uid,
+                const char *runtime) {
+
+        _cleanup_free_ char *s = NULL;
+        int r = PAM_BUF_ERR;
+
+        /* FIXME: We *really* should move the access() check into the
+         * daemons that spawn dbus-daemon, instead of forcing
+         * DBUS_SESSION_BUS_ADDRESS= here. */
+
+        s = strjoin(runtime, "/bus");
+        if (!s)
+                goto error;
+
+        if (access(s, F_OK) < 0)
+                return PAM_SUCCESS;
+
+        s = mfree(s);
+        if (asprintf(&s, DEFAULT_USER_BUS_ADDRESS_FMT, runtime) < 0)
+                goto error;
+
+        r = pam_misc_setenv(handle, "DBUS_SESSION_BUS_ADDRESS", s, 0);
+        if (r != PAM_SUCCESS)
+                goto error;
+
+        return PAM_SUCCESS;
+
+error:
+        pam_syslog(handle, LOG_ERR, "Failed to set bus variable.");
+        return r;
+}
+
 static int append_session_memory_max(pam_handle_t *handle, sd_bus_message *m, const char *limit) {
         uint64_t val;
         int r;
@@ -405,6 +439,10 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                         }
                 }
 
+                r = export_legacy_dbus_address(handle, pw->pw_uid, rt);
+                if (r != PAM_SUCCESS)
+                        return r;
+
                 return PAM_SUCCESS;
         }
 
@@ -613,6 +651,10 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                         if (r != PAM_SUCCESS)
                                 return r;
                 }
+
+                r = export_legacy_dbus_address(handle, pw->pw_uid, runtime_path);
+                if (r != PAM_SUCCESS)
+                        return r;
         }
 
         /* Most likely we got the session/type/class from environment variables, but might have gotten the data