chiark / gitweb /
logind: move X11 socket
[elogind.git] / src / login / pam-module.c
index 14e706b37430a52c2f03953f48fc36a159d2793e..46509245fb4a801361a460e63bfa70acec18b992 100644 (file)
 #include <security/pam_ext.h>
 #include <security/pam_misc.h>
 
+#include <systemd/sd-daemon.h>
+
 #include "util.h"
 #include "macro.h"
-#include "sd-daemon.h"
 #include "strv.h"
 #include "dbus-common.h"
 #include "def.h"
@@ -259,7 +260,6 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_
         int v;
 
         assert(display);
-        assert(seat);
         assert(vtnr);
 
         /* We deduce the X11 socket from the display name, then use
@@ -307,7 +307,8 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_
         else if (v == 0)
                 return -ENOENT;
 
-        *seat = "seat0";
+        if (seat)
+                *seat = "seat0";
         *vtnr = (uint32_t) v;
 
         return 0;
@@ -454,8 +455,12 @@ _public_ PAM_EXTERN int pam_sm_open_session(
         if (!isempty(cvtnr))
                 safe_atou32(cvtnr, &vtnr);
 
-        if (!isempty(display) && isempty(seat) && vtnr <= 0)
-                get_seat_from_display(display, &seat, &vtnr);
+        if (!isempty(display) && vtnr <= 0) {
+                if (isempty(seat))
+                        get_seat_from_display(display, &seat, &vtnr);
+                else if (streq(seat, "seat0"))
+                        get_seat_from_display(display, NULL, &vtnr);
+        }
 
         type = !isempty(display) ? "x11" :
                    !isempty(tty) ? "tty" : "unspecified";