aboutsummaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2019-09-07 12:37:37 +0900
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2019-09-08 23:15:32 +0900
commitccdfae388d61f2263a085a4ddac8cb2919d01531 (patch)
tree2482e978bf5a1d925c16367c03d1d8c21fcfd304 /gnu/services
parent2625abc6aa5df66a6503e906b7592691452954f5 (diff)
downloadguix-ccdfae388d61f2263a085a4ddac8cb2919d01531.tar.gz
guix-ccdfae388d61f2263a085a4ddac8cb2919d01531.zip
services: openntpd: Fix the config generation code.
This fixes issue #37318 (see: http://bugs.gnu.org/37318). * gnu/services/networking.scm (openntpd-configuration->string): Rewrite in order to make the "openntpd configuration generation sanity check" test pass.
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/networking.scm35
1 files changed, 23 insertions, 12 deletions
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 432f3a80ee..c775242f99 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -505,22 +505,33 @@ make an initial adjustment of more than 1,000 seconds."
(default #f))) ; upstream default
(define (openntpd-configuration->string config)
+
+ (define (quote-field? name)
+ (member name '("constraints from")))
+
(match-record config <openntpd-configuration>
(listen-on query-from sensor server servers constraint-from
constraints-from)
- (string-join
- (filter-map
- (lambda (field value)
- (string-join
- (map (cut string-append field <> "\n")
- value)))
- '("listen on " "query from " "sensor " "server " "servers "
- "constraint from ")
- (list listen-on query-from sensor server servers constraint-from))
- ;; The 'constraints from' field needs to be enclosed in double quotes.
+ (string-append
(string-join
- (map (cut string-append "constraints from \"" <> "\"\n")
- constraints-from)))))
+ (concatenate
+ (filter-map (lambda (field values)
+ (match values
+ (() #f) ;discard entry with filter-map
+ ((val ...) ;validate value type
+ (map (lambda (value)
+ (if (quote-field? field)
+ (format #f "~a \"~a\"" field value)
+ (format #f "~a ~a" field value)))
+ values))))
+ ;; The entry names.
+ '("listen on" "query from" "sensor" "server" "servers"
+ "constraint from" "constraints from")
+ ;; The corresponding entry values.
+ (list listen-on query-from sensor server servers
+ constraint-from constraints-from)))
+ "\n")
+ "\n"))) ;add a trailing newline
(define (openntpd-shepherd-service config)
(let ((openntpd (openntpd-configuration-openntpd config))