open_basedir not working on FreeBSD
| From: | Matt Haught | Date: | Fri, 23 Aug 2002 16:38:48 +0000 |
| Subject: | open_basedir not working on FreeBSD | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-87355@lists.php.net to get a copy of this message | ||
Hello,
Open_basedir does not seem to be working properly for me on my FreeBSD servers. Reading files from outside the open_basedir is successfull for both include() and readfile(), but fails (as it should) when trying to do the same with fopen or opendir and gives the "Warning: open_basedir restriction in effect. File is in wrong directory in /home/www/websites/htdocs/info.php on line 10" error. I am using FreeBSD 4.4-RELEASE/apache-1.26, 4.6-RELEASE/apache-1.26, and 4.6.2-RELEASE/apache-1.27-dev and they are all using a fresh cvs of php4 from Aug 21-23. I am reading /etc/resolv.conf to test the servers, and all of them have their open_basedir set to "/home/www/websites/htdocs/" or "/websites/" for the testing. Am I missing something. Could someone else using FreeBSD/open_basedir test this out for me? My WinXP/apache-1.26/php-4.2.2 development box does not seem to have this problem.
Here is my test file:
<?php
$testfile='/etc/resolv.conf';
$testdir='/etc';
echo 'include(): ';
include($testfile);
echo '<br>';
echo "fopen()/fread(): ";
if ($fd = fopen ($testfile, "r")) {
echo fread ($fd, filesize ($testfile));} echo '<br>'; echo 'readfile(): '; echo readfile($testfile); echo '<br>'; echo 'opendir()/readdir(): '; if ($handle = opendir($testdir)) { echo "Directory handle: $handle<br>"; echo "Files:<br>"; /* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) {
echo "$file<br>";} } echo '<br>'; phpinfo(); ?> _________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com