return 0;
}
+int user_runtime_dir(char **runtime_dir) {
+ const char *e;
+ char *r;
+
+ e = getenv("XDG_RUNTIME_DIR");
+ if (e) {
+ r = strappend(e, "/systemd/user");
+ if (!r)
+ return -ENOMEM;
+
+ *runtime_dir = r;
+ return 1;
+ }
+
+ return 0;
+}
+
static char** user_dirs(
const char *generator,
const char *generator_early,
const char * const config_unit_paths[] = {
USER_CONFIG_UNIT_PATH,
"/etc/systemd/user",
- "/run/systemd/user",
NULL
};
+ const char * const runtime_unit_path = "/run/systemd/user";
+
const char * const data_unit_paths[] = {
"/usr/local/lib/systemd/user",
"/usr/local/share/systemd/user",
};
const char *home, *e;
- _cleanup_free_ char *config_home = NULL, *data_home = NULL;
+ _cleanup_free_ char *config_home = NULL, *runtime_dir = NULL, *data_home = NULL;
_cleanup_strv_free_ char **config_dirs = NULL, **data_dirs = NULL;
char **r = NULL;
if (user_config_home(&config_home) < 0)
goto fail;
+ if (user_runtime_dir(&runtime_dir) < 0)
+ goto fail;
+
home = getenv("HOME");
e = getenv("XDG_CONFIG_DIRS");
if (strv_extend_strv(&r, (char**) config_unit_paths) < 0)
goto fail;
+ if (runtime_dir)
+ if (strv_extend(&r, runtime_dir) < 0)
+ goto fail;
+
+ if (strv_extend(&r, runtime_unit_path) < 0)
+ goto fail;
+
if (generator)
if (strv_extend(&r, generator) < 0)
goto fail;
if (!p->unit_path || append) {
/* Let's figure something out. */
- char **unit_path;
+ _cleanup_strv_free_ char **unit_path;
int r;
/* For the user units we include share/ in the search