summaryrefslogtreecommitdiffstats
path: root/etc/rc
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2016-01-06 17:13:40 +0000
committerimp <imp@FreeBSD.org>2016-01-06 17:13:40 +0000
commit76cb3b35021b722f3e8330ec6ac0df444fdcc651 (patch)
treef791ad9573513eb26af99aa2eea9a39e58069e7a /etc/rc
parentfce5b67dc0d23e9c9a49c4d50ef0c66467f584e4 (diff)
downloadFreeBSD-src-76cb3b35021b722f3e8330ec6ac0df444fdcc651.zip
FreeBSD-src-76cb3b35021b722f3e8330ec6ac0df444fdcc651.tar.gz
Try a little harder to remove firstboot and firstboot-reboot files in
case they accidentally get created as directories or with flags that prevent their removal. While I wouldn't normally go the extra mile here and let the normal unix rules prevail, the effects of failure are large enough that extra care is warranted.
Diffstat (limited to 'etc/rc')
-rw-r--r--etc/rc10
1 files changed, 8 insertions, 2 deletions
diff --git a/etc/rc b/etc/rc
index 2127d78..576ddf9 100644
--- a/etc/rc
+++ b/etc/rc
@@ -130,11 +130,17 @@ for _rc_elem in ${files}; do
done
# Remove the firstboot sentinel, and reboot if it was requested.
+# Be a bit paranoid about removing it to handle the common failure
+# modes since the consequence of failure can be big.
+# Note: this assumes firstboot_sentinel is on / when we have
+# a read-only /, or that it is on media that's writable.
if [ -e ${firstboot_sentinel} ]; then
[ ${root_rw_mount} = "yes" ] || mount -uw /
- /bin/rm -f ${firstboot_sentinel}
+ chflags -R 0 ${firstboot_sentinel}
+ rm -rf ${firstboot_sentinel}
if [ -e ${firstboot_sentinel}-reboot ]; then
- /bin/rm -f ${firstboot_sentinel}-reboot
+ chflags -R 0 ${firstboot_sentinel}-reboot
+ rm -rf ${firstboot_sentinel}-reboot
[ ${root_rw_mount} = "yes" ] || mount -ur /
kill -INT 1
fi
OpenPOWER on IntegriCloud