summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorChris Buechler <cmb@pfsense.org>2015-07-10 18:12:09 -0500
committerChris Buechler <cmb@pfsense.org>2015-07-10 18:12:09 -0500
commit4171affc8548bd98295f915f60d7eca2dc4f27b4 (patch)
tree80a3896ac8050326a21c5cd4838bb8291b4e63d7 /etc/inc
parent601ba5427ac6cd8fb91614262d139cb7303ec4c5 (diff)
downloadpfsense-4171affc8548bd98295f915f60d7eca2dc4f27b4.zip
pfsense-4171affc8548bd98295f915f60d7eca2dc4f27b4.tar.gz
fsync after fclose here, clean up some white space while here.
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/config.lib.inc48
1 files changed, 27 insertions, 21 deletions
diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc
index d5274c1..19e8401 100644
--- a/etc/inc/config.lib.inc
+++ b/etc/inc/config.lib.inc
@@ -78,6 +78,7 @@ function encrypted_configxml() {
exec("/bin/mv {$g['conf_path']}/config.xml.tmp {$g['conf_path']}/config.xml");
echo "\n" . gettext("Config.xml unlocked.") . "\n";
fclose($fp);
+ pfSense_fsync("{$g['conf_path']}/config.xml");
} else {
echo "\n" . gettext("Invalid password entered. Please try again.") . "\n";
}
@@ -179,12 +180,15 @@ function generate_config_cache($config) {
$configcache = fopen($g['tmp_path'] . '/config.cache', "w");
fwrite($configcache, serialize($config));
fclose($configcache);
+ pfSense_fsync($configcache);
+
unset($configcache);
/* Used for config.extra.xml */
if(file_exists($g['tmp_path'] . '/config.extra.cache') && $config_extra) {
$configcacheextra = fopen($g['tmp_path'] . '/config.extra.cache', "w");
fwrite($configcacheextra, serialize($config_extra));
- fclose($configcacheextra);
+ fclose($configcacheextra);
+ pfSense_fsync($configcacheextra);
unset($configcacheextra);
}
}
@@ -475,7 +479,7 @@ function safe_write_file($file, $content, $force_binary) {
}
// Sync file before returning
- return pfSense_fsync(dirname($file));
+ return pfSense_fsync($file);
}
/****f* config/write_config
@@ -791,6 +795,7 @@ function cleanup_backupcache($lock = false) {
$bakout = fopen($g['cf_conf_path'] . '/backup/backup.cache', "w");
fwrite($bakout, serialize($tocache));
fclose($bakout);
+ pfSense_fsync("{$g['cf_conf_path']}/backup/backup.cache");
conf_mount_ro();
if (!$lock)
@@ -824,30 +829,31 @@ function backup_config() {
/* Create backup directory if needed */
safe_mkdir("{$g['cf_conf_path']}/backup");
-
- if($config['revision']['time'] == "") {
- $baktime = 0;
- } else {
- $baktime = $config['revision']['time'];
- }
- if($config['revision']['description'] == "") {
- $bakdesc = "Unknown";
- } else {
- $bakdesc = $config['revision']['description'];
- }
+
+ if($config['revision']['time'] == "") {
+ $baktime = 0;
+ } else {
+ $baktime = $config['revision']['time'];
+ }
+ if($config['revision']['description'] == "") {
+ $bakdesc = "Unknown";
+ } else {
+ $bakdesc = $config['revision']['description'];
+ }
$bakver = ($config['version'] == "") ? "?" : $config['version'];
$bakfilename = $g['cf_conf_path'] . '/backup/config-' . $baktime . '.xml';
copy($g['cf_conf_path'] . '/config.xml', $bakfilename);
- if(file_exists($g['cf_conf_path'] . '/backup/backup.cache')) {
- $backupcache = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache'));
- } else {
- $backupcache = array();
- }
+ if(file_exists($g['cf_conf_path'] . '/backup/backup.cache')) {
+ $backupcache = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache'));
+ } else {
+ $backupcache = array();
+ }
$backupcache[$baktime] = array('description' => $bakdesc, 'version' => $bakver, 'filesize' => filesize($bakfilename));
- $bakout = fopen($g['cf_conf_path'] . '/backup/backup.cache', "w");
- fwrite($bakout, serialize($backupcache));
- fclose($bakout);
+ $bakout = fopen($g['cf_conf_path'] . '/backup/backup.cache', "w");
+ fwrite($bakout, serialize($backupcache));
+ fclose($bakout);
+ pfSense_fsync("{$g['cf_conf_path']}/backup/backup.cache");
conf_mount_ro();
OpenPOWER on IntegriCloud