]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Fix ask_for_password bug breaking bash without plymouth 60/head
authorRusty Bird <rustybird@openmailbox.org>
Thu, 30 Apr 2015 03:25:14 +0000 (03:25 +0000)
committerRusty Bird <rustybird@openmailbox.org>
Thu, 30 Apr 2015 03:25:14 +0000 (03:25 +0000)
If crypt-lib.sh is sourced from any #!/bin/sh script, a POSIX shell
quirk is in effect that causes variable assignments to "special
builtins" (such as "shift") to leak to their context. So the buggy
code works even despite the missing semicolons.

But if it is sourced by "bash acting under its own name", i.e. from
any #!/bin/bash script, the quirk is disabled, tty_cmd/tty_prompt are
undefined, and ask_for_password doesn't do anything if plymouth is not
present.

modules.d/90crypt/crypt-lib.sh

index 3f12ea0f889b2a7b87322d0706d2135a01659933..4e98010965ef3595d4bdddd5a6ff626db0b25f7d 100755 (executable)
@@ -42,10 +42,10 @@ ask_for_password() {
 
     while [ $# -gt 0 ]; do
         case "$1" in
-            --cmd) ply_cmd="$2"; tty_cmd="$2" shift;;
+            --cmd) ply_cmd="$2"; tty_cmd="$2"; shift;;
             --ply-cmd) ply_cmd="$2"; shift;;
             --tty-cmd) tty_cmd="$2"; shift;;
-            --prompt) ply_prompt="$2"; tty_prompt="$2" shift;;
+            --prompt) ply_prompt="$2"; tty_prompt="$2"; shift;;
             --ply-prompt) ply_prompt="$2"; shift;;
             --tty-prompt) tty_prompt="$2"; shift;;
             --tries) ply_tries="$2"; tty_tries="$2"; shift;;