Thu Apr 23 13:43:42 2020 UTC ()
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.


(martin)
diff -r1.71 -r1.71.8.1 src/etc/rc.d/network
diff -r1.166.6.1 -r1.166.6.2 src/share/man/man5/rc.conf.5

cvs diff -r1.71 -r1.71.8.1 src/etc/rc.d/network (expand / switch to unified diff)

--- src/etc/rc.d/network 2016/03/06 18:50:06 1.71
+++ src/etc/rc.d/network 2020/04/23 13:43:42 1.71.8.1
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: network,v 1.71 2016/03/06 18:50:06 christos Exp $ 3# $NetBSD: network,v 1.71.8.1 2020/04/23 13:43:42 martin Exp $
4# 4#
5 5
6# PROVIDE: network 6# PROVIDE: network
7# REQUIRE: ipfilter ipsec mountcritlocal root tty sysctl 7# REQUIRE: ipfilter ipsec mountcritlocal root tty sysctl
8# BEFORE: NETWORKING 8# BEFORE: NETWORKING
9 9
10$_rc_subr_loaded . /etc/rc.subr 10$_rc_subr_loaded . /etc/rc.subr
11 11
12name="network" 12name="network"
13start_cmd="network_start" 13start_cmd="network_start"
14stop_cmd="network_stop" 14stop_cmd="network_stop"
15 15
16nl=' 16nl='
@@ -42,26 +42,27 @@ network_start() @@ -42,26 +42,27 @@ network_start()
42 network_start_hostname 42 network_start_hostname
43 network_start_domainname 43 network_start_domainname
44 network_start_loopback 44 network_start_loopback
45 have_inet6 && 45 have_inet6 &&
46 network_start_ipv6_route 46 network_start_ipv6_route
47 [ "$net_interfaces" != NO ] && 47 [ "$net_interfaces" != NO ] &&
48 network_start_interfaces 48 network_start_interfaces
49 network_start_aliases 49 network_start_aliases
50 network_start_defaultroute 50 network_start_defaultroute
51 network_start_defaultroute6 51 network_start_defaultroute6
52 have_inet6 && 52 have_inet6 &&
53 network_start_ipv6_autoconf 53 network_start_ipv6_autoconf
54 network_wait_dad 54 network_wait_dad
 55 network_start_resolv
55 network_start_local 56 network_start_local
56} 57}
57 58
58network_start_hostname() 59network_start_hostname()
59{ 60{
60 # If $hostname is set, use it for my Internet name, 61 # If $hostname is set, use it for my Internet name,
61 # otherwise use /etc/myname 62 # otherwise use /etc/myname
62 # 63 #
63 if [ -z "$hostname" ] && [ -f /etc/myname ]; then 64 if [ -z "$hostname" ] && [ -f /etc/myname ]; then
64 hostname=$(kat /etc/myname) 65 hostname=$(kat /etc/myname)
65 fi 66 fi
66 if [ -n "$hostname" ]; then 67 if [ -n "$hostname" ]; then
67 echo "Hostname: $hostname" 68 echo "Hostname: $hostname"
@@ -444,53 +445,85 @@ network_start_ipv6_autoconf() @@ -444,53 +445,85 @@ network_start_ipv6_autoconf()
444 fi 445 fi
445} 446}
446 447
447network_wait_dad() 448network_wait_dad()
448{ 449{
449 # Wait for the DAD flags to clear form all addresses. 450 # Wait for the DAD flags to clear form all addresses.
450 if [ -n "$ifconfig_wait_dad_flags" ]; then 451 if [ -n "$ifconfig_wait_dad_flags" ]; then
451 echo 'Waiting for DAD to complete for' \ 452 echo 'Waiting for DAD to complete for' \
452 'statically configured addresses...' 453 'statically configured addresses...'
453 ifconfig $ifconfig_wait_dad_flags 454 ifconfig $ifconfig_wait_dad_flags
454 fi 455 fi
455} 456}
456 457
 458network_start_resolv()
 459{
 460 resconf=
 461
 462 if [ -n "$dns_domain" ]; then
 463 resconf="${resconf}domain $dns_domain$nl"
 464 fi
 465 if [ -n "$dns_search" ]; then
 466 resconf="${resconf}search $dns_search$nl"
 467 fi
 468 for n in $dns_nameservers; do
 469 resconf="${resconf}nameserver $n$nl"
 470 done
 471 if [ -n "$dns_sortlist" ]; then
 472 resconf="${resconf}sortlist $dns_sortlist$nl"
 473 fi
 474 if [ -n "$dns_options" ]; then
 475 resconf="${resconf}options $dns_options$nl"
 476 fi
 477 if [ -n "$resconf" ]; then
 478 resconf="# Generated by /etc/rc.d/network$nl$resconf"
 479 echo 'Configuring resolv.conf'
 480 printf %s "$resconf" | resolvconf -m "${dns_metric:-0}" -a network
 481 fi
 482}
 483
457network_start_local() 484network_start_local()
458{ 485{
459 # XXX this must die 486 # XXX this must die
460 if [ -s /etc/netstart.local ]; then 487 if [ -s /etc/netstart.local ]; then
461 sh /etc/netstart.local start 488 sh /etc/netstart.local start
462 fi 489 fi
463} 490}
464 491
465network_stop() 492network_stop()
466{ 493{
467 echo "Stopping network." 494 echo "Stopping network."
468 495
469 network_stop_local 496 network_stop_local
 497 network_stop_resolv
470 network_stop_aliases 498 network_stop_aliases
471 [ "$net_interfaces" != NO ] && 499 [ "$net_interfaces" != NO ] &&
472 network_stop_interfaces 500 network_stop_interfaces
473 network_stop_route 501 network_stop_route
474} 502}
475 503
476network_stop_local() 504network_stop_local()
477{ 505{
478 # XXX this must die 506 # XXX this must die
479 if [ -s /etc/netstart.local ]; then 507 if [ -s /etc/netstart.local ]; then
480 sh /etc/netstart.local stop 508 sh /etc/netstart.local stop
481 fi 509 fi
482} 510}
483 511
 512network_stop_resolv()
 513{
 514 resolvconf -f -d network
 515}
 516
