On Mon, Mar 21, 2022 at 07:24:54PM +0000, Adam Dinwoodie wrote:
> On Mon, Mar 21, 2022 at 05:57:10PM +0100, Michael Biebl wrote:
> > Control: reassign dhcpcd5
> > 
> > Am 21.03.22 um 17:39 schrieb Michael Biebl:
> > > 
> > > Am 21.03.22 um 17:36 schrieb Michael Biebl:
> > > 
> > > > Is that a result of /etc/dhcp/dhclient-exit-hooks.d/timesyncd ?
> > > > 
> > > > What happens if you remove that dhclient hook
> > > 
> > > 
> > > Actually, I think it might be
> > > dhcpcd5: /lib/dhcpcd/dhcpcd-hooks/64-timesyncd.conf
> > > 
> > > which triggers the service restart, i.e. it would be a dhcpcd5 issue.
> > 
> > Reassigning accordingly.
> > 
> > # cat /lib/dhcpcd/dhcpcd-hooks/64-timesyncd.conf
> > # vi: ft=sh
> > 
> > SERVERFILE_IPV4="/run/systemd/timesyncd.conf.d/01-dhcpcd.ipv4.$interface.conf"
> > SERVERFILE_IPV6="/run/systemd/timesyncd.conf.d/01-dhcpcd.ipv6.$interface.conf"
> > 
> > reload_config() {
> >     systemctl try-restart systemd-timesyncd.service || :
> > }
> 
> Fantastic, thank you!  I've confirmed that replacing that line with a
> simple `:` stops this behaviour.

And I think I've found the bug: the `add_servers` function in
60-ntp-common.conf attempts to work out if it needs to rebuild the
server file, and only actually rebuild and reload the configuration if
it's necessary.  But the test it uses doesn't work when there are no
configured NTP servers, such as because someone is using SNTP with
systemd-timesyncd and the default Debian time server.

I think the patch below should resolve this:

diff -ur old/60-ntp-common.conf new/60-ntp-common.conf
--- old/debian/hooks/60-ntp-common.conf 2022-03-21 19:49:03.518699860 +0000
+++ new/debian/hooks/60-ntp-common.conf 2022-03-21 19:51:32.216039388 +0000
@@ -3,6 +3,8 @@
 add_servers() {
        if [ -f "$SERVERFILE" ] && [ "$new_ntp_servers" = "$old_ntp_servers" ]; 
then
                return
+       elif [ ! -f "$SERVERFILE" ] && [ -z "$new_ntp_servers" ]; then
+               return
        fi
 
        rm -f "$SERVERFILE"

Reply via email to