summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-11-30 22:18:59 +0000
committerErmal <eri@pfsense.org>2010-11-30 22:18:59 +0000
commit628d1548f5be13df9a155133b82639e0dda6acb5 (patch)
tree252914bf3418f17f39ca5c2a9c41b5eea4c39c1f /etc/inc
parent65c5cec3e32245442377ea0134563a47850151ee (diff)
downloadpfsense-628d1548f5be13df9a155133b82639e0dda6acb5.zip
pfsense-628d1548f5be13df9a155133b82639e0dda6acb5.tar.gz
Do a fflush of file before closing and sync(2). Fix whitespace while here.
Diffstat (limited to 'etc/inc')
-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