diff options
author | Ludovic Courtès <ludo@gnu.org> | 2022-10-04 09:44:18 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-10-04 18:15:35 +0200 |
commit | f83622f17d21d684e431fe14731349b952411368 (patch) | |
tree | 289bc9768296268208cbacfe52db22de6c7e2ecd | |
parent | channels: Warn about missing introductions. (diff) | |
download | guix-f83622f17d21d684e431fe14731349b952411368.tar.gz guix-f83622f17d21d684e431fe14731349b952411368.tar.bz2 guix-f83622f17d21d684e431fe14731349b952411368.tar.xz |
services: anonip: Bail out when the input is not a FIFO.
* gnu/services/web.scm (anonip-shepherd-service)[start]: Accept zero
arguments. Define 'spawn'. Print a message and return #f when #$INPUT
does not denote a FIFO.
-rw-r--r-- | gnu/services/web.scm | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/gnu/services/web.scm b/gnu/services/web.scm index e347f5dbcc..e5ab1a1180 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm | |||
@@ -1438,32 +1438,40 @@ files.") | |||
1438 | (documentation | 1438 | (documentation |
1439 | "Anonimyze the given log file location with anonip.") | 1439 | "Anonimyze the given log file location with anonip.") |
1440 | (start | 1440 | (start |
1441 | #~(lambda _ | 1441 | #~(lambda () |
1442 | (unless (file-exists? #$input) | 1442 | (define (spawn) |
1443 | (mknod #$input 'fifo #o600 0)) | 1443 | (fork+exec-command |
1444 | (let ((pid | 1444 | (append |
1445 | (fork+exec-command | 1445 | (list #$(file-append (anonip-configuration-anonip config) |
1446 | (append | 1446 | "/bin/anonip") |
1447 | (list #$(file-append (anonip-configuration-anonip config) | 1447 | (string-append "--input=" #$input) |
1448 | "/bin/anonip") | 1448 | (string-append "--output=" #$output)) |
1449 | (string-append "--input=" #$input) | 1449 | (if #$(anonip-configuration-skip-private? config) |
1450 | (string-append "--output=" #$output)) | 1450 | '("--skip-private") (list)) |
1451 | (if #$(anonip-configuration-skip-private? config) | 1451 | '#$(optional anonip-configuration-column "--column") |
1452 | '("--skip-private") (list)) | 1452 | '#$(optional anonip-configuration-ipv4mask "--ipv4mask") |
1453 | '#$(optional anonip-configuration-column "--column") | 1453 | '#$(optional anonip-configuration-ipv6mask "--ipv6mask") |
1454 | '#$(optional anonip-configuration-ipv4mask "--ipv4mask") | 1454 | '#$(optional anonip-configuration-increment "--increment") |
1455 | '#$(optional anonip-configuration-ipv6mask "--ipv6mask") | 1455 | '#$(optional anonip-configuration-replacement |
1456 | '#$(optional anonip-configuration-increment "--increment") | 1456 | "--replacement") |
1457 | '#$(optional anonip-configuration-replacement | 1457 | '#$(optional anonip-configuration-delimiter "--delimiter") |
1458 | "--replacement") | 1458 | '#$(optional anonip-configuration-regex "--regex")) |
1459 | '#$(optional anonip-configuration-delimiter "--delimiter") | 1459 | ;; Run in a UTF-8 locale |
1460 | '#$(optional anonip-configuration-regex "--regex")) | 1460 | #:environment-variables |
1461 | ;; Run in a UTF-8 locale | 1461 | (list (string-append "GUIX_LOCPATH=" #$glibc-utf8-locales |
1462 | #:environment-variables | 1462 | "/lib/locale") |
1463 | (list (string-append "GUIX_LOCPATH=" #$glibc-utf8-locales | 1463 | "LC_ALL=en_US.utf8"))) |
1464 | "/lib/locale") | 1464 | |
1465 | "LC_ALL=en_US.utf8")))) | 1465 | (let ((stat (stat #$input #f))) |
1466 | pid))) | 1466 | (cond ((not stat) |
1467 | (mknod #$input 'fifo #o600 0) | ||
1468 | (spawn)) | ||
1469 | ((eq? 'fifo (stat:type stat)) | ||
1470 | (spawn)) | ||
1471 | (else | ||
1472 | (format #t "'~a' is not a FIFO; bailing out~%" | ||
1473 | #$input) | ||
1474 | #f))))) | ||
1467 | (stop #~(make-kill-destructor)))))) | 1475 | (stop #~(make-kill-destructor)))))) |
1468 | 1476 | ||
1469 | (define anonip-service-type | 1477 | (define anonip-service-type |