php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29145 unlink() won't delete symlink pointing outside open_basedir
Submitted: 2004-07-14 15:12 UTC Modified: 2005-01-31 23:32 UTC
Votes:6
Avg. Score:4.7 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:6 (100.0%)
From: francois at bonzon dot com Assigned:
Status: Wont fix Package: Safe Mode/open_basedir
PHP Version: 4.3.7 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: francois at bonzon dot com
New email:
PHP Version: OS:

 

 [2004-07-14 15:12 UTC] francois at bonzon dot com
Description:
------------
First, remember that when you delete a symlink (symbolic link) with the unlink() function, the link file itself is deleted, not the target file it references.

When you try to delete a symbolic link and an open_basedir restriction is in effect, with the link file itself inside the allowed path(s), but the target file outside the allowed path(s), then PHP incorrectly refuses to do it.

Reproduce code:
---------------
# the file 'test' is a symlink to '/home'
unlink($_SERVER['DOCUMENT_ROOT'] . '/debug/test');

Expected result:
----------------
PHP shouldn't resolve the symbolic link when determining whether or not it is within the allowed path(s), and allow the deletion. It should't care what the link references, but only whether the link file itself is in the allowed path(s).

Actual result:
--------------
PHP throws this error message:

Warning: unlink(): open_basedir restriction in effect. File(/home/sites/site23/web/debug/test) is not within the allowed path(s): (/home/sites/site23:/tmp) in /home/sites/site23/web/debug/unlink.php on line 6

You can see the contradiction in this message: /home/sites/site23/web/debug/test is indeed in the /home/sites/site23 directory-tree.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-15 00:36 UTC] iliaa@php.net
The nature of open_basedir handling prevents this behavior. 
This is almost impossible to change without a lot of 
special exceptions for unlink() operations on symlinks. 
 
 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 13:01:30 2024 UTC