summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2013-01-12 23:35:13 -0500
committerMichael Gapczynski <mtgap@owncloud.com>2013-01-12 23:35:13 -0500
commitebcf41b420d3cd2f013b1b834b3c55d31c39041f (patch)
tree99a251630b271cde4ab72d599127a0b367a2c076
parent981fd5e4249d6bda0f8a06d86055ede896cdc9da (diff)
downloadnextcloud-server-ebcf41b420d3cd2f013b1b834b3c55d31c39041f.tar.gz
nextcloud-server-ebcf41b420d3cd2f013b1b834b3c55d31c39041f.zip
Move data directory permission checks after data directory existence checks
-rwxr-xr-xlib/util.php57
1 files changed, 28 insertions, 29 deletions
diff --git a/lib/util.php b/lib/util.php
index 7b1de094ead..bc8d22a9e92 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -207,35 +207,7 @@ class OC_Util {
in owncloud or disabling the appstore in the config file.");
}
}
-
$CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
- //check for correct file permissions
- if(!stristr(PHP_OS, 'WIN')) {
- $permissionsModHint="Please change the permissions to 0770 so that the directory cannot be listed by other users.";
- $prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY)), -3);
- if(substr($prems, -1)!='0') {
- OC_Helper::chmodr($CONFIG_DATADIRECTORY, 0770);
- clearstatcache();
- $prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY)), -3);
- if(substr($prems, 2, 1)!='0') {
- $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') is readable for other users<br/>', 'hint'=>$permissionsModHint);
- }
- }
- if( OC_Config::getValue( "enablebackup", false )) {
- $CONFIG_BACKUPDIRECTORY = OC_Config::getValue( "backupdirectory", OC::$SERVERROOT."/backup" );
- $prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3);
- if(substr($prems, -1)!='0') {
- OC_Helper::chmodr($CONFIG_BACKUPDIRECTORY, 0770);
- clearstatcache();
- $prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3);
- if(substr($prems, 2, 1)!='0') {
- $errors[]=array('error'=>'Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable for other users<br/>', 'hint'=>$permissionsModHint);
- }
- }
- }
- }else{
- //TODO: permissions checks for windows hosts
- }
// Create root dir.
if(!is_dir($CONFIG_DATADIRECTORY)) {
$success=@mkdir($CONFIG_DATADIRECTORY);
@@ -244,8 +216,35 @@ class OC_Util {
}
} else if(!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) {
$errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') not writable by ownCloud<br/>', 'hint'=>$permissionsHint);
+ } else {
+ //check for correct file permissions
+ if(!stristr(PHP_OS, 'WIN')) {
+ $permissionsModHint="Please change the permissions to 0770 so that the directory cannot be listed by other users.";
+ $prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY)), -3);
+ if(substr($prems, -1)!='0') {
+ OC_Helper::chmodr($CONFIG_DATADIRECTORY, 0770);
+ clearstatcache();
+ $prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY)), -3);
+ if(substr($prems, 2, 1)!='0') {
+ $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') is readable for other users<br/>', 'hint'=>$permissionsModHint);
+ }
+ }
+ if( OC_Config::getValue( "enablebackup", false )) {
+ $CONFIG_BACKUPDIRECTORY = OC_Config::getValue( "backupdirectory", OC::$SERVERROOT."/backup" );
+ $prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3);
+ if(substr($prems, -1)!='0') {
+ OC_Helper::chmodr($CONFIG_BACKUPDIRECTORY, 0770);
+ clearstatcache();
+ $prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3);
+ if(substr($prems, 2, 1)!='0') {
+ $errors[]=array('error'=>'Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable for other users<br/>', 'hint'=>$permissionsModHint);
+ }
+ }
+ }
+ } else {
+ //TODO: permissions checks for windows hosts
+ }
}
-
// check if all required php modules are present
if(!class_exists('ZipArchive')) {
$errors[]=array('error'=>'PHP module zip not installed.<br/>', 'hint'=>'Please ask your server administrator to install the module.');