1ab2043b8SDevin Teskeif [ ! "$_USERMGMT_GROUP_INPUT_SUBR" ]; then _USERMGMT_GROUP_INPUT_SUBR=1 2ab2043b8SDevin Teske# 3ab2043b8SDevin Teske# Copyright (c) 2012 Ron McDowell 4ab2043b8SDevin Teske# Copyright (c) 2012 Devin Teske 5ab2043b8SDevin Teske# All rights reserved. 6ab2043b8SDevin Teske# 7ab2043b8SDevin Teske# Redistribution and use in source and binary forms, with or without 8ab2043b8SDevin Teske# modification, are permitted provided that the following conditions 9ab2043b8SDevin Teske# are met: 10ab2043b8SDevin Teske# 1. Redistributions of source code must retain the above copyright 11ab2043b8SDevin Teske# notice, this list of conditions and the following disclaimer. 12ab2043b8SDevin Teske# 2. Redistributions in binary form must reproduce the above copyright 13ab2043b8SDevin Teske# notice, this list of conditions and the following disclaimer in the 14ab2043b8SDevin Teske# documentation and/or other materials provided with the distribution. 15ab2043b8SDevin Teske# 16ab2043b8SDevin Teske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17ab2043b8SDevin Teske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18ab2043b8SDevin Teske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19ab2043b8SDevin Teske# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20ab2043b8SDevin Teske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21ab2043b8SDevin Teske# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22ab2043b8SDevin Teske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23ab2043b8SDevin Teske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24ab2043b8SDevin Teske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25ab2043b8SDevin Teske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26ab2043b8SDevin Teske# SUCH DAMAGE. 27ab2043b8SDevin Teske# 28ab2043b8SDevin Teske# $FreeBSD$ 29ab2043b8SDevin Teske# 30ab2043b8SDevin Teske############################################################ INCLUDES 31ab2043b8SDevin Teske 32ab2043b8SDevin TeskeBSDCFG_SHARE="/usr/share/bsdconfig" 33ab2043b8SDevin Teske. $BSDCFG_SHARE/common.subr || exit 1 34ab2043b8SDevin Teskef_include $BSDCFG_SHARE/dialog.subr 35ab2043b8SDevin Teskef_include $BSDCFG_SHARE/strings.subr 36ab2043b8SDevin Teske 37ab2043b8SDevin TeskeBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt" 38ab2043b8SDevin Teskef_include_lang $BSDCFG_LIBE/include/messages.subr 39ab2043b8SDevin Teskef_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 40ab2043b8SDevin Teske 41ab2043b8SDevin Teske############################################################ FUNCTIONS 42ab2043b8SDevin Teske 43ab2043b8SDevin Teske# f_input_group $group 44ab2043b8SDevin Teske# 45ab2043b8SDevin Teske# Given $group name or id, create the environment variables group_name, 46ab2043b8SDevin Teske# group_gid, and group_members (and group_password is reset to NULL). 47ab2043b8SDevin Teske# 48ab2043b8SDevin Teskef_input_group() 49ab2043b8SDevin Teske{ 50ab2043b8SDevin Teske eval $( pw groupshow "$1" | awk -F: ' 51ab2043b8SDevin Teske { 52ab2043b8SDevin Teske printf "group_name='\'%s\''\n", $1 53ab2043b8SDevin Teske printf "group_password=\n" 54ab2043b8SDevin Teske printf "group_gid='\'%s\''\n", $3 55ab2043b8SDevin Teske printf "group_members='\'%s\''\n", $4 56ab2043b8SDevin Teske exit 57ab2043b8SDevin Teske }' ) 58ab2043b8SDevin Teske} 59ab2043b8SDevin Teske 60ab2043b8SDevin Teske# f_dialog_menu_group_list 61ab2043b8SDevin Teske# 62ab2043b8SDevin Teske# Allows the user to select a group from a list. 63ab2043b8SDevin Teske# 64ab2043b8SDevin Teskef_dialog_menu_group_list() 65ab2043b8SDevin Teske{ 66ab2043b8SDevin Teske local menu_list size 67ab2043b8SDevin Teske local hline="$hline_alnum_punc_tab_enter" 68ab2043b8SDevin Teske 69ab2043b8SDevin Teske menu_list=" 70ab2043b8SDevin Teske 'X $msg_exit' '' 71ab2043b8SDevin Teske " # END-QUOTE 72ab2043b8SDevin Teske 73ab2043b8SDevin Teske # Add groups from group(5) 74ab2043b8SDevin Teske menu_list="$menu_list $( pw groupshow -a | awk -F: ' 75ab2043b8SDevin Teske !/^[[:space:]]*(#|$)/ { 76ab2043b8SDevin Teske printf "'\'%s\'\ \'%s\''\n", $1, $1 77ab2043b8SDevin Teske }' 78ab2043b8SDevin Teske )" 79ab2043b8SDevin Teske 80ab2043b8SDevin Teske size=$( eval f_dialog_menu_size \ 81ab2043b8SDevin Teske \"\$DIALOG_TITLE\" \ 82ab2043b8SDevin Teske \"\$DIALOG_BACKTITLE\" \ 83ab2043b8SDevin Teske \"\" \ 84ab2043b8SDevin Teske \"\$hline\" \ 85ab2043b8SDevin Teske $menu_list ) 86ab2043b8SDevin Teske 87*89498fdfSDevin Teske local dialog_menu 88*89498fdfSDevin Teske dialog_menu=$( eval $DIALOG \ 89ab2043b8SDevin Teske --clear --title \"\$DIALOG_TITLE\" \ 90ab2043b8SDevin Teske --backtitle \"\$DIALOG_BACKTITLE\" \ 91ab2043b8SDevin Teske --hline \"\$hline\" \ 92ab2043b8SDevin Teske --ok-label \"\$msg_ok\" \ 93ab2043b8SDevin Teske --cancel-label \"\$msg_cancel\" \ 94ab2043b8SDevin Teske --menu \"\" $size $menu_list \ 95*89498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 96*89498fdfSDevin Teske ) 97*89498fdfSDevin Teske local retval=$? 98*89498fdfSDevin Teske setvar DIALOG_MENU_$$ "$dialog_menu" 99*89498fdfSDevin Teske return $retval 100ab2043b8SDevin Teske} 101ab2043b8SDevin Teske 102ab2043b8SDevin Teske# f_dialog_input_group_name [$group_name] 103ab2043b8SDevin Teske# 104ab2043b8SDevin Teske# Allows the user to enter a new groupname for a given group. If the user does 105ab2043b8SDevin Teske# not cancel or press ESC, the $group_name variable will hold the 106ab2043b8SDevin Teske# newly-configured value upon return. 107ab2043b8SDevin Teske# 108ab2043b8SDevin Teske# If $cur_group_name is defined, the user can enter that and by-pass error- 109ab2043b8SDevin Teske# checking (allowing the user to "revert" to an old value without, for example, 110ab2043b8SDevin Teske# being told that the groupname already exists). 111ab2043b8SDevin Teske# 112ab2043b8SDevin Teskef_dialog_input_group_name() 113ab2043b8SDevin Teske{ 114ab2043b8SDevin Teske local msg="$( printf "$msg_group" )" 115ab2043b8SDevin Teske local hline="$hline_alnum_tab_enter" 116ab2043b8SDevin Teske 117ab2043b8SDevin Teske # 118ab2043b8SDevin Teske # Loop until the user provides taint-free/valid input 119ab2043b8SDevin Teske # 120ab2043b8SDevin Teske local size retval _name="$1" _input="$1" 121ab2043b8SDevin Teske while :; do 122ab2043b8SDevin Teske size=$( f_dialog_inputbox_size \ 123ab2043b8SDevin Teske "$DIALOG_TITLE" \ 124ab2043b8SDevin Teske "$DIALOG_BACKTITLE" \ 125ab2043b8SDevin Teske "$msg" \ 126ab2043b8SDevin Teske "$_input" \ 127ab2043b8SDevin Teske "$hline" ) 128ab2043b8SDevin Teske 129*89498fdfSDevin Teske local dialog_inputbox 130*89498fdfSDevin Teske dialog_inputbox=$( eval $DIALOG \ 131ab2043b8SDevin Teske --title \"\$DIALOG_TITLE\" \ 132ab2043b8SDevin Teske --backtitle \"\$DIALOG_BACKTITLE\" \ 133ab2043b8SDevin Teske --hline \"\$hline\" \ 134ab2043b8SDevin Teske --ok-label \"\$msg_ok\" \ 135ab2043b8SDevin Teske --cancel-label \"\$msg_cancel\" \ 136ab2043b8SDevin Teske --inputbox \"\$msg\" $size \ 137ab2043b8SDevin Teske \"\$_input\" \ 138*89498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 139*89498fdfSDevin Teske ) 140ab2043b8SDevin Teske 141ab2043b8SDevin Teske retval=$? 142*89498fdfSDevin Teske setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" 143ab2043b8SDevin Teske _input=$( f_dialog_inputstr ) 144ab2043b8SDevin Teske 145ab2043b8SDevin Teske # Return if user has either pressed ESC or chosen Cancel/No 146ab2043b8SDevin Teske [ $retval -eq $SUCCESS ] || return $retval 147ab2043b8SDevin Teske 148ab2043b8SDevin Teske # Check for no-change 149ab2043b8SDevin Teske [ "$_input" = "$_name" ] && return $SUCCESS 150ab2043b8SDevin Teske 151ab2043b8SDevin Teske # Check for reversion 152ab2043b8SDevin Teske if [ "$_input" = "$cur_group_name" ]; then 153ab2043b8SDevin Teske group_name="$cur_group_name" 154ab2043b8SDevin Teske return $SUCCESS 155ab2043b8SDevin Teske fi 156ab2043b8SDevin Teske 157ab2043b8SDevin Teske # Check for NULL entry 158ab2043b8SDevin Teske if [ ! "$_input" ]; then 159ab2043b8SDevin Teske f_show_msg "$msg_group_is_empty" 160ab2043b8SDevin Teske continue 161ab2043b8SDevin Teske fi 162ab2043b8SDevin Teske 163ab2043b8SDevin Teske # Check for invalid entry 164ab2043b8SDevin Teske if ! echo "$_input" | grep -q "^[[:alpha:]]"; then 165ab2043b8SDevin Teske f_show_msg "$msg_group_must_start_with_letter" 166ab2043b8SDevin Teske continue 167ab2043b8SDevin Teske fi 168ab2043b8SDevin Teske 169ab2043b8SDevin Teske # Check for duplicate entry 170ab2043b8SDevin Teske if f_quietly pw groupshow -n "$_input"; then 171ab2043b8SDevin Teske f_show_msg "$msg_group_already_used" "$_input" 172ab2043b8SDevin Teske continue 173ab2043b8SDevin Teske fi 174ab2043b8SDevin Teske 175ab2043b8SDevin Teske group_name="$_input" 176ab2043b8SDevin Teske break 177ab2043b8SDevin Teske done 178ab2043b8SDevin Teske save_flag=1 179ab2043b8SDevin Teske 180ab2043b8SDevin Teske f_dprintf "group_name: [$cur_group_name]->[$group_name]" 181ab2043b8SDevin Teske 182ab2043b8SDevin Teske return $SUCCESS 183ab2043b8SDevin Teske} 184ab2043b8SDevin Teske 185ab2043b8SDevin Teske# f_dialog_input_group_password 186ab2043b8SDevin Teske# 187ab2043b8SDevin Teske# Prompt the user to enter a password (twice). 188ab2043b8SDevin Teske# 189ab2043b8SDevin Teskef_dialog_input_group_password() 190ab2043b8SDevin Teske{ 191ab2043b8SDevin Teske local hline="$hline_alnum_punc_tab_enter" 192ab2043b8SDevin Teske local msg size rmsg rsize 193ab2043b8SDevin Teske 194ab2043b8SDevin Teske msg=$( printf "$msg_group_password" ) 195ab2043b8SDevin Teske size=$( f_dialog_inputbox_size \ 196ab2043b8SDevin Teske "$DIALOG_TITLE" \ 197ab2043b8SDevin Teske "$DIALOG_BACKTITLE" \ 198ab2043b8SDevin Teske "$msg" \ 199ab2043b8SDevin Teske "" \ 200ab2043b8SDevin Teske "$hline" ) 201ab2043b8SDevin Teske 202ab2043b8SDevin Teske rmsg=$( printf "$msg_reenter_group_password" ) 203ab2043b8SDevin Teske rsize=$( f_dialog_inputbox_size \ 204ab2043b8SDevin Teske "$DIALOG_TITLE" \ 205ab2043b8SDevin Teske "$DIALOG_BACKTITLE" \ 206ab2043b8SDevin Teske "$rmsg" \ 207ab2043b8SDevin Teske "" \ 208ab2043b8SDevin Teske "$hline" ) 209ab2043b8SDevin Teske 210ab2043b8SDevin Teske # 211ab2043b8SDevin Teske # Loop until the user provides taint-free/valid input 212ab2043b8SDevin Teske # 213ab2043b8SDevin Teske local retval _password1 _password2 214ab2043b8SDevin Teske while :; do 215*89498fdfSDevin Teske local dialog_inputbox 216*89498fdfSDevin Teske dialog_inputbox=$( eval $DIALOG \ 217ab2043b8SDevin Teske --title \"\$DIALOG_TITLE\" \ 218ab2043b8SDevin Teske --backtitle \"\$DIALOG_BACKTITLE\" \ 219ab2043b8SDevin Teske --hline \"\$hline\" \ 220ab2043b8SDevin Teske --ok-label \"\$msg_ok\" \ 221ab2043b8SDevin Teske --cancel-label \"\$msg_cancel\" \ 222ab2043b8SDevin Teske --insecure \ 223ab2043b8SDevin Teske --passwordbox \"\$msg\" $size \ 224*89498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 225*89498fdfSDevin Teske ) 226ab2043b8SDevin Teske 227ab2043b8SDevin Teske retval=$? 228*89498fdfSDevin Teske setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" 229ab2043b8SDevin Teske _password1=$( f_dialog_inputstr ) 230ab2043b8SDevin Teske 231ab2043b8SDevin Teske # Return if user has either pressed ESC or chosen Cancel/No 232ab2043b8SDevin Teske [ $retval -eq $SUCCESS ] || return $retval 233ab2043b8SDevin Teske 234*89498fdfSDevin Teske dialog_inputbox=$( eval $DIALOG \ 235ab2043b8SDevin Teske --title \"\$DIALOG_TITLE\" \ 236ab2043b8SDevin Teske --backtitle \"\$DIALOG_BACKTITLE\" \ 237ab2043b8SDevin Teske --hline \"\$hline\" \ 238ab2043b8SDevin Teske --ok-label \"\$msg_ok\" \ 239ab2043b8SDevin Teske --cancel-label \"\$msg_cancel\" \ 240ab2043b8SDevin Teske --insecure \ 241ab2043b8SDevin Teske --passwordbox \"\$rmsg\" $rsize \ 242*89498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 243*89498fdfSDevin Teske ) 244ab2043b8SDevin Teske 245ab2043b8SDevin Teske retval=$? 246*89498fdfSDevin Teske setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" 247ab2043b8SDevin Teske _password2=$( f_dialog_inputstr ) 248ab2043b8SDevin Teske 249ab2043b8SDevin Teske # Return if user has either pressed ESC or chosen Cancel/No 250ab2043b8SDevin Teske [ $retval -eq $SUCCESS ] || return $retval 251ab2043b8SDevin Teske 252ab2043b8SDevin Teske # Check for password mismatch 253ab2043b8SDevin Teske if [ "$_password1" != "$_password2" ]; then 254ab2043b8SDevin Teske f_show_msg "$msg_group_passwords_do_not_match" 255ab2043b8SDevin Teske continue 256ab2043b8SDevin Teske fi 257ab2043b8SDevin Teske 258ab2043b8SDevin Teske # Check for NULL entry 259ab2043b8SDevin Teske if [ ! "$_password1" ]; then 260ab2043b8SDevin Teske f_dialog_yesno \ 261ab2043b8SDevin Teske "$msg_disable_password_auth_for_group" || 262ab2043b8SDevin Teske continue 263ab2043b8SDevin Teske pw_group_password_disable=1 264ab2043b8SDevin Teske else 265ab2043b8SDevin Teske pw_group_password_disable= 266ab2043b8SDevin Teske fi 267ab2043b8SDevin Teske 268ab2043b8SDevin Teske group_password="$_password1" 269ab2043b8SDevin Teske break 270ab2043b8SDevin Teske done 271ab2043b8SDevin Teske save_flag=1 272ab2043b8SDevin Teske 273ab2043b8SDevin Teske f_dprintf "group_password: [$cur_group_password]->[$group_password]" 274ab2043b8SDevin Teske 275ab2043b8SDevin Teske return $SUCCESS 276ab2043b8SDevin Teske} 277ab2043b8SDevin Teske 278ab2043b8SDevin Teske# f_dialog_input_group_gid [$group_gid] 279ab2043b8SDevin Teske# 280ab2043b8SDevin Teske# Allow the user to enter a new GID for a given group. If the user does not 281ab2043b8SDevin Teske# cancel or press ESC, the $group_gid variable will hold the newly-configured 282ab2043b8SDevin Teske# value upon return. 283ab2043b8SDevin Teske# 284ab2043b8SDevin Teskef_dialog_input_group_gid() 285ab2043b8SDevin Teske{ 286ab2043b8SDevin Teske local msg size retval _input="$1" 287ab2043b8SDevin Teske local hline="$hline_num_tab_enter" 288ab2043b8SDevin Teske 289ab2043b8SDevin Teske msg=$( printf "$msg_group_id_leave_empty_for_default" ) 290ab2043b8SDevin Teske size=$( f_dialog_inputbox_size \ 291ab2043b8SDevin Teske "$DIALOG_TITLE" \ 292ab2043b8SDevin Teske "$DIALOG_BACKTITLE" \ 293ab2043b8SDevin Teske "$msg" \ 294ab2043b8SDevin Teske "$_input" \ 295ab2043b8SDevin Teske "$hline" ) 296ab2043b8SDevin Teske 297*89498fdfSDevin Teske local dialog_inputbox 298*89498fdfSDevin Teske dialog_inputbox=$( eval $DIALOG \ 299ab2043b8SDevin Teske --title \"\$DIALOG_TITLE\" \ 300ab2043b8SDevin Teske --backtitle \"\$DIALOG_BACKTITLE\" \ 301ab2043b8SDevin Teske --hline \"\$hline\" \ 302ab2043b8SDevin Teske --ok-label \"\$msg_ok\" \ 303ab2043b8SDevin Teske --cancel-label \"\$msg_cancel\" \ 304ab2043b8SDevin Teske --inputbox \"\$msg\" $size \ 305ab2043b8SDevin Teske \"\$_input\" \ 306*89498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 307*89498fdfSDevin Teske ) 308ab2043b8SDevin Teske 309ab2043b8SDevin Teske retval=$? 310*89498fdfSDevin Teske setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" 311ab2043b8SDevin Teske _input=$( f_dialog_inputstr ) 312ab2043b8SDevin Teske 313ab2043b8SDevin Teske # Return if user has either pressed ESC or chosen Cancel/No 314ab2043b8SDevin Teske [ $retval -eq $SUCCESS ] || return $retval 315ab2043b8SDevin Teske 316ab2043b8SDevin Teske group_gid="$_input" 317ab2043b8SDevin Teske save_flag=1 318ab2043b8SDevin Teske 319ab2043b8SDevin Teske f_dprintf "group_gid: [$cur_group_gid]->[$group_gid]" 320ab2043b8SDevin Teske 321ab2043b8SDevin Teske return $SUCCESS 322ab2043b8SDevin Teske} 323ab2043b8SDevin Teske 324ab2043b8SDevin Teske# f_dialog_input_group_members [$group_members] 325ab2043b8SDevin Teske# 326ab2043b8SDevin Teske# Allow the user to modify a list of members for a given group. If the user does 327ab2043b8SDevin Teske# not cancel or press ESC, the $group_members variable will hold the newly- 328ab2043b8SDevin Teske# configured value upon return. 329ab2043b8SDevin Teske# 330ab2043b8SDevin Teskef_dialog_input_group_members() 331ab2043b8SDevin Teske{ 332ab2043b8SDevin Teske local menu_choice msg size retval _input="$1" 333ab2043b8SDevin Teske local hline="$hline_num_arrows_tab_enter" 334ab2043b8SDevin Teske local user 335ab2043b8SDevin Teske local menu_list 336ab2043b8SDevin Teske local all_users_valid 337ab2043b8SDevin Teske local _group_members 338ab2043b8SDevin Teske local checklist_users 339ab2043b8SDevin Teske 340ab2043b8SDevin Teske menu_list=" 341ab2043b8SDevin Teske 'X' '$msg_continue' 342ab2043b8SDevin Teske '1' '$msg_select_group_members_from_list' 343ab2043b8SDevin Teske '2' '$msg_enter_group_members_manually' 344ab2043b8SDevin Teske " # END-QUOTE 345ab2043b8SDevin Teske 346*89498fdfSDevin Teske local dialog_menu 347ab2043b8SDevin Teske while :; do 348ab2043b8SDevin Teske msg="$msg_group_members:" 349ab2043b8SDevin Teske menu_size=$( eval f_dialog_menu_size \ 350ab2043b8SDevin Teske \"\$DIALOG_TITLE\" \ 351ab2043b8SDevin Teske \"\$DIALOG_BACKTITLE\" \ 352ab2043b8SDevin Teske \"\$msg\" \ 353ab2043b8SDevin Teske \"\$hline\" \ 354ab2043b8SDevin Teske $menu_list ) 355*89498fdfSDevin Teske dialog_menu=$( eval $DIALOG \ 356ab2043b8SDevin Teske --title \"\$DIALOG_TITLE\" \ 357ab2043b8SDevin Teske --backtitle \"\$DIALOG_BACKTITLE\" \ 358ab2043b8SDevin Teske --hline \"\$hline\" \ 359ab2043b8SDevin Teske --ok-label \"\$msg_ok\" \ 360ab2043b8SDevin Teske --cancel-label \"\$msg_cancel\" \ 361ab2043b8SDevin Teske --menu \"\$msg\" $menu_size \ 362ab2043b8SDevin Teske $menu_list \ 363*89498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 364*89498fdfSDevin Teske ) 365ab2043b8SDevin Teske retval=$? 366*89498fdfSDevin Teske setvar DIALOG_MENU_$$ "$dialog_menu" 367ab2043b8SDevin Teske menu_choice=$( f_dialog_menutag ) 368ab2043b8SDevin Teske f_dprintf "retval=$retval menu_choice=[$menu_choice]" 369ab2043b8SDevin Teske 370ab2043b8SDevin Teske # Return if user has either pressed ESC or chosen Cancel/No 371ab2043b8SDevin Teske [ $retval -eq $SUCCESS ] || return $retval 372ab2043b8SDevin Teske 373ab2043b8SDevin Teske case "$menu_choice" in 374ab2043b8SDevin Teske X) # Exit 375ab2043b8SDevin Teske break ;; 376ab2043b8SDevin Teske 1) # Select Group Members from a list 377ab2043b8SDevin Teske user_list=$( pw usershow -a | awk -F: ' 378ab2043b8SDevin Teske !/^[[:space:]]*(#|$)/ { printf "%s\n", $1 }' ) 379ab2043b8SDevin Teske checklist_users= 380ab2043b8SDevin Teske for user in $user_list; do 381ab2043b8SDevin Teske checklist_users="$checklist_users $user \"\"" 382ab2043b8SDevin Teske if echo "$_input" | grep -q "\<$user\>"; then 383ab2043b8SDevin Teske checklist_users="$checklist_users on" 384ab2043b8SDevin Teske else 385ab2043b8SDevin Teske checklist_users="$checklist_users off" 386ab2043b8SDevin Teske fi 387ab2043b8SDevin Teske done 388ab2043b8SDevin Teske 389ab2043b8SDevin Teske size=$( eval f_dialog_radiolist_size \ 390ab2043b8SDevin Teske \"\$DIALOG_TITLE\" \ 391ab2043b8SDevin Teske \"\$DIALOG_BACKTITLE\" \ 392ab2043b8SDevin Teske \"\" \ 393ab2043b8SDevin Teske \"\$hline\" \ 394ab2043b8SDevin Teske $checklist_users ) 395*89498fdfSDevin Teske local dialog_inputbox 396*89498fdfSDevin Teske dialog_inputbox=$( eval $DIALOG \ 397ab2043b8SDevin Teske --title \"\$DIALOG_TITLE\" \ 398ab2043b8SDevin Teske --backtitle \"\$DIALOG_BACKTITLE\" \ 399ab2043b8SDevin Teske --separate-output \ 400ab2043b8SDevin Teske --hline \"\$hline\" \ 401ab2043b8SDevin Teske --ok-label \"\$msg_ok\" \ 402ab2043b8SDevin Teske --cancel-label \"\$msg_cancel\" \ 403ab2043b8SDevin Teske --checklist \"\$msg\" $size \ 404ab2043b8SDevin Teske $checklist_users \ 405*89498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 406*89498fdfSDevin Teske ) 407ab2043b8SDevin Teske retval=$? 408*89498fdfSDevin Teske setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" 409ab2043b8SDevin Teske _group_members=$( f_dialog_inputstr | tr '\n' ' ' | 410ab2043b8SDevin Teske sed -e 's/[[:space:]]\{1,\}/,/g;s/^,//;s/,$//' ) 411ab2043b8SDevin Teske 412ab2043b8SDevin Teske # Return to previous menu if user has either 413ab2043b8SDevin Teske # pressed ESC or chosen Cancel/No 414ab2043b8SDevin Teske [ $retval -eq $SUCCESS ] || continue 415ab2043b8SDevin Teske 416ab2043b8SDevin Teske _input="$_group_members" 417ab2043b8SDevin Teske ;; 418ab2043b8SDevin Teske 2) # Enter Group Members manually 419ab2043b8SDevin Teske hline="$hline_num_tab_enter" 420ab2043b8SDevin Teske msg=$( 421ab2043b8SDevin Teske printf "$msg_group_members ($msg_separated_by_commas)" 422ab2043b8SDevin Teske ) 423ab2043b8SDevin Teske size=$( f_dialog_inputbox_size \ 424ab2043b8SDevin Teske "$DIALOG_TITLE" \ 425ab2043b8SDevin Teske "$DIALOG_BACKTITLE" \ 426ab2043b8SDevin Teske "$msg" \ 427ab2043b8SDevin Teske "$_input" \ 428ab2043b8SDevin Teske "$hline" ) 429ab2043b8SDevin Teske 430*89498fdfSDevin Teske local dialog_inputbox 431*89498fdfSDevin Teske dialog_inputbox=$( eval $DIALOG \ 432ab2043b8SDevin Teske --title \"\$DIALOG_TITLE\" \ 433ab2043b8SDevin Teske --backtitle \"\$DIALOG_BACKTITLE\" \ 434ab2043b8SDevin Teske --hline \"\$hline\" \ 435ab2043b8SDevin Teske --ok-label \"\$msg_ok\" \ 436ab2043b8SDevin Teske --cancel-label \"\$msg_cancel\" \ 437ab2043b8SDevin Teske --inputbox \"\$msg\" $size \ 438ab2043b8SDevin Teske \"\$_input\" \ 439*89498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 440*89498fdfSDevin Teske ) 441ab2043b8SDevin Teske 442ab2043b8SDevin Teske retval=$? 443*89498fdfSDevin Teske setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" 444ab2043b8SDevin Teske _group_members=$( f_dialog_inputstr ) 445ab2043b8SDevin Teske 446ab2043b8SDevin Teske # Return to previous menu if user has either 447ab2043b8SDevin Teske # pressed ESC or chosen Cancel/No 448ab2043b8SDevin Teske [ $retval -eq $SUCCESS ] || continue 449ab2043b8SDevin Teske 450ab2043b8SDevin Teske _input="$_group_members" 451ab2043b8SDevin Teske ;; 452ab2043b8SDevin Teske esac 453ab2043b8SDevin Teske done 454ab2043b8SDevin Teske 455ab2043b8SDevin Teske group_members="$_input" 456ab2043b8SDevin Teske save_flag=1 457ab2043b8SDevin Teske f_dprintf "group_members: [$cur_group_members]->[$group_members]" 458ab2043b8SDevin Teske 459ab2043b8SDevin Teske return $SUCCESS 460ab2043b8SDevin Teske} 461ab2043b8SDevin Teske 462ab2043b8SDevin Teskefi # ! $_USERMGMT_GROUP_INPUT_SUBR 463