[pkg-ntp-maintainers] Bug#382311: grepping of ntp.conf gets refclocks, misses peers

sacrificial-spam-address at horizon.com sacrificial-spam-address at horizon.com
Thu Aug 10 07:51:10 UTC 2006


Package: ntpdate
Version: 4.2.2+dfsg-2.1

The relevant lines from my ntp.conf file:
peer 192.35.100.1 key 101 minpoll 4 iburst
server 127.127.29.0 minpoll 1 maxpoll 4 iburst

Result in ntpdate trying uselessly to sync up to 127.127.29.0
while failing to query the perfectly good server at 192.35.100.1.

It's not causing me any problems, but perhaps the script could
be made fractionally smarter.

Something like

sed -rne 's/^(server|peer) ([-_.[:alnum:]]+).*$/\2/p' /etc/ntp.conf | grep -v '^127\.127\.'

or even (allowing alternate whitespace and making the server name regexp
a bit stricter)

sed -rne 's/^(server|peer)[ \t]+([_[:alnum]][-_.[:alnum:]]*)[ \t].*$/\2/p' /etc/ntp.conf | grep -v '^127\.127\.'

Alternatively, perhaps if there are both "peer" and "server" lines,
peers should be given absolute precedence...

# Servers to check (Separate multiple servers with spaces.)
# This code will take the server list from /etc/ntp.conf, if that exists,
# so you only have to keep it in one place.

# Peers (if any) are most trusted, and preferred.
NTPSERVERS=$(sed -rne 's/^peer[ \t]([-_.[:alnum:]]+)[ \t].*$/\1/p' /etc/ntp.conf 2>/dev/null)
# Then any configured servers
if [ -z "$NTPSERVERS" ]; then
	NTPSERVERS=$(sed -rne 's/^server[ \t]([-_.[:alnum:]]+)[ \t].*$/\1/p' /etc/ntp.conf 2>/dev/null)
fi
# A good fallback list if /etc/ntp.conf is missing or unhelpful
if [ -z "$NTPSERVERS" ]; then
        NTPSERVERS="0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org"
fi




More information about the pkg-ntp-maintainers mailing list