Unlinking files mimicing "rm -f"

Conor P. Cahill cpcahil at virtech.uucp
Sat Mar 3 12:25:57 AEST 1990


In article <2885 at umbc3.UMBC.EDU> cs223130 at umbc5.umbc.edu.UUCP (CMSC 223/01011) writes:
>The problem arises when
>a process running as joeblow wants to remove entries in "foodir" that
>are not owned by him. A regular call to unlink() prompts the user if
>they really want to remove the file. How do I disable this feature in
>a C program using UNIX system calls -vs- invoking "system("rm -f

This is not true.  unlink(2) is a system call and it does not prompt the
user for anything.  rm(1) has some special code that stats a file (or calls
access(2), whatever) to see if the current user doesn't have write access
to the file.  If not rm(1) asks the user if it it ok to remove the file.

To unlink(2) a file, all you need is write permission in the directory
in which the file exists. The only exception that I know of is that in
some systems (namely system V.3+) if the sticky bit is set on a directory,
only those that own the file can remove them.  Normally this is only set
for directories like /tmp.

>no user interaction whatsoever. This process runs on System V version
>2.2. (Yeah I know it's old but I have no say on upgrades) The machine
>is an AT&T 3b15. Any help with this would be greatly appreciated.

This is true for any current version of unix. 


-- 
--
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 



More information about the Comp.unix.i386 mailing list