Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F138006901
D44280.id155744.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D44280.id155744.diff
View Options
diff --git a/usr.sbin/bsdinstall/scripts/rootpass b/usr.sbin/bsdinstall/scripts/rootpass
--- 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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 29, 2:13 AM (11 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26314092
Default Alt Text
D44280.id155744.diff (2 KB)
Attached To
Mode
D44280: bsdinstall: implement rootpass with bsddialog
Attached
Detach File
Event Timeline
Log In to Comment