Re: unlink()?
| From: | Ashley Sheridan | Date: | Sun, 06 Jun 2010 00:02:41 +0000 |
| Subject: | Re: unlink()? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-305851@lists.php.net to get a copy of this message | ||
On Sat, 2010-06-05 at 18:55 -0400, tedd wrote:
> Hi gang:
>
> Never-mind.
>
> I didn't change the parent directory permissions to unlink the file -- duh!
>
> Cheers,
>
> tedd
>
> --- I asked:
>
> Hi gang:
>
> I use unlink() to delete files on my server by using the statement:
>
> unlink($filename);
>
> where $filename is the physical path to the file plus file name, such as:
>
> $filename = '/var/www/vhosts/domain.com/httpdocs/a-dir/a-text.txt';
>
> Now, I can read, write, and even create the file -- so I have the
> path and permissions correct. But if I unlink() the file and then
> examine the contents of the parent directory afterwards, I find the
> file remains -- what's up with that?
>
> This reminds me of the process of deleting files on your local hard
> disk, which basically sets the disk-space allocated to the file as
> "available for writing" without actually deleting the file.
>
> So what am I not understanding here?
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com Ý*é
> ¨a™ÙÿA$�Œhttp://ancientstones.com
> http://earthstones.com
>
I was just about to mention this! It's one of the bizarre security
loopholes in Linux. If you have write permissions to a directory but not
a file within it, you can still delete the file. I believe you can
change this behaviour with filesystem security mods, but I've not tried
that.
Thanks,
Ash
http://www.ashleysheridan.co.uk