Merge lp:~robert-ancell/lightdm/conf.d into lp:lightdm

Proposed by Robert Ancell
Status: Merged
Approved by: Robert Ancell
Approved revision: 1692
Merged at revision: 1688
Proposed branch: lp:~robert-ancell/lightdm/conf.d
Merge into: lp:lightdm
Diff against target: 309 lines (+157/-8)
9 files modified
src/configuration.c (+26/-1)
src/lightdm.c (+60/-6)
tests/Makefile.am (+4/-0)
tests/scripts/0-additional.conf (+2/-0)
tests/scripts/1-additional.conf (+2/-0)
tests/scripts/additional-config.conf (+29/-0)
tests/src/libsystem.c (+17/-0)
tests/src/test-runner.c (+15/-1)
tests/test-additional-config (+2/-0)
To merge this branch: bzr merge lp:~robert-ancell/lightdm/conf.d
Reviewer Review Type Date Requested Status
Robert Ancell Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+169973@code.launchpad.net

Commit message

Load configuration from /etc/lightdm/lightdm.conf.d

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1688
http://jenkins.qa.ubuntu.com/job/lightdm-ci/78/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/lightdm-raring-amd64-ci/72/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/lightdm-ci/78/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1688
http://jenkins.qa.ubuntu.com/job/lightdm-ci/79/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/lightdm-raring-amd64-ci/73/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/lightdm-ci/79/rebuild

review: Needs Fixing (continuous-integration)
lp:~robert-ancell/lightdm/conf.d updated
1689. By Robert Ancell

Fix tests running on server

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1689
http://jenkins.qa.ubuntu.com/job/lightdm-ci/80/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/lightdm-raring-amd64-ci/74/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/lightdm-ci/80/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1689
http://jenkins.qa.ubuntu.com/job/lightdm-ci/81/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/lightdm-raring-amd64-ci/75/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/lightdm-ci/81/rebuild

review: Needs Fixing (continuous-integration)
lp:~robert-ancell/lightdm/conf.d updated
1690. By Robert Ancell

Enable debugging to work out what is going on on the server

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1690
http://jenkins.qa.ubuntu.com/job/lightdm-ci/82/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/lightdm-raring-amd64-ci/76/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/lightdm-ci/82/rebuild

review: Needs Fixing (continuous-integration)
lp:~robert-ancell/lightdm/conf.d updated
1691. By Robert Ancell

Fix session name for additional config test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1691
http://jenkins.qa.ubuntu.com/job/lightdm-ci/83/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/lightdm-raring-amd64-ci/77/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/lightdm-ci/83/rebuild

review: Needs Fixing (continuous-integration)
lp:~robert-ancell/lightdm/conf.d updated
1692. By Robert Ancell

Really fix Fix session name for additional config test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:1692
http://jenkins.qa.ubuntu.com/job/lightdm-ci/84/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/lightdm-raring-amd64-ci/78

Click here to trigger a rebuild:
http://s-jenkins:8080/job/lightdm-ci/84/rebuild

