svn commit: r251242 - in head/usr.sbin/bsdconfig: console mouse networking/share password/share share share/media startup startup/share usermgmt/share

Devin Teske dteske at FreeBSD.org
Sun Jun 2 05:45:30 UTC 2013


Author: dteske
Date: Sun Jun  2 05:45:25 2013
New Revision: 251242
URL: http://svnweb.freebsd.org/changeset/base/251242

Log:
  Similar to r251236, improve the portion of dialog(1) API in dialog.subr
  responsible for retrieving stored input (for the --inputbox and --password
  widgets).
  
  When we (Ron McDowell and I) developed the first version of bsdconfig, it
  used temporary files to store responses from dialog(1). That hasn't been
  true for a very long time, so the need to always execute some clean-up
  function is long-deprecated. The function that used to perform these clean-
  up routines for these widgets was f_dialog_inputstr().
  
  We really don't need f_dialog_inputstr() for its originally designed purpose
  as all dialog invocations no longer require temporary files.
  
  Just as in r251236, redesign f_dialog_inputstr() in the following four ways:
  
  1. Rename f_dialog_inputstr() to f_dialog_inputstr_fetch()
  2. Introduce the new first-argument of $var_to_set to reduce forking
  3. Create a corresponding f_dialog_inputstr_store() to abstract storage
  4. Offload the sanitization to a new function, f_dialog_line_sanitize()
  
  It should be noted that f_dialog_line_sanitize() -- unlike its cousin from
  SVN r251236, f_dialog_data_sanitize() -- trims leading/trailing whitespace
  from the user's input. This helps prevent errors and common mistakes caused
  by the fact that the new cdialog implementation allows the right-arrow
  cursor key to go beyond the last byte of realtime input (adding whitespace
  at the end of the typed value).
  
  While we're centralizing the sanitization, let's rewrite f_dialog_input()
  while we're here to likewise reduce forking. The f_dialog_input() function
  now expects the first argument of $var_to_set instead of producing results
  on standard-out.
  
  These changes greatly improve readability and also improve performance.

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/media.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/password/share/password.subr
  head/usr.sbin/bsdconfig/share/dialog.subr
  head/usr.sbin/bsdconfig/share/media/tcpip.subr
  head/usr.sbin/bsdconfig/share/mustberoot.subr
  head/usr.sbin/bsdconfig/share/variable.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	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/console/saver	Sun Jun  2 05:45:25 2013	(r251242)
@@ -183,9 +183,9 @@ while :; do
 		break ;;
 	"$msg_timeout") # Set the screen saver timeout interval
 		f_dialog_title "$msg_value_required"
-		blanktime=$( f_dialog_input "$msg_enter_timeout_period" \
-		                            "$( f_sysrc_get blanktime )"
-		           ) && f_sysrc_set blanktime "$blanktime"
+		f_dialog_input blanktime "$msg_enter_timeout_period" \
+		               "$( f_sysrc_get blanktime )" &&
+			f_sysrc_set blanktime "$blanktime"
 		f_dialog_title_restore
 		;;
 	esac

Modified: head/usr.sbin/bsdconfig/mouse/flags
==============================================================================
--- head/usr.sbin/bsdconfig/mouse/flags	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/mouse/flags	Sun Jun  2 05:45:25 2013	(r251242)
@@ -79,9 +79,8 @@ flags=$( f_sysrc_get moused_flags )
 # Prompt the user with the current value
 #
 f_dialog_title "$msg_value_required"
-flags=$( f_dialog_input "$msg_please_specify_the_mouse_daemon_flags" \
-                        "$flags"
-       ) || f_die
+f_dialog_input flags "$msg_please_specify_the_mouse_daemon_flags" \
+               "$flags" || f_die
 f_dialog_title_restore
 
 #

Modified: head/usr.sbin/bsdconfig/networking/share/hostname.subr
==============================================================================
--- head/usr.sbin/bsdconfig/networking/share/hostname.subr	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/networking/share/hostname.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -108,9 +108,8 @@ f_dialog_input_hostname()
 	# Loop until the user provides taint-free input.
 	#
 	while :; do
