diff options
Diffstat (limited to 'usr.sbin/bsdconfig/networking/share/ipaddr.subr')
-rw-r--r-- | usr.sbin/bsdconfig/networking/share/ipaddr.subr | 65 |
1 files changed, 20 insertions, 45 deletions
diff --git a/usr.sbin/bsdconfig/networking/share/ipaddr.subr b/usr.sbin/bsdconfig/networking/share/ipaddr.subr index 65c2b98..d5398e5 100644 --- a/usr.sbin/bsdconfig/networking/share/ipaddr.subr +++ b/usr.sbin/bsdconfig/networking/share/ipaddr.subr @@ -30,7 +30,7 @@ if [ ! "$_NETWORKING_IPADDR_SUBR" ]; then _NETWORKING_IPADDR_SUBR=1 BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 -f_include $BSDCFG_SHARE/sysrc.subr +f_dprintf "%s: loading includes..." networking/ipaddr.subr f_include $BSDCFG_SHARE/dialog.subr f_include $BSDCFG_SHARE/strings.subr f_include $BSDCFG_SHARE/networking/common.subr @@ -104,6 +104,7 @@ f_validate_ipaddr() [ $noctets -eq 4 ] || exit 4 ) } + # f_dialog_iperror $error $ipaddr # # Display a msgbox with the appropriate error message for an error returned by @@ -116,14 +117,10 @@ f_dialog_iperror() [ ${error:-0} -ne 0 ] || return $SUCCESS case "$error" in - 1) f_dialog_msgbox "$( printf \ - "$msg_ipv4_addr_octet_contains_invalid_chars" "$ip" )";; - 2) f_dialog_msgbox "$( printf \ - "$msg_ipv4_addr_octet_is_null" "$ip" )";; - 3) f_dialog_msgbox "$( printf \ - "$msg_ipv4_addr_octet_exceeds_max_value" "$ip" )";; - 4) f_dialog_msgbox "$( printf \ - "$msg_ipv4_addr_octet_missing_or_extra" "$ip" )";; + 1) f_show_msg "$msg_ipv4_addr_octet_contains_invalid_chars" "$ip";; + 2) f_show_msg "$msg_ipv4_addr_octet_is_null" "$ip";; + 3) f_show_msg "$msg_ipv4_addr_octet_exceeds_max_value" "$ip";; + 4) f_show_msg "$msg_ipv4_addr_octet_missing_or_extra" "$ip";; esac } @@ -294,14 +291,10 @@ f_dialog_ip6error() [ ${error:-0} -ne 0 ] || return $SUCCESS case "$error" in - 1) f_dialog_msgbox "$( printf \ - "$msg_ipv6_addr_segment_contains_invalid_chars" "$ip" )";; - 2) f_dialog_msgbox "$( printf \ - "$msg_ipv6_addr_too_many_null_segments" "$ip" )";; - 3) f_dialog_msgbox "$( printf \ - "$msg_ipv6_addr_segment_contains_too_many_chars" "$ip" )";; - 4) f_dialog_msgbox "$( printf \ - "$msg_ipv6_addr_too_few_or_extra_segments" "$ip" )";; + 1) f_show_msg "$msg_ipv6_addr_segment_contains_invalid_chars" "$ip";; + 2) f_show_msg "$msg_ipv6_addr_too_many_null_segments" "$ip";; + 3) f_show_msg "$msg_ipv6_addr_segment_contains_too_many_chars" "$ip";; + 4) f_show_msg "$msg_ipv6_addr_too_few_or_extra_segments" "$ip";; *) if [ $(( $error & 0xF )) -eq 5 ]; then # IPv4 at the end of IPv6 address is invalid @@ -353,48 +346,26 @@ f_dialog_input_ipaddr() if f_nfs_mounted && ! f_jailed; then local setting="$( printf "$msg_current_ipaddr" \ "$interface" "$_ipaddr" )" - local message="$( printf "$msg_nfs_mounts_may_cause_hang" \ - "$setting" )" - f_dialog_msgbox "$message" + f_show_msg "$msg_nfs_mounts_may_cause_hang" "$setting" return $FAILURE 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 @@ -441,4 +412,8 @@ f_dialog_input_ipaddr() return $SUCCESS } +############################################################ MAIN + +f_dprintf "%s: Successfully loaded." networking/ipaddr.subr + fi # ! $_NETWORKING_IPADDR_SUBR |