On 05/11/2018 02:56 AM, Julien Goodwin wrote: > Please either add a method to disable the entire hook (I'd prefer this > to avoid additional service restarts), or at least add a variable to > /etc/default/ntp that will cause /run/ntp.conf.dhcp to not be used.
For the ntp package, there's a similar long-standing bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560046 with this patch: https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=560046;filename=ntp.diff;msg=5 We definitely need to avoid using the config file if it exists, or else a reboot to clear /run, or a manual deletion of /run/ntp.conf.dhcp, would be necessary for the IGNORE_DHCP=yes change to take effect. You make a good point about spurious restarts, which are especially harmful to ntpd. How do you feel about the following patch (untested): diff --git a/debian/ntp-systemd-wrapper b/debian/ntp-systemd-wrapper index 8ff43db..c72088e 100755 --- a/debian/ntp-systemd-wrapper +++ b/debian/ntp-systemd-wrapper @@ -8,7 +8,7 @@ if [ -r /etc/default/ntp ]; then . /etc/default/ntp fi -if [ -e /run/ntp.conf.dhcp ]; then +if [ "$IGNORE_DHCP" != "yes" ] && [ -e /run/ntp.conf.dhcp ]; then NTPD_OPTS="$NTPD_OPTS -c /run/ntp.conf.dhcp" fi diff --git a/debian/ntp.dhcp b/debian/ntp.dhcp index eedf6d9..7ca0927 100644 --- a/debian/ntp.dhcp +++ b/debian/ntp.dhcp @@ -3,7 +3,13 @@ NTP_DHCP_CONF=/run/ntp.conf.dhcp ntp_server_restart() { - invoke-rc.d ntp try-restart + if [ -r /etc/default/ntp ]; then + . /etc/default/ntp + fi + + if [ "$IGNORE_DHCP" != "yes" ]; then + invoke-rc.d ntp try-restart + fi } diff --git a/debian/ntpsec.ntp.default b/debian/ntpsec.ntp.default index 53a4505..a488c7f 100644 --- a/debian/ntpsec.ntp.default +++ b/debian/ntpsec.ntp.default @@ -1 +1,4 @@ NTPD_OPTS='-g -N' + +# Set to 'yes' to ignore DHCP servers returned by DHCP. +IGNORE_DHCP='' diff --git a/debian/ntpsec.ntp.init b/debian/ntpsec.ntp.init index 2481b28..b2c29f4 100644 --- a/debian/ntpsec.ntp.init +++ b/debian/ntpsec.ntp.init @@ -27,7 +27,7 @@ if [ -r /etc/default/ntp ]; then . /etc/default/ntp fi -if [ -e /run/ntp.conf.dhcp ]; then +if [ "$IGNORE_DHCP" != "yes" ] && [ -e /run/ntp.conf.dhcp ]; then NTPD_OPTS="$NTPD_OPTS -c /run/ntp.conf.dhcp" fi -- Richard

