Hey Ian, On 20/05/2011 Ian Jackson wrote: > Jonas Meurer writes ("Re: [pkg-cryptsetup-devel] Bug#597583: > initramfs-tools"): > > On 21/09/2010 Ian Jackson wrote: > > > This could be done by replacing this test > > > if [ -n "$cryptkeyscript" ] && [ ! -x "$cryptkeyscript" ]; then > > > with something like > > > if ! type "$cryptkeyscript >/dev/null; then > > > with the added benefit of getting a slightly better error message too. > > > > While I like your idea, it doesn't work. $cryptkeyscript might contain a > > whole commandline, with arguments and options as well. Actually the > > initramfs cryproot script even does it that way. See line 270 of the > > script: > > > > cryptkeyscript="plymouth ask-for-password --prompt" > > It's been a while since I looked at this, and I don't have the code in > front of me, but I'm puzzled, because if > cryptkeyscript="plymouth ask-for-password --prompt" > then > if [ -n "$cryptkeyscript" ] && [ ! -x "$cryptkeyscript" ]; then > would be true, just like my proposed test > if ! type "$cryptkeyscript" >/dev/null; then > (err, with the syntax fixed...) > > $ cryptkeyscript="plymouth ask-for-password --prompt" > $ if [ -n "$cryptkeyscript" ] && [ ! -x "$cryptkeyscript" ]; then echo > y; fi > y > $ if ! type "$cryptkeyscript" >/dev/null; then echo y; fi > bash: type: plymouth ask-for-password --prompt: not found > y > $ > > > That one clearly doesn't work with type, as type checks for all > > arguments, and errors out for the second and third one. > > The same is true for test -x.
you're perfectly right. guess it was a little late, when I wrote the last mail. I now tried to implement support for keyfiles inside $PATH everywhere necessary. unfortunately I'm rather busy at the moment, and don't have time to test the patch within the next weeks. thus it would be great, if you could give it a first try, and report back whether it does the trick for you. for sure I'll test it as well, before actually uploading new packages. greetings, jonas
--- debian/initramfs/cryptroot-hook (revision 883) +++ debian/initramfs/cryptroot-hook (working copy) @@ -407,6 +407,10 @@ copy_exec "/lib/cryptsetup/scripts/$KEYSCRIPT" /lib/cryptsetup/scripts >&2 elif [ -e "$KEYSCRIPT" ]; then copy_exec "$KEYSCRIPT" /lib/cryptsetup/scripts >&2 + elif KSTYPE="$(type "$KEYSCRIPT" 2>&1)"; then + if [ -x "${KSTYPE#"$KEYSCRIPT" is }" ]; then + copy_exec "${KSTYPE#"$KEYSCRIPT" is }" /lib/cryptsetup/scripts >&2 + fi else echo "cryptsetup: WARNING: failed to find keyscript $KEYSCRIPT" >&2 continue =================================================================== --- debian/initramfs/cryptroot-script (revision 883) +++ debian/initramfs/cryptroot-script (working copy) @@ -184,7 +184,7 @@ parse_options "$opts" || return 1 - if [ -n "$cryptkeyscript" ] && [ ! -x "$cryptkeyscript" ]; then + if [ -n "$cryptkeyscript" ] && ! type "$cryptkeyscript" >/dev/null; then message "cryptsetup: error - script \"$cryptkeyscript\" missing" return 1 fi --- debian/cryptdisks.functions (revision 883) +++ debian/cryptdisks.functions (working copy) @@ -167,11 +167,12 @@ elif [ -z "$VALUE" ]; then log_warning_msg "$dst: no value for keyscript option, skipping" return 1 - #elif type "$VALUE" >/dev/null 2>&1; then elif [ -x "$VALUE" ]; then KEYSCRIPT="$VALUE" elif [ -x "/lib/cryptsetup/scripts/$VALUE" ]; then KEYSCRIPT="/lib/cryptsetup/scripts/$VALUE" + elif type "$VALUE" >/dev/null 2>&1; then + KEYSCRIPT="$VALUE" else log_warning_msg "script $VALUE is not an executable script, skipping" return 1
signature.asc
Description: Digital signature