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>
This commit is contained in:
Ben Hutchings 2016-01-17 19:32:37 +00:00
parent c6d067cc87
commit 3c8b67c9da
2 changed files with 2 additions and 24 deletions

2
debian/control vendored
View File

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

24
init
View File

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