Hey List!

First of all: ownCloud seems to be awesome at the first glance! :)

I just configured ownCloud in a shared webhosting environment and a minor 
problem occured.
On this server, every user got its own UserDir[1] what seems to confuse 
ownCloud.

First, I got an error because of an open_basedir restriction:
To set the OC::$DOCUMENTROOT you use realpath() what tries to open 
$_SERVER['DOCUMENT_ROOT'] what is outside the allowed paths for PHP since my 
scripts are in my UserDir (!= $_SERVER['DOCUMENT_ROOT']).
This is known PHP behaviour and the PHP folks are - with good reasons - not 
willing to change this [2].

Then, while reading lib/base.php, I found a substr() call that was used to 
traverse upwards in a directory using hardcoded value for the string leth of 
"lib/base.php". Well... :) This is an aesthetic flaw.

Without knowing anything (!) about the code of ownCloud, I changed these two 
issues for my installation and everything seems to work. I assume that these 
two things do *not* have a specific reason to be done like this.
See attached patches.

By the way: I did not try this with/did not apply this on the webfinger app but 
it seems to have a very similar detection for the $DOCUMENTROOT.

Regards,

Lukas Pirl

[1] http://httpd.apache.org/docs/2.0/mod/mod_userdir.html
[2] https://issues.apache.org/bugzilla/show_bug.cgi?id=26052
--- owncloud.orig/lib/base.php	2012-01-29 14:50:19.000000000 +0100
+++ owncloud/lib/base.php	2012-02-10 14:40:59.867313951 +0100
@@ -127,7 +127,7 @@
 
 		// calculate the documentroot
 		OC::$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
-		OC::$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-13));
+		OC::$SERVERROOT=str_replace("\\",'/',realpath(dirname(__FILE__)."/.."));
 		OC::$SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen(OC::$SERVERROOT));
 		$scriptName=$_SERVER["SCRIPT_NAME"];
 		if(substr($scriptName,-1)=='/'){
--- owncloud.orig/lib/base.php	2012-01-29 14:50:19.000000000 +0100
+++ owncloud/lib/base.php	2012-02-10 14:43:41.935318101 +0100
@@ -31,10 +31,6 @@
 	 */
 	public static $CLASSPATH = array();
 	/**
-	 * $_SERVER['DOCUMENTROOT'] but without symlinks
-	 */
-	public static $DOCUMENTROOT = '';
-	/**
 	 * The installation path for owncloud on the server (e.g. /srv/http/owncloud)
 	 */
 	public static $SERVERROOT = '';
@@ -125,8 +121,7 @@
 			$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
 		}
 
-		// calculate the documentroot
-		OC::$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
+		// calculate the root directories
 		OC::$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-13));
 		OC::$SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen(OC::$SERVERROOT));
 		$scriptName=$_SERVER["SCRIPT_NAME"];
_______________________________________________
Owncloud mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/owncloud

Reply via email to