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.
This commit is contained in:
Warner Losh 2016-01-06 17:13:40 +00:00
parent 353e5e6e30
commit 3e972f4409

10
etc/rc
View File

@ -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