summaryrefslogtreecommitdiff
path: root/src/path-lookup.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-06-16 01:58:50 +0200
committerLennart Poettering <lennart@poettering.net>2010-06-16 01:58:50 +0200
commit10e87ee7f66b59a504c0ed2025463ba5faa69923 (patch)
treead0e78fd44128dac8a2a45f89b228bb081b65194 /src/path-lookup.c
parent2c7108c40abfb1f175391aa59cf1b07ab203e690 (diff)
install: add systemd-install tool for managing alias/wants symlinks
Diffstat (limited to 'src/path-lookup.c')
-rw-r--r--src/path-lookup.c34
1 files changed, 25 insertions, 9 deletions
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, ":")))