Re: May packages rm -rf subdirectories of /etc/ ?
On Mon, Jul 21, 2003 at 07:06:17AM +0200, Thomas Hood wrote:
> Recently I purged a package foo which had a configuration directory
> /etc/foo/. The package contained a number of conffiles in /etc/foo/ .
> I backed up some of these before the purge by copying them to other
> names, but leaving them in /etc/foo/ . To my surprise, the package
> postrm did a "rm -rf" on the whole /etc/foo/ directory, thus
> deleting my backups.
> Looking at the postrms of other packages I have installed, I see that
> a handful of them do likewise.
> Now, on one hand I can see that given the current state of Debian's
> packaging tools, removing an entire directory can be the convenient
> thing to do. If a package maintains a bunch of configuration files
> (not conffiles -- dpkg knows how to delete those) in the directory
> then "rm -rf" is sure to remove them all.
> However, "rm -rf" is always a dangerous command to use. Configuration
> directories are often shared; add-on packages may store things in the
> configuration directories of the packages to which they add things on,
> especially if the latter uses run-parts to run hook scripts. Sometimes
> one package Replaces another and hijacks the latter's configuration
> files; but these will be improperly deleted if the admin later purges
> the original package. And admins may store things in /etc/
> subdirectories. I think it would be better if packages removed only
> files that they have created.
> One may want to treat /etc/foo/ differently from, e.g., /var/lib/foo/ .
> I would never store anything additional in /var/lib/foo/ because it
> wouldn't surprise me if a package did "rm -rf /var/lib/foo/" on purge.
> I know of no policy section that pronounces on this. Am I overlooking
> If not, what do think of this? When is it OK for a package to
> "rm -rf /etc/foo/" on purge?
rm -rf /etc/foo really shouldn't be needed except in the cruft related
cases other people have brought up, which just as easily could be done
by removing with wildcards for particular types of tempfiles.
There is one glaring problem though... dpkg does not remove empty dirs
under /etc on purge. This is a long standing bug in dpkg. 
Personally I just leave the /etc dirs my packages create on purge, its a
f*cking bug in dpkg and I don't feel like trying to hack around it.
 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=58878 (24 Feb 2000)