On Thu, Aug 17, 2023 at 06:43:36PM +1000, Joel Sing wrote:
> I agree with the intent, however the man page should probably reflect this
> change (i.e. -s makes it non-interactive and you will not get confirmation).
Done.
>
> > 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 17 Aug 2023 02:16:37 -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_REQUIRE_TTY ? 1 : 0);
>
> I think it would be less ugly to have an iteractive global (or similar)
> and clear that when -s is given (the correct way to write the above would
> require masking rpp_flag).
Done. This makes all of the following behave as expected
bioctl -cC -lvnd0a softraid0
bioctl -d sd2
bioctl -s -cC -lvnd0a softraid0
bioctl -P sd2
bioctl -s -P sd2
Feedback? OK?
Index: bioctl.8
===================================================================
RCS file: /cvs/src/sbin/bioctl/bioctl.8,v
retrieving revision 1.111
diff -u -p -r1.111 bioctl.8
--- bioctl.8 6 Jul 2023 21:08:50 -0000 1.111
+++ bioctl.8 17 Aug 2023 09:24:28 -0000
@@ -288,7 +288,7 @@ is specified as "auto", the number of ro
based on system performance.
Otherwise the minimum is 4 rounds and the default is 16.
.It Fl s
-Read the passphrase for the selected crypto volume from
+Omit prompts and read passphrases without confirmation from
.Pa /dev/stdin
rather than
.Pa /dev/tty .
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 17 Aug 2023 09:23:13 -0000
@@ -94,7 +94,7 @@ char *password;
void *bio_cookie;
-int rpp_flag = RPP_REQUIRE_TTY;
+int interactive = 1;
int
main(int argc, char *argv[])
@@ -200,7 +200,7 @@ main(int argc, char *argv[])
al_arg = optarg;
break;
case 's':
- rpp_flag = RPP_STDIN;
+ interactive = 0;
break;
case 't': /* patrol */
func |= BIOC_PATROL;
@@ -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: ", interactive);
}
int
@@ -1316,6 +1316,7 @@ derive_key(u_int32_t type, int rounds, u
size_t pl;
struct stat sb;
char passphrase[1024], verifybuf[1024];
+ int rpp_flag = RPP_ECHO_OFF;
if (!key)
errx(1, "Invalid key");
@@ -1351,6 +1352,8 @@ derive_key(u_int32_t type, int rounds, u
fclose(f);
} else {
+ rpp_flag |= interactive ? RPP_REQUIRE_TTY : RPP_STDIN;
+
if (readpassphrase(prompt, passphrase, sizeof(passphrase),
rpp_flag) == NULL)
err(1, "unable to read passphrase");