aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLexi Winter <ivy@FreeBSD.org>2025-08-10 14:53:30 +0100
committerLexi Winter <ivy@FreeBSD.org>2025-08-10 15:09:21 +0100
commit3738005fae09451b411e8f47f124d9fc94da4238 (patch)
tree709237d2de9de07152cd7cecee75e38900cf7c25
parent65ddbe7b3376c942e7226ec1ceea5792e77a419e (diff)
rc.subr: Add /etc/defaults/rc.conf.d
This is /etc/defaults/rc.conf but for individual services. Unlike /etc/rc.conf.d, files in /etc/defaults/rc.conf.d are shipped by the operating system and shouldn't be modified by users, so they should not have the @config tag. This allows optional packages to install their own default config instead of dumping everything in /etc/defaults/rc.conf. While here, move rc.d and rc.conf.d to the rc package.
-rw-r--r--etc/mtree/BSD.root.dist6
-rw-r--r--libexec/rc/rc.subr12
2 files changed, 14 insertions, 4 deletions
diff --git a/etc/mtree/BSD.root.dist b/etc/mtree/BSD.root.dist
index 1312251cdd9e..a38dc3461ae7 100644
--- a/etc/mtree/BSD.root.dist
+++ b/etc/mtree/BSD.root.dist
@@ -52,6 +52,8 @@
cron.d
..
defaults
+ rc.conf.d tags=package=rc
+ ..
..
devd
..
@@ -89,9 +91,9 @@
..
profile.d
..
- rc.conf.d
+ rc.conf.d tags=package=rc
..
- rc.d
+ rc.d tags=package=rc
..
security
..
diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
index 06b1bd51384c..62b68a8b127f 100644
--- a/libexec/rc/rc.subr
+++ b/libexec/rc/rc.subr
@@ -1987,10 +1987,18 @@ load_rc_config()
_rc_conf_loaded=true
fi
- # If a service name was specified, attempt to load
- # service-specific configuration
+ # If a service name was specified, load any default configuration from
+ # /etc/defaults/rc.conf.d, then attempt to load user overrides from
+ # /etc/rc.conf.d and local startup dirs.
if [ -n "$_name" ] ; then
_loaded_services="${_loaded_services} ${_name}"
+
+ local _default_d="/etc/defaults/rc.conf.d/$_name"
+ if [ -f "$_default_d" ]; then
+ debug "Sourcing $_default_d"
+ $_dot "$_default_d"
+ fi
+
for _d in /etc ${local_startup}; do
_d=${_d%/rc.d}
if [ -f ${_d}/rc.conf.d/"$_name" ]; then