#24873 [Bgs->Csd]: open_basedir doesn't work for single `/'
ID: 24873
Updated by: iliaa@php.net
Reported By: enrik dot berkhan at planb dot de
-Status: Bogus
+Status: Closed
Bug Type: PHP options/info functions
Operating System: any
PHP Version: 4.3.2
New Comment:
This bug has been fixed in CVS.
In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
The path resolving logic dealing with addition of / is there for *nix
based systems that always use / as the directory separator.
Previous Comments:
------------------------------------------------------------------------
[2003-07-30 11:21:22] enrik dot berkhan at planb dot de
Then it should be documented not to work. But you're right, just
letting something broken fits into the all over PHP quality ;-)
What about my comment on adding `/' instead of PHP_DIR_SEPARATOR?
------------------------------------------------------------------------
[2003-07-30 11:09:21] sniper@php.net
It's not supposed to work as it's the same as leaving open_basedir
setting out altogether..
------------------------------------------------------------------------
[2003-07-30 10:50:01] enrik dot berkhan at planb dot de
Description:
------------
if you set open_basedir = "/" it doesn't work, as it is internally
expanded to "//" in fopen_wrappers.c.
Suggested patch:
*** fopen_wrappers.c.orig Sun Feb 23 23:03:54 2003
--- fopen_wrappers.c Wed Jul 30 17:38:41 2003
***************
*** 131,137 ****
/* Resolve the real path into resolved_name */
if ((expand_filepath(path, resolved_name TSRMLS_CC) != NULL) &&
(expand_filepath(local_open_basedir, resolved_basedir TSRMLS_CC) !=
NULL)) {
/* Handler for basedirs that end with a / */
! if (basedir[strlen(basedir)-1] == PHP_DIR_SEPARATOR) {
resolved_basedir_len =
strlen(resolved_basedir);
resolved_basedir[resolved_basedir_len] = '/';
resolved_basedir[++resolved_basedir_len] =
'\0';
--- 131,138 ----
/* Resolve the real path into resolved_name */
if ((expand_filepath(path, resolved_name TSRMLS_CC) != NULL) &&
(expand_filepath(local_open_basedir, resolved_basedir TSRMLS_CC) !=
NULL)) {
/* Handler for basedirs that end with a / */
! if (basedir[strlen(basedir)-1] == PHP_DIR_SEPARATOR &&
! resolved_basedir[strlen(resolved_basedir)-1] !=
PHP_DIR_SEPARATOR) {
resolved_basedir_len =
strlen(resolved_basedir);
resolved_basedir[resolved_basedir_len] = '/';
resolved_basedir[++resolved_basedir_len] =
'\0';
***************
*** 139,145 ****
resolved_basedir_len =
strlen(resolved_basedir);
}
! if (path[strlen(path)-1] == PHP_DIR_SEPARATOR) {
resolved_name_len = strlen(resolved_name);
resolved_name[resolved_name_len] = '/';
resolved_name[++resolved_name_len] = '\0';
--- 140,147 ----
resolved_basedir_len =
strlen(resolved_basedir);
}
! if (path[strlen(path)-1] == PHP_DIR_SEPARATOR &&
! resolved_name[strlen(resolved_name)-1] !=
PHP_DIR_SEPARATOR) {
resolved_name_len =
strlen(resolved_naPHP_DIR_SEPARATORme);
resolved_name[resolved_name_len] = '/';
resolved_name[++resolved_name_len] = '\0';
BTW, why is a literal `/' added to the names, not PHP_DIR_SEPARATOR?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24873&edit=1
Thread (4 messages)