summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/login/pam_systemd.c35
-rwxr-xr-xxorg/50-systemd-user.sh4
2 files changed, 28 insertions, 11 deletions
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
index f83d18b035..71c84d8e0a 100644
--- a/src/login/pam_systemd.c
+++ b/src/login/pam_systemd.c
@@ -179,24 +179,37 @@ static int export_legacy_dbus_address(
const char *runtime) {
_cleanup_free_ char *s = NULL;
- int r;
+ int r = PAM_BUF_ERR;
- /* skip export if kdbus is not active */
- if (!is_kdbus_available())
- return PAM_SUCCESS;
+ if (is_kdbus_available()) {
+ if (asprintf(&s, KERNEL_USER_BUS_ADDRESS_FMT ";" UNIX_USER_BUS_ADDRESS_FMT, uid, runtime) < 0)
+ goto error;
+ } else {
+ /* FIXME: We *realy* should move the access() check into the
+ * daemons that spawn dbus-daemon, instead of forcing
+ * DBUS_SESSION_BUS_ADDRESS= here. */
+
+ s = strjoin(runtime, "/bus", NULL);
+ if (!s)
+ goto error;
+
+ if (access(s, F_OK) < 0)
+ return PAM_SUCCESS;
- if (asprintf(&s, KERNEL_USER_BUS_ADDRESS_FMT ";" UNIX_USER_BUS_ADDRESS_FMT, uid, runtime) < 0) {
- pam_syslog(handle, LOG_ERR, "Failed to set bus variable.");
- return PAM_BUF_ERR;
+ s = mfree(s);
+ if (asprintf(&s, UNIX_USER_BUS_ADDRESS_FMT, runtime) < 0)
+ goto error;
}
r = pam_misc_setenv(handle, "DBUS_SESSION_BUS_ADDRESS", s, 0);
- if (r != PAM_SUCCESS) {
- pam_syslog(handle, LOG_ERR, "Failed to set bus variable.");
- return r;
- }
+ if (r != PAM_SUCCESS)
+ goto error;
return PAM_SUCCESS;
+
+error:
+ pam_syslog(handle, LOG_ERR, "Failed to set bus variable.");
+ return r;
}
_public_ PAM_EXTERN int pam_sm_open_session(
diff --git a/xorg/50-systemd-user.sh b/xorg/50-systemd-user.sh
index f4df13b619..4d49767228 100755
--- a/xorg/50-systemd-user.sh
+++ b/xorg/50-systemd-user.sh
@@ -1,3 +1,7 @@
#!/bin/sh
systemctl --user import-environment DISPLAY XAUTHORITY
+
+if which dbus-update-activation-environment >/dev/null 2>&1; then
+ dbus-update-activation-environment DISPLAY XAUTHORITY
+fi