summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/common.php2
-rw-r--r--inc/init.php34
-rw-r--r--inc/io.php18
3 files changed, 39 insertions, 15 deletions
diff --git a/inc/common.php b/inc/common.php
index ef36593ab..cef8a0ab0 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -810,7 +810,6 @@ function getRevisionInfo($id,$rev){
function saveWikiText($id,$text,$summary,$minor=false){
global $conf;
global $lang;
- umask($conf['umask']);
// ignore if no changes were made
if($text == rawWiki($id,'')){
return;
@@ -857,7 +856,6 @@ function saveWikiText($id,$text,$summary,$minor=false){
*/
function saveOldRevision($id){
global $conf;
- umask($conf['umask']);
$oldf = wikiFN($id);
if(!@file_exists($oldf)) return '';
$date = filemtime($oldf);
diff --git a/inc/init.php b/inc/init.php
index a81ca2d10..855096bae 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -76,8 +76,35 @@
$conf['usegzip'] = 0;
}
- // remember original umask
- $conf['oldumask'] = umask();
+ // Legacy support for old umask/dmask scheme
+ if(isset($conf['dmask'])) {
+ unset($conf['dmask']);
+ unset($conf['fmask']);
+ unset($conf['umask']);
+ }
+
+ // Set defaults for fmode, dmode and umask.
+ if(!isset($conf['fmode'])) {
+ $conf['fmode'] = 0666;
+ }
+ if(!isset($conf['dmode'])) {
+ $conf['dmode'] = 0777;
+ }
+ if(!isset($conf['umask'])) {
+ $conf['umask'] = umask();
+ }
+
+ // Precalculate the fmask and dmask, so we can set later.
+ if(($conf['umask'] != umask()) or ($conf['fmode'] != 0666)) {
+ $conf['fmask'] = $conf['fmode'] & ~$conf['umask'];
+ }
+ if(($conf['umask'] != umask()) or ($conf['dmode'] != 0666)) {
+ $conf['dmask'] = $conf['dmode'] & ~$conf['umask'];
+ }
+# print "$name:".sprintf("dmask:%04o<br>\n",$conf['dmode'])."\n";
+# print "$name:".sprintf("umask:%04o<br>\n",$conf['umask'])."\n";
+# print "$name:".sprintf("dmask:%04o<br>\n",$conf['dmask'])."\n";
+# exit;
// make real paths and check them
init_paths();
@@ -118,12 +145,11 @@ function init_files(){
$conf['cachedir'].'/page.idx',
$conf['cachedir'].'/index.idx', );
- umask($conf['umask']);
foreach($files as $file){
if(!@file_exists($file)){
$fh = fopen($file,'a');
fclose($fh);
- chmod($conf['fmode'], $file);
+ if(isset($conf['fmask'])) { chmod($file, $conf['fmask']); }
}
}
}
diff --git a/inc/io.php b/inc/io.php
index 3e13124de..bf8bc903c 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -88,7 +88,7 @@ function io_saveFile($file,$content,$append=false){
fclose($fh);
}
- if(!$fileexists && $conf['fmode'] != 0666) { chmod($file, $conf['fmode']); }
+ if(!$fileexists and isset($conf['fmask'])) { chmod($file, $conf['fmask']); }
io_unlock($file);
return true;
}
@@ -178,7 +178,8 @@ function io_lock($file){
do {
//waited longer than 3 seconds? -> stale lock
if ((time() - $timeStart) > 3) break;
- $locked = @mkdir($lockDir);
+ $locked = @mkdir($lockDir, $conf['dmode']);
+ if($locked and isset($conf['dmask'])) { chmod($lockDir, $conf['dmask']); }
} while ($locked === false);
}
@@ -206,7 +207,6 @@ function io_makeFileDir($file){
global $conf;
$dir = dirname($file);
- umask($conf['umask']);
if(!is_dir($dir)){
io_mkdir_p($dir) || msg("Creating directory $dir failed",-1);
}
@@ -229,7 +229,9 @@ function io_mkdir_p($target){
$dir = preg_replace('/^'.preg_quote(realpath($conf['ftp']['root']),'/').'/','', $target);
return io_mkdir_ftp($dir);
}else{
- return @mkdir($target,$conf['dmode']); // crawl back up & create dir tree
+ $ret = @mkdir($target,$conf['dmode']); // crawl back up & create dir tree
+ if($ret and isset($conf['dmask'])) { chmod($target, $conf['dmask']); }
+ return $ret;
}
}
return 0;
@@ -264,7 +266,7 @@ function io_mkdir_ftp($dir){
//create directory
$ok = @ftp_mkdir($conn, $dir);
//set permissions (using the directory umask and dmode)
- @ftp_site($conn,sprintf("CHMOD %04o %s",($conf['dmode'] & ~$conf['umask']),$dir));
+ @ftp_site($conn,sprintf("CHMOD %04o %s",$conf['dmask'],$dir));
@ftp_close($conn);
return $ok;
@@ -315,12 +317,11 @@ function io_download($url,$file,$useAttachment=false,$defaultName=''){
}
$fileexists = file_exists($file);
- umask($conf['umask']);
$fp = @fopen($file,"w");
if(!$fp) return false;
fwrite($fp,$data);
fclose($fp);
- if(!$fileexists && $conf['fmode'] != 0666) { chmod($file, $conf['fmode']); }
+ if(!$fileexists and isset($conf['fmask'])) { chmod($file, $conf['fmask']); }
if ($useAttachment) return $name;
return true;
}
@@ -335,7 +336,7 @@ function io_rename($from,$to){
global $conf;
if(!@rename($from,$to)){
if(@copy($from,$to)){
- if($conf['fmode'] != 0666) { chmod($file, $conf['fmode']); }
+ if(isset($conf['fmask'])) { chmod($file, $conf['fmask']); }
@unlink($from);
return true;
}
@@ -363,5 +364,4 @@ function io_runcmd($cmd){
return $ret;
}
-
//Setup VIM: ex: et ts=2 enc=utf-8 :