Merge lp:~ubuntu-multiseat/lightdm/simple-globbing-in-seat-config-section into lp:lightdm

Proposed by Laércio de Sousa
Status: Superseded
Proposed branch: lp:~ubuntu-multiseat/lightdm/simple-globbing-in-seat-config-section
Merge into: lp:lightdm
Diff against target: 243 lines (+146/-23)
4 files modified
src/lightdm.c (+36/-23)
tests/Makefile.am (+2/-0)
tests/scripts/multi-seat-with-globbing-config-sections.conf (+106/-0)
tests/test-multi-seat-with-globbing-config-sections (+2/-0)
To merge this branch: bzr merge lp:~ubuntu-multiseat/lightdm/simple-globbing-in-seat-config-section
Reviewer Review Type Date Requested Status
Robert Ancell Needs Fixing
Review via email: mp+232398@code.launchpad.net

This proposal has been superseded by a proposal from 2014-09-03.

Description of the change

Add support for simple globbing in seat config sections.

Example: if a config section [Seat:seatFoo*] is available in lightdm.conf, it will match any seat name starting with "seatFoo", like "seatFooBar", "seatFooBaz", etc.

In particular, [Seat:seat*] will match any seat added from logind (including seat0), and [Seat:*] will match any seat (including those eventually added from other mechanisms than logind), just as [SeatDefaults] currently does.

To post a comment you must log in.
Revision history for this message
Laércio de Sousa (lbssousa) wrote :

[NEW ISSUE] New function get_config_section() should return a list of all available globbing config sections that match a given seat name (including the exact match), not only the first occurrence.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Yes, you could match against n-sections. Also, you should use the GLib pattern matcher [1]

[1] https://developer.gnome.org/glib/stable/glib-Glob-style-pattern-matching.html

review: Needs Fixing
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Will also need a regression test to confirm this matching works

Revision history for this message
Laércio de Sousa (lbssousa) wrote :

> Yes, you could match against n-sections. Also, you should use the GLib pattern
> matcher [1]
>
> [1] https://developer.gnome.org/glib/stable/glib-Glob-style-pattern-
> matching.html

Done.

Revision history for this message
Laércio de Sousa (lbssousa) wrote :

> Will also need a regression test to confirm this matching works

I've written a regression test that starts 3 seats and enables autologin as guest with different timeouts for the non-seat0 ones. My local "make check" returns FAIL to this test, but I could not see any relevant error message in test log.

Could you review it, please?

Revision history for this message
Laércio de Sousa (lbssousa) wrote :

[NEW IDEA] Support wildcard %s when setting seat property values, which will be replaced with corresponding seat name.

Revision history for this message
Laércio de Sousa (lbssousa) wrote :

Example:

[Seat:seat-*]
xserver-command=X -config xorg.conf.%s

Revision history for this message
Robert Ancell (robert-ancell) wrote :

There were some typos in the script but the main reason was the seat IDs (e.g. "seat-AAA-Foo") were being converted into invalid D-Bus address names (e.g. "/org/freedesktop/login1/seat/seat-AAA-Foo" - "_" is not allowed in D-Bus addresses). So there was a bug in my mock login1 code in tests/src/test-runner.c

I fixed that up and simplified the test.

Thanks!

Revision history for this message
Robert Ancell (robert-ancell) wrote :

The wildcard idea sounds good, things to think about:
- Does the wildcard work in all config values or just command?
- Could this wildcard be a valid value in other cases and will those values now have to be escaped (potentially breaking existing config)? For this reason, we should use a bigger token, e.g. "%(seat-name)" which is both more self-explanatory and less likely to collide with something else.
- What are the escape rules if you need a literal "%s"?
- Are there other values we should give?

As always, please open a new MP and/or bug for this feature.

2047. By Laércio de Sousa

Reintroduce test after merge with trunk.

2048. By Laércio de Sousa

Remove dashes from logind seat IDs in test script

2049. By Laércio de Sousa

Fix iteration pointer when iterating backwards on GList object

2050. By Laércio de Sousa

Move debug message from add_login1_seat() to set_seat_properties() body.

