From c3d4136918b74d3e884f07364f051462107ddb0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 Feb 2010 21:26:52 +0000 Subject: [PATCH] Fix: Bad mask --- htdocs/lib/files.lib.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/lib/files.lib.php b/htdocs/lib/files.lib.php index caa7e9f7c1f..77918285fa1 100644 --- a/htdocs/lib/files.lib.php +++ b/htdocs/lib/files.lib.php @@ -306,14 +306,19 @@ function dol_is_file($pathoffile) * Copy a file to another file * @param $srcfile Source file * @param $destfile Destination file - * @param $newmask Mask for new file + * @param $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK) * @return boolean True if OK, false if KO */ -function dol_copy($srcfile, $destfile, $newmask) +function dol_copy($srcfile, $destfile, $newmask=0) { + global $conf; + dol_syslog("files.lib.php::dol_copy srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask); $result=@copy($srcfile, $destfile); - @chmod($file, octdec($newmask)); // File must not be readable by any others + + if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; + @chmod($file, octdec($newmask)); + return $result; }