diff options
author | Renato Botelho <renato@netgate.com> | 2016-10-14 08:46:42 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-10-14 08:49:43 -0300 |
commit | 952ff2cbf963088bea08e88f503a5afabd858f3a (patch) | |
tree | 96398f967e3aa1d7ac04e34553b29e11ab2dd147 /src/etc/inc/config.lib.inc | |
parent | e9c60f20dc64a09a495493725395dc023d858df9 (diff) | |
download | pfsense-952ff2cbf963088bea08e88f503a5afabd858f3a.zip pfsense-952ff2cbf963088bea08e88f503a5afabd858f3a.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.inc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/etc/inc/config.lib.inc b/src/etc/inc/config.lib.inc index 71df92a..e51dd0a 100644 --- a/src/etc/inc/config.lib.inc +++ b/src/etc/inc/config.lib.inc @@ -485,7 +485,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 @@ -500,7 +500,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; |