Sat Jul 4 06:24:53 2020 UTC ()
Trailing whitespace


(skrll)
diff -r1.15 -r1.16 src/etc/rc.d/bootconf.sh
diff -r1.3 -r1.4 src/etc/rc.d/fccache.in
diff -r1.3 -r1.4 src/etc/rc.d/mdnsd
diff -r1.18 -r1.19 src/etc/rc.d/ipfilter
diff -r1.5 -r1.6 src/etc/rc.d/lvm
diff -r1.25 -r1.26 src/etc/rc.d/named
diff -r1.79 -r1.80 src/etc/rc.d/network
diff -r1.4 -r1.5 src/etc/rc.d/npf
diff -r1.16 -r1.17 src/etc/rc.d/ntpd
diff -r1.11 -r1.12 src/etc/rc.d/pf
diff -r1.10 -r1.11 src/etc/rc.d/rtadvd

cvs diff -r1.15 -r1.16 src/etc/rc.d/bootconf.sh (switch to unified diff)

--- src/etc/rc.d/bootconf.sh 2012/12/31 23:21:27 1.15
+++ src/etc/rc.d/bootconf.sh 2020/07/04 06:24:53 1.16
@@ -1,87 +1,87 @@ @@ -1,87 +1,87 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: bootconf.sh,v 1.15 2012/12/31 23:21:27 christos Exp $ 3# $NetBSD: bootconf.sh,v 1.16 2020/07/04 06:24:53 skrll Exp $
4# 4#
5 5
6# PROVIDE: bootconf 6# PROVIDE: bootconf
7# REQUIRE: mountcritlocal 7# REQUIRE: mountcritlocal
8# KEYWORD: interactive 8# KEYWORD: interactive
9 9
10$_rc_subr_loaded . /etc/rc.subr 10$_rc_subr_loaded . /etc/rc.subr
11 11
12name="bootconf" 12name="bootconf"
13start_cmd="bootconf_start" 13start_cmd="bootconf_start"
14stop_cmd=":" 14stop_cmd=":"
15 15
16bootconf_start() 16bootconf_start()
17{ 17{
18 # Refer to newbtconf(8) for more information 18 # Refer to newbtconf(8) for more information
19 # 19 #
20 20
21 if [ ! -e /etc/etc.current ]; then 21 if [ ! -e /etc/etc.current ]; then
22 return 0 22 return 0
23 fi 23 fi
24 if [ -h /etc/etc.default ]; then 24 if [ -h /etc/etc.default ]; then
25 def=$(ls -ld /etc/etc.default 2>&1) 25 def=$(ls -ld /etc/etc.default 2>&1)
26 default="${def##*-> *etc.}" 26 default="${def##*-> *etc.}"
27 else 27 else
28 default=current 28 default=current
29 fi 29 fi
30 if [ "$default" = "current" ]; then 30 if [ "$default" = "current" ]; then
31 def=$(ls -ld /etc/etc.current 2>&1) 31 def=$(ls -ld /etc/etc.current 2>&1)
32 default="${def##*-> *etc.}" 32 default="${def##*-> *etc.}"
33 fi 33 fi
34 34
35 spc="" 35 spc=""
36 for i in /etc/etc.*; do 36 for i in /etc/etc.*; do
37 name="${i##/etc/etc.}" 37 name="${i##/etc/etc.}"
38 case $name in 38 case $name in
39 current|default|\*) 39 current|default|\*)
40 continue 40 continue
41 ;;  41 ;;
42 *) 42 *)
43 if [ "$name" = "$default" ]; then 43 if [ "$name" = "$default" ]; then
44 echo -n "${spc}[${name}]" 44 echo -n "${spc}[${name}]"
45 else 45 else
46 echo -n "${spc}${name}" 46 echo -n "${spc}${name}"
47 fi 47 fi
48 spc=" " 48 spc=" "
49 ;; 49 ;;
50 esac 50 esac
51 done 51 done
52 echo 52 echo
53 _DUMMY=/etc/passwd 53 _DUMMY=/etc/passwd
54 conf=${_DUMMY} 54 conf=${_DUMMY}
55 while [ ! -d /etc/etc.$conf/. ]; do 55 while [ ! -d /etc/etc.$conf/. ]; do
56 trap "conf=$default; echo; echo Using default of $default" ALRM 56 trap "conf=$default; echo; echo Using default of $default" ALRM
57 echo -n "Which configuration [$default] ? " 57 echo -n "Which configuration [$default] ? "
58 (sleep 30 && kill -ALRM $RC_PID) >/dev/null 2>&1 & 58 (sleep 30 && kill -ALRM $RC_PID) >/dev/null 2>&1 &
59 read conf 59 read conf
60 trap : ALRM 60 trap : ALRM
61 if [ -z $conf ] ; then 61 if [ -z $conf ] ; then
62 conf=$default 62 conf=$default
63 fi 63 fi
64 if [ ! -d /etc/etc.$conf/. ]; then 64 if [ ! -d /etc/etc.$conf/. ]; then
65 conf=${_DUMMY} 65 conf=${_DUMMY}
66 fi 66 fi
67 done 67 done
68 68
69 print_rc_metadata "note:Using configuration \"${conf}\"" 69 print_rc_metadata "note:Using configuration \"${conf}\""
70 70
71 case $conf in 71 case $conf in
72 current|default) 72 current|default)
73 ;; 73 ;;
74 *) 74 *)
75 rm -f /etc/etc.current 75 rm -f /etc/etc.current
76 ln -s etc.$conf /etc/etc.current 76 ln -s etc.$conf /etc/etc.current
77 sync 77 sync
78 ;; 78 ;;
79 esac 79 esac
80 80
81 if [ -f /etc/rc.conf ] ; then 81 if [ -f /etc/rc.conf ] ; then
82 . /etc/rc.conf 82 . /etc/rc.conf
83 fi 83 fi
84} 84}
85 85
86load_rc_config $name 86load_rc_config $name
87run_rc_command "$1" 87run_rc_command "$1"

cvs diff -r1.3 -r1.4 src/etc/rc.d/fccache.in (switch to unified diff)

--- src/etc/rc.d/fccache.in 2012/02/07 10:36:01 1.3
+++ src/etc/rc.d/fccache.in 2020/07/04 06:24:53 1.4
@@ -1,28 +1,28 @@ @@ -1,28 +1,28 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: fccache.in,v 1.3 2012/02/07 10:36:01 mbalmer Exp $ 3# $NetBSD: fccache.in,v 1.4 2020/07/04 06:24:53 skrll Exp $
4# 4#
5 5
6# PROVIDE: fccache  6# PROVIDE: fccache
7# REQUIRE: mountcritremote 7# REQUIRE: mountcritremote
8# BEFORE: DAEMON 8# BEFORE: DAEMON
9 9
10$_rc_subr_loaded . /etc/rc.subr 10$_rc_subr_loaded . /etc/rc.subr
11 11
12name="fccache" 12name="fccache"
13rcvar=${name} 13rcvar=${name}
14command="@X11ROOTDIR@/bin/fc-cache" 14command="@X11ROOTDIR@/bin/fc-cache"
15start_cmd="fccache_start" 15start_cmd="fccache_start"
16stop_cmd=":" 16stop_cmd=":"
17 17
18fccache_start() 18fccache_start()
19{ 19{
20 if [ -x "${command}" ]; then 20 if [ -x "${command}" ]; then
21 echo -n "Updating fontconfig cache:" 21 echo -n "Updating fontconfig cache:"
22 ${command} 22 ${command}
23 echo " done." 23 echo " done."
24 fi 24 fi
25} 25}
26 26
27load_rc_config $name 27load_rc_config $name
28run_rc_command "$1" 28run_rc_command "$1"

cvs diff -r1.3 -r1.4 src/etc/rc.d/mdnsd (switch to unified diff)

--- src/etc/rc.d/mdnsd 2015/10/15 16:47:28 1.3
+++ src/etc/rc.d/mdnsd 2020/07/04 06:24:53 1.4
@@ -1,27 +1,27 @@ @@ -1,27 +1,27 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: mdnsd,v 1.3 2015/10/15 16:47:28 roy Exp $ 3# $NetBSD: mdnsd,v 1.4 2020/07/04 06:24:53 skrll Exp $
4# 4#
5 5
6# PROVIDE: mdnsd 6# PROVIDE: mdnsd
7# REQUIRE: network mountcritlocal staticroute 7# REQUIRE: network mountcritlocal staticroute
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="mdnsd" 12name="mdnsd"
13rcvar=$name 13rcvar=$name
14command="/usr/sbin/$name" 14command="/usr/sbin/$name"
15pidfile="/var/run/mdnsd/${name}.pid" 15pidfile="/var/run/mdnsd/${name}.pid"
16start_precmd="mdnsd_precmd" 16start_precmd="mdnsd_precmd"
17 17
18mdnsd_precmd() 18mdnsd_precmd()
19{ 19{
20 if [ ! -d /var/run/mdnsd ]; then 20 if [ ! -d /var/run/mdnsd ]; then
21 mkdir -p -m 755 /var/run/mdnsd 21 mkdir -p -m 755 /var/run/mdnsd
22 fi 22 fi
23 chown _mdnsd:_mdnsd /var/run/mdnsd 23 chown _mdnsd:_mdnsd /var/run/mdnsd
24} 24}
25  25
26load_rc_config $name 26load_rc_config $name
27run_rc_command "$1" 27run_rc_command "$1"

cvs diff -r1.18 -r1.19 src/etc/rc.d/ipfilter (switch to unified diff)

