mirror of
https://https.git.savannah.gnu.org/git/guix.git/
synced 2025-07-13 10:30:43 +02:00
gnu: fail2ban: Improve style.
* gnu/packages/admin.scm (fail2ban): [arguments]<phases>: Rewrite phases 'set-action-dependencies and copy-man-pages for readability. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
30f240b034
commit
bbae08827f
1 changed files with 54 additions and 67 deletions
|
@ -6237,21 +6237,22 @@ alias cysdig=sudo csysdig --modern-bpf
|
||||||
(((make-suite "servertestcase.ServerConfigReaderTests"))
|
(((make-suite "servertestcase.ServerConfigReaderTests"))
|
||||||
""))))
|
""))))
|
||||||
(add-before 'build 'fix-default-config
|
(add-before 'build 'fix-default-config
|
||||||
(lambda* (#:key outputs #:allow-other-keys)
|
(lambda _
|
||||||
(substitute* '("config/paths-common.conf"
|
(substitute* '("config/paths-common.conf"
|
||||||
"fail2ban/tests/utils.py"
|
"fail2ban/tests/utils.py"
|
||||||
"fail2ban/client/configreader.py"
|
"fail2ban/client/configreader.py"
|
||||||
"fail2ban/client/fail2bancmdline.py"
|
"fail2ban/client/fail2bancmdline.py"
|
||||||
"fail2ban/client/fail2banregex.py")
|
"fail2ban/client/fail2banregex.py")
|
||||||
(("/etc/fail2ban")
|
(("/etc/fail2ban")
|
||||||
(string-append (assoc-ref outputs "out") "/etc/fail2ban")))))
|
(string-append #$output "/etc/fail2ban")))))
|
||||||
(add-after 'fix-default-config 'set-action-dependencies
|
(add-after 'fix-default-config 'set-action-dependencies
|
||||||
(lambda* (#:key inputs #:allow-other-keys)
|
(lambda* (#:key inputs #:allow-other-keys)
|
||||||
;; deleting things that are not feasible to fix
|
;; deleting things that are not feasible to fix
|
||||||
;; or won't be used any way
|
;; or won't be used any way
|
||||||
(with-directory-excursion "config/action.d"
|
(with-directory-excursion "config/action.d"
|
||||||
(for-each delete-file
|
(for-each delete-file
|
||||||
'("apf.conf" "bsd-ipfw.conf"
|
'("apf.conf"
|
||||||
|
"bsd-ipfw.conf"
|
||||||
"dshield.conf"
|
"dshield.conf"
|
||||||
"ipfilter.conf"
|
"ipfilter.conf"
|
||||||
"ipfw.conf"
|
"ipfw.conf"
|
||||||
|
@ -6270,74 +6271,60 @@ alias cysdig=sudo csysdig --modern-bpf
|
||||||
"shorewall.conf"
|
"shorewall.conf"
|
||||||
"shorewall-ipset-proto6.conf"
|
"shorewall-ipset-proto6.conf"
|
||||||
"ufw.conf")))
|
"ufw.conf")))
|
||||||
(let* ((lookup-cmd (lambda (i)
|
(define (lookup dir file)
|
||||||
(search-input-file inputs i)))
|
(search-input-file inputs (string-append "/" dir "/" file)))
|
||||||
(bin (lambda (i)
|
|
||||||
(lookup-cmd (string-append "/bin/" i))))
|
(substitute* (find-files "config/action.d" "\\.conf$")
|
||||||
(sbin (lambda (i)
|
;; TODO: deal with geoiplookup ..
|
||||||
(lookup-cmd (string-append "/sbin/" i))))
|
(("(awk|curl|dig|jq)" all cmd)
|
||||||
(ip (sbin "ip"))
|
(lookup "bin" cmd))
|
||||||
(sendmail (sbin "sendmail")))
|
(("(cat|echo|grep|head|printf|wc) " all cmd)
|
||||||
(substitute* (find-files "config/action.d" "\\.conf$")
|
(string-append (lookup "bin" cmd) " "))
|
||||||
;; TODO: deal with geoiplookup ..
|
((" (date|rm|sed|tail|touch|tr) " all cmd)
|
||||||
(("(awk|curl|dig|jq)" all cmd)
|
(string-append " " (lookup "bin" cmd) " "))
|
||||||
(bin cmd))
|
(("cut -d")
|
||||||
(("(cat|echo|grep|head|printf|wc) " all cmd)
|
(string-append (lookup "bin" "cut") " -d"))
|
||||||
(string-append (bin cmd) " "))
|
(("`date`")
|
||||||
((" (date|rm|sed|tail|touch|tr) " all cmd)
|
(string-append "`" (lookup "bin" "date") "`"))
|
||||||
(string-append " "
|
(("id -")
|
||||||
(bin cmd) " "))
|
(string-append (lookup "bin" "id") " -"))
|
||||||
(("cut -d")
|
(("ip (route|-[46] addr)" all rest)
|
||||||
(string-append (bin "cut") " -d"))
|
(string-append (lookup "sbin" "ip") rest))
|
||||||
(("`date`")
|
(("ipset ")
|
||||||
(string-append "`"
|
(string-append (lookup "sbin" "ipset") " "))
|
||||||
(bin "date") "`"))
|
(("(iptables|ip6tables) <" all cmd)
|
||||||
(("id -")
|
(string-append (lookup "sbin" cmd) " <"))
|
||||||
(string-append (bin "id") " -"))
|
(("/usr/bin/nsupdate")
|
||||||
(("ip -([46]) addr" all ver)
|
(lookup "bin" "nsupdate"))
|
||||||
(string-append ip " -" ver " addr"))
|
(("mail -E")
|
||||||
(("ip route")
|
(string-append (lookup "sbin" "sendmail") " -E"))
|
||||||
(string-append ip " route"))
|
(("nftables = nft")
|
||||||
(("ipset ")
|
(string-append "nftables = " (lookup "sbin" "nft")))
|
||||||
(string-append (sbin "ipset") " "))
|
(("perl -e")
|
||||||
(("(iptables|ip6tables) <" all cmd)
|
(string-append (lookup "bin" "perl") " -e"))
|
||||||
(string-append (sbin cmd) " <"))
|
(("/usr/sbin/sendmail")
|
||||||
(("/usr/bin/nsupdate")
|
(lookup "sbin" "sendmail"))
|
||||||
(bin "nsupdate"))
|
(("test -e")
|
||||||
(("mail -E")
|
(string-append (lookup "bin" "test") " -e"))
|
||||||
(string-append sendmail " -E"))
|
(("_whois = whois")
|
||||||
(("nftables = nft")
|
(string-append "_whois = " (lookup "bin" "whois"))))
|
||||||
(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")))))
|
|
||||||
(substitute* "config/jail.conf"
|
(substitute* "config/jail.conf"
|
||||||
(("before = paths-debian\\.conf")
|
(("before = paths-debian\\.conf")
|
||||||
"before = paths-guix.conf"))))
|
"before = paths-guix.conf"))))
|
||||||
(add-after 'install 'copy-man-pages
|
(add-after 'install 'copy-man-pages
|
||||||
(lambda* (#:key outputs #:allow-other-keys)
|
(lambda _
|
||||||
(let* ((man (string-append (assoc-ref outputs "out") "/man"))
|
(define (install-man m)
|
||||||
(install-man (lambda (m)
|
(lambda (f)
|
||||||
(lambda (f)
|
(install-file (string-append f "." m)
|
||||||
(install-file (string-append f "." m)
|
(string-append #$output "man/man" m))))
|
||||||
(string-append man "/man"
|
|
||||||
m)))))
|
(with-directory-excursion "man"
|
||||||
(install-man1 (install-man "1"))
|
(for-each (install-man "1")
|
||||||
(install-man5 (install-man "5")))
|
'("fail2ban" "fail2ban-client" "fail2ban-python"
|
||||||
(with-directory-excursion "man"
|
"fail2ban-regex" "fail2ban-server"
|
||||||
(for-each install-man1
|
"fail2ban-testcases"))
|
||||||
'("fail2ban" "fail2ban-client" "fail2ban-python"
|
((install-man "5") "jail.conf")))))))
|
||||||
"fail2ban-regex" "fail2ban-server"
|
|
||||||
"fail2ban-testcases"))
|
|
||||||
(for-each install-man5
|
|
||||||
'("jail.conf")))))))))
|
|
||||||
(native-inputs (list python-setuptools python-wheel))
|
(native-inputs (list python-setuptools python-wheel))
|
||||||
(inputs (list gawk
|
(inputs (list gawk
|
||||||
coreutils-minimal
|
coreutils-minimal
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue