Annotation of src/etc/rc, Revision 1.562
1.562 ! deraadt 1: # $OpenBSD: rc,v 1.561 2022/07/17 03:17:37 deraadt Exp $
1.1 deraadt 2:
1.450 rpe 3: # System startup script run by init on autoboot or after single-user.
4: # Output and error are redirected to console by init, and the console is the
5: # controlling terminal.
1.454 rpe 6:
7: # Turn off Strict Bourne shell.
8: set +o sh
1.1 deraadt 9:
1.131 millert 10: # Subroutines (have to come first).
11:
1.456 rpe 12: # Strip in- and whole-line comments from a file.
13: # Strip leading and trailing whitespace if IFS is set.
14: # Usage: stripcom /path/to/file
1.131 millert 15: stripcom() {
1.456 rpe 16: local _file=$1 _line
1.131 millert 17:
1.456 rpe 18: [[ -s $_file ]] || return
19:
20: while read _line ; do
21: _line=${_line%%#*}
22: [[ -n $_line ]] && print -r -- "$_line"
23: done <$_file
1.131 millert 24: }
25:
1.456 rpe 26: # Update resource limits based on login.conf settings.
27: # Usage: update_limit -flag capability
1.265 millert 28: update_limit() {
1.456 rpe 29: local _flag=$1 # ulimit flag
30: local _cap=$2 _val # login.conf capability and its value
31: local _suffix
32:
1.490 otto 33: for _suffix in {,-max,-cur}; do
1.456 rpe 34: _val=$(getcap -f /etc/login.conf -s ${_cap}${_suffix} daemon 2>/dev/null)
35: [[ -n $_val ]] || continue
36: [[ $_val == infinity ]] && _val=unlimited
37:
38: case $_suffix in
39: -cur) ulimit -S $_flag $_val
40: ;;
41: -max) ulimit -H $_flag $_val
42: ;;
43: *) ulimit $_flag $_val
44: return
45: ;;
46: esac
1.265 millert 47: done
48: }
49:
1.457 rpe 50: # Apply sysctl.conf(5) settings.
1.265 millert 51: sysctl_conf() {
1.520 bluhm 52: # do not use a pipe as limits would only be applied to the subshell
53: set -- $(stripcom /etc/sysctl.conf)
54: while [[ $# > 0 ]] ; do
55: sysctl "$1"
1.267 millert 56:
1.520 bluhm 57: case "$1" in
1.265 millert 58: kern.maxproc=*)
1.520 bluhm 59: update_limit -p maxproc
60: ;;
1.265 millert 61: kern.maxfiles=*)
1.520 bluhm 62: update_limit -n openfiles
63: ;;
1.265 millert 64: esac
1.520 bluhm 65: shift
1.265 millert 66: done
67: }
68:
1.457 rpe 69: # Apply mixerctl.conf(5) settings.
1.452 rpe 70: mixerctl_conf() {
1.457 rpe 71: stripcom /etc/mixerctl.conf |
72: while read _line; do
73: mixerctl -q "$_line" 2>/dev/null
1.265 millert 74: done
75: }
76:
1.457 rpe 77: # Apply wsconsctl.conf(5) settings.
1.452 rpe 78: wsconsctl_conf() {
1.457 rpe 79: [[ -x /sbin/wsconsctl ]] || return
1.267 millert 80:
1.457 rpe 81: stripcom /etc/wsconsctl.conf |
82: while read _line; do
1.458 rpe 83: eval "wsconsctl $_line"
1.267 millert 84: done
85: }
86:
1.495 rpe 87: # Push the old seed into the kernel, create a future seed and create a seed
88: # file for the boot-loader.
1.452 rpe 89: random_seed() {
1.427 bluhm 90: dd if=/var/db/host.random of=/dev/random bs=65536 count=1 status=none
91: chmod 600 /var/db/host.random
92: dd if=/dev/random of=/var/db/host.random bs=65536 count=1 status=none
93: dd if=/dev/random of=/etc/random.seed bs=512 count=1 status=none
94: chmod 600 /etc/random.seed
1.312 djm 95: }
96:
1.450 rpe 97: # Populate net.inet.(tcp|udp).baddynamic with the contents of /etc/services so
98: # as to avoid randomly allocating source ports that correspond to well-known
1.451 rpe 99: # services.
1.459 rpe 100: # Usage: fill_baddynamic tcp|udp
1.452 rpe 101: fill_baddynamic() {
1.390 halex 102: local _service=$1
1.318 djm 103: local _sysctl="net.inet.${_service}.baddynamic"
1.459 rpe 104:
1.390 halex 105: stripcom /etc/services |
106: {
1.459 rpe 107: _ban=
1.390 halex 108: while IFS=" /" read _name _port _srv _junk; do
1.459 rpe 109: [[ $_srv == $_service ]] || continue
110:
111: _ban="${_ban:+$_ban,}+$_port"
112:
1.390 halex 113: # Flush before argv gets too long
1.459 rpe 114: if ((${#_ban} > 1024)); then
115: sysctl -q "$_sysctl=$_ban"
116: _ban=
1.390 halex 117: fi
118: done
1.459 rpe 119: [[ -n $_ban ]] && sysctl -q "$_sysctl=$_ban"
1.390 halex 120: }
1.318 djm 121: }
122:
1.450 rpe 123: # Start daemon using the rc.d daemon control scripts.
1.451 rpe 124: # Usage: start_daemon daemon1 daemon2 daemon3
1.452 rpe 125: start_daemon() {
1.460 rpe 126: local _daemon
127:
128: for _daemon; do
129: eval "_do=\${${_daemon}_flags}"
130: [[ $_do != NO ]] && /etc/rc.d/${_daemon} start
1.353 robert 131: done
132: }
133:
1.469 tim 134: # Generate keys for isakmpd, iked and sshd if they don't exist yet.
1.452 rpe 135: make_keys() {
1.460 rpe 136: local _isakmpd_key=/etc/isakmpd/private/local.key
137: local _isakmpd_pub=/etc/isakmpd/local.pub
138: local _iked_key=/etc/iked/private/local.key
139: local _iked_pub=/etc/iked/local.pub
140:
141: if [[ ! -f $_isakmpd_key ]]; then
1.560 tobhe 142: echo -n "openssl: generating isakmpd RSA keys... "
1.460 rpe 143: if openssl genrsa -out $_isakmpd_key 2048 >/dev/null 2>&1 &&
144: chmod 600 $_isakmpd_key &&
145: openssl rsa -out $_isakmpd_pub -in $_isakmpd_key \
146: -pubout >/dev/null 2>&1; then
1.373 deraadt 147: echo done.
148: else
149: echo failed.
150: fi
151: fi
152:
1.460 rpe 153: if [[ ! -f $_iked_key ]]; then
1.560 tobhe 154: echo -n "openssl: generating iked ECDSA keys... "
155: if openssl ecparam -genkey -name prime256v1 -out $_iked_key >/dev/null 2>&1 &&
156: chmod 600 $_iked_key &&
157: openssl ec -out $_iked_pub -in $_iked_key \
158: -pubout >/dev/null 2>&1; then
159: echo done.
160: else
161: echo failed.
162: fi
1.373 deraadt 163: fi
164:
165: ssh-keygen -A
1.524 florian 166:
167: if [[ ! -f /etc/soii.key ]]; then
1.525 rpe 168: openssl rand -hex 16 > /etc/soii.key &&
1.524 florian 169: chmod 600 /etc/soii.key && sysctl -q \
170: "net.inet6.ip6.soiikey=$(</etc/soii.key)"
171: fi
1.373 deraadt 172: }
173:
1.483 rpe 174: # Re-link libraries, placing the objects in a random order.
1.481 rpe 175: reorder_libs() {
1.521 rpe 176: local _error=false _dkdev _liba _libas _mp _ro_list _tmpdir
1.522 rpe 177: local _relink=/usr/share/relink
1.498 tb 178:
179: [[ $library_aslr == NO ]] && return
180:
1.521 rpe 181: # Skip if /usr/lib, /usr/libexec or /usr/share/relink are on nfs mounted
182: # filesystems, otherwise record which ones are mounted read-only.
1.533 kn 183: for _dkdev in $(df /usr/{lib,libexec} $_relink |
184: sed '1d;s/ .*//' | sort -u); do
185: _mp=$(mount -t ffs | grep "^$_dkdev") || return
186: if [[ $_mp == *read-only* ]]; then
187: _ro_list="$_ro_list ${_mp%% *}"
1.521 rpe 188: fi
189: done
1.484 rpe 190:
1.481 rpe 191: echo -n 'reordering libraries:'
1.523 tb 192:
1.556 jsg 193: # Remount the (read-only) filesystems in _ro_list as read-write.
1.521 rpe 194: for _mp in $_ro_list; do
195: if ! mount -u -w $_mp; then
1.481 rpe 196: echo ' failed.'
197: return
198: fi
1.521 rpe 199: done
1.509 tb 200:
201: # Only choose the latest version of the libraries.
1.522 rpe 202: for _liba in $_relink/usr/lib/lib{c,crypto}; do
1.513 zhuk 203: _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -rV | head -1)"
1.509 tb 204: done
1.481 rpe 205:
1.522 rpe 206: for _liba in $_relink/usr/libexec/ld.so.a $_libas; do
207: _tmpdir=$(mktemp -dq $_relink/_rebuild.XXXXXXXXXXXX) &&
1.517 rpe 208: (
209: set -o errexit
1.534 kn 210: _install='install -F -o root -g bin -m 0444'
1.517 rpe 211: _lib=${_liba##*/}
212: _lib=${_lib%.a}
1.522 rpe 213: _lib_dir=${_liba#$_relink}
1.523 tb 214: _lib_dir=${_lib_dir%/*}
1.517 rpe 215: cd $_tmpdir
216: ar x $_liba
217: if [[ $_lib == ld.so ]]; then
1.537 guenther 218: args="-g -x -e _dl_start \
1.517 rpe 219: --version-script=Symbols.map --shared -Bsymbolic \
1.537 guenther 220: --no-undefined"
221: [[ -f ld.script ]] && args="$args -T ld.script"
222: ld $args -o ld.so.test $(ls *.o | sort -R)
1.517 rpe 223: chmod u+x test-ld.so
224: [[ $(./test-ld.so ok) == './test-ld.so: ok!' ]]
225: $_install /usr/libexec/ld.so /usr/libexec/ld.so.save
1.521 rpe 226: $_install ld.so.test $_lib_dir/ld.so
1.517 rpe 227: else
1.541 naddy 228: cc -shared -o $_lib $(ls *.so | sort -R) $(<.ldadd)
1.475 deraadt 229: [[ -s $_lib ]] && file $_lib | fgrep -q 'shared object'
230: LD_BIND_NOW=1 LD_LIBRARY_PATH=$_tmpdir awk 'BEGIN {exit 0}'
1.500 deraadt 231: LD_BIND_NOW=1 LD_LIBRARY_PATH=$_tmpdir openssl \
232: x509 -in /etc/ssl/cert.pem -out /dev/null
1.521 rpe 233: $_install $_lib $_lib_dir/$_lib
1.517 rpe 234: fi
1.485 rpe 235: ) || { _error=true; break; }
1.475 deraadt 236: done
1.481 rpe 237:
1.522 rpe 238: rm -rf $_relink/_rebuild.*
1.485 rpe 239:
1.481 rpe 240: # Restore previous mount state if it was changed.
1.521 rpe 241: for _mp in $_ro_list; do
242: mount -u -r $_mp || _error=true
243: done
1.482 deraadt 244:
1.485 rpe 245: if $_error; then
246: echo ' failed.'
247: else
248: echo ' done.'
249: fi
1.475 deraadt 250: }
251:
1.483 rpe 252: # Run rc.* script and email output to root.
253: # Usage: run_upgrade_script firsttime|sysmerge
1.477 ajacouto 254: run_upgrade_script() {
255: local _suffix=$1
1.491 rpe 256:
1.477 ajacouto 257: [[ -n $_suffix ]] || return 1
1.491 rpe 258:
1.477 ajacouto 259: if [[ -f /etc/rc.$_suffix ]]; then
1.516 ajacouto 260: echo "running rc.$_suffix"
1.477 ajacouto 261: mv /etc/rc.$_suffix /etc/rc.$_suffix.run
262: . /etc/rc.$_suffix.run 2>&1 | tee /dev/tty |
263: mail -Es "$(hostname) rc.$_suffix output" root >/dev/null
264: fi
265: rm -f /etc/rc.$_suffix.run
266: }
267:
1.462 rpe 268: # Check filesystems, optionally by using a fsck(8) flag.
269: # Usage: do_fsck [-flag]
1.452 rpe 270: do_fsck() {
1.462 rpe 271: fsck -p "$@"
1.429 claudio 272: case $? in
1.462 rpe 273: 0) ;;
274: 2) exit 1
1.429 claudio 275: ;;
1.462 rpe 276: 4) echo "Rebooting..."
1.429 claudio 277: reboot
278: echo "Reboot failed; help!"
279: exit 1
280: ;;
1.462 rpe 281: 8) echo "Automatic file system check failed; help!"
1.429 claudio 282: exit 1
283: ;;
1.462 rpe 284: 12) echo "Boot interrupted."
1.429 claudio 285: exit 1
286: ;;
1.462 rpe 287: 130) # Interrupt before catcher installed.
1.429 claudio 288: exit 1
289: ;;
1.462 rpe 290: *) echo "Unknown error; help!"
1.429 claudio 291: exit 1
292: ;;
293: esac
294: }
295:
1.450 rpe 296: # End subroutines.
1.131 millert 297:
1.1 deraadt 298: stty status '^T'
299:
1.450 rpe 300: # Set shell to ignore SIGINT (2), but not children; shell catches SIGQUIT (3)
301: # and returns to single user after fsck.
1.1 deraadt 302: trap : 2
1.450 rpe 303: trap : 3 # Shouldn't be needed.
1.1 deraadt 304:
1.463 rpe 305: export HOME=/
306: export INRC=1
307: export PATH=/sbin:/bin:/usr/sbin:/usr/bin
1.544 deraadt 308:
309: # /etc/myname contains my symbolic name.
310: if [[ -f /etc/myname ]]; then
311: hostname "$(stripcom /etc/myname)"
312: fi
1.395 deraadt 313:
1.450 rpe 314: # Must set the domainname before rc.conf, so YP startup choices can be made.
1.463 rpe 315: if [[ -s /etc/defaultdomain ]]; then
316: domainname "$(stripcom /etc/defaultdomain)"
1.395 deraadt 317: fi
1.108 deraadt 318:
1.495 rpe 319: # Get local functions from rc.subr to load rc.conf into scope.
1.428 robert 320: FUNCS_ONLY=1 . /etc/rc.d/rc.subr
321: _rc_parse_conf
1.343 robert 322:
1.495 rpe 323: # If executed with the 'shutdown' parameter by the halt, reboot or shutdown:
324: # - update seed files
325: # - execute the rc.d scripts specified by $pkg_scripts in reverse order
326: # - bring carp interfaces down gracefully
1.463 rpe 327: if [[ $1 == shutdown ]]; then
1.525 rpe 328: if echo 2>/dev/null >>/var/db/host.random ||
1.437 bluhm 329: echo 2>/dev/null >>/etc/random.seed; then
330: random_seed
331: else
332: echo warning: cannot write random seed to disk
333: fi
1.416 rpe 334:
1.469 tim 335: # If we are in secure level 0, assume single user mode.
1.463 rpe 336: if (($(sysctl -n kern.securelevel) == 0)); then
337: echo 'single user: not running shutdown scripts'
338: else
1.514 rpe 339: set -A _d -- $pkg_scripts
340: _i=${#_d[*]}
341: if ((_i)); then
1.413 deraadt 342: echo -n 'stopping package daemons:'
1.514 rpe 343: while ((--_i >= 0)); do
344: [[ -x /etc/rc.d/${_d[_i]} ]] &&
345: /etc/rc.d/${_d[_i]} stop
1.413 deraadt 346: done
1.527 sthen 347: echo '.'
348: fi
349:
350: if /etc/rc.d/vmd check > /dev/null; then
351: echo -n 'stopping VMs'
352: /etc/rc.d/vmd stop > /dev/null
1.413 deraadt 353: echo '.'
354: fi
355:
1.463 rpe 356: [[ -f /etc/rc.shutdown ]] && sh /etc/rc.shutdown
1.413 deraadt 357: fi
1.240 mcbride 358:
1.463 rpe 359: ifconfig | while read _if _junk; do
1.474 rpe 360: [[ $_if == carp+([0-9]): ]] && ifconfig ${_if%:} down
1.413 deraadt 361: done
1.246 mcbride 362:
1.108 deraadt 363: exit 0
1.1 deraadt 364: fi
1.98 jakob 365:
1.540 deraadt 366: # If bootblocks failed to give us random, try to cause some churn
367: (dmesg; sysctl hw.{uuid,serialno,sensors} ) >/dev/random 2>&1
368:
1.482 deraadt 369: # Add swap block-devices.
1.172 miod 370: swapctl -A -t blk
1.170 deraadt 371:
1.495 rpe 372: # Run filesystem check unless a /fastboot file exists.
1.463 rpe 373: if [[ -e /fastboot ]]; then
1.1 deraadt 374: echo "Fast boot: skipping disk checks."
1.463 rpe 375: elif [[ $1 == autoboot ]]; then
1.1 deraadt 376: echo "Automatic boot in progress: starting file system checks."
1.429 claudio 377: do_fsck
1.1 deraadt 378: fi
379:
1.495 rpe 380: # From now on, allow user to interrupt (^C) the boot process.
1.1 deraadt 381: trap "echo 'Boot interrupted.'; exit 1" 3
382:
1.495 rpe 383: # Unmount all filesystems except root.
1.1 deraadt 384: umount -a >/dev/null 2>&1
1.495 rpe 385:
386: # Mount all filesystems except those of type NFS and VND.
1.303 grunk 387: mount -a -t nonfs,vnd
1.177 deraadt 388:
1.495 rpe 389: # Re-mount the root filesystem read/writeable. (root on nfs requires this,
390: # others aren't hurt.)
391: mount -uw /
1.499 deraadt 392: chmod og-rwx /bsd
1.503 deraadt 393: ln -fh /bsd /bsd.booted
1.495 rpe 394:
395: rm -f /fastboot
396:
1.505 tedu 397: # Set flags on ttys.
1.1 deraadt 398: ttyflags -a
1.77 angelos 399:
1.464 rpe 400: # Set keyboard encoding.
401: if [[ -x /sbin/kbd && -s /etc/kbdtype ]]; then
1.541 naddy 402: kbd "$(</etc/kbdtype)"
1.252 mcbride 403: fi
404:
1.279 deraadt 405: wsconsctl_conf
406:
1.464 rpe 407: # Set initial temporary pf rule set.
408: if [[ $pf != NO ]]; then
1.511 rpe 409: RULES="
1.510 rpe 410: block all
411: pass on lo0
412: pass in proto tcp from any to any port ssh keep state
413: pass out proto { tcp, udp } from any to any port domain keep state
414: pass out inet proto icmp all icmp-type echoreq keep state
415: pass out inet proto udp from any port bootpc to any port bootps
1.511 rpe 416: pass in inet proto udp from any port bootps to any port bootpc"
1.510 rpe 417:
1.257 grange 418: if ifconfig lo0 inet6 >/dev/null 2>&1; then
1.510 rpe 419: RULES="$RULES
420: pass out inet6 proto icmp6 all icmp6-type neighbrsol
421: pass in inet6 proto icmp6 all icmp6-type neighbradv
422: pass out inet6 proto icmp6 all icmp6-type routersol
423: pass in inet6 proto icmp6 all icmp6-type routeradv
424: pass out inet6 proto udp from any port dhcpv6-client to any port dhcpv6-server
425: pass in inet6 proto udp from any port dhcpv6-server to any port dhcpv6-client"
1.257 grange 426: fi
1.510 rpe 427:
428: RULES="$RULES
429: pass in proto carp keep state (no-sync)
430: pass out proto carp !received-on any keep state (no-sync)"
431:
1.545 naddy 432: if (($(sysctl -n vfs.mounts.nfs 2>/dev/null)+0 > 0)); then
1.511 rpe 433: # Don't kill NFS.
1.510 rpe 434: RULES="set reassemble yes no-df
435: $RULES
436: pass in proto { tcp, udp } from any port { sunrpc, nfsd } to any
437: pass out proto { tcp, udp } from any to any port { sunrpc, nfsd } !received-on any"
1.474 rpe 438: fi
1.511 rpe 439:
1.464 rpe 440: print -- "$RULES" | pfctl -f -
1.269 dhartmei 441: pfctl -e
1.176 kjell 442: fi
1.318 djm 443:
444: fill_baddynamic udp
445: fill_baddynamic tcp
1.176 kjell 446:
1.267 millert 447: sysctl_conf
1.260 jsg 448:
1.557 florian 449: mount -s /var >/dev/null 2>&1 # cannot be on NFS
450: mount -s /var/log >/dev/null 2>&1 # cannot be on NFS
451:
452: start_daemon slaacd dhcpleased resolvd >/dev/null 2>&1
1.501 florian 453:
1.1 deraadt 454: echo 'starting network'
1.464 rpe 455:
456: # Set carp interlock by increasing the demotion counter.
457: # Prevents carp from preempting until the system is booted.
1.536 tedu 458: ifconfig -g carp carpdemote 128
1.464 rpe 459:
1.439 ajacouto 460: sh /etc/netstart
1.176 kjell 461:
1.542 deraadt 462: mount -s /usr >/dev/null 2>&1
463:
1.557 florian 464: start_daemon unwind >/dev/null 2>&1
1.542 deraadt 465:
1.550 deraadt 466: random_seed
467:
468: reorder_libs
469:
1.450 rpe 470: # Load pf rules and bring up pfsync interface.
1.464 rpe 471: if [[ $pf != NO ]]; then
472: if [[ -f /etc/pf.conf ]]; then
1.449 ajacouto 473: pfctl -f /etc/pf.conf
1.309 mpf 474: fi
1.464 rpe 475: if [[ -f /etc/hostname.pfsync0 ]]; then
1.435 deraadt 476: sh /etc/netstart pfsync0
1.367 deraadt 477: fi
1.176 kjell 478: fi
1.29 deraadt 479:
1.450 rpe 480: # Clean up left-over files.
1.492 jca 481: rm -f /etc/nologin /var/spool/lock/LCK.*
1.247 henning 482: (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
1.196 beck 483: (cd /var/authpf && rm -rf -- *)
1.96 alex 484:
1.495 rpe 485: # Save a copy of the boot messages.
486: dmesg >/var/run/dmesg.boot
1.55 deraadt 487:
1.373 deraadt 488: make_keys
489:
1.379 deraadt 490: echo -n 'starting early daemons:'
1.543 tedu 491: start_daemon syslogd ldattach pflogd nsd unbound ntpd
1.429 claudio 492: start_daemon iscsid isakmpd iked sasyncd ldapd npppd
1.353 robert 493: echo '.'
1.280 hshoexer 494:
1.450 rpe 495: # Load IPsec rules.
1.464 rpe 496: if [[ $ipsec != NO && -f /etc/ipsec.conf ]]; then
497: ipsecctl -f /etc/ipsec.conf
1.40 provos 498: fi
1.1 deraadt 499:
1.379 deraadt 500: echo -n 'starting RPC daemons:'
1.562 ! deraadt 501: start_daemon portmap
1.464 rpe 502: if [[ -n $(domainname) ]]; then
1.562 ! deraadt 503: start_daemon ypldap ypserv ypbind
1.376 deraadt 504: fi
1.399 dlg 505: start_daemon mountd nfsd lockd statd amd
1.1 deraadt 506: echo '.'
1.58 deraadt 507:
1.464 rpe 508: # Check and mount remaining file systems and enable additional swap.
1.278 otto 509: mount -a
1.172 miod 510: swapctl -A -t noblk
1.429 claudio 511: do_fsck -N
512: mount -a -N
1.1 deraadt 513:
1.549 deraadt 514: # Build kvm(3) and /dev databases.
515: kvm_mkdb
516: dev_mkdb
517:
1.450 rpe 518: # /var/crash should be a directory or a symbolic link to the crash directory
519: # if core dumps are to be saved.
1.464 rpe 520: if [[ -d /var/crash ]]; then
521: savecore $savecore_flags /var/crash
1.487 rpe 522: fi
523:
524: # Store ACPI tables in /var/db/acpi to be used by sendbug(1).
525: if [[ -x /usr/sbin/acpidump ]]; then
1.530 kettenis 526: acpidump -q -o /var/db/acpi/
1.90 art 527: fi
528:
1.464 rpe 529: if [[ $check_quotas == YES ]]; then
1.41 downsj 530: echo -n 'checking quotas:'
531: quotacheck -a
532: echo ' done.'
533: quotaon -a
534: fi
1.464 rpe 535:
536: # Set proper permission for the tty device files.
1.101 deraadt 537: chmod 666 /dev/tty[pqrstuvwxyzPQRST]*
1.226 millert 538: chown root:wheel /dev/tty[pqrstuvwxyzPQRST]*
1.1 deraadt 539:
1.495 rpe 540: # Check for the password temp/lock file.
1.467 rpe 541: if [[ -f /etc/ptmp ]]; then
1.1 deraadt 542: logger -s -p auth.err \
1.376 deraadt 543: 'password file may be incorrect -- /etc/ptmp exists'
1.32 deraadt 544: fi
545:
1.49 millert 546: echo clearing /tmp
547:
1.450 rpe 548: # Prune quickly with one rm, then use find to clean up /tmp/[lqv]*
549: # (not needed with mfs /tmp, but doesn't hurt there...).
1.444 deraadt 550: (cd /tmp && rm -rf [a-km-pr-uw-zA-Z]*)
1.339 sthen 551: (cd /tmp &&
1.443 millert 552: find . -maxdepth 1 ! -name . ! -name lost+found ! -name quota.user \
1.444 deraadt 553: ! -name quota.group ! -name vi.recover -execdir rm -rf -- {} \;)
1.373 deraadt 554:
1.462 rpe 555: # Create Unix sockets directories for X if needed and make sure they have
556: # correct permissions.
557: [[ -d /usr/X11R6/lib ]] && mkdir -m 1777 /tmp/.{X11,ICE}-unix
1.203 hugh 558:
1.467 rpe 559: [[ -f /etc/rc.securelevel ]] && sh /etc/rc.securelevel
560:
1.450 rpe 561: # rc.securelevel did not specifically set -1 or 2, so select the default: 1.
1.467 rpe 562: (($(sysctl -n kern.securelevel) == 0)) && sysctl kern.securelevel=1
563:
1.1 deraadt 564:
1.450 rpe 565: # Patch /etc/motd.
1.467 rpe 566: if [[ ! -f /etc/motd ]]; then
1.34 deraadt 567: install -c -o root -g wheel -m 664 /dev/null /etc/motd
568: fi
1.467 rpe 569: if T=$(mktemp /tmp/_motd.XXXXXXXXXX); then
1.451 rpe 570: sysctl -n kern.version | sed 1q >$T
1.494 schwarze 571: sed -n '/^$/,$p' </etc/motd >>$T
1.102 millert 572: cmp -s $T /etc/motd || cp $T /etc/motd
573: rm -f $T
574: fi
1.34 deraadt 575:
1.467 rpe 576: if [[ $accounting == YES ]]; then
577: [[ ! -f /var/account/acct ]] && touch /var/account/acct
578: echo 'turning on accounting'
579: accton /var/account/acct
1.1 deraadt 580: fi
581:
1.467 rpe 582: if [[ -x /sbin/ldconfig ]]; then
1.115 deraadt 583: echo 'creating runtime link editor directory cache.'
1.471 rpe 584: [[ -d /usr/local/lib ]] && shlib_dirs="/usr/local/lib $shlib_dirs"
1.467 rpe 585: [[ -d /usr/X11R6/lib ]] && shlib_dirs="/usr/X11R6/lib $shlib_dirs"
1.115 deraadt 586: ldconfig $shlib_dirs
1.231 millert 587: fi
588:
1.451 rpe 589: echo 'preserving editor files.'; /usr/libexec/vi.recover
1.244 markus 590:
1.477 ajacouto 591: # If rc.sysmerge exists, run it just once, and make sure it is deleted.
592: run_upgrade_script sysmerge
593:
1.353 robert 594: echo -n 'starting network daemons:'
1.555 claudio 595: start_daemon ldomd sshd snmpd ldpd ripd ospfd ospf6d bgpd ifstated
1.529 florian 596: start_daemon relayd dhcpd dhcrelay mrouted dvmrpd radiusd eigrpd route6d
1.559 claudio 597: start_daemon rad hostapd lpd smtpd slowcgi bgplgd httpd ftpd
1.461 sthen 598: start_daemon ftpproxy ftpproxy6 tftpd tftpproxy identd inetd rarpd bootparamd
1.488 reyk 599: start_daemon rbootd mopd vmd spamd spamlogd sndiod
1.377 robert 600: echo '.'
1.335 deraadt 601:
1.450 rpe 602: # If rc.firsttime exists, run it just once, and make sure it is deleted.
1.477 ajacouto 603: run_upgrade_script firsttime
1.352 ajacouto 604:
1.450 rpe 605: # Run rc.d(8) scripts from packages.
1.467 rpe 606: if [[ -n $pkg_scripts ]]; then
1.352 ajacouto 607: echo -n 'starting package daemons:'
1.467 rpe 608: for _daemon in $pkg_scripts; do
609: if [[ -x /etc/rc.d/$_daemon ]]; then
610: start_daemon $_daemon
1.410 espie 611: else
1.467 rpe 612: echo -n " ${_daemon}(absent)"
1.410 espie 613: fi
1.352 ajacouto 614: done
615: echo '.'
616: fi
1.17 deraadt 617:
1.467 rpe 618: [[ -f /etc/rc.local ]] && sh /etc/rc.local
1.73 millert 619:
1.495 rpe 620: # Disable carp interlock.
1.536 tedu 621: ifconfig -g carp -carpdemote 128
1.286 mcbride 622:
1.379 deraadt 623: mixerctl_conf
1.467 rpe 624:
1.379 deraadt 625: echo -n 'starting local daemons:'
1.493 matthieu 626: start_daemon apmd sensorsd hotplugd watchdogd cron wsmoused xenodm
1.73 millert 627: echo '.'
1.502 rpe 628:
1.515 rpe 629: # Re-link the kernel, placing the objects in a random order.
630: # Replace current with relinked kernel and inform root about it.
631: /usr/libexec/reorder_kernel &
1.1 deraadt 632:
633: date
634: exit 0