Module Name:    src
Committed By:   martin
Date:           Thu Apr 23 13:43:42 UTC 2020

Modified Files:
        src/etc/rc.d [netbsd-8]: network
        src/share/man/man5 [netbsd-8]: rc.conf.5

Log Message:
Pull up following revision(s) (requested by kim in ticket #1537):

        share/man/man5/rc.conf.5: revision 1.172
        etc/rc.d/network: revision 1.75

Allow rc.conf to setup resolv.conf via resolvconf(8).

This allows all static network config to be in rc.conf rather than
spread across files.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.71.8.1 src/etc/rc.d/network
cvs rdiff -u -r1.166.6.1 -r1.166.6.2 src/share/man/man5/rc.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/etc/rc.d/network
diff -u src/etc/rc.d/network:1.71 src/etc/rc.d/network:1.71.8.1
--- src/etc/rc.d/network:1.71	Sun Mar  6 18:50:06 2016
+++ src/etc/rc.d/network	Thu Apr 23 13:43:42 2020
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: network,v 1.71 2016/03/06 18:50:06 christos Exp $
+# $NetBSD: network,v 1.71.8.1 2020/04/23 13:43:42 martin Exp $
 #
 
 # PROVIDE: network
@@ -52,6 +52,7 @@ network_start()
 	have_inet6 &&
 	network_start_ipv6_autoconf
 	network_wait_dad
+	network_start_resolv
 	network_start_local
 }
 
@@ -454,6 +455,32 @@ network_wait_dad()
 	fi
 }
 
+network_start_resolv()
+{
+	resconf=
+
+	if [ -n "$dns_domain" ]; then
+		resconf="${resconf}domain $dns_domain$nl"
+	fi
+	if [ -n "$dns_search" ]; then
+		resconf="${resconf}search $dns_search$nl"
+	fi
+	for n in $dns_nameservers; do
+		resconf="${resconf}nameserver $n$nl"
+	done
+	if [ -n "$dns_sortlist" ]; then
+		resconf="${resconf}sortlist $dns_sortlist$nl"
+	fi
+	if [ -n "$dns_options" ]; then
+		resconf="${resconf}options $dns_options$nl"
+	fi
+	if [ -n "$resconf" ]; then
+		resconf="# Generated by /etc/rc.d/network$nl$resconf"
+		echo 'Configuring resolv.conf'
+		printf %s "$resconf" | resolvconf -m "${dns_metric:-0}" -a network
+	fi
+}
+
 network_start_local()
 {
 	# XXX this must die
@@ -467,6 +494,7 @@ network_stop()
 	echo "Stopping network."
 
 	network_stop_local
+	network_stop_resolv
 	network_stop_aliases
 	[ "$net_interfaces" != NO ] &&
 	network_stop_interfaces
@@ -481,6 +509,11 @@ network_stop_local()
 	fi
 }
 
+network_stop_resolv()
+{
+	resolvconf -f -d network
+}
+
 network_stop_aliases()
 {
 	echo "Deleting aliases."

Index: src/share/man/man5/rc.conf.5
diff -u src/share/man/man5/rc.conf.5:1.166.6.1 src/share/man/man5/rc.conf.5:1.166.6.2
--- src/share/man/man5/rc.conf.5:1.166.6.1	Tue May 14 11:33:43 2019
+++ src/share/man/man5/rc.conf.5	Thu Apr 23 13:43:42 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rc.conf.5,v 1.166.6.1 2019/05/14 11:33:43 martin Exp $
+.\"	$NetBSD: rc.conf.5,v 1.166.6.2 2020/04/23 13:43:42 martin Exp $
 .\"
 .\" Copyright (c) 1996 Matthew R. Green
 .\" All rights reserved.
@@ -55,7 +55,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 14, 2019
+.Dd April 23, 2020
 .Dt RC.CONF 5
 .Os
 .Sh NAME
@@ -249,6 +249,30 @@ If empty or not set, then the contents o
 A space separated list of interface names.
 These interfaces will be configured down when going from multiuser to single-user
 mode or on system shutdown.
+.It Sy dns_domain
+A string.
+Sets domain in
+.Pa /etc/resolv.conf .
+.It Sy dns_search
+A string.
+Sets search in
+.Pa /etc/resolv.conf .
+.It Sy dns_nameservers
+A string of space seperated domain name servers.
+Sets nameserver for each value in
+.Pa /etc/resolv.conf .
+.It Sy dns_sortlist
+A string.
+Sets sortlist in
+.Pa /etc/resolv.conf .
+.It Sy dns_options
+A string.
+Sets options in
+.Pa /etc/resolv.conf .
+.It Sy dns_metric
+An unsigned integer.
+Sets the priority of the above DNS to other sources, lowest wins.
+Defaults to 0.
 .Pp
 This is important for some stateful interfaces, for example PPP over ISDN
 connections that cost money by connection time or PPPoE interfaces which

Reply via email to