From 51bc97279d9457cccf6dac6d588a7ad3c11336cc Mon Sep 17 00:00:00 2001 From: William Allen Date: Thu, 4 Jan 2024 04:04:56 -0600 Subject: [PATCH 01/15] Update lightdm.service --- debian/lightdm.service | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debian/lightdm.service b/debian/lightdm.service index 84b2b4360..0a18d3c0a 100644 --- a/debian/lightdm.service +++ b/debian/lightdm.service @@ -3,6 +3,9 @@ Description=Light Display Manager Documentation=man:lightdm(1) Conflicts=getty@tty7.service plymouth-quit.service After=systemd-user-sessions.service getty@tty7.service plymouth-quit.service +StartLimitInterval=60s +StartLimitBurst=5 +OnFailure=lightdm-failure-handler.service [Service] # temporary safety check until all DMs are converted to correct @@ -10,4 +13,5 @@ After=systemd-user-sessions.service getty@tty7.service plymouth-quit.service ExecStartPre=/bin/sh -c '[ "$(basename $(cat /etc/X11/default-display-manager 2>/dev/null))" = "lightdm" ]' ExecStart=/usr/sbin/lightdm Restart=always +RestartSec=15s BusName=org.freedesktop.DisplayManager From 9cae2581fce5ecaf74d35773b21e6c5b6981eb10 Mon Sep 17 00:00:00 2001 From: William Allen Date: Thu, 4 Jan 2024 04:14:04 -0600 Subject: [PATCH 02/15] Create lightdm-failure-handler.service --- debian/lightdm-failure-handler.service | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 debian/lightdm-failure-handler.service diff --git a/debian/lightdm-failure-handler.service b/debian/lightdm-failure-handler.service new file mode 100644 index 000000000..8b317cc66 --- /dev/null +++ b/debian/lightdm-failure-handler.service @@ -0,0 +1,9 @@ +[Unit] +Description=Handle LightDM failure + +[Service] +Type=oneshot +ExecStart=/bin/mv /etc/issue /etc/issue.restore; /bin/sh -c 'echo -e "LightDM has failed to start. You are now in a TTY for troubleshooting...\nYou can log in and check for details in logs." > /etc/issue; /usr/bin/chvt 4' + +[Install] +WantedBy=multi-user.target From 801d1f0a45fdf141a6c92ea9316b5e2d5ea08bd7 Mon Sep 17 00:00:00 2001 From: William Allen Date: Thu, 4 Jan 2024 04:16:17 -0600 Subject: [PATCH 03/15] Create lightdm-success-handler.service --- debian/lightdm-success-handler.service | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 debian/lightdm-success-handler.service diff --git a/debian/lightdm-success-handler.service b/debian/lightdm-success-handler.service new file mode 100644 index 000000000..da47a0b0f --- /dev/null +++ b/debian/lightdm-success-handler.service @@ -0,0 +1,11 @@ +[Unit] +Description=Reset /etc/issue after LightDM starts successfully +Requires=lightdm.service +After=lightdm.service + +[Service] +Type=oneshot +ExecStart=/bin/mv /etc/issue.restore /etc/issue + +[Install] +WantedBy=graphical.target From 3a22dd7e64030011e0f83869b4465602831a4b55 Mon Sep 17 00:00:00 2001 From: William Allen Date: Thu, 4 Jan 2024 05:08:10 -0600 Subject: [PATCH 04/15] Update lightdm.service --- debian/lightdm.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/lightdm.service b/debian/lightdm.service index 0a18d3c0a..6a46f46c1 100644 --- a/debian/lightdm.service +++ b/debian/lightdm.service @@ -3,7 +3,7 @@ Description=Light Display Manager Documentation=man:lightdm(1) Conflicts=getty@tty7.service plymouth-quit.service After=systemd-user-sessions.service getty@tty7.service plymouth-quit.service -StartLimitInterval=60s +StartLimitIntervalSec=60s StartLimitBurst=5 OnFailure=lightdm-failure-handler.service From 3453fcb8330d2e97348b60f6edee0163246e8208 Mon Sep 17 00:00:00 2001 From: William Allen Date: Thu, 4 Jan 2024 05:14:31 -0600 Subject: [PATCH 05/15] Update lightdm.service RestartSec --- debian/lightdm.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/lightdm.service b/debian/lightdm.service index 6a46f46c1..74b3933c5 100644 --- a/debian/lightdm.service +++ b/debian/lightdm.service @@ -13,5 +13,5 @@ OnFailure=lightdm-failure-handler.service ExecStartPre=/bin/sh -c '[ "$(basename $(cat /etc/X11/default-display-manager 2>/dev/null))" = "lightdm" ]' ExecStart=/usr/sbin/lightdm Restart=always -RestartSec=15s +RestartSec=5s BusName=org.freedesktop.DisplayManager From ec19df30ad16af78f7676288dab9be110ba7c79c Mon Sep 17 00:00:00 2001 From: William Allen Date: Thu, 4 Jan 2024 05:33:35 -0600 Subject: [PATCH 06/15] Update lightdm-success-handler.service in the event issue.restore doesn't exist --- debian/lightdm-success-handler.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/lightdm-success-handler.service b/debian/lightdm-success-handler.service index da47a0b0f..736e287a8 100644 --- a/debian/lightdm-success-handler.service +++ b/debian/lightdm-success-handler.service @@ -5,7 +5,7 @@ After=lightdm.service [Service] Type=oneshot -ExecStart=/bin/mv /etc/issue.restore /etc/issue +ExecStart=/bin/sh -c 'test -f /etc/issue.restore && mv /etc/issue.restore /etc/issue || echo -e "Linux \\\\r (\\\\l)\n\n" > /etc/issue' [Install] WantedBy=graphical.target From f3fbf190268d8544888c533507aade215dc697db Mon Sep 17 00:00:00 2001 From: William Allen Date: Thu, 4 Jan 2024 05:38:10 -0600 Subject: [PATCH 07/15] Only making success handler act if a restore file exists --- debian/lightdm-success-handler.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/lightdm-success-handler.service b/debian/lightdm-success-handler.service index 736e287a8..7976de416 100644 --- a/debian/lightdm-success-handler.service +++ b/debian/lightdm-success-handler.service @@ -5,7 +5,7 @@ After=lightdm.service [Service] Type=oneshot -ExecStart=/bin/sh -c 'test -f /etc/issue.restore && mv /etc/issue.restore /etc/issue || echo -e "Linux \\\\r (\\\\l)\n\n" > /etc/issue' +ExecStart=/bin/sh -c 'test -f /etc/issue.restore && mv /etc/issue.restore /etc/issue || echo "File /etc/issue.restore not found. No restore action needed."' [Install] WantedBy=graphical.target From 367d9f4c97a078e3694224eb7fb545f353992d91 Mon Sep 17 00:00:00 2001 From: Guido Berhoerster Date: Thu, 21 Sep 2023 11:37:47 +0200 Subject: [PATCH 08/15] Add support for changing the home directory in PAM modules PAM modules such as pam_mklocaluser may change or even create the home directory. Currently, LightDM assumes that the home directory will not change when opening the PAM session, the user's home directory is obtained via getpwent() after authentication but before opening the session. Fix this by trying to update the user's home directory from the HOME environment variable from PAM after opening the session. Furthermore, if the Xauthority file is not stored in a system directory, the daemon hardcodes its path to the user's home directory and passes it as an absolute path to the session child. Fix this by passing it as a relative path so that the actual path can be constructed after the PAM session has been opened and the home directory has potentially been updated. --- src/session-child.c | 16 ++++++++++++++-- src/session.c | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/session-child.c b/src/session-child.c index b4661577b..cda812697 100644 --- a/src/session-child.c +++ b/src/session-child.c @@ -541,6 +541,12 @@ session_child_run (int argc, char **argv) return EXIT_FAILURE; } + /* try to get HOME from PAM since it might have been changed */ + const gchar *home_directory = pam_getenv (pam_handle, "HOME"); + if (!home_directory) { + home_directory = user_get_home_directory (user); + } + /* Open a connection to the system bus for ConsoleKit - we must keep it open or CK will close the session */ g_autoptr(GError) error = NULL; g_autoptr(GDBusConnection) bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); @@ -605,6 +611,11 @@ session_child_run (int argc, char **argv) /* Write X authority */ if (x_authority) { + if (!g_path_is_absolute (x_authority_filename)) { + gchar *x_authority_filename_new = g_build_filename (home_directory, x_authority_filename, NULL); + g_free (x_authority_filename); + x_authority_filename = x_authority_filename_new; + } gboolean drop_privileges = geteuid () == 0; if (drop_privileges) privileges_drop (user_get_uid (user), user_get_gid (user)); @@ -632,7 +643,6 @@ session_child_run (int argc, char **argv) /* Run the command as the authenticated user */ uid_t uid = user_get_uid (user); gid_t gid = user_get_gid (user); - const gchar *home_directory = user_get_home_directory (user); child_pid = fork (); if (child_pid == 0) { @@ -677,8 +687,10 @@ session_child_run (int argc, char **argv) /* NOTE: This must be done after the permissions are changed because NFS filesystems can * be setup so the local root user accesses the NFS files as 'nobody'. If the home directories * are not system readable then the chdir can fail */ - if (chdir (home_directory) != 0) + if (chdir (home_directory) != 0) { + g_printerr ("chdir: %s\n", strerror (errno)); _exit (errno); + } if (log_filename) { diff --git a/src/session.c b/src/session.c index fce12a0be..40bed8ddf 100644 --- a/src/session.c +++ b/src/session.c @@ -812,7 +812,7 @@ session_real_run (Session *session) x_authority_filename = g_build_filename (dir, "xauthority", NULL); } else - x_authority_filename = g_build_filename (user_get_home_directory (session_get_user (session)), ".Xauthority", NULL); + x_authority_filename = g_strdup (".Xauthority"); /* Make sure shared user directory for this user exists */ if (!priv->remote_host_name) From 576ebfafb25dc7477039f46c588c3b154c57681e Mon Sep 17 00:00:00 2001 From: Guido Berhoerster Date: Mon, 9 Oct 2023 08:51:16 +0200 Subject: [PATCH 09/15] Return and use the potentially changed home directory from the session child Return the home directory from the session child to the daemon which may have been changed by PAM. Use the returned home directory in the daemon when running script hooks. --- src/seat.c | 12 ++++++------ src/session-child.c | 2 ++ src/session.c | 22 +++++++++++++++++++++- src/session.h | 2 ++ 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/seat.c b/src/seat.c index 998acdbb8..8e09026c8 100644 --- a/src/seat.c +++ b/src/seat.c @@ -365,7 +365,7 @@ seat_get_allow_guest (Seat *seat) } static gboolean -run_script (Seat *seat, DisplayServer *display_server, const gchar *script_name, User *user) +run_script (Seat *seat, DisplayServer *display_server, const gchar *script_name, User *user, const gchar *home_directory) { g_autoptr(Process) script = process_new (NULL, NULL); @@ -392,7 +392,7 @@ run_script (Seat *seat, DisplayServer *display_server, const gchar *script_name, { process_set_env (script, "USER", user_get_name (user)); process_set_env (script, "LOGNAME", user_get_name (user)); - process_set_env (script, "HOME", user_get_home_directory (user)); + process_set_env (script, "HOME", home_directory ? home_directory : user_get_home_directory (user)); } else process_set_env (script, "HOME", "/"); @@ -457,7 +457,7 @@ display_server_stopped_cb (DisplayServer *display_server, Seat *seat) /* Run a script right after stopping the display server */ const gchar *script = seat_get_string_property (seat, "display-stopped-script"); if (script) - run_script (seat, NULL, script, NULL); + run_script (seat, NULL, script, NULL, NULL); g_signal_handlers_disconnect_matched (display_server, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, seat); priv->display_servers = g_list_remove (priv->display_servers, display_server); @@ -654,7 +654,7 @@ run_session (Seat *seat, Session *session) script = seat_get_string_property (seat, "greeter-setup-script"); else script = seat_get_string_property (seat, "session-setup-script"); - if (script && !run_script (seat, session_get_display_server (session), script, session_get_user (session))) + if (script && !run_script (seat, session_get_display_server (session), script, session_get_user (session), session_get_home_directory (session))) { l_debug (seat, "Switching to greeter due to failed setup script"); switch_to_greeter_from_failed_session (seat, session); @@ -778,7 +778,7 @@ session_stopped_cb (Session *session, Seat *seat) { const gchar *script = seat_get_string_property (seat, "session-cleanup-script"); if (script) - run_script (seat, display_server, script, session_get_user (session)); + run_script (seat, display_server, script, session_get_user (session), session_get_home_directory (session)); } if (priv->stopping) @@ -1324,7 +1324,7 @@ display_server_ready_cb (DisplayServer *display_server, Seat *seat) { /* Run setup script */ const gchar *script = seat_get_string_property (seat, "display-setup-script"); - if (script && !run_script (seat, display_server, script, NULL)) + if (script && !run_script (seat, display_server, script, NULL, NULL)) { l_debug (seat, "Stopping display server due to failed setup script"); display_server_stop (display_server); diff --git a/src/session-child.c b/src/session-child.c index cda812697..4e04137d8 100644 --- a/src/session-child.c +++ b/src/session-child.c @@ -546,6 +546,8 @@ session_child_run (int argc, char **argv) if (!home_directory) { home_directory = user_get_home_directory (user); } + if (version >= 4) + write_string (home_directory); /* Open a connection to the system bus for ConsoleKit - we must keep it open or CK will close the session */ g_autoptr(GError) error = NULL; diff --git a/src/session.c b/src/session.c index 40bed8ddf..d0d8a2351 100644 --- a/src/session.c +++ b/src/session.c @@ -59,6 +59,9 @@ typedef struct /* User to authenticate as */ gchar *username; + /* Home directory of the authenticating user */ + gchar *home_directory; + /* TRUE if is a guest account */ gboolean is_guest; @@ -644,7 +647,7 @@ session_real_start (Session *session) close (from_child_input); /* Indicate what version of the protocol we are using */ - int version = 3; + int version = 4; write_data (session, &version, sizeof (version)); /* Send configuration */ @@ -671,6 +674,14 @@ session_get_username (Session *session) return priv->username; } +const gchar * +session_get_home_directory (Session *session) +{ + SessionPrivate *priv = session_get_instance_private (session); + g_return_val_if_fail (session != NULL, NULL); + return priv->home_directory; +} + const gchar * session_get_login1_session_id (Session *session) { @@ -863,6 +874,14 @@ session_real_run (Session *session) for (gsize i = 0; i < argc; i++) write_string (session, priv->argv[i]); + /* Get the home directory of the user currently being authenticated (may change after opening PAM session) */ + g_autofree gchar *home_directory = read_string_from_child (session); + if (g_strcmp0 (home_directory, priv->home_directory) != 0) + { + g_free (priv->home_directory); + priv->home_directory = g_steal_pointer (&home_directory); + } + priv->login1_session_id = read_string_from_child (session); priv->console_kit_cookie = read_string_from_child (session); } @@ -1005,6 +1024,7 @@ session_finalize (GObject *object) if (priv->child_watch) g_source_remove (priv->child_watch); g_clear_pointer (&priv->username, g_free); + g_clear_pointer (&priv->home_directory, g_free); g_clear_object (&priv->user); g_clear_pointer (&priv->pam_service, g_free); for (size_t i = 0; i < priv->messages_length; i++) diff --git a/src/session.h b/src/session.h index e1130e837..ed9bacf40 100644 --- a/src/session.h +++ b/src/session.h @@ -118,6 +118,8 @@ gboolean session_get_is_started (Session *session); const gchar *session_get_username (Session *session); +const gchar *session_get_home_directory (Session *session); + const gchar *session_get_login1_session_id (Session *session); const gchar *session_get_console_kit_cookie (Session *session); From 9ed2bb0b8418e46859ea9b5fcc50af00f6fffa2e Mon Sep 17 00:00:00 2001 From: Guido Berhoerster Date: Mon, 9 Oct 2023 13:02:09 +0200 Subject: [PATCH 10/15] Add test case for users who have their home directory changed by PAM --- tests/Makefile.am | 4 ++- tests/scripts/change-home-dir-on-session.conf | 34 +++++++++++++++++++ tests/src/libsystem.c | 21 ++++++++++++ tests/src/test-runner.c | 4 ++- tests/test-change-home-dir-on-session | 2 ++ 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 tests/scripts/change-home-dir-on-session.conf create mode 100755 tests/test-change-home-dir-on-session diff --git a/tests/Makefile.am b/tests/Makefile.am index 98a3acce3..ac43aa1c8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -256,7 +256,8 @@ TESTS = \ test-wayland-greeter \ test-wayland-session \ test-invalid-seat \ - test-seatdefaults-still-supported + test-seatdefaults-still-supported \ + test-change-home-dir-on-session # test-switch-to-greeter-return-session-repeat # test-session-exit-error @@ -389,6 +390,7 @@ EXTRA_DIST = \ scripts/autologin-timeout-logout.conf \ scripts/autologin-xserver-crash.conf \ scripts/change-authentication.conf \ + scripts/change-home-dir-on-session.conf \ scripts/cancel-authentication.conf \ scripts/console-kit.conf \ scripts/console-kit-no-xdg-runtime.conf \ diff --git a/tests/scripts/change-home-dir-on-session.conf b/tests/scripts/change-home-dir-on-session.conf new file mode 100644 index 000000000..c1e469ba2 --- /dev/null +++ b/tests/scripts/change-home-dir-on-session.conf @@ -0,0 +1,34 @@ +# +# Check home directory is set correctly in session after having been changed by PAM +# + +[Seat:*] +autologin-user=change-home-dir +user-session=default + +#?*START-DAEMON +#?RUNNER DAEMON-START + +# X server starts +#?XSERVER-0 START VT=7 SEAT=seat0 + +# Daemon connects when X server is ready +#?*XSERVER-0 INDICATE-READY +#?XSERVER-0 INDICATE-READY +#?XSERVER-0 ACCEPT-CONNECT + +# Session starts +#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/change-home-dir XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=change-home-dir +#?LOGIN1 ACTIVATE-SESSION SESSION=c0 +#?XSERVER-0 ACCEPT-CONNECT +#?SESSION-X-0 CONNECT-XSERVER + +# Check environment variables +#?*SESSION-X-0 READ-ENV NAME=HOME +#?SESSION-X-0 READ-ENV NAME=HOME VALUE=.*/users/change-home-dir + +# Cleanup +#?*STOP-DAEMON +#?SESSION-X-0 TERMINATE SIGNAL=15 +#?XSERVER-0 TERMINATE SIGNAL=15 +#?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/src/libsystem.c b/tests/src/libsystem.c index a15e7df55..4007ab49b 100644 --- a/tests/src/libsystem.c +++ b/tests/src/libsystem.c @@ -1285,6 +1285,27 @@ pam_open_session (pam_handle_t *pamh, int flags) g_mkdir_with_parents (entry->pw_dir, 0755); } + if (strcmp (pamh->user, "change-home-dir") == 0) + { + struct passwd *entry = getpwnam (pamh->user); + + /* Actual home dir is changed by PAM, differing from passwd, strip off + trailing /home/ and replace with /users/ */ + const char *endp = pamh->user; + int slashes = 0; + while (*endp++ != '\0'); + while (slashes < 2 && endp > pamh->user) { + if (*endp-- == '/') + slashes++; + } + g_autofree gchar *changed_home = g_strdup_printf("%.*s/users/%s\n", (int)(endp - entry->pw_dir), entry->pw_dir, pamh->user); + + g_mkdir_with_parents (changed_home, 0755); + + g_autofree gchar *e = g_strdup_printf ("HOME=%s", changed_home); + pam_putenv (pamh, e); + } + /* Open logind session */ g_autoptr(GError) error = NULL; g_autoptr(GVariant) result = g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL), diff --git a/tests/src/test-runner.c b/tests/src/test-runner.c index 7de9694ce..bfda38efe 100644 --- a/tests/src/test-runner.c +++ b/tests/src/test-runner.c @@ -2772,13 +2772,15 @@ main (int argc, char **argv) {"corrupt-xauth", "password", "Corrupt Xauthority", 1032}, /* User to test properties */ {"prop-user", "", "TEST", 1033}, + /* This account has the home directory changed by PAM during authentication */ + {"change-home-dir", "", "Change Home Dir User", 1034}, {NULL, NULL, NULL, 0} }; g_autoptr(GString) passwd_data = g_string_new (""); g_autoptr(GString) group_data = g_string_new (""); for (int i = 0; users[i].user_name; i++) { - if (strcmp (users[i].user_name, "mount-home-dir") != 0 && strcmp (users[i].user_name, "make-home-dir") != 0) + if (strcmp (users[i].user_name, "mount-home-dir") != 0 && strcmp (users[i].user_name, "make-home-dir") != 0 && strcmp (users[i].user_name, "change-home-dir") != 0) { g_autofree gchar *path = g_build_filename (home_dir, users[i].user_name, NULL); g_mkdir_with_parents (path, 0755); diff --git a/tests/test-change-home-dir-on-session b/tests/test-change-home-dir-on-session new file mode 100755 index 000000000..38d5a9dba --- /dev/null +++ b/tests/test-change-home-dir-on-session @@ -0,0 +1,2 @@ +#!/bin/sh +./src/dbus-env ./src/test-runner change-home-dir-on-session test-gobject-greeter From 388c86520347f0d7c15081c33a01b8c308eb8937 Mon Sep 17 00:00:00 2001 From: Guido Falsi Date: Mon, 19 Feb 2024 16:32:39 +0100 Subject: [PATCH 11/15] Implement logic to get FreeBSD ttyv device names. In FreeBSD the virtual terminals used for Xorg are named ttyv. Their device numbers are also base32 encoded. Code mostly taken from https://github.com/swaywm/wlroots/commit/fc6c0ca12e941d5d7d567834bff3ab7df9447001 --- src/x-server.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/x-server.c b/src/x-server.c index f17a842d5..bc1829677 100644 --- a/src/x-server.c +++ b/src/x-server.c @@ -181,13 +181,60 @@ x_server_connect_session (DisplayServer *display_server, Session *session) g_autofree gchar *tty_text = NULL; g_autofree gchar *vt_text = NULL; +#ifdef __FreeBSD__ + char vty_num32[6]; + int num; + const int base = 32; + size_t offset = 0; + + num = vt - 1; + + if (num == 0) { + vty_num32[offset++] = '0'; + vty_num32[offset] = '\0'; + } else { + for (int remaning = num; remaning > 0; remaning /= base, offset++) { + if (offset + 1 >= 6) { + g_error ("tty number buffer too small"); + goto error; + } + + const int value = remaning % base; + if (value >= 10) { + vty_num32[offset] = 'a' + value - 10; + } else { + vty_num32[offset] = '0' + value; + } + } + + for (size_t i = 0; i < offset / 2; i++) { + const size_t p1 = i; + const size_t p2 = offset - 1 - i; + const char tmp = vty_num32[p1]; + vty_num32[p1] = vty_num32[p2]; + vty_num32[p2] = tmp; + } + + vty_num32[offset] = '\0'; + } + + tty_text = g_strdup_printf ("/dev/ttyv%s", vty_num32); +#else tty_text = g_strdup_printf ("/dev/tty%d", vt); +#endif session_set_tty (session, tty_text); +#ifdef __FreeBSD__ + vt_text = g_strdup_printf ("%d", num); +#else vt_text = g_strdup_printf ("%d", vt); +#endif session_set_env (session, "XDG_VTNR", vt_text); } else +#ifdef __FreeBSD__ +error: +#endif l_debug (session, "Not setting XDG_VTNR"); session_set_env (session, "DISPLAY", x_server_get_address (X_SERVER (display_server))); From 939c34d8ce78d55d32bace3c6d109182e48fb270 Mon Sep 17 00:00:00 2001 From: nerdopolis Date: Wed, 26 Jul 2023 22:28:03 -0400 Subject: [PATCH 12/15] Allow Wayland sessions to start on seat0 on kernels with no VTs --- src/lightdm.c | 2 ++ src/login1.c | 13 +++++++++++++ src/login1.h | 2 ++ src/seat-local.c | 4 ++-- src/seat.c | 19 +++++++++++++++++++ src/seat.h | 4 ++++ 6 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/lightdm.c b/src/lightdm.c index 7fd77ed9b..2821a1c9c 100644 --- a/src/lightdm.c +++ b/src/lightdm.c @@ -424,9 +424,11 @@ add_login1_seat (Login1Seat *login1_seat) set_seat_properties (seat, seat_name); gboolean can_multi_session = login1_seat_get_can_multi_session (login1_seat); + gboolean can_tty = login1_seat_get_can_tty (login1_seat); if (!can_multi_session) g_debug ("Seat %s has property CanMultiSession=no", seat_name); seat_set_supports_multi_session (seat, can_multi_session); + seat_set_can_tty (seat, can_tty); if (is_seat0) seat_set_property (seat, "exit-on-failure", "true"); diff --git a/src/login1.c b/src/login1.c index 42e8fe264..7fe84119e 100644 --- a/src/login1.c +++ b/src/login1.c @@ -67,6 +67,9 @@ typedef struct /* TRUE if can do session switching */ gboolean can_multi_session; + + /* TRUE if seat has TTYs */ + gboolean can_tty; } Login1SeatPrivate; G_DEFINE_TYPE_WITH_PRIVATE (Login1Service, login1_service, G_TYPE_OBJECT) @@ -199,6 +202,8 @@ add_seat (Login1Service *service, const gchar *id, const gchar *path) s_priv->can_graphical = g_variant_get_boolean (value); else if (strcmp (name, "CanMultiSession") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) s_priv->can_multi_session = g_variant_get_boolean (value); + else if (strcmp (name, "CanTTY") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) + s_priv->can_tty = g_variant_get_boolean (value); } } @@ -519,6 +524,14 @@ login1_seat_get_can_multi_session (Login1Seat *seat) return priv->can_multi_session; } +gboolean +login1_seat_get_can_tty (Login1Seat *seat) +{ + Login1SeatPrivate *priv = login1_seat_get_instance_private (seat); + g_return_val_if_fail (seat != NULL, FALSE); + return priv->can_tty; +} + static void login1_seat_init (Login1Seat *seat) { diff --git a/src/login1.h b/src/login1.h index b28855212..d956242c7 100644 --- a/src/login1.h +++ b/src/login1.h @@ -80,6 +80,8 @@ gboolean login1_seat_get_can_graphical (Login1Seat *seat); gboolean login1_seat_get_can_multi_session (Login1Seat *seat); +gboolean login1_seat_get_can_tty (Login1Seat *seat); + G_END_DECLS #endif /* _LOGIN1_H_ */ diff --git a/src/seat-local.c b/src/seat-local.c index dc7a4508e..142dbaf55 100644 --- a/src/seat-local.c +++ b/src/seat-local.c @@ -120,7 +120,7 @@ display_server_transition_plymouth_cb (DisplayServer *display_server, Seat *seat static gint get_vt (SeatLocal *seat, DisplayServer *display_server) { - if (strcmp (seat_get_name (SEAT (seat)), "seat0") != 0) + if (strcmp (seat_get_name (SEAT (seat)), "seat0") != 0 || !seat_get_can_tty ( SEAT (seat))) return -1; /* If Plymouth is running, stop it */ @@ -270,7 +270,7 @@ seat_local_get_active_session (Seat *seat) * FIXME: Use seat_get_expected_active_session even for seat0, falling back * to VT probing if the systemd-logind service is unavailable. */ - if (strcmp (seat_get_name (seat), "seat0") != 0) + if (strcmp (seat_get_name (seat), "seat0") != 0 || !seat_get_can_tty (seat)) return seat_get_expected_active_session (seat); gint vt = vt_get_active (); diff --git a/src/seat.c b/src/seat.c index 8e09026c8..0b55906c0 100644 --- a/src/seat.c +++ b/src/seat.c @@ -39,6 +39,9 @@ typedef struct /* TRUE if this seat can run multiple sessions at once */ gboolean supports_multi_session; + /* TRUE if this seat has TTYs */ + gboolean can_tty; + /* TRUE if display server can be shared for sessions */ gboolean share_display_server; @@ -207,6 +210,14 @@ seat_set_share_display_server (Seat *seat, gboolean share_display_server) priv->share_display_server = share_display_server; } +void +seat_set_can_tty (Seat *seat, gboolean can_tty) +{ + SeatPrivate *priv = seat_get_instance_private (seat); + g_return_if_fail (seat != NULL); + priv->can_tty = can_tty; +} + gboolean seat_start (Seat *seat) { @@ -357,6 +368,14 @@ seat_get_can_switch (Seat *seat) return seat_get_boolean_property (seat, "allow-user-switching") && priv->supports_multi_session; } +gboolean +seat_get_can_tty (Seat *seat) +{ + SeatPrivate *priv = seat_get_instance_private (seat); + g_return_val_if_fail (seat != NULL, FALSE); + return priv->can_tty; +} + gboolean seat_get_allow_guest (Seat *seat) { diff --git a/src/seat.h b/src/seat.h index c037295f5..31cd05a2d 100644 --- a/src/seat.h +++ b/src/seat.h @@ -83,6 +83,8 @@ void seat_set_supports_multi_session (Seat *seat, gboolean supports_multi_sessio void seat_set_share_display_server (Seat *seat, gboolean share_display_server); +void seat_set_can_tty (Seat *seat, gboolean can_tty); + gboolean seat_start (Seat *seat); GList *seat_get_sessions (Seat *seat); @@ -101,6 +103,8 @@ Session *seat_find_session_by_login1_id (Seat *seat, const gchar *login1_session gboolean seat_get_can_switch (Seat *seat); +gboolean seat_get_can_tty (Seat *seat); + gboolean seat_get_allow_guest (Seat *seat); gboolean seat_get_greeter_allow_guest (Seat *seat); From 4e08058ab674db991d58f6a6877d3db222f4e879 Mon Sep 17 00:00:00 2001 From: William Allen Date: Tue, 2 Jul 2024 15:57:12 -0500 Subject: [PATCH 13/15] add payload capture --- .github/workflows/cla-check.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/cla-check.yaml b/.github/workflows/cla-check.yaml index 75e5796bd..007d385f4 100644 --- a/.github/workflows/cla-check.yaml +++ b/.github/workflows/cla-check.yaml @@ -5,5 +5,11 @@ jobs: cla-check: runs-on: ubuntu-latest steps: + - name: Catch Payload + if: runner.debug == '1' + shell: bash + run: | + jq '.' "$GITHUB_EVENT_PATH" + env | sort - name: Check if CLA signed uses: canonical/has-signed-canonical-cla@v1 From 85b69efdb10d1541603ee647bb0c2dae286ffd5b Mon Sep 17 00:00:00 2001 From: William Allen Date: Tue, 2 Jul 2024 16:00:43 -0500 Subject: [PATCH 14/15] Update cla-check.yaml --- .github/workflows/cla-check.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/cla-check.yaml b/.github/workflows/cla-check.yaml index 007d385f4..75e5796bd 100644 --- a/.github/workflows/cla-check.yaml +++ b/.github/workflows/cla-check.yaml @@ -5,11 +5,5 @@ jobs: cla-check: runs-on: ubuntu-latest steps: - - name: Catch Payload - if: runner.debug == '1' - shell: bash - run: | - jq '.' "$GITHUB_EVENT_PATH" - env | sort - name: Check if CLA signed uses: canonical/has-signed-canonical-cla@v1 From 8bc728dc3394a1d76881229e9cc9365280ef0385 Mon Sep 17 00:00:00 2001 From: William Allen Date: Tue, 2 Jul 2024 16:06:01 -0500 Subject: [PATCH 15/15] Update cla-check.yaml --- .github/workflows/cla-check.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/cla-check.yaml b/.github/workflows/cla-check.yaml index 75e5796bd..a80e3d23a 100644 --- a/.github/workflows/cla-check.yaml +++ b/.github/workflows/cla-check.yaml @@ -2,6 +2,14 @@ name: cla-check on: [pull_request_target] jobs: + capture-payload: + runs-on: ubuntu-latest + steps: + - name: Catch Payload + shell: bash + run: | + jq '.' "$GITHUB_EVENT_PATH" + env | sort cla-check: runs-on: ubuntu-latest steps: