From patchwork Fri Nov 1 12:39:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 32778 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A0BD527BBEA; Fri, 1 Nov 2024 12:44:00 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2111A27BBE2 for ; Fri, 1 Nov 2024 12:44:00 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6qzd-0007hI-RU; Fri, 01 Nov 2024 08:43:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6qzc-0007h0-FU for guix-patches@gnu.org; Fri, 01 Nov 2024 08:43:08 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t6qzc-0000SG-6l for guix-patches@gnu.org; Fri, 01 Nov 2024 08:43:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=KGe8VyZN2Ra66xrmhWqWpZAX95htDF0u7v2gQpwIFQo=; b=QM00qrOVlfRFC1eqNDBtAPtk2qgpxH8n1DzrLc+a5TBE6R6fy+HrCATotPjI4rRLJ+6FQPmUmvayO5w55QldKR1zjRMjl+1cFinQF/Tpek/UwQzsGUs/BTcQqRZuWF7o2wZw9l0Z/3LS2YprfG5zzi39YAuKaFuyPfCnxH3zb+YVf0Mmi7vxsCwG/Kfvn/ZnZUUhspCgVuD+PmOvsGipCca3UCyTFM+GaXhNhZl4dEiSAUhz+foV9Y+7CS3jh9SdbgIKADPgalt1cxmfxDoix9Z7klXdjS5XdK9SakayycdxOMeo9xeo0EKTfDorr0i/JHLh8W2EeCx4wTAYBTJGBw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6qzc-0007wE-1G; Fri, 01 Nov 2024 08:43:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#74151] [PATCH v2 9/9] services: web: Fix race between nginx activation and anonip. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Fri, 01 Nov 2024 12:43:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74151 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74151@debbugs.gnu.org Cc: Maxim Cournoyer , Maxim Cournoyer X-Debbugs-Original-Xcc: Maxim Cournoyer Received: via spool by 74151-submit@debbugs.gnu.org id=B74151.173046495930434 (code B ref 74151); Fri, 01 Nov 2024 12:43:07 +0000 Received: (at 74151) by debbugs.gnu.org; 1 Nov 2024 12:42:39 +0000 Received: from localhost ([127.0.0.1]:49231 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6qz8-0007un-Ib for submit@debbugs.gnu.org; Fri, 01 Nov 2024 08:42:39 -0400 Received: from mail-pf1-f178.google.com ([209.85.210.178]:50571) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6qz4-0007uG-9J for 74151@debbugs.gnu.org; Fri, 01 Nov 2024 08:42:35 -0400 Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-71e5a62031aso1510637b3a.1 for <74151@debbugs.gnu.org>; Fri, 01 Nov 2024 05:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730464888; x=1731069688; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KGe8VyZN2Ra66xrmhWqWpZAX95htDF0u7v2gQpwIFQo=; b=XFIdxqo0qSklID+PpydkkU7/5w9LYBmhoZYQ0oJWFaxN16VxANBPe49vDl0YU7YT3u HCsWa5KPY7Xj6h29QnLtYPC01fihyWXOvjtITi/Ujl4/f/Za/bYK2lx2QZ5UY1pUELjg b6iLmfMsVF3FIKt7f+dTOgP+lKT6tLivFJG1Jq0DBs0llqBKlJ3Ta8UvsM3pKYVGwkmt /hkJungIBczNfTKaYtPNge7hsUkcQgXXaI9htL//BHha12ct7xJq6JTyTtj/By0xxn4Y qaw90HK+4a/Rc3ER2avXU5ahaXcDLbPNLhQ3je0qCaHxVyGrqb5jIoPpvpxsdw34lH3i lcbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730464888; x=1731069688; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KGe8VyZN2Ra66xrmhWqWpZAX95htDF0u7v2gQpwIFQo=; b=TWn7U1oYgr2QwZEEduUB1W3WgkyJKIF2Jd0uGlqkWNzjqNd51CbbnUvDM5l3pFKgwI OaAL2REXS4Oi1S4VkOLOdi5QIWl2UGQT7wu4Ppw9hFYBv06xosijinT3N2ut/uebXkxS Mh7lJE4N6NnItmpdI78sZ+yZ/oKqkY2yHYeu5bIIviLowlpoj9kwVk9bMJIIUaQFhIny Kcu82yGqOMHVY3K8FGYkbBuDraThFL2mTCVcAIOlkJoxeuCaHR/lkg8cXOLD3sghCX8r Nmsmd1wsbzaXioC+hzbhe6YF0/70FROMDuVfiDAZ1B70p0Wq/itx23+vAV1QMG85JdzY fdVg== X-Gm-Message-State: AOJu0YzNZE83RA8oGtCkn6mzTvT96L5Zd8906Ld6/7eBlUW5E7HdIfnK fwNke0iEQfG0nRsVykM11mpIOdZwfLeTyB+RBnwDEcPXLQZkGbE0bsaHi9WI X-Google-Smtp-Source: AGHT+IF/jch5hLqJABLw+fRDEF6YIkJ4zKMWjTB7ItkhTzAFCjMrwBETi5z28485ygw4UnzrU4EdRA== X-Received: by 2002:a17:90b:1650:b0:2e2:b45f:53b4 with SMTP id 98e67ed59e1d1-2e94c50d447mr4565972a91.25.1730464887983; Fri, 01 Nov 2024 05:41:27 -0700 (PDT) Received: from localhost.localdomain ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e92fa0ea9bsm4819463a91.10.2024.11.01.05.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 05:41:27 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 1 Nov 2024 21:39:29 +0900 Message-ID: <1d6c7e71f2a80a38f801965b7fd27f0b982016ec.1730464675.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <281a4773768a6c271ff464f473fdbc333a58c348.1730464675.git.maxim.cournoyer@gmail.com> References: <281a4773768a6c271ff464f473fdbc333a58c348.1730464675.git.maxim.cournoyer@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/web.scm (anonip-shepherd-service): Recreate the input file when it's not a FIFO. Fixes: 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