-		hostname=$( f_dialog_input "$msg" "$hostname" \
-		                           "$hline_alnum_punc_tab_enter"
-		          ) || return
+		f_dialog_input hostname "$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	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/networking/share/ipaddr.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -162,9 +162,8 @@ f_dialog_input_ipaddr()
 		# - 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
+		f_dialog_input _input "$msg" "$_ipaddr" \
+		               "$hline_num_punc_tab_enter" || return
 		[ "$_ipaddr" = "$_input" ] && return $FAILURE
 
 		# Return success if NULL value was entered

Modified: head/usr.sbin/bsdconfig/networking/share/media.subr
==============================================================================
--- head/usr.sbin/bsdconfig/networking/share/media.subr	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/networking/share/media.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -122,8 +122,8 @@ f_dialog_input_options()
 	local msg="$( printf "$msg_please_enter_mediaopts" "$interface" )"
 	local hline="$hline_alnum_punc_tab_enter"
 
-	local dialog_inputbox
-	dialog_inputbox=$( $DIALOG \
+	local _options
+	_options=$( $DIALOG \
 		--title "$DIALOG_TITLE"         \
 		--backtitle "$DIALOG_BACKTITLE" \
 		--hline "$hline"                \
@@ -133,10 +133,8 @@ f_dialog_input_options()
 		"$options"                      \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
-
 	local retval=$?
-	setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
-	local _options="$( f_dialog_inputstr )"
+	f_dialog_line_sanitize _options
 
 	[ $retval -eq $SUCCESS ] && options="$_options"
 

Modified: head/usr.sbin/bsdconfig/networking/share/netmask.subr
==============================================================================
--- head/usr.sbin/bsdconfig/networking/share/netmask.subr	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/networking/share/netmask.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -110,9 +110,8 @@ f_dialog_input_netmask()
 		# - 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
+		f_dialog_input _input "$msg" "$_netmask" \
+		               "$hline_num_punc_tab_enter" || return
 		[ "$_netmask" = "$_input" ] && return $FAILURE
 
 		# Return success if NULL value was entered

Modified: head/usr.sbin/bsdconfig/networking/share/resolv.subr
==============================================================================
--- head/usr.sbin/bsdconfig/networking/share/resolv.subr	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/networking/share/resolv.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -311,9 +311,8 @@ f_dialog_input_nameserver()
 	# Loop until the user provides taint-free input.
 	#
 	while :; do
-		new_ns=$( f_dialog_input "$msg" "$ns" \
-		                         "$hline_num_punc_tab_enter"
-		        ) || return
+		f_dialog_input new_ns "$msg" "$ns" \
+		               "$hline_num_punc_tab_enter" || return
 
 		# Take only the first "word" of the user's input
 		new_ns="${new_ns%%[$IFS]*}"

Modified: head/usr.sbin/bsdconfig/networking/share/routing.subr
==============================================================================
--- head/usr.sbin/bsdconfig/networking/share/routing.subr	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/networking/share/routing.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -83,10 +83,9 @@ f_dialog_input_defaultrouter()
 	#
 	local retval
 	while :; do
-		defaultrouter=$( f_dialog_input \
-			"$msg_please_enter_default_router" \
-			"$defaultrouter" "$hline_num_punc_tab_enter"
-		)
+		f_dialog_input defaultrouter \
+		               "$msg_please_enter_default_router" \
+		               "$defaultrouter" "$hline_num_punc_tab_enter"
 		retval=$?
 		[ "$defaultrouter" ] || return $SUCCESS
 		[ $retval -eq $SUCCESS ] || return $retval

Modified: head/usr.sbin/bsdconfig/password/share/password.subr
==============================================================================
--- head/usr.sbin/bsdconfig/password/share/password.subr	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/password/share/password.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -69,10 +69,9 @@ f_dialog_input_password()
 	#
 	# Loop until the user provides taint-free/valid input
 	#
-	local retval _password1 _password2
+	local _password1 _password2
 	while :; do
-		local dialog_inputbox
-		dialog_inputbox=$( $DIALOG \
+		_password1=$( $DIALOG \
 			--title "$DIALOG_TITLE"         \
 			--backtitle "$DIALOG_BACKTITLE" \
 			--hline "$hline"                \
@@ -82,16 +81,11 @@ f_dialog_input_password()
 			--passwordbox "$msg"            \
 			$height1 $width1                \
 			2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
-		)
+		) || return $?
+			# Return if user either pressed ESC or chose Cancel/No
+		debug= f_dialog_line_sanitize _password1
 
-		retval=$?
-		setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
-		_password1=$( f_dialog_inputstr )
-
-		# Return if user has either pressed ESC or chosen Cancel/No
-		[ $retval -eq $SUCCESS ] || return $retval
-
-		dialog_inputbox=$( $DIALOG \
+		_password2=$( $DIALOG \
 			--title "$DIALOG_TITLE"         \
 			--backtitle "$DIALOG_BACKTITLE" \
 			--hline "$hline"                \
@@ -101,14 +95,9 @@ f_dialog_input_password()
 			--passwordbox "$rmsg"           \
 			$height2 $width2                \
 			2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
-		)
-
-		retval=$?
-		setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
-		_password2=$( f_dialog_inputstr )
-
-		# Return if user has either pressed ESC or chosen Cancel/No
-		[ $retval -eq $SUCCESS ] || return $retval
+		) || return $?
+			# Return if user either pressed ESC or chose Cancel/No
+		debug= f_dialog_line_sanitize _password2
 
 		# Check for NULL entry
 		if ! [ "$_password1" -o "$_password2" ]; then

Modified: head/usr.sbin/bsdconfig/share/dialog.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/dialog.subr	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/share/dialog.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -144,6 +144,48 @@ f_dialog_data_sanitize()
 	done
 }
 
+# f_dialog_line_sanitize $var_to_edit ...
+#
+# When using dialog(1) or Xdialog(1) sometimes unintended warnings or errors
+# are generated from underlying libraries. For example, if $LANG is set to an
+# invalid or unknown locale, the warnings from the Xdialog(1) libraries will
+# clutter the output. This function helps by providing a centralied function
+# that removes spurious warnings from the dialog(1) (or Xdialog(1)) response.
+#
+# Simply pass the name of one or more variables that need to be sanitized.
+# After execution, the variables will hold their newly-sanitized data.
+#
+# This function, unlike f_dialog_data_sanitize(), also removes leading/trailing
+# whitespace from each line.
+#
+f_dialog_line_sanitize()
+{
+	if [ "$#" -eq 0 ]; then
+		f_dprintf "%s: called with zero arguments" \
+		          f_dialog_response_sanitize
+		return $FAILURE
+	fi
+
+	local __var_to_edit
+	for __var_to_edit in $*; do
+		# Skip warnings and trim leading/trailing whitespace
+		setvar $__var_to_edit "$( f_getvar $__var_to_edit | awk '
+			BEGIN { data = 0 }
+			{
+				if ( ! data )
+				{
+					if ( $0 ~ /^$/ ) next
+					if ( $0 ~ /^Gdk-WARNING \*\*:/ ) next
+					data = 1
+				}
+				sub(/^[[:space:]]*/, "")
+				sub(/[[:space:]]*$/, "")
+				print
+			}
+		' )"
+	done
+}
+
 ############################################################ TITLE FUNCTIONS
 
 # f_dialog_title [$new_title]
@@ -1588,33 +1630,45 @@ f_dialog_noyes()
 
 ############################################################ INPUT FUNCTIONS
 
-# f_dialog_inputstr
+# f_dialog_inputstr_store [-s] $text
+#
+# Store some text from a dialog(1) inputbox to be retrieved later by
+# f_dialog_inputstr_fetch(). If the first argument is `-s', the text is
+# sanitized before being stored.
+#
+f_dialog_inputstr_store()
+{
+	local sanitize=
+	[ "$1" = "-s" ] && sanitize=1 && shift 1 # -s
+	local text="$1"
+
+	# Sanitize the line before storing it if desired
+	[ "$sanitize" ] && f_dialog_line_sanitize text
+
+	setvar DIALOG_INPUTBOX_$$ "$text"
+}
+
+# f_dialog_inputstr_fetch [$var_to_set]
 #
 # Obtain the inputstr entered by the user from the most recently displayed
-# dialog(1) inputbox and clean up any temporary files/variables.
+# dialog(1) inputbox (previously stored with f_dialog_inputstr_store() above).
+# If $var_to_set is NULL or missing, output is printed to stdout (which is less
+# recommended due to performance degradation; in a loop for example).
 #
-f_dialog_inputstr()
+f_dialog_inputstr_fetch()
 {
-	# Skip warnings and trim leading/trailing whitespace from user input
-	eval echo \"\$DIALOG_INPUTBOX_$$\" | awk '
-		BEGIN { found = 0 }
-		{
-			if ( ! found )
-			{
-				if ( $0 ~ /^$/ ) next
-				if ( $0 ~ /^Gdk-WARNING \*\*:/ ) next
-				found = 1
-			}
-			sub(/^[[:space:]]*/, "")
-			sub(/[[:space:]]*$/, "")
-			print
-		}
-	'
+	local __var_to_set="$1" __cp
+
+	debug= f_getvar DIALOG_INPUTBOX_$$ "${__var_to_set:-__cp}" # get data
 	setvar DIALOG_INPUTBOX_$$ "" # scrub memory in case data was sensitive
+
+	# Return the line on standard-out if desired
+	[ "$__var_to_set" ] || echo "$__cp"
+
 	return $SUCCESS
 }
 
-# f_dialog_input $prompt [$init [$hline]]
+# f_dialog_input $var_to_set $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
@@ -1629,34 +1683,38 @@ f_dialog_inputstr()
 #
 f_dialog_input()
 {
-	local prompt="$1" init="$2" hline="$3"
-	local height width
-	f_dialog_inputbox_size height width \
+	local __var_to_set="$1" __prompt="$2" __init="$3" __hline="$4"
+
+	# NOTE: Function name appended to prevent __var_{height,width} values
+	#       from becoming local (and thus preventing setvar from working).
+	local __height_input __width_input
+	f_dialog_inputbox_size __height_input __width_input \
 		"$DIALOG_TITLE" "$DIALOG_BACKTITLE" \
-		"$prompt" "$init" "$hline"
+		"$__prompt" "$__init" "$__hline"
 
-	local opterm="--"
-	[ "$USE_XDIALOG" ] && opterm=
+	local __opterm="--"
+	[ "$USE_XDIALOG" ] && __opterm=
 
-	local dialog_input
-	dialog_input=$(
+	local __dialog_input
+	__dialog_input=$(
 		$DIALOG \
 			--title "$DIALOG_TITLE"         \
 			--backtitle "$DIALOG_BACKTITLE" \
-			--hline "$hline"                \
+			--hline "$__hline"              \
 			--ok-label "$msg_ok"            \
 			--cancel-label "$msg_cancel"    \
-			--inputbox "$prompt"            \
-			$height $width                  \
-			$opterm "$init"                 \
+			--inputbox "$__prompt"          \
+			$__height_input $__width_input  \
+			$__opterm "$__init"             \
 			2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
-	local retval=$?
+	local __retval=$?
 
-	setvar DIALOG_INPUTBOX_$$ "$dialog_input"
-	f_dialog_inputstr
+	# Remove warnings and leading/trailing whitespace from user input
+	f_dialog_line_sanitize __dialog_input
 
-	return $retval
+	setvar "$__var_to_set" "$__dialog_input"
+	return $__retval
 }
 
 ############################################################ MENU FUNCTIONS

Modified: head/usr.sbin/bsdconfig/share/media/tcpip.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/media/tcpip.subr	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/share/media/tcpip.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -1422,29 +1422,23 @@ f_device_dialog_tcp()
 						"$_netmask" \
 						&& break ;;
 				"$msg_host_name_including_domain:")
-					cp=$( f_dialog_input "$cp" \
-					                     "$_hostname"
-					    ) && _hostname="$cp" ;;
+					f_dialog_input cp "$cp" "$_hostname" \
+						&& _hostname="$cp" ;;
 				"$msg_ipv4_gateway:")
-					cp=$( f_dialog_input "$cp" \
-					                     "$_gateway"
-					    ) && _gateway="$cp" ;;
+					f_dialog_input cp "$cp" "$_gateway" \
+						&& _gateway="$cp" ;;
 				"$msg_name_server:")
-					cp=$( f_dialog_input "$cp" \
-					                     "$_nameserver"
-					    ) && _nameserver="$cp" ;;
+					f_dialog_input cp "$cp" "$_nameserver" \
+						&& _nameserver="$cp" ;;
 				"$msg_ipv4_address:")
-					cp=$( f_dialog_input "$cp" \
-					                     "$_ipaddr"
-					    ) && _ipaddr="$cp" ;;
+					f_dialog_input cp "$cp" "$_ipaddr" \
+						&& _ipaddr="$cp" ;;
 				"$msg_netmask:")
-					cp=$( f_dialog_input "$cp" \
-					                     "$_netmask"
-					    ) && _netmask="$cp" ;;
+					f_dialog_input cp "$cp" "$_netmask" \
+						&& _netmask="$cp" ;;
 				"$msg_extra_options_to_ifconfig")
-					cp=$( f_dialog_input "$cp" \
-					                     "$_extras"
-					    ) && _extras="$cp" ;;
+					f_dialog_input cp "$cp" "$_extras" \
+						&& _extras="$cp" ;;
 				esac
 			done
 

Modified: head/usr.sbin/bsdconfig/share/mustberoot.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/mustberoot.subr	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/share/mustberoot.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -177,8 +177,7 @@ f_become_root_via_sudo()
 				[ $retval -eq 255 ] &&
 					f_die $retval "$password"
 			else
