Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site hropus.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!hropus!ka From: ka@hropus.UUCP (Kenneth Almquist) Newsgroups: net.unix-wizards Subject: Re: SYS V unlink() call Message-ID: <283@hropus.UUCP> Date: Fri, 14-Feb-86 17:33:46 EST Article-I.D.: hropus.283 Posted: Fri Feb 14 17:33:46 1986 Date-Received: Sat, 15-Feb-86 05:14:37 EST References: <683@dayton.UUCP> Organization: Bell Labs, Holmdel, NJ Lines: 27 Keywords: SYSV unlink() > Does that mean that to delete [meaning unlink - ka] *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? Yes, the manual means what it says. This is true for all versions of UN*X. The reason is that if normal users were permitted to unlink directories, they might forget to unlink all the entries in the directory first. If they forgot to unlink the entry for ".", the directory would become inaccessible when the entry for it in the parent directory was unlinked, but the directory would not be deleted because there would still be an entry pointing to it, namely the entry "." in the directory itself. If they remembered to unlink the entry for ".", but forgot to unlink other entries in the directory, then when the directory disappeared the link counts on the files or directories that these entries pointed to would be incorrect. 4.2 BSD has a separate set of system calls called "mkdir" and "rmdir" which allow non-superusers to create and delete directories and which check that "." and ".." are handled correctly. (Actually, the documentation claims that you have to be superuser to invoke the mkdir system call, but this is never checked for in the code.) Under System V, all you have to do to create and delete directories is to run the mkdir and rmdir programs. Kenneth Almquist ihnp4!houxm!hropus!ka (official name) ihnp4!opus!ka (shorter path)