summary refs log tree commit diff
path: root/gnu
diff options
context:
space:
mode:
authormuradm <mail@muradm.net>2022-09-04 14:24:42 +0300
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-09-14 11:29:11 -0400
commit29d52a56f2d254781b65dbec0f1009db0b9d06e6 (patch)
tree85ef2670603a35a6cfe23841fb995008ba4457c4 /gnu
parent0336372296e676f97799d6a3a1e9cf209f14c6bc (diff)
downloadguix-29d52a56f2d254781b65dbec0f1009db0b9d06e6.tar.gz
gnu: fail2ban-service-type: Improve extra-content fields.
* 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.

Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Diffstat (limited to 'gnu')
-rw-r--r--gnu/services/security.scm25
1 files changed, 10 insertions, 15 deletions
diff --git a/gnu/services/security.scm b/gnu/services/security.scm
index fd5bf19730..15fae7a628 100644
--- a/gnu/services/security.scm
+++ b/gnu/services/security.scm
@@ -179,11 +179,6 @@
 (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-))
@@ -204,7 +199,7 @@
    "Backend to use to detect changes in the @code{log-path}.  The default is
 'auto.  To consult the defaults of the jail configuration, refer to the
 @file{/etc/fail2ban/jail.conf} file of the @code{fail2ban} package."
-fail2ban-jail-configuration-serialize-backend)
+   fail2ban-jail-configuration-serialize-backend)
   (max-retry
    maybe-integer
    "The number of failures before a host get banned
@@ -273,7 +268,7 @@ names matching their filter name.")
    maybe-symbol
    "The encoding of the log files handled by the jail.
 Possible values are: @code{'ascii}, @code{'utf-8} and @code{'auto}."
-fail2ban-jail-configuration-serialize-log-encoding)
+   fail2ban-jail-configuration-serialize-log-encoding)
   (log-path
    (list-of-strings '())
    "The file names of the log files to be monitored.")
@@ -281,9 +276,10 @@ fail2ban-jail-configuration-serialize-log-encoding)
    (list-of-fail2ban-jail-actions '())
    "A list of @code{<fail2ban-jail-action-configuration>}.")
   (extra-content
-   maybe-string
-   "Extra content for the jail configuration."
-   fail2ban-jail-configuration-serialize-extra-content)
+   (text-config '())
+   "Extra content for the jail configuration, provided as a list of file-like
+objects."
+   serialize-text-config)
   (prefix fail2ban-jail-configuration-))
 
 (define list-of-fail2ban-jail-configurations?
@@ -312,8 +308,9 @@ extensions.")
    (list-of-fail2ban-jail-configurations '())
    "Instances of @code{<fail2ban-jail-configuration>} explicitly provided.")
   (extra-content
-   maybe-string
-   "Extra raw content to add to the end of the @file{jail.local} file."))
+   (text-config '())
+   "Extra raw content to add to the end of the @file{jail.local} file,
+provided as a list of file-like objects."))
 
 (define (serialize-fail2ban-configuration config)
   (let* ((jails (fail2ban-configuration-jails config))
@@ -322,9 +319,7 @@ extensions.")
     (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))