Unlinking files mimicing "rm -f"

CMSC 223/01011 cs223130 at umbc5.umbc.edu
Fri Mar 2 15:24:33 AEST 1990

     The discussion regarding the efficency of unlink() -vs- chdir() has
reminded me of a problem I have encountered that maybe someone on the
net could help me with.  I had written a routine that a daemon process
uses to remove files from a directory based on certain criteria. The
problem I have run across concerns different ownerships of files in a
directory by another owner. For example...

    drwxrwx--- joeblow joesgrp  foodir

is owned by "joeblow", yet files in the directory are owned by most
anyone in "joesgrp". (i.e. janedoe or danquayl). 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
filename)" which seems to be slower because of an additional call to
invoke the shell. It is also desirable for a daemon process that wants
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.

              Thanks in advance,
                  Dan Brown

P.S. To clarify, The problem will only arise when the file owned by
janedoe does not give write permissions to joeblow or joesgrp.
I can't remember the exact wording of the question but I think is goes
something like this.

"rm filename mode?"

                  Again thanks.


More information about the Comp.unix.i386 mailing list