Skip to content

Commit

Permalink
Change zfsunlock for better busybox compatibility
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Andrey Prokopenko <[email protected]>
Signed-off-by: Richard Laager <[email protected]>
Closes #10307
rlaager authored May 10, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent fc551d7 commit 7fcf824
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion contrib/initramfs/zfsunlock
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7fcf824

Please sign in to comment.