summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am1
-rw-r--r--src/lightdm.c84
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/scripts/additional-system-config-priority.conf31
-rw-r--r--tests/scripts/additional-system-config.conf30
-rw-r--r--tests/src/test-runner.c17
-rwxr-xr-xtests/test-additional-system-config2
-rwxr-xr-xtests/test-additional-system-config-priority2
8 files changed, 131 insertions, 40 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 457d7063..bc0b7152 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -79,6 +79,7 @@ lightdm_CFLAGS = \
-DLOG_DIR=\"$(localstatedir)/log/lightdm\" \
-DRUN_DIR=\"$(localstatedir)/run/lightdm\" \
-DCACHE_DIR=\"$(localstatedir)/cache/lightdm\" \
+ -DSYSTEM_CONFIG_DIR=\"$(pkgdatadir)/lightdm.conf.d\" \
-DSESSIONS_DIR=\"$(pkgdatadir)/sessions:$(datadir)/xsessions\" \
-DREMOTE_SESSIONS_DIR=\"$(pkgdatadir)/remote-sessions\" \
-DGREETERS_DIR=\"$(pkgdatadir)/greeters:$(datadir)/xgreeters\"
diff --git a/src/lightdm.c b/src/lightdm.c
index 246a2072..edb14bf9 100644
--- a/src/lightdm.c
+++ b/src/lightdm.c
@@ -854,6 +854,49 @@ compare_strings (gconstpointer a, gconstpointer b)
return strcmp (a, b);
}
+static void
+load_config_directory (const gchar *path, GList **messages)
+{
+ GDir *dir;
+ GList *files = NULL, *link;
+ GError *error = NULL;
+
+ /* Find configuration files */
+ dir = g_dir_open (path, 0, &error);
+ if (error && !g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
+ g_printerr ("Failed to open configuration directory %s: %s\n", path, error->message);
+ g_clear_error (&error);
+ if (dir)
+ {
+ const gchar *name;
+ while ((name = g_dir_read_name (dir)))
+ files = g_list_append (files, g_strdup (name));
+ g_dir_close (dir);
+ }
+
+ /* Sort alphabetically and load onto existing configuration */
+ files = g_list_sort (files, compare_strings);
+ for (link = files; link; link = link->next)
+ {
+ gchar *filename = link->data;
+ gchar *conf_path;
+
+ conf_path = g_build_filename (path, filename, NULL);
+ if (g_str_has_suffix (filename, ".conf"))
+ {
+ *messages = g_list_append (*messages, g_strdup_printf ("Loading configuration from %s", conf_path));
+ config_load_from_file (config_get_instance (), conf_path, &error);
+ if (error && !g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
+ g_printerr ("Failed to load configuration from %s: %s\n", filename, error->message);
+ g_clear_error (&error);
+ }
+ else
+ g_debug ("Ignoring configuration file %s, it does not have .conf suffix", conf_path);
+ g_free (conf_path);
+ }
+ g_list_free_full (files, g_free);
+}
+
int
main (int argc, char **argv)
{
@@ -1009,46 +1052,9 @@ main (int argc, char **argv)
}
/* Load config file(s) */
+ load_config_directory (SYSTEM_CONFIG_DIR, &messages);
if (config_d_dir)
- {
- GDir *dir;
- GList *files = NULL, *link;
-
- /* Find configuration files */
- dir = g_dir_open (config_d_dir, 0, &error);
- if (error && !g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
- g_printerr ("Failed to open configuration directory %s: %s\n", config_d_dir, error->message);
- g_clear_error (&error);
- if (dir)
- {
- const gchar *name;
- while ((name = g_dir_read_name (dir)))
- files = g_list_append (files, g_strdup (name));
- g_dir_close (dir);
- }
-
- /* Sort alphabetically and load onto existing configuration */
- files = g_list_sort (files, compare_strings);
- for (link = files; link; link = link->next)
- {
- gchar *filename = link->data;
- gchar *path;
-
- path = g_build_filename (config_d_dir, filename, NULL);
- if (g_str_has_suffix (filename, ".conf"))
- {
- messages = g_list_append (messages, g_strdup_printf ("Loading configuration from %s", path));
- config_load_from_file (config_get_instance (), path, &error);
- if (error && !g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
- g_printerr ("Failed to load configuration from %s: %s\n", filename, error->message);
- g_clear_error (&error);
- }
- else
- g_debug ("Ignoring configuration file %s, it does not have .conf suffix", path);
- g_free (path);
- }
- g_list_free_full (files, g_free);
- }
+ load_config_directory (config_d_dir, &messages);
g_free (config_d_dir);
messages = g_list_append (messages, g_strdup_printf ("Loading configuration from %s", config_path));
if (!config_load_from_file (config_get_instance (), config_path, &error))
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 945a78ef..97239c8f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,6 +14,8 @@ TESTS = \
test-no-config \
test-additional-config \
test-additional-config-priority \
+ test-additional-system-config \
+ test-additional-system-config-priority \
test-headless \
test-autologin \
test-autologin-in-background \
@@ -280,6 +282,8 @@ EXTRA_DIST = \
scripts/1-additional.conf \
scripts/additional-config.conf \
scripts/additional-config-priority.conf \
+ scripts/additional-system-config.conf \
+ scripts/additional-system-config-priority.conf \
scripts/autologin.conf \
scripts/autologin-guest.conf \
scripts/autologin-guest-fail-setup-script.conf \
diff --git a/tests/scripts/additional-system-config-priority.conf b/tests/scripts/additional-system-config-priority.conf
new file mode 100644
index 00000000..1ed1bcba
--- /dev/null
+++ b/tests/scripts/additional-system-config-priority.conf
@@ -0,0 +1,31 @@
+#
+# Check LightDM runs with system config.d configuration and the value from /etc is used
+#
+
+[test-runner-config]
+additional-system-config=0-additional.conf
+additional-config=1-additional.conf
+
+[SeatDefaults]
+user-session=default
+
+#?RUNNER DAEMON-START
+
+# X server starts
+#?XSERVER-0 START VT=7
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+# Session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 USER=have-password2
+#?XSERVER-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# Cleanup
+#?*STOP-DAEMON
+#?SESSION-X-0 TERMINATE SIGNAL=15
+#?XSERVER-0 TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/additional-system-config.conf b/tests/scripts/additional-system-config.conf
new file mode 100644
index 00000000..5f170c66
--- /dev/null
+++ b/tests/scripts/additional-system-config.conf
@@ -0,0 +1,30 @@
+#
+# Check LightDM runs with system-config.d configuration and the value from the last file is used
+#
+
+[test-runner-config]
+additional-system-config=0-additional.conf 1-additional.conf
+
+[SeatDefaults]
+user-session=default
+
+#?RUNNER DAEMON-START
+
+# X server starts
+#?XSERVER-0 START VT=7
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+# Session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 USER=have-password2
+#?XSERVER-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# Cleanup
+#?*STOP-DAEMON
+#?SESSION-X-0 TERMINATE SIGNAL=15
+#?XSERVER-0 TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/src/test-runner.c b/tests/src/test-runner.c
index 526bb73e..e893bb86 100644
--- a/tests/src/test-runner.c
+++ b/tests/src/test-runner.c
@@ -1806,7 +1806,8 @@ main (int argc, char **argv)
{
GMainLoop *loop;
int i;
- gchar *greeter = NULL, *script_name, *config_file, *additional_config, *path, *path1, *path2, *ld_preload, *ld_library_path, *home_dir;
+ gchar *greeter = NULL, *script_name, *config_file, *additional_system_config;
+ gchar *additional_config, *path, *path1, *path2, *ld_preload, *ld_library_path, *home_dir;
GString *passwd_data, *group_data;
GSource *status_source;
gchar cwd[1024];
@@ -1940,6 +1941,20 @@ main (int argc, char **argv)
if (system (g_strdup_printf ("cp %s %s/etc/lightdm/lightdm.conf", config_path, temp_dir)))
perror ("Failed to copy configuration");
+ additional_system_config = g_key_file_get_string (config, "test-runner-config", "additional-system-config", NULL);
+ if (additional_system_config)
+ {
+ gchar **files;
+
+ g_mkdir_with_parents (g_strdup_printf ("%s/usr/share/lightdm/lightdm.conf.d", temp_dir), 0755);
+
+ files = g_strsplit (additional_system_config, " ", -1);
+ for (i = 0; files[i]; i++)
+ if (system (g_strdup_printf ("cp %s/tests/scripts/%s %s/usr/share/lightdm/lightdm.conf.d", SRCDIR, files[i], temp_dir)))
+ perror ("Failed to copy configuration");
+ g_strfreev (files);
+ }
+
additional_config = g_key_file_get_string (config, "test-runner-config", "additional-config", NULL);
if (additional_config)
{
diff --git a/tests/test-additional-system-config b/tests/test-additional-system-config
new file mode 100755
index 00000000..ad84124d
--- /dev/null
+++ b/tests/test-additional-system-config
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner additional-system-config test-gobject-greeter
diff --git a/tests/test-additional-system-config-priority b/tests/test-additional-system-config-priority
new file mode 100755
index 00000000..e8fd4b95
--- /dev/null
+++ b/tests/test-additional-system-config-priority
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner additional-system-config-priority test-gobject-greeter