On Fri, 28.03.14 19:38, Hristo Venev (hri...@venev.name) wrote:

> Predictable names and more consistent.

This definitely feels like the right thing to do.

> ---
>  src/core/manager.c | 48 +++++++++++-------------------------------------
>  1 file changed, 11 insertions(+), 37 deletions(-)
> 
> diff --git a/src/core/manager.c b/src/core/manager.c
> index ce8759e..b409738 100644
> --- a/src/core/manager.c
> +++ b/src/core/manager.c
> @@ -2550,50 +2550,24 @@ static int create_generator_dir(Manager *m, char 
> **generator, const char *name)
>          if (*generator)
>                  return 0;
>  
> -        if (m->running_as == SYSTEMD_SYSTEM && getpid() == 1) {
> -                /* systemd --system, not running --test */
> -
> -                p = strappend("/run/systemd/", name);
> -                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 if (m->running_as == SYSTEMD_USER) {
> -                const char *s = NULL;
> +        if (m->running_as == SYSTEMD_SYSTEM && getpid() != 1) {
> +                /* systemd --system --test */
>  
> -                s = getenv("XDG_RUNTIME_DIR");
> -                if (!s)
> -                        return -EINVAL;
> -                p = strjoin(s, "/systemd/", name, NULL);
> +                p = strjoin("/tmp/systemd-", name, ".XXXXXX", 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);
> +                p = strjoin(manager_get_runtime_prefix(m), "/systemd/", 
> name, NULL);
>                  if (!p)
>                          return log_oom();
> +        }
>  
> -                if (!mkdtemp(p)) {
> -                        log_error("Failed to create generator directory %s: 
> %m",
> -                                  p);
> -                        free(p);
> -                        return -errno;
> -                }

Hmm, we still need the mkdtemp() here for the --system --test case, no?
Or am I missing something?

> +        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;
>          }
>  
>          *generator = p;

Lennart

-- 
Lennart Poettering, Red Hat
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to