how to accept a password from inside initramfs/dracut?

Russ Fink docfink at gmail.com
Fri Jan 10 18:15:32 UTC 2020


Hello, I want to prompt a user for a password and then take action on that
once they input it.  I do get the password prompt, and the "--command" is
running, but the command cannot obtain the password in any way that I've
tried.  Can you help?

I'm using dracut on CentOS 7.6 to create the ramdisk.

My module-install.sh includes these lines at install:

. . .
install() {
    . . .
    inst_simple "$moddir/opal-unlock.sh" "/lib/dracut-my-unlock.sh"
    inst_hook pre-mount 60 "$moddir/my-getpass.sh"
    # dracut_need_initqueue
    . . .

My-getpass.sh includes these lines:

#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
{ flock -s 9;
        # Prompt for password with plymouth, if installed and running.
        if type plymouth >/dev/null 2>&1 && plymouth --ping 2>/dev/null;
then
            plymouth ask-for-password --prompt "enter pass"
--number-of-tries=3 --command="/lib/dracut-my-unlock.sh"

My-unlock includes these lines; note several failed attempts commented out:

#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# reboot # rebooting here proves this script is getting called.  It is.
/bin/read SUPASS # does not work
# /bin/cat >/.foo
# SUPASS=$(/bin/cat /.foo) # does not work
# SUPASS="$*" # does not work
# reboot # is the read command succeeding? YES - gets null input.  YES -
reboot works here
# ASDF=$(/bin/env | /bin/grep -iE 'asdf') # does plymouth store pass in env
var? No.
# plymouth ask-question --prompt="I see '${ASDF}' '${SUPASS}'"
plymouth ask-question --prompt="I see '${SUPASS}'" # always emits '' for
empty string
exit 0

The problem is, SUPASS is never set in the unlock script.  The prompt
always comes back with an empty string.

What should I try next?

Thanks,
Russ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/plymouth/attachments/20200110/0b3c972e/attachment.htm>


More information about the plymouth mailing list