From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A3415138334 for ; Mon, 7 Oct 2019 21:56:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7D3B6E08EF; Mon, 7 Oct 2019 21:56:49 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4F310E08EB for ; Mon, 7 Oct 2019 21:56:49 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DC43534BA0E for ; Mon, 7 Oct 2019 21:56:47 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id DA8E27F5 for ; Mon, 7 Oct 2019 21:56:45 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1570484690.3b27d1cd00f549724f5a2da0d97099e37aef6043.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/linuxrc X-VCS-Directories: defaults/ X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: 3b27d1cd00f549724f5a2da0d97099e37aef6043 X-VCS-Branch: master Date: Mon, 7 Oct 2019 21:56:45 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: d68ceb5a-7ce0-4669-a0bb-6c6e001986f5 X-Archives-Hash: 039ec9216c0b73b3a4815ee8cf1a591f commit: 3b27d1cd00f549724f5a2da0d97099e37aef6043 Author: Thomas Deutschmann gentoo org> AuthorDate: Mon Oct 7 21:01:56 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Mon Oct 7 21:44:50 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=3b27d1cd linuxrc: Check that init value is actually a file Just checking that init value is exectuable won't catch errors where user provided a directory instead of a file. Signed-off-by: Thomas Deutschmann gentoo.org> defaults/linuxrc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/defaults/linuxrc b/defaults/linuxrc index c0d4c0d..852992d 100644 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -862,27 +862,30 @@ do # else not a good root and start over. if [ "${mountret}" = '0' ] then - if [ -x "${NEW_ROOT}${REAL_INIT:-/sbin/init}" ] + init_binary_file="${NEW_ROOT}${REAL_INIT:-/sbin/init}" + init_binary_fallback_file="${NEW_ROOT}/bin/sh" + + if [ -f "${init_binary_file}" -a -x "${init_binary_file}" ] then break else - warn_msg "${NEW_ROOT}${REAL_INIT:-/sbin/init} was not found or is not executable, maybe a symlink?" ${QUIET} + warn_msg "'${init_binary_file}' was not found, is not a file or is not executable, maybe a symlink?" ${QUIET} fi - if [ -L "${NEW_ROOT}${REAL_INIT:-/sbin/init}" ] + if [ -L "${init_binary_file}" ] then good_msg "Symlink detected! Assuming split /usr ..." ${QUIET} break else - warn_msg "${NEW_ROOT}${REAL_INIT:-/sbin/init} is not a symlink, do we have at least /bin/sh?" ${QUIET} + warn_msg "'${init_binary_file}' is not a symlink, do we have at least /bin/sh?" ${QUIET} fi - if [ -x "${NEW_ROOT}/bin/sh" ] + if [ -f "${init_binary_fallback_file}" -a -x "${init_binary_fallback_file}" ] then - good_msg "Executable ${NEW_ROOT}/bin/sh detected!" ${QUIET} + good_msg "Executable fallback file '${init_binary_fallback_file}' detected!" ${QUIET} break else - warn_msg "${NEW_ROOT}/bin/sh was not found or is not executable, maybe we are working with NFS?" ${QUIET} + warn_msg "'${init_binary_fallback_file}' was not found, is not a file or is not executable, maybe we are working with NFS?" ${QUIET} fi if [ "${REAL_ROOT}" = "/dev/nfs" ] @@ -893,7 +896,9 @@ do warn_msg "No NFS detected!" ${QUIET} fi - bad_msg "The filesystem mounted at ${REAL_ROOT} does not appear to be a valid /!" + bad_msg "The filesystem mounted at ${REAL_ROOT} does not appear to be a valid /:" + bad_msg "Neither executable file '${init_binary_file}' nor '${init_binary_fallback_file}' was found." + bad_msg "If correct root device was specified, check 'root' or 'init' kernel command-line parameter!" got_good_root=0 else bad_msg "Could not mount specified ROOT!" @@ -1297,7 +1302,7 @@ init=${REAL_INIT:-/sbin/init} if ! mountpoint "${CHROOT}" 1>/dev/null 2>&1 then bad_msg "${CHROOT} was not a mountpoint" -elif chroot "${CHROOT}" /usr/bin/test ! -x /${init} +elif chroot "${CHROOT}" /usr/bin/test ! -x /${init#/} then bad_msg "init=${init} does not exist in the rootfs!" elif [ $$ != 1 ]