summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/networking
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2012-12-21 18:58:19 +0000
committerdteske <dteske@FreeBSD.org>2012-12-21 18:58:19 +0000
commit5e7ea05b1afc71ededb3af74c2ab29cec62cc286 (patch)
treeb36ed1ce72c48c84674686128b0f6e806b3330e4 /usr.sbin/bsdconfig/networking
parent804c67a4867afb8b7ef41a3ade748cab870b788c (diff)
downloadFreeBSD-src-5e7ea05b1afc71ededb3af74c2ab29cec62cc286.zip
FreeBSD-src-5e7ea05b1afc71ededb3af74c2ab29cec62cc286.tar.gz
Add much-needed dialog(1) --inputbox function for simplifying the process of
requesting input from the user.
Diffstat (limited to 'usr.sbin/bsdconfig/networking')
-rw-r--r--usr.sbin/bsdconfig/networking/share/hostname.subr32
-rw-r--r--usr.sbin/bsdconfig/networking/share/ipaddr.subr30
-rw-r--r--usr.sbin/bsdconfig/networking/share/netmask.subr32
-rw-r--r--usr.sbin/bsdconfig/networking/share/resolv.subr30
-rw-r--r--usr.sbin/bsdconfig/networking/share/routing.subr29
5 files changed, 21 insertions, 132 deletions
diff --git a/usr.sbin/bsdconfig/networking/share/hostname.subr b/usr.sbin/bsdconfig/networking/share/hostname.subr
index fed8679..e34e80c 100644
--- a/usr.sbin/bsdconfig/networking/share/hostname.subr
+++ b/usr.sbin/bsdconfig/networking/share/hostname.subr
@@ -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
#
diff --git a/usr.sbin/bsdconfig/networking/share/ipaddr.subr b/usr.sbin/bsdconfig/networking/share/ipaddr.subr
index 65c2b98..b345d1c 100644
--- a/usr.sbin/bsdconfig/networking/share/ipaddr.subr
+++ b/usr.sbin/bsdconfig/networking/share/ipaddr.subr
@@ -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
diff --git a/usr.sbin/bsdconfig/networking/share/netmask.subr b/usr.sbin/bsdconfig/networking/share/netmask.subr
index 2f2b378..12e6be9 100644
--- a/usr.sbin/bsdconfig/networking/share/netmask.subr
+++ b/usr.sbin/bsdconfig/networking/share/netmask.subr
@@ -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
diff --git a/usr.sbin/bsdconfig/networking/share/resolv.subr b/usr.sbin/bsdconfig/networking/share/resolv.subr
index 154748b..fc328c5 100644
--- a/usr.sbin/bsdconfig/networking/share/resolv.subr
+++ b/usr.sbin/bsdconfig/networking/share/resolv.subr
@@ -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
#
diff --git a/usr.sbin/bsdconfig/networking/share/routing.subr b/usr.sbin/bsdconfig/networking/share/routing.subr
index b8ccdcd..2b346d4 100644
--- a/usr.sbin/bsdconfig/networking/share/routing.subr
+++ b/usr.sbin/bsdconfig/networking/share/routing.subr
@@ -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
OpenPOWER on IntegriCloud