From patchwork Sat May 3 14:00:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 42266 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 676F427BC4B; Sat, 3 May 2025 15:05:53 +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=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 98C2627BC49 for ; Sat, 3 May 2025 15:05:52 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uBDUX-0001uG-7d; Sat, 03 May 2025 10:05:21 -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 1uBDUE-0001o9-RV for guix-patches@gnu.org; Sat, 03 May 2025 10:05:04 -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 1uBDUE-0007Og-IH for guix-patches@gnu.org; Sat, 03 May 2025 10:05:02 -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=s+ikIRLCgqDpvMCbwfMztJA1RFMb6kkUlnPaL5K51/s=; b=cghSmI28C/6m5JR2mgzjJvaCde+jTeChrjRD6XxmzvJswItwi4RggYHF6aTIhrwHDa2A16NKYQxr4w50mSYf2ID4kE1s2ByggOdGerUWwDdKjmTAJZww8V4I2xPuL6Ybkbt+uYk1CwOEOqB6k6PUS1MKWKvlgORCdFtzrP9wlAkEVZCwIIsXtdt6FWhREzx9wLTYsZKGahSgQKBc7ETdfzBbLhYEww6fJfLxR/8TojhmuU9FaP+wbRLTRzFoUJwJQrZgKGLkBsrfMw//1kDL/d4782h2ZpnN7wIuLdLcajTeafVpRt0RrOxCdpzEtaDJmm7Dgbk8Beilzo6aLjcoog==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uBDUE-0000pZ-Ak for guix-patches@gnu.org; Sat, 03 May 2025 10:05:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78066] [PATCH v2 5/6] gnu: fail2ban: Improve style. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 03 May 2025 14:05:02 +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.17462810463070 (code B ref 78066); Sat, 03 May 2025 14:05:02 +0000 Received: (at 78066) by debbugs.gnu.org; 3 May 2025 14:04:06 +0000 Received: from localhost ([127.0.0.1]:41880 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uBDTJ-0000nN-Pp for submit@debbugs.gnu.org; Sat, 03 May 2025 10:04:06 -0400 Received: from 5.mo563.mail-out.ovh.net ([46.105.53.64]:41849) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uBDTC-0000ma-CV for 78066@debbugs.gnu.org; Sat, 03 May 2025 10:03:59 -0400 Received: from director1.derp.mail-out.ovh.net (director1.derp.mail-out.ovh.net [51.68.80.175]) by mo563.mail-out.ovh.net (Postfix) with ESMTPS id 4ZqTzc5fd6z1fBq; Sat, 3 May 2025 14:03:56 +0000 (UTC) Received: from director1.derp.mail-out.ovh.net (director1.derp.mail-out.ovh.net. [127.0.0.1]) by director1.derp.mail-out.ovh.net (inspect_sender_mail_agent) with SMTP for <78066@debbugs.gnu.org>; Sat, 3 May 2025 14:03:56 +0000 (UTC) Received: from mta6.priv.ovhmail-u1.ea.mail.ovh.net (unknown [10.110.113.27]) by director1.derp.mail-out.ovh.net (Postfix) with ESMTPS id 4ZqTzc3XFzz61qd; Sat, 3 May 2025 14:03:56 +0000 (UTC) Received: from ngraves.fr (unknown [10.1.6.7]) by mta6.priv.ovhmail-u1.ea.mail.ovh.net (Postfix) with ESMTPSA id D0D8BD43E88; Sat, 3 May 2025 14:03:55 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-101G0046fcc430a-e9a0-4763-a902-b93f68226c93, 2C797D8F94FD4BAB69F3C297EB7FEDCEB15A77A0) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 89.207.175.193 Date: Sat, 3 May 2025 16:00:01 +0200 Message-ID: <20250503140234.9752-6-ngraves@ngraves.fr> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250503140234.9752-1-ngraves@ngraves.fr> References: <20250503140234.9752-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 2471350298684154594 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvjeehhedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnheptdejjedvkedtkeekfeehvdejteegvefgveelgfehhfdvjeelffdtteefudetieffnecuffhomhgrihhnpehfrghilhdvsggrnhhrvghgvgigrdhphienucfkphepuddvjedrtddrtddruddpkeelrddvtdejrddujeehrdduleefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpnhgspghrtghpthhtohepvddprhgtphhtthhopeejkedtieeiseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdfovfetjfhoshhtpehmohehieefmgdpmhhouggvpehsmhhtphhouhht DKIM-Signature: a=rsa-sha256; bh=s+ikIRLCgqDpvMCbwfMztJA1RFMb6kkUlnPaL5K51/s=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1746281036; v=1; b=n1oLnlwo8G5qm5cpuAzM9FxgBWK5HT6pkMyLanATOfogNVaZh4rct7okMdiq6aEjaTUDNbdS 5lsttOd97yqwDnxDAOJJiZTFxD40kd2ExkjyH+ZFdHYyAiQ40vkZVv0kBPDNBMyAVQXXZcYByDz aNYnZNHNEgQI5QPcXdmKPKygx3wZATOomBpfO9Z27fySdRyxm4403aIMkLMLdH1cEpBWLJ6wstm 9Y+MdvLcqtcdu90VYzm0EcKTq9IGl6qxSBkP8zGN1KIB521H9zAwgo1OnoUGrHXLGNOvs5ONtHy 8/3df6U/GXDn6Cn3SI015DbY6GrP0cBsm/WFA6dG9d5vA== 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 1f99059e4f..b808a3b6c5 100644 --- a/gnu/packages/admin.scm +++ b/gnu/packages/admin.scm @@ -6296,21 +6296,22 @@ (define (make-suite str) (((make-suite "servertestcase.ServerConfigReaderTests")) "")))) (add-before 'install '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" @@ -6329,74 +6330,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