guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/11: services: ntp-service-type: Remove deprecated server as strings s


From: guix-commits
Subject: 03/11: services: ntp-service-type: Remove deprecated server as strings support.
Date: Fri, 7 Apr 2023 12:01:57 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit b92880d0118d3a89a879515f8d373d5dbd281cf9
Author: Bruno Victal <mirai@makinata.eu>
AuthorDate: Mon Feb 27 00:11:36 2023 +0000

    services: ntp-service-type: Remove deprecated server as strings support.
    
    * gnu/services/networking.scm (<ntp-configuration>)[servers]: Rename 
accessor to ntp-configuration-servers.
    (ntp-configuration-servers): Remove helper procedure.
    (ntp-shepherd-service): Remove helper procedure usage.
    * tests/networking.scm: Remove obsolete test.
    
    Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
 gnu/services/networking.scm | 59 ++++++++++++++++-----------------------------
 tests/networking.scm        | 11 ---------
 2 files changed, 21 insertions(+), 49 deletions(-)

diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 49f897d8cf..19c109d238 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -486,36 +486,19 @@ daemon is responsible for allocating IP addresses to its 
client.")))
   ntp-configuration?
   (ntp      ntp-configuration-ntp
             (default ntp))
-  (servers  %ntp-configuration-servers   ;list of <ntp-server> objects
+  (servers  ntp-configuration-servers     ;list of <ntp-server> objects
             (default %ntp-servers))
   (allow-large-adjustment? ntp-allow-large-adjustment?
                            (default #t))) ;as recommended in the ntpd manual
 
-(define (ntp-configuration-servers ntp-configuration)
-  ;; A wrapper to support the deprecated form of this field.
-  (let ((ntp-servers (%ntp-configuration-servers ntp-configuration)))
-    (match ntp-servers
-      (((? string?) (? string?) ...)
-       (format (current-error-port) "warning: Defining NTP servers as strings 
is \
-deprecated.  Please use <ntp-server> records instead.\n")
-       (map (lambda (addr)
-              (ntp-server
-               (type 'server)
-               (address addr)
-               (options '()))) ntp-servers))
-      ((($ <ntp-server>) ($ <ntp-server>) ...)
-       ntp-servers))))
-
 (define (ntp-shepherd-service config)
   (match-record config <ntp-configuration>
     (ntp servers allow-large-adjustment?)
-    (let ((servers (ntp-configuration-servers config)))
-      ;; TODO: Add authentication support.
-      (define config
-        (string-append "driftfile /var/run/ntpd/ntp.drift\n"
-                       (string-join (map ntp-server->string servers)
-                                    "\n")
-                       "
+    ;; TODO: Add authentication support.
+    (define config
+      (string-append "driftfile /var/run/ntpd/ntp.drift\n"
+                     (string-join (map ntp-server->string servers) "\n")
+                     "
 # Disable status queries as a workaround for CVE-2013-5211:
 # 
<http://support.ntp.org/bin/view/Main/SecurityNotice#DRDoS_Amplification_Attack_using>.
 restrict default kod nomodify notrap nopeer noquery limited
@@ -529,22 +512,22 @@ restrict -6 ::1
 # option by default, as documented in the 'ntp.conf' manual.
 restrict source notrap nomodify noquery\n"))
 
-      (define ntpd.conf
-        (plain-file "ntpd.conf" config))
+    (define ntpd.conf
+      (plain-file "ntpd.conf" config))
 
-      (list (shepherd-service
-             (provision '(ntpd))
-             (documentation "Run the Network Time Protocol (NTP) daemon.")
-             (requirement '(user-processes networking))
-             (actions (list (shepherd-configuration-action ntpd.conf)))
-             (start #~(make-forkexec-constructor
-                       (list (string-append #$ntp "/bin/ntpd") "-n"
-                             "-c" #$ntpd.conf "-u" "ntpd"
-                             #$@(if allow-large-adjustment?
-                                    '("-g")
-                                    '()))
-                       #:log-file "/var/log/ntpd.log"))
-             (stop #~(make-kill-destructor)))))))
+    (list (shepherd-service
+           (provision '(ntpd))
+           (documentation "Run the Network Time Protocol (NTP) daemon.")
+           (requirement '(user-processes networking))
+           (actions (list (shepherd-configuration-action ntpd.conf)))
+           (start #~(make-forkexec-constructor
+                     (list (string-append #$ntp "/bin/ntpd") "-n"
+                           "-c" #$ntpd.conf "-u" "ntpd"
+                           #$@(if allow-large-adjustment?
+                                  '("-g")
+                                  '()))
+                     #:log-file "/var/log/ntpd.log"))
+           (stop #~(make-kill-destructor))))))
 
 (define %ntp-accounts
   (list (user-account
diff --git a/tests/networking.scm b/tests/networking.scm
index f2421370d2..fbf8db7a02 100644
--- a/tests/networking.scm
+++ b/tests/networking.scm
@@ -43,17 +43,6 @@
   "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 '())))))))
-
 
 ;;;
 ;;; OpenNTPD



reply via email to

[Prev in Thread] Current Thread [Next in Thread]