-				local dialog_inputbox
-				dialog_inputbox=$( $DIALOG \
+				password=$( $DIALOG \
 					--title "$DIALOG_TITLE"         \
 					--backtitle "$DIALOG_BACKTITLE" \
 					--hline "$hline"                \
@@ -188,14 +187,9 @@ f_become_root_via_sudo()
 					--passwordbox "$msg"            \
 					$height $width                  \
 					2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
-				)
-				retval=$?
-				setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
-				password=$( f_dialog_inputstr )
+				) || exit $?
 			fi
-
-			# Exit if the user cancelled.
-			[ $retval -eq $SUCCESS ] || exit $retval
+			debug= f_dialog_line_sanitize password
 
 			#
 			# Validate sudo(8) credentials

Modified: head/usr.sbin/bsdconfig/share/variable.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/variable.subr	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/share/variable.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -93,8 +93,7 @@ f_variable_get_value()
 
 	if ! { f_getvar $var cp && ! f_interactive; }; then
 		shift 1 # var
-		cp=$( f_dialog_input "$( printf "$@" )" "$cp" ) &&
-			setvar $var "$cp"
+		f_dialog_input cp "$( printf "$@" )" "$cp" && setvar $var "$cp"
 	fi
 
 	return $SUCCESS

Modified: head/usr.sbin/bsdconfig/startup/misc
==============================================================================
--- head/usr.sbin/bsdconfig/startup/misc	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/startup/misc	Sun Jun  2 05:45:25 2013	(r251242)
@@ -303,7 +303,7 @@ dialog_input_value()
 	local prompt="$1" _input="$2"
 
 	f_dialog_title "$msg_value_required"
