Home > Archive > PERL CGI Beginners > May 2004 > Deleting a dir
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Octavian Rasnita 2004-05-22, 11:32 am |
| Hi all,
If the user apache which runs the cgi scripts on my server want to delete a
file that has restrictive priviledges and is owned by another user, how can
I make a cgi program to be able to delete those files?
I don't know very much about Unix/Linux yet...
Thank you.
Teddy
| |
| Bob Showalter 2004-05-22, 11:32 am |
| Octavian Rasnita wrote:
> Hi all,
>
> If the user apache which runs the cgi scripts on my server want to
> delete a file that has restrictive priviledges and is owned by
> another user, how can I make a cgi program to be able to delete those
> files?
Deleting a file requires write privilege in the *directory* containing the
file; your permissions with respect to the file itself don't matter.
If the apache user doesn't have write privilege in the directory, you can
create a "setuid" script that can delete the files. There are several issues
with this; please read the information in "perldoc perlsec" carefully.
| |
| troubador 2004-05-22, 11:32 am |
| On Wed, 12 May 2004 15:36:55 +0300, Octavian Rasnita wrote:
OR> If the user apache which runs the cgi scripts on my server want to
OR> delete a file that has restrictive priviledges and is owned by another
OR> user,how can I make a cgi program to be able to delete those
OR> files?
Something like this _should_ work...this is basically taken from "Learning
Perl" by Randal Schwartz; you need this book--I can't imagine Perl
without it...anyway, the code:
###CODE###
$filename = "Name of file you want to delete";
chown("apache","$filename);
unlink($filename); #this will delete the file
###CODE###
OR> I don't know very much about Unix/Linux yet...
No worries--we all started there...heck, I'm still there! There are some
fantastic people in this group that will help you when you get stuck...of
course first you'll want to become familiar with the "man" command :)
OR> Thank you.
Hope it helps!
/troubador
|
|
|
|
|