Files
Christos Margiolis 26203cca52 rc.d/mountd: Do not require /etc/exports
mountd exits if it cannot read any exports files. Requiring
/etc/exports, however, unconditionally stops mountd from starting on a
server that exports ZFS datasets only (/etc/zfs/exports).

Let sbin/mountd handle requirements itself, instead of hardcoding
/etc/exports, which is also wrong, because different files can be
specified in mountd_flags.

This patch also works with nfsv4_server_enable="YES", by preserving the
behavior of failing to start if there is no "V4:" line in the exports
file, which is missing by default on ZFS-only exports.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Reviewed by:	rmacklem, markj, emaste
Differential Revision:	https://reviews.freebsd.org/D60044
2026-10-07 18:53:28 +02:00

79 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
#
#
# PROVIDE: mountd
# REQUIRE: NETWORKING rpcbind quota mountlate
# KEYWORD: nojailvnet shutdown
. /etc/rc.subr
name="mountd"
desc="Service remote NFS mount requests"
rcvar="mountd_enable"
command="/usr/sbin/${name}"
pidfile="/var/run/${name}.pid"
start_precmd="mountd_precmd"
extra_commands="reload"
: ${mountd_svcj_options:="net_basic nfsd"}
mountd_precmd()
{
# Load the modules now, so that the vfs.nfsd sysctl
# oids are available.
load_kld nfsd || return 1
# Do not force rpcbind to be running for an NFSv4 only server.
#
if checkyesno nfsv4_server_only; then
echo 'NFSv4 only server'
sysctl vfs.nfsd.server_min_nfsvers=4 > /dev/null
sysctl vfs.nfsd.server_max_nfsvers=4 > /dev/null
rc_flags="${rc_flags} -R"
else
force_depend rpcbind || return 1
if checkyesno nfsv4_server_enable; then
sysctl vfs.nfsd.server_max_nfsvers=4 > /dev/null
else
sysctl vfs.nfsd.server_max_nfsvers=3 > /dev/null
fi
fi
# mountd flags will differ depending on rc.conf settings
#
if checkyesno nfs_server_enable || checkyesno nfsv4_server_only; then
if checkyesno weak_mountd_authentication; then
if checkyesno nfsv4_server_only; then
echo -n 'weak_mountd_authentication '
echo -n 'incompatible with nfsv4_server_only, '
echo 'ignored'
else
rc_flags="${rc_flags} -n"
fi
fi
else
if checkyesno mountd_enable; then
checkyesno weak_mountd_authentication && rc_flags="-n"
fi
fi
if checkyesno zfs_enable; then
rc_flags="${rc_flags} /etc/exports /etc/zfs/exports"
fi
rm -f /var/db/mountdtab
( umask 022 ; > /var/db/mountdtab ) ||
err 1 'Cannot create /var/db/mountdtab'
}
load_rc_config $name
load_rc_config nfsd
load_rc_config zfs
# precmd is not compatible with svcj
mountd_svcj="NO"
run_rc_command "$1"