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

From: Liliana Marie Prikler <[email-masked]>
Date: Sat, 30 Apr 2022 16:26:29 +0200

Am Samstag, dem 30.04.2022 um 16:15 +0200 schrieb Ludovic Courtès:
> 
> > +(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.
As far as I know, those logs should be managed by shepherd, no?  It
just redirects stdout/stderr there, or is there something special going
on?

> Did you encounter this issue while working on services?
> 
> Am I right that the Shepherd 0.8 had the same problem?
It might be, I don't know.  I've encountered this for non-existing log
directory, so a reproducer would be setting #:log-file to $test-tmp-
directory/does-not-exist/log and check for each service.

Cheers