Package: htpdate
Version: 1.2.2-4
Severity: normal
X-Debbugs-Cc: [email protected]
The systemd service that comes with this package won't start because
htpdate writes the wrong PID to the PID file. The service is stuck
'activating' until it times out and kills the htpdate process.
When I run the following command:
systemctl start htpdate
I get the following in the log:
Aug 10 09:47:10 sirion systemd[1]: Starting HTTP based time synchronization
tool...
Aug 10 09:47:10 sirion htpdate[143803]: htpdate version 1.2.2 started
Aug 10 09:47:10 sirion systemd[1]: htpdate.service: New main PID 12732 does
not exist or is a zombie.
Aug 10 09:48:40 sirion systemd[1]: htpdate.service: start operation timed
out. Terminating.
Aug 10 09:48:40 sirion systemd[1]: htpdate.service: Failed with result
'timeout'.
Aug 10 09:48:40 sirion systemd[1]: Failed to start HTTP based time
synchronization tool.
To confirm that the wrong PID is written, I run the following commands
in another terminal after 'systemctl start htpdate' and before it
times out:
$ cat /run/htpdate.pid
12732
$ systemctl status htpdate
● htpdate.service - HTTP based time synchronization tool
Loaded: loaded (/lib/systemd/system/htpdate.service; enabled; vendor
preset: enabled)
Active: activating (start) since Tue 2021-08-10 09:47:10 CEST; 29s ago
Docs: man:htpdate
Process: 143799 ExecStart=/usr/sbin/htpdate $HTP_OPTIONS $HTP_PROXY -i
/run/htpdate.pid $HTP_SERVERS
Tasks: 1 (limit: 16609)
Memory: 216.0K
CPU: 21ms
CGroup: /system.slice/htpdate.service
└─143804 /usr/sbin/htpdate -D -s -i /run/htpdate.pid
www.pool.ntp.org www.ntp.br www.wikipedia.org
Aug 10 09:47:10 sirion systemd[1]: Starting HTTP based time synchronization
tool...
Aug 10 09:47:10 sirion htpdate[143803]: htpdate version 1.2.2 started
Aug 10 09:47:10 sirion systemd[1]: htpdate.service: New main PID 12732 does
not exist or is a zombie.
This shows that a htpdate process is running, but it has PID 143804
rather than 12732 as reported in the PID file. Once the activation
times out that process is killed and the PID file deleted.
I can work around this by editing the service file and changing
Type=forking
PIDFile=/run/htpdate.pid
to
Type=oneshot
RemainAfterExit=yes
ExecStopPost=/usr/bin/rm -f /run/htpdate.pid
This tells systemd to not track the PID, but just assume that htpdate
is always running successfully until the service is stopped, and then
delete the PID file so that htpdate won't object when it's started
next time. This is obviously not ideal since any problems will be
unreported.
-- System Information:
Debian Release: 11.0
APT prefers testing-security
APT policy: (500, 'testing-security'), (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.10.0-8-amd64 (SMP w/4 CPU threads)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8),
LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages htpdate depends on:
ii init-system-helpers 1.60
ii libc6 2.31-13
ii lsb-base 11.1.0
htpdate recommends no packages.
htpdate suggests no packages.
-- no debconf information