summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/networking
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bsdconfig/networking')
-rw-r--r--usr.sbin/bsdconfig/networking/INDEX61
-rw-r--r--usr.sbin/bsdconfig/networking/Makefile11
-rw-r--r--usr.sbin/bsdconfig/networking/Makefile.depend11
-rw-r--r--usr.sbin/bsdconfig/networking/USAGE37
-rwxr-xr-xusr.sbin/bsdconfig/networking/defaultrouter76
-rwxr-xr-xusr.sbin/bsdconfig/networking/devices164
-rwxr-xr-xusr.sbin/bsdconfig/networking/hostname76
-rw-r--r--usr.sbin/bsdconfig/networking/include/Makefile6
-rw-r--r--usr.sbin/bsdconfig/networking/include/Makefile.depend11
-rw-r--r--usr.sbin/bsdconfig/networking/include/messages.subr105
-rwxr-xr-xusr.sbin/bsdconfig/networking/nameservers76
-rwxr-xr-xusr.sbin/bsdconfig/networking/networking151
-rw-r--r--usr.sbin/bsdconfig/networking/share/Makefile7
-rw-r--r--usr.sbin/bsdconfig/networking/share/Makefile.depend11
-rw-r--r--usr.sbin/bsdconfig/networking/share/common.subr58
-rw-r--r--usr.sbin/bsdconfig/networking/share/device.subr385
-rw-r--r--usr.sbin/bsdconfig/networking/share/hostname.subr162
-rw-r--r--usr.sbin/bsdconfig/networking/share/ipaddr.subr219
-rw-r--r--usr.sbin/bsdconfig/networking/share/media.subr247
-rw-r--r--usr.sbin/bsdconfig/networking/share/netmask.subr137
-rw-r--r--usr.sbin/bsdconfig/networking/share/resolv.subr502
-rw-r--r--usr.sbin/bsdconfig/networking/share/routing.subr133
-rw-r--r--usr.sbin/bsdconfig/networking/share/services.subr55
23 files changed, 2701 insertions, 0 deletions
diff --git a/usr.sbin/bsdconfig/networking/INDEX b/usr.sbin/bsdconfig/networking/INDEX
new file mode 100644
index 0000000..8527124
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/INDEX
@@ -0,0 +1,61 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown in the bsdconfig menu.
+#
+menu_title="Networking Management"
+
+#
+# A short descriptive line shown at the bottom of the bsdconfig menu. keep it
+# short because any line longer than the terminal width will be truncated.
+#
+menu_help="Setup Networking interfaces, services, etc."
+
+#
+# Two-part variable that defines an action to take when `keyword' is passed on
+# a bsdconfig command line. Variable takes the form "keyword|command" and
+# multiple occurrences of the variable (with different `keyword's, or different
+# `keyword's AND `command's) are allowed. If `command' begins with a '/' then
+# the full path to the program is needed. If `command' begins with anything
+# else it is a path relative to the directory this INDEX file is in. `keyword'
+# can be i18n'ed but `command' is the name of a script.
+#
+menu_selection="networking|networking"
+menu_selection="defaultrouter|defaultrouter"
+menu_selection="hostname|hostname"
+menu_selection="nameservers|nameservers"
+menu_selection="netdev|devices"
+
+#
+# ------------ Items below this line do NOT need i18n translation ------------
+#
+# Name of the program to be run when this menu choice is selected. If it begins
+# with a '/' then the full path to the program is needed. If it begins with
+# anything else it is a path relative to the directory this INDEX file is in.
+#
+menu_program="networking"
diff --git a/usr.sbin/bsdconfig/networking/Makefile b/usr.sbin/bsdconfig/networking/Makefile
new file mode 100644
index 0000000..8a88067
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+SUBDIR= include share
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/120.networking
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= defaultrouter devices hostname nameservers networking
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/networking/Makefile.depend b/usr.sbin/bsdconfig/networking/Makefile.depend
new file mode 100644
index 0000000..f80275d
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/Makefile.depend
@@ -0,0 +1,11 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bsdconfig/networking/USAGE b/usr.sbin/bsdconfig/networking/USAGE
new file mode 100644
index 0000000..8720946
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/USAGE
@@ -0,0 +1,37 @@
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
+
+OPTIONS:
+ -d Provide lots of debugging info on standard-out when running.
+ -D file Send debugging info to file. If file begins with a plus-sign
+ debug info is sent to both standard-out and file (minus the
+ leading plus).
+ -h Print this usage statement and exit.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -X Use Xdialog(1) in place of dialog(1).
diff --git a/usr.sbin/bsdconfig/networking/defaultrouter b/usr.sbin/bsdconfig/networking/defaultrouter
new file mode 100755
index 0000000..b65981f
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/defaultrouter
@@ -0,0 +1,76 @@
+#!/bin/sh
+#-
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+# Prevent device.subr (included indirectly) from auto scanning on load
+DEVICE_SELF_SCAN_ALL=NO
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/networking/routing.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts h$GETOPTS_STDARGS flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_title "$msg_default_router"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Change the default router/gateway
+#
+f_dialog_input_defaultrouter
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/networking/devices b/usr.sbin/bsdconfig/networking/devices
new file mode 100755
index 0000000..433f25c
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/devices
@@ -0,0 +1,164 @@
+#!/bin/sh
+#-
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+# Prevent device.subr (included indirectly) from auto scanning; this will be
+# performed indirectly later via f_dialog_menu_netdev() -- but only after we've
+# successfully completed f_mustberoot_init().
+#
+DEVICE_SELF_SCAN_ALL=NO
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+f_include $BSDCFG_SHARE/media/tcpip.subr
+f_include $BSDCFG_SHARE/networking/device.subr
+f_include $BSDCFG_SHARE/networking/ipaddr.subr
+f_include $BSDCFG_SHARE/networking/media.subr
+f_include $BSDCFG_SHARE/networking/netmask.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line options
+#
+while getopts h$GETOPTS_STDARGS flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_title "$msg_networking_devices"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+defaultitem=
+while :; do
+ f_dialog_menu_netdev "$defaultitem" || break
+ f_dialog_menutag_fetch interface
+ defaultitem="$interface"
+
+ #
+ # dialog_menu_netdev adds an asterisk (*) to the right of the
+ # device name if the interface is active. Remove the asterisk
+ # from the device name if present.
+ #
+ case "$interface" in
+ *\*) interface="${interface%?}" ;;
+ esac
+
+ #
+ # Obtain initial interface settings to be configured. These will be
+ # passed to the f_dialog_menu_netdev_edit function-call below which
+ # will block until the user has either cancelled or finished editing
+ # the values.
+ #
+ # First, attempt to read stored configuration from rc.conf(5) and
+ # fallback to reading the active configuration if not configured in
+ # the rc.conf(5) file(s).
+ #
+ dhcp=
+ _ipaddr=
+ _netmask=
+ _ifconfig=$( f_sysrc_get ifconfig_$interface )
+ if [ "$_ifconfig" ]; then
+ # If DHCP, get IP address/netmask later from ifconfig(8)
+ glob="[Dd][Hh][Cc][Pp]"
+ case "$_ifconfig" in
+ $glob) dhcp=1 ;;
+ [Ss][Yy][Nn][Cc]$glob) dhcp=1 ;;
+ [Nn][Oo][Ss][Yy][Nn][Cc]$glob) dhcp=1 ;;
+ *)
+ #
+ # Get IP address/netmask from rc.conf(5) configuration
+ #
+ dhcp=
+ eval "$(
+ exec 2> /dev/null
+ set -- $_ifconfig
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ inet)
+ shift 1
+ echo "_ipaddr='$1'"
+ ;;
+ netmask)
+ shift 1
+ echo "_netmask='$1'"
+ ;;
+ esac
+ shift 1
+ done
+ )"
+ ;;
+ esac
+ fi
+
+ #
+ # Fill in IP address/netmask from active settings if no
+ # configuration could be extrapolated from rc.conf(5)
+ #
+ [ "$_ipaddr" ] || f_ifconfig_inet $interface _ipaddr
+ [ "$_netmask" ] || f_ifconfig_netmask $interface _netmask
+
+ # Get the extra options (this always comes from rc.conf(5))
+ _options=$( f_ifconfig_options $interface )
+
+ # Block on user-configuration of the probed settings
+ f_dialog_menu_netdev_edit \
+ "$interface" "$_ipaddr" "$_netmask" "$_options" $dhcp
+
+ # Return to root menu if above returns success
+ [ $? -eq $DIALOG_OK ] && break
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/networking/hostname b/usr.sbin/bsdconfig/networking/hostname
new file mode 100755
index 0000000..d0fff01
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/hostname
@@ -0,0 +1,76 @@
+#!/bin/sh
+#-
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+# Prevent device.subr (included indirectly) from auto scanning on load
+DEVICE_SELF_SCAN_ALL=NO
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/networking/hostname.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts h$GETOPTS_STDARGS flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_title "$msg_hostname_domain"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Change the local hostname
+#
+f_dialog_input_hostname
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/networking/include/Makefile b/usr.sbin/bsdconfig/networking/include/Makefile
new file mode 100644
index 0000000..54f66e1
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/include/Makefile
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/120.networking/include
+FILES= messages.subr
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/networking/include/Makefile.depend b/usr.sbin/bsdconfig/networking/include/Makefile.depend
new file mode 100644
index 0000000..f80275d
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/include/Makefile.depend
@@ -0,0 +1,11 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bsdconfig/networking/include/messages.subr b/usr.sbin/bsdconfig/networking/include/messages.subr
new file mode 100644
index 0000000..bb94c36
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/include/messages.subr
@@ -0,0 +1,105 @@
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER"
+hline_arrows_tab_enter="Press arrows, TAB or ENTER"
+hline_num_punc_tab_enter="Use numbers, punctuation, TAB or ENTER"
+msg_activate_default_router="Would you like to activate the new defaultrouter right now?\nIf you choose NO or press ESC, changes will be applied\nduring the next boot.\n\n Current Default Router: %s\n New Default Router: %s\n"
+msg_activate_hostname="Would you like to activate the new hostname right now?\nIf you choose NO or press ESC, changes will be applied\nduring the next boot.\n\n Current Hostname: %s\n New Hostname: %s\n\nNOTE: Your shell prompt may still reflect the original\nhostname until your next login."
+msg_activate_hostname_x11warning="WARNING! Activating the new hostname during an X11-Forwarded\n ssh(1) session will cause an X11 authentication error.\n\n Current Hostname: %s\n New Hostname: %s\n\nNOTE: Settings will become active upon reboot or if you\n relaunch this utility either locally or on the console."
+msg_add="Add"
+msg_add_nameserver="Add a new nameserver"
+msg_bring_interface_up="Would you like to bring the %s interface up right now?"
+msg_cancel="Cancel"
+msg_current_default_router="Current Default Route/Gateway: %s"
+msg_current_dhcp_status="Current DHCP status for %s: %s"
+msg_current_ipaddr="Current IP Address for %s: %s"
+msg_current_options="Current Options for %s: %s"
+msg_current_subnet="Current Subnet Mask for %s: %s"
+msg_custom="Custom (Manual)"
+msg_default_router="Default Router/Gateway"
+msg_dhcp="DHCP"
+msg_disabled="Disabled"
+msg_dns_configuration="DNS Nameserver Configuration:\nChoose Exit when finished else Cancel."
+msg_dns_nameservers="DNS nameservers"
+msg_enabled="Enabled"
+msg_exit="Exit"
+msg_hostname_domain="Hostname/Domain"
+msg_hostname_exceeds_max_length="ERROR! The hostname entered exceeds the maximum length of\n255 characters.\n\nInvalid Hostname: %s"
+msg_hostname_label_contains_invalid_chars="ERROR! One or more individual labels within the hostname\n(separated by dots) contains one or more invalid characters.\nLabels are case-insensitive and must contain only 0-9, a-z,\n or dash (though must not begin with or end with a dash).\n\nInvalid Hostname: %s"
+msg_hostname_label_exceeds_max_length="ERROR! One or more individual labels within the hostname\n(separated by dots) exceeds the maximum of 63 characters.\n\nInvalid Hostname: %s"
+msg_hostname_label_is_null="ERROR! One or more individual labels within the hostname\n(separated by dots) are null.\n\nInvalid Hostname: %s"
+msg_hostname_label_starts_or_ends_with_hyphen="ERROR! One or more individual labels within the hostname\n(separated by dots) starts or ends with a hyphen (hyphens\nare allowed, but a label cannot begin or end with a hyphen).\n\nInvalid Hostname: %s"
+msg_internal_error_nsindex_value="FATAL! dialog_input_nameserver_edit_awk: variable\nnsindex must be a whole positive integer greater-\nthan or equal-to zero.\n\nInvalid nsindex: %s"
+msg_ipaddr4="ipaddr"
+msg_ipv4_addr_octet_contains_invalid_chars="ERROR! One or more individual octets within the IPv4 address\n(separated by dots) contains one or more invalid characters.\nOctets must contain only the characters 0-9.\n\nInvalid IP Address: %s"
+msg_ipv4_addr_octet_exceeds_max_value="ERROR! One or more individual octets within the IPv4 address\n(separated by dots) exceeds the maximum of 255.\n\nInvalid IP Address: %s"
+msg_ipv4_addr_octet_is_null="ERROR! One or more individual octets within the IPv4 address\n(separated by dots) are null and/or missing.\n\nInvalid IP Address: %s"
+msg_ipv4_addr_octet_missing_or_extra="ERROR! The IPv4 address entered has either too few (less than\nfour) or too many (more than four) octets, separated by dots.\n\nInvalid IP Address: %s"
+msg_ipv4_mask_field_contains_invalid_chars="ERROR! One or more individual fields within the subnet mask\n(separated by dots) contains one or more invalid characters.\n\nInvalid Subnet Mask: %s"
+msg_ipv4_mask_field_exceeds_max_value="ERROR! One or more individual fields within the subnet mask\n(separated by dots) exceeds the maximum of 255.\n\nInvalid Subnet Mask: %s"
+msg_ipv4_mask_field_invalid_value="ERROR! One or more individual fields within the subnet mask\n(separated by dots) contains one or more invalid integers.\nFields must be one of 0/128/192/224/240/248/252/254/255.\n\nInvalid Subnet Mask: %s"
+msg_ipv4_mask_field_is_null="ERROR! One or more individual fields within the subnet mask\n(separated by dots) are null and/or missing.\n\nInvalid Subnet Mask: %s"
+msg_ipv4_mask_field_missing_or_extra="ERROR! The subnet mask entered has either too few or too many\nfields.\n\nInvalid Subnet Mask: %s"
+msg_ipv6_addr_segment_contains_invalid_chars="ERROR! One or more individual segments within the IP address\n(separated by colons) contains one or more invalid characters.\nSegments must contain only combinations of the characters 0-9,\nA-F, or a-f.\n\nInvalid IPv6 Address: %s"
+msg_ipv6_addr_segment_contains_too_many_chars="ERROR! One or more individual segments within the IP address\n(separated by colons) exceeds the length of 4 hex-digits.\n\nInvalid IPv6 Address: %s"
+msg_ipv6_addr_too_few_or_extra_segments="ERROR! The IP address entered has either too few (less than 3), too\nmany (more than 8), or not enough segments, separated by colons.\n\nInvalid IPv6 Address: %s"
+msg_ipv6_addr_too_many_null_segments="ERROR! Too many/incorrect null segments. A single null\nsegment is allowed within the IP address (separated by\ncolons) but not allowed at the beginning or end (unless\na double-null segment; i.e., \"::*\" or \"*::\").\n\nInvalid IPv6 Address: %s"
+msg_netmask="netmask"
+msg_network_configuration="%s Network Configuration:\nChoose Save/Exit when finished or Cancel."
+msg_network_interfaces="Network Interfaces"
+msg_network_management="Network Management"
+msg_networking_devices="Networking Devices"
+msg_nfs_mounts_may_cause_hang="WARNING! Changing this setting while NFS directories are\nmounted may cause the system to hang. Are you sure you\nwant to proceed?\n\n%s"
+msg_no_network_interfaces="No network interfaces detected."
+msg_no_options="No options (Default)"
+msg_ok="OK"
+msg_options="options"
+msg_please_enter_default_router="Please enter the IP address of your default\nrouter/gateway. The address entered will be\napplied as the default gateway for all interfaces\nusing route(4)."
+msg_please_enter_fqhn="Please enter your fully qualified hostname (e.g. full.example.com). The\ndomain portion of the hostname will be configured in resolv.conf(5)."
+msg_please_enter_mediaopts="Please enter additional network media options to be passed to ifconfig(8) for the %s interface:"
+msg_please_enter_nameserver="Please enter the new IP address of the DNS nameserver:"
+msg_please_enter_nameserver_existing="Please enter the new IP address of the DNS nameserver\n(set to the NULL string [Ctrl-U] to remove entry):"
+msg_please_enter_new_ip_addr="Please enter the new IP address of the %s interface:"
+msg_please_enter_subnet_mask="Please enter the new network subnet mask for the %s interface:"
+msg_probing_network_interfaces="Probing network interface devices..."
+msg_removing_nameserver="Removing DNS nameserver from resolv.conf(5)..."
+msg_resolv_conf_changed_while_editing="ERROR! resolv.conf(5) has changed while editing this\nvalue. Please try again after waiting a few seconds."
+msg_resolv_conf_entry_no_longer_exists="ERROR! The entry you are trying to edit no longer\nexists in resolv.conf(5). Please try again after\nwaiting a few seconds."
+msg_return_to_previous_menu="Return to previous menu"
+msg_save_exit="Save/Exit"
+msg_saving_default_router="Saving new default router/gateway settings..."
+msg_saving_hostname="Saving new hostname/domain settings..."
+msg_saving_nameserver="Saving new DNS nameserver to resolv.conf(5)..."
+msg_saving_nameserver_existing="Editing DNS nameserver in resolv.conf(5)..."
+msg_saving_network_interface="Saving %s network interface settings..."
+msg_scanning_for_dhcp="Scanning for DHCP servers on %s interface..."
+msg_select_network_interface="Select a network interface to configure.\n\n* Interface is marked as \"active\""
+msg_supported_media_options="Below is a list of supported media options for the %s interface. Please select the options that you would like to set for the %s network interface"
+msg_unknown_networking_menu_selection="Unknown networking menu selection"
+xmsg_please_enter_fqhn="Please enter your fully qualified hostname (e.g. foo.bar.com).\n The domain portion of the hostname will be configured in resolv.conf(5)."
+xmsg_please_enter_nameserver_existing="Please enter the new IP address of the DNS nameserver\n(set to the NULL string to remove entry):"
+xmsg_supported_media_options="Below is a list of supported media options for the %s interface. Please\nselect the options that you would like to set for the %s network interface"
diff --git a/usr.sbin/bsdconfig/networking/nameservers b/usr.sbin/bsdconfig/networking/nameservers
new file mode 100755
index 0000000..e18f004
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/nameservers
@@ -0,0 +1,76 @@
+#!/bin/sh
+#-
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+# Prevent device.subr (included indirectly) from auto scanning on load
+DEVICE_SELF_SCAN_ALL=NO
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/networking/resolv.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts h$GETOPTS_STDARGS flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_title "$msg_dns_nameservers"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Change the DNS nameservers
+#
+f_dialog_menu_nameservers
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/networking/networking b/usr.sbin/bsdconfig/networking/networking
new file mode 100755
index 0000000..c61ce8f
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/networking
@@ -0,0 +1,151 @@
+#!/bin/sh
+#-
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local prompt=
+ local menu_list="
+ 'X' '$msg_exit'
+ '1' '$msg_hostname_domain'
+ '2' '$msg_network_interfaces'
+ '3' '$msg_default_router'
+ '4' '$msg_dns_nameservers'
+ " # END-QUOTE
+ local defaultitem= # Calculated below
+ local hline="$hline_arrows_tab_enter"
+
+ local height width rows
+ eval f_dialog_menu_size height width rows \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list
+
+ # Obtain default-item from previously stored selection
+ f_dialog_default_fetch defaultitem
+
+ local menu_choice
+ menu_choice=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --default-item \"\$defaultitem\" \
+ --menu \"\$prompt\" \
+ $height $width $rows \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ f_dialog_data_sanitize menu_choice
+ f_dialog_menutag_store "$menu_choice"
+ f_dialog_default_store "$menu_choice"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts h$GETOPTS_STDARGS flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_title "$msg_network_management"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main || f_die
+ f_dialog_menutag_fetch mtag
+
+ command=
+ case "$mtag" in
+ X) break ;;
+ 1) command=hostname ;; # Hostname/Domain
+ 2) command=devices ;; # Network Interfaces
+ 3) command=defaultrouter ;; # Default Router/Gateway
+ 4) command=nameservers ;; # DNS nameservers
+ esac
+
+ if [ "$command" ]; then
+ $BSDCFG_LIBE/$APP_DIR/$command ${USE_XDIALOG:+-X}
+ else
+ f_die 1 "$msg_unknown_networking_menu_selection"
+ fi
+
+ if [ "$mtag" = "devices" ]; then
+ #
+ # Make subsequent uses of this menu faster by not performing
+ # "ifconfig up" (limiting the pain one must endure). See also
+ # `$BSDCFG_SHARE/networking/device.subr'.
+ #
+ export DIALOG_MENU_NETDEV_KICK_INTERFACES=
+ fi
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/networking/share/Makefile b/usr.sbin/bsdconfig/networking/share/Makefile
new file mode 100644
index 0000000..6d77f25
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+FILESDIR= ${SHAREDIR}/bsdconfig/networking
+FILES= common.subr device.subr hostname.subr ipaddr.subr media.subr \
+ netmask.subr resolv.subr routing.subr services.subr
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/networking/share/Makefile.depend b/usr.sbin/bsdconfig/networking/share/Makefile.depend
new file mode 100644
index 0000000..f80275d
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/Makefile.depend
@@ -0,0 +1,11 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bsdconfig/networking/share/common.subr b/usr.sbin/bsdconfig/networking/share/common.subr
new file mode 100644
index 0000000..152d1ac
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/common.subr
@@ -0,0 +1,58 @@
+if [ ! "$_NETWORKING_COMMON_SUBR" ]; then _NETWORKING_COMMON_SUBR=1
+#
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+
+############################################################ FUNCTIONS
+
+# f_jailed
+#
+# Returns true if the current process is jail(8)ed.
+#
+f_jailed()
+{
+ ! f_quietly ps 1
+}
+
+# f_nfs_mounted
+#
+# Returns true if there are any NFS mounts currently active, otherwise false.
+#
+f_nfs_mounted()
+{
+ [ "$( df -t nfs )" ]
+}
+
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/common.subr
+
+fi # ! $_NETWORKING_COMMON_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/device.subr b/usr.sbin/bsdconfig/networking/share/device.subr
new file mode 100644
index 0000000..14758e6
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/device.subr
@@ -0,0 +1,385 @@
+if [ ! "$_NETWORKING_DEVICE_SUBR" ]; then _NETWORKING_DEVICE_SUBR=1
+#
+# Copyright (c) 2006-2015 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/device.subr
+f_include $BSDCFG_SHARE/device.subr
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/media/tcpip.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+f_include $BSDCFG_SHARE/networking/ipaddr.subr
+f_include $BSDCFG_SHARE/networking/media.subr
+f_include $BSDCFG_SHARE/networking/netmask.subr
+f_include $BSDCFG_SHARE/networking/resolv.subr
+f_include $BSDCFG_SHARE/networking/routing.subr
+f_include $BSDCFG_SHARE/strings.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ GLOBALS
+
+#
+# Settings used while interacting with various dialog(1) menus
+#
+: ${DIALOG_MENU_NETDEV_KICK_INTERFACES=1}
+: ${DIALOG_MENU_NETDEV_SLEEP_AFTER_KICK=3}
+
+############################################################ FUNCTIONS
+
+# f_dialog_menu_netdev [$default]
+#
+# Display a list of network devices with descriptions. Optionally, if present
+# and non-NULL, initially highlight $default interface.
+#
+f_dialog_menu_netdev()
+{
+ local menu_list # Calculated below
+ local defaultitem="${1%\*}" # Trim trailing asterisk if present
+
+ #
+ # Display a message to let the user know we're working...
+ # (message will remain until we throw up the next dialog)
+ #
+ f_dialog_info "$msg_probing_network_interfaces"
+
+ #
+ # Get list of usable network interfaces
+ #
+ local dev devs if iflist= # Calculated below
+ f_device_rescan_network
+ f_device_find "" $DEVICE_TYPE_NETWORK devs
+ for dev in $devs; do
+ f_struct "$dev" get name if || continue
+ # Skip unsavory interfaces
+ case "$if" in
+ lo[0-9]*|ppp[0-9]*|sl[0-9]*) continue ;;
+ esac
+ iflist="$iflist $if"
+ done
+ iflist="${iflist# }"
+
+ #
+ # Optionally kick interfaces in the head to get them to accurately
+ # track the carrier status in realtime (required on FreeBSD).
+ #
+ if [ "$DIALOG_MENU_NETDEV_KICK_INTERFACES" ]; then
+ DIALOG_MENU_NETDEV_KICK_INTERFACES=
+
+ for if in $iflist; do
+ f_quietly ifconfig $if up
+ done
+
+ if [ "$DIALOG_MENU_NETDEV_SLEEP_AFTER_KICK" ]; then
+ # interfaces need time to update carrier status
+ sleep $DIALOG_MENU_NETDEV_SLEEP_AFTER_KICK
+ fi
+ fi
+
+ #
+ # Mark any "active" interfaces with an asterisk (*)
+ # to the right of the device name.
+ #
+ menu_list=$(
+ for if in $iflist; do
+ f_device_desc $if $DEVICE_TYPE_NETWORK desc
+ f_shell_escape "$desc" desc
+ if f_device_is_active $if; then
+ printf "'%s\*' '%s'\n" $if "$desc"
+ else
+ printf "'%s' '%s'\n" $if "$desc"
+ fi
+ done
+ )
+ if [ ! "$menu_list" ]; then
+ f_show_msg "$msg_no_network_interfaces"
+ return $DIALOG_CANCEL
+ fi
+
+ # Maybe the default item was marked as active
+ f_device_is_active "$defaultitem" && defaultitem="$defaultitem*"
+
+ #
+ # Ask user to select an interface
+ #
+ local prompt="$msg_select_network_interface"
+ local hline="$hline_arrows_tab_enter"
+ local height width rows
+ eval f_dialog_menu_size height width rows \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list
+ local menu_choice
+ menu_choice=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --default-item \"\$defaultitem\" \
+ --menu \"\$prompt\" \
+ $height $width $rows \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ f_dialog_menutag_store -s "$menu_choice"
+ return $retval
+}
+
+# f_dialog_menu_netdev_edit $interface $ipaddr $netmask $options $dhcp
+#
+# Allow a user to edit network interface settings. Current values are not
+# probed but rather taken from the positional arguments.
+#
+f_dialog_menu_netdev_edit()
+{
+ local funcname=f_dialog_menu_netdev_edit
+ local interface="$1" ipaddr="$2" netmask="$3" options="$4" dhcp="$5"
+ local prompt menu_list height width rows
+
+ #
+ # Create a duplicate set of variables for change-tracking...
+ #
+ local ipaddr_orig="$2" \
+ netmask_orig="$3" \
+ options_orig="$4" \
+ dhcp_orig="$5"
+
+ local hline="$hline_arrows_tab_enter"
+ f_sprintf prompt "$msg_network_configuration" "$interface"
+
+ #
+ # Loop forever until the user has finished configuring the different
+ # components of the network interface.
+ #
+ # To apply the settings, we need to know each of the following:
+ # - IP Address
+ # - Network subnet mask
+ # - Additional ifconfig(8) options
+ #
+ # It is only when we have all of the above values that we can make the
+ # changes effective because all three options must be specified at-once
+ # to ifconfig(8).
+ #
+ local defaultitem=
+ while :; do
+ local dhcp_status="$msg_disabled"
+ [ "$dhcp" ] && dhcp_status="$msg_enabled"
+
+ #
+ # Display configuration-edit menu
+ #
+ menu_list="
+ 'X $msg_save_exit' '$msg_return_to_previous_menu'
+ '2 $msg_dhcp' '$dhcp_status'
+ '3 $msg_ipaddr4' '$ipaddr'
+ '4 $msg_netmask' '$netmask'
+ '5 $msg_options' '$options'
+ " # END-QUOTE
+ eval f_dialog_menu_size height width rows \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list
+ local tag
+ tag=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --help-button \
+ --help-label \"\$msg_help\" \
+ ${USE_XDIALOG:+--help \"\"} \
+ --default-item \"\$defaultitem\" \
+ --menu \"\$prompt\" \
+ $height $width $rows \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ f_dialog_data_sanitize tag
+
+ if [ $retval -eq $DIALOG_HELP ]; then
+ f_show_help "$TCP_HELPFILE"
+ continue
+ elif [ $retval -ne $DIALOG_OK ]; then
+ return $retval
+ else
+ # Only update default-item on success
+ defaultitem="$tag"
+ fi
+
+ #
+ # Call the below ``modifier functions'' whose job it is to take
+ # input from the user and assign the newly-acquired values back
+ # to the ipaddr, netmask, and options variables for us to re-
+ # read and display in the summary dialog.
+ #
+ case "$tag" in
+ X\ *) break ;;
+ 2\ *) #
+ # Proceed cautiously (confirm with the user) if/when NFS-
+ # mounts are active. If the network on which these mounts
+ # are made is changed parts of the system may hang.
+ #
+ if f_nfs_mounted && ! f_jailed; then
+ local setting
+ f_sprintf setting "$msg_current_dhcp_status" \
+ "$interface" "$dhcp_status"
+ f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
+ continue
+ fi
+
+ #
+ # Toggle DHCP status
+ #
+ if [ "$dhcp_status" = "$msg_enabled" ]; then
+ dhcp=
+ else
+ trap - SIGINT
+ ( # Execute within sub-shell to allow/catch Ctrl-C
+ trap 'exit $FAILURE' SIGINT
+ f_sprintf msg "$msg_scanning_for_dhcp" "$interface"
+ if [ "$USE_XDIALOG" ]; then
+ (
+ f_quietly ifconfig "$interface" delete
+ f_quietly dhclient "$interface"
+ ) |
+ f_xdialog_info "$msg"
+ else
+ f_dialog_info "$msg"
+ f_quietly ifconfig "$interface" delete
+ f_quietly dhclient "$interface"
+ fi
+ )
+ retval=$?
+ trap 'interrupt' SIGINT
+ if [ $retval -eq $DIALOG_OK ]; then
+ dhcp=1
+ f_ifconfig_inet "$interface" ipaddr
+ f_ifconfig_inet6 "$interface" ipaddr6
+ f_ifconfig_netmask "$interface" netmask
+ options=
+
+ # Fixup search/domain in resolv.conf(5)
+ hostname=$( f_sysrc_get \
+ 'hostname:-$(hostname)' )
+ f_dialog_resolv_conf_update "$hostname"
+ fi
+ fi
+ ;;
+ 3\ *) f_dialog_input_ipaddr "$interface" "$ipaddr"
+ [ $? -eq $DIALOG_OK ] && dhcp= ;;
+ 4\ *) f_dialog_input_netmask "$interface" "$netmask"
+ [ $? -eq $DIALOG_OK -a "$_netmask" ] && dhcp= ;;
+ 5\ *) f_dialog_menu_media_options "$interface" "$options"
+ [ $? -eq $DIALOG_OK ] && dhcp= ;;
+ esac
+ done
+
+ #
+ # Save only if the user changed at least one feature of the interface
+ #
+ if [ "$ipaddr" != "$ipaddr_orig" -o \
+ "$netmask" != "$netmask_orig" -o \
+ "$options" != "$options_orig" -o \
+ "$dhcp" != "$dhcp_orig" ]
+ then
+ f_show_info "$msg_saving_network_interface" "$interface"
+
+ local value=
+ if [ "$dhcp" ]; then
+ f_eval_catch $funcname f_sysrc_delete \
+ 'f_sysrc_delete defaultrouter'
+ value=DHCP
+ else
+ value="inet $ipaddr netmask $netmask"
+ value="$value${options:+ }$options"
+ fi
+
+ f_eval_catch $funcname f_sysrc_set \
+ 'f_sysrc_set "ifconfig_%s" "%s"' "$interface" "$value"
+ fi
+
+ #
+ # Re/Apply the settings if desired
+ #
+ if [ ! "$dhcp" ]; then
+ if f_yesno "$msg_bring_interface_up" "$interface"
+ then
+ f_show_info "$msg_bring_interface_up" "$interface"
+
+ local dr="$( f_sysrc_get defaultrouter )"
+ if [ "$dr" = "NO" -o ! "$dr" ]; then
+ f_route_get_default dr
+ [ "$dr" ] && f_eval_catch \
+ $funcname f_sysrc_set \
+ 'f_sysrc_set defaultrouter "%s"' "$dr"
+ fi
+ #
+ # Make a backup of resolv.conf(5) before using
+ # ifconfig(8) and then restore it afterward. This
+ # allows preservation of nameservers acquired via
+ # DHCP on FreeBSD-8.x (normally lost as ifconfig(8)
+ # usage causes dhclient(8) to exit which scrubs
+ # resolv.conf(5) by-default upon termination).
+ #
+ f_quietly cp -fp "$RESOLV_CONF" "$RESOLV_CONF.$$"
+ if f_eval_catch $funcname ifconfig \
+ 'ifconfig "%s" inet "%s" netmask "%s" %s' \
+ "$interface" "$ipaddr" "$netmask" "$options"
+ then
+ [ "$dr" -a "$dr" != "NO" ] &&
+ f_eval_catch $funcname route \
+ 'route add default "%s"' "$dr"
+ fi
+ if cmp -s "$RESOLV_CONF" "$RESOLV_CONF.$$"; then
+ f_quietly rm -f "$RESOLV_CONF.$$"
+ else
+ f_quietly mv -f "$RESOLV_CONF.$$" "$RESOLV_CONF"
+ fi
+ fi
+ fi
+
+ return $DIALOG_OK
+}
+
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/device.subr
+
+fi # ! $_NETWORKING_DEVICE_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/hostname.subr b/usr.sbin/bsdconfig/networking/share/hostname.subr
new file mode 100644
index 0000000..1c3a67b
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/hostname.subr
@@ -0,0 +1,162 @@
+if [ ! "$_NETWORKING_HOSTNAME_SUBR" ]; then _NETWORKING_HOSTNAME_SUBR=1
+#
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/hostname.subr
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+f_include $BSDCFG_SHARE/networking/resolv.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# f_dialog_hnerror $error $hostname
+#
+# Display a msgbox with the appropriate error message for an error returned by
+# the f_validate_hostname function.
+#
+f_dialog_hnerror()
+{
+ local error="$1" fqhn="$2"
+
+ [ ${error:-0} -ne 0 ] || return $SUCCESS
+
+ case "$error" in
+ 1) f_show_msg "$msg_hostname_label_contains_invalid_chars" "$fqhn" ;;
+ 2) f_show_msg \
+ "$msg_hostname_label_starts_or_ends_with_hyphen" "$fqhn" ;;
+ 3) f_show_msg "$msg_hostname_label_is_null" "$fqhn" ;;
+ 63) f_show_msg "$msg_hostname_label_exceeds_max_length" "$fqhn" ;;
+ 255) f_show_msg "$msg_hostname_exceeds_max_length" "$fqhn" ;;
+ esac
+}
+
+# f_dialog_validate_hostname $hostname
+#
+# Returns zero if the given argument (a fully-qualified hostname) is compliant
+# with standards set-forth in RFC's 952 and 1123 of the Network Working Group:
+#
+# RFC 952 - DoD Internet host table specification
+# http://tools.ietf.org/html/rfc952
+#
+# RFC 1123 - Requirements for Internet Hosts - Application and Support
+# http://tools.ietf.org/html/rfc1123
+#
+# If the hostname is determined to be invalid, the appropriate error will be
+# displayed using the f_dialog_hnerror function above.
+#
+f_dialog_validate_hostname()
+{
+ local fqhn="$1"
+
+ f_validate_hostname "$fqhn"
+ local retval=$?
+
+ # Produce an appropriate error message if necessary.
+ [ $retval -eq $SUCCESS ] || f_dialog_hnerror $retval "$fqhn"
+
+ return $retval
+}
+
+# f_dialog_input_hostname
+#
+# Edits the current hostname.
+#
+f_dialog_input_hostname()
+{
+ local funcname=f_dialog_input_hostname
+ local hostname="$( f_sysrc_get 'hostname:-$(hostname)' )"
+ local hostname_orig="$hostname" # for change-tracking
+
+ local msg
+ if [ "$USE_XDIALOG" ]; then
+ msg="$xmsg_please_enter_fqhn"
+ else
+ msg="$msg_please_enter_fqhn"
+ fi
+
+ #
+ # Loop until the user provides taint-free input.
+ #
+ while :; do
+ 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
+
+ #
+ # Save hostname only if the user changed the hostname.
+ #
+ if [ "$hostname" != "$hostname_orig" ]; then
+ f_dialog_info "$msg_saving_hostname"
+ f_eval_catch $funcname f_sysrc_set \
+ 'f_sysrc_set hostname "%s"' "$hostname"
+ fi
+
+ #
+ # Update resolv.conf(5) search/domain directives
+ #
+ f_dialog_resolv_conf_update "$hostname"
+
+ #
+ # Only ask to apply setting if the current hostname is different than
+ # the stored configuration (in rc.conf(5)).
+ #
+ if [ "$( hostname )" != "$( f_sysrc_get hostname )" ]; then
+ [ ! "$USE_XDIALOG" ] && f_dialog_clear
+
+ #
+ # If connected via ssh(1) and performing X11-Forwarding, don't
+ # allow the hostname to be changed to prevent the fatal error
+ # "X11 connection rejected because of wrong authentication."
+ #
+ if [ "$USE_XDIALOG" -a "$SSH_CONNECTION" ]; then
+ f_show_msg "$msg_activate_hostname_x11warning" \
+ "$( hostname )" "$hostname"
+ else
+ f_yesno "$msg_activate_hostname" \
+ "$( hostname )" "$hostname" \
+ && hostname "$hostname"
+ fi
+ fi
+
+ return $DIALOG_OK
+}
+
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/hostname.subr
+
+fi # ! $_NETWORKING_HOSTNAME_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/ipaddr.subr b/usr.sbin/bsdconfig/networking/share/ipaddr.subr
new file mode 100644
index 0000000..b7624cc
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/ipaddr.subr
@@ -0,0 +1,219 @@
+if [ ! "$_NETWORKING_IPADDR_SUBR" ]; then _NETWORKING_IPADDR_SUBR=1
+#
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/ipaddr.subr
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+f_include $BSDCFG_SHARE/strings.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# f_dialog_iperror $error $ipaddr
+#
+# Display a msgbox with the appropriate error message for an error returned by
+# the f_validate_ipaddr function.
+#
+f_dialog_iperror()
+{
+ local error="$1" ip="$2"
+
+ [ ${error:-0} -ne 0 ] || return $SUCCESS
+
+ case "$error" in
+ 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
+}
+
+# f_dialog_validate_ipaddr $ipaddr
+#
+# Returns zero if the given argument (an IP address) is of the proper format.
+#
+# If the IP address is determined to be invalid, the appropriate error will be
+# displayed using the f_dialog_iperror function above.
+#
+f_dialog_validate_ipaddr()
+{
+ local ip="$1"
+
+ f_validate_ipaddr "$ip"
+ local retval=$?
+
+ # Produce an appropriate error message if necessary.
+ [ $retval -eq $SUCCESS ] || f_dialog_iperror $retval "$ip"
+
+ return $retval
+}
+
+# f_dialog_ip6error $error $ipv6_addr
+#
+# Display a msgbox with the appropriate error message for an error returned by
+# the f_validate_ipaddr6 function above.
+#
+f_dialog_ip6error()
+{
+ local error="$1" ip="$2"
+
+ [ ${error:-0} -ne 0 ] || return $SUCCESS
+
+ case "$error" in
+ 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
+ f_dialog_iperror $(( $error >> 4 )) "$ip"
+ fi
+ esac
+}
+
+# f_dialog_validate_ipaddr6 $ipv6_addr
+#
+# Returns zero if the given argument (an IPv6 address) is of the proper format.
+#
+# If the IP address is determined to be invalid, the appropriate error will be
+# displayed using the f_dialog_ip6error function above.
+#
+f_dialog_validate_ipaddr6()
+{
+ local ip="$1"
+
+ f_validate_ipaddr6 "$ip"
+ local retval=$?
+
+ # Produce an appropriate error message if necessary.
+ [ $retval -eq $SUCCESS ] || f_dialog_ip6error $retval "$ip"
+
+ return $retval
+}
+
+# f_dialog_input_ipaddr $interface $ipaddr
+#
+# Allows the user to edit a given IP address. If the user does not cancel or
+# press ESC, the $ipaddr environment variable will hold the newly-configured
+# value upon return.
+#
+# Optionally, the user can enter the format "IP_ADDRESS/NBITS" to set the
+# netmask at the same time as the IP address. If such a format is entered by
+# the user, the $netmask environment variable will hold the newly-configured
+# netmask upon return.
+#
+f_dialog_input_ipaddr()
+{
+ local interface="$1" _ipaddr="$2" _input
+
+ #
+ # Return with-error when there are NFS-mounts currently active. If the
+ # IP address is changed while NFS-exported directories are mounted, the
+ # system may hang (if any NFS mounts are using that interface).
+ #
+ if f_nfs_mounted && ! f_jailed; then
+ local setting
+ f_sprintf setting "$msg_current_ipaddr" "$interface" "$_ipaddr"
+ f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
+ return $DIALOG_CANCEL
+ fi
+
+ local msg
+ f_sprintf msg "$msg_please_enter_new_ip_addr" "$interface"
+
+ #
+ # Loop until the user provides taint-free input.
+ #
+ local retval
+ while :; do
+ #
+ # Return error status if:
+ # - User has either pressed ESC or chosen Cancel/No
+ # - User has not made any changes to the given value
+ #
+ f_dialog_input _input "$msg" "$_ipaddr" \
+ "$hline_num_punc_tab_enter" || return $?
+ [ "$_ipaddr" = "$_input" ] && return $DIALOG_CANCEL
+
+ # Return success if NULL value was entered
+ [ "$_input" ] || return $DIALOG_OK
+
+ # Take only the first "word" of the user's input
+ _ipaddr="$_input"
+ _ipaddr="${_ipaddr%%[$IFS]*}"
+
+ # Taint-check the user's input
+ f_dialog_validate_ipaddr "${_ipaddr%%/*}" && break
+ done
+
+ #
+ # Support the syntax: IP_ADDRESS/NBITS
+ #
+ local _netmask=""
+ case "$_ipaddr" in
+ */*)
+ local nbits="${_ipaddr#*/}" n=0
+ _ipaddr="${_ipaddr%%/*}"
+
+ #
+ # Taint-check $nbits to be (a) a positive whole-integer,
+ # and (b) to be less than or equal to 32. Otherwise, set
+ # $n so that the below loop never executes.
+ #
+ ( f_isinteger "$nbits" && [ $nbits -ge 0 -a $nbits -le 32 ] ) \
+ || n=4
+
+ while [ $n -lt 4 ]; do
+ _netmask="$_netmask${_netmask:+.}$((
+ (65280 >> ($nbits - 8 * $n) & 255)
+ * ((8*$n) < $nbits & $nbits <= (8*($n+1)))
+ + 255 * ($nbits > (8*($n+1)))
+ ))"
+ n=$(( $n + 1 ))
+ done
+ ;;
+ esac
+
+ ipaddr="$_ipaddr"
+ [ "$_netmask" ] && netmask="$_netmask"
+
+ return $DIALOG_OK
+}
+
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/ipaddr.subr
+
+fi # ! $_NETWORKING_IPADDR_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/media.subr b/usr.sbin/bsdconfig/networking/share/media.subr
new file mode 100644
index 0000000..1cb77f8
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/media.subr
@@ -0,0 +1,247 @@
+if [ ! "$_NETWORKING_MEDIA_SUBR" ]; then _NETWORKING_MEDIA_SUBR=1
+#
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/media.subr
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+f_include $BSDCFG_SHARE/strings.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# f_ifconfig_options $interface
+#
+# Returns any/all extra ifconfig(8) parameters associated with $interface.
+#
+f_ifconfig_options()
+{
+ local interface="$1"
+ [ "$interface" ] || return $SUCCESS
+
+ #
+ # Loop over the options, removing what we don't want
+ #
+ (
+ set -- $( f_sysrc_get ifconfig_$interface )
+
+ #
+ # Return if the interface is configured for DHCP
+ #
+ glob="[Dd][Hh][Cc][Pp]"
+ case "$*" in
+ $glob|[Ss][Yy][Nn][Cc]$glob|[Nn][Oo][Ss][Yy][Nn][Cc]$glob)
+ exit $SUCCESS
+ esac
+
+ output=
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ inet|netmask) shift 1 ;;
+ *) output="$output${output:+ }$1"
+ esac
+ shift 1
+ done
+ echo "$output"
+ )
+}
+
+# f_ifconfig_media $interface
+#
+# Returns list of supported media for $interface.
+#
+f_ifconfig_media()
+{
+ local interface="$1"
+ ifconfig -m "$interface" 2> /dev/null | awk \
+ '
+ BEGIN { media_found = 0 }
+ {
+ if ( media_found == 1 ) { print; next }
+ }
+ ( $1 $2 == "supported" "media:" ) \
+ {
+ media_found = 1
+ next
+ }
+ END { exit ! media_found }
+ '
+}
+
+# f_dialog_input_options $interface
+#
+# Input custom interface options. If the user does not press ESC or choose
+# Cancel/No, $options will hold the user's input. Default input is taken from
+# the same variable ($options).
+#
+f_dialog_input_options()
+{
+ local interface="$1"
+
+ #
+ # Return with-error when there are NFS-mounts currently active. If the
+ # options are changed while NFS-exported directories are mounted,
+ # the system may hang (if any NFS mounts are using that interface).
+ #
+ if f_nfs_mounted && ! f_jailed; then
+ local setting
+ f_sprintf setting "$msg_current_options" \
+ "$interface" "$options"
+ f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
+ return $DIALOG_CANCEL
+ fi
+
+ local msg
+ f_sprintf msg "$msg_please_enter_mediaopts" "$interface"
+ local hline="$hline_alnum_punc_tab_enter"
+
+ local _options
+ _options=$( $DIALOG \
+ --title "$DIALOG_TITLE" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --hline "$hline" \
+ --ok-label "$msg_ok" \
+ --cancel-label "$msg_cancel" \
+ --inputbox "$msg" 9 70 \
+ "$options" \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ f_dialog_line_sanitize _options
+
+ [ $retval -eq $DIALOG_OK ] && options="$_options"
+
+ return $retval
+}
+
+# f_dialog_menu_media_options $interface
+#
+# Display a menu of additional media options for the given network interface.
+#
+f_dialog_menu_media_options()
+{
+ local interface="$1" _options="$2"
+ #
+ # Not all network interfaces support additional media options, but
+ # when available we should prompt the user to select from a list
+ # of available options (or none, as is the first/default option).
+ #
+
+ #
+ # Return with-error when there are NFS-mounts currently active. If the
+ # media options are changed while NFS-exported directories are mounted,
+ # the system may hang (if any NFS mounts are using that interface).
+ #
+ if f_nfs_mounted && ! f_jailed; then
+ local setting
+ f_sprintf setting "$msg_current_options" \
+ "$interface" "$_options"
+ f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
+ return $DIALOG_CANCEL
+ fi
+
+ #
+ # Build list of additional media options
+ #
+ local opt_none="$msg_no_options"
+ local opt_cust="$msg_custom"
+ local supported_media="$(
+ f_ifconfig_media $interface | \
+ ( index=1
+
+ echo "'$( f_substr "$DIALOG_MENU_TAGS" $index 1 )'"
+ echo "'$opt_none'"
+ index=$(( $index + 1 ))
+
+ echo "'$( f_substr "$DIALOG_MENU_TAGS" $index 1 )'"
+ echo "'$opt_cust'"
+ index=$(( $index + 1 ))
+
+ while read media_options; do
+ [ $index -lt ${#DIALOG_MENU_TAGS} ] || break
+ echo "'$( f_substr "$DIALOG_MENU_TAGS" $index 1 )'"
+ echo "'$media_options'"
+ index=$(( $index + 1 ))
+ done
+ )
+ )"
+
+ local msg
+ if [ "$USE_XDIALOG" ]; then
+ f_sprintf msg "$xmsg_supported_media_options" \
+ "$interface" "$interface"
+ else
+ f_sprintf msg "$msg_supported_media_options" \
+ "$interface" "$interface"
+ fi
+
+ local hline="$hline_arrows_tab_enter"
+
+ local tag
+ tag=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$msg\" 21 60 12 \
+ $supported_media \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ f_dialog_data_sanitize tag
+
+ if [ $retval -eq $DIALOG_OK ]; then
+ options=$( eval f_dialog_menutag2item \"\$tag\" \
+ $supported_media )
+ case "$options" in
+ "$opt_none")
+ options=
+ ;;
+ "$opt_cust")
+ options="$_options"
+ f_dialog_input_options "$interface"
+ retval=$?
+ ;;
+ esac
+ fi
+
+ return $retval
+}
+
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/media.subr
+
+fi # ! $_NETWORKING_MEDIA_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/netmask.subr b/usr.sbin/bsdconfig/networking/share/netmask.subr
new file mode 100644
index 0000000..a7d44a5
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/netmask.subr
@@ -0,0 +1,137 @@
+if [ ! "$_NETWORKING_NETMASK_SUBR" ]; then _NETWORKING_NETMASK_SUBR=1
+#
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/netmask.subr
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+f_include $BSDCFG_SHARE/strings.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# f_dialog_maskerror $error $netmask
+#
+# Display a msgbox with the appropriate error message for an error returned by
+# the f_validate_netmask function.
+#
+f_dialog_maskerror()
+{
+ local error="$1" netmask="$2"
+
+ [ ${error:-0} -ne 0 ] || return $SUCCESS
+
+ case "$error" in
+ 1) f_show_msg "$msg_ipv4_mask_field_contains_invalid_chars" "$mask" ;;
+ 2) f_show_msg "$msg_ipv4_mask_field_is_null" "$mask" ;;
+ 3) f_show_msg "$msg_ipv4_mask_field_exceeds_max_value" "$mask" ;;
+ 4) f_show_msg "$msg_ipv4_mask_field_missing_or_extra" "$mask" ;;
+ 5) f_show_msg "$msg_ipv4_mask_field_invalid_value" "$mask" ;;
+ esac
+}
+
+# f_dialog_validate_netmask $netmask
+#
+# Returns zero if the given argument (a subnet mask) is of the proper format.
+#
+# If the subnet mask is determined to be invalid, the appropriate error will be
+# displayed using the f_dialog_maskerror function above.
+#
+f_dialog_validate_netmask()
+{
+ local netmask="$1"
+
+ f_validate_netmask "$netmask"
+ local retval=$?
+
+ # Produce an appropriate error message if necessary.
+ [ $retval -eq $SUCCESS ] || f_dialog_maskerror $retval "$netmask"
+
+ return $retval
+}
+
+# f_dialog_input_netmask $interface $netmask
+#
+# Edits the IP netmask of the given interface.
+#
+f_dialog_input_netmask()
+{
+ local interface="$1" _netmask="$2" _input
+
+ #
+ # Return with-error when there are NFS-mounts currently active. If the
+ # subnet mask is changed while NFS-exported directories are mounted,
+ # the system may hang (if any NFS mounts are using that interface).
+ #
+ if f_nfs_mounted && ! f_jailed; then
+ local setting
+ f_sprintf setting "$msg_current_subnet" \
+ "$interface" "$_netmask"
+ f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
+ return $DIALOG_CANCEL
+ fi
+
+ #
+ # Loop until the user provides taint-free input.
+ #
+ local msg
+ f_sprintf msg "$msg_please_enter_subnet_mask" "$interface"
+ while :; do
+ #
+ # Return error status if:
+ # - User has either pressed ESC or chosen Cancel/No
+ # - User has not made any changes to the given value
+ #
+ f_dialog_input _input "$msg" "$_netmask" \
+ "$hline_num_punc_tab_enter" || return $?
+ [ "$_netmask" = "$_input" ] && return $DIALOG_CANCEL
+
+ # Return success if NULL value was entered
+ [ "$_input" ] || return $DIALOG_OK
+
+ # Take only the first "word" of the user's input
+ _netmask="$_input"
+ _netmask="${_netmask%%[$IFS]*}"
+
+ # Taint-check the user's input
+ f_dialog_validate_netmask "$_netmask" && break
+ done
+
+ netmask="$_netmask"
+}
+
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/netmask.subr
+
+fi # ! $_NETWORKING_NETMASK_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/resolv.subr b/usr.sbin/bsdconfig/networking/share/resolv.subr
new file mode 100644
index 0000000..fc42e12
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/resolv.subr
@@ -0,0 +1,502 @@
+if [ ! "$_NETWORKING_RESOLV_SUBR" ]; then _NETWORKING_RESOLV_SUBR=1
+#
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/resolv.subr
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/media/tcpip.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+f_include $BSDCFG_SHARE/networking/ipaddr.subr
+f_include $BSDCFG_SHARE/strings.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ CONFIGURATION
+
+#
+# When updating resolv.conf(5), should we populate the `search' directive with
+# all possible sub-domains? In example, if the domain is "sub.domain.com", when
+# the below option is set to 1, include both "sub.domain.com" and "domain.com"
+# in the `search' directive, otherwise use only "sub.domain.com".
+#
+# When enabled (set to 1), specify the minimum number of dots required for each
+# `search' domain by setting the second option below, `RESOLVER_SEARCH_NDOTS'.
+#
+: ${RESOLVER_SEARCH_DOMAINS_ALL:=1}
+: ${RESOLVER_SEARCH_NDOTS:=1}
+
+############################################################ FUNCTIONS
+
+# f_resolv_conf_domain
+#
+# Returns the domain configured in resolv.conf(5).
+#
+f_resolv_conf_domain()
+{
+ tail -r "$RESOLV_CONF" 2> /dev/null | awk \
+ '
+ BEGIN { found = 0 }
+ ( tolower($1) == "domain" ) \
+ {
+ print $2
+ found = 1
+ exit
+ }
+ END { exit ! found }
+ '
+}
+
+# f_resolv_conf_search
+#
+# Returns the search configured in resolv.conf(5).
+#
+f_resolv_conf_search()
+{
+ tail -r "$RESOLV_CONF" 2> /dev/null | awk \
+ '
+ BEGIN { found = 0 }
+ {
+ tl0 = tolower($0)
+ if ( match(tl0, /^[[:space:]]*search[[:space:]]+/) ) {
+ search = substr($0, RLENGTH + 1)
+ sub(/[[:space:]]*#.*$/, "", search)
+ gsub(/[[:space:]]+/, " ", search)
+ print search
+ found = 1
+ exit
+ }
+ }
+ END { exit ! found }
+ '
+}
+
+# f_dialog_resolv_conf_update $hostname
+#
+# Updates the search/domain directives in resolv.conf(5) given a valid fully-
+# qualified hostname.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_dialog_resolv_conf_update_awk='
+# Variables that should be defined on the invocation line:
+# -v domain="domain"
+# -v search_all="0|1"
+# -v search_ndots="1+"
+#
+BEGIN {
+ domain_found = search_found = 0
+
+ if ( search_all ) {
+ search = ""
+ subdomain = domain
+ if ( search_ndots < 1 )
+ search_ndots = 1
+
+ ndots = split(subdomain, labels, ".") - 1
+ while ( ndots-- >= search_ndots ) {
+ if ( length(search) ) search = search " "
+ search = search subdomain
+ sub(/[^.]*\./, "", subdomain)
+ }
+ }
+ else search = domain
+}
+{
+ if ( domain_found && search_found ) { print; next }
+
+ tl0 = tolower($0)
+ if ( ! domain_found && \
+ match(tl0, /^[[:space:]]*domain[[:space:]]+/) ) \
+ {
+ if ( length(domain) ) {
+ printf "%s%s\n", substr($0, 0, RLENGTH), domain
+ domain_found = 1
+ }
+ }
+ else if ( ! search_found && \
+ match(tl0, /^[[:space:]]*search[[:space:]]+/) ) \
+ {
+ if ( length(search) ) {
+ printf "%s%s\n", substr($0, 0, RLENGTH), search
+ search_found = 1
+ }
+ }
+ else print
+}
+END {
+ if ( ! search_found && length(search) )
+ printf "search\t%s\n", search
+ if ( ! domain_found && length(domain) )
+ printf "domain\t%s\n", domain
+}
+'
+f_dialog_resolv_conf_update()
+{
+ local funcname=f_dialog_resolv_conf_update
+ local hostname="$1"
+
+ #
+ # Extrapolate the desired domain search parameter for resolv.conf(5)
+ #
+ local search nfields ndots domain="${hostname#*.}"
+ if [ "$RESOLVER_SEARCH_DOMAINS_ALL" = "1" ]; then
+ search=
+ IFS=. f_count_ifs nfields "$domain"
+ ndots=$(( $nfields - 1 ))
+ while [ $ndots -ge ${RESOLVER_SEARCH_NDOTS:-1} ]; do
+ search="$search $domain"
+ domain="${domain#*.}"
+ ndots=$(( $ndots - 1 ))
+ done
+ search="${search# }"
+ domain="${hostname#*.}"
+ else
+ search="$domain"
+ fi
+
+ #
+ # Save domain/search information only if different from resolv.conf(5)
+ #
+ if [ "$domain" != "$( f_resolv_conf_domain )" -o \
+ "$search" != "$( f_resolv_conf_search )" ]
+ then
+ f_dialog_info "Saving new domain/search settings" \
+ "to resolv.conf(5)..."
+
+ #
+ # Create a new temporary file to write our resolv.conf(5)
+ # update with our new `domain' and `search' directives.
+ #
+ local tmpfile
+ f_eval_catch -dk tmpfile $funcname mktemp \
+ 'mktemp -t "%s"' "$tmpfile" || return $DIALOG_CANCEL
+
+ #
+ # Fixup permissions and ownership (mktemp(1) creates the
+ # temporary file with 0600 permissions -- change the
+ # permissions and ownership to match resolv.conf(5) before
+ # we write it out and mv(1) it into place).
+ #
+ local mode owner
+ f_eval_catch -dk mode $funcname stat \
+ 'stat -f "%%#Lp" "%s"' "$RESOLV_CONF" || mode=0644
+ f_eval_catch -dk owner $funcname stat \
+ 'stat -f "%%u:%%g" "%s"' "$RESOLV_CONF" ||
+ owner="root:wheel"
+ f_eval_catch -d $funcname chmod \
+ 'chmod "%s" "%s"' "$mode" "$tmpfile"
+ f_eval_catch -d $funcname chown \
+ 'chown "%s" "%s"' "$owner" "$tmpfile"
+
+ #
+ # Operate on resolv.conf(5), replacing only the last
+ # occurrences of `domain' and `search' directives (or add
+ # them to the top if not found), in strict-adherence to the
+ # following entry in resolver(5):
+ #
+ # The domain and search keywords are mutually exclusive.
+ # If more than one instance of these keywords is present,
+ # the last instance will override.
+ #
+ # NOTE: If RESOLVER_SEARCH_DOMAINS_ALL is set to `1' in the
+ # environment, all sub-domains will be added to the `search'
+ # directive, not just the FQDN.
+ #
+ local domain="${hostname#*.}" new_contents
+ [ "$domain" = "$hostname" ] && domain=
+ new_contents=$( tail -r "$RESOLV_CONF" 2> /dev/null )
+ new_contents=$( echo "$new_contents" | awk \
+ -v domain="$domain" \
+ -v search_all="${RESOLVER_SEARCH_DOMAINS_ALL:-1}" \
+ -v search_ndots="${RESOLVER_SEARCH_NDOTS:-1}" \
+ "$f_dialog_resolv_conf_update_awk" )
+
+ #
+ # Write the temporary file contents and move the temporary
+ # file into place.
+ #
+ echo "$new_contents" | tail -r > "$tmpfile" ||
+ return $DIALOG_CANCEL
+ f_eval_catch -d $funcname mv \
+ 'mv "%s" "%s"' "$tmpfile" "$RESOLV_CONF"
+
+ fi
+}
+
+# f_dialog_input_nameserver [ $n $nameserver ]
+#
+# Allows the user to edit a given nameserver. The first argument is the
+# resolv.conf(5) nameserver ``instance'' integer. For example, this will be one
+# if editing the first nameserver instance, two if editing the second, three if
+# the third, ad nauseum. If this argument is zero, null, or missing, the value
+# entered by the user (if non-null) will be added to resolv.conf(5) as a new
+# `nameserver' entry. The second argument is the IPv4 address of the nameserver
+# to be edited -- this will be displayed as the initial value during the edit.
+#
+# Taint-checking is performed when editing an existing entry (when the second
+# argument is one or higher) in that the first argument must match the current
+# value of the Nth `nameserver' instance in resolv.conf(5) else an error is
+# generated discarding any/all changes.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_dialog_input_nameserver_edit_awk='
+# Variables that should be defined on the invocation line:
+# -v nsindex="1+"
+# -v old_value="..."
+# -v new_value="..."
+#
+BEGIN {
+ if ( nsindex < 1 ) exit 1
+ found = n = 0
+}
+{
+ if ( found ) { print; next }
+
+ if ( match(tolower($0), /^[[:space:]]*nameserver[[:space:]]+/)) {
+ if ( ++n == nsindex ) {
+ if ( $2 != old_value ) exit 2
+ if ( new_value != "" ) printf "%s%s\n", \
+ substr($0, 0, RLENGTH), new_value
+ found = 1
+ }
+ else print
+ }
+ else print
+}
+END { if ( ! found ) exit 3 }
+'
+f_dialog_input_nameserver()
+{
+ local funcname=f_dialog_input_nameserver
+ local index="${1:-0}" old_ns="$2" new_ns
+ local ns="$old_ns"
+
+ #
+ # Perform sanity checks
+ #
+ f_isinteger "$index" || return $DIALOG_CANCEL
+ [ $index -ge 0 ] || return $DIALOG_CANCEL
+
+ local msg
+ if [ $index -gt 0 ]; then
+ if [ "$USE_XDIALOG" ]; then
+ msg="$xmsg_please_enter_nameserver_existing"
+ else
+ msg="$msg_please_enter_nameserver_existing"
+ fi
+ else
+ msg="$msg_please_enter_nameserver"
+ fi
+
+ #
+ # Loop until the user provides taint-free input.
+ #
+ while :; do
+ 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]*}"
+
+ # Taint-check the user's input
+ [ "$new_ns" ] || break
+ f_dialog_validate_ipaddr "$new_ns" && break
+
+ # Update prompt to allow user to re-edit previous entry
+ ns="$new_ns"
+ done
+
+ #
+ # Save only if the user changed the nameserver.
+ #
+ if [ $index -eq "0" -a "$new_ns" ]; then
+ f_dialog_info "$msg_saving_nameserver"
+ printf "nameserver\t%s\n" "$new_ns" >> "$RESOLV_CONF"
+ return $DIALOG_OK
+ elif [ $index -gt 0 -a "$old_ns" != "$new_ns" ]; then
+ if [ "$new_ns" ]; then
+ msg="$msg_saving_nameserver_existing"
+ else
+ msg="$msg_removing_nameserver"
+ fi
+ f_dialog_info "$msg"
+
+ #
+ # Create a new temporary file to write our new resolv.conf(5)
+ #
+ local tmpfile
+ f_eval_catch -dk tmpfile $funcname mktemp \
+ 'mktemp -t "%s"' "$pgm" || return $DIALOG_CANCEL
+
+ #
+ # Quietly fixup permissions and ownership
+ #
+ local mode owner
+ f_eval_catch -dk mode $funcname stat \
+ 'stat -f "%%#Lp" "%s"' "$RESOLV_CONF" || mode=0644
+ f_eval_catch -dk owner $funcname stat \
+ 'stat -f "%%u:%%g" "%s"' "$RESOLV_CONF" ||
+ owner="root:wheel"
+ f_eval_catch -d $funcname chmod \
+ 'chmod "%s" "%s"' "$mode" "$tmpfile"
+ f_eval_catch -d $funcname chown \
+ 'chown "%s" "%s"' "$owner" "$tmpfile"
+
+ #
+ # Operate on resolv.conf(5)
+ #
+ local new_contents
+ new_contents=$( awk -v nsindex="$index" \
+ -v old_value="$old_ns" \
+ -v new_value="$new_ns" \
+ "$f_dialog_input_nameserver_edit_awk" \
+ "$RESOLV_CONF" )
+
+ #
+ # Produce an appropriate error message if necessary.
+ #
+ local retval=$?
+ case $retval in
+ 1) f_die 1 "$msg_internal_error_nsindex_value" "$nsindex" ;;
+ 2) f_show_msg "$msg_resolv_conf_changed_while_editing"
+ return $retval ;;
+ 3) f_show_msg "$msg_resolv_conf_entry_no_longer_exists"
+ return $retval ;;
+ esac
+
+ #
+ # Write the temporary file contents and move the temporary
+ # file into place.
+ #
+ echo "$new_contents" > "$tmpfile" || return $DIALOG_CANCEL
+ f_eval_catch -d $funcname mv \
+ 'mv "%s" "%s"' "$tmpfile" "$RESOLV_CONF"
+ fi
+}
+
+# f_dialog_menu_nameservers
+#
+# Edit the nameservers in resolv.conf(5).
+#
+f_dialog_menu_nameservers()
+{
+ local prompt="$msg_dns_configuration"
+ local menu_list # Calculated below
+ local hline="$hline_arrows_tab_enter"
+ local defaultitem=
+
+ local height width rows
+ local opt_exit="$msg_return_to_previous_menu"
+ local opt_add="$msg_add_nameserver"
+
+ #
+ # Loop forever until the user has finished configuring nameservers
+ #
+ while :; do
+ #
+ # Re/Build list of nameservers
+ #
+ local nameservers
+ f_resolv_conf_nameservers nameservers
+ menu_list=$(
+ index=1
+
+ echo "'X $msg_exit' '$opt_exit'"
+ index=$(( $index + 1 ))
+
+ echo "'A $msg_add' '$opt_add'"
+ index=$(( $index + 1 ))
+
+ for ns in $nameservers; do
+ [ $index -lt ${#DIALOG_MENU_TAGS} ] || break
+ tag=$( f_substr "$DIALOG_MENU_TAGS" $index 1 )
+ echo "'$tag nameserver' '$ns'"
+ index=$(( $index + 1 ))
+ done
+ )
+
+ #
+ # Display configuration-edit menu
+ #
+ eval f_dialog_menu_size height width rows \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list
+ local tag
+ tag=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --default-item \"\$defaultitem\" \
+ --menu \"\$prompt\" \
+ $height $width $rows \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ f_dialog_data_sanitize tag
+
+ # Return if "Cancel" was chosen (-1) or ESC was pressed (255)
+ if [ $retval -ne $DIALOG_OK ]; then
+ return $retval
+ else
+ # Only update default-item on success
+ defaultitem="$tag"
+ fi
+
+ case "$tag" in
+ "X $msg_exit") break ;;
+ "A $msg_add")
+ f_dialog_input_nameserver
+ ;;
+ *)
+ local n ns
+ n=$( eval f_dialog_menutag2index \"\$tag\" $menu_list )
+ ns=$( eval f_dialog_menutag2item \"\$tag\" $menu_list )
+ f_dialog_input_nameserver $(( $n - 2 )) "$ns"
+ ;;
+ esac
+ done
+}
+
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/resolv.subr
+
+fi # ! $_NETWORKING_RESOLV_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/routing.subr b/usr.sbin/bsdconfig/networking/share/routing.subr
new file mode 100644
index 0000000..826ac6e
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/routing.subr
@@ -0,0 +1,133 @@
+if [ ! "$_NETWORKING_ROUTING_SUBR" ]; then _NETWORKING_ROUTING_SUBR=1
+#
+# Copyright (c) 2006-2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/routing.subr
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/media/tcpip.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+f_include $BSDCFG_SHARE/networking/ipaddr.subr
+f_include $BSDCFG_SHARE/strings.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# f_dialog_input_defaultrouter
+#
+# Edits the default router.
+#
+f_dialog_input_defaultrouter()
+{
+ local funcname=f_dialog_input_defaultrouter
+
+ #
+ # Get the defaultrouter. When this is not configured, the default is
+ # "NO", however we don't ever want to present this default to the user
+ # in the following dialog. If the current value is "NO", then try to
+ # obtain the value from the running system using route(8).
+ #
+ # NOTE: Our `f_route_get_default' function will return NULL if the
+ # system does not have an active default router set (which is what we
+ # want).
+ #
+ local defaultrouter="$( f_sysrc_get 'defaultrouter:-NO' )"
+ local defaultrouter_orig="$defaultrouter" # for change-tracking
+ case "$defaultrouter" in
+ [Nn][Oo]) f_route_get_default defaultrouter ;;
+ esac
+
+ #
+ # Return with-error when there are NFS-mounts currently active. If the
+ # default router/gateway is changed while NFS-exported directories are
+ # mounted, the system will hang.
+ #
+ if f_nfs_mounted && ! f_jailed; then
+ local setting
+ f_sprintf setting "$msg_current_default_router" \
+ "$defaultrouter"
+ f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
+ return $DIALOG_CANCEL
+ fi
+
+ #
+ # Loop until the user provides taint-free input.
+ #
+ local retval
+ while :; do
+ f_dialog_input defaultrouter \
+ "$msg_please_enter_default_router" \
+ "$defaultrouter" "$hline_num_punc_tab_enter"
+ retval=$?
+ [ "$defaultrouter" ] || return $DIALOG_OK
+ [ $retval -eq $DIALOG_OK ] || return $retval
+
+ # Taint-check the user's input
+ f_dialog_validate_ipaddr "$defaultrouter" && break
+ done
+
+ #
+ # Save only if the user changed the default router/gateway.
+ #
+ if [ "$defaultrouter" != "$defaultrouter_orig" ]; then
+ f_dialog_info "$msg_saving_default_router"
+
+ # Save the default router/gateway
+ f_eval_catch $funcname f_sysrc_set \
+ 'f_sysrc_set defaultrouter "%s"' "$defaultrouter"
+ fi
+
+ #
+ # Only ask to apply setting if the current defaultrouter is different
+ # than the stored configuration (in rc.conf(5)).
+ #
+ local dr
+ f_route_get_default dr
+ if [ "$dr" != "$defaultrouter" ]; then
+ f_dialog_clear
+ f_yesno "$msg_activate_default_router" "$dr" "$defaultrouter"
+ if [ $? -eq $DIALOG_OK ]; then
+ # Apply the default router/gateway
+ f_eval_catch -d $funcname route 'route delete default'
+ f_eval_catch $funcname route \
+ 'route add default "%s"' "$defaultrouter" ||
+ return $DIALOG_CANCEL
+ fi
+ fi
+}
+
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/routing.subr
+
+fi # ! $_NETWORKING_ROUTING_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/services.subr b/usr.sbin/bsdconfig/networking/share/services.subr
new file mode 100644
index 0000000..246d895
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/services.subr
@@ -0,0 +1,55 @@
+if [ ! "$_NETWORKING_SERVICES_SUBR" ]; then _NETWORKING_SERVICES_SUBR=1
+#
+# Copyright (c) 2013 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/services.subr
+f_include $BSDCFG_SHARE/packages/packages.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+############################################################ FUNCTIONS
+
+# f_config_pcnfsd
+#
+# Load pcnfsd package and adjust mountd_flags in rc.conf(5).
+#
+f_config_pcnfsd()
+{
+ local funcname=f_config_pcnfsd
+ f_package_add "pcnfsd" || return $?
+ f_eval_catch $funcname f_sysrc_set 'f_sysrc_set mountd_flags -n'
+ return $SUCCESS
+}
+
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/services.subr
+
+fi # ! $_NETWORKING_SERVICES_SUBR
OpenPOWER on IntegriCloud