-	_input=$( f_dialog_input "$prompt" "$_input" "$hline_alnum_tab_enter" )
+	f_dialog_input _input "$prompt" "$_input" "$hline_alnum_tab_enter"
 	local retval=$?
 	f_dialog_title_restore
 

Modified: head/usr.sbin/bsdconfig/startup/share/rcconf.subr
==============================================================================
--- head/usr.sbin/bsdconfig/startup/share/rcconf.subr	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/startup/share/rcconf.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -454,9 +454,8 @@ f_dialog_input_rcvar()
 	while :; do
 
 		# Return if user either pressed ESC or chosen Cancel/No
-		_input=$( f_dialog_input "$msg_please_enter_rcvar_name" \
-		                         "$_input" "$hline_alnum_tab_enter"
-		        ) || return
+		f_dialog_input _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	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/startup/share/rcedit.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -68,9 +68,8 @@ f_dialog_rcedit()
 	fi
 
 	# Return if user has either pressed ESC or chosen Cancel/No
-	_input=$( f_dialog_input "$msg" "$_input" \
-	                         "$hline_alnum_punc_tab_enter"
-	        ) || return
+	f_dialog_input _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	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/usermgmt/share/group_input.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -125,9 +125,8 @@ f_dialog_input_group_name()
 	while :; do
 
 		# Return if user has either pressed ESC or chosen Cancel/No
