Index | Thread | Search

From:
Klemens Nanni <kn@openbsd.org>
Subject:
Re: [patch] Autoinstall with disk encryption
To:
Andrew Hewus Fresh <andrew@afresh1.com>, tech@openbsd.org
Date:
Sat, 17 Feb 2024 13:51:01 +0000

Download raw body.

Thread
On Sun, Feb 11, 2024 at 11:46:59PM +0000, Klemens Nanni wrote:
> On Sat, Feb 10, 2024 at 02:40:33PM -0800, Andrew Hewus Fresh wrote:
> > It _is_ technically possible to use a coprocess instead of a temporary
> > file, but not entirely sure the added complexity is worth is.
> 
> The dmesg listener is already running in the only available coprocess.
> 
> > set -o monitor
> > doas bioctl -c C -s -l /dev/${VND}a softraid0 |&
> > print -p -- test123
> > fg
> > set +o monitor
> 
> bioctl(8) uses readpassphrase(3) RPP_REQUIRE_TTY, so we can always pass
> stdin and it only gets used with `-s', i.e. in unattended mode.
> 
> Same behaviour, no passfile.

I'll go ahead with this in a few days unless I hear objections.

Index: install.sub
===================================================================
RCS file: /cvs/src/distrib/miniroot/install.sub,v
diff -u -p -r1.1259 install.sub
--- install.sub	11 Feb 2024 21:56:10 -0000	1.1259
+++ install.sub	11 Feb 2024 23:28:16 -0000
@@ -3123,9 +3123,7 @@ encrypt_root() {
 			;;
 		[pP]*)  $AI || break
 			ask_passphrase 'New passphrase?'
-			PASSFILE=/tmp/i/passfile
-			(umask 077 && print -r -- "$_passphrase" >$PASSFILE)
-			_args=-p$PASSFILE
+			_args=-s
 			break
 			;;
 		[nN]*)	return
@@ -3139,8 +3137,10 @@ encrypt_root() {
 	md_prep_fdisk $_chunk
 	echo 'RAID *' | disklabel -w -A -T- $_chunk
 
-	bioctl -Cforce -cC -l${_chunk}a $_args softraid0 >/dev/null
-	rm -fP $PASSFILE
+	# Standard input is ignored in interactive mode.
+	print -r -- "$_passphrase" |
+		bioctl -Cforce -cC -l${_chunk}a $_args softraid0 >/dev/null
+	unset _passphrase
 
 	# No volumes existed before asking, but we just created one.
 	ROOTDISK=$(get_softraid_volumes)