From 323e2210c30a681fd681781e9308ba567d02fa22 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Fri, 4 Jun 2010 05:50:23 +0000 Subject: [PATCH] - don't create absolut paths additionally as relative paths in customers docroot, fixes #259 --- .../function.mkDirWithCorrectOwnership.php | 30 ++++++++++++------- .../jobs/cron_tasks.inc.http.10.apache.php | 2 +- .../jobs/cron_tasks.inc.http.20.lighttpd.php | 2 +- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/functions/filedir/function.mkDirWithCorrectOwnership.php b/lib/functions/filedir/function.mkDirWithCorrectOwnership.php index ee8299d4..a0669e05 100644 --- a/lib/functions/filedir/function.mkDirWithCorrectOwnership.php +++ b/lib/functions/filedir/function.mkDirWithCorrectOwnership.php @@ -27,6 +27,7 @@ * @param int The uid of the user * @param int The gid of the user * @param bool Place standard-index.html into the new folder + * @param bool Allow creating a directory out of the customers docroot * * @return bool true if everything went okay, false if something went wrong * @@ -34,7 +35,7 @@ * @author Martin Burchert */ -function mkDirWithCorrectOwnership($homeDir, $dirToCreate, $uid, $gid, $placeindex = false) +function mkDirWithCorrectOwnership($homeDir, $dirToCreate, $uid, $gid, $placeindex = false, $allow_notwithinhomedir = false) { $returncode = true; @@ -47,24 +48,33 @@ function mkDirWithCorrectOwnership($homeDir, $dirToCreate, $uid, $gid, $placeind if(substr($dirToCreate, 0, strlen($homeDir)) == $homeDir) { $subdir = substr($dirToCreate, strlen($homeDir)); + $within_homedir = true; } else { $subdir = $dirToCreate; + $within_homedir = false; } $subdir = makeCorrectDir($subdir); - $subdirlen = strlen($subdir); - $subdirs = array(); - array_push($subdirs, $dirToCreate); - $offset = 0; + $subdirs = array(); - while($offset < $subdirlen) + if($within_homedir || !$allow_notwithinhomedir) { - $offset = strpos($subdir, '/', $offset); - $subdirelem = substr($subdir, 0, $offset); - $offset++; - array_push($subdirs, makeCorrectDir($homeDir . $subdirelem)); + $subdirlen = strlen($subdir); + $offset = 0; + + while($offset < $subdirlen) + { + $offset = strpos($subdir, '/', $offset); + $subdirelem = substr($subdir, 0, $offset); + $offset++; + array_push($subdirs, makeCorrectDir($homeDir . $subdirelem)); + } + } + else + { + array_push($subdirs, $dirToCreate); } $subdirs = array_unique($subdirs); diff --git a/scripts/jobs/cron_tasks.inc.http.10.apache.php b/scripts/jobs/cron_tasks.inc.http.10.apache.php index df8c8fd3..e0c3752f 100644 --- a/scripts/jobs/cron_tasks.inc.http.10.apache.php +++ b/scripts/jobs/cron_tasks.inc.http.10.apache.php @@ -677,7 +677,7 @@ class apache } } - mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true); + mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true); $vhost_content.= $this->getWebroot($domain); $vhost_content.= $this->composePhpOptions($domain); $vhost_content.= $this->getStats($domain); diff --git a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php index 5ffa7ef1..8067219f 100644 --- a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php +++ b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php @@ -368,7 +368,7 @@ class lighttpd } else { - mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true); + mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true); $vhost_content.= $this->getWebroot($domain, $ssl_vhost); $vhost_content.= $this->create_htaccess($domain);