summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/inc/config.lib.inc41
1 files changed, 21 insertions, 20 deletions
diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc
index 0215ddc..d456064 100644
--- a/etc/inc/config.lib.inc
+++ b/etc/inc/config.lib.inc
@@ -433,31 +433,32 @@ 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;
+ $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;
- }
+ if (!fwrite($fd, $content)) {
+ // Unable to write to temporary file
fclose($fd);
+ return false;
+ }
+ fflush($fd);
+ fclose($fd);
- if (!rename($tmp_file, $file)) {
- // Unable to move temporary file to original
- unlink($tmp_file);
- return false;
- }
+ if (!rename($tmp_file, $file)) {
+ // Unable to move temporary file to original
+ @unlink($tmp_file);
+ return false;
+ }
- // Sync file before returning
- pfSense_sync();
+ // Sync file before returning
+ pfSense_sync();
- return true;
+ return true;
}
/****f* config/write_config
@@ -839,4 +840,4 @@ function set_device_perms() {
}
}
-?> \ No newline at end of file
+?>
OpenPOWER on IntegriCloud