-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
#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;
* 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, ":")))
* 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")))
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")))