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
1=== modified file 'src/lightdm.c'
2--- src/lightdm.c 2014-08-28 00:11:30 +0000
3+++ src/lightdm.c 2014-08-28 14:40:56 +0000
4@@ -145,6 +145,27 @@
5 g_free (path);
6 }
7
8+static GList*
9+get_config_sections (const gchar *seat_name)
10+{
11+ gchar **groups, **i;
12+ GList *config_sections = NULL;
13+
14+ groups = config_get_groups (config_get_instance ());
15+ for (i = groups; *i; i++)
16+ {
17+ if (g_str_has_prefix (*i, "Seat:"))
18+ {
19+ const gchar *seat_name_glob = *i + strlen ("Seat:");
20+ if (g_pattern_match_simple (seat_name_glob, seat_name))
21+ config_sections = g_list_append (config_sections, g_strdup (*i));
22+ }
23+ }
24+ if (groups)
25+ g_strfreev (groups);
26+ return config_sections;
27+}
28+
29 static void
30 set_seat_properties (Seat *seat, const gchar *config_section)
31 {
32@@ -221,11 +242,13 @@
33
34 if (next_seat)
35 {
36- gchar *config_section;
37+ GList *config_sections, *link;
38
39- config_section = g_strdup_printf ("Seat:%s", seat_get_name (seat));
40- set_seat_properties (next_seat, config_section);
41- g_free (config_section);
42+ config_sections = get_config_sections (seat_get_name (seat));
43+ for (link = config_sections; link; link = link->next)
44+ set_seat_properties (next_seat, (gchar*) link->data);
45+ if (config_sections)
46+ g_list_free_full (config_sections, g_free);
47
48 // We set this manually on default seat. Let's port it over if needed.
49 if (seat_get_boolean_property (seat, "exit-on-failure"))
50@@ -938,29 +961,18 @@
51 add_login1_seat (Login1Seat *login1_seat)
52 {
53 const gchar *seat_name = login1_seat_get_id (login1_seat);
54- gchar **groups, **i;
55- gchar *config_section = NULL;
56 gchar **types = NULL, **type;
57+ GList *config_sections = NULL, *link;
58 Seat *seat = NULL;
59 gboolean is_seat0, started = FALSE;
60
61 g_debug ("New seat added from logind: %s", seat_name);
62 is_seat0 = strcmp (seat_name, "seat0") == 0;
63
64- groups = config_get_groups (config_get_instance ());
65- for (i = groups; !config_section && *i; i++)
66- {
67- if (g_str_has_prefix (*i, "Seat:") &&
68- g_str_has_suffix (*i, seat_name))
69- {
70- config_section = g_strdup (*i);
71- break;
72- }
73- }
74- g_strfreev (groups);
75-
76- if (config_section)
77- {
78+ config_sections = get_config_sections (seat_name);
79+ for (link = config_sections; link; link = link->next)
80+ {
81+ gchar *config_section = link->data;
82 g_debug ("Loading properties from config section %s", config_section);
83 types = config_get_string_list (config_get_instance (), config_section, "type");
84 }
85@@ -981,8 +993,8 @@
86 seat_set_property (seat, "allow-user-switching", "false");
87 }
88
89- if (config_section)
90- set_seat_properties (seat, config_section);
91+ for (link = config_sections; link; link = link->next)
92+ set_seat_properties (seat, (gchar*) link->data);
93
94 if (is_seat0)
95 seat_set_property (seat, "exit-on-failure", "true");
96@@ -997,7 +1009,8 @@
97 g_debug ("Failed to start seat: %s", seat_name);
98 }
99
100- g_free (config_section);
101+ if (config_sections)
102+ g_list_free_full (config_sections, g_free);
103 g_object_unref (seat);
104
105 return started;
106
107=== modified file 'tests/Makefile.am'
108--- tests/Makefile.am 2014-08-28 00:11:30 +0000
109+++ tests/Makefile.am 2014-08-28 14:40:56 +0000
110@@ -183,6 +183,7 @@
111 test-multi-seat \
112 test-multi-seat-non-graphical \
113 test-multi-seat-change-graphical \
114+ test-multi-seat-with-globbing-config-sections \
115 test-mir-autologin \
116 test-mir-greeter \
117 test-mir-session \
118@@ -448,6 +449,7 @@
119 scripts/multi-seat.conf \
120 scripts/multi-seat-non-graphical.conf \
121 scripts/multi-seat-change-graphical.conf \
122+ scripts/multi-seat-with-globbing-config-sections.conf \
123 scripts/no-accounts-service.conf \
124 scripts/no-config.conf \
125 scripts/no-console-kit.conf \
126
127=== added file 'tests/scripts/multi-seat-with-globbing-config-sections.conf'
128--- tests/scripts/multi-seat-with-globbing-config-sections.conf 1970-01-01 00:00:00 +0000
129+++ tests/scripts/multi-seat-with-globbing-config-sections.conf 2014-08-28 14:40:56 +0000
130@@ -0,0 +1,106 @@
131+#
132+# Check can set globbing config sections matching different seats
133+#
134+
135+[Seat:seat*Foo]
136+autologin-guest=true
137+user-session=default
138+
139+[Seat:seat-AAA-Foo]
140+autologin-user-timeout=5
141+
142+[Seat:seat-BBB*]
143+autologin-user-timeout=10
144+
145+#?*START-DAEMON
146+#?RUNNER DAEMON-START
147+
148+# seat0 starts
149+#?XSERVER-0 START VT=7 SEAT=seat0
150+#?*XSERVER-0 INDICATE-READY
151+#?XSERVER-0 INDICATE-READY
152+#?XSERVER-0 ACCEPT-CONNECT
153+#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
154+#?LOGIN1 ACTIVATE-SESSION SESSION=c0
155+#?XSERVER-0 ACCEPT-CONNECT
156+#?GREETER-X-0 CONNECT-XSERVER
157+#?GREETER-X-0 CONNECT-TO-DAEMON
158+#?GREETER-X-0 CONNECTED-TO-DAEMON
159+
160+# Add seat-AAA-Foo
161+#?*ADD-SEAT ID=seat-AAA-Foo
162+
163+# seat-AAA-Foo starts
164+#?XSERVER-1 START SEAT=seat-AAA-Foo SHAREVTS=TRUE
165+#?*XSERVER-1 INDICATE-READY
166+#?XSERVER-1 INDICATE-READY
167+#?XSERVER-1 ACCEPT-CONNECT
168+#?GREETER-X-1 START XDG_SEAT=seat-AAA-Foo XDG_SESSION_CLASS=greeter
169+#?LOGIN1 ACTIVATE-SESSION SESSION=c1
170+#?XSERVER-1 ACCEPT-CONNECT
171+#?GREETER-X-1 CONNECT-XSERVER
172+#?GREETER-X-1 CONNECT-TO-DAEMON
173+#?GREETER-X-1 CONNECTED-TO-DAEMON
174+
175+# Greeter is requested to timeout
176+#?GREETER-X-1 AUTOLOGIN-GUEST TIMEOUT=5
177+
178+# Trigger autologin
179+#?*GREETER-X-1 AUTHENTICATE-AUTOLOGIN
180+#?GREETER-X-1 AUTHENTICATION-COMPLETE AUTHENTICATED=TRUE
181+#?*GREETER-X-1 START-SESSION
182+#?GREETER-X-1 TERMINATE SIGNAL=15
183+
184+# Guest account created
185+#?GUEST-ACCOUNT ADD USERNAME=guest-.*
186+
187+# Guest session starts
188+#?SESSION-X-1 START XDG_SEAT=seat-AAA-Foo XDG_GREETER_DATA_DIR=.*/guest-.* XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=guest-.*
189+#?LOGIN1 ACTIVATE-SESSION SESSION=c2
190+#?XSERVER-1 ACCEPT-CONNECT
191+#?SESSION-X-1 CONNECT-XSERVER
192+
193+# Add seat-BBB-Foo
194+#?*ADD-SEAT ID=seat-BBB-Foo
195+
196+# seat-BBB-Foo starts
197+#?XSERVER-2 START SEAT=seat-BBB-Foo SHAREVTS=TRUE
198+#?*XSERVER-2 INDICATE-READY
199+#?XSERVER-2 INDICATE-READY
200+#?XSERVER-2 ACCEPT-CONNECT
201+#?GREETER-X-2 START XDG_SEAT=seat-BBB-Foo XDG_SESSION_CLASS=greeter
202+#?LOGIN1 ACTIVATE-SESSION SESSION=c3
203+#?XSERVER-2 ACCEPT-CONNECT
204+#?GREETER-X-2 CONNECT-XSERVER
205+#?GREETER-X-2 CONNECT-TO-DAEMON
206+#?GREETER-X-2 CONNECTED-TO-DAEMON
207+
208+# Greeter is requested to timeout
209+#?GREETER-X-1 AUTOLOGIN-GUEST TIMEOUT=10
210+
211+# Trigger autologin
212+#?*GREETER-X-2 AUTHENTICATE-AUTOLOGIN
213+#?GREETER-X-2 AUTHENTICATION-COMPLETE AUTHENTICATED=TRUE
214+#?*GREETER-X-2 START-SESSION
215+#?GREETER-X-2 TERMINATE SIGNAL=15
216+
217+# Guest account created
218+#?GUEST-ACCOUNT ADD USERNAME=guest-.*
219+
220+# Guest session starts
221+#?SESSION-X-2 START XDG_SEAT=seat-BBB-Foo XDG_GREETER_DATA_DIR=.*/guest-.* XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=guest-.*
222+#?LOGIN1 ACTIVATE-SESSION SESSION=c4
223+#?XSERVER-2 ACCEPT-CONNECT
224+#?SESSION-X-2 CONNECT-XSERVER
225+
226+# Cleanup
227+#?*STOP-DAEMON
228+#?GREETER-X-0 TERMINATE SIGNAL=15
229+#?XSERVER-0 TERMINATE SIGNAL=15
230+#?XSESSION-X-1 TERMINATE SIGNAL=15
231+#?XSERVER-1 TERMINATE SIGNAL=15
232+#?GUEST-ACCOUNT REMOVE USERNAME=guest.*
233+#?XSESSION-X-2 TERMINATE SIGNAL=15
234+#?XSERVER-2 TERMINATE SIGNAL=15
235+#?GUEST-ACCOUNT REMOVE USERNAME=guest.*
236+#?RUNNER DAEMON-EXIT STATUS=0
237
238=== added file 'tests/test-multi-seat-with-globbing-config-sections'
239--- tests/test-multi-seat-with-globbing-config-sections 1970-01-01 00:00:00 +0000
240+++ tests/test-multi-seat-with-globbing-config-sections 2014-08-28 14:40:56 +0000
241@@ -0,0 +1,2 @@
242+#!/bin/sh
243+./src/dbus-env ./src/test-runner multi-seat-with-globbing-config-sections test-gobject-greeter

Subscribers

People subscribed via source and target branches