484network_stop_aliases() 517network_stop_aliases()
485{ 518{
486 echo "Deleting aliases." 519 echo "Deleting aliases."
487 if [ -f /etc/ifaliases ]; then 520 if [ -f /etc/ifaliases ]; then
488 while read addr int net; do 521 while read addr int net; do
489 /sbin/ifconfig $int inet delete $addr 522 /sbin/ifconfig $int inet delete $addr
490 done < /etc/ifaliases 523 done < /etc/ifaliases
491 fi 524 fi
492 525
493 for int in $(/sbin/ifconfig -lu); do 526 for int in $(/sbin/ifconfig -lu); do
494 eval args=\$ifaliases_$int 527 eval args=\$ifaliases_$int
495 if [ -n "$args" ]; then 528 if [ -n "$args" ]; then
496 set -- $args 529 set -- $args

cvs diff -r1.166.6.1 -r1.166.6.2 src/share/man/man5/rc.conf.5 (expand / switch to unified diff)

--- src/share/man/man5/rc.conf.5 2019/05/14 11:33:43 1.166.6.1
+++ src/share/man/man5/rc.conf.5 2020/04/23 13:43:42 1.166.6.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: rc.conf.5,v 1.166.6.1 2019/05/14 11:33:43 martin Exp $ 1.\" $NetBSD: rc.conf.5,v 1.166.6.2 2020/04/23 13:43:42 martin Exp $
2.\" 2.\"
3.\" Copyright (c) 1996 Matthew R. Green 3.\" Copyright (c) 1996 Matthew R. Green
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 14.\"
@@ -45,27 +45,27 @@ @@ -45,27 +45,27 @@
45.\" 45.\"
46.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 46.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
47.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 47.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
48.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 48.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
49.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 49.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
50.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 50.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
51.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 51.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
52.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 52.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
53.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 53.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 54.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 55.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56.\" SUCH DAMAGE. 56.\" SUCH DAMAGE.
57.\" 57.\"
58.Dd May 14, 2019 58.Dd April 23, 2020
59.Dt RC.CONF 5 59.Dt RC.CONF 5
60.Os 60.Os
61.Sh NAME 61.Sh NAME
62.Nm rc.conf 62.Nm rc.conf
63.Nd system startup configuration file 63.Nd system startup configuration file
64.Sh DESCRIPTION 64.Sh DESCRIPTION
65The 65The
66.Nm 66.Nm
67file specifies which services are enabled during system startup by 67file specifies which services are enabled during system startup by
68the startup scripts invoked by 68the startup scripts invoked by
69.Pa /etc/rc 69.Pa /etc/rc
70(see 70(see
71.Xr rc 8 ) , 71.Xr rc 8 ) ,
@@ -239,26 +239,50 @@ If empty or not set, then the contents o @@ -239,26 +239,50 @@ If empty or not set, then the contents o
239.Pa /etc/mygate6 239.Pa /etc/mygate6
240(if it exists) are used. 240(if it exists) are used.
241.It Sy domainname 241.It Sy domainname
242A string. 242A string.
243.Tn NIS 243.Tn NIS
244(YP) domain of host. 244(YP) domain of host.
245If empty or not set, then the contents of 245If empty or not set, then the contents of
246.Pa /etc/defaultdomain 246.Pa /etc/defaultdomain
247(if it exists) are used. 247(if it exists) are used.
248.It Sy force_down_interfaces 248.It Sy force_down_interfaces
249A space separated list of interface names. 249A space separated list of interface names.
250These interfaces will be configured down when going from multiuser to single-user 250These interfaces will be configured down when going from multiuser to single-user
251mode or on system shutdown. 251mode or on system shutdown.
 252.It Sy dns_domain
 253A string.
 254Sets domain in
 255.Pa /etc/resolv.conf .
 256.It Sy dns_search
 257A string.
 258Sets search in
 259.Pa /etc/resolv.conf .
 260.It Sy dns_nameservers
 261A string of space seperated domain name servers.
 262Sets nameserver for each value in
 263.Pa /etc/resolv.conf .
 264.It Sy dns_sortlist
 265A string.
 266Sets sortlist in
 267.Pa /etc/resolv.conf .
 268.It Sy dns_options
 269A string.
 270Sets options in
 271.Pa /etc/resolv.conf .
 272.It Sy dns_metric
 273An unsigned integer.
 274Sets the priority of the above DNS to other sources, lowest wins.
 275Defaults to 0.
252.Pp 276.Pp
253This is important for some stateful interfaces, for example PPP over ISDN 277This is important for some stateful interfaces, for example PPP over ISDN
254connections that cost money by connection time or PPPoE interfaces which 278connections that cost money by connection time or PPPoE interfaces which
255have no direct means of noticing 279have no direct means of noticing
256.Dq disconnect 280.Dq disconnect
257events. 281events.
258.Pp 282.Pp
259All active 283All active
260.Xr pppoe 4 284.Xr pppoe 4
261and 285and
262.Xr ippp 4 286.Xr ippp 4
263interfaces will be automatically added to this list. 287interfaces will be automatically added to this list.
264.It Sy hostname 288.It Sy hostname