[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#516755: tzdata: race condition when updating /etc/localtime

Package: tzdata
Version: 2009b-1
Severity: minor
Tags: patch
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch jaunty


The postinst updates /etc/localtime:

        # Update the timezone
        echo $AREA/$ZONE > /etc/timezone
        rm -f /etc/localtime && \
            cp -f /usr/share/zoneinfo/$AREA/$ZONE /etc/localtime

This has some minor problems:

 * If the cp fails for some reason, then you do not have any
   /etc/localtime at all.

 * There is a tiny race condition between the rm and the cp, which
   can lead to log files showing wrong timestamps.

I propose to use something atomic and more robust, such as:

        # Update the timezone
        echo $AREA/$ZONE > /etc/timezone
        cp -f /usr/share/zoneinfo/$AREA/$ZONE /etc/localtime.dpkg-new && \
	    mv -f /etc/localtime.dpkg-new /etc/localtime

Thank you for considering!

Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

Attachment: signature.asc
Description: Digital signature

Reply to: