From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:51008) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iT1cb-0005mL-8Z for guix-patches@gnu.org; Fri, 08 Nov 2019 05:36:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iT1ca-0000c5-0E for guix-patches@gnu.org; Fri, 08 Nov 2019 05:36:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35957) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iT1cZ-0000bs-TH for guix-patches@gnu.org; Fri, 08 Nov 2019 05:36:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iT1cZ-0007g9-PL for guix-patches@gnu.org; Fri, 08 Nov 2019 05:36:03 -0500 Subject: [bug#38122] [PATCH 010/197] services: ntp: Ensure no double quotes are output to config file. Resent-Message-ID: From: Hartmut Goebel Date: Fri, 8 Nov 2019 11:33:38 +0100 Message-Id: <20191108103434.8390-11-h.goebel@crazy-compilers.com> In-Reply-To: <20191108103434.8390-1-h.goebel@crazy-compilers.com> References: <20191108103434.8390-1-h.goebel@crazy-compilers.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 38122@debbugs.gnu.org Cc: Maxim Cournoyer From: Maxim Cournoyer * 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. --- gnu/services/networking.scm | 2 +- tests/networking.scm | 19 ++++++++++--------- 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 (($ 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") -- 2.21.0