From patchwork Sun May 4 08:56:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 42281 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 3394927BC4A; Sun, 4 May 2025 09:59:36 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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=unavailable 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 C39C327BC49 for ; Sun, 4 May 2025 09:59:33 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uBVC2-0001pm-Rs; Sun, 04 May 2025 04:59:26 -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 1uBVBy-0001ok-5x for guix-patches@gnu.org; Sun, 04 May 2025 04:59:22 -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 1uBVBf-000456-OL for guix-patches@gnu.org; Sun, 04 May 2025 04:59: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=fiyNp+kFwllwhr97cTlN/uwnxKmABGYRh54v6E+Qa/I=; b=pcAXYnsg9NsbcWT6g90et+HLDDPXd/ZnGp7TN6QDSsgEWAzNxyQl+tJZEt3Oco+hmtDSiyl01DSrasyKS4qQImlzlIxDn9kNfdnZnYdwTYIYbeRqWrssUd0BB3tiWWJbWc/pjVnP1i03DKyeVUAjjs35mXnPtR2rbQh53ClkeQ11FOseCNT8mM7hOtrI02TkhUn56pOjRL5TlwxPvibnUvUmPcDX6ZVJuYLGFKVrtNPiRF2EgY/AnYJSna+PRksS6s3Bh7jfEjrnDCsipzCkpa7UstyTmV48ShLKyFl6f8DJRR1sHHaAydeONqnsWwuT8CukGYvRAP2XVQYeU6FI+w==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uBVBf-0000Wc-Ji for guix-patches@gnu.org; Sun, 04 May 2025 04:59:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78066] [PATCH v3 5/6] gnu: fail2ban: Improve style. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 04 May 2025 08:59:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78066 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78066@debbugs.gnu.org Cc: Nicolas Graves Received: via spool by 78066-submit@debbugs.gnu.org id=B78066.17463490941620 (code B ref 78066); Sun, 04 May 2025 08:59:03 +0000 Received: (at 78066) by debbugs.gnu.org; 4 May 2025 08:58:14 +0000 Received: from localhost ([127.0.0.1]:51338 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uBVAr-0000Py-IP for submit@debbugs.gnu.org; Sun, 04 May 2025 04:58:14 -0400 Received: from 9.mo562.mail-out.ovh.net ([46.105.72.114]:45797) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uBVAa-0000M7-7X for 78066@debbugs.gnu.org; Sun, 04 May 2025 04:57:59 -0400 Received: from director4.derp.mail-out.ovh.net (director4.derp.mail-out.ovh.net [79.137.60.37]) by mo562.mail-out.ovh.net (Postfix) with ESMTPS id 4Zqz826mTfz1W1v; Sun, 4 May 2025 08:57:54 +0000 (UTC) Received: from director4.derp.mail-out.ovh.net (director4.derp.mail-out.ovh.net. [127.0.0.1]) by director4.derp.mail-out.ovh.net (inspect_sender_mail_agent) with SMTP for <78066@debbugs.gnu.org>; Sun, 4 May 2025 08:57:54 +0000 (UTC) Received: from mta7.priv.ovhmail-u1.ea.mail.ovh.net (unknown [10.108.2.71]) by director4.derp.mail-out.ovh.net (Postfix) with ESMTPS id 4Zqz825dLVz2c5j; Sun, 4 May 2025 08:57:54 +0000 (UTC) Received: from ngraves.fr (unknown [10.1.6.6]) by mta7.priv.ovhmail-u1.ea.mail.ovh.net (Postfix) with ESMTPSA id 7DCE4C3AB1; Sun, 4 May 2025 08:57:54 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-99G003f7fe9720-8e5f-4c4d-933b-9627259a9705, 8CD8A0E5D230CF78A323F194FBE8D47D3072D94D) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 90.92.117.144 Date: Sun, 4 May 2025 10:56:25 +0200 Message-ID: <20250504085747.6387-6-ngraves@ngraves.fr> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250504085747.6387-1-ngraves@ngraves.fr> References: <20250504085747.6387-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3175600688989135586 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvjeejjeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnheptdejjedvkedtkeekfeehvdejteegvefgveelgfehhfdvjeelffdtteefudetieffnecuffhomhgrihhnpehfrghilhdvsggrnhhrvghgvgigrdhphienucfkphepuddvjedrtddrtddruddpledtrdelvddruddujedrudeggeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepjeektdeiieesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthhopehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpoffvtefjohhsthepmhhoheeivdgmpdhmohguvgepshhmthhpohhuth DKIM-Signature: a=rsa-sha256; bh=fiyNp+kFwllwhr97cTlN/uwnxKmABGYRh54v6E+Qa/I=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1746349075; v=1; b=WdEXYc+RDUK5174tXdSonaVQ5ROQVFQQgoVxIS0mY8X5DCII5+2QDcM4uDTf8/dm1Jv4Wx96 +Z8ywdFjTKrE9bkPSjAvpv/gNIchyYp6YnEAsmZWrZQqq5dE5WotcuuObzj0lWr6Qg29IT3RKKj smlPUlXCgic89l1D9enuZNfVvFdsok/IGTKPyo90rmmeFSuJg7oexsmxOgjOBQsdFJJYaKu/qwX Z4cUisDA57Dn6Jbz48J9SrTtSTJiPy1wmGouWh6yXsc2QfbWyslnvjxBNe2G4XbIv/8eXJg16it 2k2YFA3x/a0R7Xz4QWEelTz/J1BzrtN01rKmbsrH0/hHA== 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: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves 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/packages/admin.scm (fail2ban): [arguments]: Rewrite phases 'set-action-dependencies and copy-man-pages for readability. --- gnu/packages/admin.scm | 121 ++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 67 deletions(-) diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm index c9dd154313..e508340ef0 100644 --- a/gnu/packages/admin.scm +++ b/gnu/packages/admin.scm @@ -6237,21 +6237,22 @@ (define (make-suite str) (((make-suite "servertestcase.ServerConfigReaderTests")) "")))) (add-before 'build 'fix-default-config - (lambda* (#:key outputs #:allow-other-keys) + (lambda _ (substitute* '("config/paths-common.conf" "fail2ban/tests/utils.py" "fail2ban/client/configreader.py" "fail2ban/client/fail2bancmdline.py" "fail2ban/client/fail2banregex.py") (("/etc/fail2ban") - (string-append (assoc-ref outputs "out") "/etc/fail2ban"))))) + (string-append #$output "/etc/fail2ban"))))) (add-after 'fix-default-config 'set-action-dependencies (lambda* (#:key inputs #:allow-other-keys) ;; deleting things that are not feasible to fix ;; or won't be used any way (with-directory-excursion "config/action.d" (for-each delete-file - '("apf.conf" "bsd-ipfw.conf" + '("apf.conf" + "bsd-ipfw.conf" "dshield.conf" "ipfilter.conf" "ipfw.conf" @@ -6270,74 +6271,60 @@ (define (make-suite str) "shorewall.conf" "shorewall-ipset-proto6.conf" "ufw.conf"))) - (let* ((lookup-cmd (lambda (i) - (search-input-file inputs i))) - (bin (lambda (i) - (lookup-cmd (string-append "/bin/" i)))) - (sbin (lambda (i) - (lookup-cmd (string-append "/sbin/" i)))) - (ip (sbin "ip")) - (sendmail (sbin "sendmail"))) - (substitute* (find-files "config/action.d" "\\.conf$") - ;; TODO: deal with geoiplookup .. - (("(awk|curl|dig|jq)" all cmd) - (bin cmd)) - (("(cat|echo|grep|head|printf|wc) " all cmd) - (string-append (bin cmd) " ")) - ((" (date|rm|sed|tail|touch|tr) " all cmd) - (string-append " " - (bin cmd) " ")) - (("cut -d") - (string-append (bin "cut") " -d")) - (("`date`") - (string-append "`" - (bin "date") "`")) - (("id -") - (string-append (bin "id") " -")) - (("ip -([46]) addr" all ver) - (string-append ip " -" ver " addr")) - (("ip route") - (string-append ip " route")) - (("ipset ") - (string-append (sbin "ipset") " ")) - (("(iptables|ip6tables) <" all cmd) - (string-append (sbin cmd) " <")) - (("/usr/bin/nsupdate") - (bin "nsupdate")) - (("mail -E") - (string-append sendmail " -E")) - (("nftables = nft") - (string-append "nftables = " - (sbin "nft"))) - (("perl -e") - (string-append (bin "perl") " -e")) - (("/usr/sbin/sendmail") - sendmail) - (("test -e") - (string-append (bin "test") " -e")) - (("_whois = whois") - (string-append "_whois = " - (bin "whois"))))) + (define (lookup dir file) + (search-input-file inputs (string-append "/" dir "/" file))) + + (substitute* (find-files "config/action.d" "\\.conf$") + ;; TODO: deal with geoiplookup .. + (("(awk|curl|dig|jq)" all cmd) + (lookup "bin" cmd)) + (("(cat|echo|grep|head|printf|wc) " all cmd) + (string-append (lookup "bin" cmd) " ")) + ((" (date|rm|sed|tail|touch|tr) " all cmd) + (string-append " " (lookup "bin" cmd) " ")) + (("cut -d") + (string-append (lookup "bin" "cut") " -d")) + (("`date`") + (string-append "`" (lookup "bin" "date") "`")) + (("id -") + (string-append (lookup "bin" "id") " -")) + (("ip (route|-[46] addr)" all rest) + (string-append (lookup "sbin" "ip") rest)) + (("ipset ") + (string-append (lookup "sbin" "ipset") " ")) + (("(iptables|ip6tables) <" all cmd) + (string-append (lookup "sbin" cmd) " <")) + (("/usr/bin/nsupdate") + (lookup "bin" "nsupdate")) + (("mail -E") + (string-append (lookup "sbin" "sendmail") " -E")) + (("nftables = nft") + (string-append "nftables = " (lookup "sbin" "nft"))) + (("perl -e") + (string-append (lookup "bin" "perl") " -e")) + (("/usr/sbin/sendmail") + (lookup "sbin" "sendmail")) + (("test -e") + (string-append (lookup "bin" "test") " -e")) + (("_whois = whois") + (string-append "_whois = " (lookup "bin" "whois")))) + (substitute* "config/jail.conf" (("before = paths-debian\\.conf") "before = paths-guix.conf")))) (add-after 'install 'copy-man-pages - (lambda* (#:key outputs #:allow-other-keys) - (let* ((man (string-append (assoc-ref outputs "out") "/man")) - (install-man (lambda (m) - (lambda (f) - (install-file (string-append f "." m) - (string-append man "/man" - m))))) - (install-man1 (install-man "1")) - (install-man5 (install-man "5"))) - (with-directory-excursion "man" - (for-each install-man1 - '("fail2ban" "fail2ban-client" "fail2ban-python" - "fail2ban-regex" "fail2ban-server" - "fail2ban-testcases")) - (for-each install-man5 - '("jail.conf"))))))))) + (lambda _ + (define (install-man m) + (lambda (f) + (install-file (string-append f "." m) + (string-append #$output "man/man" m)))) + + (with-directory-excursion "man" + (for-each (install-man "1") + '("fail2ban" "fail2ban-client" "fail2ban-python" + "fail2ban-regex" "fail2ban-server" + "fail2ban-testcases")) + ((install-man "5") "jail.conf"))))))) (native-inputs (list python-setuptools python-wheel)) (inputs (list gawk coreutils-minimal