Bug 180502 - initscripts try to 'rm' on a directory
Summary: initscripts try to 'rm' on a directory
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: initscripts
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-02-08 17:49 UTC by Michal Jaegermann
Modified: 2014-03-17 02:58 UTC (History)
1 user (show)

Fixed In Version: 8.26-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-02-08 18:15:05 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Michal Jaegermann 2006-02-08 17:49:56 UTC
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/* ;;
           esac
        else
           rm -f $afile
        fi
done

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):
initscripts-8.25-1

How reproducible:
on every startup

Comment 1 Bill Nottingham 2006-02-08 18:15:05 UTC
This was fixed in 8.26-1.


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