Skip to content
Snippets Groups Projects
Commit c174229d authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Pb with config file backup

parent 739e8941
No related branches found
No related tags found
No related merge requests found
...@@ -208,7 +208,9 @@ if ($_POST["action"] == "set") ...@@ -208,7 +208,9 @@ if ($_POST["action"] == "set")
// Save old conf file on disk // Save old conf file on disk
if (file_exists("$conffile")) 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); $error+=write_conf_file($conffile);
......
...@@ -304,11 +304,17 @@ function dol_is_file($pathoffile) ...@@ -304,11 +304,17 @@ function dol_is_file($pathoffile)
/** /**
* Copy a file to another file * 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 * @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;
} }
?> ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment