Deleted Added
full compact
user_input.subr (249751) user_input.subr (251190)
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 249751 2013-04-22 05:52:06Z dteske $
28# $FreeBSD: head/usr.sbin/bsdconfig/usermgmt/share/user_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/user_input.subr
35f_include $BSDCFG_SHARE/dialog.subr
36f_include $BSDCFG_SHARE/strings.subr

--- 49 unchanged lines hidden (view full) ---

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 defaultitem="$1"
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

--- 49 unchanged lines hidden (view full) ---

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 defaultitem="$1"
94 local menu_list size
94 local menu_list
95 local hline="$hline_alnum_punc_tab_enter"
96
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
95 local hline="$hline_alnum_punc_tab_enter"
96
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 size=$( eval f_dialog_menu_size \
109 \"\$DIALOG_TITLE\" \
110 \"\$DIALOG_BACKTITLE\" \
111 \"\" \
112 \"\$hline\" \
113 $menu_list )
108 local height width rows
109 eval f_dialog_menu_size height width rows \
110 \"\$DIALOG_TITLE\" \
111 \"\$DIALOG_BACKTITLE\" \
112 \"\" \
113 \"\$hline\" \
114 $menu_list
114
115 local dialog_menu
116 dialog_menu=$( 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\" \
115
116 local dialog_menu
117 dialog_menu=$( 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\" \
123 --menu \"\" $size $menu_list \
124 --menu \"\" \
125 $height $width $rows \
126 $menu_list \
124 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
125 )
126 local retval=$?
127 setvar DIALOG_MENU_$$ "$dialog_menu"
128 return $retval
129}
130
131# f_dialog_input_member_groups [$member_groups]

--- 5 unchanged lines hidden (view full) ---

137f_dialog_input_member_groups()
138{
139 local msg="$( printf "$msg_member_of_groups" )"
140 local hline="$hline_alnum_space_tab_enter"
141
142 #
143 # Loop until the user provides taint-free/valid input
144 #
127 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
128 )
129 local retval=$?
130 setvar DIALOG_MENU_$$ "$dialog_menu"
131 return $retval
132}
133
134# f_dialog_input_member_groups [$member_groups]

--- 5 unchanged lines hidden (view full) ---

