diff options
| author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2019-10-30 17:46:17 -0400 |
|---|---|---|
| committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2019-10-30 18:15:54 -0400 |
| commit | 97bc3cbea5fc281a299c03eaaa3be5baf21ea673 (patch) | |
| tree | 3074bdada04bb70c776048ebaa4e31a0103fa512 | |
| parent | d29d04c9e64c2421ed84022e0c140ead40e5fb58 (diff) | |
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.scm | 2 | ||||
| -rw-r--r-- | tests/networking.scm | 19 |
2 files changed, 11 insertions, 10 deletions
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 93d9b6a15e4..841fbd741e7 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." | |||
| 345 | (res '())) | 345 | (res '())) |
| 346 | (if (list? x) | 346 | (if (list? x) |
| 347 | (fold loop res x) | 347 | (fold loop res x) |
| 348 | (cons (format #f "~s" x) res))))) | 348 | (cons (format #f "~a" x) res))))) |
| 349 | 349 | ||
| 350 | (match ntp-server | 350 | (match ntp-server |
| 351 | (($ <ntp-server> type address options) | 351 | (($ <ntp-server> type address options) |
diff --git a/tests/networking.scm b/tests/networking.scm index 439cca5ffc9..c494a480676 100644 --- a/tests/networking.scm +++ b/tests/networking.scm | |||
| @@ -36,22 +36,23 @@ | |||
| 36 | (ntp-server | 36 | (ntp-server |
| 37 | (type 'server) | 37 | (type 'server) |
| 38 | (address "some.ntp.server.org") | 38 | (address "some.ntp.server.org") |
| 39 | (options `(iburst (version 3) (maxpoll 16) prefer)))) | 39 | ;; Using either strings or symbols for option names is accepted. |
| 40 | (options `("iburst" (version 3) (maxpoll 16) prefer)))) | ||
| 40 | 41 | ||
| 41 | (test-equal "ntp-server->string" | 42 | (test-equal "ntp-server->string" |
| 42 | (ntp-server->string %ntp-server-sample) | 43 | "server some.ntp.server.org iburst version 3 maxpoll 16 prefer" |
| 43 | "server some.ntp.server.org iburst version 3 maxpoll 16 prefer") | 44 | (ntp-server->string %ntp-server-sample)) |
| 44 | 45 | ||
| 45 | (test-equal "ntp configuration servers deprecated form" | 46 | (test-equal "ntp configuration servers deprecated form" |
| 46 | (ntp-configuration-servers | 47 | (ntp-configuration-servers |
| 47 | (ntp-configuration | 48 | (ntp-configuration |
| 49 | (servers (list "example.pool.ntp.org")))) | ||
| 50 | (ntp-configuration-servers | ||
| 51 | (ntp-configuration | ||
| 48 | (servers (list (ntp-server | 52 | (servers (list (ntp-server |
| 49 | (type 'server) | 53 | (type 'server) |
| 50 | (address "example.pool.ntp.org") | 54 | (address "example.pool.ntp.org") |
| 51 | (options '())))))) | 55 | (options '()))))))) |
| 52 | (ntp-configuration-servers | ||
| 53 | (ntp-configuration | ||
| 54 | (servers (list "example.pool.ntp.org"))))) | ||
| 55 | 56 | ||
| 56 | 57 | ||
| 57 | ;;; | 58 | ;;; |
| @@ -106,8 +107,8 @@ the sanity check:\n~a~%" config) | |||
| 106 | #t)))) | 107 | #t)))) |
| 107 | 108 | ||
| 108 | (test-equal "openntpd generated config string ends with a newline" | 109 | (test-equal "openntpd generated config string ends with a newline" |
| 110 | "\n" | ||
| 109 | (let ((config (openntpd-configuration->string %openntpd-conf-sample))) | 111 | (let ((config (openntpd-configuration->string %openntpd-conf-sample))) |
| 110 | (string-take-right config 1)) | 112 | (string-take-right config 1))) |
| 111 | "\n") | ||
| 112 | 113 | ||
| 113 | (test-end "networking") | 114 | (test-end "networking") |
