Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oc-2069 - APPSROOTS not set corectly in OC 4.5 #770

Closed
msrex opened this issue Dec 7, 2012 · 8 comments
Closed

oc-2069 - APPSROOTS not set corectly in OC 4.5 #770

msrex opened this issue Dec 7, 2012 · 8 comments
Labels

Comments

@msrex
Copy link

msrex commented Dec 7, 2012

From http://bugs.owncloud.org/thebuggenie/owncloud/issues/oc-2069

There are active reporters still checking.

The descriptions and comments:

Description:
Hi, I just updated from an older version to 4.0.8. Worked great! But when I updated to 4.5. as it is descriped in the update guide I got some PHP warnings:

PHP Warning: file_exists(): open_basedir restriction in effect. File(/templates/) is not within the allowed path(s): (C:/Inetpub/vhosts/abc.xyz;C:\Windows\Temp) in C:\Inetpub\vhosts\abc.xyz\ownCloud\lib\template.php on line 245 PHP Warning: file_exists(): open_basedir restriction in effect. File(/l10n/) is not within the allowed path(s): (C:/Inetpub/vhosts/abc.xyz;C:\Windows\Temp) in C:\Inetpub\vhosts\abc.xyz\ownCloud\lib\l10n.php on line 302 PHP Warning: file_exists(): open_basedir restriction in effect. File(/l10n/) is not within the allowed path(s): (C:/Inetpub/vhosts/abc.xyz;C:\Windows\Temp) in C:\Inetpub\vhosts\abc.xyz\ownCloud\lib\l10n.php on line 302

To fix this I added this line to /lin/base.php function initPaths() OC::$APPSROOTS[1] = array('path'=>OC::$SERVERROOT,'url'=>,'writable'=>false);

Now it works ;)

Regards,

Khaos

Reproduction steps:
Don't know how to reproduce. But I'm using IIS7 on windows 2008 r2 server. All directory rights are set correctly, version 4.0.8. worked fine!
#2 Comment posted by Khaos Oct 18, 12:13

Adding path to APPSROOTS isn't the final solution! Going to /?app=settings&getfile=apps.php?installed will bring new Warnings.

PHP Warning: require_once(): open_basedir restriction in effect. File(../lib/base.php) is not within the allowed path(s): (C:/Inetpub/vhosts/abc.xyz;C:\Windows\Temp) in C:\Inetpub\vhosts\abc.xyz\ownCloud\settings\apps.php on line 24 PHP Warning: require_once(../lib/base.php): failed to open stream: Operation not permitted in C:\Inetpub\vhosts\abc.xyz\ownCloud\settings\apps.php on line 24 PHP Fatal error: require_once(): Failed opening required '../lib/base.php' (include_path='C:/Inetpub/vhosts/abc.xyz/ownCloud/lib;C:/Inetpub/vhosts/abc.xyz/ownCloud/config;C:/Inetpub/vhosts/abc.xyz/ownCloud/3rdparty;C:/Inetpub/vhosts/abc.xyz/ownCloud/apps;C:/Inetpub/vhosts/abc.xyz/ownCloud;C:/Inetpub/vhosts/abc.xyz/ownCloud/lib;.;./includes;./pear;C:/Inetpub/vhosts/abc.xyz/ownCloud') in C:\Inetpub\vhosts\abc.xyz\ownCloud\settings\apps.php on line 24
#3 Comment posted by DjGL Nov 21, 12:43

I fixed both problems by replacing the findAppInDirectories funcion in /lib/apps.php with

protected static function findAppInDirectories($appid) {
static $app_dir = array();
if (isset($app_dir[$appid])) {
return $app_dir[$appid];
}
foreach(OC::$APPSROOTS as $dir) {
if(file_exists($dir['path'].'/'.$appid)) {
return $app_dir[$appid]=$dir;
}
}
if(file_exists(OC::$SERVERROOT.'/'.$appid))
return array('path'=>OC::$SERVERROOT,'url'=>OC::$WEBROOT);
return false;
}

If you still get errors in the settings you might also replace loadAppScriptFile in /lib/base.php with

