Make sure temporary config file is safe on disk before rename, ticket #4803

This commit is contained in:
Renato Botelho 2015-07-06 13:51:45 -03:00
parent bee2f2476c
commit a83602e84a

View File

@ -486,7 +486,7 @@ function safe_write_file($file, $content, $force_binary) {
fflush($fd);
fclose($fd);
if (!rename($tmp_file, $file)) {
if (!pfSense_fsync($tmp_file) || !rename($tmp_file, $file)) {
// Unable to move temporary file to original
@unlink($tmp_file);
return false;