Bug 120130

Summary: rm cannot unlink symlinks to directories
Product: [Fedora] Fedora Reporter: Albert Strasheim <13640887>
Component: coreutilsAssignee: Tim Waugh <twaugh>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhide   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-04-07 08:56:14 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 Albert Strasheim 2004-04-06 10:09:52 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040312

Description of problem:
I cannot unlink symlinks to directories using rm -f, rm -rf or just
plain rm.

For example:

mkdir ~/k
cd ~/k
ln -s / foo

rm foo/
rm: cannot remove directory `foo/': Is a directory

rm -f foo/
rm: cannot remove `foo/': Not a directory

rm -rf foo/
rm: cannot remove `foo/': Not a directory

rm -r foo/
rm: descend into write-protected directory `foo/'? [n]
(answering no, rm exits and foo is not removed)

rm -r foo
rm: descend into write-protected directory `foo/'? [y]
rm: descend into write-protected directory `foo//sys'?
...

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

How reproducible:
Always

Actual Results:  rm doesn't unlink symlinks to directories

Expected Results:  rm should unlink symlinks to directories without
trying to descend them.

Additional info:

The same problem exists on Fedora Core 1 with coreutils-5.0-34.1. The
problem is not present on Red Hat Linux 9 with coreutils-4.5.3-19.0.2.

Comment 1 Tim Waugh 2004-04-07 08:56:14 UTC
[tim@cyberelk k]$ ln -s / foo; rm foo
[tim@cyberelk k]$ ln -s / foo; rm -f foo
[tim@cyberelk k]$ ln -s / foo; rm -rf foo
[tim@cyberelk k]$ ln -s / foo; rm -f foo
[tim@cyberelk k]$ ln -s / foo; rm -r foo
[tim@cyberelk k]$ rpm -q coreutils
coreutils-5.2.1-3

'foo' != 'foo/' -- you are forcing the dereference yourself by adding '/'.