X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fpath-lookup.c;h=00003620a57a88e2e604625682bdf96e44dffa60;hp=1c4b5dc4e1f6bc1c37eb3261432a67db6fa4e4fe;hb=674a6e4d0cae372f34df94dfab2513e071d5dc58;hpb=84e3543ef4c4758621f8a304b14642072303ef82 diff --git a/src/path-lookup.c b/src/path-lookup.c index 1c4b5dc4e..00003620a 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, ":"))) @@ -80,7 +96,7 @@ static char** session_dirs(void) { * one. */ mkdir_parents(data_home, 0777); - symlink("../../../.config/systemd/session", data_home); + (void) symlink("../../../.config/systemd/session", data_home); } if ((e = getenv("XDG_DATA_DIRS"))) @@ -165,13 +181,17 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) { return -ENOMEM; } else if (!(p->unit_path = strv_new( - SYSTEM_CONFIG_UNIT_PATH, /* /etc/systemd/system/ */ - SYSTEM_DATA_UNIT_PATH, /* /lib/systemd/system/ */ + SYSTEM_CONFIG_UNIT_PATH, + "/etc/systemd/system", + "/usr/local/share/systemd/system", + "/usr/share/systemd/system", + "/lib/systemd/system", + SYSTEM_DATA_UNIT_PATH, NULL))) return -ENOMEM; } - if (running_as == MANAGER_INIT) { + if (running_as == MANAGER_SYSTEM) { /* /etc/init.d/ compatibility does not matter to users */ if ((e = getenv("SYSTEMD_SYSVINIT_PATH")))