From nobody Fri Aug 05 15:10:53 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4LzpvK6JF8z4YC3c; Fri, 5 Aug 2022 15:10:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LzpvK5Mrpz3TBP; Fri, 5 Aug 2022 15:10:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659712253; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=idar4n0Hym9qJe0VeOTpsZMqzGNbH8cXKhf3czC6ZMA=; b=kyuGOQty62ubiDnvedDyp7yQirWQJT9mU+y6xMFvCO7EnSwVU1X+LLUkTNwD+xitn00GSg mGucWevBSJoNrAyzgQQmoVdDym4J3lodvpLLIDPpI4j0KS7fYFqyjIxxwgrsok88zxZZQ+ CYYT5sqQez2FV7uKQPXjVnTXYicwG8seAaLORfKBXdLi1fs5OsiFhMoszI4DVcuJguiBxY Rdr28jQzD+L5JfOVbKrNV/WSIbWLFh0VCKj7ljO0dGIsae4aq07WVel4xiCVszZHsHZxma 0i4zS4+SizCgBFzOYfLKHoTDyLR63NhzIcGAhGhY/hCc0pNfcIJboaxFCNmA9w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4LzpvK4SBszxqJ; Fri, 5 Aug 2022 15:10:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 275FArYW016572; Fri, 5 Aug 2022 15:10:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 275FArAZ016571; Fri, 5 Aug 2022 15:10:53 GMT (envelope-from git) Date: Fri, 5 Aug 2022 15:10:53 GMT Message-Id: <202208051510.275FArAZ016571@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brad Davis Subject: git: 3e1101f29b4f - main - bsdinstall: allow setting the root password via env variables List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3e1101f29b4ff39a67eb10a5b41b727d8702f0f5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659712253; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=idar4n0Hym9qJe0VeOTpsZMqzGNbH8cXKhf3czC6ZMA=; b=fJUSE43Ui2r0+txJL14lIezRPxIoW4AGZNboLFlaw1DjsaMN6m/BlrQw1ngSM4e24mWAzh njHi0wQWes67UKd87o51wN1Jc5gh0IQW/flwmmD4tFacXXBxY0QNgM6XywmtyYpvx+oXBn Gr1NhPajA55hhLRABvQMpv6cazDvG0LZTr/nz8je79lxMJFWVPVkQADE28oZe68Mx9GStD aFYEXat5vzPqvrjAxBatWBCYdxuNl5odQqbk9vipgvG5mVo2486VnSkDBTPePg0BHHv0Nq 1SnwkEaxxNmTbo0sxSNstgmGQb5viEkU39TQXXcZBKKfWkxVB4v5x/ul86GN3A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659712253; a=rsa-sha256; cv=none; b=MPa2e4VZv5Mz53YYb79p09PbeQEFbNeh85Xh/8dZEBeW+g80eMEPjgJZn8Te1Yv+rjMsIX IjPT6/BypFW4+1gXyAT/h+FsLqI25lH0fJj6UHoPOk6lrrTWQT1fVS2x9iLP+A5rBwYonQ unmkDdCS0j/5uIonAid/JCAhIONfdbn4ZxWIPpaT9d2g5RTRG8THkHVaVQGgbqbXQYZVg4 4Hi0Y0YbTNfapZz+8a4t96tyS7qVSWmiKKyzmgna49UjOpSRIqp3b1vWEUyYCAW2RbYQtF 5oEIT3dxuSlTfnHjUKgQt9cPGJdOn/CyTWGxdgf8N/vUunbK6U90M5HQzKoctg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by brd: URL: https://cgit.FreeBSD.org/src/commit/?id=3e1101f29b4ff39a67eb10a5b41b727d8702f0f5 commit 3e1101f29b4ff39a67eb10a5b41b727d8702f0f5 Author: Brad Davis AuthorDate: 2022-08-05 15:10:21 +0000 Commit: Brad Davis CommitDate: 2022-08-05 15:10:21 +0000 bsdinstall: allow setting the root password via env variables Reviewed by: 0mp, allanjude, asiciliano, dteske, pauamma, rpokala, sef Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D35588 --- usr.sbin/bsdinstall/bsdinstall.8 | 9 +++++++++ usr.sbin/bsdinstall/scripts/rootpass | 12 +++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bsdinstall/bsdinstall.8 b/usr.sbin/bsdinstall/bsdinstall.8 index c71097fde7f8..b76cdc04b9c3 100644 --- a/usr.sbin/bsdinstall/bsdinstall.8 +++ b/usr.sbin/bsdinstall/bsdinstall.8 @@ -343,6 +343,15 @@ target is executed. If this directory does not already exist, it will be created. Default: .Dq Pa $TMPDIR/bsdinstall_boot +.It Ev ROOTPASS_ENC +Encrypted string to set the root password to in the format expected by +.Xr pw 8 +.Fl H Ar 0 . +This option is used if both it and +.Ev ROOTPASS_PLAIN +are set. +.It Ev ROOTPASS_PLAIN +Plain text string to set the root password to. .It Ev ZFSBOOT_POOL_NAME Name for the pool containing the base system. Default: diff --git a/usr.sbin/bsdinstall/scripts/rootpass b/usr.sbin/bsdinstall/scripts/rootpass index 308c60e47a4c..f823c397c384 100755 --- a/usr.sbin/bsdinstall/scripts/rootpass +++ b/usr.sbin/bsdinstall/scripts/rootpass @@ -33,7 +33,13 @@ echo "$OSNAME Installer" echo "========================" echo -echo "Please select a password for the system management account (root):" -echo "Typed characters will not be visible." +if [ -n "$ROOTPASS_ENC" ]; then + printf '%s\n' "$ROOTPASS_ENC" | pw -R $BSDINSTALL_CHROOT usermod root -H 0 +elif [ -n "$ROOTPASS_PLAIN" ]; then + printf '%s\n' "$ROOTPASS_PLAIN" | pw -R $BSDINSTALL_CHROOT usermod root -h 0 +else + echo "Please select a password for the system management account (root):" + echo "Typed characters will not be visible." -chroot $BSDINSTALL_CHROOT passwd root 2>&1 + chroot $BSDINSTALL_CHROOT passwd root 2>&1 +fi