[this change was lost between others and private mails...]

Passphrases must not be empty or else volume creation/unlock fails:

        # bioctl -cC -lvnd0a softraid0
        New passphrase: 
        Re-type passphrase: 
        bioctl: bcrypt_pbkdf failed

[-p passfile] already says "invalid passphrase length" on empty files,
so align the interactive prompt and retry there instead of failing hard:

        # ./obj/bioctl -cC -lvnd0a softraid0
        New passphrase: 
        bioctl: invalid passphrase length
        New passphrase: 

-s to read non-interactively read from stdin not tty remains a one-shot,
but gets the better error message:

        # echo | bioctl -cC -lvnd0a softraid0
        bioctl: bcrypt_pbkdf failed
        # echo | ./obj/bioctl -s -cC -lvnd0a softraid0
        bioctl: invalid passphrase length

This should be user friendlier and fixes the last installer "bug" wrt.
disk encryption, since bioctl and thus the installer would fail if you
hit Enter twice at the passphrase prompt.

Regress keeps passing.

Feedback? OK?

Index: bioctl.c
===================================================================
RCS file: /cvs/src/sbin/bioctl/bioctl.c,v
retrieving revision 1.156
diff -u -p -r1.156 bioctl.c
--- bioctl.c    6 Oct 2023 09:55:02 -0000       1.156
+++ bioctl.c    6 Oct 2023 10:18:35 -0000
@@ -1361,6 +1361,12 @@ derive_key(u_int32_t type, int rounds, u
                if (readpassphrase(prompt, passphrase, sizeof(passphrase),
                    rpp_flag) == NULL)
                        err(1, "unable to read passphrase");
+               if (*passphrase == '\0') {
+                       warnx("invalid passphrase length");
+                       if (interactive)
+                               goto retry;
+                       exit(1);
+               }
        }
 
        if (verify && !passfile) {

Reply via email to