user_input.subr (251242) | user_input.subr (251264) |
---|---|
1if [ ! "$_USERMGMT_USER_INPUT_SUBR" ]; then _USERMGMT_USER_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_USER_INPUT_SUBR" ]; then _USERMGMT_USER_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/user_input.subr 251242 2013-06-02 05:45:25Z dteske $ | 28# $FreeBSD: head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr 251264 2013-06-02 20:02:50Z dteske $ |
29# 30############################################################ INCLUDES 31 32BSDCFG_SHARE="/usr/share/bsdconfig" 33. $BSDCFG_SHARE/common.subr || exit 1 34f_dprintf "%s: loading includes..." usermgmt/user_input.subr 35f_include $BSDCFG_SHARE/dialog.subr 36f_include $BSDCFG_SHARE/strings.subr --- 48 unchanged lines hidden (view full) --- 85 86# f_dialog_menu_user_list [$default] 87# 88# Allows the user to select a login from a list. Optionally, if present and 89# non-NULL, initially highlight $default user. 90# 91f_dialog_menu_user_list() 92{ | 29# 30############################################################ INCLUDES 31 32BSDCFG_SHARE="/usr/share/bsdconfig" 33. $BSDCFG_SHARE/common.subr || exit 1 34f_dprintf "%s: loading includes..." usermgmt/user_input.subr 35f_include $BSDCFG_SHARE/dialog.subr 36f_include $BSDCFG_SHARE/strings.subr --- 48 unchanged lines hidden (view full) --- 85 86# f_dialog_menu_user_list [$default] 87# 88# Allows the user to select a login from a list. Optionally, if present and 89# non-NULL, initially highlight $default user. 90# 91f_dialog_menu_user_list() 92{ |
93 local prompt= 94 local menu_list=" 95 'X $msg_exit' '' 96 " # END-QUOTE |
|
93 local defaultitem="$1" | 97 local defaultitem="$1" |
94 local menu_list | |
95 local hline="$hline_alnum_punc_tab_enter" 96 | 98 local hline="$hline_alnum_punc_tab_enter" 99 |
97 menu_list=" 98 'X $msg_exit' '' 99 " # END-QUOTE 100 | |
101 # Add users from passwd(5) 102 menu_list="$menu_list $( pw usershow -a | awk -F: ' 103 !/^[[:space:]]*(#|$)/ { 104 printf "'\'%s\'\ \'%s\''\n", $1, $8 105 }' 106 )" 107 108 local height width rows 109 eval f_dialog_menu_size height width rows \ 110 \"\$DIALOG_TITLE\" \ 111 \"\$DIALOG_BACKTITLE\" \ | 100 # Add users from passwd(5) 101 menu_list="$menu_list $( pw usershow -a | awk -F: ' 102 !/^[[:space:]]*(#|$)/ { 103 printf "'\'%s\'\ \'%s\''\n", $1, $8 104 }' 105 )" 106 107 local height width rows 108 eval f_dialog_menu_size height width rows \ 109 \"\$DIALOG_TITLE\" \ 110 \"\$DIALOG_BACKTITLE\" \ |
112 \"\" \ | 111 \"\$prompt\" \ |
113 \"\$hline\" \ 114 $menu_list 115 116 local menu_choice 117 menu_choice=$( eval $DIALOG \ 118 --title \"\$DIALOG_TITLE\" \ 119 --backtitle \"\$DIALOG_BACKTITLE\" \ 120 --hline \"\$hline\" \ 121 --ok-label \"\$msg_ok\" \ 122 --cancel-label \"\$msg_cancel\" \ 123 --default-item \"\$defaultitem\" \ | 112 \"\$hline\" \ 113 $menu_list 114 115 local menu_choice 116 menu_choice=$( eval $DIALOG \ 117 --title \"\$DIALOG_TITLE\" \ 118 --backtitle \"\$DIALOG_BACKTITLE\" \ 119 --hline \"\$hline\" \ 120 --ok-label \"\$msg_ok\" \ 121 --cancel-label \"\$msg_cancel\" \ 122 --default-item \"\$defaultitem\" \ |
124 --menu \"\" \ | 123 --menu \"\$prompt\" \ |
125 $height $width $rows \ 126 $menu_list \ 127 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 128 ) 129 local retval=$? 130 f_dialog_menutag_store -s "$menu_choice" 131 return $retval 132} 133 134# f_dialog_input_member_groups [$member_groups] 135# 136# Allows the user to edit group memberships for a given user. If the user does 137# not cancel or press ESC, the $pw_member_groups variable will hold the newly- 138# configured value upon return. 139# 140f_dialog_input_member_groups() 141{ | 124 $height $width $rows \ 125 $menu_list \ 126 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 127 ) 128 local retval=$? 129 f_dialog_menutag_store -s "$menu_choice" 130 return $retval 131} 132 133# f_dialog_input_member_groups [$member_groups] 134# 135# Allows the user to edit group memberships for a given user. If the user does 136# not cancel or press ESC, the $pw_member_groups variable will hold the newly- 137# configured value upon return. 138# 139f_dialog_input_member_groups() 140{ |
142 local msg="$( printf "$msg_member_of_groups" )" | 141 local _member_groups="$1" 142 local prompt="$msg_member_of_groups" 143 local check_list= # Calculated below |
143 local hline="$hline_alnum_space_tab_enter" | 144 local hline="$hline_alnum_space_tab_enter" |
145 local group |
|
144 145 # | 146 147 # |
146 # Loop until the user provides taint-free/valid input | 148 # Generate the checklist menu |
147 # | 149 # |
148 local retval all_groups checklist_groups="" _member_groups="$1" 149 all_groups=$( pw groupshow -a | awk -F: ' 150 !/^[[:space:]]*(#|$)/ { 151 printf "%s\n", $1 152 }' 153 ) 154 for grp in $all_groups; do 155 checklist_groups="$checklist_groups $grp $grp" 156 if echo "$_member_groups" | grep -q "\<$grp\>"; then 157 checklist_groups="$checklist_groups on" | 150 for group in $( 151 pw groupshow -a | awk -F: '!/^[[:space:]]*(#|$)/{print $1}' 152 ); do 153 # Format of a checklist menu entry is "tag item status" 154 # (setting both tag and item to the group name below). 155 if echo "$_member_groups" | grep -q "\<$group\>"; then 156 check_list="$check_list $group $group on" |
158 else | 157 else |
159 checklist_groups="$checklist_groups off" | 158 check_list="$check_list $group $group off" |
160 fi 161 done 162 | 159 fi 160 done 161 |
162 # 163 # Loop until the user provides taint-free/valid input 164 # |
|
163 local height width rows 164 while :; do 165 eval f_dialog_checklist_size height width rows \ 166 \"\$DIALOG_TITLE\" \ 167 \"\$DIALOG_BACKTITLE\" \ | 165 local height width rows 166 while :; do 167 eval f_dialog_checklist_size height width rows \ 168 \"\$DIALOG_TITLE\" \ 169 \"\$DIALOG_BACKTITLE\" \ |
168 \"\" \ | 170 \"\$prompt\" \ |
169 \"\$hline\" \ | 171 \"\$hline\" \ |
170 $checklist_groups | 172 $check_list |
171 _member_groups=$( eval $DIALOG \ 172 --title \"\$DIALOG_TITLE\" \ 173 --backtitle \"\$DIALOG_BACKTITLE\" \ 174 --separate-output \ 175 --hline \"\$hline\" \ 176 --ok-label \"\$msg_ok\" \ 177 --cancel-label \"\$msg_cancel\" \ | 173 _member_groups=$( eval $DIALOG \ 174 --title \"\$DIALOG_TITLE\" \ 175 --backtitle \"\$DIALOG_BACKTITLE\" \ 176 --separate-output \ 177 --hline \"\$hline\" \ 178 --ok-label \"\$msg_ok\" \ 179 --cancel-label \"\$msg_cancel\" \ |
178 --checklist \"\$msg\" \ | 180 --checklist \"\$prompt\" \ |
179 $height $width $rows \ | 181 $height $width $rows \ |
180 $checklist_groups \ | 182 $check_list \ |
181 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 182 ) || return $? 183 # Return if user either pressed ESC or chose Cancel/No 184 f_dialog_data_sanitize _member_groups 185 186 # 187 # Validate each of the groups the user has entered 188 # | 183 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 184 ) || return $? 185 # Return if user either pressed ESC or chose Cancel/No 186 f_dialog_data_sanitize _member_groups 187 188 # 189 # Validate each of the groups the user has entered 190 # |
189 local group all_groups_valid=1 | 191 local all_groups_valid=1 |
190 for group in $_member_groups; do 191 if ! f_quietly pw groupshow -n "$group"; then 192 f_show_msg "$msg_group_not_found" "$group" 193 all_groups_valid= 194 break 195 fi 196 done 197 [ "$all_groups_valid" ] || continue --- 69 unchanged lines hidden (view full) --- 267} 268 269# f_dialog_input_password 270# 271# Prompt the user to enter a password (twice). 272# 273f_dialog_input_password() 274{ | 192 for group in $_member_groups; do 193 if ! f_quietly pw groupshow -n "$group"; then 194 f_show_msg "$msg_group_not_found" "$group" 195 all_groups_valid= 196 break 197 fi 198 done 199 [ "$all_groups_valid" ] || continue --- 69 unchanged lines hidden (view full) --- 269} 270 271# f_dialog_input_password 272# 273# Prompt the user to enter a password (twice). 274# 275f_dialog_input_password() 276{ |
277 local prompt1="$msg_password" 278 local prompt2="$msg_reenter_password" |
|
275 local hline="$hline_alnum_punc_tab_enter" | 279 local hline="$hline_alnum_punc_tab_enter" |
276 local msg rmsg | |
277 | 280 |
278 msg=$( printf "$msg_password" ) | |
279 local height1 width1 280 f_dialog_inputbox_size height1 width1 \ 281 "$DIALOG_TITLE" \ 282 "$DIALOG_BACKTITLE" \ | 281 local height1 width1 282 f_dialog_inputbox_size height1 width1 \ 283 "$DIALOG_TITLE" \ 284 "$DIALOG_BACKTITLE" \ |
283 "$msg" \ | 285 "$prompt1" \ |
284 "" \ 285 "$hline" | 286 "" \ 287 "$hline" |
286 287 rmsg=$( printf "$msg_reenter_password" ) | |
288 local height2 width2 289 f_dialog_inputbox_size height2 width2 \ 290 "$DIALOG_TITLE" \ 291 "$DIALOG_BACKTITLE" \ | 288 local height2 width2 289 f_dialog_inputbox_size height2 width2 \ 290 "$DIALOG_TITLE" \ 291 "$DIALOG_BACKTITLE" \ |
292 "$rmsg" \ | 292 "$prompt2" \ |
293 "" \ 294 "$hline" 295 296 # 297 # Loop until the user provides taint-free/valid input 298 # 299 local _password1 _password2 300 while :; do 301 _password1=$( $DIALOG \ 302 --title "$DIALOG_TITLE" \ 303 --backtitle "$DIALOG_BACKTITLE" \ 304 --hline "$hline" \ 305 --ok-label "$msg_ok" \ 306 --cancel-label "$msg_cancel" \ 307 --insecure \ | 293 "" \ 294 "$hline" 295 296 # 297 # Loop until the user provides taint-free/valid input 298 # 299 local _password1 _password2 300 while :; do 301 _password1=$( $DIALOG \ 302 --title "$DIALOG_TITLE" \ 303 --backtitle "$DIALOG_BACKTITLE" \ 304 --hline "$hline" \ 305 --ok-label "$msg_ok" \ 306 --cancel-label "$msg_cancel" \ 307 --insecure \ |
308 --passwordbox "$msg" \ | 308 --passwordbox "$prompt1" \ |
309 $height1 $width1 \ 310 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 311 ) || return $? 312 # Return if user either pressed ESC or chose Cancel/No 313 debug= f_dialog_line_sanitize _password1 314 315 _password2=$( $DIALOG \ 316 --title "$DIALOG_TITLE" \ 317 --backtitle "$DIALOG_BACKTITLE" \ 318 --hline "$hline" \ 319 --ok-label "$msg_ok" \ 320 --cancel-label "$msg_cancel" \ 321 --insecure \ | 309 $height1 $width1 \ 310 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 311 ) || return $? 312 # Return if user either pressed ESC or chose Cancel/No 313 debug= f_dialog_line_sanitize _password1 314 315 _password2=$( $DIALOG \ 316 --title "$DIALOG_TITLE" \ 317 --backtitle "$DIALOG_BACKTITLE" \ 318 --hline "$hline" \ 319 --ok-label "$msg_ok" \ 320 --cancel-label "$msg_cancel" \ 321 --insecure \ |
322 --passwordbox "$rmsg" \ | 322 --passwordbox "$prompt2" \ |
323 $height2 $width2 \ 324 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 325 ) || return $? 326 # Return if user either pressed ESC or chose Cancel/No 327 debug= f_dialog_line_sanitize _password2 328 329 # Check for password mismatch 330 if [ "$_password1" != "$_password2" ]; then --- 114 unchanged lines hidden (view full) --- 445# 446# Allow the user to enter a date/time (in number-of-seconds since the `epoch') 447# for when a given user's password must be changed. If the user does not cancel 448# or press ESC, the $pw_password_expire variable will hold the newly- 449# configured value upon return. 450# 451f_dialog_input_change() 452{ | 323 $height2 $width2 \ 324 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 325 ) || return $? 326 # Return if user either pressed ESC or chose Cancel/No 327 debug= f_dialog_line_sanitize _password2 328 329 # Check for password mismatch 330 if [ "$_password1" != "$_password2" ]; then --- 114 unchanged lines hidden (view full) --- 445# 446# Allow the user to enter a date/time (in number-of-seconds since the `epoch') 447# for when a given user's password must be changed. If the user does not cancel 448# or press ESC, the $pw_password_expire variable will hold the newly- 449# configured value upon return. 450# 451f_dialog_input_change() 452{ |
453 local retval _input="$1" 454 local msg="$msg_password_expires_on" 455 local hline="$hline_num_arrows_tab_enter" 456 | 453 local prompt="$msg_password_expires_on" |
457 local menu_list=" 458 '1' '$msg_password_does_not_expire' 459 '2' '$msg_edit_date_time_with_a_calendar' 460 '3' '$msg_enter_number_of_days_into_the_future' 461 '4' '$msg_enter_value_manually' 462 " # END-QUOTE | 454 local menu_list=" 455 '1' '$msg_password_does_not_expire' 456 '2' '$msg_edit_date_time_with_a_calendar' 457 '3' '$msg_enter_number_of_days_into_the_future' 458 '4' '$msg_enter_value_manually' 459 " # END-QUOTE |
460 local hline="$hline_num_arrows_tab_enter" 461 local retval _input="$1" |
|
463 464 local mheight mwidth mrows 465 eval f_dialog_menu_size mheight mwidth mrows \ 466 \"\$DIALOG_TITLE\" \ 467 \"\$DIALOG_BACKTITLE\" \ | 462 463 local mheight mwidth mrows 464 eval f_dialog_menu_size mheight mwidth mrows \ 465 \"\$DIALOG_TITLE\" \ 466 \"\$DIALOG_BACKTITLE\" \ |
468 \"\$msg\" \ | 467 \"\$prompt\" \ |
469 \"\$hline\" \ 470 $menu_list 471 local cheight cwidth 472 f_dialog_calendar_size cheight cwidth \ 473 "$DIALOG_TITLE" \ 474 "$DIALOG_BACKTITLE" \ | 468 \"\$hline\" \ 469 $menu_list 470 local cheight cwidth 471 f_dialog_calendar_size cheight cwidth \ 472 "$DIALOG_TITLE" \ 473 "$DIALOG_BACKTITLE" \ |
475 "$msg" \ | 474 "$prompt" \ |
476 "$hline" 477 local theight twidth 478 f_dialog_timebox_size theight twidth \ 479 "$DIALOG_TITLE" \ 480 "$DIALOG_BACKTITLE" \ | 475 "$hline" 476 local theight twidth 477 f_dialog_timebox_size theight twidth \ 478 "$DIALOG_TITLE" \ 479 "$DIALOG_BACKTITLE" \ |
481 "$msg" \ | 480 "$prompt" \ |
482 "$hline" 483 484 # 485 # Loop until the user provides taint-free/cancellation-free input 486 # 487 local date_type 488 while :; do 489 date_type=$( eval $DIALOG \ 490 --title \"\$DIALOG_TITLE\" \ 491 --backtitle \"\$DIALOG_BACKTITLE\" \ 492 --hline \"\$hline\" \ 493 --ok-label \"\$msg_ok\" \ 494 --cancel-label \"\$msg_cancel\" \ | 481 "$hline" 482 483 # 484 # Loop until the user provides taint-free/cancellation-free input 485 # 486 local date_type 487 while :; do 488 date_type=$( eval $DIALOG \ 489 --title \"\$DIALOG_TITLE\" \ 490 --backtitle \"\$DIALOG_BACKTITLE\" \ 491 --hline \"\$hline\" \ 492 --ok-label \"\$msg_ok\" \ 493 --cancel-label \"\$msg_cancel\" \ |
495 --menu \"\$msg\" \ | 494 --menu \"\$prompt\" \ |
496 $mheight $mwidth $mrows \ 497 $menu_list \ 498 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 499 ) 500 retval=$? 501 f_dialog_data_sanitize date_type 502 f_dprintf "retval=%u date_type=[%s]" $retval "$date_type" 503 --- 13 unchanged lines hidden (view full) --- 517 _input_date=$( date -j -f "%s" -- "$secs" \ 518 "+%d %m %Y" 2> /dev/null ) 519 ret_date=$( eval $DIALOG \ 520 --title \"\$DIALOG_TITLE\" \ 521 --backtitle \"\$DIALOG_BACKTITLE\" \ 522 --hline \"\$hline\" \ 523 --ok-label \"\$msg_ok\" \ 524 --cancel-label \"\$msg_cancel\" \ | 495 $mheight $mwidth $mrows \ 496 $menu_list \ 497 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 498 ) 499 retval=$? 500 f_dialog_data_sanitize date_type 501 f_dprintf "retval=%u date_type=[%s]" $retval "$date_type" 502 --- 13 unchanged lines hidden (view full) --- 516 _input_date=$( date -j -f "%s" -- "$secs" \ 517 "+%d %m %Y" 2> /dev/null ) 518 ret_date=$( eval $DIALOG \ 519 --title \"\$DIALOG_TITLE\" \ 520 --backtitle \"\$DIALOG_BACKTITLE\" \ 521 --hline \"\$hline\" \ 522 --ok-label \"\$msg_ok\" \ 523 --cancel-label \"\$msg_cancel\" \ |
525 --calendar \"\$msg\" \ | 524 --calendar \"\$prompt\" \ |
526 $cheight $cwidth \ 527 $_input_date \ 528 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 529 ) 530 retval=$? 531 f_dialog_data_sanitize ret_date 532 f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date" 533 --- 4 unchanged lines hidden (view full) --- 538 [ "$secs" ] && _input_time=$( date -j \ 539 -f %s -- "$_input" "+%H %M %S" 2> /dev/null ) 540 ret_time=$( eval $DIALOG \ 541 --title \"\$DIALOG_TITLE\" \ 542 --backtitle \"\$DIALOG_BACKTITLE\" \ 543 --hline \"\$hline\" \ 544 --ok-label \"\$msg_ok\" \ 545 --cancel-label \"\$msg_cancel\" \ | 525 $cheight $cwidth \ 526 $_input_date \ 527 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 528 ) 529 retval=$? 530 f_dialog_data_sanitize ret_date 531 f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date" 532 --- 4 unchanged lines hidden (view full) --- 537 [ "$secs" ] && _input_time=$( date -j \ 538 -f %s -- "$_input" "+%H %M %S" 2> /dev/null ) 539 ret_time=$( eval $DIALOG \ 540 --title \"\$DIALOG_TITLE\" \ 541 --backtitle \"\$DIALOG_BACKTITLE\" \ 542 --hline \"\$hline\" \ 543 --ok-label \"\$msg_ok\" \ 544 --cancel-label \"\$msg_cancel\" \ |
546 --timebox \"\$msg\" \ | 545 --timebox \"\$prompt\" \ |
547 $theight $twidth \ 548 $_input_time \ 549 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 550 ) 551 retval=$? 552 f_dialog_data_sanitize ret_time 553 f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time" 554 --- 32 unchanged lines hidden (view full) --- 587 [-+]*) _input=$( date -v${ret_days}d +%s );; 588 0) _input=$( date +%s );; 589 *) _input=$( date -v+${ret_days}d +%s );; 590 esac 591 f_dprintf "_input=[%s]" "$_input" 592 break ;; 593 594 4) # Enter value manually | 546 $theight $twidth \ 547 $_input_time \ 548 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 549 ) 550 retval=$? 551 f_dialog_data_sanitize ret_time 552 f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time" 553 --- 32 unchanged lines hidden (view full) --- 586 [-+]*) _input=$( date -v${ret_days}d +%s );; 587 0) _input=$( date +%s );; 588 *) _input=$( date -v+${ret_days}d +%s );; 589 esac 590 f_dprintf "_input=[%s]" "$_input" 591 break ;; 592 593 4) # Enter value manually |
594 local msg |
|
595 msg=$( printf "$msg_number_of_seconds_since_epoch" \ 596 "$( date -r 1 "+%c %Z" )" ) 597 598 # Return to menu if either ESC or Cancel/No 599 f_dialog_input _input \ 600 "$msg" "$_input" "$hline" || continue 601 602 # Taint-check the user's input --- 23 unchanged lines hidden (view full) --- 626# 627# Allow the user to enter a date/time (in number-of-seconds since the `epoch') 628# for when a given user's account should become expired. If the user does not 629# cancel or press ESC, the $pw_account_expire variable will hold the newly- 630# configured value upon return. 631# 632f_dialog_input_expire() 633{ | 595 msg=$( printf "$msg_number_of_seconds_since_epoch" \ 596 "$( date -r 1 "+%c %Z" )" ) 597 598 # Return to menu if either ESC or Cancel/No 599 f_dialog_input _input \ 600 "$msg" "$_input" "$hline" || continue 601 602 # Taint-check the user's input --- 23 unchanged lines hidden (view full) --- 626# 627# Allow the user to enter a date/time (in number-of-seconds since the `epoch') 628# for when a given user's account should become expired. If the user does not 629# cancel or press ESC, the $pw_account_expire variable will hold the newly- 630# configured value upon return. 631# 632f_dialog_input_expire() 633{ |
634 local retval _input="$1" 635 local msg="$msg_account_expires_on" 636 local hline="$hline_num_arrows_tab_enter" 637 | 634 local prompt="$msg_account_expires_on" |
638 local menu_list=" 639 '1' '$msg_account_does_not_expire' 640 '2' '$msg_edit_date_time_with_a_calendar' 641 '3' '$msg_enter_number_of_days_into_the_future' 642 '4' '$msg_enter_value_manually' 643 " # END-QUOTE | 635 local menu_list=" 636 '1' '$msg_account_does_not_expire' 637 '2' '$msg_edit_date_time_with_a_calendar' 638 '3' '$msg_enter_number_of_days_into_the_future' 639 '4' '$msg_enter_value_manually' 640 " # END-QUOTE |
641 local hline="$hline_num_arrows_tab_enter" 642 local retval _input="$1" |
|
644 645 local mheight mwidth mrows 646 eval f_dialog_menu_size mheight mwidth mrows \ 647 \"\$DIALOG_TITLE\" \ 648 \"\$DIALOG_BACKTITLE\" \ | 643 644 local mheight mwidth mrows 645 eval f_dialog_menu_size mheight mwidth mrows \ 646 \"\$DIALOG_TITLE\" \ 647 \"\$DIALOG_BACKTITLE\" \ |
649 \"\$msg\" \ | 648 \"\$prompt\" \ |
650 \"\$hline\" \ 651 $menu_list 652 local cheight cwidth 653 f_dialog_calendar_size cheight cwidth \ 654 "$DIALOG_TITLE" \ 655 "$DIALOG_BACKTITLE" \ | 649 \"\$hline\" \ 650 $menu_list 651 local cheight cwidth 652 f_dialog_calendar_size cheight cwidth \ 653 "$DIALOG_TITLE" \ 654 "$DIALOG_BACKTITLE" \ |
656 "$msg" \ | 655 "$prompt" \ |
657 "$hline" 658 local theight twidth 659 f_dialog_timebox_size theight twidth \ 660 "$DIALOG_TITLE" \ 661 "$DIALOG_BACKTITLE" \ | 656 "$hline" 657 local theight twidth 658 f_dialog_timebox_size theight twidth \ 659 "$DIALOG_TITLE" \ 660 "$DIALOG_BACKTITLE" \ |
662 "$msg" \ | 661 "$prompt" \ |
663 "$hline" 664 665 # 666 # Loop until the user provides taint-free/cancellation-free input 667 # 668 local date_type 669 while :; do 670 date_type=$( eval $DIALOG \ 671 --title \"\$DIALOG_TITLE\" \ 672 --backtitle \"\$DIALOG_BACKTITLE\" \ 673 --hline \"\$hline\" \ 674 --ok-label \"\$msg_ok\" \ 675 --cancel-label \"\$msg_cancel\" \ | 662 "$hline" 663 664 # 665 # Loop until the user provides taint-free/cancellation-free input 666 # 667 local date_type 668 while :; do 669 date_type=$( eval $DIALOG \ 670 --title \"\$DIALOG_TITLE\" \ 671 --backtitle \"\$DIALOG_BACKTITLE\" \ 672 --hline \"\$hline\" \ 673 --ok-label \"\$msg_ok\" \ 674 --cancel-label \"\$msg_cancel\" \ |
676 --menu \"\$msg\" \ | 675 --menu \"\$prompt\" \ |
677 $mheight $mwidth $mrows \ 678 $menu_list \ 679 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 680 ) 681 retval=$? 682 f_dialog_data_sanitize date_type 683 f_dprintf "retval=%u date_type=[%s]" $retval "$date_type" 684 --- 13 unchanged lines hidden (view full) --- 698 _input_date=$( date -j -f "%s" -- "$secs" \ 699 "+%d %m %Y" 2> /dev/null ) 700 ret_date=$( eval $DIALOG \ 701 --title \"\$DIALOG_TITLE\" \ 702 --backtitle \"\$DIALOG_BACKTITLE\" \ 703 --hline \"\$hline\" \ 704 --ok-label \"\$msg_ok\" \ 705 --cancel-label \"\$msg_cancel\" \ | 676 $mheight $mwidth $mrows \ 677 $menu_list \ 678 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 679 ) 680 retval=$? 681 f_dialog_data_sanitize date_type 682 f_dprintf "retval=%u date_type=[%s]" $retval "$date_type" 683 --- 13 unchanged lines hidden (view full) --- 697 _input_date=$( date -j -f "%s" -- "$secs" \ 698 "+%d %m %Y" 2> /dev/null ) 699 ret_date=$( eval $DIALOG \ 700 --title \"\$DIALOG_TITLE\" \ 701 --backtitle \"\$DIALOG_BACKTITLE\" \ 702 --hline \"\$hline\" \ 703 --ok-label \"\$msg_ok\" \ 704 --cancel-label \"\$msg_cancel\" \ |
706 --calendar \"\$msg\" \ | 705 --calendar \"\$prompt\" \ |
707 $cheight $cwidth \ 708 $_input_date \ 709 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 710 ) 711 retval=$? 712 f_dialog_data_sanitize ret_date 713 f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date" 714 --- 4 unchanged lines hidden (view full) --- 719 [ "$secs" ] && _input_time=$( date -j \ 720 -f %s -- "$_input" "+%H %M %S" 2> /dev/null ) 721 ret_time=$( eval $DIALOG \ 722 --title \"\$DIALOG_TITLE\" \ 723 --backtitle \"\$DIALOG_BACKTITLE\" \ 724 --hline \"\$hline\" \ 725 --ok-label \"\$msg_ok\" \ 726 --cancel-label \"\$msg_cancel\" \ | 706 $cheight $cwidth \ 707 $_input_date \ 708 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 709 ) 710 retval=$? 711 f_dialog_data_sanitize ret_date 712 f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date" 713 --- 4 unchanged lines hidden (view full) --- 718 [ "$secs" ] && _input_time=$( date -j \ 719 -f %s -- "$_input" "+%H %M %S" 2> /dev/null ) 720 ret_time=$( eval $DIALOG \ 721 --title \"\$DIALOG_TITLE\" \ 722 --backtitle \"\$DIALOG_BACKTITLE\" \ 723 --hline \"\$hline\" \ 724 --ok-label \"\$msg_ok\" \ 725 --cancel-label \"\$msg_cancel\" \ |
727 --timebox \"\$msg\" \ | 726 --timebox \"\$prompt\" \ |
728 $theight $twidth \ 729 $_input_time \ 730 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 731 ) 732 retval=$? 733 f_dialog_data_sanitize ret_time 734 f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time" 735 --- 32 unchanged lines hidden (view full) --- 768 [-+]*) _input=$( date -v${ret_days}d +%s );; 769 0) _input=$( date +%s );; 770 *) _input=$( date -v+${ret_days}d +%s );; 771 esac 772 f_dprintf "_input=[%s]" "$_input" 773 break ;; 774 775 4) # Enter value manually | 727 $theight $twidth \ 728 $_input_time \ 729 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 730 ) 731 retval=$? 732 f_dialog_data_sanitize ret_time 733 f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time" 734 --- 32 unchanged lines hidden (view full) --- 767 [-+]*) _input=$( date -v${ret_days}d +%s );; 768 0) _input=$( date +%s );; 769 *) _input=$( date -v+${ret_days}d +%s );; 770 esac 771 f_dprintf "_input=[%s]" "$_input" 772 break ;; 773 774 4) # Enter value manually |
775 local msg |
|
776 msg=$( printf "$msg_number_of_seconds_since_epoch" \ 777 "$( date -r 1 "+%c %Z" )" ) 778 779 # Return to menu if either ESC or Cancel/No 780 f_dialog_input _input "$msg" \ 781 "$_input" "$hline" || continue 782 783 # Taint-check the user's input --- 170 unchanged lines hidden (view full) --- 954# 955# Allow the user to select a new login shell for a given user. If the user does 956# not cancel or press ESC, the $pw_home_dir variable will hold the newly- 957# configured value upon return. 958# 959# 960f_dialog_input_shell() 961{ | 776 msg=$( printf "$msg_number_of_seconds_since_epoch" \ 777 "$( date -r 1 "+%c %Z" )" ) 778 779 # Return to menu if either ESC or Cancel/No 780 f_dialog_input _input "$msg" \ 781 "$_input" "$hline" || continue 782 783 # Taint-check the user's input --- 170 unchanged lines hidden (view full) --- 954# 955# Allow the user to select a new login shell for a given user. If the user does 956# not cancel or press ESC, the $pw_home_dir variable will hold the newly- 957# configured value upon return. 958# 959# 960f_dialog_input_shell() 961{ |
962 local shells shell_list _input="$1" 963 local hline="$hline_arrows_space_tab_enter" | 962 local _input="$1" |
964 local prompt="$msg_select_login_shell" | 963 local prompt="$msg_select_login_shell" |
964 local radio_list= # Calculated below 965 local hline="$hline_arrows_space_tab_enter" |
|
965 | 966 |
966 shells=$( awk '!/^[[:space:]]*(#|$)/{print}' "$ETC_SHELLS" ) 967 shell_list=$( 968 for shell in $shells; do 969 if [ "$shell" = "$_input" ]; then 970 echo "'$shell' '' 'on'" 971 else 972 echo "'$shell' '' 'off'" 973 fi 974 done 975 ) | 967 # 968 # Generate the radiolist of shells 969 # 970 local shell 971 for shell in $( awk '!/^[[:space:]]*(#|$)/{print}' "$ETC_SHELLS" ); do 972 # Format of a radiolist menu entry is "tag item status" 973 if [ "$shell" = "$_input" ]; then 974 radio_list="$radio_list '$shell' '' 'on'" 975 else 976 radio_list="$radio_list '$shell' '' 'off'" 977 fi 978 done |
976 977 local height width rows 978 eval f_dialog_radiolist_size height width rows \ 979 \"\$DIALOG_TITLE\" \ 980 \"\$DIALOG_BACKTITLE\" \ 981 \"\$prompt\" \ 982 \"\$hline\" \ | 979 980 local height width rows 981 eval f_dialog_radiolist_size height width rows \ 982 \"\$DIALOG_TITLE\" \ 983 \"\$DIALOG_BACKTITLE\" \ 984 \"\$prompt\" \ 985 \"\$hline\" \ |
983 $shell_list | 986 $radio_list |
984 985 _input=$( eval $DIALOG \ 986 --title \"\$DIALOG_TITLE\" \ 987 --backtitle \"\$DIALOG_BACKTITLE\" \ 988 --hline \"\$hline\" \ 989 --ok-label \"\$msg_ok\" \ 990 --cancel-label \"\$msg_cancel\" \ 991 --radiolist \"\$prompt\" \ 992 $height $width $rows \ | 987 988 _input=$( eval $DIALOG \ 989 --title \"\$DIALOG_TITLE\" \ 990 --backtitle \"\$DIALOG_BACKTITLE\" \ 991 --hline \"\$hline\" \ 992 --ok-label \"\$msg_ok\" \ 993 --cancel-label \"\$msg_cancel\" \ 994 --radiolist \"\$prompt\" \ 995 $height $width $rows \ |
993 $shell_list \ | 996 $radio_list \ |
994 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 995 ) || return $? 996 # Return if user either pressed ESC or chose Cancel/No 997 f_dialog_data_sanitize _input 998 999 pw_shell="$_input" 1000 save_flag=1 1001 1002 f_dprintf "pw_shell: [%s]->[%s]" "$cur_pw_shell" "$pw_shell" 1003 1004 return $SUCCESS 1005} 1006 1007############################################################ MAIN 1008 1009f_dprintf "%s: Successfully loaded." usermgmt/user_input.subr 1010 1011fi # ! $_USERMGMT_USER_INPUT_SUBR | 997 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 998 ) || return $? 999 # Return if user either pressed ESC or chose Cancel/No 1000 f_dialog_data_sanitize _input 1001 1002 pw_shell="$_input" 1003 save_flag=1 1004 1005 f_dprintf "pw_shell: [%s]->[%s]" "$cur_pw_shell" "$pw_shell" 1006 1007 return $SUCCESS 1008} 1009 1010############################################################ MAIN 1011 1012f_dprintf "%s: Successfully loaded." usermgmt/user_input.subr 1013 1014fi # ! $_USERMGMT_USER_INPUT_SUBR |