[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: zfs load-key on boot randomly reports wrong password if I type too fast



That is a good pointer, I will start experimenting with kdbrate and see if anything improves.

I did come up with the following contraption which helps at least seeing what is going on and so far

it seems that the password is 1 char short on invalid attempt and it is usually the last char that seems to be missing.

I will probably figure it out through testing eventually.

#!/bin/bash

MAX_ATTEMPTS=3
attempt=0

while [ "$attempt" -lt "$MAX_ATTEMPTS" ]; do
   printf "ZFS load-key password (attempt $((attempt + 1)) of $MAX_ATTEMPTS): "
   PASSWORD=""

   while true; do
       char=$(dd bs=1 count=1 2>/dev/null)

       if [ -z "$char" ] || [ "$char" = "$(printf '\n')" ]; then
           break
       fi

       printf "*"

       PASSWORD="${PASSWORD}${char}"
   done

   echo "$PASSWORD" | /usr/sbin/zfs load-key -a

   if [ $? -eq 0 ]; then
       echo "Password accepted. Exiting."
       exit 0
   else
       echo "Incorrect password. Please try again."
       FIRST="${PASSWORD:0:1}"
       LAST="${PASSWORD: -1}"
       LEN=${#PASSWORD}
       echo "Got $FIRST ... $LAST, length $LEN"
       attempt=$((attempt + 1))
       sleep 3
   fi
done

echo "Maximum attempts reached. Exiting."



On 12/8/23 21:53, David wrote:
On Fri, 8 Dec 2023 at 20:22, cen <imbacen@gmail.com> wrote:

I have a very weird issue that.. if I type too fast the password is wrong. I know this sounds weird but it's true..

I can type the same password fast and it is wrong, then I type it very slowly the third time and it works.

I feel like it must be some weird thing with the boot terminal input rate or key detection but I have no clue where to start looking.
[...]

Any clues welcome
Hi,

I have experienced something similar, so it does not sound weird to me.
So my solution to my similar problem, might be a useful clue for you :)

I have a Toshiba Satellite Pro laptop [1] whose default keyboard rate settings
cause manual typing of the cryptsetup password entry in the initrd environment
to fail more often than not. A very annoying situation.

I fix this situation by causing /sbin/kbdrate to run inside the initrd
environment,
before the cryptsetup password entry occurs.

A while ago I wrote an email message about how I do that here:
  https://lists.debian.org/debian-user/2022/01/msg00105.html
  https://lists.debian.org/debian-user/2022/01/msg00106.html

Maybe this method can help you with your encrypted ZFS password entry,
I don't know.

[1] Toshiba Satellite Pro C665 Model No PSC2FA-002002


Reply to: