From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 8E5251388B6 for ; Tue, 5 Jan 2016 19:39:47 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2F27D21C01D; Tue, 5 Jan 2016 19:39:47 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B843721C01D for ; Tue, 5 Jan 2016 19:39:46 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CBBB334097F for ; Tue, 5 Jan 2016 19:39:45 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2E552CFC for ; Tue, 5 Jan 2016 19:39:42 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1452022678.19d8a784c9618926a4740c43fcc40ebb1bb5bf8b.robbat2@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: /, defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/initrd.scripts gen_initramfs.sh X-VCS-Directories: / defaults/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: 19d8a784c9618926a4740c43fcc40ebb1bb5bf8b X-VCS-Branch: master Date: Tue, 5 Jan 2016 19:39:42 +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-Archives-Salt: 62477808-921a-4986-8271-b9773b863b77 X-Archives-Hash: 1bb1bebd3791454e31e9fe363539048b commit: 19d8a784c9618926a4740c43fcc40ebb1bb5bf8b Author: Robin H. Johnson gentoo org> AuthorDate: Tue Jan 5 19:35:01 2016 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Tue Jan 5 19:37:58 2016 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=19d8a784 multipath: find the needed binaries and fail visibly While making dolvm safer per commit 7316481040, I noticed that multipath had the same issue: /sbin/dmsetup was called, but the binary was actually at /bin/dmsetup. Prevent this by detecting the binary location if possible, and failing gracefully if not found. Signed-off-by: Robin H. Johnson gentoo.org> defaults/initrd.scripts | 28 ++++++++++++++++++++++------ gen_initramfs.sh | 4 ++-- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 94cb0cc..763468a 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -961,12 +961,28 @@ startVolumes() { if [ "${USE_MULTIPATH_NORMAL}" = '1' ] then - good_msg "Scanning for multipath devices" - /sbin/multipath -v 0 - sleep 2 - good_msg "Activating multipath devices" - /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a -v" - #for MULTIPATH_VOLUMES in /dev/mapper/*; do kpartx -a $MULTIPATH_VOLUMES; done + for multipath_path in /sbin/multipath /bin/multipath MISSING ; do + [ -x "$multipath_path " ] && break + fi + for dmsetup_path in /sbin/dmsetup /bin/dmsetup MISSING ; do + [ -x "$dmsetup_path " ] && break + fi + for kpartx_path in /sbin/kpartx /bin/kpartx MISSING ; do + [ -x "$kpartx_path " ] && break + fi + fail=0 + ["${multipath_path}" = "MISSING" ] && fail=1 && bad_msg "domultipath called, but multipath binary missing! Skipping multipath" + ["${dmsetup_path}" = "MISSING" ] && fail=1 && bad_msg "domultipath called, but dmsetup binary missing! Skipping multipath" + ["${kpartx_path}" = "MISSING" ] && fail=1 && bad_msg "domultipath called, but kpartx binary missing! Skipping multipath" + if [ "$fail" = "0" ] + then + good_msg "Scanning for multipath devices" + $multipath_path -v 0 + sleep 2 + good_msg "Activating multipath devices" + $dmsetup_path ls --target multipath --exec "$kpartx_path -a -v" + #for MULTIPATH_VOLUMES in /dev/mapper/*; do $kpartx_path -a $MULTIPATH_VOLUMES; done + fi fi if [ "${USE_DMRAID_NORMAL}" = '1' ] diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 7dce2cf..4420b0b 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -374,8 +374,8 @@ append_lvm(){ # Now move the static binaries into good places. mv ${TEMP}/initramfs-lvm-temp/sbin/lvm.static ${TEMP}/initramfs-lvm-temp/sbin/lvm || gen_die 'LVM error: Could not move lvm.static to lvm!' - # See bug 382555 - mv ${TEMP}/initramfs-lvm-temp/sbin/dmsetup.static ${TEMP}/initramfs-lvm-temp/bin/dmsetup || + # See bug 382555; use /sbin/dmsetup to match multipath code + mv ${TEMP}/initramfs-lvm-temp/sbin/dmsetup.static ${TEMP}/initramfs-lvm-temp/sbin/dmsetup || gen_die 'LVM error: Could not move dmsetup.static to dmsetup!' # Clean up other stuff we don't need rm -rf ${TEMP}/initramfs-lvm-temp/{lib*,share,man,include,sbin/dmeventd.static}