diff options
-rw-r--r-- | src/lightdm.c | 57 | ||||
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/scripts/multi-seat-with-globbing-config-sections.conf | 71 | ||||
-rw-r--r-- | tests/src/test-runner.c | 35 | ||||
-rwxr-xr-x | tests/test-multi-seat-with-globbing-config-sections | 2 |
5 files changed, 29 insertions, 138 deletions
diff --git a/src/lightdm.c b/src/lightdm.c index 2b2b1458..3193008b 100644 --- a/src/lightdm.c +++ b/src/lightdm.c @@ -145,27 +145,6 @@ log_init (void) g_free (path); } -static GList* -get_config_sections (const gchar *seat_name) -{ - gchar **groups, **i; - GList *config_sections = NULL; - - groups = config_get_groups (config_get_instance ()); - for (i = groups; *i; i++) - { - if (g_str_has_prefix (*i, "Seat:")) - { - const gchar *seat_name_glob = *i + strlen ("Seat:"); - if (g_pattern_match_simple (seat_name_glob, seat_name)) - config_sections = g_list_append (config_sections, g_strdup (*i)); - } - } - if (groups) - g_strfreev (groups); - return config_sections; -} - static void set_seat_properties (Seat *seat, const gchar *config_section) { @@ -242,13 +221,11 @@ display_manager_seat_removed_cb (DisplayManager *display_manager, Seat *seat) if (next_seat) { - GList *config_sections, *link; + gchar *config_section; - config_sections = get_config_sections (seat_get_name (seat)); - for (link = config_sections; link; link = link->next) - set_seat_properties (next_seat, (gchar*) link->data); - if (config_sections) - g_list_free_full (config_sections, g_free); + config_section = g_strdup_printf ("Seat:%s", seat_get_name (seat)); + set_seat_properties (next_seat, config_section); + g_free (config_section); // We set this manually on default seat. Let's port it over if needed. if (seat_get_boolean_property (seat, "exit-on-failure")) @@ -961,18 +938,29 @@ static gboolean add_login1_seat (Login1Seat *login1_seat) { const gchar *seat_name = login1_seat_get_id (login1_seat); + gchar **groups, **i; + gchar *config_section = NULL; gchar **types = NULL, **type; - GList *config_sections = NULL, *link; Seat *seat = NULL; gboolean is_seat0, started = FALSE; g_debug ("New seat added from logind: %s", seat_name); is_seat0 = strcmp (seat_name, "seat0") == 0; - config_sections = get_config_sections (seat_name); - for (link = config_sections; link; link = link->next) + groups = config_get_groups (config_get_instance ()); + for (i = groups; !config_section && *i; i++) + { + if (g_str_has_prefix (*i, "Seat:") && + g_str_has_suffix (*i, seat_name)) + { + config_section = g_strdup (*i); + break; + } + } + g_strfreev (groups); + + if (config_section) { - gchar *config_section = link->data; g_debug ("Loading properties from config section %s", config_section); types = config_get_string_list (config_get_instance (), config_section, "type"); } @@ -993,8 +981,8 @@ add_login1_seat (Login1Seat *login1_seat) seat_set_property (seat, "allow-user-switching", "false"); } - for (link = config_sections; link; link = link->next) - set_seat_properties (seat, (gchar*) link->data); + if (config_section) + set_seat_properties (seat, config_section); if (is_seat0) seat_set_property (seat, "exit-on-failure", "true"); @@ -1009,8 +997,7 @@ add_login1_seat (Login1Seat *login1_seat) g_debug ("Failed to start seat: %s", seat_name); } - if (config_sections) - g_list_free_full (config_sections, g_free); + g_free (config_section); g_object_unref (seat); return started; diff --git a/tests/Makefile.am b/tests/Makefile.am index d0426096..1685d283 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -183,7 +183,6 @@ TESTS = \ test-multi-seat \ test-multi-seat-non-graphical \ test-multi-seat-change-graphical \ - test-multi-seat-with-globbing-config-sections \ test-mir-autologin \ test-mir-greeter \ test-mir-session \ @@ -449,7 +448,6 @@ EXTRA_DIST = \ scripts/multi-seat.conf \ scripts/multi-seat-non-graphical.conf \ scripts/multi-seat-change-graphical.conf \ - scripts/multi-seat-with-globbing-config-sections.conf \ scripts/no-accounts-service.conf \ scripts/no-config.conf \ scripts/no-console-kit.conf \ diff --git a/tests/scripts/multi-seat-with-globbing-config-sections.conf b/tests/scripts/multi-seat-with-globbing-config-sections.conf deleted file mode 100644 index 3706dfc3..00000000 --- a/tests/scripts/multi-seat-with-globbing-config-sections.conf +++ /dev/null @@ -1,71 +0,0 @@ -# -# Check can set globbing config sections matching different seats -# - -[Seat:*] -autologin-user=have-password1 -user-session=default - -[Seat:seat*Foo] -autologin-user=have-password2 - -[Seat:seat-AAA-Foo] -autologin-user=have-password3 - -[Seat:seat-BBB*] -autologin-user=have-password4 - -#?*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 - -# Session starts for configured user -#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 -#?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT -#?SESSION-X-0 CONNECT-XSERVER - -# Add seat-AAA-Foo -#?*ADD-SEAT ID=seat-AAA-Foo - -# seat-AAA-Foo starts -#?XSERVER-1 START SEAT=seat-AAA-Foo SHAREVTS=TRUE -#?*XSERVER-1 INDICATE-READY -#?XSERVER-1 INDICATE-READY -#?XSERVER-1 ACCEPT-CONNECT - -# Session starts for configured user -#?SESSION-X-1 START XDG_SEAT=seat-AAA-Foo XDG_GREETER_DATA_DIR=.*/have-password3 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password3 -#?LOGIN1 ACTIVATE-SESSION SESSION=c1 -#?XSERVER-1 ACCEPT-CONNECT -#?SESSION-X-1 CONNECT-XSERVER - -# Add seat-BBB-Foo -#?*ADD-SEAT ID=seat-BBB-Foo - -# seat-BBB-Foo starts -#?XSERVER-2 START SEAT=seat-BBB-Foo SHAREVTS=TRUE -#?*XSERVER-2 INDICATE-READY -#?XSERVER-2 INDICATE-READY -#?XSERVER-2 ACCEPT-CONNECT - -# Session starts for configured user -#?SESSION-X-2 START XDG_SEAT=seat-BBB-Foo XDG_GREETER_DATA_DIR=.*/have-password4 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password4 -#?LOGIN1 ACTIVATE-SESSION SESSION=c2 -#?XSERVER-2 ACCEPT-CONNECT -#?SESSION-X-2 CONNECT-XSERVER - -# Cleanup -#?*STOP-DAEMON -#?XSERVER-0 TERMINATE SIGNAL=15 -#?SESSION-X-0 TERMINATE SIGNAL=15 -#?XSERVER-1 TERMINATE SIGNAL=15 -#?SESSION-X-1 TERMINATE SIGNAL=15 -#?XSERVER-2 TERMINATE SIGNAL=15 -#?SESSION-X-2 TERMINATE SIGNAL=15 -#?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/src/test-runner.c b/tests/src/test-runner.c index 631d299c..2dfcfd96 100644 --- a/tests/src/test-runner.c +++ b/tests/src/test-runner.c @@ -1451,29 +1451,10 @@ handle_login1_seat_get_property (GDBusConnection *connection, return NULL; } -static gchar * -escape_seat_id (const gchar *id) -{ - GString *s; - int i; - - s = g_string_new (""); - for (i = 0; id[i]; i++) - { - if (isalnum (id[i]) || id[i] == '_') - g_string_append_c (s, id[i]); - else - g_string_append_printf (s, "_%02x", id[i]); - } - - return g_string_free (s, FALSE); -} - static Login1Seat * add_login1_seat (GDBusConnection *connection, const gchar *id, gboolean emit_signal) { Login1Seat *seat; - gchar *escaped_id; GError *error = NULL; GDBusNodeInfo *login1_seat_info; @@ -1491,6 +1472,13 @@ add_login1_seat (GDBusConnection *connection, const gchar *id, gboolean emit_sig handle_login1_seat_get_property, }; + seat = g_malloc0 (sizeof (Login1Seat)); + login1_seats = g_list_append (login1_seats, seat); + seat->id = g_strdup (id); + seat->path = g_strdup_printf ("/org/freedesktop/login1/seat/%s", seat->id); + seat->can_graphical = TRUE; + seat->can_multi_session = TRUE; + login1_seat_info = g_dbus_node_info_new_for_xml (login1_seat_interface, &error); if (error) g_warning ("Failed to parse login1 seat D-Bus interface: %s", error->message); @@ -1498,15 +1486,6 @@ add_login1_seat (GDBusConnection *connection, const gchar *id, gboolean emit_sig if (!login1_seat_info) return NULL; - seat = g_malloc0 (sizeof (Login1Seat)); - login1_seats = g_list_append (login1_seats, seat); - seat->id = g_strdup (id); - escaped_id = escape_seat_id (seat->id); - seat->path = g_strdup_printf ("/org/freedesktop/login1/seat/%s", escaped_id); - g_free (escaped_id); - seat->can_graphical = TRUE; - seat->can_multi_session = TRUE; - g_dbus_connection_register_object (connection, seat->path, login1_seat_info->interfaces[0], diff --git a/tests/test-multi-seat-with-globbing-config-sections b/tests/test-multi-seat-with-globbing-config-sections deleted file mode 100755 index 42123577..00000000 --- a/tests/test-multi-seat-with-globbing-config-sections +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./src/dbus-env ./src/test-runner multi-seat-with-globbing-config-sections test-gobject-greeter |