History log of /freebsd-current/libexec/rc/rc
Revision Date Author Comments
# aa3b7a2f 09-Feb-2024 Simon J. Gerraty <sjg@FreeBSD.org>

/etc/rc add trace debug and verify

Debugging boot issues can be helped by
logging each rc.d script as it is run
and being able to selectively enable/disable set -x
debug.sh provides an elaborate framework for debugging shell scripts.

For secure systems, we want to be paranoid about what we read
during boot.

dot() simply reads (.) arg file if it exists
vdot() if mac_veriexec is active, ignore unverified files
otherwise behaves much the same as dot()
safe_dot() in safe_eval.sh allows reading an untrusted file;
limiting the input to simple variable assignments.

In load_rc_config allow caller to provide an option to indicate how to
handle its arg:
-v use vdot()
-s use sdot() which will try to use vdot() and fallback to safe_dot()
The default is to read using dot()

rc_run_scripts()
encapsulate the running of rc.d scripts
so that we can easily call it more than twice.

We vdot local.rc.subr to pick up extensions (like
run_rc_scripts_final) and overrides.

We also allow rc.subr.local or rc.conf to set rc_config_xtra
eg (rc_config_xtra=XXX for historic compatibility)

rc use set -o verify around the reading in of rc.subr
This has no effect if mac_veriexec is not active, but if it is; ensures
rc.subr has not been tampered with.

Reviewed by: imp
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43671


# 43581d7b 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

libexec: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# d0b2dbfa 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line sh pattern

Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/


# 3693d914 14-Mar-2023 Mina Galić <me+git@igalic.co>

rc: ignore .pkgsave files

The local parts of rc already skip .sample files; we add .pkgsave to the
list, and add logic for base.

Thanks to @RhodiumToad for getting this started.

Differential Revision: https://reviews.freebsd.org/D27962
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/662


# cb51e2bc 10-Feb-2022 Jose Luis Duran <jlduran@gmail.com>

rc: Allow the removal of firstboot_sentinel on read-only file systems

NanoBSD or, more generally, systems with root_rw_mount="NO" are not able
to remove the firstboot_sentinel file, typically /firstboot, because the
logic in /etc/rc is currently inverted.

When checkyesno root_rw_mount tests on a read-only file system, the
return is 1, hence avoiding the option to mount the system read-write.

Restore the ability to remove the firstboot_sentinel file on read-only
mounted file systems.

This change was introduced in 40adda8665bb, and partially fixed in
1ce07411fae8.

Differential Revision: https://reviews.freebsd.org/D34166


# c96f70e7 10-Feb-2022 Jose Luis Duran <jlduran@gmail.com>

rc: Remove extra whitespace

Differential Revision: https://reviews.freebsd.org/D34165


# f61831d2 09-Mar-2021 Baptiste Daroussin <bapt@FreeBSD.org>

Revert "rc: implement parallel boot"

This is not ready yet for prime time

This reverts commit 763db58932874bb47fc6f9322ab81cc947f80991.
This reverts commit f1ab799927c8e93e8f58e5039f287a2ca45675ec.
This reverts commit 6e822e99570fdf4c564be04840a054bccc070222.
This reverts commit 77e1ccbee3ed6c837929e4e232fd07f95bfc8294.


# 763db589 25-Feb-2021 Cy Schubert <cy@FreeBSD.org>

rc: save and restore $IFS

Fix another bug in 77e1ccbee3ed6c837929e4e232fd07f95bfc8294. $IFS
should be fully restored for its other users.

PR: 249192
Reported by: jkim
MFC after: 3 weeks
X-MFC with: 77e1ccbee3ed6c837929e4e232fd07f95bfc8294


# f1ab7999 25-Feb-2021 Cy Schubert <cy@FreeBSD.org>

rc: fix rc script parsing

77e1ccbee3ed6c837929e4e232fd07f95bfc8294 introduced a bug whereby
rc scripts in etc/rc.d and $local_startup failed to parse output
from called commands because IFS was set to " " instead of the
default " \t\n". This caused parsing of output that contains any
whitespace character, such as tabs and newlines, not matching just a
space to fail.

PR: 249192
MFC after: 3 weeks
X-MFC with: 77e1ccbee3ed6c837929e4e232fd07f95bfc8294


# 6e822e99 23-Feb-2021 Cy Schubert <cy@FreeBSD.org>

rc: fix parse of $local_startup

77e1ccbee3ed6c837929e4e232fd07f95bfc8294 introduced parallel execution
of rc. It separated groups with line feeds (\n) and elements within
groups using spaces. This is a natural separation due to rcorder
using spaces and lines to separate elements within groups with groups
of services separated by line feeds.

77e1ccbee3ed6c837929e4e232fd07f95bfc8294 parses the output from rcorder
by setting $IFS. However it failed to reset $IFS to default ' \t\n'
prior to calling find_local_scripts_new(), causing find_local_scripts_new()
to fail parsing $local_startup for site-specific local rc scripts, i.e.
${LOCALBASE}/etc/rc.d. This caused daemons from ports and packages such
as postfix, dovecot, nut, and others in ${LOCALBASE} not to be started.

PR: 249192
MFC after: 3 week
X-MFC with: 77e1ccbee3ed6c837929e4e232fd07f95bfc8294


# 77e1ccbe 06-Feb-2021 Rick Parrish <unitrunker@gmail.com>

rc: implement parallel boot

take advantage of the rcorder -p argument to implement parallel
booting in rc.

According to the author non scientific tests:
on a Core 2 Duo with spinning disk:

| Services enabled | before | after | saving |
| 0 | 8s | 8s | 0 |
| 1 | 13s | 13s | 0 |
| 2 | 17s | 13s | 5 |
| 3 | 23s | 13s | 10 |
| 4 | 28s | 13s | 15 |
| 5 | 33s | 13s | 20 |

PR: 249192
MFC after: 3 weeks


# 08867050 02-Nov-2020 Stefan Eßer <se@FreeBSD.org>

Replace literal uses of /usr/local with a variable

The variable defaults to "/usr/local", unless sysctl returns some other
value for "user.localbase".

The value of user.localbase defaults to _PATH_LOCALBASE as defined in
paths.h and thus this commit has no immediate effect.

The purpose of this change is to make /etc/defaults/rc.conf automatically
use the value of _PATH_LOCALBASE when not set to the default value.

Reviewed by: imp, scottl
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D27014


# 0696600c 17-Oct-2018 Bjoern A. Zeeb <bz@FreeBSD.org>

Move the rc framework out of sbin/init into libexec/rc.

The reasons for this are forward looking to pkgbase:
* /sbin/init is a special binary; try not to replace it with
every package update because an rc script was touched.
(a follow-up commit will make init its own package)
* having rc in its own place will allow more easy replacement
of the rc framework with alternatives, such as openrc.

Discussed with: brd (during BSDCam), kmoore
Requested by: cem, bz
PR: 231522
Approved by: re (gjb)