Bug 180502

Summary: initscripts try to 'rm' on a directory
Product: [Fedora] Fedora Reporter: Michal Jaegermann <michal>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED RAWHIDE QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 8.26-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-02-08 18:15:05 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.