[Bug 283729] sysrc destroys rc.conf if given easily-typo'd bad input
Date: Sun, 29 Dec 2024 21:01:48 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=283729 --- Comment #1 from Bill Cole <freebsdbugz-20241229@billmail.scconsult.com> --- Accidentally embedding a linefeed in a variable setting crashes awk and leaves /etc/rc.conf with only the (BAD) new setting. Here's a transcript example: [root@shinyghost ~]# sysrc -a clamav_clamd_enable: YES clamav_freshclam_enable: YES dovecot_enable: YES firewall_enable: YES firewall_type: /etc/ipfw.rules growfs_enable: YES ifconfig_em0: inet 192.168.254.17 netmask 255.255.255.0 ifconfig_em0_alias0: inet 192.168.254.22 netmask 255.255.255.255 ifconfig_em0_alias1: inet 192.168.254.26 netmask 255.255.255.255 ifconfig_em0_alias2: inet 192.168.254.72 netmask 255.255.255.255 ifconfig_em0_alias3: inet 192.168.254.100 netmask 255.255.255.255 ifconfig_em0_alias4: inet 192.168.254.111 netmask 255.255.255.255 ipfw_enable: YES named_enable: YES nfsv4_server_enable: YES postfix_enable: YES sshd_enable: YES [root@shinyghost ~]# sysrc nfsv4_server_enable="YES " awk: newline in string YES ... at source line 1t nfsv4_server_enable: YES -> YES [root@shinyghost ~]# sysrc -a nfsv4_server_enable: YES [root@shinyghost ~]# cat /etc/rc.conf nfsv4_server_enable="YES " I know that what I'd do is replace any linefeeds in a setting value with spaces on the input side, and on the output side do all writing of the new rc.conf to a tempfile and then do size sanity checking of it before renaming it into place. As a nice side-effect, the change of rc.conf would then be atomic. -- You are receiving this mail because: You are the assignee for the bug.