diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2022-12-06 17:46:45 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2022-12-06 17:49:50 +0100 |
| commit | a420b4f34e7449319f6ec73301ffb932845b66d6 (patch) | |
| tree | b6cd10f34e9d096bf08e952288f2e5a61cad5f6d /gnu | |
| parent | a508b5c7785bcd040c5a9e890be71ccd97f198fb (diff) | |
services: fail2ban: Start server in the foreground.
Previously, we were passing '-b', thereby starting the server in the
background. Consequently the 'start' method could complete before the
server was ready to accept connections on its socket, leading to
non-deterministic test failures.
Reported by Mathieu Othacehe <othacehe@gnu.org>.
* gnu/services/security.scm (fail2ban-shepherd-service): Change
FAIL2BAN-ACTION to invoke 'fail2ban-client'.
Change 'start' method to use 'make-forkexec-constructor'; start the
server in the foreground with '-f' and pass '-x' to force execution of
the server, as done upstream in 'fail2ban.service.in'.
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/services/security.scm | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/gnu/services/security.scm b/gnu/services/security.scm index 2010f9143af..50111455fb2 100644 --- a/gnu/services/security.scm +++ b/gnu/services/security.scm | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2022 muradm <mail@muradm.net> | 2 | ;;; Copyright © 2022 muradm <mail@muradm.net> |
| 3 | ;;; Copyright © 2022 Ludovic Courtès <ludo@gnu.org> | ||
| 3 | ;;; | 4 | ;;; |
| 4 | ;;; This file is part of GNU Guix. | 5 | ;;; This file is part of GNU Guix. |
| 5 | ;;; | 6 | ;;; |
| @@ -351,25 +352,24 @@ provided as a list of file-like objects.")) | |||
| 351 | (match-record config <fail2ban-configuration> | 352 | (match-record config <fail2ban-configuration> |
| 352 | (fail2ban run-directory) | 353 | (fail2ban run-directory) |
| 353 | (let* ((fail2ban-server (file-append fail2ban "/bin/fail2ban-server")) | 354 | (let* ((fail2ban-server (file-append fail2ban "/bin/fail2ban-server")) |
| 355 | (fail2ban-client (file-append fail2ban "/bin/fail2ban-client")) | ||
| 354 | (pid-file (in-vicinity run-directory "fail2ban.pid")) | 356 | (pid-file (in-vicinity run-directory "fail2ban.pid")) |
| 355 | (socket-file (in-vicinity run-directory "fail2ban.sock")) | 357 | (socket-file (in-vicinity run-directory "fail2ban.sock")) |
| 356 | (config-dir (file-append (config->fail2ban-etc-directory config) | 358 | (config-dir (file-append (config->fail2ban-etc-directory config) |
| 357 | "/etc/fail2ban")) | 359 | "/etc/fail2ban")) |
| 358 | (fail2ban-action (lambda args | 360 | (fail2ban-action (lambda args |
| 359 | #~(invoke #$fail2ban-server | 361 | #~(invoke #$fail2ban-client #$@args)))) |
| 360 | "-c" #$config-dir | 362 | |
| 361 | "-p" #$pid-file | 363 | ;; TODO: Add 'reload' action (see 'fail2ban.service.in' in the source). |
| 362 | "-s" #$socket-file | ||
| 363 | "-b" | ||
| 364 | #$@args)))) | ||
| 365 | |||
| 366 | ;; TODO: Add 'reload' action. | ||
| 367 | (list (shepherd-service | 364 | (list (shepherd-service |
| 368 | (provision '(fail2ban)) | 365 | (provision '(fail2ban)) |
| 369 | (documentation "Run the fail2ban daemon.") | 366 | (documentation "Run the fail2ban daemon.") |
| 370 | (requirement '(user-processes)) | 367 | (requirement '(user-processes)) |
| 371 | (start #~(lambda () | 368 | (start #~(make-forkexec-constructor |
| 372 | #$(fail2ban-action "start"))) | 369 | (list #$fail2ban-server |
| 370 | "-c" #$config-dir "-s" #$socket-file | ||
| 371 | "-p" #$pid-file "-xf" "start") | ||
| 372 | #:pid-file #$pid-file)) | ||
| 373 | (stop #~(lambda (_) | 373 | (stop #~(lambda (_) |
| 374 | #$(fail2ban-action "stop") | 374 | #$(fail2ban-action "stop") |
| 375 | #f))))))) ;successfully stopped | 375 | #f))))))) ;successfully stopped |