140f_dialog_input_member_groups()
141{
142 local msg="$( printf "$msg_member_of_groups" )"
143 local hline="$hline_alnum_space_tab_enter"
144
145 #
146 # Loop until the user provides taint-free/valid input
147 #
145 local size retval all_groups checklist_groups="" _member_groups="$1"
148 local retval all_groups checklist_groups="" _member_groups="$1"
146 all_groups=$( pw groupshow -a | awk -F: '
147 !/^[[:space:]]*(#|$)/ {
148 printf "%s\n", $1
149 }'
150 )
151 for grp in $all_groups; do
152 checklist_groups="$checklist_groups $grp $grp"
153 if echo "$_member_groups" | grep -q "\<$grp\>"; then
154 checklist_groups="$checklist_groups on"
155 else
156 checklist_groups="$checklist_groups off"
157 fi
158 done
159
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"
158 else
159 checklist_groups="$checklist_groups off"
160 fi
161 done
162
163 local height width rows
160 while :; do
164 while :; do
161 size=$( eval f_dialog_radiolist_size \
165 eval f_dialog_checklist_size height width rows \
162 \"\$DIALOG_TITLE\" \
163 \"\$DIALOG_BACKTITLE\" \
164 \"\" \
165 \"\$hline\" \
166 \"\$DIALOG_TITLE\" \
167 \"\$DIALOG_BACKTITLE\" \
168 \"\" \
169 \"\$hline\" \
166 $checklist_groups )
170 $checklist_groups
167 local dialog_inputbox
168 dialog_inputbox=$( eval $DIALOG \
169 --title \"\$DIALOG_TITLE\" \
170 --backtitle \"\$DIALOG_BACKTITLE\" \
171 --separate-output \
172 --hline \"\$hline\" \
173 --ok-label \"\$msg_ok\" \
174 --cancel-label \"\$msg_cancel\" \
171 local dialog_inputbox
172 dialog_inputbox=$( eval $DIALOG \
173 --title \"\$DIALOG_TITLE\" \
174 --backtitle \"\$DIALOG_BACKTITLE\" \
175 --separate-output \
176 --hline \"\$hline\" \
177 --ok-label \"\$msg_ok\" \
178 --cancel-label \"\$msg_cancel\" \
175 --checklist \"\$msg\" $size \
179 --checklist \"\$msg\" \
180 $height $width $rows \
176 $checklist_groups \
177 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
178 )
179
180 retval=$?
181 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
182 _member_groups=$( f_dialog_inputstr )
183

--- 86 unchanged lines hidden (view full) ---

270
271# f_dialog_input_password
272#
273# Prompt the user to enter a password (twice).
274#
275f_dialog_input_password()
276{
277 local hline="$hline_alnum_punc_tab_enter"
181 $checklist_groups \
182 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
183 )
184
185 retval=$?
186 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
187 _member_groups=$( f_dialog_inputstr )
188

--- 86 unchanged lines hidden (view full) ---

275
276# f_dialog_input_password
277#
278# Prompt the user to enter a password (twice).
279#
280f_dialog_input_password()
281{
282 local hline="$hline_alnum_punc_tab_enter"
278 local msg size rmsg rsize
283 local msg rmsg
279
280 msg=$( printf "$msg_password" )
284
285 msg=$( printf "$msg_password" )
281 size=$( f_dialog_inputbox_size \
286 local height1 width1
287 f_dialog_inputbox_size height1 width1 \
282 "$DIALOG_TITLE" \
283 "$DIALOG_BACKTITLE" \
284 "$msg" \
285 "" \
288 "$DIALOG_TITLE" \
289 "$DIALOG_BACKTITLE" \
290 "$msg" \
291 "" \
286 "$hline" )
292 "$hline"
287
288 rmsg=$( printf "$msg_reenter_password" )
293
294 rmsg=$( printf "$msg_reenter_password" )
289 rsize=$( f_dialog_inputbox_size \
295 local height2 width2
296 f_dialog_inputbox_size height2 width2 \
290 "$DIALOG_TITLE" \
291 "$DIALOG_BACKTITLE" \
292 "$rmsg" \
293 "" \
297 "$DIALOG_TITLE" \
298 "$DIALOG_BACKTITLE" \
299 "$rmsg" \
300 "" \
294 "$hline" )
301 "$hline"
295
296 #
297 # Loop until the user provides taint-free/valid input
298 #
299 local retval _password1 _password2
300 while :; do
301 local dialog_inputbox
302
303 #
304 # Loop until the user provides taint-free/valid input
305 #
306 local retval _password1 _password2
307 while :; do
308 local dialog_inputbox
302 dialog_inputbox=$( eval $DIALOG \
303 --title \"\$DIALOG_TITLE\" \
304 --backtitle \"\$DIALOG_BACKTITLE\" \
305 --hline \"\$hline\" \
306 --ok-label \"\$msg_ok\" \
307 --cancel-label \"\$msg_cancel\" \
308 --insecure \
309 --passwordbox \"\$msg\" $size \
309 dialog_inputbox=$( $DIALOG \
310 --title "$DIALOG_TITLE" \
311 --backtitle "$DIALOG_BACKTITLE" \
312 --hline "$hline" \
313 --ok-label "$msg_ok" \
314 --cancel-label "$msg_cancel" \
315 --insecure \
316 --passwordbox "$msg" \
317 $height1 $width1 \
310 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
311 )
312
313 retval=$?
314 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
315 _password1=$( f_dialog_inputstr )
316
318 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
319 )
320
321 retval=$?
322 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
323 _password1=$( f_dialog_inputstr )
324
317 # Return if user has either pressed ESC or chosen Cancel/No
318 [ $retval -eq $SUCCESS ] || return $retval
319
320 dialog_inputbox=$( eval $DIALOG \
321 --title \"\$DIALOG_TITLE\" \
322 --backtitle \"\$DIALOG_BACKTITLE\" \
323 --hline \"\$hline\" \
324 --ok-label \"\$msg_ok\" \
325 --cancel-label \"\$msg_cancel\" \
326 --insecure \
327 --passwordbox \"\$rmsg\" $rsize \
325 dialog_inputbox=$( $DIALOG \
326 --title "$DIALOG_TITLE" \
327 --backtitle "$DIALOG_BACKTITLE" \
328 --hline "$hline" \
329 --ok-label "$msg_ok" \
330 --cancel-label "$msg_cancel" \
331 --insecure \
332 --passwordbox "$rmsg" \
333 $height2 $width2 \
328 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
329 )
330
331 retval=$?
332 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
333 _password2=$( f_dialog_inputstr )
334
335 # Return if user has either pressed ESC or chosen Cancel/No

--- 122 unchanged lines hidden (view full) ---

458#
459# Allow the user to enter a date/time (in number-of-seconds since the `epoch')
460# for when a given user's password must be changed. If the user does not cancel
461# or press ESC, the $pw_password_expire variable will hold the newly-
462# configured value upon return.
463#
464f_dialog_input_change()
465{
334 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
335 )
336
337 retval=$?
338 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
339 _password2=$( f_dialog_inputstr )
340
341 # Return if user has either pressed ESC or chosen Cancel/No

--- 122 unchanged lines hidden (view full) ---

464#
465# Allow the user to enter a date/time (in number-of-seconds since the `epoch')
466# for when a given user's password must be changed. If the user does not cancel
467# or press ESC, the $pw_password_expire variable will hold the newly-
468# configured value upon return.
469#
470f_dialog_input_change()
471{
466 local calendar_size timebox_size
467 local msg menu_size size retval _input="$1"
472 local retval _input="$1"
473 local msg="$msg_password_expires_on"
468 local hline="$hline_num_arrows_tab_enter"
469
470 local menu_list="
471 '1' '$msg_password_does_not_expire'
472 '2' '$msg_edit_date_time_with_a_calendar'
473 '3' '$msg_enter_number_of_days_into_the_future'
474 '4' '$msg_enter_value_manually'
475 " # END-QUOTE
476
474 local hline="$hline_num_arrows_tab_enter"
475
476 local menu_list="
477 '1' '$msg_password_does_not_expire'
478 '2' '$msg_edit_date_time_with_a_calendar'
479 '3' '$msg_enter_number_of_days_into_the_future'
480 '4' '$msg_enter_value_manually'
481 " # END-QUOTE
482
483 local mheight mwidth mrows
484 eval f_dialog_menu_size mheight mwidth mrows \
485 \"\$DIALOG_TITLE\" \
486 \"\$DIALOG_BACKTITLE\" \
487 \"\$msg\" \
488 \"\$hline\" \
489 $menu_list
490 local cheight cwidth
491 f_dialog_calendar_size cheight cwidth \
492 "$DIALOG_TITLE" \
493 "$DIALOG_BACKTITLE" \
494 "$msg" \
495 "$hline"
496 local theight twidth
497 f_dialog_timebox_size theight twidth \
498 "$DIALOG_TITLE" \
499 "$DIALOG_BACKTITLE" \
500 "$msg" \
501 "$hline"
502
477 #
478 # Loop until the user provides taint-free/cancellation-free input
479 #
480 while :; do
503 #
504 # Loop until the user provides taint-free/cancellation-free input
505 #
506 while :; do
481 msg="$msg_password_expires_on"
482 menu_size=$( eval f_dialog_menu_size \
483 \"\$DIALOG_TITLE\" \
484 \"\$DIALOG_BACKTITLE\" \
485 \"\$msg\" \
486 \"\$hline\" \
487 $menu_list )
488
489 local dialog_menu
490 dialog_menu=$( eval $DIALOG \
491 --title \"\$DIALOG_TITLE\" \
492 --backtitle \"\$DIALOG_BACKTITLE\" \
493 --hline \"\$hline\" \
494 --ok-label \"\$msg_ok\" \
495 --cancel-label \"\$msg_cancel\" \
507 local dialog_menu
508 dialog_menu=$( eval $DIALOG \
509 --title \"\$DIALOG_TITLE\" \
510 --backtitle \"\$DIALOG_BACKTITLE\" \
511 --hline \"\$hline\" \
512 --ok-label \"\$msg_ok\" \
513 --cancel-label \"\$msg_cancel\" \
496 --menu \"\$msg\" $menu_size \
514 --menu \"\$msg\" \
515 $mheight $mwidth $mrows \
497 $menu_list \
498 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
499 )
500 retval=$?
501 setvar DIALOG_MENU_$$ "$dialog_menu"
502 date_type=$( f_dialog_menutag )
503 f_dprintf "retval=%u date_type=[%s]" $retval "$date_type"
504

--- 7 unchanged lines hidden (view full) ---

512
513 2) # Edit date/time with a calendar
514 local _input_date _input_time ret_date ret_time
515
516 local secs="$_input"
517 { f_isinteger "$secs" && [ $secs -gt 0 ]; } || secs=
518 _input_date=$( date -j -f "%s" -- "$secs" \
519 "+%d %m %Y" 2> /dev/null )
516 $menu_list \
517 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
518 )
519 retval=$?
520 setvar DIALOG_MENU_$$ "$dialog_menu"
521 date_type=$( f_dialog_menutag )
522 f_dprintf "retval=%u date_type=[%s]" $retval "$date_type"
523

--- 7 unchanged lines hidden (view full) ---

531
532 2) # Edit date/time with a calendar
533 local _input_date _input_time ret_date ret_time
534
535 local secs="$_input"
536 { f_isinteger "$secs" && [ $secs -gt 0 ]; } || secs=
537 _input_date=$( date -j -f "%s" -- "$secs" \
538 "+%d %m %Y" 2> /dev/null )
520 calendar_size=$( f_dialog_calendar_size \
521 "$DIALOG_TITLE" \
522 "$DIALOG_BACKTITLE" \
523 "$msg" \
524 "$hline" )
525 local dialog_inputbox
526 dialog_inputbox=$( eval $DIALOG \
527 --title \"\$DIALOG_TITLE\" \
528 --backtitle \"\$DIALOG_BACKTITLE\" \
529 --hline \"\$hline\" \
530 --ok-label \"\$msg_ok\" \
531 --cancel-label \"\$msg_cancel\" \
539 local dialog_inputbox
540 dialog_inputbox=$( eval $DIALOG \
541 --title \"\$DIALOG_TITLE\" \
542 --backtitle \"\$DIALOG_BACKTITLE\" \
543 --hline \"\$hline\" \
544 --ok-label \"\$msg_ok\" \
545 --cancel-label \"\$msg_cancel\" \
532 --calendar \"\$msg\" $calendar_size \
546 --calendar \"\$msg\" \
547 $cheight $cwidth \
533 $_input_date \
534 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
535 )
536 retval=$?
537 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
538 ret_date=$( f_dialog_inputstr )
539 f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date"
540
541 # Return to menu if either ESC or Cancel/No
542 [ $retval -eq $SUCCESS ] || continue
543
544 _input_time=
545 [ "$secs" ] && _input_time=$( date -j \
546 -f %s -- "$_input" "+%H %M %S" 2> /dev/null )
548 $_input_date \
549 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
550 )
551 retval=$?
552 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
553 ret_date=$( f_dialog_inputstr )
554 f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date"
555
556 # Return to menu if either ESC or Cancel/No
557 [ $retval -eq $SUCCESS ] || continue
558
559 _input_time=
560 [ "$secs" ] && _input_time=$( date -j \
561 -f %s -- "$_input" "+%H %M %S" 2> /dev/null )
547 timebox_size=$( f_dialog_timebox_size \
548 "$DIALOG_TITLE" \
549 "$DIALOG_BACKTITLE" \
550 "$msg" \
551 "$hline" )
552 local dialog_inputbox
553 dialog_inputbox=$( eval $DIALOG \
554 --title \"\$DIALOG_TITLE\" \
555 --backtitle \"\$DIALOG_BACKTITLE\" \
556 --hline \"\$hline\" \
557 --ok-label \"\$msg_ok\" \
558 --cancel-label \"\$msg_cancel\" \
562 local dialog_inputbox
563 dialog_inputbox=$( eval $DIALOG \
564 --title \"\$DIALOG_TITLE\" \
565 --backtitle \"\$DIALOG_BACKTITLE\" \
566 --hline \"\$hline\" \
567 --ok-label \"\$msg_ok\" \
568 --cancel-label \"\$msg_cancel\" \
559 --timebox \"\$msg\" $timebox_size \
569 --timebox \"\$msg\" \
570 $theight $twidth \
560 $_input_time \
561 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
562 )
563 retval=$?
564 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
565 ret_time=$( f_dialog_inputstr )
566 f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time"
567

--- 76 unchanged lines hidden (view full) ---

644#
645# Allow the user to enter a date/time (in number-of-seconds since the `epoch')
646# for when a given user's account should become expired. If the user does not
647# cancel or press ESC, the $pw_account_expire variable will hold the newly-
648# configured value upon return.
649#
650f_dialog_input_expire()
651{
571 $_input_time \
572 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
573 )
574 retval=$?
575 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
576 ret_time=$( f_dialog_inputstr )
577 f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time"
578

--- 76 unchanged lines hidden (view full) ---

655#
656# Allow the user to enter a date/time (in number-of-seconds since the `epoch')
657# for when a given user's account should become expired. If the user does not
658# cancel or press ESC, the $pw_account_expire variable will hold the newly-
659# configured value upon return.
660#
661f_dialog_input_expire()
662{
652 local calendar_size timebox_size
653 local msg menu_size size retval _input="$1"
663 local retval _input="$1"
664 local msg="$msg_account_expires_on"
654 local hline="$hline_num_arrows_tab_enter"
655
656 local menu_list="
657 '1' '$msg_account_does_not_expire'
658 '2' '$msg_edit_date_time_with_a_calendar'
659 '3' '$msg_enter_number_of_days_into_the_future'
660 '4' '$msg_enter_value_manually'
661 " # END-QUOTE
662
665 local hline="$hline_num_arrows_tab_enter"
666
667 local menu_list="
668 '1' '$msg_account_does_not_expire'
669 '2' '$msg_edit_date_time_with_a_calendar'
670 '3' '$msg_enter_number_of_days_into_the_future'
671 '4' '$msg_enter_value_manually'
672 " # END-QUOTE
673
674 local mheight mwidth mrows
675 eval f_dialog_menu_size mheight mwidth mrows \
676 \"\$DIALOG_TITLE\" \
677 \"\$DIALOG_BACKTITLE\" \
678 \"\$msg\" \
679 \"\$hline\" \
680 $menu_list
681 local cheight cwidth
682 f_dialog_calendar_size cheight cwidth \
683 "$DIALOG_TITLE" \
684 "$DIALOG_BACKTITLE" \
685 "$msg" \
686 "$hline"
687 local theight twidth
688 f_dialog_timebox_size theight twidth \
689 "$DIALOG_TITLE" \
690 "$DIALOG_BACKTITLE" \
691 "$msg" \
692 "$hline"
693
663 #
664 # Loop until the user provides taint-free/cancellation-free input
665 #
666 while :; do
694 #
695 # Loop until the user provides taint-free/cancellation-free input
696 #
697 while :; do
667 msg="$msg_account_expires_on"
668 menu_size=$( eval f_dialog_menu_size \
669 \"\$DIALOG_TITLE\" \
670 \"\$DIALOG_BACKTITLE\" \
671 \"\$msg\" \
672 \"\$hline\" \
673 $menu_list )
674
675 local dialog_menu
676 dialog_menu=$( eval $DIALOG \
677 --title \"\$DIALOG_TITLE\" \
678 --backtitle \"\$DIALOG_BACKTITLE\" \
679 --hline \"\$hline\" \
680 --ok-label \"\$msg_ok\" \
681 --cancel-label \"\$msg_cancel\" \
698 local dialog_menu
699 dialog_menu=$( eval $DIALOG \
700 --title \"\$DIALOG_TITLE\" \
701 --backtitle \"\$DIALOG_BACKTITLE\" \
702 --hline \"\$hline\" \
703 --ok-label \"\$msg_ok\" \
704 --cancel-label \"\$msg_cancel\" \
682 --menu \"\$msg\" $menu_size \
705 --menu \"\$msg\" \
706 $mheight $mwidth $mrows \
683 $menu_list \
684 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
685 )
686 retval=$?
687 setvar DIALOG_MENU_$$ "$dialog_menu"
688 date_type=$( f_dialog_menutag )
689 f_dprintf "retval=%u date_type=[%s]" $retval "$date_type"
690

--- 7 unchanged lines hidden (view full) ---

698
699 2) # Edit date/time with a calendar
700 local _input_date _input_time ret_date ret_time
701
702 local secs="$_input"
703 { f_isinteger "$secs" && [ $secs -gt 0 ]; } || secs=
704 _input_date=$( date -j -f "%s" -- "$secs" \
705 "+%d %m %Y" 2> /dev/null )
707 $menu_list \
708 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
709 )
710 retval=$?
711 setvar DIALOG_MENU_$$ "$dialog_menu"
712 date_type=$( f_dialog_menutag )
713 f_dprintf "retval=%u date_type=[%s]" $retval "$date_type"
714

--- 7 unchanged lines hidden (view full) ---

722
723 2) # Edit date/time with a calendar
724 local _input_date _input_time ret_date ret_time
725
726 local secs="$_input"
727 { f_isinteger "$secs" && [ $secs -gt 0 ]; } || secs=
728 _input_date=$( date -j -f "%s" -- "$secs" \
729 "+%d %m %Y" 2> /dev/null )
706 calendar_size=$( f_dialog_calendar_size \
707 "$DIALOG_TITLE" \
708 "$DIALOG_BACKTITLE" \
709 "$msg" \
710 "$hline" )
711 local dialog_inputbox
712 dialog_inputbox=$( eval $DIALOG \
713 --title \"\$DIALOG_TITLE\" \
714 --backtitle \"\$DIALOG_BACKTITLE\" \
715 --hline \"\$hline\" \
716 --ok-label \"\$msg_ok\" \
717 --cancel-label \"\$msg_cancel\" \
730 local dialog_inputbox
731 dialog_inputbox=$( eval $DIALOG \
732 --title \"\$DIALOG_TITLE\" \
733 --backtitle \"\$DIALOG_BACKTITLE\" \
734 --hline \"\$hline\" \
735 --ok-label \"\$msg_ok\" \
736 --cancel-label \"\$msg_cancel\" \
718 --calendar \"\$msg\" $calendar_size \
737 --calendar \"\$msg\" \
738 $cheight $cwidth \
719 $_input_date \
720 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
721 )
722 retval=$?
723 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
724 ret_date=$( f_dialog_inputstr )
725 f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date"
726
727 # Return to menu if either ESC or Cancel/No
728 [ $retval -eq $SUCCESS ] || continue
729
730 _input_time=
731 [ "$secs" ] && _input_time=$( date -j \
732 -f %s -- "$_input" "+%H %M %S" 2> /dev/null )
739 $_input_date \
740 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
741 )
742 retval=$?
743 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
744 ret_date=$( f_dialog_inputstr )
745 f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date"
746
747 # Return to menu if either ESC or Cancel/No
748 [ $retval -eq $SUCCESS ] || continue
749
750 _input_time=
751 [ "$secs" ] && _input_time=$( date -j \
752 -f %s -- "$_input" "+%H %M %S" 2> /dev/null )
733 timebox_size=$( f_dialog_timebox_size \
734 "$DIALOG_TITLE" \
735 "$DIALOG_BACKTITLE" \
736 "$msg" \
737 "$hline" )
738 dialog_inputbox=$( eval $DIALOG \
739 --title \"\$DIALOG_TITLE\" \
740 --backtitle \"\$DIALOG_BACKTITLE\" \
741 --hline \"\$hline\" \
742 --ok-label \"\$msg_ok\" \
743 --cancel-label \"\$msg_cancel\" \
753 dialog_inputbox=$( eval $DIALOG \
754 --title \"\$DIALOG_TITLE\" \
755 --backtitle \"\$DIALOG_BACKTITLE\" \
756 --hline \"\$hline\" \
757 --ok-label \"\$msg_ok\" \
758 --cancel-label \"\$msg_cancel\" \
744 --timebox \"\$msg\" $timebox_size \
759 --timebox \"\$msg\" \
760 $theight $twidth \
745 $_input_time \
746 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
747 )
748 retval=$?
749 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
750 ret_time=$( f_dialog_inputstr )
751 f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time"
752

--- 224 unchanged lines hidden (view full) ---

977#
978# Allow the user to select a new login shell for a given user. If the user does
979# not cancel or press ESC, the $pw_home_dir variable will hold the newly-
980# configured value upon return.
981#
982#
983f_dialog_input_shell()
984{
761 $_input_time \
762 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
763 )
764 retval=$?
765 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
766 ret_time=$( f_dialog_inputstr )
767 f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time"
768

--- 224 unchanged lines hidden (view full) ---

993#
994# Allow the user to select a new login shell for a given user. If the user does
995# not cancel or press ESC, the $pw_home_dir variable will hold the newly-
996# configured value upon return.
997#
998#
999f_dialog_input_shell()
1000{
985 local size retval shells shell_list _input="$1"
1001 local retval shells shell_list _input="$1"
986 local hline="$hline_arrows_space_tab_enter"
987 local prompt="$msg_select_login_shell"
988
989 shells=$( awk '!/^[[:space:]]*(#|$)/{print}' "$ETC_SHELLS" )
990 shell_list=$(
991 for shell in $shells; do
992 if [ "$shell" = "$_input" ]; then
993 echo "'$shell' '' 'on'"
994 else
995 echo "'$shell' '' 'off'"
996 fi
997 done
998 )
999
1002 local hline="$hline_arrows_space_tab_enter"
1003 local prompt="$msg_select_login_shell"
1004
1005 shells=$( awk '!/^[[:space:]]*(#|$)/{print}' "$ETC_SHELLS" )
1006 shell_list=$(
1007 for shell in $shells; do
1008 if [ "$shell" = "$_input" ]; then
1009 echo "'$shell' '' 'on'"
1010 else
1011 echo "'$shell' '' 'off'"
1012 fi
1013 done
1014 )
1015
1000 size=$( eval f_dialog_radiolist_size \
1001 \"\$DIALOG_TITLE\" \
1002 \"\$DIALOG_BACKTITLE\" \
1003 \"\$prompt\" \
1004 \"\$hline\" \
1005 $shell_list )
1016 local height width rows
1017 eval f_dialog_radiolist_size height width rows \
1018 \"\$DIALOG_TITLE\" \
1019 \"\$DIALOG_BACKTITLE\" \
1020 \"\$prompt\" \
1021 \"\$hline\" \
1022 $shell_list
1006
1007 local dialog_inputbox
1008 dialog_inputbox=$( eval $DIALOG \
1009 --title \"\$DIALOG_TITLE\" \
1010 --backtitle \"\$DIALOG_BACKTITLE\" \
1011 --hline \"\$hline\" \
1012 --ok-label \"\$msg_ok\" \
1013 --cancel-label \"\$msg_cancel\" \
1023
1024 local dialog_inputbox
1025 dialog_inputbox=$( eval $DIALOG \
1026 --title \"\$DIALOG_TITLE\" \
1027 --backtitle \"\$DIALOG_BACKTITLE\" \
1028 --hline \"\$hline\" \
1029 --ok-label \"\$msg_ok\" \
1030 --cancel-label \"\$msg_cancel\" \
1014 --radiolist \"\$prompt\" $size \
1031 --radiolist \"\$prompt\" \
1032 $height $width $rows \
1015 $shell_list \
1016 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
1017 )
1018
1019 retval=$?
1020 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
1021 _input=$( f_dialog_inputstr )
1022

--- 16 unchanged lines hidden ---
1033 $shell_list \
1034 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
1035 )
1036
1037 retval=$?
1038 setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
1039 _input=$( f_dialog_inputstr )
1040

--- 16 unchanged lines hidden ---