diff options
author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2024-11-01 21:08:12 +0900 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2024-11-01 21:58:28 +0900 |
commit | 49375f83fc53f8286c5127a07d603ef7967c1b1f (patch) | |
tree | 11cb77a43b06fce217a1720948c2ea2a4d68a938 /gnu | |
parent | a007045b7c6d26a8a051356c51481beaed6a2bfd (diff) | |
download | guix-49375f83fc53f8286c5127a07d603ef7967c1b1f.tar.gz guix-49375f83fc53f8286c5127a07d603ef7967c1b1f.zip |
services: web: Fix race between nginx activation and anonip.
* gnu/services/web.scm (anonip-shepherd-service): Recreate the input file when
it's not a FIFO.
Fixes: <https://issues.guix.gnu.org/59181>
Change-Id: I8ba87f9fc48ecfd515e34bdee9e2949a2a559f9c
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/services/web.scm | 63 |
1 files changed, 29 insertions, 34 deletions
diff --git a/gnu/services/web.scm b/gnu/services/web.scm index cc6f4e6d9b..740d29de95 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -1496,40 +1496,35 @@ files.") "Anonimyze the given log file location with anonip.") (start #~(lambda () - (define (spawn) - (fork+exec-command - (append - (list #$(file-append (anonip-configuration-anonip config) - "/bin/anonip") - (string-append "--input=" #$input) - (string-append "--output=" #$output)) - (if #$(anonip-configuration-skip-private? config) - '("--skip-private") (list)) - '#$(optional anonip-configuration-column "--column") - '#$(optional anonip-configuration-ipv4mask "--ipv4mask") - '#$(optional anonip-configuration-ipv6mask "--ipv6mask") - '#$(optional anonip-configuration-increment "--increment") - '#$(optional anonip-configuration-replacement - "--replacement") - '#$(optional anonip-configuration-delimiter "--delimiter") - '#$(optional anonip-configuration-regex "--regex")) - ;; Run in a UTF-8 locale - #:environment-variables - (list (string-append "GUIX_LOCPATH=" - #$(libc-utf8-locales-for-target) - "/lib/locale") - "LC_ALL=en_US.utf8"))) - - (let ((stat (stat #$input #f))) - (cond ((not stat) - (mknod #$input 'fifo #o600 0) - (spawn)) - ((eq? 'fifo (stat:type stat)) - (spawn)) - (else - (format #t "'~a' is not a FIFO; bailing out~%" - #$input) - #f))))) + ;; Always attempt to recreate the named pipe, as activation scripts + ;; such as that of nginx may have created plain files in its place + ;; (see: https://issues.guix.gnu.org/59181). + (false-if-exception (delete-file #$input)) + (mknod #$input 'fifo #o600 0) + + (fork+exec-command + (append + (list #$(file-append (anonip-configuration-anonip config) + "/bin/anonip") + (string-append "--input=" #$input) + (string-append "--output=" #$output)) + (if #$(anonip-configuration-debug? config) + '("--debug") (list)) + (if #$(anonip-configuration-skip-private? config) + '("--skip-private") (list)) + '#$(optional anonip-configuration-column "--column") + '#$(optional anonip-configuration-ipv4mask "--ipv4mask") + '#$(optional anonip-configuration-ipv6mask "--ipv6mask") + '#$(optional anonip-configuration-increment "--increment") + '#$(optional anonip-configuration-replacement "--replacement") + '#$(optional anonip-configuration-delimiter "--delimiter") + '#$(optional anonip-configuration-regex "--regex")) + ;; Run in a UTF-8 locale + #:environment-variables + (list (string-append "GUIX_LOCPATH=" + #$(libc-utf8-locales-for-target) + "/lib/locale") + "LC_ALL=en_US.utf8")))) (stop #~(make-kill-destructor)))))) (define anonip-service-type |