473,746 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

open_basedir

Hello,
I use php 5.1.4 with apache 2.2.2 on Solaris 10.
The problem is that I can't configure open_basedir
because I always get warming message:

Warning: readfile() [function.readfi le]: open_basedir restriction in
effect. File(test.txt) is not within the allowed path(s):
(/wwwroot/default) in /wwwroot/default/mk.php on line 3
Warning: readfile(test.t xt) [function.readfi le]: failed to open stream:
Not owner in /wwwroot/default/mk.php on line 3

open_basedir = /wwwroot/default
/wwwroot/default
- test.txt <- my txt file
- mk.php <- my script that read test.txt
<?
readfile("test. txt");
?>

My read file - test.txt is in open_basedir path.
When I use full path to the file everything is ok.

Do you have any clue ?

--
Marcin

Jun 24 '06 #1
2 3005
sr*****@wp.pl wrote:
My read file - test.txt is in open_basedir path.
When I use full path to the file everything is ok.

Do you have any clue ?


Image the following situation:

The text and script files are in the following dir:

/somedir/subdir

The script file includes the text file relatively to the current working
dir, as in:

readfile('test. txt');

The open_basedir directive is set as follows:

open_basedir = /somedir/subdir

Now, you cd to /somedir/subdir and execute the script: all is fine.

Next, you cd to /somedir and execute the script: it fails. Why?

Because you include the text file relatively to the current working dir
(cwd), PHP expects the text file to be in /somedir, simular to:

readfile('/somedir/test.txt');

And this is restricted, hence the error message. For this reason, using an
absolute path works, because this doesn't take the cwd into account.

The same applies to the safe_mode settings, which you also seem to use
according to the "Not owner" error.

To dynamically determine the absolute path, you could do something like:

readfile(dirnam e($_SERVER['PHP_SELF']) .'/test.txt');
HTH;
JW
Jun 25 '06 #2
Now, you cd to /somedir/subdir and execute the script: all is fine.
Next, you cd to /somedir and execute the script: it fails. Why?

Because you include the text file relatively to the current working dir
(cwd), PHP expects the text file to be in /somedir, simular to:

readfile('/somedir/test.txt');

And this is restricted, hence the error message. For this reason, using an
absolute path works, because this doesn't take the cwd into account.
You are right, but problem isn't in it.
On my home's FreeBSD box evrything works ok, but
on Solaris 10 I have to use absolute path's.
Why do I have to do it ?
To dynamically determine the absolute path, you could do something like:
readfile(dirnam e($_SERVER['PHP_SELF']) .'/test.txt');

Thank you, I will use it :)

--
Marcin Kula

Jun 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2092
by: Felix Natter | last post by:
hi, I read the section about open_basedir in the safe_mode documentation (http://de3.php.net/features.safe-mode) but this only confirmed my understanding of open_basedir and didn't help understand the problem below. I tried to search the net, but couldn't find anything yet. here is my test-case (with php_admin_value open_basedir /home/m2004001):
7
20792
by: Paul | last post by:
Hi Im testing a script to see if it works in different situations and open_basedir is one of them. However if i turn it On all i get is errors Warning: Unknown(): open_basedir restriction in effect. File(c:\web\httpdocs\session.php) is not within the allowed path(s): (1) in Unknown on line 0 Warning: Unknown(c:\web\httpdocs\session.php): failed to open stream:
3
4636
by: Alvaro G Vicario | last post by:
This is the open_basedir restriction of my site: php_admin_value open_basedir /tmp/:/home/site/ All my PHP files are under /home/site/htdocs. However, I get lots of errors like: Warning: open_basedir restriction in effect. File is in wrong directory in /home/site/.......
0
1416
by: Chris Ritson | last post by:
I am setting open_basedir to include only the DocumentRoot and PHP installation tree in 16 out of 18 VirtualHosts on our (test) apache server. This is running apache 2.0.53 and PHP 5.0.3. If I force a graceful restart, then fetch a trivial PHP page containing little more than a single call to phpinfo(); from each host, I get the correct value reported for open_basedir from the first few requests, then the value seems to cycle round the...
2
6929
by: Brandons of mass destruction | last post by:
I'm trying to turn off open_basedir, and according to php.info, I've managed to do that in the master value column, by editing the php.ini file. But it's still on as local value for several domains, and I don't know where turn it off. does anyone?
0
2349
by: jeff.battle | last post by:
I'm trying to get PEAR DB to work on my machine at serverbeach but I'm getting the following error: Warning: main(): open_basedir restriction in effect. File(/usr/share/pear/DB.php) is not within the allowed path(s): (/home/httpd/vhosts/adapttosolve.com/httpdocs:/tmp) in... phpinfo() says I have the following open_basedir values set: open_basedir | /home/httpd/vhosts/adapttosolve.com/httpdocs:/tmp | no value
0
2487
by: erwinschrijver | last post by:
On a previous installed server my site which uses several PEAR-packages worked fine. Now it's transfered to a new server. (Both servers installed with Windows 2003 / IIS 6, on the previous server the PHP version was 5.03, on the new one 5.05) The site gives a open_basedir restriction on this new server. In the php.ini the open_basedir line is commented, but when I run the command phpinfo() there appears to be a local value, which I...
6
15051
by: lawrence k | last post by:
If I ssh to my server and look at the php.ini file, it apears that open_basedir is off: ; open_basedir, if set, limits all file operations to the defined directory ; and below. This directive makes most sense if used in a per- directory ; or per-virtualhost web server configuration file. This directive is ; *NOT* affected by whether Safe Mode is turned On or Off. ;open_basedir =
2
839
by: rdlowrey | last post by:
Okay, I've tried a bunch of things on this one and can't figure it out. The line in my phpinfo: open_basedir /var/www/vhosts/mysite.com/subdomains/intranet/httpdocs:/ tmp no value Why would I get a "Warning: move_uploaded_file(): open_basedir restriction in effect." error message if I've used SSH to set the Master open_basedir value to "no value" (as evidenced by phpinfo)?
0
8801
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9516
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9351
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9219
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4587
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4840
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3294
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2200
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.