From owner-svn-src-all@FreeBSD.ORG Fri Dec 21 18:58:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 25A6C1F4; Fri, 21 Dec 2012 18:58:22 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 083E28FC13; Fri, 21 Dec 2012 18:58:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qBLIwMpT017179; Fri, 21 Dec 2012 18:58:22 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qBLIwJCI017163; Fri, 21 Dec 2012 18:58:19 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201212211858.qBLIwJCI017163@svn.freebsd.org> From: Devin Teske Date: Fri, 21 Dec 2012 18:58:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r244548 - in head/usr.sbin/bsdconfig: console mouse networking/share share startup startup/share usermgmt/share X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Dec 2012 18:58:22 -0000 Author: dteske Date: Fri Dec 21 18:58:19 2012 New Revision: 244548 URL: http://svnweb.freebsd.org/changeset/base/244548 Log: Add much-needed dialog(1) --inputbox function for simplifying the process of requesting input from the user. Modified: head/usr.sbin/bsdconfig/console/saver head/usr.sbin/bsdconfig/mouse/flags head/usr.sbin/bsdconfig/networking/share/hostname.subr head/usr.sbin/bsdconfig/networking/share/ipaddr.subr head/usr.sbin/bsdconfig/networking/share/netmask.subr head/usr.sbin/bsdconfig/networking/share/resolv.subr head/usr.sbin/bsdconfig/networking/share/routing.subr head/usr.sbin/bsdconfig/share/dialog.subr head/usr.sbin/bsdconfig/startup/misc head/usr.sbin/bsdconfig/startup/share/rcconf.subr head/usr.sbin/bsdconfig/startup/share/rcedit.subr head/usr.sbin/bsdconfig/usermgmt/share/group_input.subr head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr Modified: head/usr.sbin/bsdconfig/console/saver ============================================================================== --- head/usr.sbin/bsdconfig/console/saver Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/console/saver Fri Dec 21 18:58:19 2012 (r244548) @@ -167,33 +167,10 @@ while :; do break ;; "$msg_timeout") # Set the screen saver timeout interval f_dialog_title "$msg_value_required" - title="$DIALOG_TITLE" - btitle="$DIALOG_BACKTITLE" + blanktime=$( f_dialog_input "$msg_enter_timeout_period" \ + "$( f_sysrc_get blanktime )" + ) && f_sysrc_set blanktime "$blanktime" f_dialog_title_restore - prompt="$msg_enter_timeout_period" - blanktime=$( f_sysrc_get blanktime ) - hline="" - size=$( f_dialog_inputbox_size \ - "$title" \ - "$btitle" \ - "$prompt" \ - "$blanktime" \ - "$hline" ) - dialog_inputbox=$( $DIALOG \ - --title "$title" \ - --backtitle "$btitle" \ - --hline "$hline" \ - --ok-label "$msg_ok" \ - --cancel-label "$msg_cancel" \ - --inputbox "$prompt" $size \ - "$blanktime" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - blanktime=$( f_dialog_inputstr ) - [ $retval -eq $SUCCESS ] && - f_sysrc_set blanktime "$blanktime" ;; esac done Modified: head/usr.sbin/bsdconfig/mouse/flags ============================================================================== --- head/usr.sbin/bsdconfig/mouse/flags Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/mouse/flags Fri Dec 21 18:58:19 2012 (r244548) @@ -79,32 +79,10 @@ flags=$( f_sysrc_get moused_flags ) # Prompt the user with the current value # f_dialog_title "$msg_value_required" -title="$DIALOG_TITLE" -btitle="$DIALOG_BACKTITLE" +flags=$( f_dialog_input "$msg_please_specify_the_mouse_daemon_flags" \ + "$flags" + ) || f_die f_dialog_title_restore -hline= -prompt="$msg_please_specify_the_mouse_daemon_flags" -size=$( f_dialog_inputbox_size \ - "$title" \ - "$btitle" \ - "$prompt" \ - "$flags" \ - "$hline" ) -dialog_inputbox=$( eval $DIALOG \ - --title \"\$title\" \ - --backtitle \"\$btitle\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$prompt\" $size \ - \"\$flags\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD -) -retval=$? -setvar MENU_INPUTBOX_$$ "$dialog_inputbox" -flags=$( f_dialog_inputstr ) - -[ $retval -eq $SUCCESS ] || f_die # # Save the new value Modified: head/usr.sbin/bsdconfig/networking/share/hostname.subr ============================================================================== --- head/usr.sbin/bsdconfig/networking/share/hostname.subr Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/networking/share/hostname.subr Fri Dec 21 18:58:19 2012 (r244548) @@ -132,41 +132,15 @@ f_dialog_input_hostname() msg="$msg_please_enter_fqhn" fi - local hline="$hline_alnum_punc_tab_enter" - # # Loop until the user provides taint-free input. # - local size height width while :; do - - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$hostname" \ - "$hline" ) - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$hostname\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - local retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - hostname=$( f_dialog_inputstr ) - - [ $retval -eq $SUCCESS ] || return $retval - + hostname=$( f_dialog_input "$msg" "$hostname" \ + "$hline_alnum_punc_tab_enter" + ) || return # Taint-check the user's input f_dialog_validate_hostname "$hostname" && break - done # Modified: head/usr.sbin/bsdconfig/networking/share/ipaddr.subr ============================================================================== --- head/usr.sbin/bsdconfig/networking/share/ipaddr.subr Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/networking/share/ipaddr.subr Fri Dec 21 18:58:19 2012 (r244548) @@ -360,41 +360,21 @@ f_dialog_input_ipaddr() fi local msg="$( printf "$msg_please_enter_new_ip_addr" "$interface" )" - local hline="$hline_num_punc_tab_enter" - local size="$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_ipaddr" \ - "$hline" )" # # Loop until the user provides taint-free input. # + local retval while :; do - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_ipaddr\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - local retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) - # # Return error status if: - # - User has not made any changes to the given value # - User has either pressed ESC or chosen Cancel/No + # - User has not made any changes to the given value # + _input=$( f_dialog_input "$msg" "$_ipaddr" \ + "$hline_num_punc_tab_enter" + ) || return [ "$_ipaddr" = "$_input" ] && return $FAILURE - [ $retval -eq $SUCCESS ] || return $retval # Return success if NULL value was entered [ "$_input" ] || return $SUCCESS Modified: head/usr.sbin/bsdconfig/networking/share/netmask.subr ============================================================================== --- head/usr.sbin/bsdconfig/networking/share/netmask.subr Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/networking/share/netmask.subr Fri Dec 21 18:58:19 2012 (r244548) @@ -164,42 +164,20 @@ f_dialog_input_netmask() return $FAILURE fi - local msg="$( printf "$msg_please_enter_subnet_mask" "$interface" )" - local hline="$hline_num_punc_tab_enter" - local size="$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_netmask" \ - "$hline" )" - # # Loop until the user provides taint-free input. # + local msg="$( printf "$msg_please_enter_subnet_mask" "$interface" )" while :; do - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_netmask\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - local retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) - # # Return error status if: - # - User has not made any changes to the given value # - User has either pressed ESC or chosen Cancel/No + # - User has not made any changes to the given value # + _input=$( f_dialog_input "$msg" "$_netmask" \ + "$hline_num_punc_tab_enter" + ) || return [ "$_netmask" = "$_input" ] && return $FAILURE - [ $retval -eq $SUCCESS ] || return $retval # Return success if NULL value was entered [ "$_input" ] || return $SUCCESS Modified: head/usr.sbin/bsdconfig/networking/share/resolv.subr ============================================================================== --- head/usr.sbin/bsdconfig/networking/share/resolv.subr Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/networking/share/resolv.subr Fri Dec 21 18:58:19 2012 (r244548) @@ -329,36 +329,13 @@ f_dialog_input_nameserver() msg="$msg_please_enter_nameserver" fi - local hline="$hline_num_punc_tab_enter" - local size="$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$ns" \ - "$hline" )" - # # Loop until the user provides taint-free input. # while :; do - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$ns\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - local retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - new_ns=$( f_dialog_inputstr ) - - [ $retval -eq $SUCCESS ] || return $retval + new_ns=$( f_dialog_input "$msg" "$ns" \ + "$hline_num_punc_tab_enter" + ) || return # Take only the first "word" of the user's input new_ns="${new_ns%%[$IFS]*}" @@ -369,7 +346,6 @@ f_dialog_input_nameserver() # Update prompt to allow user to re-edit previous entry ns="$new_ns" - done # Modified: head/usr.sbin/bsdconfig/networking/share/routing.subr ============================================================================== --- head/usr.sbin/bsdconfig/networking/share/routing.subr Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/networking/share/routing.subr Fri Dec 21 18:58:19 2012 (r244548) @@ -97,35 +97,16 @@ f_dialog_input_defaultrouter() return $FAILURE fi - local msg="$msg_please_enter_default_router" - local hline="$hline_num_punc_tab_enter" - local size="$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$defaultrouter" \ - "$hline" )" - # # Loop until the user provides taint-free input. # + local retval while :; do - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$defaultrouter\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD + defaultrouter=$( f_dialog_input \ + "$msg_please_enter_default_router" \ + "$defaultrouter" "$hline_num_punc_tab_enter" ) - - local retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - defaultrouter=$( f_dialog_inputstr ) - + retval=$? [ "$defaultrouter" ] || return $SUCCESS [ $retval -eq $SUCCESS ] || return $retval Modified: head/usr.sbin/bsdconfig/share/dialog.subr ============================================================================== --- head/usr.sbin/bsdconfig/share/dialog.subr Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/share/dialog.subr Fri Dec 21 18:58:19 2012 (r244548) @@ -1115,7 +1115,7 @@ f_dialog_noyes() # f_dialog_inputstr # # Obtain the inputstr entered by the user from the most recently displayed -# dialog(1) inputbox and clean up any temporary files. +# dialog(1) inputbox and clean up any temporary files/variables. # f_dialog_inputstr() { @@ -1138,12 +1138,58 @@ f_dialog_inputstr() return $SUCCESS } +# f_dialog_input $prompt [$init [$hline]] +# +# Prompt the user with a dialog(1) inputbox to enter some value. The inputbox +# remains until the the user presses ENTER or ESC, or otherwise ends the +# editing session, by selecting `Cancel' for example. +# +# If the user presses ENTER, the exit status is zero (success), otherwise if +# the user presses ESC the exit status is 255, or if the user chose Cancel, the +# exit status is instead 1. +# +# NOTE: The hline should correspond to the type of data you want from the user. +# NOTE: Should not be used to edit multiline values. +# +f_dialog_input() +{ + local prompt="$1" init="$2" hline="$3" + local size="$( f_dialog_inputbox_size \ + "$DIALOG_TITLE" \ + "$DIALOG_BACKTITLE" \ + "$prompt" \ + "$init" \ + "$hline" )" + + local opterm="--" + [ "$USE_XDIALOG" ] && opterm= + + local dialog_input + dialog_input=$( + eval $DIALOG \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --inputbox \"\$prompt\" $size \ + $opterm \"\$init\" \ + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD + ) + local retval=$? + + setvar DIALOG_INPUTBOX_$$ "$dialog_input" + f_dialog_inputstr + + return $retval +} + ############################################################ MENU FUNCTIONS # f_dialog_menutag # # Obtain the menutag chosen by the user from the most recently displayed -# dialog(1) menu and clean up any temporary files. +# dialog(1) menu and clean up any temporary files/variables. # f_dialog_menutag() { Modified: head/usr.sbin/bsdconfig/startup/misc ============================================================================== --- head/usr.sbin/bsdconfig/startup/misc Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/startup/misc Fri Dec 21 18:58:19 2012 (r244548) @@ -253,34 +253,11 @@ dialog_menu_main() # dialog_input_value() { - local hline="$hline_alnum_tab_enter" - local size prompt="$1" _input="$2" + local prompt="$1" _input="$2" f_dialog_title "$msg_value_required" - - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$prompt" \ - "$_input" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$prompt\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) - + _input=$( f_dialog_input "$prompt" "$_input" "$hline_alnum_tab_enter" ) + local retval=$? f_dialog_title_restore # Return if user has either pressed ESC or chosen Cancel/No Modified: head/usr.sbin/bsdconfig/startup/share/rcconf.subr ============================================================================== --- head/usr.sbin/bsdconfig/startup/share/rcconf.subr Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/startup/share/rcconf.subr Fri Dec 21 18:58:19 2012 (r244548) @@ -418,39 +418,16 @@ f_dialog_input_rclist() # f_dialog_input_rcvar() { - local msg="$msg_please_enter_rcvar_name" - local hline="$hline_alnum_tab_enter" - # # Loop until the user provides taint-free/valid input # - local size _input="$1" + local _input="$1" while :; do - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) # Return if user either pressed ESC or chosen Cancel/No - [ $retval -eq $SUCCESS ] || return $retval + _input=$( f_dialog_input "$msg_please_enter_rcvar_name" \ + "$_input" "$hline_alnum_tab_enter" + ) || return # Check for invalid entry (1of2) if ! echo "$_input" | grep -q "^[[:alpha:]_]"; then Modified: head/usr.sbin/bsdconfig/startup/share/rcedit.subr ============================================================================== --- head/usr.sbin/bsdconfig/startup/share/rcedit.subr Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/startup/share/rcedit.subr Fri Dec 21 18:58:19 2012 (r244548) @@ -53,8 +53,7 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/inc # f_dialog_rcedit() { - local msg size retval var="$1" _input - local hline="$hline_alnum_punc_tab_enter" + local msg var="$1" _input msg=$( printf "$msg_please_enter_a_new_value" \ "$var" "$( f_sysrc_get_default "$var" )" ) @@ -67,34 +66,10 @@ f_dialog_rcedit() _input=$( f_sysrc_get "$var" ) fi - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - - local opterm="--" - [ "$USE_XDIALOG" ] && opterm= - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - $opterm \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) - # Return if user has either pressed ESC or chosen Cancel/No - [ $retval -eq $SUCCESS ] || return $retval + _input=$( f_dialog_input "$msg" "$_input" \ + "$hline_alnum_punc_tab_enter" + ) || return # Return if the value has not changed from current local cur_val="$( f_sysrc_get "$var" )" Modified: head/usr.sbin/bsdconfig/usermgmt/share/group_input.subr ============================================================================== --- head/usr.sbin/bsdconfig/usermgmt/share/group_input.subr Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/usermgmt/share/group_input.subr Fri Dec 21 18:58:19 2012 (r244548) @@ -111,39 +111,16 @@ f_dialog_menu_group_list() # f_dialog_input_group_name() { - local msg="$( printf "$msg_group" )" - local hline="$hline_alnum_tab_enter" - # # Loop until the user provides taint-free/valid input # - local size retval _name="$1" _input="$1" + local _name="$1" _input="$1" while :; do - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) # Return if user has either pressed ESC or chosen Cancel/No - [ $retval -eq $SUCCESS ] || return $retval + _input=$( f_dialog_input "$msg_group" "$_input" \ + "$hline_alnum_tab_enter" + ) || return # Check for no-change [ "$_input" = "$_name" ] && return $SUCCESS @@ -283,35 +260,12 @@ f_dialog_input_group_password() # f_dialog_input_group_gid() { - local msg size retval _input="$1" - local hline="$hline_num_tab_enter" - - msg=$( printf "$msg_group_id_leave_empty_for_default" ) - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) + local _input="$1" # Return if user has either pressed ESC or chosen Cancel/No - [ $retval -eq $SUCCESS ] || return $retval + _input=$( f_dialog_input "$msg_group_id_leave_empty_for_default" \ + "$_input" "$hline_num_tab_enter" + ) || return group_gid="$_input" save_flag=1 @@ -416,36 +370,13 @@ f_dialog_input_group_members() _input="$_group_members" ;; 2) # Enter Group Members manually - hline="$hline_num_tab_enter" - msg=$( - printf "$msg_group_members ($msg_separated_by_commas)" - ) - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _group_members=$( f_dialog_inputstr ) + msg="$msg_group_members ($msg_separated_by_commas)" # Return to previous menu if user has either # pressed ESC or chosen Cancel/No - [ $retval -eq $SUCCESS ] || continue + _group_members=$( f_dialog_input "$msg" "$_input" \ + "$hline_num_tab_enter" + ) || continue _input="$_group_members" ;; Modified: head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr ============================================================================== --- head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr Fri Dec 21 18:25:05 2012 (r244547) +++ head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr Fri Dec 21 18:58:19 2012 (r244548) @@ -216,39 +216,16 @@ f_dialog_input_member_groups() # f_dialog_input_name() { - local msg="$( printf "$msg_login" )" - local hline="$hline_alnum_tab_enter" - # # Loop until the user provides taint-free/valid input # - local size retval _name="$1" _input="$1" + local _name="$1" _input="$1" while :; do - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) # Return if user has either pressed ESC or chosen Cancel/No - [ $retval -eq $SUCCESS ] || return $retval + _input=$( f_dialog_input "$msg_login" "$_input" \ + "$hline_alnum_tab_enter" + ) || return # Check for no-change [ "$_input" = "$_name" ] && return $SUCCESS @@ -389,35 +366,12 @@ f_dialog_input_password() # f_dialog_input_gecos() { - local msg size retval _input="$1" - local hline="$hline_alnum_punc_tab_enter" - - msg=$( printf "$msg_full_name" ) - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) + local _input="$1" # Return if user has either pressed ESC or chosen Cancel/No - [ $retval -eq $SUCCESS ] || return $retval + _input=$( f_dialog_input "$msg_full_name" "$_input" \ + "$hline_alnum_punc_tab_enter" + ) || return pw_gecos="$_input" save_flag=1 @@ -435,35 +389,12 @@ f_dialog_input_gecos() # f_dialog_input_uid() { - local msg size retval _input="$1" - local hline="$hline_num_tab_enter" - - msg=$( printf "$msg_user_id_leave_empty_for_default" ) - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) + local _input="$1" # Return if user has either pressed ESC or chosen Cancel/No - [ $retval -eq $SUCCESS ] || return $retval + _input=$( f_dialog_input "$msg_user_id_leave_empty_for_default" \ + "$_input" "$hline_num_tab_enter" + ) || return pw_uid="$_input" save_flag=1 @@ -481,35 +412,12 @@ f_dialog_input_uid() # f_dialog_input_gid() { - local msg size retval _input="$1" - local hline="$hline_num_tab_enter" - - msg=$( printf "$msg_group_id_leave_empty_for_default" ) - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) + local _input="$1" # Return if user has either pressed ESC or chosen Cancel/No - [ $retval -eq $SUCCESS ] || return $retval + _input=$( f_dialog_input "$msg_group_id_leave_empty_for_default" \ + "$_input" "$hline_num_tab_enter" + ) || return pw_gid="$_input" save_flag=1 @@ -527,35 +435,12 @@ f_dialog_input_gid() # f_dialog_input_class() { - local msg size retval _input="$1" - local hline="$hline_alnum_tab_enter" - - msg=$( printf "$msg_login_class" ) - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) + local _input="$1" # Return if user has either pressed ESC or chosen Cancel/No - [ $retval -eq $SUCCESS ] || return $retval + _input=$( f_dialog_input "$msg_login_class" "$_input" \ + "$hline_alnum_tab_enter" + ) || return pw_class="$_input" save_flag=1 @@ -695,31 +580,11 @@ f_dialog_input_change() f_isinteger "$ret_days" && ret_days=$(( $ret_days + 1 )) - msg="$msg_password_expires_in_how_many_days" - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$ret_days" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$ret_days\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - ret_days=$( f_dialog_inputstr ) - # Return to menu if either ESC or Cancel/No - [ $retval -eq $SUCCESS ] || continue + ret_days=$( f_dialog_input \ + "$msg_password_expires_in_how_many_days" \ + "$ret_days" "$hline" + ) || continue # Taint-check the user's input if ! f_isinteger "$ret_days"; then @@ -741,30 +606,10 @@ f_dialog_input_change() msg=$( printf "$msg_number_of_seconds_since_epoch" \ "$( date -r 1 "+%c %Z" )" ) - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - ret_secs=$( f_dialog_inputstr ) # Return to menu if either ESC or Cancel/No - [ $retval -eq $SUCCESS ] || continue + ret_secs=$( f_dialog_input \ + "$msg" "$_input" "$hline" ) || continue _input="$ret_secs" @@ -919,31 +764,11 @@ f_dialog_input_expire() f_isinteger "$ret_days" && ret_days=$(( $ret_days + 1 )) - msg="$msg_account_expires_in_how_many_days" - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$ret_days" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$ret_days\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - ret_days=$( f_dialog_inputstr ) - # Return to menu if either ESC or Cancel/No - [ $retval -eq $SUCCESS ] || continue + ret_days=$( f_dialog_input \ + "$msg_account_expires_in_how_many_days" \ + "$ret_days" "$hline" + ) || continue # Taint-check the user's input if ! f_isinteger "$ret_days"; then @@ -965,30 +790,10 @@ f_dialog_input_expire() msg=$( printf "$msg_number_of_seconds_since_epoch" \ "$( date -r 1 "+%c %Z" )" ) - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - ret_secs=$( f_dialog_inputstr ) # Return to menu if either ESC or Cancel/No - [ $retval -eq $SUCCESS ] || continue + ret_secs=$( f_dialog_input \ + "$msg" "$_input" "$hline" ) || continue _input="$ret_secs" @@ -1022,35 +827,12 @@ f_dialog_input_expire() # f_dialog_input_home_dir() { - local msg size retval _input="$1" - local hline="$hline_alnum_punc_tab_enter" *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***