From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 74151@debbugs.gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer@gmail.com>,
Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [bug#74151] [PATCH v2 9/9] services: web: Fix race between nginx activation and anonip.
Date: Fri, 1 Nov 2024 21:39:29 +0900 [thread overview]
Message-ID: <1d6c7e71f2a80a38f801965b7fd27f0b982016ec.1730464675.git.maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <281a4773768a6c271ff464f473fdbc333a58c348.1730464675.git.maxim.cournoyer@gmail.com>
* 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
---
New commit in v2
gnu/services/web.scm | 64 ++++++++++++++++++++------------------------
1 file changed, 29 insertions(+), 35 deletions(-)
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index cf3515bf70..4cf7c68997 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -1499,41 +1499,35 @@ (define (anonip-shepherd-service config)
"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-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")))
-
- (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
--
2.46.0
prev parent reply other threads:[~2024-11-01 12:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-01 6:20 [bug#74151] [PATCH 0/7] Add anonip system test Maxim Cournoyer
2024-11-01 7:11 ` [bug#74151] [PATCH 1/7] doc: Use @table @code for anonip-configuration doc Maxim Cournoyer
2024-11-01 7:11 ` [bug#74151] [PATCH 2/7] services: anonip: Add 'debug?' configuration field Maxim Cournoyer
2024-11-01 7:11 ` [bug#74151] [PATCH 3/7] system/vm: Fix virtual-machine bug Maxim Cournoyer
2024-11-01 7:11 ` [bug#74151] [PATCH 4/7] tests: web: Have the retry-on-error throw on exhausted attempts Maxim Cournoyer
2024-11-01 7:11 ` [bug#74151] [PATCH 5/7] services: herd: Export 'eval-there' in API Maxim Cournoyer
2024-11-01 7:11 ` [bug#74151] [PATCH 6/7] build: marionette: Make it possible to reboot VM during tests Maxim Cournoyer
2024-11-01 7:11 ` [bug#74151] [PATCH 7/7] tests: Add anonip system test Maxim Cournoyer
2024-11-01 12:39 ` [bug#74151] [PATCH v2 1/9] doc: Use @table @code for anonip-configuration doc Maxim Cournoyer
2024-11-01 12:39 ` [bug#74151] [PATCH v2 2/9] services: anonip: Add 'debug?' configuration field Maxim Cournoyer
2024-11-01 12:39 ` [bug#74151] [PATCH v2 3/9] system/vm: Fix virtual-machine bug Maxim Cournoyer
2024-11-01 12:39 ` [bug#74151] [PATCH v2 4/9] tests: web: Have the retry-on-error throw on exhausted attempts Maxim Cournoyer
2024-11-01 12:39 ` [bug#74151] [PATCH v2 5/9] services: herd: Export 'eval-there' in API Maxim Cournoyer
2024-11-01 12:39 ` [bug#74151] [PATCH v2 6/9] build: marionette: Make it possible to reboot VM during tests Maxim Cournoyer
2024-11-01 12:39 ` [bug#74151] [PATCH v2 7/9] tests: Add anonip system test Maxim Cournoyer
2024-11-01 12:39 ` [bug#74151] [PATCH v2 8/9] tests: web: Add nginx+anonip test Maxim Cournoyer
2024-11-01 12:39 ` Maxim Cournoyer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1d6c7e71f2a80a38f801965b7fd27f0b982016ec.1730464675.git.maxim.cournoyer@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=74151@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).