Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Jan 2016 17:13:40 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r293240 - head/etc
Message-ID:  <201601061713.u06HDeTS032983@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Wed Jan  6 17:13:40 2016
New Revision: 293240
URL: https://svnweb.freebsd.org/changeset/base/293240

Log:
  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.

Modified:
  head/etc/rc

Modified: head/etc/rc
==============================================================================
--- head/etc/rc	Wed Jan  6 16:35:30 2016	(r293239)
+++ head/etc/rc	Wed Jan  6 17:13:40 2016	(r293240)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601061713.u06HDeTS032983>