--- src/etc/rc.d/ipfilter 2009/03/23 18:52:02 1.18
+++ src/etc/rc.d/ipfilter 2020/07/04 06:24:53 1.19
@@ -1,104 +1,104 @@ @@ -1,104 +1,104 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: ipfilter,v 1.18 2009/03/23 18:52:02 hannken Exp $ 3# $NetBSD: ipfilter,v 1.19 2020/07/04 06:24:53 skrll Exp $
4# 4#
5 5
6# PROVIDE: ipfilter 6# PROVIDE: ipfilter
7# REQUIRE: root bootconf mountcritlocal tty 7# REQUIRE: root bootconf mountcritlocal tty
8 8
9$_rc_subr_loaded . /etc/rc.subr 9$_rc_subr_loaded . /etc/rc.subr
10 10
11name="ipfilter" 11name="ipfilter"
12rcvar=$name 12rcvar=$name
13start_precmd="ipfilter_prestart" 13start_precmd="ipfilter_prestart"
14start_cmd="ipfilter_start" 14start_cmd="ipfilter_start"
15stop_precmd="test -f /etc/ipf.conf -o -f /etc/ipf6.conf" 15stop_precmd="test -f /etc/ipf.conf -o -f /etc/ipf6.conf"
16stop_cmd="ipfilter_stop" 16stop_cmd="ipfilter_stop"
17reload_precmd="$stop_precmd" 17reload_precmd="$stop_precmd"
18reload_cmd="ipfilter_reload" 18reload_cmd="ipfilter_reload"
19resync_precmd="$stop_precmd" 19resync_precmd="$stop_precmd"
20resync_cmd="ipfilter_resync" 20resync_cmd="ipfilter_resync"
21status_precmd="$stop_precmd" 21status_precmd="$stop_precmd"
22status_cmd="ipfilter_status" 22status_cmd="ipfilter_status"
23extra_commands="reload resync status" 23extra_commands="reload resync status"
24 24
25ipfilter_prestart() 25ipfilter_prestart()
26{ 26{
27 if [ ! -f /etc/ipf.conf ] && [ ! -f /etc/ipf6.conf ]; then 27 if [ ! -f /etc/ipf.conf ] && [ ! -f /etc/ipf6.conf ]; then
28 warn "/etc/ipf*.conf not readable; ipfilter start aborted." 28 warn "/etc/ipf*.conf not readable; ipfilter start aborted."
29 29
30 stop_boot 30 stop_boot
31 return 1 31 return 1
32 fi 32 fi
33 return 0 33 return 0
34} 34}
35 35
36ipfilter_start() 36ipfilter_start()
37{ 37{
38 echo "Enabling ipfilter." 38 echo "Enabling ipfilter."
39 /sbin/ipf ${rc_flags} -E 39 /sbin/ipf ${rc_flags} -E
40 40
41 # Do the flush first; since older ipf has different semantics. 41 # Do the flush first; since older ipf has different semantics.
42 # 42 #
43 if [ -f /etc/ipf.conf ]; then 43 if [ -f /etc/ipf.conf ]; then
44 /sbin/ipf -Fa 44 /sbin/ipf -Fa
45 fi 45 fi
46 if [ -f /etc/ipf6.conf ]; then 46 if [ -f /etc/ipf6.conf ]; then
47 /sbin/ipf -6 -Fa 47 /sbin/ipf -6 -Fa
48 fi 48 fi
49 49
50 # Now load the config files 50 # Now load the config files
51 # 51 #
52 if [ -f /etc/ipf.conf ]; then 52 if [ -f /etc/ipf.conf ]; then
53 /sbin/ipf -f /etc/ipf.conf 53 /sbin/ipf -f /etc/ipf.conf
54 fi 54 fi
55 if [ -f /etc/ipf6.conf ]; then 55 if [ -f /etc/ipf6.conf ]; then
56 /sbin/ipf -6 -f /etc/ipf6.conf 56 /sbin/ipf -6 -f /etc/ipf6.conf
57 fi 57 fi
58} 58}
59 59
60ipfilter_stop() 60ipfilter_stop()
61{ 61{
62 echo "Disabling ipfilter." 62 echo "Disabling ipfilter."
63 /sbin/ipf -D 63 /sbin/ipf -D
64} 64}
65 65
66ipfilter_reload() 66ipfilter_reload()
67{ 67{
68 echo "Reloading ipfilter rules." 68 echo "Reloading ipfilter rules."
69 69
70 # Do the flush first; since older ipf has different semantics. 70 # Do the flush first; since older ipf has different semantics.
71 # 71 #
72 if [ -f /etc/ipf.conf ]; then 72 if [ -f /etc/ipf.conf ]; then
73 /sbin/ipf -I -Fa 73 /sbin/ipf -I -Fa
74 fi 74 fi
75 if [ -f /etc/ipf6.conf ]; then 75 if [ -f /etc/ipf6.conf ]; then
76 /sbin/ipf -6 -I -Fa 76 /sbin/ipf -6 -I -Fa
77 fi 77 fi
78 78
79 # Now load the config files into the Inactive set 79 # Now load the config files into the Inactive set
80 # 80 #
81 if [ -f /etc/ipf.conf ] && ! /sbin/ipf -I -f /etc/ipf.conf; then 81 if [ -f /etc/ipf.conf ] && ! /sbin/ipf -I -f /etc/ipf.conf; then
82 err 1 "reload of ipf.conf failed; not swapping to new ruleset." 82 err 1 "reload of ipf.conf failed; not swapping to new ruleset."
83 fi 83 fi
84 if [ -f /etc/ipf6.conf ] && ! /sbin/ipf -I -6 -f /etc/ipf6.conf; then 84 if [ -f /etc/ipf6.conf ] && ! /sbin/ipf -I -6 -f /etc/ipf6.conf; then
85 err 1 "reload of ipf6.conf failed; not swapping to new ruleset." 85 err 1 "reload of ipf6.conf failed; not swapping to new ruleset."
86 fi 86 fi
87  87
88 # Swap in the new rules 88 # Swap in the new rules
89 # 89 #
90 /sbin/ipf -s 90 /sbin/ipf -s
91} 91}
92 92
93ipfilter_resync() 93ipfilter_resync()
94{ 94{
95 /sbin/ipf -y 95 /sbin/ipf -y
96} 96}
97 97
98ipfilter_status() 98ipfilter_status()
99{ 99{
100 /sbin/ipf -V 100 /sbin/ipf -V
101} 101}
102 102
103load_rc_config $name 103load_rc_config $name
104run_rc_command "$1" 104run_rc_command "$1"

cvs diff -r1.5 -r1.6 src/etc/rc.d/lvm (switch to unified diff)

--- src/etc/rc.d/lvm 2009/04/21 16:08:57 1.5
+++ src/etc/rc.d/lvm 2020/07/04 06:24:53 1.6
@@ -1,90 +1,90 @@ @@ -1,90 +1,90 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: lvm,v 1.5 2009/04/21 16:08:57 joerg Exp $ 3# $NetBSD: lvm,v 1.6 2020/07/04 06:24:53 skrll Exp $
4# 4#
5 5
6# PROVIDE: lvm 6# PROVIDE: lvm
7# REQUIRE: root 7# REQUIRE: root
8# BEFORE: DISKS 8# BEFORE: DISKS
9 9
10$_rc_subr_loaded . /etc/rc.subr 10$_rc_subr_loaded . /etc/rc.subr
11 11
12name="lvm" 12name="lvm"
13rcvar=$name 13rcvar=$name
14start_cmd="lvm_start" 14start_cmd="lvm_start"
15stop_cmd="lvm_stop" 15stop_cmd="lvm_stop"
16 16
17ifs_restore="$IFS"; 17ifs_restore="$IFS";
18 18
19lvm_start() 19lvm_start()
20{ 20{
21 if [ -x /sbin/dmsetup ]; then 21 if [ -x /sbin/dmsetup ]; then
22 /sbin/dmsetup version >/dev/null 22 /sbin/dmsetup version >/dev/null
23 if [ $? -ne 0 ]; then  23 if [ $? -ne 0 ]; then
24 warn "Device-mapper not present in kernel" 24 warn "Device-mapper not present in kernel"
25 return 1; 25 return 1;
26 fi 26 fi
27 fi 27 fi
28 28
29 if [ -x /sbin/lvm ]; then 29 if [ -x /sbin/lvm ]; then
30 echo "Configuring lvm devices." 30 echo "Configuring lvm devices."
31 31
32 # Scan for all available VG's 32 # Scan for all available VG's
33 /sbin/lvm vgscan --mknodes --ignorelockingfailure >/dev/null 33 /sbin/lvm vgscan --mknodes --ignorelockingfailure >/dev/null
34  34
35 # Activate all LV's and create apropriate nodes in /dev 35 # Activate all LV's and create apropriate nodes in /dev
36 /sbin/lvm vgchange --ignorelockingfailure -a y >/dev/null 36 /sbin/lvm vgchange --ignorelockingfailure -a y >/dev/null
37 LV_LIST=$(/sbin/lvm vgdisplay -C -o vg_name --noheadings 2>/dev/null) 37 LV_LIST=$(/sbin/lvm vgdisplay -C -o vg_name --noheadings 2>/dev/null)
38 echo " Activated Volume Groups:" $LV_LIST 38 echo " Activated Volume Groups:" $LV_LIST
39 fi 39 fi
40} 40}
41 41
42lvm_stop() 42lvm_stop()
43{ 43{
44 if [ -x /sbin/dmsetup ]; then 44 if [ -x /sbin/dmsetup ]; then
45 /sbin/dmsetup version >/dev/null 45 /sbin/dmsetup version >/dev/null
46 if [ $? -ne 0 ]; then  46 if [ $? -ne 0 ]; then
47 warn "Device-mapper not present in kernel" 47 warn "Device-mapper not present in kernel"
48 return 1; 48 return 1;
49 fi 49 fi
50 fi 50 fi
51 51
52 if [ -x /sbin/lvm ]; then 52 if [ -x /sbin/lvm ]; then
53 echo "Unconfiguring lvm devices." 53 echo "Unconfiguring lvm devices."
54  54
55 LOGICAL_VOLUMES=$(/sbin/lvm lvdisplay -C -o vg_name,lv_name \ 55 LOGICAL_VOLUMES=$(/sbin/lvm lvdisplay -C -o vg_name,lv_name \
56 -O vg_name --separator \/ --noheadings 2>/dev/null) 56 -O vg_name --separator \/ --noheadings 2>/dev/null)
57 VOLUME_GROUPS=$(/sbin/lvm vgdisplay -C -o vg_name \ 57 VOLUME_GROUPS=$(/sbin/lvm vgdisplay -C -o vg_name \
58 --separator " " --noheadings 2>/dev/null) 58 --separator " " --noheadings 2>/dev/null)
59 59
60 for lv in ${LOGICAL_VOLUMES}; do 60 for lv in ${LOGICAL_VOLUMES}; do
61 LV_IS_ACTIVE=$(/sbin/lvm lvdisplay -C --noheadings \ 61 LV_IS_ACTIVE=$(/sbin/lvm lvdisplay -C --noheadings \
62 -o lv_attr $lv) 62 -o lv_attr $lv)
63 case $LV_IS_ACTIVE in 63 case $LV_IS_ACTIVE in
64 *a*) 64 *a*)
65 echo " Shutting Down logical volume: ${lv}" 65 echo " Shutting Down logical volume: ${lv}"
66 /sbin/lvm lvchange -an --ignorelockingfailure \ 66 /sbin/lvm lvchange -an --ignorelockingfailure \
67 -P ${lv} >/dev/null 67 -P ${lv} >/dev/null
68 ;; 68 ;;
69 esac 69 esac
70 done 70 done
71  71
72 for vg in ${VOLUME_GROUPS}; do 72 for vg in ${VOLUME_GROUPS}; do
73 # Set IFS to field separator 73 # Set IFS to field separator
74 IFS=":" 74 IFS=":"
75 set -- $(/sbin/lvm vgdisplay -cA ${vg} 2>/dev/null) 75 set -- $(/sbin/lvm vgdisplay -cA ${vg} 2>/dev/null)
76 # The seventh parameter is number of opened LVs in a Volume Group 76 # The seventh parameter is number of opened LVs in a Volume Group
77 VG_HAS_ACTIVE_LV=$7 77 VG_HAS_ACTIVE_LV=$7
78 IFS="$ifs_restore"; 78 IFS="$ifs_restore";
79  79
80 if [ "${VG_HAS_ACTIVE_LV}" = 0 ]; then 80 if [ "${VG_HAS_ACTIVE_LV}" = 0 ]; then
81 echo " Shutting Down volume group: ${vg}" 81 echo " Shutting Down volume group: ${vg}"
82 /sbin/lvm vgchange -an --ignorelockingfailure \ 82 /sbin/lvm vgchange -an --ignorelockingfailure \
83 -P ${vg} >/dev/null 83 -P ${vg} >/dev/null
84 fi 84 fi
85 done 85 done
86 fi 86 fi
87} 87}
88 88
89load_rc_config $name 89load_rc_config $name
90run_rc_command "$1" 90run_rc_command "$1"

