guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#56608] [PATCH v2 2/2] gnu: tests: Add fail2ban tests.


From: muradm
Subject: [bug#56608] [PATCH v2 2/2] gnu: tests: Add fail2ban tests.
Date: Tue, 23 Aug 2022 23:19:34 +0300
User-agent: mu4e 1.8.7; emacs 29.0.50


muradm <mail@muradm.net> writes:

[...]

+          (test-equal "fail2ban sshd jail running"
+            '("Status for the jail: sshd"
+              "|- Filter"
+              "|  |- Currently failed:\t0"
+              "|  |- Total failed:\t0"
+              "|  `- File list:\t/var/log/secure"
+              "`- Actions"
+              "   |- Currently banned:\t0"
+              "   |- Total banned:\t0"
+              "   `- Banned IP list:\t"
+              "")
+            (marionette-eval
+             '(begin
+ (use-modules (ice-9 rdelim) (ice-9 popen) (rnrs io
ports))
+                (let ((call-command
+                       (lambda (cmd)
+                         (let* ((err-cons (pipe))
+ (port (with-error-to-port (cdr
err-cons)
+                                        (lambda ()
(open-input-pipe cmd))))
+ (_ (setvbuf (car err-cons) 'block + (* 1024 1024 16))) + (result (read-delimited "" port)))
+                           (close-port (cdr err-cons))
+ (values result (read-delimited "" (car
err-cons)))))))
+                  (string-split
+                   (call-command
+                    (string-join (list #$%fail2ban-server-cmd
"status" "sshd") " "))
+                   #\newline)))
+             marionette))

Perhaps this could be turned into an Shepherd action, and the Guile procedure could do the above to return the text output; to simplify
the
test and reduce boilerplate, while providing value to the user.


Here I use a cli of fail2ban. It's arguments are very extended.
I'm not sure how it should be implemented in terms of
shepherd-action. I will continue thinking about it, but I
would prefer to skip this for now, if you don't mind.

thanks in advance,
muradm

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]