php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41510 open_basedir restriction in effect. File(/var/tmp/)
Submitted: 2007-05-27 08:19 UTC Modified: 2007-06-05 11:54 UTC
From: damian at 1do1 dot pl Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.4.7 OS: FreeBSD 5.5
Private report: No CVE-ID: None
 [2007-05-27 08:19 UTC] damian at 1do1 dot pl
Description:
------------
Hello,
After upgrade from PHP 4.4.4 to 4.4.7 I am having this error in my aplication i've read that this bug was fixed but I think something is wrong.

I have all set in my ini 
open_basedir = /home
session.save_path = /home/var/tmp

I haven't change anything only upgrade and everything crush.

Reproduce code:
---------------
$sessionpath = session_save_path();
define('SESSION_DIR', '');
session_save_path(SESSION_DIR);
session_name('test');
session_start();
echo '<br>session_save_path - ' .$sessionpath;

Actual result:
--------------
Warning: session_start() [function.session-start]: open_basedir restriction in effect. File(/var/tmp/) is not within the allowed path(s): (/home) in /usr/home/xxx/public_html/test.php on line 8

Fatal error: session_start() [<a href='function.session-start'>function.session-start</a>]: Failed to initialize storage module: files (path: ) in /usr/home/xxx/public_html/test.php on line 8

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-27 14:36 UTC] sniper@php.net
What is the point of this in your reproduce script: 

define('SESSION_DIR', '');
session_save_path(SESSION_DIR);

???

Of course that won't work. Why should it?
And are there by any chance any symlinks in the /home/var/tmp path?
 [2007-05-27 17:06 UTC] damian at 1do1 dot pl
It worked on PHP 4.4.4.

In ini session.save_path is set to /home/var/tmp so why the script is trying to save in /var/tmp? 
"File(/var/tmp/) is not within the allowed
path(s):"
 [2007-05-27 17:45 UTC] sniper@php.net
If that worked in 4.4.4, it was bug that got fixed. 
If you set the save path to '' (empty string), default tmp path will be used which is /var/tmp in your system. This is not any bug.
 [2007-05-27 18:23 UTC] damian at 1do1 dot pl
OK. How can I change this default path?

So what for is 'session.save_path' in PHP.INI now?
 [2007-05-31 09:09 UTC] sniper@php.net
session.save_path in php.ini is what it is. If you want to use that, don't call session_save_path() at all.
 [2007-06-05 11:54 UTC] damian at 1do1 dot pl
Can You answer to my question?

How can I change this default path? Can I change it in my PHP configuration or only way is too change all scripts?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 13:01:33 2025 UTC