[aklug] Re: interesting rm behavior

From: Royce Williams <royce@tycho.org>
Date: Sat Dec 24 2011 - 06:52:22 AKST

bryanm@acsalaska.net said, on 12/24/2011 06:21 AM:
> I encountered interesting behavior of the 'rm' command. Here's
> what I did:
>
> bryan@atlantis:/tmp$ mkdir mydir
> bryan@atlantis:/tmp$ touch mydir/myfile
> bryan@atlantis:/tmp$ chmod u-w mydir
> bryan@atlantis:/tmp$ ls -la mydir
> total 3416
> dr-x------ 2 bryan users 8 2011-12-20 06:42 .
> drwxrwxrwt 14 root root 3461120 2011-12-20 06:42 ..
> -rw------- 1 bryan users 0 2011-12-20 06:42 myfile
> bryan@atlantis:/tmp$ rm -rf mydir
> rm: cannot remove `mydir/myfile': Permission denied
>
> Of course, "rmdir mydir" would fail because the directory is not
> empty, and "rm mydir/myfile" would fail because the user does not
> have permission to change the directory. I find it interesting,
> though, that "rm -rf" (unix's nuclear option) fails to perform
> the requested delete.
>
> When done as root, however, "rm -rf mydir" performs the deletion.
>
> Comments welcome.

FreeBSD provides a little more feedback, which may explain the behavior:

royce@heffalump$ mkdir mydir
royce@heffalump$ touch mydir/myfile
royce@heffalump$ chmod u-w mydir
royce@heffalump$ ls -la mydir
total 4
dr-xr-xr-x 2 royce royce 512 Dec 24 06:41 .
drwxr-xr-x 7 royce royce 1024 Dec 24 06:41 ..
-rw-r--r-- 1 royce royce 0 Dec 24 06:41 myfile
royce@heffalump$ rm -rf mydir
rm: mydir/myfile: Permission denied
rm: mydir: Directory not empty

Royce
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Sat Dec 24 06:52:30 2011

This archive was generated by hypermail 2.1.8 : Sat Dec 24 2011 - 06:52:30 AKST