Subject: Re: bug#55080: [PATCH shepherd] service: Gracefully handle non-existing log directories.

From: Ludovic Courtès <[email-masked]>
Date: Sat, 30 Apr 2022 16:15:33 +0200

Hi,

Liliana Marie Prikler <[email-masked]> skribis:

> * gnu/packages/services.scm (%service-file-logger): New variable,
> implementing...
> (service-file-logger): ... the old behaviour of this variable.  Catch system
> errors from %service-file-logger and handle them.

[...]

> +(define (service-file-logger file input)
> +  "Return a thunk meant to run as a fiber that reads from INPUT and logs it to
> +FILE."
> +  (catch 'system-error
> +    (lambda ()
> +      (%service-file-logger file input))
> +    (lambda args
> +      (if (= ENOENT (system-error-errno args))
> +          (begin
> +            (mkdir-p (dirname file))
> +            (%service-file-logger file input))
> +          (apply throw args)))))

I wonder to what extent automatically creating log directories is a good
idea.  A potential drawback is if shepherd creates them with unexpected
ownership or permissions.

Did you encounter this issue while working on services?

Am I right that the Shepherd 0.8 had the same problem?

Thanks,
Ludo’.