diff options
author | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2024-07-08 14:32:45 +0000 |
---|---|---|
committer | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2024-07-08 14:32:45 +0000 |
commit | 83f2bf439331afbe60d1d5f1c4617b812d1c2a98 (patch) | |
tree | d2e6486d460ab404bbe3246c4ef68de7679697d0 /usr.sbin | |
parent | d3a185f333ab3c4216f6e5727907c56cc3a83b63 (diff) |
Prevent rewriting /etc/rc.conf.local unconditionnally. Compare the new and old
ones and do nothing is they match.
This mean that "rcctl enable foobar" will not touch anything is foobar is
already enabled.
spotted by robert@ using Saltstack (that runs "rcctl enable ..." on a regular
basis).
ok robert@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/rcctl/rcctl.sh | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/rcctl/rcctl.sh b/usr.sbin/rcctl/rcctl.sh index eda191fae7d..56ee8cb173d 100644 --- a/usr.sbin/rcctl/rcctl.sh +++ b/usr.sbin/rcctl/rcctl.sh @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: rcctl.sh,v 1.117 2023/07/13 13:54:27 ajacoutot Exp $ +# $OpenBSD: rcctl.sh,v 1.118 2024/07/08 14:32:44 ajacoutot Exp $ # # Copyright (c) 2014, 2015-2022 Antoine Jacoutot <ajacoutot@openbsd.org> # Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -127,8 +127,10 @@ rcconf_edit_end() { sort -u -o ${_TMP_RCCONF} ${_TMP_RCCONF} || \ rcctl_err "cannot modify ${_TMP_RCCONF}" - cat ${_TMP_RCCONF} >/etc/rc.conf.local || \ - rcctl_err "cannot append to /etc/rc.conf.local" + if ! cmp -s ${_TMP_RCCONF} /etc/rc.conf.local; then + cat ${_TMP_RCCONF} >/etc/rc.conf.local || \ + rcctl_err "cannot write to /etc/rc.conf.local" + fi if [ ! -s /etc/rc.conf.local ]; then rm /etc/rc.conf.local || \ rcctl_err "cannot remove /etc/rc.conf.local" |