git: fefb7c399b39 - main - mountd.c: Add warning messages for administrative controls
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 31 Mar 2024 19:01:11 UTC
The branch main has been updated by rmacklem:
URL: https://cgit.FreeBSD.org/src/commit/?id=fefb7c399b39403e1a31157e925a541f1cc24f0b
commit fefb7c399b39403e1a31157e925a541f1cc24f0b
Author: Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2024-03-31 19:00:08 +0000
Commit: Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2024-03-31 19:00:08 +0000
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
---
usr.sbin/mountd/mountd.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 73a4dbfe39b3..14693a922186 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -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.
*/