[pkg-ntp-maintainers] Bug#731976: Bug#731976: ntpdate: Please use flock(1) in /etc/network/if-up.d/ntpdate
Aurelien Jarno
aurelien at aurel32.net
Wed Sep 17 14:01:53 UTC 2014
control: tag -1 + patch
On Tue, Sep 16, 2014 at 10:07:46PM +0200, Aurelien Jarno wrote:
> control: severity -1 important
>
> On Wed, Dec 11, 2013 at 11:45:25PM +0100, Kurt Roeckx wrote:
> > On Wed, Dec 11, 2013 at 10:26:32PM +0100, Christoph Biedl wrote:
> > > Package: ntpdate
> > > Version: 1:4.2.6.p5+dfsg-2
> > > Severity: normal
> > > Tags: patch
> > >
> > > Dear Maintainer,
> > >
> > > the code in /etc/network/if-up.d/ntpdate tries to prevent parallel
> > > excution of ntpdate-debian by perusing the lockfile-progs package. If
> > > this is not installed - and it seldom is here -,
>
> With the switch to systemd by default, the problem appears at almost all
> boots, even with -u is not added to /etc/default/ntpdate.
>
> > You know there is a:
> > Recommends: lockfile-progs
>
> The problem now affects all users using systemd which is the default for
> Jessie. In that case a Recommends: is clearly not enough. I am therefore
> bumping the severity of this bug.
>
> > I didn't know about flock(1), will look in to it.
>
> I'll see if I can come with a patch.
Here is a possible patch. I set the timeout to 180 seconds, which is the
default value in lockfile-progs.
--- ntp-4.2.6.p5+dfsg/debian/ntpdate.if-up
+++ ntp-4.2.6.p5+dfsg/debian/ntpdate.if-up
@@ -33,17 +33,9 @@
LOCKFILE=/var/lock/ntpdate
# Avoid running more than one at a time
-if [ -x /usr/bin/lockfile-create ]; then
- lockfile-create $LOCKFILE
- lockfile-touch $LOCKFILE &
- LOCKTOUCHPID="$!"
-fi
-
-/usr/sbin/ntpdate-debian -s $OPTS 2>/dev/null || :
-
-if [ -x /usr/bin/lockfile-create ] ; then
- kill $LOCKTOUCHPID
- lockfile-remove $LOCKFILE
-fi
+(
+ flock -w 180 -x 9 || exit 1
+ /usr/sbin/ntpdate-debian -s $OPTS 2>/dev/null || :
+) 9>$LOCKFILE
) &
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien at aurel32.net http://www.aurel32.net
More information about the pkg-ntp-maintainers
mailing list