Re: unlink system call on directories - Bug + fix

Torbjorn Lindgren (tl@funcom.no)
Mon, 18 Nov 1996 10:39:20 +0100 (MET)


On Sun, 17 Nov 1996, Kenneth Albanowski wrote:
> On Fri, 15 Nov 1996, Andrew M. Bishop wrote:
> > Even worse for NFS, the unlink() call will succeed on directories.
> > The inode will disapear, only to be found in lost+found on the
> > file server next time it is fsck'd.
>
> This can't be right. If this does occur, it is the server's fault, not the
> client.

Correct, but not that uncommon, at least not on some older boxes.

In several older BSD-based boxes I have seen you could do unlink's of
directories *IF* you were root (owning the directory wasn't enough), with
exactly that effect. You couldn't do it using rm (it checked first), but
the system call supported it.

I wouldn't be surprised if the original NFS code from Sun just tried to
do unlink when told, and if you didn't map uid 0 (you usually did) and
used one of these OS you could get into real trouble. You could do the
same thing locally, and uid 0 was mapped by default, so I don't think the
*NFS* code was to blame for that.

In short, these OS depended on the application program (rm) to do the
checking for it, *IFF* you were root. Might even have been by design,
after all *root* can do it anyway :-)

-- 
Torbjörn Lindgren
Funcom Oslo A/S, Langkaia 1, N-0150 Oslo, Norway  Phone: +47 22420102
E-mail: tl@funcom.com
If Santa ever DID deliver presents on Christmas Eve, he's dead now.