Creating new volumes prompts
        Re-type passphrase:
which is sane for interative usage, but -s (which omits prompts) to read
from stdin also prompts twice.

I think that's neither intuitive nor ergonomical and as intended for
non-interactive scripts, -s should take a new passphase just once.

Until a month ago, the manual errorneously said -s could not be used during
initial creation anyway, so I worry little about existing scripts like

        printf '%s\n%s\n' "$pw" "$pw" | bioctl -s -cC -lsd0a softraid0

Diff below makes -s create new volumes with a single passphase:

        # echo secret |       bioctl -s -Cforce -cC -lvnd0a softraid0
        bioctl: Passphrases did not match
        # echo secret | ./obj/bioctl -s -Cforce -cC -lvnd0a softraid0
        softraid0: CRYPTO volume attached as sd3

Feedback? Objection? OK?

Index: bioctl.c
RCS file: /cvs/src/sbin/bioctl/bioctl.c,v
retrieving revision 1.151
diff -u -p -r1.151 bioctl.c
--- bioctl.c    18 Oct 2022 07:04:20 -0000      1.151
+++ bioctl.c    2 Aug 2023 10:30:39 -0000
@@ -989,7 +989,7 @@ bio_kdf_generate(struct sr_crypto_kdfinf
        derive_key(kdfinfo->pbkdf.generic.type, kdfinfo->pbkdf.rounds,
            kdfinfo->maskkey, sizeof(kdfinfo->maskkey),
            kdfinfo->pbkdf.salt, sizeof(kdfinfo->pbkdf.salt),
-           "New passphrase: ", 1);
+           "New passphrase: ", rpp_flag == RPP_STDIN ? 0 : 1);

Reply via email to