File gdm-fix-btmp-record-with-seat.patch of Package gdm.38856
diff --unified --recursive --text --new-file --color gdm-41.3.old/daemon/gdm-manager.c gdm-41.3.new/daemon/gdm-manager.c
--- gdm-41.3.old/daemon/gdm-manager.c 2023-06-05 15:30:39.141087142 +0800
+++ gdm-41.3.new/daemon/gdm-manager.c 2023-06-05 15:30:50.094441216 +0800
@@ -655,13 +655,14 @@
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 @@
"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 @@
g_free (display_name);
g_free (hostname);
g_free (display_device);
+ g_free (display_seat_id);
return recorded;
}
diff --unified --recursive --text --new-file --color gdm-41.3.old/daemon/gdm-session-record.c gdm-41.3.new/daemon/gdm-session-record.c
--- gdm-41.3.old/daemon/gdm-session-record.c 2023-06-05 15:30:39.141087142 +0800
+++ gdm-41.3.new/daemon/gdm-session-record.c 2023-06-05 15:31:12.864483985 +0800
@@ -25,6 +25,8 @@
#include <string.h>
#include <unistd.h>
+#define _GNU_SOURCE
+
#if defined(HAVE_UTMPX_H)
#include <utmpx.h>
#endif
@@ -149,15 +151,21 @@
{
/*
* Set ut_line to the device name associated with this display
- * but remove the "/dev/" prefix. If no device, then use the
- * $DISPLAY value.
+ * but remove the "/dev/" prefix if there is one. Otherwise, if it
+ * seems like the display device is a seat id, just use it wholesale.
+ * If there's no device at all, but $DISPLAY is set, just fall back to
+ * using that.
*/
- 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,