Bug 180502 - initscripts try to 'rm' on a directory
initscripts try to 'rm' on a directory
Product: Fedora
Classification: Fedora
Component: initscripts (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
Brock Organ
Depends On:
  Show dependency treegraph
Reported: 2006-02-08 12:49 EST by Michal Jaegermann
Modified: 2014-03-16 22:58 EDT (History)
1 user (show)

See Also:
Fixed In Version: 8.26-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-02-08 13:15:05 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Michal Jaegermann 2006-02-08 12:49:56 EST
Description of problem:

In /etc/rc.d/rc.sysinit there is the following piece of code:

# Clean up /var.  I'd use find, but /usr may not be mounted.
for afile in /var/lock/* /var/run/* ; do
        if [ -d "$afile" ]; then
           case "$afile" in
                */news|*/mon)   ;;
                */sudo)         rm -f $afile/*/* ;;
                */vmware)       rm -rf $afile/*/* ;;
                */samba)        rm -rf $afile/*/* ;;
                */screen)       rm -rf $afile/* ;;
                */cvs)          rm -rf $afile/* ;;
                *)              rm -f $afile/* ;;
           rm -f $afile

The problem is that after recent changes to dovecot this atempts to
do 'rm -f /var/run/dovecot/login' and loudly complaints because this is
a directory.  OTOH it leaves old /var/run/dovecot/login/ssl-parameters.dat

Instead of trying to keep up with various possible changes there I think
that the following code, which recursively walks through subdirectories, would
be more robust:

remove_files () {
    # use subshell so directory changes and variables
    # are invocation independent
    ( cd "$1" || exit;
    for x in * ; do
	[ -d "$x" ] && remove_files $x || rm -f $x
    done )

remove_files /var/lock ; remove_files /var/run

plus possibly some special cases when you want to remove some subdirectories
as well.

Version-Release number of selected component (if applicable):

How reproducible:
on every startup
Comment 1 Bill Nottingham 2006-02-08 13:15:05 EST
This was fixed in 8.26-1.

Note You need to log in before you can comment on or make changes to this bug.