summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/usermgmt
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bsdconfig/usermgmt')
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/group_input.subr74
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/user_input.subr137
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/usermgmt13
3 files changed, 110 insertions, 114 deletions
diff --git a/usr.sbin/bsdconfig/usermgmt/share/group_input.subr b/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
index 49986cf..1bb3819 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
@@ -65,13 +65,12 @@ f_input_group()
#
f_dialog_menu_group_list()
{
- local defaultitem="$1"
- local menu_list
- local hline="$hline_alnum_punc_tab_enter"
-
- menu_list="
+ local prompt=
+ local menu_list="
'X $msg_exit' ''
" # END-QUOTE
+ local defaultitem="$1"
+ local hline="$hline_alnum_punc_tab_enter"
# Add groups from group(5)
menu_list="$menu_list $( pw groupshow -a | awk -F: '
@@ -84,7 +83,7 @@ f_dialog_menu_group_list()
eval f_dialog_menu_size height width rows \
\"\$DIALOG_TITLE\" \
\"\$DIALOG_BACKTITLE\" \
- \"\" \
+ \"\$prompt\" \
\"\$hline\" \
$menu_list
@@ -96,7 +95,7 @@ f_dialog_menu_group_list()
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
--default-item \"\$defaultitem\" \
- --menu \"\" \
+ --menu \"\$prompt\" \
$height $width $rows \
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
@@ -171,24 +170,23 @@ f_dialog_input_group_name()
#
f_dialog_input_group_password()
{
+ local prompt1="$msg_group_password"
+ local prompt2="$msg_reenter_group_password"
local hline="$hline_alnum_punc_tab_enter"
- local msg rmsg
- msg=$( printf "$msg_group_password" )
local height1 width1
f_dialog_inputbox_size height1 width1 \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
- "$msg" \
+ "$prompt1" \
"" \
"$hline"
- rmsg=$( printf "$msg_reenter_group_password" )
local height2 width2
f_dialog_inputbox_size height2 width2 \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
- "$rmsg" \
+ "$prompt2" \
"" \
"$hline"
@@ -204,7 +202,7 @@ f_dialog_input_group_password()
--ok-label "$msg_ok" \
--cancel-label "$msg_cancel" \
--insecure \
- --passwordbox "$msg" \
+ --passwordbox "$prompt1" \
$height1 $width1 \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
@@ -221,7 +219,7 @@ f_dialog_input_group_password()
--ok-label "$msg_ok" \
--cancel-label "$msg_cancel" \
--insecure \
- --passwordbox "$rmsg" \
+ --passwordbox "$prompt2" \
$height2 $width2 \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
@@ -288,30 +286,25 @@ f_dialog_input_group_gid()
#
f_dialog_input_group_members()
{
- local menu_choice retval _input="$1"
- local msg="$msg_group_members:"
- local hline="$hline_num_arrows_tab_enter"
- local user
- local menu_list
- local all_users_valid
- local _group_members
- local checklist_users
-
- menu_list="
+ local _input="$1"
+ local prompt="$msg_group_members:"
+ local menu_list="
'X' '$msg_continue'
'1' '$msg_select_group_members_from_list'
'2' '$msg_enter_group_members_manually'
" # END-QUOTE
+ local defaultitem=
+ local hline="$hline_num_arrows_tab_enter"
- local menu_choice defaultitem=
local mheight mwidth mrows
eval f_dialog_menu_size mheight mwidth mrows \
\"\$DIALOG_TITLE\" \
\"\$DIALOG_BACKTITLE\" \
- \"\$msg\" \
+ \"\$prompt\" \
\"\$hline\" \
$menu_list
+ local menu_choice retval
while :; do
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
@@ -320,7 +313,7 @@ f_dialog_input_group_members()
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
--default-item \"\$defaultitem\" \
- --menu \"\$msg\" \
+ --menu \"\$prompt\" \
$mheight $mwidth $mrows \
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
@@ -333,19 +326,20 @@ f_dialog_input_group_members()
# Return if user has either pressed ESC or chosen Cancel/No
[ $retval -eq $SUCCESS ] || return $retval
+ local _group_members
case "$menu_choice" in
X) # Exit
break ;;
1) # Select Group Members from a list
- user_list=$( pw usershow -a | awk -F: '
- !/^[[:space:]]*(#|$)/ { printf "%s\n", $1 }' )
- checklist_users=
- for user in $user_list; do
- checklist_users="$checklist_users $user \"\""
+ local user check_list=
+ for user in $( pw usershow -a |
+ awk -F: '!/^[[:space:]]*(#|$)/{print $1}'
+ ); do
+ # Format of a checklist entry: tag item status
if echo "$_input" | grep -q "\<$user\>"; then
- checklist_users="$checklist_users on"
+ check_list="$check_list $user '' on"
else
- checklist_users="$checklist_users off"
+ check_list="$check_list $user '' off"
fi
done
@@ -353,9 +347,9 @@ f_dialog_input_group_members()
eval f_dialog_checklist_size cheight cwidth crows \
\"\$DIALOG_TITLE\" \
\"\$DIALOG_BACKTITLE\" \
- \"\" \
+ \"\$prompt\" \
\"\$hline\" \
- $checklist_users
+ $check_list
_group_members=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
@@ -363,9 +357,9 @@ f_dialog_input_group_members()
--hline \"\$hline\" \
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
- --checklist \"\$msg\" \
+ --checklist \"\$prompt\" \
$cheight $cwidth $crows \
- $checklist_users \
+ $check_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
) || continue
# Return to previous menu if user either
@@ -383,9 +377,9 @@ f_dialog_input_group_members()
_input="$_group_members"
;;
2) # Enter Group Members manually
- msg="$msg_group_members ($msg_separated_by_commas)"
+ local p="$msg_group_members ($msg_separated_by_commas)"
- f_dialog_input _group_members "$msg" "$_input" \
+ f_dialog_input _group_members "$p" "$_input" \
"$hline_num_tab_enter" || continue
# Return to previous menu if user either
# pressed ESC or chose Cancel/No
diff --git a/usr.sbin/bsdconfig/usermgmt/share/user_input.subr b/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
index 7b79d7b..63f4583 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
@@ -90,13 +90,12 @@ f_input_user()
#
f_dialog_menu_user_list()
{
- local defaultitem="$1"
- local menu_list
- local hline="$hline_alnum_punc_tab_enter"
-
- menu_list="
+ local prompt=
+ local menu_list="
'X $msg_exit' ''
" # END-QUOTE
+ local defaultitem="$1"
+ local hline="$hline_alnum_punc_tab_enter"
# Add users from passwd(5)
menu_list="$menu_list $( pw usershow -a | awk -F: '
@@ -109,7 +108,7 @@ f_dialog_menu_user_list()
eval f_dialog_menu_size height width rows \
\"\$DIALOG_TITLE\" \
\"\$DIALOG_BACKTITLE\" \
- \"\" \
+ \"\$prompt\" \
\"\$hline\" \
$menu_list
@@ -121,7 +120,7 @@ f_dialog_menu_user_list()
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
--default-item \"\$defaultitem\" \
- --menu \"\" \
+ --menu \"\$prompt\" \
$height $width $rows \
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
@@ -139,35 +138,38 @@ f_dialog_menu_user_list()
#
f_dialog_input_member_groups()
{
- local msg="$( printf "$msg_member_of_groups" )"
+ local _member_groups="$1"
+ local prompt="$msg_member_of_groups"
+ local check_list= # Calculated below
local hline="$hline_alnum_space_tab_enter"
+ local group
#
- # Loop until the user provides taint-free/valid input
+ # Generate the checklist menu
#
- local retval all_groups checklist_groups="" _member_groups="$1"
- all_groups=$( pw groupshow -a | awk -F: '
- !/^[[:space:]]*(#|$)/ {
- printf "%s\n", $1
- }'
- )
- for grp in $all_groups; do
- checklist_groups="$checklist_groups $grp $grp"
- if echo "$_member_groups" | grep -q "\<$grp\>"; then
- checklist_groups="$checklist_groups on"
+ for group in $(
+ pw groupshow -a | awk -F: '!/^[[:space:]]*(#|$)/{print $1}'
+ ); do
+ # Format of a checklist menu entry is "tag item status"
+ # (setting both tag and item to the group name below).
+ if echo "$_member_groups" | grep -q "\<$group\>"; then
+ check_list="$check_list $group $group on"
else
- checklist_groups="$checklist_groups off"
+ check_list="$check_list $group $group off"
fi
done
+ #
+ # Loop until the user provides taint-free/valid input
+ #
local height width rows
while :; do
eval f_dialog_checklist_size height width rows \
\"\$DIALOG_TITLE\" \
\"\$DIALOG_BACKTITLE\" \
- \"\" \
+ \"\$prompt\" \
\"\$hline\" \
- $checklist_groups
+ $check_list
_member_groups=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
@@ -175,9 +177,9 @@ f_dialog_input_member_groups()
--hline \"\$hline\" \
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
- --checklist \"\$msg\" \
+ --checklist \"\$prompt\" \
$height $width $rows \
- $checklist_groups \
+ $check_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
) || return $?
# Return if user either pressed ESC or chose Cancel/No
@@ -186,7 +188,7 @@ f_dialog_input_member_groups()
#
# Validate each of the groups the user has entered
#
- local group all_groups_valid=1
+ local all_groups_valid=1
for group in $_member_groups; do
if ! f_quietly pw groupshow -n "$group"; then
f_show_msg "$msg_group_not_found" "$group"
@@ -272,24 +274,22 @@ f_dialog_input_name()
#
f_dialog_input_password()
{
+ local prompt1="$msg_password"
+ local prompt2="$msg_reenter_password"
local hline="$hline_alnum_punc_tab_enter"
- local msg rmsg
- msg=$( printf "$msg_password" )
local height1 width1
f_dialog_inputbox_size height1 width1 \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
- "$msg" \
+ "$prompt1" \
"" \
"$hline"
-
- rmsg=$( printf "$msg_reenter_password" )
local height2 width2
f_dialog_inputbox_size height2 width2 \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
- "$rmsg" \
+ "$prompt2" \
"" \
"$hline"
@@ -305,7 +305,7 @@ f_dialog_input_password()
--ok-label "$msg_ok" \
--cancel-label "$msg_cancel" \
--insecure \
- --passwordbox "$msg" \
+ --passwordbox "$prompt1" \
$height1 $width1 \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
) || return $?
@@ -319,7 +319,7 @@ f_dialog_input_password()
--ok-label "$msg_ok" \
--cancel-label "$msg_cancel" \
--insecure \
- --passwordbox "$rmsg" \
+ --passwordbox "$prompt2" \
$height2 $width2 \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
) || return $?
@@ -450,35 +450,34 @@ f_dialog_input_class()
#
f_dialog_input_change()
{
- local retval _input="$1"
- local msg="$msg_password_expires_on"
- local hline="$hline_num_arrows_tab_enter"
-
+ local prompt="$msg_password_expires_on"
local menu_list="
'1' '$msg_password_does_not_expire'
'2' '$msg_edit_date_time_with_a_calendar'
'3' '$msg_enter_number_of_days_into_the_future'
'4' '$msg_enter_value_manually'
" # END-QUOTE
+ local hline="$hline_num_arrows_tab_enter"
+ local retval _input="$1"
local mheight mwidth mrows
eval f_dialog_menu_size mheight mwidth mrows \
\"\$DIALOG_TITLE\" \
\"\$DIALOG_BACKTITLE\" \
- \"\$msg\" \
+ \"\$prompt\" \
\"\$hline\" \
$menu_list
local cheight cwidth
f_dialog_calendar_size cheight cwidth \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
- "$msg" \
+ "$prompt" \
"$hline"
local theight twidth
f_dialog_timebox_size theight twidth \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
- "$msg" \
+ "$prompt" \
"$hline"
#
@@ -492,7 +491,7 @@ f_dialog_input_change()
--hline \"\$hline\" \
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
- --menu \"\$msg\" \
+ --menu \"\$prompt\" \
$mheight $mwidth $mrows \
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
@@ -522,7 +521,7 @@ f_dialog_input_change()
--hline \"\$hline\" \
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
- --calendar \"\$msg\" \
+ --calendar \"\$prompt\" \
$cheight $cwidth \
$_input_date \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
@@ -543,7 +542,7 @@ f_dialog_input_change()
--hline \"\$hline\" \
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
- --timebox \"\$msg\" \
+ --timebox \"\$prompt\" \
$theight $twidth \
$_input_time \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
@@ -592,6 +591,7 @@ f_dialog_input_change()
break ;;
4) # Enter value manually
+ local msg
msg=$( printf "$msg_number_of_seconds_since_epoch" \
"$( date -r 1 "+%c %Z" )" )
@@ -631,35 +631,34 @@ f_dialog_input_change()
#
f_dialog_input_expire()
{
- local retval _input="$1"
- local msg="$msg_account_expires_on"
- local hline="$hline_num_arrows_tab_enter"
-
+ local prompt="$msg_account_expires_on"
local menu_list="
'1' '$msg_account_does_not_expire'
'2' '$msg_edit_date_time_with_a_calendar'
'3' '$msg_enter_number_of_days_into_the_future'
'4' '$msg_enter_value_manually'
" # END-QUOTE
+ local hline="$hline_num_arrows_tab_enter"
+ local retval _input="$1"
local mheight mwidth mrows
eval f_dialog_menu_size mheight mwidth mrows \
\"\$DIALOG_TITLE\" \
\"\$DIALOG_BACKTITLE\" \
- \"\$msg\" \
+ \"\$prompt\" \
\"\$hline\" \
$menu_list
local cheight cwidth
f_dialog_calendar_size cheight cwidth \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
- "$msg" \
+ "$prompt" \
"$hline"
local theight twidth
f_dialog_timebox_size theight twidth \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
- "$msg" \
+ "$prompt" \
"$hline"
#
@@ -673,7 +672,7 @@ f_dialog_input_expire()
--hline \"\$hline\" \
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
- --menu \"\$msg\" \
+ --menu \"\$prompt\" \
$mheight $mwidth $mrows \
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
@@ -703,7 +702,7 @@ f_dialog_input_expire()
--hline \"\$hline\" \
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
- --calendar \"\$msg\" \
+ --calendar \"\$prompt\" \
$cheight $cwidth \
$_input_date \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
@@ -724,7 +723,7 @@ f_dialog_input_expire()
--hline \"\$hline\" \
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
- --timebox \"\$msg\" \
+ --timebox \"\$prompt\" \
$theight $twidth \
$_input_time \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
@@ -773,6 +772,7 @@ f_dialog_input_expire()
break ;;
4) # Enter value manually
+ local msg
msg=$( printf "$msg_number_of_seconds_since_epoch" \
"$( date -r 1 "+%c %Z" )" )
@@ -959,20 +959,23 @@ f_dialog_input_dotfiles_create()
#
f_dialog_input_shell()
{
- local shells shell_list _input="$1"
- local hline="$hline_arrows_space_tab_enter"
+ local _input="$1"
local prompt="$msg_select_login_shell"
+ local radio_list= # Calculated below
+ local hline="$hline_arrows_space_tab_enter"
- shells=$( awk '!/^[[:space:]]*(#|$)/{print}' "$ETC_SHELLS" )
- shell_list=$(
- for shell in $shells; do
- if [ "$shell" = "$_input" ]; then
- echo "'$shell' '' 'on'"
- else
- echo "'$shell' '' 'off'"
- fi
- done
- )
+ #
+ # Generate the radiolist of shells
+ #
+ local shell
+ for shell in $( awk '!/^[[:space:]]*(#|$)/{print}' "$ETC_SHELLS" ); do
+ # Format of a radiolist menu entry is "tag item status"
+ if [ "$shell" = "$_input" ]; then
+ radio_list="$radio_list '$shell' '' 'on'"
+ else
+ radio_list="$radio_list '$shell' '' 'off'"
+ fi
+ done
local height width rows
eval f_dialog_radiolist_size height width rows \
@@ -980,7 +983,7 @@ f_dialog_input_shell()
\"\$DIALOG_BACKTITLE\" \
\"\$prompt\" \
\"\$hline\" \
- $shell_list
+ $radio_list
_input=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
@@ -990,7 +993,7 @@ f_dialog_input_shell()
--cancel-label \"\$msg_cancel\" \
--radiolist \"\$prompt\" \
$height $width $rows \
- $shell_list \
+ $radio_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
) || return $?
# Return if user either pressed ESC or chose Cancel/No
diff --git a/usr.sbin/bsdconfig/usermgmt/usermgmt b/usr.sbin/bsdconfig/usermgmt/usermgmt
index 880985f..96f7e6f 100755
--- a/usr.sbin/bsdconfig/usermgmt/usermgmt
+++ b/usr.sbin/bsdconfig/usermgmt/usermgmt
@@ -51,11 +51,8 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
#
dialog_menu_main()
{
- local menu_list
- local hline="$hline_arrows_tab_enter"
- local defaultitem= # Calculated below
-
- menu_list="
+ local prompt=
+ local menu_list="
'X' '$msg_exit'
'1' '$msg_add_login'
'2' '$msg_edit_login'
@@ -65,12 +62,14 @@ dialog_menu_main()
'5' '$msg_edit_group'
'6' '$msg_delete_group'
" # END-QUOTE
+ local defaultitem= # Calculated below
+ local hline="$hline_arrows_tab_enter"
local height width rows
eval f_dialog_menu_size height width rows \
\"\$DIALOG_TITLE\" \
\"\$DIALOG_BACKTITLE\" \
- \"\" \
+ \"\$prompt\" \
\"\$hline\" \
$menu_list
@@ -91,7 +90,7 @@ dialog_menu_main()
--help-label \"\$msg_help\" \
${USE_XDIALOG:+--help \"\"} \
--default-item \"\$defaultitem\" \
- --menu \"\" \
+ --menu \"\$prompt\" \
$height $width $rows \
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
OpenPOWER on IntegriCloud