Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 447118 - FEATURES=clean-logs can be dangerous
Summary: FEATURES=clean-logs can be dangerous
Status: UNCONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Enhancement/Feature Requests (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-13 14:54 UTC by Jimmy.Jazz
Modified: 2012-12-13 14:54 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jimmy.Jazz 2012-12-13 14:54:27 UTC
The feature clean-logs calls PORT_LOGDIR_CLEAN. In some circumstancies the program called can delete data on your disks regardless of your mount points.

If PORTDIR is set to a wrong pathname, the command 'find' will scan through all the mount points and delete files except summary.log*. If the user is portage, it harms only that user. That is not what is expected.

In my case, I had the wrong idea to set it to /var/tmp and mount filesystems like /usr/portage in order to boot strap gentoo, like that:

 $ portageq envvar PORT_LOGDIR
/var/tmp

 $ vi /usr/share/portage/config/make.globals
# Executed before emerge exit if FEATURES=c
PORT_LOGDIR_CLEAN="find \"\${PORT_LOGDIR}\" -type f ! -name \"summary.log*\" -mtime +7 -delete"

 $ mount  | grep bootstrap
/dev/mapper/vg1-portage on /var/tmp/bootstrap/usr/portage type ext4 (ro,relatime,errors=remount-ro,stripe=384,data=ordered)
/dev/mapper/sys-src on /var/tmp/bootstrap/usr/src/linux type ext4 (ro,relatime,errors=remount-ro,stripe=256,data=ordered)
tmpfs on /var/tmp/bootstrap/var/tmp type tmpfs (rw,noatime,size=6442336k)
tmpfs on /var/tmp/bootstrap/tmp type tmpfs (rw,noatime,size=6442336k)
proc on /var/tmp/bootstrap/proc type proc (rw,relatime)
sysfs on /var/tmp/bootstrap/sys type sysfs (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /var/tmp/bootstrap/dev type devtmpfs (rw,nosuid,relatime,size=5120k,nr_inodes=51200,mode=755)
none on /var/tmp/bootstrap/dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000)


After a succesful emerge I get
[...]
find: cannot delete `/var/tmp/bootstrap/usr/portage/games-fps/ut2004-da2/ut2004-da2-1.6_beta.ebuild': Read-only file system
find: cannot delete `/var/tmp/bootstrap/usr/portage/games-fps/ut2003-bonuspack-de/metadata.xml': Read-only file system
find: cannot delete `/var/tmp/bootstrap/usr/portage/games-fps/ut2003-bonuspack-de/ChangeLog': Read-only file system
find: cannot delete `/var/tmp/bootstrap/usr/portage/games-fps/ut2003-bonuspack-de/Manifest': Read-only file system
find: cannot delete `/var/tmp/bootstrap/usr/portage/games-fps/ut2003-bonuspack-de/ut2003-bonuspack-de-1.ebuild': Read-only file system
find: cannot delete `/var/tmp/bootstrap/usr/portage/scripts/bootstrap.sh': Read-only file system
find: cannot delete `/var/tmp/bootstrap/usr/portage/skel.metadata.xml': Read-only file system
 * PORT_LOGDIR_CLEAN command returned 1
 * See the make.conf(5) man page for PORT_LOGDIR_CLEAN usage instructions.
Hopefully, /usr/portage was read only ;)

My suggestion is to add one or more options to the 'find' command,
1. -mindepth 1 -maxdepth 1 to limit the deletes
2. -xdev to not descend directories on other filesystems
3. find ${PORT_LOGDIR}/{elog,ebuild,portage} for instance in case PORT_LOGDIR is wrong. Portage manages only an empty PORT_LOGDIR variable.