chiark / gitweb /
bus: fix a couple of format string mistakes
[elogind.git] / src / login / pam-module.c
index be5901fd77355e4040b2921bd0f7c1953a28994f..89623aa765747e5bc93c0e2a3191dba3eb8f2b7d 100644 (file)
@@ -120,7 +120,6 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_
         _cleanup_free_ char *p = NULL, *tty = NULL;
         _cleanup_close_ int fd = -1;
         struct ucred ucred;
-        socklen_t l;
         int v, r;
 
         assert(display);
@@ -144,10 +143,9 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_
         if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path)) < 0)
                 return -errno;
 
-        l = sizeof(ucred);
-        r = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &l);
+        r = getpeercred(fd, &ucred);
         if (r < 0)
-                return -errno;
+                return r;
 
         r = get_ctty(ucred.pid, NULL, &tty);
         if (r < 0)
@@ -284,7 +282,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
         if (!isempty(cvtnr))
                 safe_atou32(cvtnr, &vtnr);
 
-        if (!isempty(display) && vtnr <= 0) {
+        if (!isempty(display) && !vtnr) {
                 if (isempty(seat))
                         get_seat_from_display(display, &seat, &vtnr);
                 else if (streq(seat, "seat0"))