aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2019-10-30 17:46:17 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2019-10-30 18:15:54 -0400
commit97bc3cbea5fc281a299c03eaaa3be5baf21ea673 (patch)
tree3074bdada04bb70c776048ebaa4e31a0103fa512
parentd29d04c9e64c2421ed84022e0c140ead40e5fb58 (diff)
downloadpatches-97bc3cbea5fc281a299c03eaaa3be5baf21ea673.tar
patches-97bc3cbea5fc281a299c03eaaa3be5baf21ea673.tar.gz
services: ntp: Ensure no double quotes are output to config file.
* gnu/services/networking.scm (ntp-server->string): Use the textual representation of the values as printed by 'display' rather than 'write', to avoid inserting double quotes in the generated config. * tests/networking.scm (%ntp-server-sample): Add a comment and make one of the options a string, to exercise the fix. ("ntp-server->string"): Move the expected value to the first argument. ("ntp configuration servers deprecated form"): Likewise. ("openntpd generated config string ends with a newline"): Likewise.
-rw-r--r--gnu/services/networking.scm2
-rw-r--r--tests/networking.scm19
2 files changed, 11 insertions, 10 deletions
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 93d9b6a15e..841fbd741e 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -345,7 +345,7 @@ Protocol (DHCP) client, on all the non-loopback network interfaces."
(res '()))
(if (list? x)
(fold loop res x)
- (cons (format #f "~s" x) res)))))
+ (cons (format #f "~a" x) res)))))
(match ntp-server
(($ <ntp-server> type address options)
diff --git a/tests/networking.scm b/tests/networking.scm
index 439cca5ffc..c494a48067 100644
--- a/tests/networking.scm
+++ b/tests/networking.scm
@@ -36,22 +36,23 @@
(ntp-server
(type 'server)
(address "some.ntp.server.org")
- (options `(iburst (version 3) (maxpoll 16) prefer))))
+ ;; Using either strings or symbols for option names is accepted.
+ (options `("iburst" (version 3) (maxpoll 16) prefer))))
(test-equal "ntp-server->string"
- (ntp-server->string %ntp-server-sample)
- "server some.ntp.server.org iburst version 3 maxpoll 16 prefer")
+ "server some.ntp.server.org iburst version 3 maxpoll 16 prefer"
+ (ntp-server->string %ntp-server-sample))
(test-equal "ntp configuration servers deprecated form"
(ntp-configuration-servers
(ntp-configuration
+ (servers (list "example.pool.ntp.org"))))
+ (ntp-configuration-servers
+ (ntp-configuration
(servers (list (ntp-server
(type 'server)
(address "example.pool.ntp.org")
- (options '()))))))
- (ntp-configuration-servers
- (ntp-configuration
- (servers (list "example.pool.ntp.org")))))
+ (options '())))))))
;;;
@@ -106,8 +107,8 @@ the sanity check:\n~a~%" config)
#t))))
(test-equal "openntpd generated config string ends with a newline"
+ "\n"
(let ((config (openntpd-configuration->string %openntpd-conf-sample)))
- (string-take-right config 1))
- "\n")
+ (string-take-right config 1)))
(test-end "networking")