From patchwork Sun Sep 4 11:24:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: muradm X-Patchwork-Id: 42201 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 7AF8E27BBEA; Sun, 4 Sep 2022 12:25:54 +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=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,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 E7A0427BBE9 for ; Sun, 4 Sep 2022 12:25:53 +0100 (BST) Received: from localhost ([::1]:60838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUnl8-0000by-WE for patchwork@mira.cbaines.net; Sun, 04 Sep 2022 07:25:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUnkM-0000a4-TK for guix-patches@gnu.org; Sun, 04 Sep 2022 07:25:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:54886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUnkM-00029l-L1 for guix-patches@gnu.org; Sun, 04 Sep 2022 07:25:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oUnkM-0001j3-Gp for guix-patches@gnu.org; Sun, 04 Sep 2022 07:25:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57575] [PATCH] gnu: fail2ban-service-type: Improve extra-content fields. Resent-From: muradm Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 04 Sep 2022 11:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 57575 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57575@debbugs.gnu.org Cc: Maxim Cournoyer X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16622906986618 (code B ref -1); Sun, 04 Sep 2022 11:25:02 +0000 Received: (at submit) by debbugs.gnu.org; 4 Sep 2022 11:24:58 +0000 Received: from localhost ([127.0.0.1]:43585 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUnkG-0001ic-7q for submit@debbugs.gnu.org; Sun, 04 Sep 2022 07:24:58 -0400 Received: from lists.gnu.org ([209.51.188.17]:49000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUnkB-0001iR-82 for submit@debbugs.gnu.org; Sun, 04 Sep 2022 07:24:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUnkA-0000WX-AP for guix-patches@gnu.org; Sun, 04 Sep 2022 07:24:50 -0400 Received: from nomad-cl1.staging.muradm.net ([139.162.159.157]:60018 helo=nomad-cl1.muradm.net) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUnk7-00025h-CE for guix-patches@gnu.org; Sun, 04 Sep 2022 07:24:48 -0400 Received: from localhost ([127.0.0.1]:44794) by nomad-cl1.muradm.net with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1oUnjx-00033m-0f; Sun, 04 Sep 2022 11:24:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=muradm.net; s=mail; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=o/A4fvyl6KBxyJjcWYloKbhjEMSRsAWtAXkhF1glAFw=; b=wJCY3XVR5CeMMLAeYnqUzpYqhh hR1vaJeHHnDk7TVP/aN9pGwunCXrXvjy1Xkx4dYqkqM/TbiYsCudmUEI7PxQDyxqoKepavlLNt3GT JoBmyruNogwR/X8GnxG2xIpOH3eRPOYMOxzIJBHpU71wdtEZCbddypdCVDGcS/ACpZPuzZ4averXG UAatIbUT/wMDZfntKTqS3BfHLUvKYUr0b/RP0khwNU+o28hYEpLyDdlPV/odsEQsfXQb9bmm/lvJe 9e2ztKxA6KghZ13DY6mPLds/dFd4+ylBPhrJsTvkwz7xGfDxFYu5D4n0SPrMA/+WpZ/lXC4yhEt0b tpYvbH1t8+G0Qqh8GsgL0sEwCVMcIrdTz0R4y96oLou1eBh1aQbj8IlGNde2Y6B+qAqkbUA8B0fd9 KyKaM0eT0NYHkXIrRUSaSjf+YgwIv1US9zFOv/Nm9XShVL27/MP30fGjR4fClkjNL1F8ia/yErvan qehgbJkJmyDnE/iSTICWY7r6; Received: from muradm by localhost with local (Exim 4.96) (envelope-from ) id 1oUnk2-0008CD-2Y; Sun, 04 Sep 2022 14:24:42 +0300 From: muradm Date: Sun, 4 Sep 2022 14:24:42 +0300 Message-Id: <20220904112442.31501-1-mail@muradm.net> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Received-SPF: pass client-ip=139.162.159.157; envelope-from=mail@muradm.net; helo=nomad-cl1.muradm.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/security.scm: (fail2ban-jail-configuration)[extra-content]: Change to text-config. (fail2ban-configuration)[extra-content]: Change to text-config. * gnu/doc/guix.texi: Update type of extra-content fields. --- doc/guix.texi | 4 ++-- gnu/services/security.scm | 15 ++++----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 80ca017599..b0a309efc2 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -36619,7 +36619,7 @@ extensions. @item @code{extra-jails} (default: @code{()}) (type: list-of-fail2ban-jail-configurations) Instances of @code{} explicitly provided. -@item @code{extra-content} (type: maybe-string) +@item @code{extra-content} (default: @code{()}) (type: text-config) Extra raw content to add to the end of the @file{jail.local} file. @end table @@ -36747,7 +36747,7 @@ The file names of the log files to be monitored. @item @code{action} (default: @code{()}) (type: list-of-fail2ban-jail-actions) A list of @code{}. -@item @code{extra-content} (type: maybe-string) +@item @code{extra-content} (default: @code{()}) (type: text-config) Extra content for the jail configuration. @end table diff --git a/gnu/services/security.scm b/gnu/services/security.scm index fd5bf19730..e6b59442ca 100644 --- a/gnu/services/security.scm +++ b/gnu/services/security.scm @@ -179,11 +179,6 @@ (define (fail2ban-jail-configuration-serialize-list-of-fail2ban-jail-actions fie (define (fail2ban-jail-configuration-serialize-symbol field-name value) (fail2ban-jail-configuration-serialize-string field-name (symbol->string value))) -(define (fail2ban-jail-configuration-serialize-extra-content field-name value) - (if (maybe-value-set? value) - (string-append "\n" value "\n") - "")) - (define-maybe integer (prefix fail2ban-jail-configuration-)) (define-maybe string (prefix fail2ban-jail-configuration-)) (define-maybe boolean (prefix fail2ban-jail-configuration-)) @@ -281,9 +276,9 @@ (define-configuration fail2ban-jail-configuration (list-of-fail2ban-jail-actions '()) "A list of @code{}.") (extra-content - maybe-string + (text-config '()) "Extra content for the jail configuration." - fail2ban-jail-configuration-serialize-extra-content) + serialize-text-config) (prefix fail2ban-jail-configuration-)) (define list-of-fail2ban-jail-configurations? @@ -312,7 +307,7 @@ (define-configuration/no-serialization fail2ban-configuration (list-of-fail2ban-jail-configurations '()) "Instances of @code{} explicitly provided.") (extra-content - maybe-string + (text-config '()) "Extra raw content to add to the end of the @file{jail.local} file.")) (define (serialize-fail2ban-configuration config) @@ -322,9 +317,7 @@ (define (serialize-fail2ban-configuration config) (interpose (append (map serialize-fail2ban-jail-configuration (append jails extra-jails)) - (list (if (maybe-value-set? extra-content) - extra-content - "")))))) + (list (serialize-text-config 'extra-content extra-content)))))) (define (config->fail2ban-etc-directory config) (let* ((fail2ban (fail2ban-configuration-fail2ban config))