Skip to content

Commit

Permalink
Disable user switching if logind says it isn't supported
Browse files Browse the repository at this point in the history
This should work now that seat_local_get_active_session returns the
proper value for non-seat0 seats.

Note: systemd-logind v245 and older erroneously report
CanMultiSession=no on non-seat0 seats even when it is supported.  This
change will break those users.  See
<systemd/systemd#15337>.
  • Loading branch information
rhansen authored and robert-ancell committed Apr 28, 2023
1 parent c84feb0 commit e520b32
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/lightdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,10 @@ add_login1_seat (Login1Seat *login1_seat)
{
set_seat_properties (seat, seat_name);

if (!login1_seat_get_can_multi_session (login1_seat))
{
gboolean can_multi_session = login1_seat_get_can_multi_session (login1_seat);
if (!can_multi_session)
g_debug ("Seat %s has property CanMultiSession=no", seat_name);
/* XXX: uncomment this line after bug #1371250 is closed.
seat_set_property (seat, "allow-user-switching", "false"); */
}
seat_set_supports_multi_session (seat, can_multi_session);

if (is_seat0)
seat_set_property (seat, "exit-on-failure", "true");
Expand Down
2 changes: 2 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ TESTS = \
test-multi-seat-autologin-seat1 \
test-multi-seat-seat0-non-graphical \
test-multi-seat-seat0-non-graphical-disabled \
test-multi-seat-no-multi-session \
test-multi-seat-non-graphical \
test-multi-seat-non-graphical-disabled \
test-multi-seat-change-graphical \
Expand Down Expand Up @@ -476,6 +477,7 @@ EXTRA_DIST = \
scripts/multi-seat-change-graphical.conf \
scripts/multi-seat-change-graphical-disabled.conf \
scripts/multi-seat-login.conf \
scripts/multi-seat-no-multi-session \
scripts/multi-seat-non-graphical.conf \
scripts/multi-seat-non-graphical-disabled.conf \
scripts/multi-seat-seat0-non-graphical.conf \
Expand Down
86 changes: 86 additions & 0 deletions tests/scripts/multi-seat-no-multi-session.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#
# Check that logging out from a CanMultiSession=false seat activates greeter on
# that seat.
#

[Seat:*]
user-session=default

#?*START-DAEMON
#?RUNNER DAEMON-START

# seat0 starts
#?XSERVER-0 START VT=7 SEAT=seat0
#?*XSERVER-0 INDICATE-READY
#?XSERVER-0 INDICATE-READY
#?XSERVER-0 ACCEPT-CONNECT
#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
#?LOGIN1 ACTIVATE-SESSION SESSION=c0
#?XSERVER-0 ACCEPT-CONNECT
#?GREETER-X-0 CONNECT-XSERVER
#?GREETER-X-0 CONNECT-TO-DAEMON
#?GREETER-X-0 CONNECTED-TO-DAEMON

# Add seat1
#?*ADD-SEAT ID=seat1 CAN-MULTI-SESSION=FALSE
#?XSERVER-1 START SEAT=seat1
#?*SEAT-CAN-SWITCH PATH=/org/freedesktop/DisplayManager/Seat1
#?RUNNER SEAT-CAN-SWITCH PATH=/org/freedesktop/DisplayManager/Seat1 CAN-SWITCH=FALSE
#?*XSERVER-1 INDICATE-READY
#?XSERVER-1 INDICATE-READY
#?XSERVER-1 ACCEPT-CONNECT
#?GREETER-X-1 START XDG_SEAT=seat1 XDG_SESSION_CLASS=greeter
#?LOGIN1 ACTIVATE-SESSION SESSION=c1
#?XSERVER-1 ACCEPT-CONNECT
#?GREETER-X-1 CONNECT-XSERVER
#?GREETER-X-1 CONNECT-TO-DAEMON
#?GREETER-X-1 CONNECTED-TO-DAEMON

# Log in seat0 so that its active session is not a greeter (in case there is a
# cross-seat bug).
#?*GREETER-X-0 AUTHENTICATE USERNAME=no-password1
#?GREETER-X-0 AUTHENTICATION-COMPLETE USERNAME=no-password1 AUTHENTICATED=TRUE
#?*GREETER-X-0 START-SESSION
#?GREETER-X-0 TERMINATE SIGNAL=15
#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/no-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=no-password1
#?LOGIN1 ACTIVATE-SESSION SESSION=c2
#?XSERVER-0 ACCEPT-CONNECT
#?SESSION-X-0 CONNECT-XSERVER

# Log in seat1
#?*GREETER-X-1 AUTHENTICATE USERNAME=no-password2
#?GREETER-X-1 AUTHENTICATION-COMPLETE USERNAME=no-password2 AUTHENTICATED=TRUE
#?*GREETER-X-1 START-SESSION
#?GREETER-X-1 TERMINATE SIGNAL=15
#?SESSION-X-1 START XDG_SEAT=seat1 XDG_GREETER_DATA_DIR=.*/no-password2 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=no-password2
#?LOGIN1 ACTIVATE-SESSION SESSION=c3
#?XSERVER-1 ACCEPT-CONNECT
#?SESSION-X-1 CONNECT-XSERVER

# Logout seat1
#?*SESSION-X-1 LOGOUT
#?XSERVER-1 TERMINATE SIGNAL=15

# Ensure that the X server and greeter for seat1 are not restarted until after
# the user logs out. WAIT is not needed here because XSERVER-1 cannot terminate
# and start concurrently.
#?*FENCE

#?XSERVER-1 START SEAT=seat1
#?*XSERVER-1 INDICATE-READY
#?XSERVER-1 INDICATE-READY
#?XSERVER-1 ACCEPT-CONNECT
#?GREETER-X-1 START XDG_SEAT=seat1 XDG_SESSION_CLASS=greeter
#?LOGIN1 ACTIVATE-SESSION SESSION=c4
#?XSERVER-1 ACCEPT-CONNECT
#?GREETER-X-1 CONNECT-XSERVER
#?GREETER-X-1 CONNECT-TO-DAEMON
#?GREETER-X-1 CONNECTED-TO-DAEMON

# Cleanup
#?*STOP-DAEMON
#?SESSION-X-0 TERMINATE SIGNAL=15
#?XSERVER-0 TERMINATE SIGNAL=15
#?GREETER-X-1 TERMINATE SIGNAL=15
#?XSERVER-1 TERMINATE SIGNAL=15
#?RUNNER DAEMON-EXIT STATUS=0
5 changes: 4 additions & 1 deletion tests/src/test-runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,10 +697,11 @@ handle_command (const gchar *command)
}
else if (strcmp (name, "SEAT-CAN-SWITCH") == 0)
{
const gchar *path = g_hash_table_lookup (params, "PATH");
g_autoptr(GError) error = NULL;
g_autoptr(GVariant) result = g_dbus_connection_call_sync (dbus_conn,
"org.freedesktop.DisplayManager",
"/org/freedesktop/DisplayManager/Seat0",
path ? path : "/org/freedesktop/DisplayManager/Seat0",
"org.freedesktop.DBus.Properties",
"Get",
g_variant_new ("(ss)", "org.freedesktop.DisplayManager.Seat", "CanSwitch"),
Expand All @@ -711,6 +712,8 @@ handle_command (const gchar *command)
&error);

g_autoptr(GString) status = g_string_new ("RUNNER SEAT-CAN-SWITCH");
if (path)
g_string_append_printf (status, " PATH=%s", path);
if (result)
{
g_autoptr(GVariant) value = NULL;
Expand Down
2 changes: 2 additions & 0 deletions tests/test-multi-seat-no-multi-session
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
./src/dbus-env ./src/test-runner multi-seat-no-multi-session test-gobject-greeter

0 comments on commit e520b32

Please sign in to comment.