Fix: Pb with config file backup

This commit is contained in:
Laurent Destailleur 2010-02-10 18:04:03 +00:00
parent 739e8941a2
commit c174229d64
2 changed files with 11 additions and 3 deletions

View File

@ -208,7 +208,9 @@ if ($_POST["action"] == "set")
// Save old conf file on disk
if (file_exists("$conffile"))
{
@dol_copy($conffile, $conffile.'.old'); // We must ignore errors as an existing old file may alreday exists and not be replacable
// We must ignore errors as an existing old file may alreday exists and not be replacable
// Also no other process must be able to read file or we expose the new file so content with password.
@dol_copy($conffile, $conffile.'.old', '0400');
}
$error+=write_conf_file($conffile);

View File

@ -304,11 +304,17 @@ 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
* @return boolean True if OK, false if KO
*/
function dol_copy($srcfile, $destfile)
function dol_copy($srcfile, $destfile, $newmask)
{
return @copy($srcfile, $destfile);
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
return $result;
}
?>