2051. By Laércio de Sousa

Merge with trunk

2052. By Laércio de Sousa

Remove duplicated line after merging with trunk

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/lightdm.c'
--- src/lightdm.c 2014-08-28 00:11:30 +0000
+++ src/lightdm.c 2014-08-28 14:40:56 +0000
@@ -145,6 +145,27 @@
145 g_free (path);145 g_free (path);
146}146}
147147
148static GList*
149get_config_sections (const gchar *seat_name)
150{
151 gchar **groups, **i;
152 GList *config_sections = NULL;
153
154 groups = config_get_groups (config_get_instance ());
155 for (i = groups; *i; i++)
156 {
157 if (g_str_has_prefix (*i, "Seat:"))
158 {
159 const gchar *seat_name_glob = *i + strlen ("Seat:");
160 if (g_pattern_match_simple (seat_name_glob, seat_name))
161 config_sections = g_list_append (config_sections, g_strdup (*i));
162 }
163 }
164 if (groups)
165 g_strfreev (groups);
166 return config_sections;
167}
168
148static void169static void
149set_seat_properties (Seat *seat, const gchar *config_section)170set_seat_properties (Seat *seat, const gchar *config_section)
150{171{
@@ -221,11 +242,13 @@
221242
222 if (next_seat)243 if (next_seat)
223 {244 {
224 gchar *config_section;245 GList *config_sections, *link;
225246
226 config_section = g_strdup_printf ("Seat:%s", seat_get_name (seat));247 config_sections = get_config_sections (seat_get_name (seat));
227 set_seat_properties (next_seat, config_section);248 for (link = config_sections; link; link = link->next)
228 g_free (config_section);249 set_seat_properties (next_seat, (gchar*) link->data);
250 if (config_sections)
251 g_list_free_full (config_sections, g_free);
229252
230 // We set this manually on default seat. Let's port it over if needed.253 // We set this manually on default seat. Let's port it over if needed.
231 if (seat_get_boolean_property (seat, "exit-on-failure"))254 if (seat_get_boolean_property (seat, "exit-on-failure"))
@@ -938,29 +961,18 @@
938add_login1_seat (Login1Seat *login1_seat)961add_login1_seat (Login1Seat *login1_seat)
939{962{
940 const gchar *seat_name = login1_seat_get_id (login1_seat);963 const gchar *seat_name = login1_seat_get_id (login1_seat);
941 gchar **groups, **i;
942 gchar *config_section = NULL;
943 gchar **types = NULL, **type;964 gchar **types = NULL, **type;
965 GList *config_sections = NULL, *link;
944 Seat *seat = NULL;966 Seat *seat = NULL;
945 gboolean is_seat0, started = FALSE;967 gboolean is_seat0, started = FALSE;
946968
947 g_debug ("New seat added from logind: %s", seat_name);969 g_debug ("New seat added from logind: %s", seat_name);
948 is_seat0 = strcmp (seat_name, "seat0") == 0;970 is_seat0 = strcmp (seat_name, "seat0") == 0;
949971
950 groups = config_get_groups (config_get_instance ());972 config_sections = get_config_sections (seat_name);
951 for (i = groups; !config_section && *i; i++)973 for (link = config_sections; link; link = link->next)
952 {974 {
953 if (g_str_has_prefix (*i, "Seat:") &&975 gchar *config_section = link->data;
954 g_str_has_suffix (*i, seat_name))
955 {
956 config_section = g_strdup (*i);
957 break;
958 }
959 }
960 g_strfreev (groups);
961
962 if (config_section)
963 {
964 g_debug ("Loading properties from config section %s", config_section);976 g_debug ("Loading properties from config section %s", config_section);
965 types = config_get_string_list (config_get_instance (), config_section, "type");977 types = config_get_string_list (config_get_instance (), config_section, "type");
966 }978 }
@@ -981,8 +993,8 @@
981 seat_set_property (seat, "allow-user-switching", "false");993 seat_set_property (seat, "allow-user-switching", "false");
982 }994 }
983995
984 if (config_section)996 for (link = config_sections; link; link = link->next)
985 set_seat_properties (seat, config_section);997 set_seat_properties (seat, (gchar*) link->data);
986998
987 if (is_seat0)999 if (is_seat0)
988 seat_set_property (seat, "exit-on-failure", "true");1000 seat_set_property (seat, "exit-on-failure", "true");
@@ -997,7 +1009,8 @@
997 g_debug ("Failed to start seat: %s", seat_name);1009 g_debug ("Failed to start seat: %s", seat_name);
998 }1010 }
9991011
1000 g_free (config_section);1012 if (config_sections)
1013 g_list_free_full (config_sections, g_free);
1001 g_object_unref (seat);1014 g_object_unref (seat);
1002 1015
1003 return started;1016 return started;
10041017
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2014-08-28 00:11:30 +0000
+++ tests/Makefile.am 2014-08-28 14:40:56 +0000
@@ -183,6 +183,7 @@
183 test-multi-seat \183 test-multi-seat \
184 test-multi-seat-non-graphical \184 test-multi-seat-non-graphical \
185 test-multi-seat-change-graphical \185 test-multi-seat-change-graphical \
186 test-multi-seat-with-globbing-config-sections \
186 test-mir-autologin \187 test-mir-autologin \
187 test-mir-greeter \188 test-mir-greeter \
188 test-mir-session \189 test-mir-session \
@@ -448,6 +449,7 @@
448 scripts/multi-seat.conf \449 scripts/multi-seat.conf \
449 scripts/multi-seat-non-graphical.conf \450 scripts/multi-seat-non-graphical.conf \
450 scripts/multi-seat-change-graphical.conf \451 scripts/multi-seat-change-graphical.conf \
452 scripts/multi-seat-with-globbing-config-sections.conf \
451 scripts/no-accounts-service.conf \453 scripts/no-accounts-service.conf \
452 scripts/no-config.conf \454 scripts/no-config.conf \
453 scripts/no-console-kit.conf \455 scripts/no-console-kit.conf \
454456
=== added file 'tests/scripts/multi-seat-with-globbing-config-sections.conf'
--- tests/scripts/multi-seat-with-globbing-config-sections.conf 1970-01-01 00:00:00 +0000
+++ tests/scripts/multi-seat-with-globbing-config-sections.conf 2014-08-28 14:40:56 +0000
@@ -0,0 +1,106 @@
1#
2# Check can set globbing config sections matching different seats
3#
4
5[Seat:seat*Foo]
6autologin-guest=true
7user-session=default
8
9[Seat:seat-AAA-Foo]
10autologin-user-timeout=5
11
12[Seat:seat-BBB*]
13autologin-user-timeout=10
14
15#?*START-DAEMON
16#?RUNNER DAEMON-START
17
18# seat0 starts
19#?XSERVER-0 START VT=7 SEAT=seat0
20#?*XSERVER-0 INDICATE-READY
21#?XSERVER-0 INDICATE-READY
22#?XSERVER-0 ACCEPT-CONNECT
23#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
24#?LOGIN1 ACTIVATE-SESSION SESSION=c0
25#?XSERVER-0 ACCEPT-CONNECT
26#?GREETER-X-0 CONNECT-XSERVER
27#?GREETER-X-0 CONNECT-TO-DAEMON
28#?GREETER-X-0 CONNECTED-TO-DAEMON
29
30# Add seat-AAA-Foo
31#?*ADD-SEAT ID=seat-AAA-Foo
32
33# seat-AAA-Foo starts
34#?XSERVER-1 START SEAT=seat-AAA-Foo SHAREVTS=TRUE
35#?*XSERVER-1 INDICATE-READY
36#?XSERVER-1 INDICATE-READY
37#?XSERVER-1 ACCEPT-CONNECT
38#?GREETER-X-1 START XDG_SEAT=seat-AAA-Foo XDG_SESSION_CLASS=greeter
39#?LOGIN1 ACTIVATE-SESSION SESSION=c1
40#?XSERVER-1 ACCEPT-CONNECT
41#?GREETER-X-1 CONNECT-XSERVER
42#?GREETER-X-1 CONNECT-TO-DAEMON
43#?GREETER-X-1 CONNECTED-TO-DAEMON
44
45# Greeter is requested to timeout
46#?GREETER-X-1 AUTOLOGIN-GUEST TIMEOUT=5
47
48# Trigger autologin
49#?*GREETER-X-1 AUTHENTICATE-AUTOLOGIN
50#?GREETER-X-1 AUTHENTICATION-COMPLETE AUTHENTICATED=TRUE
51#?*GREETER-X-1 START-SESSION
52#?GREETER-X-1 TERMINATE SIGNAL=15
53
54# Guest account created
55#?GUEST-ACCOUNT ADD USERNAME=guest-.*
56
57# Guest session starts
58#?SESSION-X-1 START XDG_SEAT=seat-AAA-Foo XDG_GREETER_DATA_DIR=.*/guest-.* XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=guest-.*
59#?LOGIN1 ACTIVATE-SESSION SESSION=c2
60#?XSERVER-1 ACCEPT-CONNECT
61#?SESSION-X-1 CONNECT-XSERVER
62
63# Add seat-BBB-Foo
64#?*ADD-SEAT ID=seat-BBB-Foo
65
66# seat-BBB-Foo starts
67#?XSERVER-2 START SEAT=seat-BBB-Foo SHAREVTS=TRUE
68#?*XSERVER-2 INDICATE-READY
69#?XSERVER-2 INDICATE-READY
70#?XSERVER-2 ACCEPT-CONNECT
71#?GREETER-X-2 START XDG_SEAT=seat-BBB-Foo XDG_SESSION_CLASS=greeter
72#?LOGIN1 ACTIVATE-SESSION SESSION=c3
73#?XSERVER-2 ACCEPT-CONNECT
74#?GREETER-X-2 CONNECT-XSERVER
75#?GREETER-X-2 CONNECT-TO-DAEMON
76#?GREETER-X-2 CONNECTED-TO-DAEMON
77
78# Greeter is requested to timeout
79#?GREETER-X-1 AUTOLOGIN-GUEST TIMEOUT=10
80
81# Trigger autologin
82#?*GREETER-X-2 AUTHENTICATE-AUTOLOGIN
83#?GREETER-X-2 AUTHENTICATION-COMPLETE AUTHENTICATED=TRUE
84#?*GREETER-X-2 START-SESSION
85#?GREETER-X-2 TERMINATE SIGNAL=15
86
87# Guest account created
88#?GUEST-ACCOUNT ADD USERNAME=guest-.*
89
90# Guest session starts
91#?SESSION-X-2 START XDG_SEAT=seat-BBB-Foo XDG_GREETER_DATA_DIR=.*/guest-.* XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=guest-.*
92#?LOGIN1 ACTIVATE-SESSION SESSION=c4
93#?XSERVER-2 ACCEPT-CONNECT
94#?SESSION-X-2 CONNECT-XSERVER
95
96# Cleanup
97#?*STOP-DAEMON
98#?GREETER-X-0 TERMINATE SIGNAL=15
99#?XSERVER-0 TERMINATE SIGNAL=15
100#?XSESSION-X-1 TERMINATE SIGNAL=15
101#?XSERVER-1 TERMINATE SIGNAL=15
102#?GUEST-ACCOUNT REMOVE USERNAME=guest.*
103#?XSESSION-X-2 TERMINATE SIGNAL=15
104#?XSERVER-2 TERMINATE SIGNAL=15
105#?GUEST-ACCOUNT REMOVE USERNAME=guest.*
106#?RUNNER DAEMON-EXIT STATUS=0
0107
=== added file 'tests/test-multi-seat-with-globbing-config-sections'
--- tests/test-multi-seat-with-globbing-config-sections 1970-01-01 00:00:00 +0000
+++ tests/test-multi-seat-with-globbing-config-sections 2014-08-28 14:40:56 +0000
@@ -0,0 +1,2 @@
1#!/bin/sh
2./src/dbus-env ./src/test-runner multi-seat-with-globbing-config-sections test-gobject-greeter

Subscribers

People subscribed via source and target branches