-		_input=$( f_dialog_input "$msg_group" "$_input" \
-		                         "$hline_alnum_tab_enter"
-		        ) || return
+		f_dialog_input _input "$msg_group" "$_input" \
+		               "$hline_alnum_tab_enter" || return
 
 		# Check for no-change
 		[ "$_input" = "$_name" ] && return $SUCCESS
@@ -198,8 +197,7 @@ f_dialog_input_group_password()
 	#
 	local retval _password1 _password2
 	while :; do
-		local dialog_inputbox
-		dialog_inputbox=$( $DIALOG \
+		_password1=$( $DIALOG \
 			--title "$DIALOG_TITLE"         \
 			--backtitle "$DIALOG_BACKTITLE" \
 			--hline "$hline"                \
@@ -210,15 +208,13 @@ f_dialog_input_group_password()
 			$height1 $width1                \
 			2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 		)
-
 		retval=$?
-		setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
-		_password1=$( f_dialog_inputstr )
+		debug= f_dialog_line_sanitize _password1
 
 		# Return if user has either pressed ESC or chosen Cancel/No
 		[ $retval -eq $SUCCESS ] || return $retval
 
-		dialog_inputbox=$( $DIALOG \
+		_password2=$( $DIALOG \
 			--title "$DIALOG_TITLE"         \
 			--backtitle "$DIALOG_BACKTITLE" \
 			--hline "$hline"                \
@@ -229,10 +225,8 @@ f_dialog_input_group_password()
 			$height2 $width2                \
 			2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 		)
-
 		retval=$?
-		setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
-		_password2=$( f_dialog_inputstr )
+		debug= f_dialog_line_sanitize _password2
 
 		# Return if user has either pressed ESC or chosen Cancel/No
 		[ $retval -eq $SUCCESS ] || return $retval
@@ -275,9 +269,8 @@ f_dialog_input_group_gid()
 	local _input="$1"
 
 	# Return if user has either pressed ESC or chosen Cancel/No
-	_input=$( f_dialog_input "$msg_group_id_leave_empty_for_default" \
-	                         "$_input" "$hline_num_tab_enter"
-	        ) || return
+	f_dialog_input _input "$msg_group_id_leave_empty_for_default" \
+	               "$_input" "$hline_num_tab_enter" || return
 
 	group_gid="$_input"
 	save_flag=1
@@ -392,11 +385,10 @@ f_dialog_input_group_members()
 		2) # Enter Group Members manually
 			msg="$msg_group_members ($msg_separated_by_commas)"
 
-			# Return to previous menu if user has either
-			#     pressed ESC or chosen Cancel/No
-			_group_members=$( f_dialog_input "$msg" "$_input" \
-			                                 "$hline_num_tab_enter"
-			                ) || continue
+			f_dialog_input _group_members "$msg" "$_input" \
+			               "$hline_num_tab_enter" || continue
+				# Return to previous menu if user either
+				# pressed ESC or chose Cancel/No
 
 			_input="$_group_members"
 			;;

Modified: head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
==============================================================================
--- head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr	Sun Jun  2 04:30:03 2013	(r251241)
+++ head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr	Sun Jun  2 05:45:25 2013	(r251242)
@@ -226,9 +226,8 @@ f_dialog_input_name()
 	while :; do
 
 		# Return if user has either pressed ESC or chosen Cancel/No
-		_input=$( f_dialog_input "$msg_login" "$_input" \
-		                         "$hline_alnum_tab_enter"
-		        ) || return
+		f_dialog_input _input "$msg_login" "$_input" \
+		               "$hline_alnum_tab_enter" || return
 
 		# Check for no-change
 		[ "$_input" = "$_name" ] && return $SUCCESS
@@ -297,10 +296,9 @@ f_dialog_input_password()
 	#
 	# Loop until the user provides taint-free/valid input
 	#
-	local retval _password1 _password2
+	local _password1 _password2
 	while :; do
-		local dialog_inputbox
-		dialog_inputbox=$( $DIALOG \
+		_password1=$( $DIALOG \
 			--title "$DIALOG_TITLE"         \
 			--backtitle "$DIALOG_BACKTITLE" \
 			--hline "$hline"                \
@@ -310,13 +308,11 @@ f_dialog_input_password()
 			--passwordbox "$msg"            \
 			$height1 $width1                \
 			2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
-		)
-
-		retval=$?
-		setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
-		_password1=$( f_dialog_inputstr )
+		) || return $?
+			# Return if user either pressed ESC or chose Cancel/No
+		debug= f_dialog_line_sanitize _password1
 
-		dialog_inputbox=$( $DIALOG \
+		_password2=$( $DIALOG \
 			--title "$DIALOG_TITLE"         \
 			--backtitle "$DIALOG_BACKTITLE" \
 			--hline "$hline"                \
@@ -326,14 +322,9 @@ f_dialog_input_password()
 			--passwordbox "$rmsg"           \
 			$height2 $width2                \
 			2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
-		)
-
-		retval=$?
-		setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
-		_password2=$( f_dialog_inputstr )
-
-		# Return if user has either pressed ESC or chosen Cancel/No
-		[ $retval -eq $SUCCESS ] || return $retval
+		) || return $?
+			# Return if user either pressed ESC or chose Cancel/No
+		debug= f_dialog_line_sanitize _password2
 
 		# Check for password mismatch
 		if [ "$_password1" != "$_password2" ]; then
@@ -373,9 +364,8 @@ f_dialog_input_gecos()
 	local _input="$1"
 
 	# Return if user has either pressed ESC or chosen Cancel/No
-	_input=$( f_dialog_input "$msg_full_name" "$_input" \
-	                         "$hline_alnum_punc_tab_enter"
-	        ) || return
+	f_dialog_input _input "$msg_full_name" "$_input" \
+	               "$hline_alnum_punc_tab_enter" || return
 
 	pw_gecos="$_input"
 	save_flag=1
@@ -396,9 +386,8 @@ f_dialog_input_uid()
 	local _input="$1"
 
 	# Return if user has either pressed ESC or chosen Cancel/No
-	_input=$( f_dialog_input "$msg_user_id_leave_empty_for_default" \
-	                         "$_input" "$hline_num_tab_enter"
-	        ) || return
+	f_dialog_input _input "$msg_user_id_leave_empty_for_default" \
+	               "$_input" "$hline_num_tab_enter" || return
 
 	pw_uid="$_input"
 	save_flag=1
@@ -419,9 +408,8 @@ f_dialog_input_gid()
 	local _input="$1"
 
 	# Return if user has either pressed ESC or chosen Cancel/No
-	_input=$( f_dialog_input "$msg_group_id_leave_empty_for_default" \
-	                         "$_input" "$hline_num_tab_enter"
-	        ) || return
+	f_dialog_input _input "$msg_group_id_leave_empty_for_default" \
+	               "$_input" "$hline_num_tab_enter" || return
 
 	pw_gid="$_input"
 	save_flag=1
@@ -442,9 +430,8 @@ f_dialog_input_class()
 	local _input="$1"
 
 	# Return if user has either pressed ESC or chosen Cancel/No
-	_input=$( f_dialog_input "$msg_login_class" "$_input" \
-	                         "$hline_alnum_tab_enter"
-	        ) || return
+	f_dialog_input _input "$msg_login_class" "$_input" \
+	               "$hline_alnum_tab_enter" || return
 
 	pw_class="$_input"
 	save_flag=1
@@ -585,10 +572,9 @@ f_dialog_input_change()
 				ret_days=$(( $ret_days + 1 ))
 
 			# Return to menu if either ESC or Cancel/No
-			ret_days=$( f_dialog_input \
+			f_dialog_input ret_days \
 				"$msg_password_expires_in_how_many_days" \
-				"$ret_days" "$hline"
-			) || continue
+				"$ret_days" "$hline" || continue
 
 			# Taint-check the user's input
 			if ! f_isinteger "$ret_days"; then
@@ -606,16 +592,12 @@ f_dialog_input_change()
 			break ;;
 
 		4) # Enter value manually
