diff options
author | Renato Botelho <renato@netgate.com> | 2016-10-14 08:46:42 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-10-14 09:05:44 -0300 |
commit | 1a6cb937c7841ade46b188c6c33cd40220833939 (patch) | |
tree | 502096a2b1f0b981d07c3652107fe27b1b8190d6 /src | |
parent | a942d5b2100f55f83ac1cdd30e04d710cd378399 (diff) | |
download | pfsense-1a6cb937c7841ade46b188c6c33cd40220833939.zip pfsense-1a6cb937c7841ade46b188c6c33cd40220833939.tar.gz |
Change safe_write_file $content parameter to accept an array
Diffstat (limited to 'src')
-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 1b2cc32..28a7a36 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; |