protected static function loadAppScriptFile($app, $file) {
$app_path = OC_App::getAppPath($app);
$file = $app_path . '/' . $file;
unset($app, $app_path);
if (file_exists($file)) {
chdir(dirname($file));
require_once basename($file);
//require_once $file;
return true;
}
return false;
}

@VicDeo
Copy link
Member

VicDeo commented Dec 8, 2012

PHP Warning: require_once(): open_basedir restriction in effect. File(../lib/base.php) is not within the allowed path(s): (C:/Inetpub/vhosts/abc.xyz;C:\Windows\Temp)

Probably server is misconfigured
http://php.net/manual/en/ini.core.php#ini.open-basedir

C:/Inetpub/vhosts/abc.xyz;C:\Windows\Temp
should be
C:\Inetpub\vhosts\abc.xyz;C:\Windows\Temp
and C:\Inetpub\vhosts\abc.xyz\ should be exact folder where owncloud is installed (check abc.xyz for typos)

@karlitschek
Copy link
Contributor

Yes. The error message shows that php is not allowed to read the template directory. This can´t be fixed from within ownCloud and is a server configuration bug.

@japi
Copy link

japi commented Dec 10, 2012

Could you please reopen this Bug?
It is not a server configuation bug.
I have the same issue and the open_basedir restriction is set correctly.
Steps to reproduce:
0. (Using IIS8 on MS Windows Server 2012 with php 5.4.9)

  1. Set open_basedir to the owncloud root folder.
  2. Activate display_errors or look into the errorlog.
    Consequences:
    Around 4 error messages on every page.
    For example in \lib\l10n.php on line 302.
    301 // Check if the app is in the app folder
    302 if(file_exists(OC_App::getAppPath($app).'/l10n/')) {
    303     $i18ndir = OC_App::getAppPath($app).'/l10n/';
    304 }
    305 else{
    306     $i18ndir = OC::$SERVERROOT.'/'.$app.'/l10n/';
    307 }

I think everything works, although an error is shown, because of the code on line 306.

The function OC_App::getAppPath($app) seems to return nothing:

    Warning: file_exists(): open_basedir restriction in effect. File(/l10n/) is not within the allowed path(s): (C:\inetpub) in C:\inetpub\wwwroot\owncloud\lib\l10n.php on line 302

As you can see it tries to access "/l10n/" and not the correct path.

@VicDeo
Copy link
Member

VicDeo commented Dec 10, 2012

@japi Please post exact errors content here

@japi
Copy link

japi commented Dec 10, 2012

For example on the login page the following errors are displayed:
Above the ownCloud logo:

Warning: file_exists(): open_basedir restriction in effect. File(/templates/) is not within the allowed path(s): (C:\inetpub) in C:\inetpub\wwwroot\owncloud\lib\template.php on line 247

Below the login form:

Warning: file_exists(): open_basedir restriction in effect. File(/l10n/) is not within the allowed path(s): (C:\inetpub) in C:\inetpub\wwwroot\owncloud\lib\l10n.php on line 302

and

Warning: file_exists(): open_basedir restriction in effect. File(/l10n/) is not within the allowed path(s): (C:\inetpub) in C:\inetpub\wwwroot\owncloud\lib\l10n.php on line 302

(it is the same error, shown two times)

Edit:
I forgot to mention my php error reporting level. It's set to:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

@karlitschek
Copy link
Contributor

Can you please try to run it without open_basedir ?

@VicDeo
Copy link
Member

VicDeo commented Dec 10, 2012

@karlitschek OC_App::getAppPath($app) might return false if the app dir is not found.
https://github.com/owncloud/core/blob/stable45/lib/app.php#L374

So it should be reproducible if the app has entry in DB but has no files in app directories.
cc @eMerzh

@japi
Copy link

japi commented Dec 10, 2012

@karlitschek Sorry, i can't disable it. It is set via Fast-CGI parameter in my hosting environment. Deactivating it would most likely stop the warnings, but reducing security (even by a tiny bit like this) is not a good solution i think :-)

It is a vanilla ownCloud installation and although there are warnings it seems to work. I have not tested much yet, because this is the first day i am using it. I switched display_errors off, so the warnings don't break the layout. But this is only a workaround in my opinion.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants