summaryrefslogtreecommitdiff
path: root/src/text-backend.c
diff options
context:
space:
mode:
authorOssama Othman <ossama.othman@intel.com>2013-05-14 09:48:26 -0700
committerKristian Høgsberg <krh@bitplanet.net>2013-05-14 14:36:37 -0400
commita50e6e4c500e3080b8df7ec14c7e42741477a423 (patch)
tree0cae5b3f325814e7f2d859eaa3f2c2415c69eb33 /src/text-backend.c
parent95eb3a2eb470bd341ab078c7e48a28ffebc6dde1 (diff)
downloadweston-a50e6e4c500e3080b8df7ec14c7e42741477a423.tar.gz
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>
Diffstat (limited to 'src/text-backend.c')
-rw-r--r--src/text-backend.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/text-backend.c b/src/text-backend.c
index 92efd9f3..da62fd74 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "compositor.h"
#include "text-server-protocol.h"
@@ -885,7 +886,7 @@ handle_seat_created(struct wl_listener *listener,
static void
text_backend_configuration(struct text_backend *text_backend)
{
- char *config_file;
+ int config_fd;
char *path = NULL;
struct config_key input_method_keys[] = {
@@ -896,9 +897,9 @@ text_backend_configuration(struct text_backend *text_backend)
{ "input-method", input_method_keys, ARRAY_LENGTH(input_method_keys), NULL }
};
- config_file = config_file_path("weston.ini");
- parse_config_file(config_file, cs, ARRAY_LENGTH(cs), text_backend);
- free(config_file);
+ config_fd = open_config_file("weston.ini");
+ parse_config_file(config_fd, cs, ARRAY_LENGTH(cs), text_backend);
+ close(config_fd);
if (path)
text_backend->input_method.path = path;