group_input.subr (249751) | group_input.subr (251190) |
---|---|
1if [ ! "$_USERMGMT_GROUP_INPUT_SUBR" ]; then _USERMGMT_GROUP_INPUT_SUBR=1 2# 3# Copyright (c) 2012 Ron McDowell 4# Copyright (c) 2012-2013 Devin Teske 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26# SUCH DAMAGE. 27# | 1if [ ! "$_USERMGMT_GROUP_INPUT_SUBR" ]; then _USERMGMT_GROUP_INPUT_SUBR=1 2# 3# Copyright (c) 2012 Ron McDowell 4# Copyright (c) 2012-2013 Devin Teske 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26# SUCH DAMAGE. 27# |
28# $FreeBSD: head/usr.sbin/bsdconfig/usermgmt/share/group_input.subr 249751 2013-04-22 05:52:06Z dteske $ | 28# $FreeBSD: head/usr.sbin/bsdconfig/usermgmt/share/group_input.subr 251190 2013-05-31 19:07:17Z dteske $ |
29# 30############################################################ INCLUDES 31 32BSDCFG_SHARE="/usr/share/bsdconfig" 33. $BSDCFG_SHARE/common.subr || exit 1 34f_dprintf "%s: loading includes..." usermgmt/group_input.subr 35f_include $BSDCFG_SHARE/dialog.subr 36f_include $BSDCFG_SHARE/strings.subr --- 24 unchanged lines hidden (view full) --- 61# f_dialog_menu_group_list [$default] 62# 63# Allows the user to select a group from a list. Optionally, if present and 64# non-NULL, initially highlight $default group. 65# 66f_dialog_menu_group_list() 67{ 68 local defaultitem="$1" | 29# 30############################################################ INCLUDES 31 32BSDCFG_SHARE="/usr/share/bsdconfig" 33. $BSDCFG_SHARE/common.subr || exit 1 34f_dprintf "%s: loading includes..." usermgmt/group_input.subr 35f_include $BSDCFG_SHARE/dialog.subr 36f_include $BSDCFG_SHARE/strings.subr --- 24 unchanged lines hidden (view full) --- 61# f_dialog_menu_group_list [$default] 62# 63# Allows the user to select a group from a list. Optionally, if present and 64# non-NULL, initially highlight $default group. 65# 66f_dialog_menu_group_list() 67{ 68 local defaultitem="$1" |
69 local menu_list size | 69 local menu_list |
70 local hline="$hline_alnum_punc_tab_enter" 71 72 menu_list=" 73 'X $msg_exit' '' 74 " # END-QUOTE 75 76 # Add groups from group(5) 77 menu_list="$menu_list $( pw groupshow -a | awk -F: ' 78 !/^[[:space:]]*(#|$)/ { 79 printf "'\'%s\'\ \'%s\''\n", $1, $1 80 }' 81 )" 82 | 70 local hline="$hline_alnum_punc_tab_enter" 71 72 menu_list=" 73 'X $msg_exit' '' 74 " # END-QUOTE 75 76 # Add groups from group(5) 77 menu_list="$menu_list $( pw groupshow -a | awk -F: ' 78 !/^[[:space:]]*(#|$)/ { 79 printf "'\'%s\'\ \'%s\''\n", $1, $1 80 }' 81 )" 82 |
83 size=$( eval f_dialog_menu_size \ 84 \"\$DIALOG_TITLE\" \ 85 \"\$DIALOG_BACKTITLE\" \ 86 \"\" \ 87 \"\$hline\" \ 88 $menu_list ) | 83 local height width rows 84 eval f_dialog_menu_size height width rows \ 85 \"\$DIALOG_TITLE\" \ 86 \"\$DIALOG_BACKTITLE\" \ 87 \"\" \ 88 \"\$hline\" \ 89 $menu_list |
89 90 local dialog_menu 91 dialog_menu=$( eval $DIALOG \ 92 --title \"\$DIALOG_TITLE\" \ 93 --backtitle \"\$DIALOG_BACKTITLE\" \ 94 --hline \"\$hline\" \ 95 --ok-label \"\$msg_ok\" \ 96 --cancel-label \"\$msg_cancel\" \ 97 --default-item \"\$defaultitem\" \ | 90 91 local dialog_menu 92 dialog_menu=$( eval $DIALOG \ 93 --title \"\$DIALOG_TITLE\" \ 94 --backtitle \"\$DIALOG_BACKTITLE\" \ 95 --hline \"\$hline\" \ 96 --ok-label \"\$msg_ok\" \ 97 --cancel-label \"\$msg_cancel\" \ 98 --default-item \"\$defaultitem\" \ |
98 --menu \"\" $size $menu_list \ | 99 --menu \"\" \ 100 $height $width $rows \ 101 $menu_list \ |
99 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 100 ) 101 local retval=$? 102 setvar DIALOG_MENU_$$ "$dialog_menu" 103 return $retval 104} 105 106# f_dialog_input_group_name [$group_name] --- 58 unchanged lines hidden (view full) --- 165 166# f_dialog_input_group_password 167# 168# Prompt the user to enter a password (twice). 169# 170f_dialog_input_group_password() 171{ 172 local hline="$hline_alnum_punc_tab_enter" | 102 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 103 ) 104 local retval=$? 105 setvar DIALOG_MENU_$$ "$dialog_menu" 106 return $retval 107} 108 109# f_dialog_input_group_name [$group_name] --- 58 unchanged lines hidden (view full) --- 168 169# f_dialog_input_group_password 170# 171# Prompt the user to enter a password (twice). 172# 173f_dialog_input_group_password() 174{ 175 local hline="$hline_alnum_punc_tab_enter" |
173 local msg size rmsg rsize | 176 local msg rmsg |
174 175 msg=$( printf "$msg_group_password" ) | 177 178 msg=$( printf "$msg_group_password" ) |
176 size=$( f_dialog_inputbox_size \ | 179 local height1 width1 180 f_dialog_inputbox_size height1 width1 \ |
177 "$DIALOG_TITLE" \ 178 "$DIALOG_BACKTITLE" \ 179 "$msg" \ 180 "" \ | 181 "$DIALOG_TITLE" \ 182 "$DIALOG_BACKTITLE" \ 183 "$msg" \ 184 "" \ |
181 "$hline" ) | 185 "$hline" |
182 183 rmsg=$( printf "$msg_reenter_group_password" ) | 186 187 rmsg=$( printf "$msg_reenter_group_password" ) |
184 rsize=$( f_dialog_inputbox_size \ | 188 local height2 width2 189 f_dialog_inputbox_size height2 width2 \ |
185 "$DIALOG_TITLE" \ 186 "$DIALOG_BACKTITLE" \ 187 "$rmsg" \ 188 "" \ | 190 "$DIALOG_TITLE" \ 191 "$DIALOG_BACKTITLE" \ 192 "$rmsg" \ 193 "" \ |
189 "$hline" ) | 194 "$hline" |
190 191 # 192 # Loop until the user provides taint-free/valid input 193 # 194 local retval _password1 _password2 195 while :; do 196 local dialog_inputbox | 195 196 # 197 # Loop until the user provides taint-free/valid input 198 # 199 local retval _password1 _password2 200 while :; do 201 local dialog_inputbox |
197 dialog_inputbox=$( eval $DIALOG \ 198 --title \"\$DIALOG_TITLE\" \ 199 --backtitle \"\$DIALOG_BACKTITLE\" \ 200 --hline \"\$hline\" \ 201 --ok-label \"\$msg_ok\" \ 202 --cancel-label \"\$msg_cancel\" \ 203 --insecure \ 204 --passwordbox \"\$msg\" $size \ | 202 dialog_inputbox=$( $DIALOG \ 203 --title "$DIALOG_TITLE" \ 204 --backtitle "$DIALOG_BACKTITLE" \ 205 --hline "$hline" \ 206 --ok-label "$msg_ok" \ 207 --cancel-label "$msg_cancel" \ 208 --insecure \ 209 --passwordbox "$msg" \ 210 $height1 $width1 \ |
205 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 206 ) 207 208 retval=$? 209 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" 210 _password1=$( f_dialog_inputstr ) 211 212 # Return if user has either pressed ESC or chosen Cancel/No 213 [ $retval -eq $SUCCESS ] || return $retval 214 | 211 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 212 ) 213 214 retval=$? 215 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" 216 _password1=$( f_dialog_inputstr ) 217 218 # Return if user has either pressed ESC or chosen Cancel/No 219 [ $retval -eq $SUCCESS ] || return $retval 220 |
215 dialog_inputbox=$( eval $DIALOG \ 216 --title \"\$DIALOG_TITLE\" \ 217 --backtitle \"\$DIALOG_BACKTITLE\" \ 218 --hline \"\$hline\" \ 219 --ok-label \"\$msg_ok\" \ 220 --cancel-label \"\$msg_cancel\" \ 221 --insecure \ 222 --passwordbox \"\$rmsg\" $rsize \ | 221 dialog_inputbox=$( $DIALOG \ 222 --title "$DIALOG_TITLE" \ 223 --backtitle "$DIALOG_BACKTITLE" \ 224 --hline "$hline" \ 225 --ok-label "$msg_ok" \ 226 --cancel-label "$msg_cancel" \ 227 --insecure \ 228 --passwordbox "$rmsg" \ 229 $height2 $width2 \ |
223 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 224 ) 225 226 retval=$? 227 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" 228 _password2=$( f_dialog_inputstr ) 229 230 # Return if user has either pressed ESC or chosen Cancel/No --- 52 unchanged lines hidden (view full) --- 283# f_dialog_input_group_members [$group_members] 284# 285# Allow the user to modify a list of members for a given group. If the user does 286# not cancel or press ESC, the $group_members variable will hold the newly- 287# configured value upon return. 288# 289f_dialog_input_group_members() 290{ | 230 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 231 ) 232 233 retval=$? 234 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" 235 _password2=$( f_dialog_inputstr ) 236 237 # Return if user has either pressed ESC or chosen Cancel/No --- 52 unchanged lines hidden (view full) --- 290# f_dialog_input_group_members [$group_members] 291# 292# Allow the user to modify a list of members for a given group. If the user does 293# not cancel or press ESC, the $group_members variable will hold the newly- 294# configured value upon return. 295# 296f_dialog_input_group_members() 297{ |
291 local menu_choice msg size retval _input="$1" | 298 local menu_choice retval _input="$1" 299 local msg="$msg_group_members:" |
292 local hline="$hline_num_arrows_tab_enter" 293 local user 294 local menu_list 295 local all_users_valid 296 local _group_members 297 local checklist_users 298 299 menu_list=" 300 'X' '$msg_continue' 301 '1' '$msg_select_group_members_from_list' 302 '2' '$msg_enter_group_members_manually' 303 " # END-QUOTE 304 305 local dialog_menu defaultitem= | 300 local hline="$hline_num_arrows_tab_enter" 301 local user 302 local menu_list 303 local all_users_valid 304 local _group_members 305 local checklist_users 306 307 menu_list=" 308 'X' '$msg_continue' 309 '1' '$msg_select_group_members_from_list' 310 '2' '$msg_enter_group_members_manually' 311 " # END-QUOTE 312 313 local dialog_menu defaultitem= |
314 local mheight mwidth mrows 315 eval f_dialog_menu_size mheight mwidth mrows \ 316 \"\$DIALOG_TITLE\" \ 317 \"\$DIALOG_BACKTITLE\" \ 318 \"\$msg\" \ 319 \"\$hline\" \ 320 $menu_list 321 |
|
306 while :; do | 322 while :; do |
307 msg="$msg_group_members:" 308 menu_size=$( eval f_dialog_menu_size \ 309 \"\$DIALOG_TITLE\" \ 310 \"\$DIALOG_BACKTITLE\" \ 311 \"\$msg\" \ 312 \"\$hline\" \ 313 $menu_list ) | |
314 dialog_menu=$( eval $DIALOG \ 315 --title \"\$DIALOG_TITLE\" \ 316 --backtitle \"\$DIALOG_BACKTITLE\" \ 317 --hline \"\$hline\" \ 318 --ok-label \"\$msg_ok\" \ 319 --cancel-label \"\$msg_cancel\" \ 320 --default-item \"\$defaultitem\" \ | 323 dialog_menu=$( eval $DIALOG \ 324 --title \"\$DIALOG_TITLE\" \ 325 --backtitle \"\$DIALOG_BACKTITLE\" \ 326 --hline \"\$hline\" \ 327 --ok-label \"\$msg_ok\" \ 328 --cancel-label \"\$msg_cancel\" \ 329 --default-item \"\$defaultitem\" \ |
321 --menu \"\$msg\" $menu_size \ | 330 --menu \"\$msg\" \ 331 $mheight $mwidth $mrows \ |
322 $menu_list \ 323 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 324 ) 325 retval=$? 326 setvar DIALOG_MENU_$$ "$dialog_menu" 327 defaultitem="$dialog_menu" 328 menu_choice=$( f_dialog_menutag ) 329 f_dprintf "retval=%u menu_choice=[%s]" $retval "$menu_choice" --- 12 unchanged lines hidden (view full) --- 342 checklist_users="$checklist_users $user \"\"" 343 if echo "$_input" | grep -q "\<$user\>"; then 344 checklist_users="$checklist_users on" 345 else 346 checklist_users="$checklist_users off" 347 fi 348 done 349 | 332 $menu_list \ 333 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 334 ) 335 retval=$? 336 setvar DIALOG_MENU_$$ "$dialog_menu" 337 defaultitem="$dialog_menu" 338 menu_choice=$( f_dialog_menutag ) 339 f_dprintf "retval=%u menu_choice=[%s]" $retval "$menu_choice" --- 12 unchanged lines hidden (view full) --- 352 checklist_users="$checklist_users $user \"\"" 353 if echo "$_input" | grep -q "\<$user\>"; then 354 checklist_users="$checklist_users on" 355 else 356 checklist_users="$checklist_users off" 357 fi 358 done 359 |
350 size=$( eval f_dialog_radiolist_size \ 351 \"\$DIALOG_TITLE\" \ 352 \"\$DIALOG_BACKTITLE\" \ 353 \"\" \ 354 \"\$hline\" \ 355 $checklist_users ) | 360 local cheight cwidth crows 361 eval f_dialog_checklist_size cheight cwidth crows \ 362 \"\$DIALOG_TITLE\" \ 363 \"\$DIALOG_BACKTITLE\" \ 364 \"\" \ 365 \"\$hline\" \ 366 $checklist_users |
356 local dialog_inputbox 357 dialog_inputbox=$( eval $DIALOG \ 358 --title \"\$DIALOG_TITLE\" \ 359 --backtitle \"\$DIALOG_BACKTITLE\" \ 360 --separate-output \ 361 --hline \"\$hline\" \ 362 --ok-label \"\$msg_ok\" \ 363 --cancel-label \"\$msg_cancel\" \ | 367 local dialog_inputbox 368 dialog_inputbox=$( eval $DIALOG \ 369 --title \"\$DIALOG_TITLE\" \ 370 --backtitle \"\$DIALOG_BACKTITLE\" \ 371 --separate-output \ 372 --hline \"\$hline\" \ 373 --ok-label \"\$msg_ok\" \ 374 --cancel-label \"\$msg_cancel\" \ |
364 --checklist \"\$msg\" $size \ | 375 --checklist \"\$msg\" \ 376 $cheight $cwidth $crows \ |
365 $checklist_users \ 366 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 367 ) 368 retval=$? 369 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" 370 _group_members=$( f_dialog_inputstr | tr '\n' ' ' | 371 sed -e 's/[[:space:]]\{1,\}/,/g;s/^,//;s/,$//' ) 372 --- 33 unchanged lines hidden --- | 377 $checklist_users \ 378 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 379 ) 380 retval=$? 381 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" 382 _group_members=$( f_dialog_inputstr | tr '\n' ' ' | 383 sed -e 's/[[:space:]]\{1,\}/,/g;s/^,//;s/,$//' ) 384 --- 33 unchanged lines hidden --- |