chiark / gitweb /
Merge branch 'journal'
[elogind.git] / src / pam-module.c
index 78f9b30d5bffa8db425508cf5360570571d72374..14e706b37430a52c2f03953f48fc36a159d2793e 100644 (file)
@@ -445,6 +445,10 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                 if (isempty(display))
                         display = tty;
                 tty = "";
+        } else if (streq(tty, "cron")) {
+                /* cron has been setting PAM_TTY to "cron" for a very long time
+                 * and it cannot stop doing that for compatibility reasons. */
+                tty = "";
         }
 
         if (!isempty(cvtnr))
@@ -454,7 +458,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                 get_seat_from_display(display, &seat, &vtnr);
 
         type = !isempty(display) ? "x11" :
-                   !isempty(tty) ? "tty" : "other";
+                   !isempty(tty) ? "tty" : "unspecified";
 
         remote = !isempty(remote_host) && !streq(remote_host, "localhost") && !streq(remote_host, "localhost.localdomain");
 
@@ -499,6 +503,11 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                 goto finish;
         }
 
+        if (debug)
+                pam_syslog(handle, LOG_DEBUG, "Asking logind to create session: "
+                           "uid=%u pid=%u service=%s type=%s seat=%s vtnr=%u tty=%s display=%s remote=%s remote_user=%s remote_host=%s",
+                           uid, pid, service, type, seat, vtnr, tty, display, yes_no(remote), remote_user, remote_host);
+
         reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error);
         if (!reply) {
                 pam_syslog(handle, LOG_ERR, "Failed to create session: %s", bus_error_message(&error));
@@ -519,6 +528,11 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                 goto finish;
         }
 
+        if (debug)
+                pam_syslog(handle, LOG_DEBUG, "Reply from logind: "
+                           "id=%s object_path=%s runtime_path=%s session_fd=%d seat=%s vtnr=%u",
+                           id, object_path, runtime_path, session_fd, seat, vtnr);
+
         r = pam_misc_setenv(handle, "XDG_SESSION_ID", id, 0);
         if (r != PAM_SUCCESS) {
                 pam_syslog(handle, LOG_ERR, "Failed to set session id.");