[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
08/08: services: openntpd: Fix the config generation code.
From: |
guix-commits |
Subject: |
08/08: services: openntpd: Fix the config generation code. |
Date: |
Sun, 8 Sep 2019 10:17:05 -0400 (EDT) |
apteryx pushed a commit to branch master
in repository guix.
commit ccdfae388d61f2263a085a4ddac8cb2919d01531
Author: Maxim Cournoyer <address@hidden>
Date: Sat Sep 7 12:37:37 2019 +0900
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.
---
gnu/services/networking.scm | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 432f3a8..c775242 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))
- branch master updated (861b9a3 -> ccdfae3), guix-commits, 2019/09/08
- 01/08: services: ntp: Allow large adjustment by default., guix-commits, 2019/09/08
- 02/08: services: ntp: Fix KOD warning., guix-commits, 2019/09/08
- 08/08: services: openntpd: Fix the config generation code.,
guix-commits <=
- 03/08: doc: Add index to find 'ntpd'., guix-commits, 2019/09/08
- 06/08: services: openntpd: Remove useless let., guix-commits, 2019/09/08
- 04/08: services: ntp: Support different NTP server types and options., guix-commits, 2019/09/08
- 07/08: services: openntpd: Add test for issue #3731., guix-commits, 2019/09/08
- 05/08: gnu: openntpd: Fix error CA errors when using constraints., guix-commits, 2019/09/08