HardenedBSD/libexec/rc/rc.d/mountcritlocal
Alexander Leidinger f99f0ee14e rc.d: add a service jails config to all base system services
This gives more permissions to services (e.g. network access to
services which require this) when they are started as an automatic
service jail.

The sshd patch is important for the sshd-related functionality as
described in the man-page in the service jails part.

The location of the added env vars is supposed to allow overriding them
in rc.conf, and to hard-disable the use of svcj for some parts where it
doesn't make sense or will not work.

Only a subset of all of the services are fully tested (I'm running this
since more than a year with various services started as service jails).
The untested parts should be most of the time ok, in some edge-cases
more permissions are needed inside the service jail.
Differential Revision:	https://reviews.freebsd.org/D40371
2024-05-22 15:41:49 +02:00

68 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
#
#
# PROVIDE: mountcritlocal
# REQUIRE: root hostid_save mdconfig
# KEYWORD: nojail shutdown
. /etc/rc.subr
name="mountcritlocal"
desc="Mount critical local filesystems"
start_cmd="mountcritlocal_start"
stop_cmd=sync
mountcritlocal_start()
{
local err holders waited
# Set up the list of network filesystem types for which mounting
# should be delayed until after network initialization.
case ${extra_netfs_types} in
[Nn][Oo])
;;
*)
netfs_types="${netfs_types} ${extra_netfs_types}"
;;
esac
# Mount everything except nfs filesystems.
startmsg -n 'Mounting local filesystems:'
mount_excludes='no'
for i in ${netfs_types}; do
fstype=${i%:*}
mount_excludes="${mount_excludes}${fstype},"
done
mount_excludes=${mount_excludes%,}
mount -a -t ${mount_excludes}
err=$?
if [ ${err} -ne 0 ]; then
echo 'Mounting /etc/fstab filesystems failed,' \
'will retry after root mount hold release'
root_hold_wait
mount -a -t ${mount_excludes}
err=$?
fi
startmsg '.'
case ${err} in
0)
;;
*)
echo 'Mounting /etc/fstab filesystems failed,' \
'startup aborted'
stop_boot true
;;
esac
}
load_rc_config $name
# mounting shall not be performed in a svcj
mountcritlocal_svcj="NO"
run_rc_command "$1"