diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2010-11-30 14:08:25 -0500 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2010-11-30 14:08:25 -0500 |
commit | 00bc5bcc87a5e5f8aa7fc5e33973add703d688b4 (patch) | |
tree | dbcc0713d23f6476fc8e72314d3187d032602b4a /etc/inc | |
parent | a6e0e07bf1934f9e73d1a1bd8e99c91f7839e30f (diff) | |
download | pfsense-00bc5bcc87a5e5f8aa7fc5e33973add703d688b4.zip pfsense-00bc5bcc87a5e5f8aa7fc5e33973add703d688b4.tar.gz |
Call sync after writing the file and before returning to continue processing.
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/config.lib.inc | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc index b383921..2d51db7 100644 --- a/etc/inc/config.lib.inc +++ b/etc/inc/config.lib.inc @@ -433,27 +433,31 @@ function convert_config() { * boolean - true if successful, false if not ******/ function safe_write_file($file, $content, $force_binary) { - $tmp_file = $file . "." . getmypid(); - $write_mode = $force_binary ? "wb" : "w"; + $tmp_file = $file . "." . getmypid(); + $write_mode = $force_binary ? "wb" : "w"; - $fd = fopen($tmp_file, $write_mode); - if (!$fd) { - // Unable to open temporary file for writing - return false; - } - if (!fwrite($fd, $content)) { - // Unable to write to temporary file - fclose($fd); - return false; + $fd = fopen($tmp_file, $write_mode); + if (!$fd) { + // Unable to open temporary file for writing + return false; } - fclose($fd); + if (!fwrite($fd, $content)) { + // Unable to write to temporary file + fclose($fd); + return false; + } + fclose($fd); - if (!rename($tmp_file, $file)) { - // Unable to move temporary file to original - unlink($tmp_file); - return false; - } - return true; + if (!rename($tmp_file, $file)) { + // Unable to move temporary file to original + unlink($tmp_file); + return false; + } + + // Sync file before returning + exec("/bin/sync"); + + return true; } /****f* config/write_config |