chiark / gitweb /
Added attribute support for sd-rtnl
[elogind.git] / src / login / pam-module.c
index c67e677384b11e0ce4b37c5ec099786924838dfb..18dd4e2e2136482e3a73f1356502ecef269d4bac 100644 (file)
@@ -173,7 +173,11 @@ static int export_legacy_dbus_address(
         _cleanup_free_ char *s = NULL;
         int r;
 
-        if (asprintf(&s, "kernel:path=/dev/kdbus/%lu-user/bus;unix:path=%s/bus",
+        /* skip export if kdbus is not active */
+        if (access("/dev/kdbus", F_OK) < 0)
+                return PAM_SUCCESS;
+
+        if (asprintf(&s, KERNEL_USER_BUS_FMT ";" UNIX_USER_BUS_FMT,
                      (unsigned long) uid, runtime) < 0) {
                 pam_syslog(handle, LOG_ERR, "Failed to set bus variable.");
                 return PAM_BUF_ERR;
@@ -317,6 +321,12 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                         get_seat_from_display(display, NULL, &vtnr);
         }
 
+        if (seat && !streq(seat, "seat0")) {
+                pam_syslog(handle, LOG_DEBUG,
+                      "Ignoring vtnr %d for %s which is not seat0", vtnr, seat);
+                vtnr = 0;
+        }
+
         if (!type)
                 type = !isempty(display) ? "x11" :
                         !isempty(tty) ? "tty" : "unspecified";