[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#810965: [PATCH initramfs-tools 3/3] init: Use run-init -n option to validate real init



validate_init tries to resolve symlinks, but we can't do it properly
without chroot'ing to the real root.  Rather than running readlink
from the real system, use the new run-init -n option.

Closes: #810965
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 debian/control |  2 +-
 init           | 24 +-----------------------
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/debian/control b/debian/control
index af7e559..a943598 100644
--- a/debian/control
+++ b/debian/control
@@ -25,7 +25,7 @@ Package: initramfs-tools-core
 Architecture: all
 Multi-Arch: foreign
 Recommends: busybox (>= 1:1.01-3) | busybox-initramfs | busybox-static
-Depends: klibc-utils (>= 2.0-1~), cpio, kmod | module-init-tools, udev, ${misc:Depends}, klibc-utils (>= 2.0.4-1.2~) | busybox (>= 1:1.01-3) | busybox-initramfs | busybox-static
+Depends: klibc-utils (>= 2.0.4-7~), cpio, kmod | module-init-tools, udev, ${misc:Depends}, klibc-utils (>= 2.0.4-1.2~) | busybox (>= 1:1.01-3) | busybox-initramfs | busybox-static
 Suggests: bash-completion
 Breaks: initramfs-tools (<< 0.121~)
 Replaces: initramfs-tools (<< 0.121~)
diff --git a/init b/init
index 0a862f2..c10546f 100755
--- a/init
+++ b/init
@@ -237,29 +237,7 @@ if read_fstab_entry /usr; then
 fi
 
 validate_init() {
-	checktarget="${1}"
-
-	# Work around absolute symlinks
-	if [ -d "${rootmnt}" ] && [ -h "${rootmnt}${checktarget}" ]; then
-		checktarget="$(readlink "${rootmnt}${checktarget}")"
-		case "$checktarget" in
-		/*)
-			;;
-		*)
-			checktarget="${1%/*}/$checktarget"
-			;;
-		esac
-	fi
-
-	# Make sure the specified init can be executed
-	if [ ! -x "${rootmnt}${checktarget}" ]; then
-		return 1
-	fi
-
-	# Upstart uses /etc/init as configuration directory :-/
-	if [ -d "${rootmnt}${checktarget}" ]; then
-		return 1
-	fi
+	run-init -n "${rootmnt}" "${1}"
 }
 
 # Check init is really there

Attachment: signature.asc
Description: Digital signature


Reply to: