Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
NTPsec
ntpsec
Compare Revisions
21a5b3b84c20d154f9863c3cd909f2e7a3d85279...695741ac4b8fd499b3b311d3a80183921bd569c5
Commits (3)
ImportError doesn't have a message attribute
· 824c0cfa
Matt Selsky
authored
Nov 14, 2016
824c0cfa
Remove unused imports
· c611e988
Matt Selsky
authored
Nov 14, 2016
c611e988
Python3: fix tabs/spacing, exception syntax
· 695741ac
Matt Selsky
authored
Nov 14, 2016
695741ac
Hide whitespace changes
Inline
Side-by-side
libntp/wscript
View file @
695741ac
import sys
def build(ctx):
srcnode = ctx.srcnode.abspath()
...
...
ntpq/ntpq
View file @
695741ac
...
...
@@ -21,7 +21,7 @@ try:
import
ntp.version
except
ImportError
as
e
:
sys
.
stderr
.
write
(
"ntpq: can't find Python NTP library -- check PYTHONPATH.
\n
"
)
sys
.
stderr
.
write
(
"%s
\n
"
%
e
.
message
)
sys
.
stderr
.
write
(
"%s
\n
"
%
e
)
sys
.
exit
(
1
)
# This import only works on Unixes. The intention is to enable
...
...
ntpstats/ntpviz
View file @
695741ac
...
...
@@ -45,7 +45,7 @@ try:
import ntp.util
except ImportError as e:
sys.stderr.write("ntpviz: can't find Python NTP library -- check PYTHONPATH.\n")
sys.stderr.write("%s\n" % e
.message
)
sys.stderr.write("%s\n" % e)
sys.exit(1)
# overload ArgumentParser
...
...
ntptrace/ntptrace
View file @
695741ac
...
...
@@ -14,7 +14,6 @@ from __future__ import print_function
import
getopt
import
re
import
socket
import
subprocess
import
sys
import
ntp.util
...
...
pylib/packet.py
View file @
695741ac
...
...
@@ -606,7 +606,7 @@ class ControlSession:
return
True
def
password
(
self
):
"Get a keyid and the password if we don't have one."
"Get a keyid and the password if we don't have one."
if
self
.
keyid
is
None
:
if
self
.
auth
is
None
:
try
:
...
...
@@ -693,7 +693,7 @@ class ControlSession:
raise
ControlException
(
SERR_NOKEY
)
else
:
pkt
.
extension
+=
mac
return
pkt
.
send
()
return
pkt
.
send
()
def
getresponse
(
self
,
opcode
,
associd
,
timeo
):
"Get a response expected to match a given opcode and associd."
...
...
@@ -979,9 +979,9 @@ class ControlSession:
def
mrulist
(
self
,
variables
=
None
,
rawhook
=
None
):
"Retrieve MRU list data"
nonce_uses
=
0
restarted_count
=
0
cap_frags
=
True
nonce_uses
=
0
restarted_count
=
0
cap_frags
=
True
warn
=
sys
.
stderr
.
write
sorter
=
None
if
variables
is
None
:
...
...
@@ -1063,20 +1063,20 @@ class ControlSession:
cap_frags
=
False
if
self
.
debug
:
warn
(
"Reverted to row limit from fragments limit.
\n
"
)
else
:
else
:
# ntpd has lower cap on row limit
self
.
ntpd_row_limit
-=
1
limit
=
min
(
limit
,
ntpd_row_limit
)
if
self
.
debug
:
warn
(
"Row limit reduced to %d following CERR_BADVALUE.
\n
"
%
limit
)
elif
e
.
errorcode
in
(
ERR_INCOMPLETE
,
ERR_TIMEOUT
):
# Reduce the number of rows/frags requested by
# half to recover from lost response fragments.
if
cap_frags
:
# Reduce the number of rows/frags requested by
# half to recover from lost response fragments.
if
cap_frags
:
frags
=
max
(
2
,
frags
/
2
)
if
self
.
debug
:
warn
(
"Frag limit reduced to %d following incomplete response.
\n
"
%
frags
)
else
:
else
:
limit
=
max
(
2
,
limit
/
2
)
if
self
.
debug
:
warn
(
"Row limit reduced to %d following incomplete response.
\n
"
%
limit
)
...
...
@@ -1124,15 +1124,15 @@ class ControlSession:
if
span
.
is_complete
():
break
# Snooze for a bit between queries to let ntpd catch
# up with other duties.
# Snooze for a bit between queries to let ntpd catch
# up with other duties.
time
.
sleep
(
0.05
)
# If there were no errors, increase the number of rows
# to a maximum of 3 * MAXFRAGS (the most packets ntpq
# can handle in one response), on the assumption that
# no less than 3 rows fit in each packet, capped at
# our best guess at the server's row limit.
# If there were no errors, increase the number of rows
# to a maximum of 3 * MAXFRAGS (the most packets ntpq
# can handle in one response), on the assumption that
# no less than 3 rows fit in each packet, capped at
# our best guess at the server's row limit.
if
not
recoverable_read_errors
:
if
cap_frags
:
frags
=
min
(
MAXFRAGS
,
frags
+
1
)
...
...
@@ -1142,14 +1142,14 @@ class ControlSession:
max
(
limit
+
1
,
limit
*
33
/
32
))
# prepare next query with as many address and last-seen
# timestamps as will fit in a single packet.
req_buf
=
"%s, %s=%d%s"
%
\
# prepare next query with as many address and last-seen
# timestamps as will fit in a single packet.
req_buf
=
"%s, %s=%d%s"
%
\
(
nonce
,
"frags"
if
cap_frags
else
"limit"
,
frags
if
cap_frags
else
limit
,
parms
)
nonce_uses
+=
1
nonce_uses
+=
1
if
nonce_uses
>=
4
:
nonce
=
self
.
fetch_nonce
()
nonce_uses
=
0
...
...
pylib/statfiles.py
View file @
695741ac
...
...
@@ -7,7 +7,7 @@ Requires GNUPLOT and liberation fonts installed.
#SPDX-License-Identifier: BSD-2-Clause
from
__future__
import
print_function
,
division
import
calendar
,
datetime
,
glob
,
gzip
,
os
,
socket
,
subprocess
,
sys
,
time
import
glob
,
gzip
,
os
,
socket
,
sys
,
time
class
NTPStats
:
"Gather statistics for a specified NTP site"
...
...
pylib/util.py
View file @
695741ac
...
...
@@ -5,7 +5,6 @@ from __future__ import print_function
import
socket
import
sys
import
subprocess
import
time
import
ntp.ntpc
import
re
...
...
@@ -39,8 +38,8 @@ def canonicalize_dns(hostname, family=socket.AF_UNSPEC):
(
hostname
,
portsuffix
)
=
portsplit
(
hostname
)
try
:
ai
=
socket
.
getaddrinfo
(
hostname
,
None
,
family
,
0
,
0
,
socket
.
AI_CANONNAME
)
except
socket
.
gaierror
as
(
s
,
_e
)
:
print
(
'getaddrinfo failed: %s'
%
s
,
file
=
sys
.
stderr
)
except
socket
.
gaierror
as
e
:
print
(
'getaddrinfo failed: %s'
%
e
,
file
=
sys
.
stderr
)
raise
SystemExit
(
1
)
(
family
,
socktype
,
proto
,
canonname
,
sockaddr
)
=
ai
[
0
]
try
:
...
...
wafhelpers/check_multicast.py
View file @
695741ac
import
sys
from
waflib.Logs
import
pprint
def
check_multicast
(
ctx
):
"Probe for IP multicast capability."
ctx
.
check_cc
(
...
...
wafhelpers/check_openssl.py
View file @
695741ac
from
waflib.Configure
import
conf
from
wafhelpers.util
import
msg
,
msg_setting
# Versions older than 0.9.7d were deemed incompatible in NTP Classic.
OPENSSL_FRAG
=
"""
%s
...
...
wafhelpers/check_pthread.py
View file @
695741ac
from
waflib.Logs
import
pprint
from
wafhelpers.tool
import
check_sanity
PTHREAD_FRAG
=
"""
...
...
wafhelpers/check_vsprintfm.py
View file @
695741ac
import
sys
from
waflib.Logs
import
pprint
# What we really want to do here is test to see if the following program
# compiles *and exits with 9 status*. Because we don't know how to check
# the return status we must settle for a simpler test.
...
...
wafhelpers/configure.py
View file @
695741ac
import
sys
,
os
,
platform
from
waflib.Configure
import
conf
from
wafhelpers.probes
import
*
from
wafhelpers.util
import
msg
,
msg_setting
,
parse_version
from
wafhelpers.util
import
msg
,
msg_setting
def
cmd_configure
(
ctx
,
config
):
srcnode
=
ctx
.
srcnode
.
abspath
()
...
...
wscript
View file @
695741ac
...
...
@@ -231,10 +231,10 @@ def build(ctx):
from waflib import Options
Options.options.no_tests = True
if ctx.cmd == "build":
if not "PYTHONPATH" in os.environ:
print("--- PYTHONPATH is not set, "
"loading the Python ntp library may be troublesome ---")
if ctx.cmd == "build":
if not "PYTHONPATH" in os.environ:
print("--- PYTHONPATH is not set, "
"loading the Python ntp library may be troublesome ---")
#
# Miscellaneous utility productions
...
...