From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1099547-garchives=archives.gentoo.org@lists.gentoo.org> 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 AC6CF138334 for <garchives@archives.gentoo.org>; Sun, 14 Jul 2019 18:15:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D60E1E092A; Sun, 14 Jul 2019 18:15:39 +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 A9C7EE092A for <gentoo-commits@lists.gentoo.org>; Sun, 14 Jul 2019 18:15:39 +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 3F62B347B09 for <gentoo-commits@lists.gentoo.org>; Sun, 14 Jul 2019 18:15:38 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 505B66EA for <gentoo-commits@lists.gentoo.org>; Sun, 14 Jul 2019 18:15:36 +0000 (UTC) From: "Thomas Deutschmann" <whissi@gentoo.org> 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" <whissi@gentoo.org> Message-ID: <1563127894.74d7acd9ae1cf38725c1f31172e761eeadf857c9.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: / X-VCS-Repository: proj/genkernel X-VCS-Files: gen_determineargs.sh gen_initramfs.sh X-VCS-Directories: / X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: 74d7acd9ae1cf38725c1f31172e761eeadf857c9 X-VCS-Branch: master Date: Sun, 14 Jul 2019 18:15:36 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 03187a0b-7c44-4a2b-9413-68e0f6029723 X-Archives-Hash: 95ec313532ff0dcab535a20e94b9cee9 commit: 74d7acd9ae1cf38725c1f31172e761eeadf857c9 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> AuthorDate: Sun Jul 14 18:11:34 2019 +0000 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> CommitDate: Sun Jul 14 18:11:34 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=74d7acd9 Dropbear: Move --ssh-authorized-keys validation to determine_real_args() function It's a common error especially for new setups that '/etc/dropbear/authorized_keys' file will be missing. Moving the check to determine_real_args() will allow us to bail out very early for better user experience. Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> gen_determineargs.sh | 16 ++++++++++++++++ gen_initramfs.sh | 15 ++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/gen_determineargs.sh b/gen_determineargs.sh index a42cd44..1b3abf8 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -424,6 +424,22 @@ determine_real_args() { gen_die "--multipath requires --lvm but --no-lvm is set!" fi + if isTrue "${SSH}" + then + local ssh_authorized_keys_file=$(expand_file "${SSH_AUTHORIZED_KEYS_FILE}") + if [ -z "${ssh_authorized_keys_file}" ] + then + # expand_file() will return also return an empty string when file + # doesn't exist! + gen_die "--ssh-authorized-keys value '${SSH_AUTHORIZED_KEYS_FILE}' is invalid! Does the file exists?" + elif [ ! -s "${ssh_authorized_keys_file}" ] + then + gen_die "authorized_keys file '${ssh_authorized_keys_file}' is empty!" + else + declare -gr DROPBEAR_AUTHORIZED_KEYS_FILE="${ssh_authorized_keys_file}" + fi + fi + if isTrue "${ZFS}" && isTrue "$(tc-is-cross-compiler)" then local error_msg="Using binpkg for ZFS is not supported." diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 41f0269..973ed9e 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -899,16 +899,9 @@ append_dropbear() { dropbear_command=dropbearconvert fi - local ssh_authorized_keys_file=$(expand_file "${SSH_AUTHORIZED_KEYS_FILE}") - if [ -z "${ssh_authorized_keys_file}" ] + if [ -z "${DROPBEAR_AUTHORIZED_KEYS_FILE}" ] then - gen_die "--ssh-authorized-keys value '${SSH_AUTHORIZED_KEYS_FILE}' is invalid!" - elif [ ! -f "${ssh_authorized_keys_file}" ] - then - gen_die "authorized_keys file '${ssh_authorized_keys_file}' does NOT exist!" - elif [ ! -s "${ssh_authorized_keys_file}" ] - then - gen_die "authorized_keys file '${ssh_authorized_keys_file}' is empty!" + gen_die "Something went wrong: DROPBEAR_AUTHORIZED_KEYS_FILE should already been set but is missing!" fi populate_binpkg ${PN} @@ -1122,8 +1115,8 @@ append_dropbear() { cp -a "${GK_SHARE}"/defaults/unlock-luks.sh "${TDIR}"/usr/sbin/unlock-luks \ || gen_die "Failed to copy '${GK_SHARE}/defaults/unlock-luks.sh' to '${TDIR}/usr/sbin/unlock-luks'" - cp -aL "${ssh_authorized_keys_file}" "${TDIR}"/root/.ssh/ \ - || gen_die "Failed to copy '${ssh_authorized_keys_file}'!" + cp -aL "${DROPBEAR_AUTHORIZED_KEYS_FILE}" "${TDIR}"/root/.ssh/ \ + || gen_die "Failed to copy '${DROPBEAR_AUTHORIZED_KEYS_FILE}'!" cp -aL /etc/localtime "${TDIR}"/etc/ \ || gen_die "Failed to copy '/etc/localtime'. Please set system's timezone!"