[gdm/fix-btmp-accounting] manager: Fix btmp record accounting




commit 3611c6871867a6ca86b07786eb55e3d223b294ca
Author: Ray Strode <rstrode redhat com>
Date:   Wed Oct 19 14:50:33 2022 -0400

    manager: Fix btmp record accounting
    
    Before a user logs in they don't have a display.
    
    btmp records currently need a display though, and they
    get written when the user can't log in.
    
    Furthermore, the display from X11 point of view is
    somewhat archaic. We use wayland by default now.
    
    In lieu of a display, this commit gives the btmp record
    the seat id instead.

 daemon/gdm-manager.c        | 11 +++++++++--
 daemon/gdm-session-record.c |  8 ++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index cc61efc93..e1bc62d71 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -655,13 +655,14 @@ add_session_record (GdmManager    *manager,
                     SessionRecord  record)
 {
         const char *username;
-        char *display_name, *hostname, *display_device;
+        char *display_name, *hostname, *display_device, *display_seat_id;
         gboolean recorded = FALSE;
 
         display_name = NULL;
         username = NULL;
         hostname = NULL;
         display_device = NULL;
+        display_seat_id = NULL;
 
         username = gdm_session_get_username (session);
 
@@ -673,10 +674,15 @@ add_session_record (GdmManager    *manager,
                       "display-name", &display_name,
                       "display-hostname", &hostname,
                       "display-device", &display_device,
+                      "display-seat-id", &display_seat_id,
                       NULL);
 
         if (display_name == NULL && display_device == NULL) {
-                goto out;
+                if (display_seat_id == NULL)
+                        goto out;
+
+                display_name = g_strdup ("login screen");
+                display_device = g_strdup (display_seat_id);
         }
 
         switch (record) {
@@ -708,6 +714,7 @@ out:
         g_free (display_name);
         g_free (hostname);
         g_free (display_device);
+        g_free (display_seat_id);
 
         return recorded;
 }
diff --git a/daemon/gdm-session-record.c b/daemon/gdm-session-record.c
index 7719d0a86..310323b69 100644
--- a/daemon/gdm-session-record.c
+++ b/daemon/gdm-session-record.c
@@ -152,12 +152,16 @@ record_set_line (UTMP       *u,
          * but remove the "/dev/" prefix.  If no device, then use the
          * $DISPLAY value.
          */
-        if (display_device != NULL
-            && g_str_has_prefix (display_device, "/dev/")) {
+        if (display_device != NULL && g_str_has_prefix (display_device, "/dev/")) {
                 memccpy (u->ut_line,
                          display_device + strlen ("/dev/"),
                          '\0',
                          sizeof (u->ut_line));
+        } else if (display_device != NULL && g_str_has_prefix (display_device, "seat")) {
+                memccpy (u->ut_line,
+                         display_device,
+                         '\0',
+                         sizeof (u->ut_line));
         } else if (x11_display_name != NULL) {
                 memccpy (u->ut_line,
                          x11_display_name,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]