Bug 12976

Summary: No backup init(8) kept during installworld
Product: Base System Reporter: Peter Jeremy <jeremyp>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-CURRENT   
Hardware: Any   
OS: Any   

Description Peter Jeremy 1999-08-04 23:50:01 UTC
	init(8) is a critical part of the system startup - if no
	suitable init can be found, the kernel will panic.  It's
	also the only critical file which is automatically updated
	during an installworld without any backup being kept.

	When a new kernel is installed, the current kernel is kept as
	/kernel.old.  Similarly, the old /boot/loader is kept as
	/boot/loader.old.  Whilst /bin/sh is not backed up, /bin/csh
	and /stand/sh (the latter is unaffected by installworld) are
	available as alternatives.  [If wanted, something very similar
	to the patch below should also apply to /src/bin/sh/Makefile].

	During startup, the kernel will scan a range of pathnames
	(/sbin/init, /sbin/oinit, /sbin/init.bak, /stand/sysinstall
	by default), and this can be over-ridden from /boot/loader
	with the init_path environment variable.

	It therefore seems reasonable to save the existing (working)
	init in case the new one is faulty in some way.

Fix: 

--
Peter Jeremy (VK2PJ)                    peter.jeremy@alcatel.com.au
Alcatel Australia Limited
41 Mandible St                          Phone: +61 2 9690 5019
ALEXANDRIA  NSW  2015                   Fax:   +61 2 9690 5982--81C27L1t9vly05r0S6gBk4ugLvucLtUiDgQW73sx6GhwF0O5
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

Index: Makefile
===================================================================
RCS file: /home/CVSROOT/./src/sbin/init/Makefile,v
retrieving revision 1.17
diff -u -r1.17 Makefile
--- Makefile	1999/07/01 13:33:56	1.17
+++ Makefile	1999/08/04 22:22:54
@@ -33,3 +33,10 @@
 .endif
 
 .endif
+
+# Backup existing /sbin/init as /sbin/oinit in case the new one blows up
+.if exists(${DESTDIR}${BINDIR}/${PROG})
+beforeinstall:
+	-chflags noschg ${DESTDIR}${BINDIR}/${PROG}
+	mv ${DESTDIR}${BINDIR}/${PROG} ${DESTDIR}${BINDIR}/o${PROG}
+.endif
How-To-Repeat: 
	Code inspection.
	cd .../src/sbin/init; make install
Comment 1 ru freebsd_committer freebsd_triage 1999-08-05 10:14:31 UTC
State Changed
From-To: open->closed

Committed, thanks!