From 00e22682b49d1281b6a66e745a34417b9ccfc80e Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Wed, 1 Jun 2016 12:07:33 +1200 Subject: [PATCH] Fix invalid unref when fail to start seat. Add regression test for this case --- src/lightdm.c | 11 +++++------ tests/Makefile.am | 2 ++ tests/scripts/invalid-seat.conf | 14 ++++++++++++++ tests/test-invalid-seat | 2 ++ 4 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 tests/scripts/invalid-seat.conf create mode 100755 tests/test-invalid-seat diff --git a/src/lightdm.c b/src/lightdm.c index 32ab3c05..714f86fc 100644 --- a/src/lightdm.c +++ b/src/lightdm.c @@ -1038,15 +1038,14 @@ add_login1_seat (Login1Seat *login1_seat) seat_set_property (seat, "exit-on-failure", "true"); } else - g_debug ("Unable to create seat: %s", seat_name); - - if (seat) { - started = display_manager_add_seat (display_manager, seat); - if (!started) - g_debug ("Failed to start seat: %s", seat_name); + g_debug ("Unable to create seat: %s", seat_name); + return FALSE; } + started = display_manager_add_seat (display_manager, seat); + if (!started) + g_debug ("Failed to start seat: %s", seat_name); g_object_unref (seat); return started; diff --git a/tests/Makefile.am b/tests/Makefile.am index 1e55a588..866f46a7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -249,6 +249,7 @@ TESTS = \ test-unity-mir-switch \ test-unity-mir-switch-to-user-resettable \ test-unity-mir-script-hooks \ + test-invalid-seat \ test-seatdefaults-still-supported # test-mir-script-hooks \ @@ -447,6 +448,7 @@ EXTRA_DIST = \ scripts/headless.conf \ scripts/home-dir-on-authenticate.conf \ scripts/home-dir-on-session.conf \ + scripts/invalid-seat.conf \ scripts/language.conf \ scripts/language-env.conf \ scripts/language-no-accounts-service.conf \ diff --git a/tests/scripts/invalid-seat.conf b/tests/scripts/invalid-seat.conf new file mode 100644 index 00000000..1be78f40 --- /dev/null +++ b/tests/scripts/invalid-seat.conf @@ -0,0 +1,14 @@ +# +# Check stops on an unknown seat type +# + +[Seat:*] +type=invalid +autologin-user=have-password1 +user-session=default + +#?*START-DAEMON +#?RUNNER DAEMON-START + +# Can't start an unknown seat +#?RUNNER DAEMON-EXIT STATUS=1 diff --git a/tests/test-invalid-seat b/tests/test-invalid-seat new file mode 100755 index 00000000..31d79d82 --- /dev/null +++ b/tests/test-invalid-seat @@ -0,0 +1,2 @@ +#!/bin/sh +./src/dbus-env ./src/test-runner invalid-seat test-gobject-greeter -- 2.39.2