From 10e87ee7f66b59a504c0ed2025463ba5faa69923 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 16 Jun 2010 01:58:50 +0200 Subject: install: add systemd-install tool for managing alias/wants symlinks --- src/path-lookup.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'src/path-lookup.c') diff --git a/src/path-lookup.c b/src/path-lookup.c index 1c4b5dc4e1..7a5b9b813e 100644 --- a/src/path-lookup.c +++ b/src/path-lookup.c @@ -30,6 +30,28 @@ #include "path-lookup.h" +int session_config_home(char **config_home) { + const char *e; + + if ((e = getenv("XDG_CONFIG_HOME"))) { + if (asprintf(config_home, "%s/systemd/session", e) < 0) + return -ENOMEM; + + return 1; + } else { + const char *home; + + if ((home = getenv("HOME"))) { + if (asprintf(config_home, "%s/.config/systemd/session", home) < 0) + return -ENOMEM; + + return 1; + } + } + + return 0; +} + static char** session_dirs(void) { const char *home, *e; char *config_home = NULL, *data_home = NULL; @@ -45,16 +67,10 @@ static char** session_dirs(void) { * as data, and allow overriding as configuration. */ - home = getenv("HOME"); - - if ((e = getenv("XDG_CONFIG_HOME"))) { - if (asprintf(&config_home, "%s/systemd/session", e) < 0) - goto fail; + if (session_config_home(&config_home) < 0) + goto fail; - } else if (home) { - if (asprintf(&config_home, "%s/.config/systemd/session", home) < 0) - goto fail; - } + home = getenv("HOME"); if ((e = getenv("XDG_CONFIG_DIRS"))) if (!(config_dirs = strv_split(e, ":"))) -- cgit v1.2.3-54-g00ecf