review: Approve (continuous-integration)
Revision history for this message
Robert Ancell (robert-ancell) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/configuration.c'
2--- src/configuration.c 2011-08-16 08:20:30 +0000
3+++ src/configuration.c 2013-06-19 05:09:25 +0000
4@@ -31,7 +31,32 @@
5 gboolean
6 config_load_from_file (Configuration *config, const gchar *path, GError **error)
7 {
8- return g_key_file_load_from_file (config->priv->key_file, path, G_KEY_FILE_NONE, error);
9+ GKeyFile *key_file;
10+ gchar **groups;
11+ int i;
12+
13+ key_file = g_key_file_new ();
14+ if (!g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, error))
15+ return FALSE;
16+
17+ groups = g_key_file_get_groups (key_file, NULL);
18+ for (i = 0; groups[i]; i++)
19+ {
20+ gchar **keys;
21+ int j;
22+
23+ keys = g_key_file_get_keys (key_file, groups[i], NULL, error);
24+ if (!keys)
25+ break;
26+
27+ for (j = 0; keys[j]; j++)
28+ g_key_file_set_value (config->priv->key_file, groups[i], keys[j], g_key_file_get_value (key_file, groups[i], keys[j], NULL));
29+
30+ g_strfreev (keys);
31+ }
32+ g_strfreev (groups);
33+
34+ return TRUE;
35 }
36
37 gchar **
38
39=== modified file 'src/lightdm.c'
40--- src/lightdm.c 2013-06-13 03:17:43 +0000
41+++ src/lightdm.c 2013-06-19 05:09:25 +0000
42@@ -788,6 +788,12 @@
43 g_object_unref (seat);
44 }
45
46+static int
47+compare_strings (gconstpointer a, gconstpointer b)
48+{
49+ return strcmp (a, b);
50+}
51+
52 int
53 main (int argc, char **argv)
54 {
55@@ -802,7 +808,7 @@
56 gchar *xsessions_dir = NULL;
57 gchar *remote_sessions_dir = NULL;
58 gchar *xgreeters_dir = NULL;
59- gchar *config_dir;
60+ gchar *config_dir, *config_d_dir = NULL;
61 gchar *log_dir = NULL;
62 gchar *run_dir = NULL;
63 gchar *cache_dir = NULL;
64@@ -810,6 +816,7 @@
65 gchar *default_run_dir = g_strdup (RUN_DIR);
66 gchar *default_cache_dir = g_strdup (CACHE_DIR);
67 gboolean show_version = FALSE;
68+ GList *link, *messages = NULL;
69 GOptionEntry options[] =
70 {
71 { "config", 'c', 0, G_OPTION_ARG_STRING, &config_path,
72@@ -858,6 +865,8 @@
73 #endif
74 loop = g_main_loop_new (NULL, FALSE);
75
76+ messages = g_list_append (messages, g_strdup_printf ("Starting Light Display Manager %s, UID=%i PID=%i", VERSION, getuid (), getpid ()));
77+
78 g_signal_connect (process_get_current (), "got-signal", G_CALLBACK (signal_cb), NULL);
79
80 option_context = g_option_context_new (/* Arguments and description for --help test */
81@@ -892,6 +901,7 @@
82 else
83 {
84 config_dir = g_strdup (CONFIG_DIR);
85+ config_d_dir = g_build_filename (config_dir, "lightdm.conf.d", NULL);
86 config_path = g_build_filename (config_dir, "lightdm.conf", NULL);
87 }
88 config_set_string (config_get_instance (), "LightDM", "config-directory", config_dir);
89@@ -955,7 +965,8 @@
90 default_cache_dir = g_build_filename (g_get_user_cache_dir (), "lightdm", "cache", NULL);
91 }
92
93- /* Load config file */
94+ /* Load config file(s) */
95+ messages = g_list_append (messages, g_strdup_printf ("Loading configuration from %s", config_path));
96 if (!config_load_from_file (config_get_instance (), config_path, &error))
97 {
98 gboolean is_empty;
99@@ -970,6 +981,49 @@
100 }
101 }
102 g_clear_error (&error);
103+ g_free (config_path);
104+ if (config_d_dir)
105+ {
106+ GDir *dir;
107+ GList *files, *link;
108+ GKeyFile *f;
109+
110+ /* Find configuration files */
111+ dir = g_dir_open (config_d_dir, 0, &error);
112+ if (error && !g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
113+ g_printerr ("Failed to open configuration directory %s: %s\n", config_d_dir, error->message);
114+ g_clear_error (&error);
115+ if (dir)
116+ {
117+ const gchar *name;
118+ while ((name = g_dir_read_name (dir)))
119+ files = g_list_append (files, g_strdup (name));
120+ g_dir_close (dir);
121+ }
122+
123+ /* Sort alphabetically and load onto existing configuration */
124+ files = g_list_sort (files, compare_strings);
125+ for (link = files; link; link = link->next)
126+ {
127+ gchar *filename = link->data;
128+ gchar *path;
129+
130+ path = g_build_filename (config_d_dir, filename, NULL);
131+ if (g_str_has_suffix (filename, ".conf"))
132+ {
133+ messages = g_list_append (messages, g_strdup_printf ("Loading configuration from %s", path));
134+ config_load_from_file (config_get_instance (), path, &error);
135+ if (error && !g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
136+ g_printerr ("Failed to load configuration from %s: %s\n", filename, error->message);
137+ g_clear_error (&error);
138+ }
139+ else
140+ g_debug ("Ignoring configuration file %s, it does not have .conf suffix", path);
141+ g_free (path);
142+ }
143+ g_list_free_full (files, g_free);
144+ }
145+ g_free (config_d_dir);
146
147 /* Set default values */
148 if (!config_has_key (config_get_instance (), "LightDM", "start-default-seat"))
149@@ -1052,10 +1106,10 @@
150
151 log_init ();
152
153- g_debug ("Starting Light Display Manager %s, UID=%i PID=%i", VERSION, getuid (), getpid ());
154-
155- g_debug ("Loaded configuration from %s", config_path);
156- g_free (config_path);
157+ /* Show queued messages once logging is complete */
158+ for (link = messages; link; link = link->next)
159+ g_debug ("%s", link->data);
160+ g_list_free_full (messages, g_free);
161
162 g_debug ("Using D-Bus name %s", LIGHTDM_BUS_NAME);
163 bus_id = g_bus_own_name (getuid () == 0 ? G_BUS_TYPE_SYSTEM : G_BUS_TYPE_SESSION,
164
165=== modified file 'tests/Makefile.am'
166--- tests/Makefile.am 2013-06-06 21:51:01 +0000
167+++ tests/Makefile.am 2013-06-19 05:09:25 +0000
168@@ -6,6 +6,7 @@
169 test-greeter-not-installed \
170 test-greeter-xserver-crash \
171 test-no-config \
172+ test-additional-config \
173 test-headless \
174 test-autologin \
175 test-autologin-in-background \
176@@ -236,6 +237,9 @@
177 data/xgreeters/test-qt5-greeter.desktop \
178 data/xsessions/alternative.desktop \
179 data/xsessions/default.desktop \
180+ scripts/0-additional.conf \
181+ scripts/1-additional.conf \
182+ scripts/additional-config.conf \
183 scripts/autologin.conf \
184 scripts/autologin-guest.conf \
185 scripts/autologin-guest-fail-setup-script.conf \
186
187=== added file 'tests/scripts/0-additional.conf'
188--- tests/scripts/0-additional.conf 1970-01-01 00:00:00 +0000
189+++ tests/scripts/0-additional.conf 2013-06-19 05:09:25 +0000
190@@ -0,0 +1,2 @@
191+[SeatDefaults]
192+autologin-user=have-password1
193
194=== added file 'tests/scripts/1-additional.conf'
195--- tests/scripts/1-additional.conf 1970-01-01 00:00:00 +0000
196+++ tests/scripts/1-additional.conf 2013-06-19 05:09:25 +0000
197@@ -0,0 +1,2 @@
198+[SeatDefaults]
199+autologin-user=have-password2
200
201=== added file 'tests/scripts/additional-config.conf'
202--- tests/scripts/additional-config.conf 1970-01-01 00:00:00 +0000
203+++ tests/scripts/additional-config.conf 2013-06-19 05:09:25 +0000
204@@ -0,0 +1,29 @@
205+#
206+# Check LightDM runs without a config.d configuration
207+#
208+
209+[test-runner-config]
210+additional-config=0-additional.conf 1-additional.conf
211+
212+[SeatDefaults]
213+user-session=default
214+
215+#?RUNNER DAEMON-START
216+
217+# X server starts
218+#?XSERVER-0 START
219+#?XSERVER-0 INDICATE-READY
220+
221+# LightDM connects to X server
222+#?XSERVER-0 ACCEPT-CONNECT
223+
224+# Session starts
225+#?SESSION-X-0 START USER=have-password2
226+#?XSERVER-0 ACCEPT-CONNECT
227+#?SESSION-X-0 CONNECT-XSERVER
228+
229+# Cleanup
230+#?*STOP-DAEMON
231+#?SESSION-X-0 TERMINATE SIGNAL=15
232+#?XSERVER-0 TERMINATE SIGNAL=15
233+#?RUNNER DAEMON-EXIT STATUS=0
234
235=== modified file 'tests/src/libsystem.c'
236--- tests/src/libsystem.c 2013-06-17 04:38:04 +0000
237+++ tests/src/libsystem.c 2013-06-19 05:09:25 +0000
238@@ -5,6 +5,7 @@
239 #include <sys/stat.h>
240 #include <pwd.h>
241 #include <unistd.h>
242+#include <dirent.h>
243 #include <grp.h>
244 #include <security/pam_appl.h>
245 #include <fcntl.h>
246@@ -357,6 +358,22 @@
247 return ret;
248 }
249
250+DIR *
251+opendir (const char *name)
252+{
253+ DIR *(*_opendir) (const char *name);
254+ gchar *new_path = NULL;
255+ DIR *result;
256+
257+ _opendir = (DIR *(*)(const char *name)) dlsym (RTLD_NEXT, "opendir");
258+
259+ new_path = redirect_path (name);
260+ result = _opendir (new_path);
261+ g_free (new_path);
262+
263+ return result;
264+}
265+
266 int
267 mkdir (const char *pathname, mode_t mode)
268 {
269
270=== modified file 'tests/src/test-runner.c'
271--- tests/src/test-runner.c 2013-06-17 23:14:43 +0000
272+++ tests/src/test-runner.c 2013-06-19 05:09:25 +0000
273@@ -1698,7 +1698,7 @@
274 {
275 GMainLoop *loop;
276 int i;
277- gchar *greeter = NULL, *script_name, *config_file, *path, *path1, *path2, *ld_preload, *ld_library_path, *home_dir;
278+ gchar *greeter = NULL, *script_name, *config_file, *additional_config, *path, *path1, *path2, *ld_preload, *ld_library_path, *home_dir;
279 GString *passwd_data, *group_data;
280 GSource *status_source;
281 gchar cwd[1024];
282@@ -1832,6 +1832,20 @@
283 if (system (g_strdup_printf ("cp %s %s/etc/lightdm/lightdm.conf", config_path, temp_dir)))
284 perror ("Failed to copy configuration");
285
286+ additional_config = g_key_file_get_string (config, "test-runner-config", "additional-config", NULL);
287+ if (additional_config)
288+ {
289+ gchar **files;
290+
291+ g_mkdir_with_parents (g_strdup_printf ("%s/etc/lightdm/lightdm.conf.d", temp_dir), 0755);
292+
293+ files = g_strsplit (additional_config, " ", -1);
294+ for (i = 0; files[i]; i++)
295+ if (system (g_strdup_printf ("cp %s/tests/scripts/%s %s/etc/lightdm/lightdm.conf.d", SRCDIR, files[i], temp_dir)))
296+ perror ("Failed to copy configuration");
297+ g_strfreev (files);
298+ }
299+
300 /* Always copy the script */
301 if (system (g_strdup_printf ("cp %s %s/script", config_path, temp_dir)))
302 perror ("Failed to copy configuration");
303
304=== added file 'tests/test-additional-config'
305--- tests/test-additional-config 1970-01-01 00:00:00 +0000
306+++ tests/test-additional-config 2013-06-19 05:09:25 +0000
307@@ -0,0 +1,2 @@
308+#!/bin/sh
309+./src/dbus-env ./src/test-runner additional-config test-gobject-greeter

Subscribers

People subscribed via source and target branches