cvs diff -r1.25 -r1.26 src/etc/rc.d/named (switch to unified diff)

--- src/etc/rc.d/named 2014/07/13 22:06:56 1.25
+++ src/etc/rc.d/named 2020/07/04 06:24:53 1.26
@@ -1,146 +1,146 @@ @@ -1,146 +1,146 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: named,v 1.25 2014/07/13 22:06:56 tls Exp $ 3# $NetBSD: named,v 1.26 2020/07/04 06:24:53 skrll Exp $
4# 4#
5 5
6# PROVIDE: named 6# PROVIDE: named
7# REQUIRE: NETWORKING mountcritremote syslogd 7# REQUIRE: NETWORKING mountcritremote syslogd
8# BEFORE: DAEMON 8# BEFORE: DAEMON
9# KEYWORD: chrootdir 9# KEYWORD: chrootdir
10 10
11$_rc_subr_loaded . /etc/rc.subr 11$_rc_subr_loaded . /etc/rc.subr
12 12
13name="named" 13name="named"
14rcvar=$name 14rcvar=$name
15command="/usr/sbin/${name}" 15command="/usr/sbin/${name}"
16pidfile="/var/run/${name}/${name}.pid" 16pidfile="/var/run/${name}/${name}.pid"
17start_precmd="named_precmd" 17start_precmd="named_precmd"
18extra_commands="reload" 18extra_commands="reload"
19required_dirs="$named_chrootdir" # if it is set, it must exist 19required_dirs="$named_chrootdir" # if it is set, it must exist
20 20
21named_migrate() 21named_migrate()
22{ 22{
23 local src="$1" 23 local src="$1"
24 local dst="$2$1" 24 local dst="$2$1"
25 echo "Migrating $src to $dst" 25 echo "Migrating $src to $dst"
26( 26(
27 diff=false 27 diff=false
28 cd "$src" 28 cd "$src"
29 mkdir -p "$dst" 29 mkdir -p "$dst"
30 for f in $(find . -type f) 30 for f in $(find . -type f)
31 do 31 do
32 f="${f##./}" 32 f="${f##./}"
33 case "$f" in 33 case "$f" in
34 */*) 34 */*)
35 ds="$(dirname "$f")" 35 ds="$(dirname "$f")"
36 dd="$dst/$ds" 36 dd="$dst/$ds"
37 mkdir -p "$dd" 37 mkdir -p "$dd"
38 chmod "$(stat -f "%p" "$ds" | 38 chmod "$(stat -f "%p" "$ds" |
39 sed -e 's/.*\([0-7][0-7][0-7][0-7]\)$/\1/g')" "$dd" 39 sed -e 's/.*\([0-7][0-7][0-7][0-7]\)$/\1/g')" "$dd"
40 chown "$(stat -f %u:%g "$ds")" "$dd" 40 chown "$(stat -f %u:%g "$ds")" "$dd"
41 ;; 41 ;;
42 *) 42 *)
43 ;; 43 ;;
44 esac 44 esac
45 if [ -r "$dst/$f" ] 45 if [ -r "$dst/$f" ]
46 then 46 then
47 if ! cmp "$f" "$dst/$f"; then 47 if ! cmp "$f" "$dst/$f"; then
48 diff=true 48 diff=true
49 fi 49 fi
50 else 50 else
51 cp -p "$f" "$dst/$f" 51 cp -p "$f" "$dst/$f"
52 fi 52 fi
53 done 53 done
54 if $diff; then 54 if $diff; then
55 echo "Cannot complete migration because files are different" 55 echo "Cannot complete migration because files are different"
56 echo "Run 'diff -r $src $dst' resolve the differences" 56 echo "Run 'diff -r $src $dst' resolve the differences"
57 else 57 else
58 rm -fr "$src" 58 rm -fr "$src"
59 ln -s "$dst" "$src" 59 ln -s "$dst" "$src"
60 fi 60 fi
61) 61)
62} 62}
63 63
64named_precmd() 64named_precmd()
65{ 65{
66 if [ ! -e "/etc/rndc.key" ]; then 66 if [ ! -e "/etc/rndc.key" ]; then
67 echo "Generating rndc.key" 67 echo "Generating rndc.key"
68 /usr/sbin/rndc-confgen -a 68 /usr/sbin/rndc-confgen -a
69 fi 69 fi
70 70
71 if [ -z "$named_chrootdir" ]; then 71 if [ -z "$named_chrootdir" ]; then
72 if [ ! -d "/etc/namedb/keys" ]; then 72 if [ ! -d "/etc/namedb/keys" ]; then
73 mkdir -m 775 "/etc/namedb/keys" 73 mkdir -m 775 "/etc/namedb/keys"
74 chown named:named "/etc/namedb/keys" 74 chown named:named "/etc/namedb/keys"
75 fi 75 fi
76 return 0; 76 return 0;
77 fi 77 fi
78 78
79 # If running in a chroot cage, ensure that the appropriate files 79 # If running in a chroot cage, ensure that the appropriate files
80 # exist inside the cage, as well as helper symlinks into the cage  80 # exist inside the cage, as well as helper symlinks into the cage
81 # from outside. 81 # from outside.
82 # 82 #
83 # As this is called after the is_running and required_dir checks 83 # As this is called after the is_running and required_dir checks
84 # are made in run_rc_command(), we can safely assume ${named_chrootdir} 84 # are made in run_rc_command(), we can safely assume ${named_chrootdir}
85 # exists and named isn't running at this point (unless forcestart 85 # exists and named isn't running at this point (unless forcestart
86 # is used). 86 # is used).
87 # 87 #
88 case "$($command -v)" in 88 case "$($command -v)" in
89 BIND*) # 9 no group, named-xfer, or ndc 89 BIND*) # 9 no group, named-xfer, or ndc
90 ;; 90 ;;
91 named*) # 4 and 8 91 named*) # 4 and 8
92 rc_flags="-g named $rc_flags" 92 rc_flags="-g named $rc_flags"
93 if [ ! -x "${named_chrootdir}/usr/libexec/named-xfer" -o \ 93 if [ ! -x "${named_chrootdir}/usr/libexec/named-xfer" -o \
94 "${named_chrootdir}/usr/libexec/named-xfer" -ot \ 94 "${named_chrootdir}/usr/libexec/named-xfer" -ot \
95 /usr/libexec/named-xfer ]; then 95 /usr/libexec/named-xfer ]; then
96 rm -f "${named_chrootdir}/usr/libexec/named-xfer" 96 rm -f "${named_chrootdir}/usr/libexec/named-xfer"
97 cp -p /usr/libexec/named-xfer \ 97 cp -p /usr/libexec/named-xfer \
98 "${named_chrootdir}/usr/libexec" 98 "${named_chrootdir}/usr/libexec"
99 fi 99 fi
100 ln -fs "${named_chrootdir}/var/run/ndc" /var/run/ndc 100 ln -fs "${named_chrootdir}/var/run/ndc" /var/run/ndc
101 ;; 101 ;;
102 esac 102 esac
103 103
104 for i in null random urandom; do 104 for i in null random urandom; do
105 if [ ! -c "${named_chrootdir}/dev/$i" ]; then 105 if [ ! -c "${named_chrootdir}/dev/$i" ]; then
106 rm -f "${named_chrootdir}/dev/$i" 106 rm -f "${named_chrootdir}/dev/$i"
107 (cd /dev &&  107 (cd /dev &&
108 /bin/pax -rw -pe "$i" "${named_chrootdir}/dev") 108 /bin/pax -rw -pe "$i" "${named_chrootdir}/dev")
109 fi 109 fi
110 done 110 done
111 111
112 if [ ! -h /etc/namedb ]; then 112 if [ ! -h /etc/namedb ]; then
113 named_migrate /etc/namedb ${named_chrootdir} 113 named_migrate /etc/namedb ${named_chrootdir}
114 fi 114 fi
115 115
116 for i in named.conf rndc.key; do 116 for i in named.conf rndc.key; do
117 if [ \( -r "/etc/$i" \) -a \( ! -h "/etc/$i" \) -a \ 117 if [ \( -r "/etc/$i" \) -a \( ! -h "/etc/$i" \) -a \
118 \( ! -r "${named_chrootdir}/etc/$i" \) ]; then 118 \( ! -r "${named_chrootdir}/etc/$i" \) ]; then
119 mv "/etc/$i" "${named_chrootdir}/etc/$i" 119 mv "/etc/$i" "${named_chrootdir}/etc/$i"
120 ln -s "${named_chrootdir}/etc/$i" "/etc/$i" 120 ln -s "${named_chrootdir}/etc/$i" "/etc/$i"
121 fi 121 fi
122 done 122 done
123 123
124 if [ \( ! -r ${named_chrootdir}/etc/named.conf \) -a \ 124 if [ \( ! -r ${named_chrootdir}/etc/named.conf \) -a \
125 \( -r ${named_chrootdir}/etc/namedb/named.conf \) ]; then 125 \( -r ${named_chrootdir}/etc/namedb/named.conf \) ]; then
126 ln -s namedb/named.conf ${named_chrootdir}/etc 126 ln -s namedb/named.conf ${named_chrootdir}/etc
127 fi 127 fi
128 128
129 if [ -f /etc/localtime ]; then 129 if [ -f /etc/localtime ]; then
130 cmp -s /etc/localtime "${named_chrootdir}/etc/localtime" || \ 130 cmp -s /etc/localtime "${named_chrootdir}/etc/localtime" || \
131 cp -p /etc/localtime "${named_chrootdir}/etc/localtime" 131 cp -p /etc/localtime "${named_chrootdir}/etc/localtime"
132 fi 132 fi
133 133
134 local piddir="$(dirname "${pidfile}")" 134 local piddir="$(dirname "${pidfile}")"
135 mkdir -p "${named_chrootdir}${piddir}" "${piddir}" 135 mkdir -p "${named_chrootdir}${piddir}" "${piddir}"
136 chmod 755 "${named_chrootdir}${piddir}" "${piddir}" 136 chmod 755 "${named_chrootdir}${piddir}" "${piddir}"
137 chown named:named "${named_chrootdir}${piddir}" "${piddir}" 137 chown named:named "${named_chrootdir}${piddir}" "${piddir}"
138 ln -fs "${named_chrootdir}${pidfile}" "${pidfile}" 138 ln -fs "${named_chrootdir}${pidfile}" "${pidfile}"
139 139
140 # Change run_rc_commands()'s internal copy of $named_flags 140 # Change run_rc_commands()'s internal copy of $named_flags
141 # 141 #
142 rc_flags="-u named -t ${named_chrootdir} $rc_flags" 142 rc_flags="-u named -t ${named_chrootdir} $rc_flags"
143} 143}
144 144
145load_rc_config $name 145load_rc_config $name
146run_rc_command "$1" 146run_rc_command "$1"

