services: mcron: Validate jobs even in the presence of #:user.

Fixes a bug in 949672c923 whereby jobs
specifying a #:user not available in the build environment would fail
validation.

Reported by Maxim Cournoyer.

* gnu/services/mcron.scm (job-files)[validated-file]: Add "prologue"
file and pass it to 'mcron --schedule'.
This commit is contained in:
Ludovic Courtès 2020-08-26 15:30:04 +02:00
parent ce022b2e14
commit ef5ddb0e17
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 10 additions and 1 deletions

View File

@ -67,12 +67,21 @@
#~(begin
(use-modules (guix build utils))
(call-with-output-file "prologue"
(lambda (port)
;; This prologue allows 'mcron --schedule' to
;; proceed no matter what #:user option is passed
;; to 'job'.
(write '(set! getpw
(const (getpwuid (getuid))))
port)))
(call-with-output-file "job"
(lambda (port)
(write '#$job port)))
(invoke #+(file-append mcron "/bin/mcron")
"--schedule=20" "job")
"--schedule=20" "prologue" "job")
(copy-file "job" #$output)))
#:options '(#:env-vars (("COLUMNS" . "150")))))