Skip to content

Commit c31bbb7

Browse files
committed
Fix crash if switching to greeter and it isn't installed
1 parent 62750ba commit c31bbb7

File tree

6 files changed

+58
-2
lines changed

6 files changed

+58
-2
lines changed

src/seat.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,11 @@ display_server_stopped_cb (DisplayServer *display_server, Seat *seat)
392392
if (!active_session || session_get_display_server (active_session) == display_server)
393393
{
394394
l_debug (seat, "Active display server stopped, starting greeter");
395-
seat_switch_to_greeter (seat);
395+
if (!seat_switch_to_greeter (seat))
396+
{
397+
l_debug (seat, "Stopping; failed to start a greeter");
398+
seat_stop (seat);
399+
}
396400
}
397401
}
398402

@@ -671,7 +675,11 @@ session_stopped_cb (Session *session, Seat *seat)
671675
else if (!IS_GREETER (session) && session == seat_get_active_session (seat))
672676
{
673677
l_debug (seat, "Active session stopped, starting greeter");
674-
seat_switch_to_greeter (seat);
678+
if (!seat_switch_to_greeter (seat))
679+
{
680+
l_debug (seat, "Stopping; failed to start a greeter");
681+
seat_stop (seat);
682+
}
675683
}
676684

677685
/* Stop the display server if no-longer required */
@@ -1241,6 +1249,9 @@ seat_switch_to_greeter (Seat *seat)
12411249
}
12421250

12431251
greeter_session = create_greeter_session (seat);
1252+
if (!greeter_session)
1253+
return FALSE;
1254+
12441255
if (seat->priv->session_to_activate)
12451256
g_object_unref (seat->priv->session_to_activate);
12461257
seat->priv->session_to_activate = g_object_ref (greeter_session);

tests/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ TESTS = \
2222
test-autologin-guest-in-background \
2323
test-autologin-timeout-in-background \
2424
test-autologin-invalid-user \
25+
test-autologin-invalid-greeter \
2526
test-autologin-invalid-session \
2627
test-crash-authenticate \
2728
test-autologin-xserver-crash \
@@ -72,6 +73,7 @@ TESTS = \
7273
test-language \
7374
test-language-no-accounts-service \
7475
test-login-crash-authenticate \
76+
test-login-invalid-greeter \
7577
test-login-gobject \
7678
test-login-gobject-manual \
7779
test-login-gobject-manual-previous-session \
@@ -307,6 +309,7 @@ EXTRA_DIST = \
307309
scripts/autologin-guest-logout.conf \
308310
scripts/autologin-guest-timeout.conf \
309311
scripts/autologin-in-background.conf \
312+
scripts/autologin-invalid-greeter.conf \
310313
scripts/autologin-guest-in-background.conf \
311314
scripts/autologin-timeout-in-background.conf \
312315
scripts/autologin-invalid-session.conf \
@@ -362,6 +365,7 @@ EXTRA_DIST = \
362365
scripts/login-guest-logout.conf \
363366
scripts/login-guest-no-setup-script.conf \
364367
scripts/login-info-prompt.conf \
368+
scripts/login-invalid-greeter.conf \
365369
scripts/login-invalid-session.conf \
366370
scripts/login-invalid-user.conf \
367371
scripts/login-logout.conf \
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# Check quits if autologin session ends and no valid greeter
3+
#
4+
5+
[SeatDefaults]
6+
autologin-user=have-password1
7+
user-session=default
8+
9+
#?RUNNER DAEMON-START
10+
11+
# X server starts
12+
#?XSERVER-0 START VT=7
13+
14+
# Daemon connects when X server is ready
15+
#?*XSERVER-0 INDICATE-READY
16+
#?XSERVER-0 INDICATE-READY
17+
#?XSERVER-0 ACCEPT-CONNECT
18+
19+
# Session starts
20+
#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 DESKTOP_SESSION=default USER=have-password1
21+
#?XSERVER-0 ACCEPT-CONNECT
22+
#?SESSION-X-0 CONNECT-XSERVER
23+
24+
# Logout session
25+
#?*SESSION-X-0 LOGOUT
26+
27+
# X server stops
28+
#?XSERVER-0 TERMINATE SIGNAL=15
29+
30+
#?RUNNER DAEMON-EXIT STATUS=1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# Check fails to start if invalid greeter
3+
#
4+
5+
#?RUNNER DAEMON-START
6+
7+
#?RUNNER DAEMON-EXIT STATUS=1

tests/test-autologin-invalid-greeter

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
./src/dbus-env ./src/test-runner autologin-invalid-greeter INVALID

tests/test-login-invalid-greeter

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
./src/dbus-env ./src/test-runner login-invalid-greeter INVALID

0 commit comments

Comments
 (0)