[Git][NTPsec/ntpsec][master] In ntpq, fix clockvar command and improve server error reporting.

Eric S. Raymond gitlab at mg.gitlab.com
Tue Nov 8 04:04:15 UTC 2016


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


Commits:
38b1d05e by Eric S. Raymond at 2016-11-07T23:02:46-05:00
In ntpq, fix clockvar command and improve server error reporting.

- - - - -


2 changed files:

- ntpq/ntpq
- pylib/packet.py


Changes:

=====================================
ntpq/ntpq
=====================================
--- a/ntpq/ntpq
+++ b/ntpq/ntpq
@@ -1032,7 +1032,7 @@ usage: mrv assocIDlow assocIDhigh [ name=value[,...] ]
         assoc = self.__assoc_valid(line)
         if assoc >= 0:
             self.__dolist(self.uservars.keys(),
-                          assoc, CTL_OP_READVAR, TYPE_CLOCK)
+                          assoc, CTL_OP_READCLOCK, TYPE_CLOCK)
 
     def help_clocklist(self):
         self.say("""\


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -256,7 +256,7 @@ SERR_NOKEY = "***Key not found"
 SERR_BADNONCE = "***Unexpected nonce response format"
 SERR_BADPARAM = "***Unknown parameter '%s'"
 SERR_NOCRED = "***No credentials"
-SERR_SERVER = "***Server error code %d"
+SERR_SERVER = "***Server error code %s"
 SERR_STALL = "***No response, probably high-traffic server with low MRU limit"
 SERR_BADTAG = "***Bad MRU tag %s"
 SERR_BADSORT = "***Sort order %s is not implemented"
@@ -318,6 +318,16 @@ class Mode6Exception(BaseException):
 class Mode6Session:
     "A session to a host"
     MRU_ROW_LIMIT	= 256
+    server_errors = {
+        CERR_UNSPEC: "UNSPEC",
+        CERR_PERMISSION: "PERMISSION",
+        CERR_BADFMT: "BADFMT",
+        CERR_BADOP: "BADOP",
+        CERR_BADASSOC: "BADASSOC",
+        CERR_UNKNOWNVAR: "UNKNOWNVAR",
+        CERR_BADVALUE: "BADVALUE",
+        CERR_RESTRICT: "RESTRICT",
+        }
 
     def __init__(self):
         self.debug = 0
@@ -610,7 +620,8 @@ class Mode6Session:
                     warn("Error %d received on non-final packet\n" %
                          rpkt.errcode())
                 self.keyid = self.passwd = None
-                raise Mode6Exception(SERR_SERVER % rpkt.errcode(), rpkt.errcode())
+                raise Mode6Exception(SERR_SERVER % Mode6Session.server_errors[rpkt.errcode()],
+                                     rpkt.errcode())
 
             # Check the association ID to make sure it matches what we expect
             if rpkt.associd != associd:



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/38b1d05eb71604a303a84077a588ac77b93266ba
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161108/08b487c9/attachment.html>


More information about the vc mailing list