mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-11 13:49:23 -05:00
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.
This commit is contained in:
parent
5bc4b8e8e3
commit
f83622f17d
1 changed files with 34 additions and 26 deletions
|
@ -1438,32 +1438,40 @@ (define (anonip-shepherd-service config)
|
||||||
(documentation
|
(documentation
|
||||||
"Anonimyze the given log file location with anonip.")
|
"Anonimyze the given log file location with anonip.")
|
||||||
(start
|
(start
|
||||||
#~(lambda _
|
#~(lambda ()
|
||||||
(unless (file-exists? #$input)
|
(define (spawn)
|
||||||
(mknod #$input 'fifo #o600 0))
|
(fork+exec-command
|
||||||
(let ((pid
|
(append
|
||||||
(fork+exec-command
|
(list #$(file-append (anonip-configuration-anonip config)
|
||||||
(append
|
"/bin/anonip")
|
||||||
(list #$(file-append (anonip-configuration-anonip config)
|
(string-append "--input=" #$input)
|
||||||
"/bin/anonip")
|
(string-append "--output=" #$output))
|
||||||
(string-append "--input=" #$input)
|
(if #$(anonip-configuration-skip-private? config)
|
||||||
(string-append "--output=" #$output))
|
'("--skip-private") (list))
|
||||||
(if #$(anonip-configuration-skip-private? config)
|
'#$(optional anonip-configuration-column "--column")
|
||||||
'("--skip-private") (list))
|
'#$(optional anonip-configuration-ipv4mask "--ipv4mask")
|
||||||
'#$(optional anonip-configuration-column "--column")
|
'#$(optional anonip-configuration-ipv6mask "--ipv6mask")
|
||||||
'#$(optional anonip-configuration-ipv4mask "--ipv4mask")
|
'#$(optional anonip-configuration-increment "--increment")
|
||||||
'#$(optional anonip-configuration-ipv6mask "--ipv6mask")
|
'#$(optional anonip-configuration-replacement
|
||||||
'#$(optional anonip-configuration-increment "--increment")
|
"--replacement")
|
||||||
'#$(optional anonip-configuration-replacement
|
'#$(optional anonip-configuration-delimiter "--delimiter")
|
||||||
"--replacement")
|
'#$(optional anonip-configuration-regex "--regex"))
|
||||||
'#$(optional anonip-configuration-delimiter "--delimiter")
|
;; Run in a UTF-8 locale
|
||||||
'#$(optional anonip-configuration-regex "--regex"))
|
#:environment-variables
|
||||||
;; Run in a UTF-8 locale
|
(list (string-append "GUIX_LOCPATH=" #$glibc-utf8-locales
|
||||||
#:environment-variables
|
"/lib/locale")
|
||||||
(list (string-append "GUIX_LOCPATH=" #$glibc-utf8-locales
|
"LC_ALL=en_US.utf8")))
|
||||||
"/lib/locale")
|
|
||||||
"LC_ALL=en_US.utf8"))))
|
(let ((stat (stat #$input #f)))
|
||||||
pid)))
|
(cond ((not stat)
|
||||||
|
(mknod #$input 'fifo #o600 0)
|
||||||
|
(spawn))
|
||||||
|
((eq? 'fifo (stat:type stat))
|
||||||
|
(spawn))
|
||||||
|
(else
|
||||||
|
(format #t "'~a' is not a FIFO; bailing out~%"
|
||||||
|
#$input)
|
||||||
|
#f)))))
|
||||||
(stop #~(make-kill-destructor))))))
|
(stop #~(make-kill-destructor))))))
|
||||||
|
|
||||||
(define anonip-service-type
|
(define anonip-service-type
|
||||||
|
|
Loading…
Reference in a new issue