Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 171117 - Emerge changes timestamp on the main file when writing config protect version. Breaks backups
Summary: Emerge changes timestamp on the main file when writing config protect version...
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All All
: High major (vote)
Assignee: Portage team
Keywords: InVCS
Depends on:
Blocks: 172589
  Show dependency tree
Reported: 2007-03-16 03:39 UTC by Ben Bennett
Modified: 2007-03-29 22:36 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Ben Bennett 2007-03-16 03:39:36 UTC
If you emerge a package and it needs to write to a config protected directory it correctly makes a ._cfg... version of the file.  However, it also updates the time stamp (mtime in particular) of the source file.  So when you have finished the emerge you have a pair of files with the same timestamp (e.g. /etc/hosts and /etc/._cfg0000_hosts).

The problem arises if a backup occurs between the time the emerge creates those files and when you update the conf files.  If you accept the new version of the file then it is moved on top of the original... the contents have changed, but the mtime timestamp is preserved.  The next time the backup runs it does not see the change.

Reproducible: Sometimes

Steps to Reproduce:
1. Run an emerge that makes a ._cfg... file somewhere
2. Look at the new config mtime and the old config mtime (with stat)
3. Run dispatch-conf
4. Accept the new version of the file without edits
5. Look at the mtime on the final file (with stat)

Actual Results:  
The mtimes on the both files from step 2 and the resulting file in step 5 are extremely likely to be the same.  There is a slim chance they may not be if more than a second manages to pass between two calls to utime in the code, but on my machine it is always reproducible.

Expected Results:  
Different mtimes, at least between steps 2 and 5.

Portage version: sys-apps/portage-
Architecture: AMD X86  (32 bit)
Backup software: app-backup/boxbackup-0.10
I use dispatch-conf to do the config merging

The error seems to be around line 7190 of /usr/lib/portage/pym/ (rev 5647) in the isprotected() subroutine.  The problem is that it does a utime on the original file, passing in None as the timestamp to update it to the current system time.  If it is still the same second that the outer code got its timestamp for the thismtime argument to mergeme (set into the mymtime variable on line 7424) then it will end up with the same value.

A possible fix would be to set mymtime to 1 second before the current time thus ensuring that a collision is impossible.

The above bug still exists in the current SVN code, but the affected file seems to now be pym/portage/dbapi/
Comment 1 Zac Medico gentoo-dev 2007-03-16 18:14:00 UTC
Thanks, this is fixed in svn r6216.
Comment 2 Zac Medico gentoo-dev 2007-03-29 22:36:27 UTC
This has been released in