cvs diff -r1.79 -r1.80 src/etc/rc.d/network (switch to unified diff)

--- src/etc/rc.d/network 2020/06/12 11:04:45 1.79
+++ src/etc/rc.d/network 2020/07/04 06:24:53 1.80
@@ -1,570 +1,570 @@ @@ -1,570 +1,570 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: network,v 1.79 2020/06/12 11:04:45 roy Exp $ 3# $NetBSD: network,v 1.80 2020/07/04 06:24:53 skrll 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='
17' # a newline 17' # a newline
18 18
19intmissing() 19intmissing()
20{ 20{
21 local int="$1" 21 local int="$1"
22 shift 22 shift
23 for i; do 23 for i; do
24 if [ "$int" = "$i" ]; then 24 if [ "$int" = "$i" ]; then
25 return 1 25 return 1
26 fi 26 fi
27 done 27 done
28 return 0 28 return 0
29} 29}
30 30
31have_inet6() 31have_inet6()
32{ 32{
33 /sbin/ifconfig lo0 inet6 >/dev/null 2>&1 33 /sbin/ifconfig lo0 inet6 >/dev/null 2>&1
34} 34}
35 35
36network_start() 36network_start()
37{ 37{
38 # set hostname, turn on network 38 # set hostname, turn on network
39 # 39 #
40 echo "Starting network." 40 echo "Starting network."
41 41
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_wait_dad 53 network_wait_dad
54 network_start_resolv 54 network_start_resolv
55 network_start_local 55 network_start_local
56} 56}
57 57
58network_start_hostname() 58network_start_hostname()
59{ 59{
60 # If $hostname is set, use it for my Internet name, 60 # If $hostname is set, use it for my Internet name,
61 # otherwise use /etc/myname 61 # otherwise use /etc/myname
62 # 62 #
63 if [ -z "$hostname" ] && [ -f /etc/myname ]; then 63 if [ -z "$hostname" ] && [ -f /etc/myname ]; then
64 hostname=$(kat /etc/myname) 64 hostname=$(kat /etc/myname)
65 fi 65 fi
66 if [ -n "$hostname" ]; then 66 if [ -n "$hostname" ]; then
67 echo "Hostname: $hostname" 67 echo "Hostname: $hostname"
68 hostname $hostname 68 hostname $hostname
69 else 69 else
70 # Don't warn about it if we're going to run 70 # Don't warn about it if we're going to run
71 # DHCP later, as we will probably get the 71 # DHCP later, as we will probably get the
72 # hostname at that time. 72 # hostname at that time.
73 # 73 #
74 if ! checkyesno dhcpcd && \ 74 if ! checkyesno dhcpcd && \
75 [ -z "$(hostname)" ] 75 [ -z "$(hostname)" ]
76 then 76 then
77 warn "\$hostname not set." 77 warn "\$hostname not set."
78 fi 78 fi
79 fi 79 fi
80} 80}
81 81
82network_start_domainname() 82network_start_domainname()
83{ 83{
84 # Check $domainname first, then /etc/defaultdomain, 84 # Check $domainname first, then /etc/defaultdomain,
85 # for NIS/YP domain name 85 # for NIS/YP domain name
86 # 86 #
87 if [ -z "$domainname" ] && [ -f /etc/defaultdomain ]; then 87 if [ -z "$domainname" ] && [ -f /etc/defaultdomain ]; then
88 domainname=$(kat /etc/defaultdomain) 88 domainname=$(kat /etc/defaultdomain)
89 fi 89 fi
90 if [ -n "$domainname" ]; then 90 if [ -n "$domainname" ]; then
91 echo "NIS domainname: $domainname" 91 echo "NIS domainname: $domainname"
92 domainname $domainname 92 domainname $domainname
93 fi 93 fi
94 94
95 # Flush all routes just to make sure it is clean 95 # Flush all routes just to make sure it is clean
96 if checkyesno flushroutes; then 96 if checkyesno flushroutes; then
97 /sbin/route -qn flush 97 /sbin/route -qn flush
98 fi 98 fi
99} 99}
100 100
101network_start_loopback() 101network_start_loopback()
102{ 102{
103 # Set the address for the first loopback interface, so that the 103 # Set the address for the first loopback interface, so that the
104 # auto-route from a newly configured interface's address to lo0 104 # auto-route from a newly configured interface's address to lo0
105 # works correctly. 105 # works correctly.
106 # 106 #
107 # NOTE: obscure networking problems will occur if lo0 isn't configured. 107 # NOTE: obscure networking problems will occur if lo0 isn't configured.
108 # 108 #
109 /sbin/ifconfig lo0 inet 127.0.0.1 109 /sbin/ifconfig lo0 inet 127.0.0.1
110 110
111 # According to RFC1122, 127.0.0.0/8 must not leave the node. 111 # According to RFC1122, 127.0.0.0/8 must not leave the node.
112 # 112 #
113 /sbin/route -q add -inet 127.0.0.0 -netmask 0xff000000 127.0.0.1 -reject 113 /sbin/route -q add -inet 127.0.0.0 -netmask 0xff000000 127.0.0.1 -reject
114} 114}
115 115
116network_start_ipv6_route() 116network_start_ipv6_route()
117{ 117{
118 # IPv6 routing setups, and host/router mode selection. 118 # IPv6 routing setups, and host/router mode selection.
119 # 119 #
120 # We have IPv6 support in kernel. 120 # We have IPv6 support in kernel.
121 121
122 # disallow link-local unicast dest without outgoing scope 122 # disallow link-local unicast dest without outgoing scope
123 # identifiers. 123 # identifiers.
124 # 124 #
125 /sbin/route -q add -inet6 fe80:: -prefixlen 10 ::1 -reject 125 /sbin/route -q add -inet6 fe80:: -prefixlen 10 ::1 -reject
126 126
127 # disallow the use of the RFC3849 documentation address 127 # disallow the use of the RFC3849 documentation address
128 # 128 #
129 /sbin/route -q add -inet6 2001:db8:: -prefixlen 32 ::1 -reject 129 /sbin/route -q add -inet6 2001:db8:: -prefixlen 32 ::1 -reject
130 130
131 # IPv6 site-local scoped address prefix (fec0::/10) 131 # IPv6 site-local scoped address prefix (fec0::/10)
132 # has been deprecated by RFC3879. 132 # has been deprecated by RFC3879.
133 # 133 #
134 if [ -n "$ip6sitelocal" ]; then 134 if [ -n "$ip6sitelocal" ]; then
135 warn "\$ip6sitelocal is no longer valid" 135 warn "\$ip6sitelocal is no longer valid"
136 fi 136 fi
137 137
138 # disallow "internal" addresses to appear on the wire. 138 # disallow "internal" addresses to appear on the wire.
139 # 139 #
140 /sbin/route -q add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject 140 /sbin/route -q add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
141 141
142 # disallow packets to malicious IPv4 compatible prefix 142 # disallow packets to malicious IPv4 compatible prefix
143 # 143 #
144 /sbin/route -q add -inet6 ::224.0.0.0 -prefixlen 100 ::1 -reject 144 /sbin/route -q add -inet6 ::224.0.0.0 -prefixlen 100 ::1 -reject
145 /sbin/route -q add -inet6 ::127.0.0.0 -prefixlen 104 ::1 -reject 145 /sbin/route -q add -inet6 ::127.0.0.0 -prefixlen 104 ::1 -reject
146 /sbin/route -q add -inet6 ::0.0.0.0 -prefixlen 104 ::1 -reject 146 /sbin/route -q add -inet6 ::0.0.0.0 -prefixlen 104 ::1 -reject
147 /sbin/route -q add -inet6 ::255.0.0.0 -prefixlen 104 ::1 -reject 147 /sbin/route -q add -inet6 ::255.0.0.0 -prefixlen 104 ::1 -reject
148 148
149 # disallow packets to malicious 6to4 prefix 149 # disallow packets to malicious 6to4 prefix
150 # 150 #
151 /sbin/route -q add -inet6 2002:e000:: -prefixlen 20 ::1 -reject 151 /sbin/route -q add -inet6 2002:e000:: -prefixlen 20 ::1 -reject
152 /sbin/route -q add -inet6 2002:7f00:: -prefixlen 24 ::1 -reject 152 /sbin/route -q add -inet6 2002:7f00:: -prefixlen 24 ::1 -reject
153 /sbin/route -q add -inet6 2002:0000:: -prefixlen 24 ::1 -reject 153 /sbin/route -q add -inet6 2002:0000:: -prefixlen 24 ::1 -reject
154 /sbin/route -q add -inet6 2002:ff00:: -prefixlen 24 ::1 -reject 154 /sbin/route -q add -inet6 2002:ff00:: -prefixlen 24 ::1 -reject
155 155
156 # Completely disallow packets to IPv4 compatible prefix. 156 # Completely disallow packets to IPv4 compatible prefix.
157 # This may conflict with RFC1933 under following circumstances: 157 # This may conflict with RFC1933 under following circumstances:
158 # (1) An IPv6-only KAME node tries to originate packets to IPv4 158 # (1) An IPv6-only KAME node tries to originate packets to IPv4
159 # compatible destination. The KAME node has no IPv4 159 # compatible destination. The KAME node has no IPv4
160 # compatible support. Under RFC1933, it should transmit 160 # compatible support. Under RFC1933, it should transmit
161 # native IPv6 packets toward IPv4 compatible destination, 161 # native IPv6 packets toward IPv4 compatible destination,
162 # hoping it would reach a router that forwards the packet 162 # hoping it would reach a router that forwards the packet
163 # toward auto-tunnel interface. 163 # toward auto-tunnel interface.
164 # (2) An IPv6-only node originates a packet to IPv4 compatible 164 # (2) An IPv6-only node originates a packet to IPv4 compatible
165 # destination. A KAME node is acting as an IPv6 router, and 165 # destination. A KAME node is acting as an IPv6 router, and
166 # asked to forward it. 166 # asked to forward it.
167 # Due to rare use of IPv4 compatible address, and security 167 # Due to rare use of IPv4 compatible address, and security
168 # issues with it, we disable it by default. 168 # issues with it, we disable it by default.
169 # 169 #
170 /sbin/route -q add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject 170 /sbin/route -q add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
171 171
172 /sbin/sysctl -qw net.inet6.ip6.forwarding=0 172 /sbin/sysctl -qw net.inet6.ip6.forwarding=0
173 173
174 case $ip6mode in 174 case $ip6mode in
175 router) 175 router)
176 echo 'IPv6 mode: router' 176 echo 'IPv6 mode: router'
177 /sbin/sysctl -qw net.inet6.ip6.forwarding=1 177 /sbin/sysctl -qw net.inet6.ip6.forwarding=1
178 178
179 # disallow unique-local unicast forwarding without 179 # disallow unique-local unicast forwarding without
180 # explicit configuration. 180 # explicit configuration.
181 if ! checkyesno ip6uniquelocal; then 181 if ! checkyesno ip6uniquelocal; then
182 /sbin/route -q add -inet6 fc00:: -prefixlen 7 \ 182 /sbin/route -q add -inet6 fc00:: -prefixlen 7 \
183 ::1 -reject 183 ::1 -reject
184 fi 184 fi
185 ;; 185 ;;
186 186
187 autohost) 187 autohost)
188 if ! checkyesno dhcpcd; then 188 if ! checkyesno dhcpcd; then
189 warn "rtsol and kernel ra handling have been removed" 189 warn "rtsol and kernel ra handling have been removed"
190 warn "please configure dhcpcd in its place." 190 warn "please configure dhcpcd in its place."
191 fi 191 fi
192 ;; 192 ;;
193 193
194 host)  194 host)
195 echo 'IPv6 mode: host' 195 echo 'IPv6 mode: host'
196 ;; 196 ;;
197 197
198 *) warn "invalid \$ip6mode value "\"$ip6mode\" 198 *) warn "invalid \$ip6mode value "\"$ip6mode\"
199 ;; 199 ;;
200 200
201 esac 201 esac
202} 202}
203 203
204network_start_interfaces() 204network_start_interfaces()
205{ 205{
206 # Configure all of the network interfaces listed in $net_interfaces; 206 # Configure all of the network interfaces listed in $net_interfaces;
207 # if $auto_ifconfig is YES, grab all interfaces from ifconfig. 207 # if $auto_ifconfig is YES, grab all interfaces from ifconfig.
208 # In the following, "xxN" stands in for interface names, like "le0". 208 # In the following, "xxN" stands in for interface names, like "le0".
209 # 209 #
210 # For any interfaces that has an $ifconfig_xxN variable 210 # For any interfaces that has an $ifconfig_xxN variable
211 # associated, we break it into lines using ';' as a separator, 211 # associated, we break it into lines using ';' as a separator,
212 # then process it just like the contents of an /etc/ifconfig.xxN 212 # then process it just like the contents of an /etc/ifconfig.xxN
213 # file. 213 # file.
214 # 214 #
215 # For each line from the $ifconfig_xxN variable or the 215 # For each line from the $ifconfig_xxN variable or the
216 # /etc/ifconfig.xxN file, we ignore comments and blank lines, 216 # /etc/ifconfig.xxN file, we ignore comments and blank lines,
217 # treat lines beginning with "!" as commands to execute, treat 217 # treat lines beginning with "!" as commands to execute, treat
218 # "dhcp" as a special case to invoke dhcpcd, treat "rtsol" as 218 # "dhcp" as a special case to invoke dhcpcd, treat "rtsol" as
219 # a special case to send a router solicitation, and for any other 219 # a special case to send a router solicitation, and for any other
220 # line we run "ifconfig xxN", using each line of the file as the 220 # line we run "ifconfig xxN", using each line of the file as the
221 # arguments for a separate "ifconfig" invocation. 221 # arguments for a separate "ifconfig" invocation.
222 # 222 #
223 # In order to configure an interface reasonably, you at the very least 223 # In order to configure an interface reasonably, you at the very least
224 # need to specify "[addr_family] [hostname]" (e.g "inet my.domain.org"), 224 # need to specify "[addr_family] [hostname]" (e.g "inet my.domain.org"),
225 # and probably a netmask (as in "netmask 0xffffffe0"). You will 225 # and probably a netmask (as in "netmask 0xffffffe0"). You will
226 # frequently need to specify a media type, as in "media UTP", for 226 # frequently need to specify a media type, as in "media UTP", for
227 # interface cards with multiple media connections that do not 227 # interface cards with multiple media connections that do not
228 # autoconfigure. See the ifconfig manual page for details. 228 # autoconfigure. See the ifconfig manual page for details.
229 # 229 #
230 # Note that /etc/ifconfig.xxN takes multiple lines. The following 230 # Note that /etc/ifconfig.xxN takes multiple lines. The following
231 # configuration is possible: 231 # configuration is possible:
232 # inet 10.1.1.1 netmask 0xffffff00 232 # inet 10.1.1.1 netmask 0xffffff00
233 # inet 10.1.1.2 netmask 0xffffff00 alias 233 # inet 10.1.1.2 netmask 0xffffff00 alias
234 # inet6 2001:db8::1 prefixlen 64 alias 234 # inet6 2001:db8::1 prefixlen 64 alias
235 # 235 #
236 # You can put shell script fragment into /etc/ifconfig.xxN by 236 # You can put shell script fragment into /etc/ifconfig.xxN by
237 # starting a line with "!". Refer to ifconfig.if(5) for details. 237 # starting a line with "!". Refer to ifconfig.if(5) for details.
238 # 238 #
239 ifaces="$(/sbin/ifconfig -l)" 239 ifaces="$(/sbin/ifconfig -l)"
240 if checkyesno auto_ifconfig; then 240 if checkyesno auto_ifconfig; then
241 tmp="$ifaces" 241 tmp="$ifaces"
242 for cloner in $(/sbin/ifconfig -C); do 242 for cloner in $(/sbin/ifconfig -C); do
243 for int in /etc/ifconfig.${cloner}[0-9]*; do 243 for int in /etc/ifconfig.${cloner}[0-9]*; do
244 [ ! -f $int ] && break 244 [ ! -f $int ] && break
245 tmp="$tmp ${int##*.}" 245 tmp="$tmp ${int##*.}"
246 done 246 done
247 done 247 done
248 else 248 else
249 tmp="$net_interfaces" 249 tmp="$net_interfaces"
250 fi 250 fi
251 echo -n 'Configuring network interfaces:' 251 echo -n 'Configuring network interfaces:'
252 for int in $tmp; do 252 for int in $tmp; do
253 eval argslist=\$ifconfig_$int 253 eval argslist=\$ifconfig_$int
254 254
255 # Skip interfaces that do not have explicit 255 # Skip interfaces that do not have explicit
256 # configuration information. If auto_ifconfig is 256 # configuration information. If auto_ifconfig is
257 # false then also warn about such interfaces. 257 # false then also warn about such interfaces.
258 # 258 #
259 if [ -z "$argslist" ] && ! [ -f /etc/ifconfig.$int ] 259 if [ -z "$argslist" ] && ! [ -f /etc/ifconfig.$int ]
260 then 260 then
261 if ! checkyesno auto_ifconfig; then 261 if ! checkyesno auto_ifconfig; then
262 echo 262 echo
263 warn \ 263 warn \
264 "/etc/ifconfig.$int missing and ifconfig_$int not set;" 264 "/etc/ifconfig.$int missing and ifconfig_$int not set;"
265 warn "interface $int not configured." 265 warn "interface $int not configured."
266 fi 266 fi
267 continue 267 continue
268 fi 268 fi
269 269
270 echo -n " $int" 270 echo -n " $int"
271 271
272 # Create the interface if necessary. 272 # Create the interface if necessary.
273 # If the interface did not exist before, 273 # If the interface did not exist before,
274 # then also resync ipf(4). 274 # then also resync ipf(4).
275 # 275 #
276 if intmissing $int $ifaces; then 276 if intmissing $int $ifaces; then
277 if /sbin/ifconfig $int create && \ 277 if /sbin/ifconfig $int create && \
278 checkyesno ipfilter; then 278 checkyesno ipfilter; then
279 /sbin/ipf -y >/dev/null 279 /sbin/ipf -y >/dev/null
280 fi 280 fi
281 fi 281 fi
282 282
283 # If $ifconfig_xxN is empty, then use 283 # If $ifconfig_xxN is empty, then use
284 # /etc/ifconfig.xxN, which we know exists due to 284 # /etc/ifconfig.xxN, which we know exists due to
285 # an earlier test. 285 # an earlier test.
286 # 286 #
287 # If $ifconfig_xxN is non-empty and contains a 287 # If $ifconfig_xxN is non-empty and contains a
288 # newline, then just use it as is. (This allows 288 # newline, then just use it as is. (This allows
289 # semicolons through unmolested.) 289 # semicolons through unmolested.)
290 # 290 #
291 # If $ifconfig_xxN is non-empty and does not 291 # If $ifconfig_xxN is non-empty and does not
292 # contain a newline, then convert all semicolons 292 # contain a newline, then convert all semicolons
293 # to newlines. 293 # to newlines.
294 # 294 #
295 case "$argslist" in 295 case "$argslist" in
296 '') 296 '')
297 cat /etc/ifconfig.$int 297 cat /etc/ifconfig.$int
298 ;; 298 ;;
299 *"${nl}"*) 299 *"${nl}"*)
300 echo "$argslist" 300 echo "$argslist"
301 ;; 301 ;;
302 *) 302 *)
303 ( 303 (
304 set -o noglob 304 set -o noglob
305 IFS=';'; set -- $argslist 305 IFS=';'; set -- $argslist
306 #echo >&2 "[$#] [$1] [$2] [$3] [$4]" 306 #echo >&2 "[$#] [$1] [$2] [$3] [$4]"
307 IFS="$nl"; echo "$*" 307 IFS="$nl"; echo "$*"
308 ) 308 )
309 ;; 309 ;;
310 esac | 310 esac |
311 collapse_backslash_newline | 311 collapse_backslash_newline |
312 while read -r args; do 312 while read -r args; do
313 case "$args" in 313 case "$args" in
314 ''|"#"*|create) 314 ''|"#"*|create)
315 ;; 315 ;;
316 "!"*) 316 "!"*)
317 # Run arbitrary command in a subshell. 317 # Run arbitrary command in a subshell.
318 ( eval "${args#*!}" ) 318 ( eval "${args#*!}" )
319 ;; 319 ;;
320 dhcp) 320 dhcp)
321 if ! checkyesno dhcpcd; then 321 if ! checkyesno dhcpcd; then
322 /sbin/dhcpcd -n --dhcp \ 322 /sbin/dhcpcd -n --dhcp \
323 ${dhcpcd_flags} $int 323 ${dhcpcd_flags} $int
324 fi 324 fi
325 ;; 325 ;;
326 rtsol) 326 rtsol)
327 if ! checkyesno dhcpcd; then 327 if ! checkyesno dhcpcd; then
328 /sbin/dhcpcd -n --ipv6rs \ 328 /sbin/dhcpcd -n --ipv6rs \
329 ${dhcpcd_flags} $int 329 ${dhcpcd_flags} $int
330 fi 330 fi
331 ;; 331 ;;
332 *) 332 *)
333 # Pass args to ifconfig. Note 333 # Pass args to ifconfig. Note
334 # that args may contain embedded 334 # that args may contain embedded
335 # shell metacharacters, such as 335 # shell metacharacters, such as
336 # "ssid 'foo;*>bar'". We eval 336 # "ssid 'foo;*>bar'". We eval
337 # one more time so that things 337 # one more time so that things
338 # like ssid "Columbia University" work. 338 # like ssid "Columbia University" work.
339 ( 339 (
340 set -o noglob 340 set -o noglob
341 eval set -- $args 341 eval set -- $args
342 #echo >&2 "[$#] [$1] [$2] [$3]" 342 #echo >&2 "[$#] [$1] [$2] [$3]"
343 /sbin/ifconfig $int "$@" 343 /sbin/ifconfig $int "$@"
344 ) 344 )
345 ;; 345 ;;
346 esac 346 esac
347 done 347 done
348 configured_interfaces="$configured_interfaces $int" 348 configured_interfaces="$configured_interfaces $int"
349 done 349 done
350 echo "." 350 echo "."
351} 351}
352 352
353network_start_aliases() 353network_start_aliases()
354{ 354{
355 echo -n "Adding interface aliases:" 355 echo -n "Adding interface aliases:"
356 356
357 # Check if each configured interface xxN has an $ifaliases_xxN variable 357 # Check if each configured interface xxN has an $ifaliases_xxN variable
358 # associated, then configure additional IP addresses for that interface. 358 # associated, then configure additional IP addresses for that interface.
359 # The variable contains a list of "address netmask" pairs, with 359 # The variable contains a list of "address netmask" pairs, with
360 # "netmask" set to "-" if the interface default netmask is to be used. 360 # "netmask" set to "-" if the interface default netmask is to be used.
361 # 361 #
362 # Note that $ifaliases_xxN works only in certain cases and its 362 # Note that $ifaliases_xxN works only in certain cases and its
363 # use is not recommended. Use /etc/ifconfig.xxN or multiple 363 # use is not recommended. Use /etc/ifconfig.xxN or multiple
364 # commands in $ifconfig_xxN instead. 364 # commands in $ifconfig_xxN instead.
365 # 365 #
366 for int in lo0 $configured_interfaces; do 366 for int in lo0 $configured_interfaces; do
367 eval args=\$ifaliases_$int 367 eval args=\$ifaliases_$int
368 if [ -n "$args" ]; then 368 if [ -n "$args" ]; then
369 set -- $args 369 set -- $args
370 while [ $# -ge 2 ]; do 370 while [ $# -ge 2 ]; do
371 addr=$1 ; net=$2 ; shift 2 371 addr=$1 ; net=$2 ; shift 2
372 if [ "$net" = "-" ]; then 372 if [ "$net" = "-" ]; then
373 # for compatibility only, obsolete 373 # for compatibility only, obsolete
374 /sbin/ifconfig $int inet alias $addr 374 /sbin/ifconfig $int inet alias $addr
375 else 375 else
376 /sbin/ifconfig $int inet alias $addr \ 376 /sbin/ifconfig $int inet alias $addr \
377 netmask $net 377 netmask $net
378 fi 378 fi
379 echo -n " $int:$addr" 379 echo -n " $int:$addr"
380 done 380 done
381 fi 381 fi
382 done 382 done
383 383
384 # /etc/ifaliases, if it exists, contains the names of additional IP 384 # /etc/ifaliases, if it exists, contains the names of additional IP
385 # addresses for each interface. It is formatted as a series of lines 385 # addresses for each interface. It is formatted as a series of lines
386 # that contain 386 # that contain
387 # address interface netmask 387 # address interface netmask
388 # 388 #
389 # Note that /etc/ifaliases works only in certain cases and its 389 # Note that /etc/ifaliases works only in certain cases and its
390 # use is not recommended. Use /etc/ifconfig.xxN or multiple 390 # use is not recommended. Use /etc/ifconfig.xxN or multiple
391 # commands in $ifconfig_xxN instead. 391 # commands in $ifconfig_xxN instead.
392 # 392 #
393 if [ -f /etc/ifaliases ]; then 393 if [ -f /etc/ifaliases ]; then
394 while read addr int net; do 394 while read addr int net; do
395 if [ -z "$net" ]; then 395 if [ -z "$net" ]; then
396 # for compatibility only, obsolete 396 # for compatibility only, obsolete
397 /sbin/ifconfig $int inet alias $addr 397 /sbin/ifconfig $int inet alias $addr
398 else 398 else
399 /sbin/ifconfig $int inet alias $addr netmask $net 399 /sbin/ifconfig $int inet alias $addr netmask $net
400 fi 400 fi
401 done < /etc/ifaliases 401 done < /etc/ifaliases
402 fi 402 fi
403 403
404 echo "." # for "Adding interface aliases:" 404 echo "." # for "Adding interface aliases:"
405} 405}
406 406
407network_start_defaultroute() 407network_start_defaultroute()
408{ 408{
409 # Check $defaultroute, then /etc/mygate, for the name or address 409 # Check $defaultroute, then /etc/mygate, for the name or address
410 # of my IPv4 gateway host. If using a name, that name must be in 410 # of my IPv4 gateway host. If using a name, that name must be in
411 # /etc/hosts. 411 # /etc/hosts.
412 # 412 #
413 if [ -z "$defaultroute" ] && [ -f /etc/mygate ]; then 413 if [ -z "$defaultroute" ] && [ -f /etc/mygate ]; then
414 defaultroute=$(kat /etc/mygate) 414 defaultroute=$(kat /etc/mygate)
415 fi 415 fi
416 if [ -n "$defaultroute" ]; then 416 if [ -n "$defaultroute" ]; then
417 /sbin/route add default $defaultroute 417 /sbin/route add default $defaultroute
418 fi 418 fi
419} 419}
420 420
421network_start_defaultroute6() 421network_start_defaultroute6()
422{ 422{
423 # Check $defaultroute6, then /etc/mygate6, for the name or address 423 # Check $defaultroute6, then /etc/mygate6, for the name or address
424 # of my IPv6 gateway host. If using a name, that name must be in 424 # of my IPv6 gateway host. If using a name, that name must be in
425 # /etc/hosts. Note that the gateway host address must be a link-local 425 # /etc/hosts. Note that the gateway host address must be a link-local
426 # address if it is not using an stf* interface. 426 # address if it is not using an stf* interface.
427 # 427 #
428 if [ -z "$defaultroute6" ] && [ -f /etc/mygate6 ]; then 428 if [ -z "$defaultroute6" ] && [ -f /etc/mygate6 ]; then
429 defaultroute6=$(kat /etc/mygate6) 429 defaultroute6=$(kat /etc/mygate6)
430 fi 430 fi
431 if [ -n "$defaultroute6" ]; then 431 if [ -n "$defaultroute6" ]; then
432 if [ "$ip6mode" = "autohost" ]; then 432 if [ "$ip6mode" = "autohost" ]; then
433 echo 433 echo
434 warn \ 434 warn \
435 "ip6mode is set to 'autohost' and a v6 default route is also set." 435 "ip6mode is set to 'autohost' and a v6 default route is also set."
436 fi 436 fi
437 /sbin/route add -inet6 default $defaultroute6 437 /sbin/route add -inet6 default $defaultroute6
438 fi 438 fi
439} 439}
440 440
441network_wait_dad() 441network_wait_dad()
442{ 442{
443 # Wait for the DAD flags to clear from all addresses. 443 # Wait for the DAD flags to clear from all addresses.
444 if [ -n "$ifconfig_wait_dad_flags" ]; then 444 if [ -n "$ifconfig_wait_dad_flags" ]; then
445 echo "Waiting for duplicate address detection to finish..." 445 echo "Waiting for duplicate address detection to finish..."
446 ifconfig $ifconfig_wait_dad_flags 446 ifconfig $ifconfig_wait_dad_flags
447 fi 447 fi
448} 448}
449 449
450network_start_resolv() 450network_start_resolv()
451{ 451{
452 resconf= 452 resconf=
453 453
454 if [ -n "$dns_domain" ]; then 454 if [ -n "$dns_domain" ]; then
455 resconf="${resconf}domain $dns_domain$nl" 455 resconf="${resconf}domain $dns_domain$nl"
456 fi 456 fi
457 if [ -n "$dns_search" ]; then 457 if [ -n "$dns_search" ]; then
458 resconf="${resconf}search $dns_search$nl" 458 resconf="${resconf}search $dns_search$nl"
459 fi 459 fi
460 for n in $dns_nameservers; do 460 for n in $dns_nameservers; do
461 resconf="${resconf}nameserver $n$nl" 461 resconf="${resconf}nameserver $n$nl"
462 done 462 done
463 if [ -n "$dns_sortlist" ]; then 463 if [ -n "$dns_sortlist" ]; then
464 resconf="${resconf}sortlist $dns_sortlist$nl" 464 resconf="${resconf}sortlist $dns_sortlist$nl"
465 fi 465 fi
466 if [ -n "$dns_options" ]; then 466 if [ -n "$dns_options" ]; then
467 resconf="${resconf}options $dns_options$nl" 467 resconf="${resconf}options $dns_options$nl"
468 fi 468 fi
469 if [ -n "$resconf" ]; then 469 if [ -n "$resconf" ]; then
470 resconf="# Generated by /etc/rc.d/network$nl$resconf" 470 resconf="# Generated by /etc/rc.d/network$nl$resconf"
471 echo 'Configuring resolv.conf' 471 echo 'Configuring resolv.conf'
472 printf %s "$resconf" | resolvconf -m "${dns_metric:-0}" -a network 472 printf %s "$resconf" | resolvconf -m "${dns_metric:-0}" -a network
473 fi 473 fi
474} 474}
475 475
476network_start_local() 476network_start_local()
477{ 477{
478 # XXX this must die 478 # XXX this must die
479 if [ -s /etc/netstart.local ]; then 479 if [ -s /etc/netstart.local ]; then
480 sh /etc/netstart.local start 480 sh /etc/netstart.local start
481 fi 481 fi
482} 482}
483 483
484network_stop() 484network_stop()
485{ 485{
486 echo "Stopping network." 486 echo "Stopping network."
487 487
488 network_stop_local 488 network_stop_local
489 network_stop_resolv 489 network_stop_resolv
490 network_stop_aliases 490 network_stop_aliases
491 [ "$net_interfaces" != NO ] && 491 [ "$net_interfaces" != NO ] &&
492 network_stop_interfaces 492 network_stop_interfaces
493 network_stop_route 493 network_stop_route
494} 494}
495 495
496network_stop_local() 496network_stop_local()
497{ 497{
498 # XXX this must die 498 # XXX this must die
499 if [ -s /etc/netstart.local ]; then 499 if [ -s /etc/netstart.local ]; then
500 sh /etc/netstart.local stop 500 sh /etc/netstart.local stop
501 fi 501 fi
502} 502}
503 503
504network_stop_resolv() 504network_stop_resolv()
505{ 505{
506 resolvconf -f -d network 506 resolvconf -f -d network
507} 507}
508 508
509network_stop_aliases() 509network_stop_aliases()
510{ 510{
511 echo "Deleting aliases." 511 echo "Deleting aliases."
512 if [ -f /etc/ifaliases ]; then 512 if [ -f /etc/ifaliases ]; then
513 while read addr int net; do 513 while read addr int net; do
514 /sbin/ifconfig $int inet delete $addr 514 /sbin/ifconfig $int inet delete $addr
515 done < /etc/ifaliases 515 done < /etc/ifaliases
516 fi 516 fi
517 517
518 for int in $(/sbin/ifconfig -lu); do 518 for int in $(/sbin/ifconfig -lu); do
519 eval args=\$ifaliases_$int 519 eval args=\$ifaliases_$int
520 if [ -n "$args" ]; then 520 if [ -n "$args" ]; then
521 set -- $args 521 set -- $args
522 while [ $# -ge 2 ]; do 522 while [ $# -ge 2 ]; do
523 addr=$1 ; net=$2 ; shift 2 523 addr=$1 ; net=$2 ; shift 2
524 /sbin/ifconfig $int inet delete $addr 524 /sbin/ifconfig $int inet delete $addr
525 done 525 done
526 fi 526 fi
527 done 527 done
528} 528}
529 529
530network_stop_interfaces() 530network_stop_interfaces()
531{ 531{
532 # down interfaces 532 # down interfaces
533 # 533 #
534 echo -n 'Downing network interfaces:' 534 echo -n 'Downing network interfaces:'
535 if checkyesno auto_ifconfig; then 535 if checkyesno auto_ifconfig; then
536 tmp=$(/sbin/ifconfig -l) 536 tmp=$(/sbin/ifconfig -l)
537 else 537 else
538 tmp="$net_interfaces" 538 tmp="$net_interfaces"
539 fi 539 fi
540 for int in $tmp; do 540 for int in $tmp; do
541 eval args=\$ifconfig_$int 541 eval args=\$ifconfig_$int
542 if [ -n "$args" ] || [ -f /etc/ifconfig.$int ]; then 542 if [ -n "$args" ] || [ -f /etc/ifconfig.$int ]; then
543 echo -n " $int" 543 echo -n " $int"
544 if [ -f /var/run/dhcpcd-$int.pid ]; then 544 if [ -f /var/run/dhcpcd-$int.pid ]; then
545 /sbin/dhcpcd -k $int 2> /dev/null 545 /sbin/dhcpcd -k $int 2> /dev/null
546 fi 546 fi
547 /sbin/ifconfig $int down 547 /sbin/ifconfig $int down
548 if /sbin/ifconfig $int destroy 2>/dev/null && \ 548 if /sbin/ifconfig $int destroy 2>/dev/null && \
549 checkyesno ipfilter; then 549 checkyesno ipfilter; then
550 # resync ipf(4) 550 # resync ipf(4)
551 /sbin/ipf -y >/dev/null 551 /sbin/ipf -y >/dev/null
552 fi 552 fi
553 fi 553 fi
554 done 554 done
555 echo "." 555 echo "."
556} 556}
557 557
558network_stop_route() 558network_stop_route()
559{ 559{
560 # flush routes 560 # flush routes
561 # 561 #
562 if checkyesno flushroutes; then 562 if checkyesno flushroutes; then
563 /sbin/route -qn flush 563 /sbin/route -qn flush
564 fi 564 fi
565} 565}
566 566
567load_rc_config $name 567load_rc_config $name
568load_rc_config_var dhcpcd dhcpcd 568load_rc_config_var dhcpcd dhcpcd
569load_rc_config_var ipfilter ipfilter 569load_rc_config_var ipfilter ipfilter
570run_rc_command "$1" 570run_rc_command "$1"

cvs diff -r1.4 -r1.5 src/etc/rc.d/npf (switch to unified diff)

--- src/etc/rc.d/npf 2019/04/19 18:36:25 1.4
+++ src/etc/rc.d/npf 2020/07/04 06:24:53 1.5
@@ -1,66 +1,66 @@ @@ -1,66 +1,66 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: npf,v 1.4 2019/04/19 18:36:25 leot Exp $ 3# $NetBSD: npf,v 1.5 2020/07/04 06:24:53 skrll Exp $
4# 4#
5# Public Domain. 5# Public Domain.
6# 6#
7 7
8# PROVIDE: npf 8# PROVIDE: npf
9# REQUIRE: root bootconf mountcritlocal tty network 9# REQUIRE: root bootconf mountcritlocal tty network
10# BEFORE: NETWORKING 10# BEFORE: NETWORKING
11 11
12$_rc_subr_loaded . /etc/rc.subr 12$_rc_subr_loaded . /etc/rc.subr
13 13
14name="npf" 14name="npf"
15rcvar=$name 15rcvar=$name
16 16
17config="/etc/npf.conf" 17config="/etc/npf.conf"
18 18
19start_cmd="npf_start" 19start_cmd="npf_start"
20stop_cmd="npf_stop" 20stop_cmd="npf_stop"
21 21
22reload_cmd="npf_reload" 22reload_cmd="npf_reload"
23status_cmd="npf_status" 23status_cmd="npf_status"
24extra_commands="reload status" 24extra_commands="reload status"
25 25
26npf_cfg_check() 26npf_cfg_check()
27{ 27{
28 if [ ! -f ${config} ]; then 28 if [ ! -f ${config} ]; then
29 warn "${config} is not readable; failed." 29 warn "${config} is not readable; failed."
30 exit 1  30 exit 1
31 fi 31 fi
32} 32}
33 33
34npf_start() 34npf_start()
35{ 35{
36 echo "Enabling NPF." 36 echo "Enabling NPF."
37 npf_cfg_check 37 npf_cfg_check
38 /sbin/npfctl reload 38 /sbin/npfctl reload
39 39
40 # The npf_boot script has enabled npf already. 40 # The npf_boot script has enabled npf already.
41 if [ "$autoboot" != "yes" ]; then 41 if [ "$autoboot" != "yes" ]; then
42 /sbin/npfctl start 42 /sbin/npfctl start
43 fi 43 fi
44} 44}
45 45
46npf_stop() 46npf_stop()
47{ 47{
48 echo "Disabling NPF." 48 echo "Disabling NPF."
49 /sbin/npfctl stop 49 /sbin/npfctl stop
50 /sbin/npfctl flush 50 /sbin/npfctl flush
51} 51}
52 52
53npf_reload() 53npf_reload()
54{ 54{
55 echo "Reloading NPF ruleset." 55 echo "Reloading NPF ruleset."
56 npf_cfg_check 56 npf_cfg_check
57 /sbin/npfctl reload 57 /sbin/npfctl reload
58} 58}
59 59
60npf_status() 60npf_status()
61{ 61{
62 : 62 :
63} 63}
64 64
65load_rc_config $name 65load_rc_config $name
66run_rc_command "$1" 66run_rc_command "$1"

cvs diff -r1.16 -r1.17 src/etc/rc.d/ntpd (switch to unified diff)

--- src/etc/rc.d/ntpd 2015/11/23 19:56:47 1.16
+++ src/etc/rc.d/ntpd 2020/07/04 06:24:53 1.17
@@ -1,81 +1,81 @@ @@ -1,81 +1,81 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: ntpd,v 1.16 2015/11/23 19:56:47 christos Exp $ 3# $NetBSD: ntpd,v 1.17 2020/07/04 06:24:53 skrll Exp $
4# 4#
5 5
6# PROVIDE: ntpd 6# PROVIDE: ntpd
7# REQUIRE: DAEMON 7# REQUIRE: DAEMON
8# BEFORE: LOGIN 8# BEFORE: LOGIN
9# KEYWORD: chrootdir 9# KEYWORD: chrootdir
10 10
11$_rc_subr_loaded . /etc/rc.subr 11$_rc_subr_loaded . /etc/rc.subr
12 12
13name="ntpd" 13name="ntpd"
14rcvar=$name 14rcvar=$name
15command="/usr/sbin/${name}" 15command="/usr/sbin/${name}"
16pidfile="/var/run/${name}.pid" 16pidfile="/var/run/${name}.pid"
17start_precmd="ntpd_precmd" 17start_precmd="ntpd_precmd"
18required_files="/etc/ntp.conf" 18required_files="/etc/ntp.conf"
19 19
20ntpd_precmd() 20ntpd_precmd()
21{ 21{
22 rc_flags="-p ${pidfile} $rc_flags" 22 rc_flags="-p ${pidfile} $rc_flags"
23 if [ -z "$ntpd_chrootdir" ]; then 23 if [ -z "$ntpd_chrootdir" ]; then
24 return 0; 24 return 0;
25 fi 25 fi
26 26
27 # If running in a chroot cage, ensure that the appropriate files 27 # If running in a chroot cage, ensure that the appropriate files
28 # exist inside the cage, as well as helper symlinks into the cage  28 # exist inside the cage, as well as helper symlinks into the cage
29 # from outside. 29 # from outside.
30 # 30 #
31 # As this is called after the is_running and required_dir checks 31 # As this is called after the is_running and required_dir checks
32 # are made in run_rc_command(), we can safely assume ${ntpd_chrootdir} 32 # are made in run_rc_command(), we can safely assume ${ntpd_chrootdir}
33 # exists and ntpd isn't running at this point (unless forcestart 33 # exists and ntpd isn't running at this point (unless forcestart
34 # is used). 34 # is used).
35 # 35 #
36 # Before enabling ntpd_chrootdir, ensure that: 36 # Before enabling ntpd_chrootdir, ensure that:
37 # - The kernel has "pseudo-device clockctl" compiled in 37 # - The kernel has "pseudo-device clockctl" compiled in
38 # - /dev/clockctl is present 38 # - /dev/clockctl is present
39 # 39 #
40 if (: </dev/clockctl) 2>/dev/null; then 40 if (: </dev/clockctl) 2>/dev/null; then
41 : exists and works 41 : exists and works
42 else 42 else
43 logger -s -p daemon.warning -t ntpd \ 43 logger -s -p daemon.warning -t ntpd \
44 "WARNING: not chrooting -- no working /dev/clockctl device" 44 "WARNING: not chrooting -- no working /dev/clockctl device"
45 return 0 45 return 0
46 fi 46 fi
47 if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then 47 if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then
48 rm -f "${ntpd_chrootdir}/dev/clockctl" 48 rm -f "${ntpd_chrootdir}/dev/clockctl"
49 ( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" ) 49 ( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" )
50 fi 50 fi
51 ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift 51 ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift
52 52
53 if [ ! -d "${ntpd_chrootdir}/etc" ]; then 53 if [ ! -d "${ntpd_chrootdir}/etc" ]; then
54 mkdir "${ntpd_chrootdir}/etc" 54 mkdir "${ntpd_chrootdir}/etc"
55 fi 55 fi
56 56
57 for f in resolv.conf; do 57 for f in resolv.conf; do
58 if ! cmp -s "/etc/$f" "${ntpd_chrootdir}/etc/$f"; then 58 if ! cmp -s "/etc/$f" "${ntpd_chrootdir}/etc/$f"; then
59 cp -p "/etc/$f" "${ntpd_chrootdir}/etc/$f" 59 cp -p "/etc/$f" "${ntpd_chrootdir}/etc/$f"
60 fi 60 fi
61 done 61 done
62 62
63 if [ ! -f "${ntpd_chrootdir}/etc/services" ]; then 63 if [ ! -f "${ntpd_chrootdir}/etc/services" ]; then
64 getent services ntp/udp ntp/tcp \ 64 getent services ntp/udp ntp/tcp \
65 > "${ntpd_chrootdir}/etc/services" 65 > "${ntpd_chrootdir}/etc/services"
66 fi 66 fi
67 if [ ! -d "${ntpd_chrootdir}/var/db" ]; then 67 if [ ! -d "${ntpd_chrootdir}/var/db" ]; then
68 mkdir -p "${ntpd_chrootdir}/var/db" 68 mkdir -p "${ntpd_chrootdir}/var/db"
69 fi 69 fi
70 if [ ! -f "${ntpd_chrootdir}/var/db/services.cdb" ]; then 70 if [ ! -f "${ntpd_chrootdir}/var/db/services.cdb" ]; then
71 services_mkdb -o "${ntpd_chrootdir}/var/db/services.cdb" \ 71 services_mkdb -o "${ntpd_chrootdir}/var/db/services.cdb" \
72 "${ntpd_chrootdir}/etc/services" 72 "${ntpd_chrootdir}/etc/services"
73 fi 73 fi
74 74
75 # Change run_rc_commands()'s internal copy of $ntpd_flags 75 # Change run_rc_commands()'s internal copy of $ntpd_flags
76 # 76 #
77 rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags" 77 rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags"
78} 78}
79 79
80load_rc_config $name 80load_rc_config $name
81run_rc_command "$1" 81run_rc_command "$1"

cvs diff -r1.11 -r1.12 src/etc/rc.d/pf (switch to unified diff)

--- src/etc/rc.d/pf 2018/06/29 12:34:15 1.11
+++ src/etc/rc.d/pf 2020/07/04 06:24:53 1.12
@@ -1,70 +1,70 @@ @@ -1,70 +1,70 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: pf,v 1.11 2018/06/29 12:34:15 roy Exp $ 3# $NetBSD: pf,v 1.12 2020/07/04 06:24:53 skrll Exp $
4# 4#
5 5
6# PROVIDE: pf 6# PROVIDE: pf
7# REQUIRE: root bootconf mountcritlocal tty network dhcpcd 7# REQUIRE: root bootconf mountcritlocal tty network dhcpcd
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="pf" 12name="pf"
13rcvar=$name 13rcvar=$name
14start_precmd="pf_prestart" 14start_precmd="pf_prestart"
15start_cmd="pf_start" 15start_cmd="pf_start"
16stop_cmd="pf_stop" 16stop_cmd="pf_stop"
17reload_cmd="pf_reload" 17reload_cmd="pf_reload"
18status_cmd="pf_status" 18status_cmd="pf_status"
19extra_commands="reload status" 19extra_commands="reload status"
20 20
21pf_prestart() 21pf_prestart()
22{ 22{
23 if [ ! -f ${pf_rules} ]; then 23 if [ ! -f ${pf_rules} ]; then
24 warn "${pf_rules} not readable; pf start aborted." 24 warn "${pf_rules} not readable; pf start aborted."
25 25
26 stop_boot 26 stop_boot
27 return 1 27 return 1
28 fi 28 fi
29 return 0 29 return 0
30} 30}
31 31
32pf_start() 32pf_start()
33{ 33{
34 echo "Enabling pf firewall." 34 echo "Enabling pf firewall."
35 35
36 # The pf_boot script has enabled pf already. 36 # The pf_boot script has enabled pf already.
37 if [ "$autoboot" != yes ]; then 37 if [ "$autoboot" != yes ]; then
38 /sbin/pfctl -q ${pf_flags} -e  38 /sbin/pfctl -q ${pf_flags} -e
39 fi 39 fi
40 40
41 if [ -f ${pf_rules} ]; then 41 if [ -f ${pf_rules} ]; then
42 /sbin/pfctl -q ${pf_flags} -f ${pf_rules} 42 /sbin/pfctl -q ${pf_flags} -f ${pf_rules}
43 else 43 else
44 warn "${pf_rules} not found; no pf rules loaded." 44 warn "${pf_rules} not found; no pf rules loaded."
45 fi 45 fi
46} 46}
47 47
48pf_stop() 48pf_stop()
49{ 49{
50 echo "Disabling pf firewall." 50 echo "Disabling pf firewall."
51 /sbin/pfctl -q ${pf_flags} -Fa -d 51 /sbin/pfctl -q ${pf_flags} -Fa -d
52} 52}
53 53
54pf_reload() 54pf_reload()
55{ 55{
56 echo "Reloading pf rules." 56 echo "Reloading pf rules."
57 if [ -f ${pf_rules} ]; then 57 if [ -f ${pf_rules} ]; then
58 /sbin/pfctl -q ${pf_flags} -f ${pf_rules} 58 /sbin/pfctl -q ${pf_flags} -f ${pf_rules}
59 else 59 else
60 warn "${pf_rules} not found; no pf rules loaded." 60 warn "${pf_rules} not found; no pf rules loaded."
61 fi 61 fi
62} 62}
63 63
64pf_status() 64pf_status()
65{ 65{
66 /sbin/pfctl ${pf_flags} -s info 66 /sbin/pfctl ${pf_flags} -s info
67} 67}
68 68
69load_rc_config $name 69load_rc_config $name
70run_rc_command "$1" 70run_rc_command "$1"

cvs diff -r1.10 -r1.11 src/etc/rc.d/rtadvd (switch to unified diff)

--- src/etc/rc.d/rtadvd 2016/11/19 01:14:58 1.10
+++ src/etc/rc.d/rtadvd 2020/07/04 06:24:53 1.11
@@ -1,79 +1,79 @@ @@ -1,79 +1,79 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: rtadvd,v 1.10 2016/11/19 01:14:58 kre Exp $ 3# $NetBSD: rtadvd,v 1.11 2020/07/04 06:24:53 skrll Exp $
4# 4#
5 5
6# PROVIDE: rtadvd 6# PROVIDE: rtadvd
7# REQUIRE: DAEMON 7# REQUIRE: DAEMON
8# BEFORE: LOGIN 8# BEFORE: LOGIN
9 9
10$_rc_subr_loaded . /etc/rc.subr 10$_rc_subr_loaded . /etc/rc.subr
11 11
12name=rtadvd 12name=rtadvd
13rcvar=$name 13rcvar=$name
14command="/usr/sbin/$name" 14command="/usr/sbin/$name"
15pidfile="/var/run/$name.pid" 15pidfile="/var/run/$name.pid"
16extra_commands=reload 16extra_commands=reload
17start_precmd=rtadvd_prestart 17start_precmd=rtadvd_prestart
18reload_precmd=rtadvd_prereload 18reload_precmd=rtadvd_prereload
19 19
20rtadvd_prereload() 20rtadvd_prereload()
21{ 21{
22 local chdir="$(getent passwd _rtadvd | cut -d: -f6)" 22 local chdir="$(getent passwd _rtadvd | cut -d: -f6)"
23 local conf=/etc/rtadvd.conf myflags o confdir 23 local conf=/etc/rtadvd.conf myflags o confdir
24 local cflag=false 24 local cflag=false
25  25
26 [ -z "${chdir}" ] || [ "/${chdir}" = // ] && return 0 26 [ -z "${chdir}" ] || [ "/${chdir}" = // ] && return 0
27 27
28 if [ -n "${flags}" ]; then 28 if [ -n "${flags}" ]; then
29 myflags=${flags} 29 myflags=${flags}
30 else 30 else
31 eval myflags=\$${name}_flags 31 eval myflags=\$${name}_flags
32 fi 32 fi
33 set -- ${myflags} 33 set -- ${myflags}
34 while getopts c:dDfM:Rs o; do 34 while getopts c:dDfM:Rs o; do
35 # ignore other args, they are processed by rtadvd itself 35 # ignore other args, they are processed by rtadvd itself
36 case "${o}" in 36 case "${o}" in
37 c) conf="${OPTARG}" 37 c) conf="${OPTARG}"
38 case "${conf}" in 38 case "${conf}" in
39 /*) ;; 39 /*) ;;
40 *) echo "${name}: config file (${conf}) must be" \ 40 *) echo "${name}: config file (${conf}) must be" \
41 "full pathname" 41 "full pathname"
42 return 1 42 return 1
43 ;; 43 ;;
44 esac 44 esac
45 cflag=true;; 45 cflag=true;;
46 esac 46 esac
47 done 47 done
48 48
49 ${cflag} || test -f "${conf}" && { 49 ${cflag} || test -f "${conf}" && {
50 confdir=$(dirname "${conf}") 50 confdir=$(dirname "${conf}")
51 echo "${name}: copying ${conf} to ${chdir}${conf}" 51 echo "${name}: copying ${conf} to ${chdir}${conf}"
52 mkdir -p "${chdir}${confdir}" 52 mkdir -p "${chdir}${confdir}"
53 cp "${conf}" "${chdir}${conf}" || return 1 53 cp "${conf}" "${chdir}${conf}" || return 1
54 } 54 }
55 55
56 # Make sure /var/run exists in the chroot 56 # Make sure /var/run exists in the chroot
57 mkdir -p "${chdir}/var/run" 57 mkdir -p "${chdir}/var/run"
58 58
59 # Provide a link to the chrooted dump file 59 # Provide a link to the chrooted dump file
60 ln -snf "${chdir}/var/run/${name}.dump" /var/run 60 ln -snf "${chdir}/var/run/${name}.dump" /var/run
61 61
62 # Note: actual chroot is done by rtadvd itself 62 # Note: actual chroot is done by rtadvd itself
63 63
64 return 0 64 return 0
65} 65}
66 66
67rtadvd_prestart() 67rtadvd_prestart()
68{ 68{
69 if [ "$ip6mode" != router ]; then 69 if [ "$ip6mode" != router ]; then
70 warn \ 70 warn \
71 "${name} cannot be used on IPv6 host, only on an IPv6 router." 71 "${name} cannot be used on IPv6 host, only on an IPv6 router."
72 return 1 72 return 1
73 fi 73 fi
74 74
75 rtadvd_prereload 75 rtadvd_prereload
76} 76}
77 77
78load_rc_config $name 78load_rc_config $name
79run_rc_command "$1" 79run_rc_command "$1"