-			local ret_secs
-
 			msg=$( printf "$msg_number_of_seconds_since_epoch" \
 			              "$( date -r 1 "+%c %Z" )" )
 
 			# Return to menu if either ESC or Cancel/No
-			ret_secs=$( f_dialog_input \
-			            	"$msg" "$_input" "$hline" ) || continue
-
-			_input="$ret_secs"
+			f_dialog_input _input \
+			               "$msg" "$_input" "$hline" || continue
 
 			# Taint-check the user's input
 			if ! f_isinteger "${_input:-0}"; then
@@ -771,10 +753,9 @@ f_dialog_input_expire()
 				ret_days=$(( $ret_days + 1 ))
 
 			# Return to menu if either ESC or Cancel/No
-			ret_days=$( f_dialog_input \
+			f_dialog_input ret_days \
 				"$msg_account_expires_in_how_many_days" \
-				"$ret_days" "$hline"
-			) || continue
+				"$ret_days" "$hline" || continue
 
 			# Taint-check the user's input
 			if ! f_isinteger "$ret_days"; then
@@ -792,16 +773,12 @@ f_dialog_input_expire()
 			break ;;
 
 		4) # Enter value manually
-			local ret_secs
-
 			msg=$( printf "$msg_number_of_seconds_since_epoch" \
 			              "$( date -r 1 "+%c %Z" )" )
 
 			# Return to menu if either ESC or Cancel/No
-			ret_secs=$( f_dialog_input \
-			            	"$msg" "$_input" "$hline" ) || continue
-
-			_input="$ret_secs"
+			f_dialog_input _input "$msg" \
+			               "$_input" "$hline" || continue
 
 			# Taint-check the user's input
 			if ! f_isinteger "${_input:-0}"; then
@@ -837,9 +814,8 @@ f_dialog_input_home_dir()
 	local _input="$1"
 
 	# Return if user has either pressed ESC or chosen Cancel/No
-	_input=$( f_dialog_input "$msg_home_directory" "$_input" \
-	                         "$hline_alnum_punc_tab_enter"
-	        ) || return
+	f_dialog_input _input "$msg_home_directory" "$_input" \
+	               "$hline_alnum_punc_tab_enter" || return
 
 	pw_home_dir="$_input"
 	save_flag=1


More information about the svn-src-all mailing list