Setting a variable to a value containing a newline, e.g.
sysrc foo_enable="YES<newline>", destroyed the configuration file.
When the variable already existed, awk(1) aborted with "newline in
string" and printed nothing. The non-zero exit status was taken as
"append the assignment instead", so the empty output was written to
the temporary file along with the new setting. Since a quoted string
spanning two lines is valid sh(1) the syntax check passed and the
result replaced the file. When the variable did not exist, the
multi-line value was appended as is.
Refuse such values in f_sysrc_set() before touching any file. Also
only treat awk(1) exit status 1, which means "append", as such and
abort without replacing the file on any other failure.
Added a test case.
PR: 283729
Reported by: Bill Cole <freebsdbugz-20241229@billmail.scconsult.com>
Signed-off-by: Kushagra Chauhan <zenzesama@gmail.com>