diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2010-02-14 14:58:45 -0500 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2010-02-14 14:58:45 -0500 |
commit | 41bf8e8e9fec86518f904eb86d52e590f2828965 (patch) | |
tree | 840b74ecabff151bef29f94069b60b5151d7fbae /etc/inc/config.lib.inc | |
parent | fcbbdd850ff28dea780e43f7c8a85c128ec50260 (diff) | |
download | pfsense-41bf8e8e9fec86518f904eb86d52e590f2828965.zip pfsense-41bf8e8e9fec86518f904eb86d52e590f2828965.tar.gz |
Use safe_write_file() like RELENG_1_2 does. Not sure how this diverged?!
Diffstat (limited to 'etc/inc/config.lib.inc')
-rw-r--r-- | etc/inc/config.lib.inc | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc index ea0c206..cf8127d 100644 --- a/etc/inc/config.lib.inc +++ b/etc/inc/config.lib.inc @@ -457,26 +457,13 @@ function write_config($desc="Unknown", $backup = true) { conf_mount_rw(); - /* write new configuration to a .tmp file first and then move into place */ - $fd = fopen("{$g['conf_path']}/config.xml.tmp", "w"); - if (!$fd) { - // Unable to open temporary file for writing + /* write new configuration */ + if (!safe_write_file("{$g['cf_conf_path']}/config.xml", $xmlconfig, false)) { log_error("WARNING: Config contents could not be save. Could not open file!"); unlock($lockkey); - return false; - } - if (!fwrite($fd, $xmlconfig)) { - // Unable to write to temporary file - log_error("WARNING: Config contents could not be written on file."); - fclose($fd); - unlock($lockkey); - return false; + die("Unable to open {$g['cf_conf_path']}/config.xml for writing in write_config()\n"); } - fclose($fd); - - // Move completely written file into place - exec("/bin/mv {$g['conf_path']}/config.xml.tmp {$g['conf_path']}/config.xml"); - + if($g['platform'] == "embedded" or $g['platform'] == "nanobsd") { cleanup_backupcache(5, true); } else { |