diff options
author | Troels Liebe Bentsen <tlb@rapanden.dk> | 2006-02-24 22:16:55 +0100 |
---|---|---|
committer | Troels Liebe Bentsen <tlb@rapanden.dk> | 2006-02-24 22:16:55 +0100 |
commit | 44881d272282937c9bb745f462c947319d404dd0 (patch) | |
tree | 186d932116e04b1271ad22a3bd628d6617a49c49 /inc/init.php | |
parent | b687885519897ab2959bb0540ec822b96f722fd6 (diff) | |
download | rpg-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/init.php')
-rw-r--r-- | inc/init.php | 34 |
1 files changed, 30 insertions, 4 deletions
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']); } } } } |