[Git][NTPsec/ntpsec][master] Cope better with invalid addresses passed to ntpq.

Eric S. Raymond gitlab at mg.gitlab.com
Fri Dec 2 01:30:46 UTC 2016


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


Commits:
31f0296a by Eric S. Raymond at 2016-12-01T20:29:57-05:00
Cope better with invalid addresses passed to ntpq.

- - - - -


2 changed files:

- ntpq/ntpq
- pylib/packet.py


Changes:

=====================================
ntpq/ntpq
=====================================
--- a/ntpq/ntpq
+++ b/ntpq/ntpq
@@ -1643,6 +1643,8 @@ if __name__ == '__main__':
         raise SystemExit(0)
     except KeyboardInterrupt:
         interpreter.say("\n")
+    except ntp.packet.ControlException as e:
+        interpreter.warn(e.message + "\n")
     except IOError:
         print("Bailing out...")
 # end


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -792,14 +792,14 @@ class ControlSession:
         self.port = sockaddr[1]
         try:
             self.sock = socket.socket(family, socktype, protocol)
-        except socket.error as msg:
-            sys.stderr.write(msg)
-            return False
+        except socket.error as (errno, msg):
+            raise ControlException("Error opening %s: %s [%d]" \
+                                   % (hname, msg, errno))
         try:
             self.sock.connect(sockaddr)
-        except socket.error as msg:
-            sys.stderr.write(msg)
-            return False
+        except socket.error as (errno, msg):            
+            raise ControlException("Error connecting to %s: %s [%d]" \
+                                   % (hname, msg, errno))
         return True
 
     def password(self):



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/31f0296a0c0b1de4ac20c7fcf134f1ecd4ead0fe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161202/76544851/attachment.html>


More information about the vc mailing list