Open basedir and file_exists

Having trouble installing serendipity?
Post Reply
deathline
Regular
Posts: 7
Joined: Tue May 30, 2006 12:05 pm

Open basedir and file_exists

Post by deathline »

Code: Select all

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/data/web/virtuals/_/www/s9y/serendipity_config_local.inc.php) is not within the allowed path(s): (/data/web/virtuals/xxxx.xxx/:/tmp/) in /data/web/virtuals/xxxx.xxx/www/s9y/serendipity_config.inc.php on line 164
line 164-175

Code: Select all

if (file_exists($_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/serendipity_config_local.inc.php')) {
    $local_config = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/serendipity_config_local.inc.php';
} elseif (file_exists($serendipity['serendipityPath'] . '/serendipity_config_local.inc.php')) {
    $local_config = $serendipity['serendipityPath'] . '/serendipity_config_local.inc.php';
} elseif (defined('S9Y_DATA_PATH')) {
    // Shared installation!
    $local_config = 'data/web/virtuals/xxxx.xxx/www/s9y' . '/serendipity_config_local.inc.php';
} else {
    // Installation fallback
    $local_config = S9Y_INCLUDE_PATH . '/serendipity_config_local.inc.php';


I solved this problem in serendipty_config.inc.php deleting some codes and a little editing in this file which is written above.First fourth raw deleted and used "if" instead of second "elseif"

Now s9y work good but, will it be a problem next time?


[/code]
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Open basedir and file_exists

Post by garvinhicking »

Hi!

Instead you should talk to your provider, he has not properly setup your open_basedir path(s).

The fix you made will be overwritten for the next s9y update, since the original code used by Serendipity is the proper one, as long as open_basedir is properly configured...

HTH and best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
orang
Regular
Posts: 23
Joined: Wed Aug 16, 2006 9:03 am

Re: Open basedir and file_exists

Post by orang »

Hi there,

I have the same problem described above.

I have actually two serendipity softwares installed on my webspace (http://www.weisenbacher.de/kfd/index.php and http://www.weisenbacher.de/bib/) and both of them are displaying since a couple of weeks the same error messages:

Warning: file_exists(): open_basedir restriction in effect. File(/customers/weisenbacher.de/weisenbacher.de/httpd.www/kfd/templates/costa-nature_theme/404.tpl) is not within the allowed path(s): ...

Both of them have been running without any problems since more than at least 6 years without them being changed by me in any way and now, all of a sudden, they both don't work anymore - displaying the same error message. I had a long chat with my provider and I even pointed them to this thread here, at the end of which he stated:
unfortunately, we can't help you regarding this since open_basedir is not going to be altered in any way, you may also ask for some suggestions on that forum on how to fix it since they are in control of your software which "Serendipity"
What else can I do?

Thanks,
Stefan
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Open basedir and file_exists

Post by Timbalu »

orang wrote:... displaying since a couple of weeks the same error messages...
That short...? You don't seem to need your installations... :-)

If you google this, this isn't really the fault of the software used, it is by your servers (ISPs) configuration, as Garvin pointed out.
Therefor they should be able to solve this for you (and all their other customers). I found a lot of others with the same crude open_basedir error messages... based on corresponding server environments (or same provider).

The message displayed is clear: the path and file on demand is NOT in the allowed open_basedir() paths. What is the correct system file path that is allowed and correct accessible by your ISP?

You can either test what you Server configuration tells you

Code: Select all

<?php 
echo "1: " . $_SERVER['DOCUMENT_ROOT'] . "<br>\n";
echo "2: " . dirname($_SERVER['PHP_SELF']) . "<br>\n";
echo "3: " . $serendipity['serendipityPath'] . "<br>\n";
echo "4: " . S9Y_DATA_PATH . "<br>\n";
echo "5: " . getcwd() . "<br>\n";
echo "6: " . dirname(__FILE__) . "<br>\n";
?> 
Put that into a mypathtests.php file in your Home directory and access it via browser.
What is the scripts output and which path is not a real (allowed and accessible) path? Of very interest is also number 3. Is it still an allowed and acessible path? Maybe that has changed...?! If so, you need to modify the value of serendipityPath in the *_config table of you database.

The path not found error is this, for example....

Code: Select all

/customers/weisenbacher.de/weisenbacher.de/httpd.www/kfd/templates/costa-nature_theme/404.tpl
as it says:

Code: Select all

Warning: file_exists(): open_basedir restriction in effect. 
File
/customers/weisenbacher.de/weisenbacher.de/httpd.www/kfd/templates/costa-nature_theme/404.tpl
is not within the allowed path(s):
(
/customers/d/f/6/weisenbacher.de/httpd.www:
/customers/d/f/6/weisenbacher.de/httpd.private:
/customers/d/f/6/weisenbacher.de/tmp:
/customers/weisenbacher.de/weisenbacher.de:
/var/www/diagnostics:
/usr/share/php
)
in .... file
Are you sure it should'nt be either:

Code: Select all

/customers/weisenbacher.de/weisenbacher.de/kfd/templates/costa-nature_theme/404.tpl
or

Code: Select all

/customers/d/f/6/weisenbacher.de/httpd.www/kfd/templates/costa-nature_theme/404.tpl
or some other path?

First, try to add

Code: Select all

php_admin_value open_basedir none
on top of your Serendipity .htaccess files to disable open basedir in your blogs.

If that does not help, you can try to set the correct path via ini_set():
As of PHP 5.3.0 open_basedir can be tightened at run-time. This means that if open_basedir is set to /www/ in php.ini a script can tighten the configuration to /www/tmp/ at run-time with ini_set(). When listing several directories, you can use the PATH_SEPARATOR constant as a separator regardless of the operating system.

Second, it ~might~ help to add an empty 404.tpl file to your theme testwise, to circumvent the restriction message on a file which is actually not a real file. Does that change the errors?

Edit:
Please provide some more info about server configuation, system info, S9y and PHP Versions.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
orang
Regular
Posts: 23
Joined: Wed Aug 16, 2006 9:03 am

Re: Open basedir and file_exists

Post by orang »

Hi Ian,

Thank you very much for your help, I haven't gotten around trying out what you pointed out in your post up until now.

Customer service told me when I chatted with him, the correct path is:

Code: Select all

/customers/d/f/6/weisenbacher.de/httpd.www
Which seems right, since this is also the number 1 in the mypathtest file that you wrote.

I'm using Serendipity 1.5.5, PHP is 5.3.23 and phpinfo() tells me about the system:

Code: Select all

Linux web157.local 3.4.35-20130304-0940-ef1617a #1 SMP Mon Mar 4 09:42:04 UTC 2013 x86_64 
this is from http://weisenbacher.de/test.php.
I set up a mypathtest.php here: http://weisenbacher.de/mypathtest.php. And you can see that concerning #3, nothing is displayed. I'm not sure what that means. I tried the edit to the .htaccess file you mentioned, but it didn't seem to help.

I do understand that it is a server side problem, however I don't understand how it could occur. As much as I didn't understand how I can "tighten the .ini at run-time".
This is all very strange to me still, they must have changed something and are now unwilling to change it back. I haven't talked to them again since.


Thanks,
Stefan
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Open basedir and file_exists

Post by Timbalu »

This does look like they have changed the path from
/customers/weisenbacher.de/weisenbacher.de/httpd.www
to
/customers/d/f/6/weisenbacher.de/httpd.www
If you had a previous install, you will possibly have an old path set in your database config table. Have a look at it before changing.
Update the path with the following SQL statement (replacing the PREFIX with yours, normally serendipity_config):

Code: Select all

UPDATE PREFIX_config
SET value = '/customers/d/f/6/weisenbacher.de/httpd.www/kfd/'
WHERE name = 'serendipityPath';
and the same for the /bib/ installation. If that was the main problem you should kick them in the ...! They should have told you.

I am surprised that dirname($_SERVER['PHP_SELF']) is empty.... (*)
You could try to add to the test script:

Code: Select all

echo '2.1: ' . $_SERVER['PHP_SELF'] ."<br>\n";
echo '2.5: ' . basename(__DIR__) ."<br>\n";
Normally the dirname($_SERVER['PHP_SELF']) should be "/kfd" or "/bib" in your environment.
so that

Code: Select all

$_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/serendipity_config_local.inc.php';
would give the correct path
/customers/d/f/6/weisenbacher.de/httpd.www/kfd/serendipity_config_local.inc.php
(*) well, not if in webservers root... There dirname would be nothing...

Edit:
It might also well be they have updated the PHP version to now 5.3.23, which is a step stricter in noting changed coding standards. If all that mentioned above has been solved, you should update Serendipity to the latest available version 1.7 RC3, or wait some more days until we release the 1.7 final. Before updating Serendipity you have to make sure to get all updated plugins and also templates first (costa for example has changed).
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
orang
Regular
Posts: 23
Joined: Wed Aug 16, 2006 9:03 am

Re: Open basedir and file_exists

Post by orang »

Hi Ian,

Thanks so much for your reply.

The update change that you mentioned concerning the serendipity_config table worked for the /kfd/. So I updated the path and the site is back now as usual.

However there are seem to be more problems with the /bib/ installation. I wonder whether that is, because it is an older serendipity version. I have to admit that no one uses this website right now, but it contains information that is useful to have as an archive thing... So, it would be nice to have it back on.
After I changed the path, I had the deprecated error message, so I changed the error report line in the config_inc.php, but now I only get a blank page and I don't seem to be able to get proper error messages. Do you have an idea how to get an error output at all or what the problem could be? I'm not even sure, how to find out the serendiptiy version, the files date back from 2008...

I put up an error.php containing:
ini_set ('track_errors', 1);
ini_set ('log_errors', 1);
ini_set ('error_log', '/customers/d/f/6/weisenbacher.de/httpd.www/bib/php_error.log');
But the error_log remains empty.

Thanks again!
Stefan
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Open basedir and file_exists

Post by Timbalu »

Well, a white page of death means fatal error, which should be logged somehow to the server logs. Ask your ISP about that. How in detail did you silence the error reporting deprecated warnings?

What kind of useful information does that bib page provide. Is it changed serendipity code or just some old entries you want to save? If the last, take the latest stable Serendipity 1.6.2 and copy it onto your bib installation. That will most likely solve the white page and keep it running after changing the error reporting variable in serendipity_config.inc.php like this

Code: Select all

error_reporting(E_ALL & ~E_NOTICE ^ E_DEPRECATED);
~line 54
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Post Reply