views:

20

answers:

1

Hi,

I have a very strange behavior with is_file() or file_exists() function.

<?php 
    $nfsFile = '/mnt/nfsdir/file.txt';
    var_dump(is_file($nfsFile));
?>

this code returns FALSE all the time, but:

$#php -r 'var_dump(is_file('/mnt/nfsdir/file.txt'));'

returns TRUE, which is correct.

I'm running Debian Squeeze, Apache 2.2.15 and PHP 5.3.2-1.

I'm not in safe mode, the directory /mnt/nfsdir/ and all files are in 777, www-data user can ls /mnt/nfsdir/ so I'm a bite out of idea now.

Any suggestion are welcome!

A: 

Looks realy like a server config issue to me.

Maybe test if echo exec('ls /mnt/nfsdir/file.txt'); works.

I don't think so. Cause it seams, even if www-data can access the file, PHP is not allowed to access it.

But if exec('ls /mnt/nfsdir/file.txt'); works this could be a solution for you.

Otherwise I would have a look at the server config again.

JochenJung
Yes, in fact open_basedir must be set to 'none' even if your are not in safe mode if you want to have access to any files. Changing open_basedir=none resolved the problem, but I assume that it's not very secure.
pvledoux
Well.. you can make sure, all of your open(), exec(), etc. statements don't allow your users to open/exec any file. If the user can decide wich file to open, make sure to prepend a basedir and to disallow "../", this way your application should be as secure as with open_basedir set.
JochenJung