[Git][NTPsec/ntpsec][master] 3 commits: Accept hex literals in Mode 6 responses.

Eric S. Raymond gitlab at mg.gitlab.com
Sat Oct 22 05:16:24 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
ab1f3a0d by Eric S. Raymond at 2016-10-22T01:15:33-04:00
Accept hex literals in Mode 6 responses.

- - - - -
0f519906 by Eric S. Raymond at 2016-10-22T01:15:33-04:00
Add pyntpq code to validate association IDs and indices.

- - - - -
b6f3094e by Eric S. Raymond at 2016-10-22T01:15:33-04:00
Address Gitlab issue #128: git head fails on debian 7 x86_64

- - - - -


4 changed files:

- ntpfrob/wscript
- ntpkeygen/wscript
- ntpq/pyntpq
- pylib/packet.py


Changes:

=====================================
ntpfrob/wscript
=====================================
--- a/ntpfrob/wscript
+++ b/ntpfrob/wscript
@@ -14,6 +14,7 @@ def build(ctx):
 		includes	= [
 					"%s/ntpfrob/" % bldnode
 				],
+		use		= "M RT",
 		install_path = "${PREFIX}/bin/"
 	)
 


=====================================
ntpkeygen/wscript
=====================================
--- a/ntpkeygen/wscript
+++ b/ntpkeygen/wscript
@@ -17,7 +17,7 @@ def build(ctx):
 			"%s/libsodium/include/" % srcnode
 		],
 		# clock_gettime needs -lrt for glibc versions before 2.17
-		use		= "ntp isc sodium M CRYPTO",
+		use		= "ntp isc sodium RT M CRYPTO",
 		install_path= "${PREFIX}/bin/"
 	)
 


=====================================
ntpq/pyntpq
=====================================
--- a/ntpq/pyntpq
+++ b/ntpq/pyntpq
@@ -15,6 +15,7 @@ import os, sys, getopt, cmd, errno, curses, curses.ascii
 import socket, select, struct, shlex
 
 from ntp.packet import *
+from ntp.util import *
 from ntp.libntpc import *
 
 # This import only works on Unixes.  The intention is to enable
@@ -415,6 +416,37 @@ usage: help [ command ]
             if not self.__dogetpeers(varlist[1:], peer.associd, af):
                 return
 
+    def assoc_valid(self, line, required=False):
+        "Process a numeric associd or index."
+        if not line:
+            if required:
+                sys.stderr.write("An associd argument is required.\n")
+                return -1
+            else:
+                return 0
+        elif associd.startswith("&"):
+            try:
+                idx = int(line[1:])
+            except:
+                sys.stderr.write("Invalid index literal.\n")
+                return -1
+            if idx not in range(1, len(self.peers)+1):
+                sys.stderr.write("No such index.\n")
+                return -1
+            else:
+                return self.peers[idx - 1].associd
+        else:
+            try:
+                associd = int(line)
+            except:
+                sys.stderr.write("Invalid associd literal.\n")
+                return -1
+            if associd not in [peer.associd for peer in self.peers]:
+                sys.stderr.write("Unknown associd.\n")
+                return -1
+            else:
+                return associd
+
     # Unexposed helper tables and functions end here
 
     def do_EOF(self, _unused):
@@ -947,12 +979,10 @@ usage: cv [ assocID ] [ name=value[,...] ]
             ("selbroken",	"bad reference time:  ", NTP_STR),
             ("candidate",	"candidate order:     ", NTP_STR),
         )
-        associd=int(line)
-        if associd not in [peer.associd for peer in self.peers]:
-            sys.stderr.write("Unknown associd.\n")
-            return
-	self.collect_display(associd=associd,
-                             variables=pstats, decodestatus=True)
+        associd = self.assoc_valid(line)
+        if associd >= 0:
+            self.collect_display(associd=associd,
+                                 variables=pstats, decodestatus=True)
 
     def help_pstats(self):
         sys.stdout.write("""\


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -622,7 +622,7 @@ class Mode6Session:
                 var = var.strip()
                 val = val.strip()
                 try:
-                    val = int(val)
+                    val = int(val, 0)
                 except ValueError:
                     try:
                         val = float(val)



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/ff669dcd5ee45874c5e71815ff8ca9b413f5dd75...b6f3094e73748f3a6982e71ff8c0575b37e32e06
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161022/94b2aef9/attachment.html>


More information about the vc mailing list