From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id sDYVO6M3BWOo/AAAbAwnHQ (envelope-from ) for ; Tue, 23 Aug 2022 22:25:08 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id KFMNO6M3BWOTiQAAauVa8A (envelope-from ) for ; Tue, 23 Aug 2022 22:25:07 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B00652E668 for ; Tue, 23 Aug 2022 22:25:07 +0200 (CEST) Received: from localhost ([::1]:33964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQaSQ-0000kX-RP for larch@yhetil.org; Tue, 23 Aug 2022 16:25:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQaSM-0000kN-Ut for guix-patches@gnu.org; Tue, 23 Aug 2022 16:25:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55364) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQaSM-0003pi-FA for guix-patches@gnu.org; Tue, 23 Aug 2022 16:25:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oQaSM-0007Z4-6r for guix-patches@gnu.org; Tue, 23 Aug 2022 16:25:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56608] [PATCH v2 2/2] gnu: tests: Add fail2ban tests. Resent-From: muradm Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 23 Aug 2022 20:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56608 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 56608@debbugs.gnu.org Received: via spool by 56608-submit@debbugs.gnu.org id=B56608.166128624729013 (code B ref 56608); Tue, 23 Aug 2022 20:25:02 +0000 Received: (at 56608) by debbugs.gnu.org; 23 Aug 2022 20:24:07 +0000 Received: from localhost ([127.0.0.1]:45113 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQaRS-0007Xt-RL for submit@debbugs.gnu.org; Tue, 23 Aug 2022 16:24:07 -0400 Received: from nomad-cl1.staging.muradm.net ([139.162.159.157]:57524 helo=nomad-cl1.muradm.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQaRR-0007XO-JX for 56608@debbugs.gnu.org; Tue, 23 Aug 2022 16:24:06 -0400 Received: from localhost ([127.0.0.1]:54074) by nomad-cl1.muradm.net with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1oQaQW-0006oI-0O; Tue, 23 Aug 2022 20:23:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=muradm.net; s=mail; h=Content-Type:MIME-Version:Message-ID:In-reply-to:Date:Subject:Cc:To :From:References:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=VRSCUGYEbZ7ypTN4UM1TJLm7X0kD271KCN2CB4JkL4o=; b=Ytkp7f62fEM0aezGpHIXehq4aW zRCn6Th7krWcQHwBfKOCaddtS94YVyoZ1HRi2ERq3uqSWQ5AMXQ6RaR7mBAsfM27YARvwLuPpCmkp wstMTJTDq8Id6iqofAVpd76hQhwlSxjDAMKOly1WXvI/tX5QXAqwH7gTlq1SIFjraqVw/e/JMZ8+X Ih4K2gRcjdThxGQoyDd1bdnx1fcn6JchyJY8A6i+xIDzpxGfobW3NfjaWsCMiHLMUBZ6OqWthqMf/ B19CDwcNTMvlHb4CSweOIH/49OwTcJq3Bjsh/ds7hW2su0/Am9wSDb66EpvNvJMNM0DDrHGHi+aSp Lqlg9RTpbnfxYpnUkJpQiqSs1c4DyltzKYKMOGph4zw02JEiQzXRf3Nnwsb0A+gMYfY1kiyilRuMx jJZGjRQLO9T3SfmMKrOnZhy9CLXsWfDGjHnyO8jP9AASL52mSY9ti5AATvoinDGKO8ilwXQurPzUw on9M4wzJDX5FXzpwkLGoRDd1; Received: from muradm by localhost with local (Exim 4.96) (envelope-from ) id 1oQaRK-0006Dp-2Q; Tue, 23 Aug 2022 23:23:58 +0300 References: <87edxxqpg3.fsf@gmail.com> <20220822172607.31515-1-mail@muradm.net> <20220822172607.31515-3-mail@muradm.net> <87edx8gkhm.fsf@gmail.com> <87r116ybj4.fsf@muradm.net> User-agent: mu4e 1.8.7; emacs 29.0.50 From: muradm Date: Tue, 23 Aug 2022 23:19:34 +0300 In-reply-to: <87r116ybj4.fsf@muradm.net> Message-ID: <87mtbuyaht.fsf@muradm.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1661286307; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=VRSCUGYEbZ7ypTN4UM1TJLm7X0kD271KCN2CB4JkL4o=; b=J6YrzCBHH2CeHe1xsccXCKdcrNf9JxiFbAizHHXJ3GRBJpkXEVXBUH2PIb98Lk+DD0PKIt oBs197C6khgPl3CieIyQaY44/djKK4LxjmVSfNC4Rm/dEHljg+2woaAnmdgzm7vByehf4L UyQK/+Z6VhmMfIrqkkgILvo6cMEGl7cXrjYeiuyTlTO2D5AUCub0X/YE8OcTxIL8WtsEye vSTPk2+XCYQbcRmLsa8rF3MXqqQes2uSRgnU7oRMJ9ye6eKDWjVWZsLYhU1FQZXFZXpWA7 mbBVfflWVZylpkXQ+ImtJmwdwOcOSCOtng7f/xYRoSZEFesKJqziPNhY6kU0NQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1661286307; a=rsa-sha256; cv=none; b=rVKMUiwGQxNejIZnjdQpo+IJCW5fpmQBAduyCnszUf38cIKchWqnz8ZM4DoPWe9XolwJSl cIDNVV6baRsQt64Ny81mPBBh0xwdZsdQCjc9ANv6w1e8NauHHoPNxvsAWC9X8alWOkTOvy hWEUKYE1kgrXktg+IGM/ToSMEfTi/nKPYpDURuVrsxpdw4RUuDVazsYZaG6yTEECRTgp7g t+fTprVUNa+IQ0J7ptLCmY+tQVYb0HXCeB30tGWuBijVtw/oACbCs8MHaLvBr6yeSvw5E2 HLroP1mEReUvcWFLRDnq6HqI9XY9LKKRl73KdH997EF63F7SGUPSSpu32COXFQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=muradm.net header.s=mail header.b=Ytkp7f62; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -0.90 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=muradm.net header.s=mail header.b=Ytkp7f62; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: B00652E668 X-Spam-Score: -0.90 X-Migadu-Scanner: scn1.migadu.com X-TUID: 7CLnWhBh1v6r --=-=-= Content-Type: text/plain; format=flowed muradm 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 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEESPY5lma9A9l5HGLP6M7O0mLOBeIFAmMFN14ACgkQ6M7O0mLO BeI8gxAAgM9Grih6A+uIX/JdLwXXmW6CLi5Vj1zZs63Kw0KoMoknvOIOcabFvf7f WhUwFfaHkoBvuUAdCy6+rb6Is4B11Xn7ihFOZ1/C5xHL9uo0HtGys8lRht2t+Q7V RcM90CEN75NITU6fsT5fRBOU0CUNrx7PD8HqKAGwjYu7npGC9jQ9nt72nq4gwigA S+ANrPn4QmS3xCspbY5qXtxSmkElDwCELzQvA9PBbtsmEyKwVw5ZJifpBtVK6ZVu lsq7hi2i75HQ2hQsnTAQBvkGu6Y4ptGJumgOP4Jzhct96bQ76h7I+8iZe4/RvNCN uF0vYzjYsJ6VyZrz/E2Qovtq9gZB680zk6y6VpV7v5P/z3+uZuIwnpgtPJBr93Nm sOBYiop17y3I9HiMIr9ZNb5FonE/A3voEWDAQmiGGyYRJfRYkKPGXSmQYXAlvKCM F9nexpRyUUeUYY4mxh3kxUVx84JpXaDkge9EpFzUaVxikzTePnQ0Rc7ikD5kAzFS RK/JMxteTrWmWujOyvk3PKUNBkIwGcPiIwOoPhRumvqFNfe9pCqmDj0nzuDUPITA piw+rsCOEPFiBNzr4q+Iy8ioTCNdPYx3/duCuf6v7FVIJUzHcYjUjftbRZAWWA8W /wsofO8FMrs+PZp/WjbSFyyjFDfOBP5H5vUmdFSsYH5KpxzbXiE= =j3/U -----END PGP SIGNATURE----- --=-=-=--