summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/usermgmt
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-06-08 19:13:49 +0000
committerdteske <dteske@FreeBSD.org>2013-06-08 19:13:49 +0000
commit8c2b3ff7836ad1192f01806cdd6df35d1ce8459b (patch)
treeee2af1c31f9d54b161aee4f25f3c959c455afc69 /usr.sbin/bsdconfig/usermgmt
parent86cb12eccd0e0cf2316295d26015d714da76f80a (diff)
downloadFreeBSD-src-8c2b3ff7836ad1192f01806cdd6df35d1ce8459b.zip
FreeBSD-src-8c2b3ff7836ad1192f01806cdd6df35d1ce8459b.tar.gz
Add a prompt to the "Add User" and "Add Group" sub-menu items (under the
"Login Management" module): Use default values for all account details? If you select "Yes" (the default is "No"), you'll jump past all the prompts and jump straight to the review screen with all-default values. Makes adding a lot of users/groups faster/easier if you don't need to customize more than one or two different values from their defaults.
Diffstat (limited to 'usr.sbin/bsdconfig/usermgmt')
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupinput32
-rw-r--r--usr.sbin/bsdconfig/usermgmt/include/messages.subr1
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/userinput65
3 files changed, 64 insertions, 34 deletions
diff --git a/usr.sbin/bsdconfig/usermgmt/groupinput b/usr.sbin/bsdconfig/usermgmt/groupinput
index ac27c98..261758b 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupinput
+++ b/usr.sbin/bsdconfig/usermgmt/groupinput
@@ -157,19 +157,27 @@ save_flag=
hline="$hline_arrows_tab_enter"
if [ "$mode" = "Add" ]; then
- #
- # Ask a series of questions to pre-fill the editor screen.
- #
- # The defaults used in each dialog should allow the user to simply
- # hit ENTER to proceed, because cancelling a single dialog will
- # cause them to be returned to the main groupmenu.
- #
-
f_dialog_input_group_name || exit 0
- [ "$passwdtype" = "yes" ] &&
- { f_dialog_input_group_password || exit 0; }
- f_dialog_input_group_gid || exit 0
- f_dialog_input_group_members || exit 0
+
+ f_dialog_noyes "$msg_use_default_values_for_all_account_details"
+ retval=$?
+
+ if [ $retval -eq 255 ]; then # User pressed ESC
+ exit $SUCCESS
+ elif [ $retval -ne $SUCCESS ]; then
+ #
+ # Ask a series of questions to pre-fill the editor screen.
+ #
+ # The defaults used in each dialog should allow the user to
+ # simply hit ENTER to proceed, because cancelling a single
+ # dialog will cause them to be returned to the main groupmenu.
+ #
+
+ [ "$passwdtype" = "yes" ] &&
+ { f_dialog_input_group_password || exit 0; }
+ f_dialog_input_group_gid || exit 0
+ f_dialog_input_group_members || exit 0
+ fi
fi
if [ "$mode" = "Edit/View" -o "$mode" = "Delete" ]; then
diff --git a/usr.sbin/bsdconfig/usermgmt/include/messages.subr b/usr.sbin/bsdconfig/usermgmt/include/messages.subr
index 24d7a95..aa98407 100644
--- a/usr.sbin/bsdconfig/usermgmt/include/messages.subr
+++ b/usr.sbin/bsdconfig/usermgmt/include/messages.subr
@@ -105,6 +105,7 @@ msg_separated_by_commas="Separated by commas"
msg_select_group_members_from_list="Select Group Members from a list"
msg_select_login_shell="Select Login Shell"
msg_shell="Shell"
+msg_use_default_values_for_all_account_details="Use default values for all account details?"
msg_user="User"
msg_user_id="UID"
msg_user_id_leave_empty_for_default="UID (Leave empty for default)"
diff --git a/usr.sbin/bsdconfig/usermgmt/userinput b/usr.sbin/bsdconfig/usermgmt/userinput
index 3df184c..21e61f6 100755
--- a/usr.sbin/bsdconfig/usermgmt/userinput
+++ b/usr.sbin/bsdconfig/usermgmt/userinput
@@ -238,32 +238,53 @@ save_flag=
hline="$hline_arrows_tab_enter"
if [ "$mode" = "Add" ]; then
+ f_dialog_input_name || exit 0
+
#
- # Ask a series of questions to pre-fill the editor screen.
- #
- # The defaults used in each dialog should allow the user to simply
- # hit ENTER to proceed, because cancelling a single dialog will
- # cause them to be returned to the main usermenu.
+ # Set some sensible defaults for account attributes
#
+ pw_gecos="${pw_gecos-$pw_name}"
+ pw_home_dir="${pw_home_dir:-$homeprefix/$pw_name}"
+ if [ -d "$pw_home_dir" ]; then
+ pw_home_create="${pw_home_create:-$msg_no}"
+ pw_dotfiles_create="${pw_dotfiles_create:-$msg_no}"
+ else
+ pw_home_create="${pw_home_create:-$msg_yes}"
+ pw_dotfiles_create="${pw_dotfiles_create:-$msg_yes}"
+ fi
+ pw_shell="${pw_shell:-$defaultshell}"
- f_dialog_input_name || exit 0
- f_dialog_input_gecos "$pw_name" || exit 0
- [ "$passwdtype" = "yes" ] &&
- { f_dialog_input_password || exit 0; }
- f_dialog_input_uid || exit 0
- f_dialog_input_gid || exit 0
- f_dialog_input_member_groups || exit 0
- f_dialog_input_class || exit 0
- f_dialog_input_expire_password || exit 0
- f_dialog_input_expire_account || exit 0
- f_dialog_input_home_dir "$homeprefix/$pw_name" || exit 0
- pw_dotfiles_create="$msg_no"
- if [ ! -d "$homeprefix/$pw_name" ]; then
- f_dialog_input_home_create || exit 0
- [ "$pw_home_create" = "$msg_yes" ] &&
- { f_dialog_input_dotfiles_create || exit 0; }
+ f_dialog_noyes "$msg_use_default_values_for_all_account_details"
+ retval=$?
+
+ if [ $retval -eq 255 ]; then # User pressed ESC
+ exit $SUCCESS
+ elif [ $retval -ne $SUCCESS ]; then
+ #
+ # Ask a series of questions to pre-fill the editor screen.
+ #
+ # The defaults used in each dialog should allow the user to
+ # simply hit ENTER to proceed, because cancelling a single
+ # dialog will cause them to be returned to the main usermenu.
+ #
+
+ f_dialog_input_gecos "$pw_gecos" || exit 0
+ [ "$passwdtype" = "yes" ] &&
+ { f_dialog_input_password || exit 0; }
+ f_dialog_input_uid || exit 0
+ f_dialog_input_gid || exit 0
+ f_dialog_input_member_groups || exit 0
+ f_dialog_input_class || exit 0
+ f_dialog_input_expire_password || exit 0
+ f_dialog_input_expire_account || exit 0
+ f_dialog_input_home_dir "$pw_home_dir" || exit 0
+ if [ ! -d "$pw_home_dir" ]; then
+ f_dialog_input_home_create || exit 0
+ [ "$pw_home_create" = "$msg_yes" ] &&
+ { f_dialog_input_dotfiles_create || exit 0; }
+ fi
+ f_dialog_input_shell "$pw_shell" || exit 0
fi
- f_dialog_input_shell "$defaultshell" || exit 0
fi
if [ "$mode" = "Edit/View" -o "$mode" = "Delete" ]; then
OpenPOWER on IntegriCloud