From a50e6e4c500e3080b8df7ec14c7e42741477a423 Mon Sep 17 00:00:00 2001 From: Ossama Othman Date: Tue, 14 May 2013 09:48:26 -0700 Subject: config-parser: Honor XDG_CONFIG_DIRS This set of changes adds support for searching for a given config file in the directories listed in $XDG_CONFIG_DIRS if it wasn't found in $XDG_CONFIG_HOME or ~/.config. This allows packages to install custom config files in /etc/xdg/weston, for example, thus allowing them to avoid dealing with home directories. To avoid a TOCTOU race the config file is actually open()ed during the search. Its file descriptor is returned and stored in the compositor for later use when performing subsequent config file parses. Signed-off-by: Ossama Othman --- src/shell.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/shell.c') diff --git a/src/shell.c b/src/shell.c index 5da649dd..d5b5fcf5 100644 --- a/src/shell.c +++ b/src/shell.c @@ -375,7 +375,7 @@ get_animation_type(char *animation) } static void -shell_configuration(struct desktop_shell *shell, const char *config_file) +shell_configuration(struct desktop_shell *shell, int config_fd) { char *path = NULL; int duration = 60; @@ -400,7 +400,7 @@ shell_configuration(struct desktop_shell *shell, const char *config_file) { "screensaver", saver_keys, ARRAY_LENGTH(saver_keys), NULL }, }; - parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell); + parse_config_file(config_fd, cs, ARRAY_LENGTH(cs), shell); shell->screensaver.path = path; shell->screensaver.duration = duration * 1000; @@ -4286,7 +4286,7 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell) WL_EXPORT int module_init(struct weston_compositor *ec, - int *argc, char *argv[], const char *config_file) + int *argc, char *argv[]) { struct weston_seat *seat; struct desktop_shell *shell; @@ -4333,7 +4333,7 @@ module_init(struct weston_compositor *ec, wl_array_init(&shell->workspaces.array); wl_list_init(&shell->workspaces.client_list); - shell_configuration(shell, config_file); + shell_configuration(shell, ec->config_fd); for (i = 0; i < shell->workspaces.num; i++) { pws = wl_array_add(&shell->workspaces.array, sizeof *pws); -- cgit v1.2.3