mlocate cron job doesn't respect its lockfile

Bug #731632 reported by Steve Atwell
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mlocate (Debian)
Fix Released
Unknown
mlocate (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: mlocate

The mlocate cron job (/etc/cron.daily/mlocate) doesn't always respect its lockfile. The cron job always removes the lockfile, even if it aborts because the lockfile already exists. The result is that every other concurrent invocation of /etc/cron.daily/mlocate will run updatedb.

The bug is pretty obvious. From /etc/cron.daily/mlocate:

-----
trap "rm -f $LOCKFILE" EXIT

if [ -e "$LOCKFILE" ]; then
    echo >&2 "Warning: $LOCKFILE present, not running updatedb."
    exit 1
else
    touch "$LOCKFILE"
fi
-----

The trap to remove the lockfile is turned on before checking for the existence of the lockfile. So even if the lockfile exists, we rm it on exit. Moving the trap inside the else block should fix it.

# lsb_release -rd
Description: Ubuntu 10.04 LTS
Release: 10.04

# apt-cache policy mlocate
mlocate:
  Installed: 0.22.2-1ubuntu1
  Candidate: 0.22.2-1ubuntu1

Changed in mlocate (Debian):
status: Unknown → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package mlocate - 0.26-1ubuntu1

---------------
mlocate (0.26-1ubuntu1) saucy; urgency=low

  * Resynchronise with Debian (locking fix closes LP: #731632). Remaining
    changes:
    - Add ecryptfs, fusesmb, and devtmpfs to PRUNEFS.
    - Add /home/.ecryptfs to PRUNEPATHS.

mlocate (0.26-1) unstable; urgency=low

  * New upstream release. Closes: #669368
    - Stops using PATH_MAX. Closes: #610209
  * The filesystem type for Lustre is lustre, not lustre_lite. Update
    updatedb.conf accordingly. Closes: #660781
  * Fix up locking in cron.daily. Closes: #611096
  * rm -rf /var/lib/mlocate on purge, don't just take out single files.
    Closes: #542616
 -- Colin Watson <email address hidden> Thu, 20 Jun 2013 15:03:51 +0100

Changed in mlocate (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.