summaryrefslogtreecommitdiff
path: root/inc/io.php
diff options
context:
space:
mode:
authorTroels Liebe Bentsen <tlb@rapanden.dk>2006-02-24 22:16:55 +0100
committerTroels Liebe Bentsen <tlb@rapanden.dk>2006-02-24 22:16:55 +0100
commit44881d272282937c9bb745f462c947319d404dd0 (patch)
tree186d932116e04b1271ad22a3bd628d6617a49c49 /inc/io.php
parentb687885519897ab2959bb0540ec822b96f722fd6 (diff)
downloadrpg-44881d272282937c9bb745f462c947319d404dd0.tar.gz
rpg-44881d272282937c9bb745f462c947319d404dd0.tar.bz2
Fix umask bug and do a code cleanup of chmod/mkdir usage so set the correct permissions, this should also fix problems with dokuwiki making setuid files on some umasks.
* Don't set the umask() anymore, this is not good form and we don't really know what is it in the old code anyway as it was not done properly. * Retire the dmask config option introduce 2 new ones called fmode and dmode, this is more in line with posix and should make more sense. * Use chmod for setting the correct permissions but only if it's needed. * Set changing of permissions off by default as i should work properly in most Apache setups without and it does not make sense on windows anyway. darcs-hash:20060224211655-ee6b9-68f7bb59417d6f0033cfd3764146923daa4dcf1b.gz
Diffstat (limited to 'inc/io.php')
-rw-r--r--inc/io.php18
1 files changed, 9 insertions, 9 deletions
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 :