chiark / gitweb /
core: --user -- move generator directories from /tmp to $XDG_RUNTIME_DIR
authorKay Sievers <kay@vrfy.org>
Mon, 6 Jan 2014 03:50:26 +0000 (07:50 +0400)
committerKay Sievers <kay@vrfy.org>
Mon, 6 Jan 2014 17:35:13 +0000 (01:35 +0800)
src/core/manager.c

index bbe5efa..0e35ba5 100644 (file)
@@ -2507,6 +2507,7 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
                 return 0;
 
         if (m->running_as == SYSTEMD_SYSTEM && getpid() == 1) {
+                /* systemd --system, not running --test */
 
                 p = strappend("/run/systemd/", name);
                 if (!p)
@@ -2519,7 +2520,26 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
                         free(p);
                         return r;
                 }
+        } else if (m->running_as == SYSTEMD_USER) {
+                const char *s = NULL;
+
+                s = getenv("XDG_RUNTIME_DIR");
+                if (!s)
+                        return -EINVAL;
+                p = strjoin(s, "/systemd/", name, NULL);
+                if (!p)
+                        return log_oom();
+
+                r = mkdir_p_label(p, 0755);
+                if (r < 0) {
+                        log_error("Failed to create generator directory %s: %s",
+                                  p, strerror(-r));
+                        free(p);
+                        return r;
+                }
         } else {
+                /* systemd --system --test */
+
                 p = strjoin("/tmp/systemd-", name, ".XXXXXX", NULL);
                 if (!p)
                         return log_oom();