From nobody Fri May 30 14:49:57 2025 X-Original-To: dev-commits-src-main@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 4b85kF4p79z5xlMn; Fri, 30 May 2025 14:49:57 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4b85kF44wgz3k4P; Fri, 30 May 2025 14:49:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748616597; 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=nGDuJXPjXpn/SW5OOJEeqjocTopelaFwoetrhFs2PDE=; b=bytfpmLE1CqD2kecPmAf070dPxTgmsv8Nyrlz/lCc5o6O9LSOQnt8ncpCQlLbcrOnmAUwW fWJUbEczfYOOHQX/98gH7lMg7wXFiEBd3ugrp21qCvconWU2orRnek+hJHNC1DwT+GLABM 0tbHI32bk9dbeyCrpsnZBfB0OICDA5jBxqDJzwE2K6Ms/2lePgGEdEfll/v7dIjV5iwseu 0Kz8oLRRIj1FZ1YBASFPN5LY8ir0ZIe/A+F/wlws3HqiTxmwtj0i63iilSH9QhCMnMIyhT Pyurvqo0xkG+/0VeHkhNWUUavGfrXIfQx2BNj7OtWnXvIgYrn2HbkKQdlWZh2w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1748616597; a=rsa-sha256; cv=none; b=RW/Ylu6XUBEErkeCI+cwQJgxyCCtuF1wkhK2Q8LbW2/PRAsnQZn1UU4deCUm9GxbUX/QBS bQsqnO/rMcDfC3EmA674BZfoW3ckztPqDaFTr2P6Wr5yQ5ZXexPyzX0Kwxa7Q+lc7xqO5+ xXbbsYk1wB5qxEdah+gWuJRFDu5LcoSpwQ5/yfHrCyMLfjX+SxQMxfKGmQDu2WqRNFF1I9 Vg0tHwT3AenJiy6j3TdltDywwfrh7yjXKwui94UPYqBJEWQh2dkpn7YG8iFvQjWI0q3w2e BaZGc8F3/0OCL1pqQapdPKd7vCcxoi82voX9vMTrYy5J5cSwns/21i3WIU+Gvw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748616597; 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=nGDuJXPjXpn/SW5OOJEeqjocTopelaFwoetrhFs2PDE=; b=lVqIeDyMkk/T0azYUHDNI160ehUOH6r9EoU7Il4LeZXB4SMEdSCOopvJCJmseVpEQEc4Ab GKTuCt1WlSzTzonfLV1vlpImlpmQeprDyl5B6ar4bQRQYi0yRpasJEs5Z0n7pB8nHJtxxa UVuBFXD9JdYoQoPedK4ttNiavMDM4x438JypotFmt3w4CeGz+YRLwDJOaKMuSiDP2bNYMb eDnC+AclLsAdeHWalnVBk73Od69iOKkUA6iH5SQwkilTMFpqP/wVZdsG9my+bgyCux3x5A P7jLcvZXjnUOOEJavenxFI7fjukuG/nsHgNUh99hqJ36APxPOEiDujJkWWOt6w== 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 4b85kF3X4qzwdt; Fri, 30 May 2025 14:49:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 54UEnvv0049016; Fri, 30 May 2025 14:49:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54UEnvP0049013; Fri, 30 May 2025 14:49:57 GMT (envelope-from git) Date: Fri, 30 May 2025 14:49:57 GMT Message-Id: <202505301449.54UEnvP0049013@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Pierre Pronchery Subject: git: 046800313ab6 - main - bsdinstall: implement rootpass with bsddialog List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khorben X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 046800313ab64ea058fe7e63f56b6134d6cf00ef Auto-Submitted: auto-generated The branch main has been updated by khorben: URL: https://cgit.FreeBSD.org/src/commit/?id=046800313ab64ea058fe7e63f56b6134d6cf00ef commit 046800313ab64ea058fe7e63f56b6134d6cf00ef Author: Pierre Pronchery AuthorDate: 2025-05-20 11:14:49 +0000 Commit: Pierre Pronchery CommitDate: 2025-05-30 14:45:48 +0000 bsdinstall: implement rootpass with bsddialog This provides a more consistent user experience to the FreeBSD installer. Tested by: thj Approved by: philip (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D44280 --- usr.sbin/bsdinstall/scripts/rootpass | 90 ++++++++++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/rootpass b/usr.sbin/bsdinstall/scripts/rootpass index 93523a9880d3..9d25569ae946 100755 --- a/usr.sbin/bsdinstall/scripts/rootpass +++ b/usr.sbin/bsdinstall/scripts/rootpass @@ -1,6 +1,7 @@ #!/bin/sh #- # Copyright (c) 2011 Nathan Whitehorn +# Copyright (c) 2024 The FreeBSD Foundation # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -27,18 +28,89 @@ BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 -clear -echo "$OSNAME Installer" -echo "========================" -echo if [ -n "$ROOTPASS_ENC" ]; then printf '%s\n' "$ROOTPASS_ENC" | pw -R $BSDINSTALL_CHROOT usermod root -H 0 + exit $? 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 + exit $? fi + +: ${BSDDIALOG_OK:=0} + +error_get_message() +{ + case $1 in + 62) + echo "The password cannot be empty" + ;; + 63) + echo "The passwords do not match" + ;; + 64) #EX_USAGE + echo "Command used incorrectly" + ;; + 65) #EX_DATAERR + echo "Incorrect input data" + ;; + 67) #EX_NOUSER + echo "User not found" + ;; + 70) #EX_SOFTWARE + echo "Internal software error" + ;; + 71) #EX_OSERR + echo "Operating System error detected" + ;; + 72) #EX_OSFILE + echo "Error in a system file" + ;; + 74) #EX_IOERR + echo "I/O error" + ;; + 77) #EX_NOPERM + echo "Insufficient permissions" + ;; + 78) #EX_CONFIG + echo "Configuration error" + ;; + 0) + ;; + *) + echo "An unknown error occurred (code $1)" + return 1 + ;; + esac + return $1 +} + +errormsg= +username="root" +while true; do + exec 5>&1 + output=$(bsddialog --backtitle "$OSNAME Installer" \ + --title "Set $username password" \ + --cancel-label "Skip" \ + --passwordform --insecure \ + "Please select a password for the system management account ($username) +$errormsg" \ + 0 0 2 \ + "Password" 0 0 '' 0 17 32 32 \ + "Repeat password" 1 0 '' 1 17 32 32 \ + 2>&1 1>&5) + res=$? + exec 5>&- + [ $res -eq $BSDDIALOG_OK ] || exit 0 + + echo -n "$output" | (read password1 + read password2 + [ -n "$password1" -o -n "$password2" ] || exit 62 + [ "$password1" = "$password2" ] || exit 63 + echo "$password1" | chroot $BSDINSTALL_CHROOT \ + /usr/sbin/pw usermod "$username" -h 0 + ) + err=$? + [ $err -eq 0 ] && exit 0 + errormsg=$(error_get_message $err) +done