summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/config.lib.inc
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-10-14 08:46:42 -0300
committerRenato Botelho <renato@netgate.com>2016-10-14 08:51:55 -0300
commit406ced776ecf8c1a6017b7a3df1bf079c8467863 (patch)
tree31cc85abb319054fd856c81a82c24b4e01989903 /src/etc/inc/config.lib.inc
parente717f1617331545a72a075fc05eb50781b6ab63e (diff)
downloadpfsense-406ced776ecf8c1a6017b7a3df1bf079c8467863.zip
pfsense-406ced776ecf8c1a6017b7a3df1bf079c8467863.tar.gz
Change safe_write_file $content parameter to accept an array
Diffstat (limited to 'src/etc/inc/config.lib.inc')
-rw-r--r--src/etc/inc/config.lib.inc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/etc/inc/config.lib.inc b/src/etc/inc/config.lib.inc
index 49790d1..2971c4a 100644
--- a/src/etc/inc/config.lib.inc
+++ b/src/etc/inc/config.lib.inc
@@ -384,7 +384,7 @@ function convert_config() {
* process, them renaming the temporary file over the original.
* INPUTS
* $filename - string containing the filename of the file to write
- * $content - string containing the file content to write to file
+ * $content - string or array containing the file content to write to file
* $force_binary - boolean denoting whether we should force binary
* mode writing.
* RESULT
@@ -399,7 +399,15 @@ function safe_write_file($file, $content, $force_binary = false) {
// Unable to open temporary file for writing
return false;
}
- if (!fwrite($fd, $content)) {
+ if (is_array($content)) {
+ foreach ($content as $line) {
+ if (!fwrite($fd, $line . "\n")) {
+ // Unable to write to temporary file
+ fclose($fd);
+ return false;
+ }
+ }
+ } elseif (!fwrite($fd, $content)) {
// Unable to write to temporary file
fclose($fd);
return false;
OpenPOWER on IntegriCloud