open_basedir: allowed path not recognized

open_basedir: allowed path not recognized

am 20.06.2007 13:21:15 von Markus Ernst

Hi

My ISP seems to have made a PHP version upgrade - without any change in
the code, a new error occurs:

PHP Warning: ftp_nlist() [function.ftp-nlist]: open_basedir restriction
in effect. File(/var/tmp/) is not within the allowed path(s):
(/data/htdocs/domain.com/:/usr/local/share/pear/:/tmp/:/var/ tmp/) in ...

I have found some bugs related to open_basedir and temp directory
creation, they have all been set to Bogus, as /tmp/ should be added to
the allowed paths. Others are about trailing slashes that do not match.

But what looks special and disturbing to me in my example: The required
path does actually match an allowed paths entry:

- File(/var/tmp/)
- allowed path(s):
(/data/htdocs/domain.com/:/usr/local/share/pear/:/tmp/:/var/ tmp/)

So, what could I be missing? Both temporary directory and open_basedir
seem to be properly set. Could this be a disturbing between the PHP and
FTP users, which have different base directories? Or is it related to
the trailing slash problem?

Does anybody know a way how to work around this? I am grateful for any hint!

Markus

Re: open_basedir: allowed path not recognized

am 20.06.2007 16:59:29 von Markus Ernst

Markus schrieb:
> Hi
>
> My ISP seems to have made a PHP version upgrade - without any change in
> the code, a new error occurs:
>
> PHP Warning: ftp_nlist() [function.ftp-nlist]: open_basedir restriction
> in effect. File(/var/tmp/) is not within the allowed path(s):
> (/data/htdocs/domain.com/:/usr/local/share/pear/:/tmp/:/var/ tmp/) in ...
>
> I have found some bugs related to open_basedir and temp directory
> creation, they have all been set to Bogus, as /tmp/ should be added to
> the allowed paths. Others are about trailing slashes that do not match.
>
> But what looks special and disturbing to me in my example: The required
> path does actually match an allowed paths entry:
>
> - File(/var/tmp/)
> - allowed path(s):
> (/data/htdocs/domain.com/:/usr/local/share/pear/:/tmp/:/var/ tmp/)

Strange enough: Setting a temporary directory with putenv() does not
change anything, ftp_nlist() still tries to use /var/temp/ as temporary
directory.

putenv('TMPDIR='.$_SERVER['DOCUMENT_ROOT'].'/temp/');
var_dump(getenv('TMPDIR')); // prints the path
$list = ftp_nlist($conn_id, '/');

Resulting message is still:
PHP Warning: ftp_nlist() [function.ftp-nlist]: open_basedir restriction
in effect. File(/var/tmp/) is not within the allowed path(s) ...

I tried to replace ftp_nlist() by something like:

ftp_raw($conn_id, 'PASV');
ftp_raw($conn_id, 'TYPE A');
$liste = ftp_raw($conn_id, 'NLST');
var_dump($liste); exit;

This blocks the system for several minutes, then displays an empty array.

Re: open_basedir: allowed path not recognized

am 20.06.2007 16:59:29 von Markus Ernst

Markus schrieb:
> Hi
>
> My ISP seems to have made a PHP version upgrade - without any change in
> the code, a new error occurs:
>
> PHP Warning: ftp_nlist() [function.ftp-nlist]: open_basedir restriction
> in effect. File(/var/tmp/) is not within the allowed path(s):
> (/data/htdocs/domain.com/:/usr/local/share/pear/:/tmp/:/var/ tmp/) in ...
>
> I have found some bugs related to open_basedir and temp directory
> creation, they have all been set to Bogus, as /tmp/ should be added to
> the allowed paths. Others are about trailing slashes that do not match.
>
> But what looks special and disturbing to me in my example: The required
> path does actually match an allowed paths entry:
>
> - File(/var/tmp/)
> - allowed path(s):
> (/data/htdocs/domain.com/:/usr/local/share/pear/:/tmp/:/var/ tmp/)

Strange enough: Setting a temporary directory with putenv() does not
change anything, ftp_nlist() still tries to use /var/temp/ as temporary
directory.

putenv('TMPDIR='.$_SERVER['DOCUMENT_ROOT'].'/temp/');
var_dump(getenv('TMPDIR')); // prints the path
$list = ftp_nlist($conn_id, '/');

Resulting message is still:
PHP Warning: ftp_nlist() [function.ftp-nlist]: open_basedir restriction
in effect. File(/var/tmp/) is not within the allowed path(s) ...

I tried to replace ftp_nlist() by something like:

ftp_raw($conn_id, 'PASV');
ftp_raw($conn_id, 'TYPE A');
$liste = ftp_raw($conn_id, 'NLST');
var_dump($liste); exit;

This blocks the system for several minutes, then displays an empty array.