[Pkg-sysvinit-devel] Bug#697002: [PATCH initramfs-tools 2/5] init: Fix validation of the real init program

Ben Hutchings ben at decadent.org.uk
Mon Sep 29 00:46:24 UTC 2014


If /sbin/init is executable then we would ignore that $init was
invalid, without actually setting init=/sbin/init.

$init is initialised to /sbin/init, so don't skip the error
message if it's empty.

Related-to: #763157
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
 init | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/init b/init
index 05394c2..b47bf7a 100755
--- a/init
+++ b/init
@@ -242,25 +242,16 @@ validate_init() {
 	fi
 }
 
-# Check init bootarg
-if [ -n "${init}" ]; then
-	if ! validate_init "$init"; then
-		echo "Target filesystem doesn't have requested ${init}."
-		init=
-	fi
-fi
-
-# Common case: /sbin/init is present
-if [ ! -x "${rootmnt}/sbin/init" ]; then
-	# ... if it's not available search for valid init
-	if [ -z "${init}" ] ; then
-		for inittest in /sbin/init /etc/init /bin/init /bin/sh; do
-			if validate_init "${inittest}"; then
-				init="$inittest"
-				break
-			fi
-		done
-	fi
+# Check init is really there
+if ! validate_init "$init"; then
+	echo "Target filesystem doesn't have requested ${init}."
+	init=
+	for inittest in /sbin/init /etc/init /bin/init /bin/sh; do
+		if validate_init "${inittest}"; then
+			init="$inittest"
+			break
+		fi
+	done
 fi
 
 if read_fstab_entry /usr; then


-- 
Ben Hutchings
Logic doesn't apply to the real world. - Marvin Minsky
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL: <http://lists.alioth.debian.org/pipermail/pkg-sysvinit-devel/attachments/20140929/3597ee82/attachment.sig>


More information about the Pkg-sysvinit-devel mailing list