Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!ark From: ark@alice.UucP (Andrew Koenig) Newsgroups: net.unix-wizards Subject: Re: SYS V unlink() call Message-ID: <4980@alice.uUCp> Date: Fri, 14-Feb-86 19:48:49 EST Article-I.D.: alice.4980 Posted: Fri Feb 14 19:48:49 1986 Date-Received: Sun, 16-Feb-86 03:57:19 EST References: <683@dayton.UUCP> Organization: Bell Labs, Murray Hill Lines: 36 > Our system (a CRDS Universe/32 w/ Unos 6.1) is based > on Unix V, or to be more precise, is SYS V compatible. > > My question is this: In SYSV do you have* to be SU > to unlink directories? I wrote a program that > unlinks whatever file name is passed to it to > confirm my ideas, and sure enough, it would not > remove (unlink) a file that is a directory even if > I owned it, and it had write permission. The error > I get back is EPERM..Looking it up in the good olde > System V Interface Definition Book (Spring 1985 - Issue 1) > on page 143: > > [EPERM] The named file is a directory and > the effective user ID of the process > is not super-user. > > Does that mean that to delete *any* directory the program > must be set uid'ed to root? I can't believe that this is > what is really meant here, and it must be some sort of typo. > Could anyone from Bell please clarify this? Correct: only the super-user can unlink a directory. It has always been thus (at least as far back as V6). The reason is that removing a directory is not simply a matter of breaking the link to it from its parent. One must also break the link FROM the directory TO its parent (always named "..") and the link from the directory to itself (always named "."). Unless all three of these things are done in the proper order, there is the possibility of various kinds of file system damage. In order to restrict unlinking of directories to programs that take pains to do the right things, the system allows only the super-user to break a link to a directory. Why can't you believe this is what is really meant?