From 7fcf82451c4b75afe327c77683f66bf0c6396a48 Mon Sep 17 00:00:00 2001 From: Richard Laager Date: Sun, 10 May 2020 14:26:08 -0500 Subject: [PATCH] Change zfsunlock for better busybox compatibility It turns out that there are two versions of Busybox, at least on Ubuntu 18.04. If you have the busybox-static package installed, you get a busybox that supports `ps a` and `head`. If you only have busybox-initramfs, you don't. Either way, you have `awk`. This change should also make this compatible with GNU ps, if you somehow end up with that in the initramfs environment. Reviewed-by: Tom Caputi Reviewed-by: Andrey Prokopenko Signed-off-by: Richard Laager Closes #10307 --- contrib/initramfs/zfsunlock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/initramfs/zfsunlock b/contrib/initramfs/zfsunlock index 1202a144de..f6b6b9dbe1 100755 --- a/contrib/initramfs/zfsunlock +++ b/contrib/initramfs/zfsunlock @@ -25,7 +25,7 @@ while [ ! -e /run/zfs_unlock_complete ]; do /sbin/zfs load-key "$zfs_fs_name" || true if [ "$(/sbin/zfs get -H -ovalue keystatus "$zfs_fs_name" 2> /dev/null)" = "available" ]; then echo "Password for $zfs_fs_name accepted." - zfs_console_askpwd_pid=$(ps a -o pid= -o args | grep -v grep | grep "$zfs_console_askpwd_cmd" | cut -d ' ' -f3 | sort -n | head -n1) + zfs_console_askpwd_pid=$(ps | awk '!'"/awk/ && /$zfs_console_askpwd_cmd/ { print \$1; exit }") if [ -n "$zfs_console_askpwd_pid" ]; then kill "$zfs_console_askpwd_pid" fi