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 <ossama.othman@intel.com>
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 9dce809..35019e0 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2362,7 +2362,7 @@
static struct weston_compositor *
drm_compositor_create(struct wl_display *display,
int connector, const char *seat, int tty, int pixman,
- int *argc, char *argv[], const char *config_file)
+ int *argc, char *argv[], int config_fd)
{
struct drm_compositor *ec;
struct udev_device *drm_device;
@@ -2385,7 +2385,7 @@
ec->use_pixman = pixman;
if (weston_compositor_init(&ec->base, display, argc, argv,
- config_file) < 0) {
+ config_fd) < 0) {
weston_log("%s failed\n", __func__);
goto err_base;
}
@@ -2666,7 +2666,7 @@
WL_EXPORT struct weston_compositor *
backend_init(struct wl_display *display, int *argc, char *argv[],
- const char *config_file)
+ int config_fd)
{
int connector = 0, tty = 0, use_pixman = 0;
const char *seat = default_seat;
@@ -2694,9 +2694,9 @@
ARRAY_LENGTH(drm_config_keys), output_section_done },
};
- parse_config_file(config_file, config_section,
+ parse_config_file(config_fd, config_section,
ARRAY_LENGTH(config_section), NULL);
return drm_compositor_create(display, connector, seat, tty, use_pixman,
- argc, argv, config_file);
+ argc, argv, config_fd);
}