chiark / gitweb /
pam_systemd: export DBUS_SESSION_BUS_ADDRESS
authorKay Sievers <kay@vrfy.org>
Mon, 6 Jan 2014 04:00:16 +0000 (08:00 +0400)
committerKay Sievers <kay@vrfy.org>
Wed, 8 Jan 2014 10:11:37 +0000 (18:11 +0800)
Makefile.am
src/login/pam-module.c
units/.gitignore
units/user@.service.in [moved from units/user@.service.m4.in with 64% similarity]

index 7a15942..725a375 100644 (file)
@@ -494,7 +494,7 @@ EXTRA_DIST += \
        units/user/systemd-exit.service.in \
        units/systemd-fsck@.service.in \
        units/systemd-fsck-root.service.in \
-       units/user@.service.m4.in \
+       units/user@.service.in \
        units/systemd-udevd.service \
        units/systemd-udev-trigger.service \
        units/systemd-udev-settle.service \
index 89623aa..c67e677 100644 (file)
@@ -164,6 +164,30 @@ 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) {
+
+#ifdef ENABLE_KDBUS
+        _cleanup_free_ char *s = NULL;
+        int r;
+
+        if (asprintf(&s, "kernel:path=/dev/kdbus/%lu-user/bus;unix:path=%s/bus",
+                     (unsigned long) uid, runtime) < 0) {
+                pam_syslog(handle, LOG_ERR, "Failed to set bus variable.");
+                return PAM_BUF_ERR;
+        }
+
+        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;
+        }
+#endif
+        return PAM_SUCCESS;
+}
+
 _public_ PAM_EXTERN int pam_sm_open_session(
                 pam_handle_t *handle,
                 int flags,
@@ -232,6 +256,10 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                                 pam_syslog(handle, LOG_ERR, "Failed to set runtime dir.");
                                 return r;
                         }
+
+                        r = export_legacy_dbus_address(handle, pw->pw_uid, rt);
+                        if (r != PAM_SUCCESS)
+                                return r;
                 }
 
                 return PAM_SUCCESS;
@@ -386,6 +414,10 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                         pam_syslog(handle, LOG_ERR, "Failed to set runtime dir.");
                         return r;
                 }
+
+                r = export_legacy_dbus_address(handle, pw->pw_uid, runtime_path);
+                if (r != PAM_SUCCESS)
+                        return r;
         }
 
         if (!isempty(seat)) {
index cb9fa1c..76c4cb3 100644 (file)
@@ -65,5 +65,4 @@
 /systemd-update-utmp.service
 /systemd-user-sessions.service
 /systemd-vconsole-setup.service
-/user@.service.m4
 /user@.service
similarity index 64%
rename from units/user@.service.m4.in
rename to units/user@.service.in
index 7b7d52b..c2d495f 100644 (file)
@@ -6,17 +6,12 @@
 #  (at your option) any later version.
 
 [Unit]
-Description=User Manager for %I
+Description=User Manager for %i
 After=systemd-user-sessions.service
 
 [Service]
-User=%I
+User=%i
 PAMName=systemd-user
 Type=notify
 ExecStart=-@rootlibexecdir@/systemd --user
-m4_ifdef(`ENABLE_KDBUS',
-Environment=DBUS_SESSION_BUS_ADDRESS=kernel:path=/dev/kdbus/%I-user/bus;unix:path=/run/user/%I/bus
-,m4_dnl
-Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%I/bus
-)m4_dnl
 Slice=user-%i.slice