mountd.c: Add warning messages for administrative controls

When "administrative controls" (which are exports of subdirectories
within a NFS server's local file system) are used, they export the
entire local server file system. (The subdirectory only applies to
the Mount protocol used for NFSv3 mounts.)

To minimize the risk that this causes confusion w.r.t. what is exported
to NFS client(s), this patch generates warning messages for these.
Only one message is generated for each server local file system.
The messages can be silenced via a new "-A" command line option.

The mountd.8 man page will be patched via a separate commit.

Reviewed by:	emaste, markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D44502
This commit is contained in:
Rick Macklem 2024-03-31 12:00:08 -07:00
parent ad5ec5136b
commit fefb7c399b

View file

@ -130,10 +130,11 @@ struct exportlist {
SLIST_ENTRY(exportlist) entries;
};
/* ex_flag bits */
#define EX_LINKED 0x1
#define EX_DONE 0x2
#define EX_DEFSET 0x4
#define EX_PUBLICFH 0x8
#define EX_LINKED 0x01
#define EX_DONE 0x02
#define EX_DEFSET 0x04
#define EX_PUBLICFH 0x08
#define EX_ADMINWARN 0x10
SLIST_HEAD(exportlisthead, exportlist);
@ -272,6 +273,7 @@ static char *exnames_default[2] = { _PATH_EXPORTS, NULL };
static char **exnames;
static char **hosts = NULL;
static int force_v2 = 0;
static int warn_admin = 1;
static int resvport_only = 1;
static int nhosts = 0;
static int dir_only = 1;
@ -434,11 +436,14 @@ main(int argc, char **argv)
else
close(s);
while ((c = getopt(argc, argv, "2deh:lnp:RrS")) != -1)
while ((c = getopt(argc, argv, "2Adeh:lnp:RrS")) != -1)
switch (c) {
case '2':
force_v2 = 1;
break;
case 'A':
warn_admin = 0;
break;
case 'e':
/* now a no-op, since this is the default */
break;
@ -1696,6 +1701,20 @@ get_exportlist_one(int passno)
fsb.f_fsid.val[1]);
}
if (warn_admin != 0 &&
(ep->ex_flag & EX_ADMINWARN) == 0 &&
strcmp(unvis_dir, fsb.f_mntonname) !=
0) {
if (debug)
warnx("exporting %s exports entire "
"%s file system", unvis_dir,
fsb.f_mntonname);
syslog(LOG_ERR, "Warning: exporting %s "
"exports entire %s file system",
unvis_dir, fsb.f_mntonname);
ep->ex_flag |= EX_ADMINWARN;
}
/*
* Add dirpath to export mount point.
*/