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