summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>2002-07-18 20:52:17 +0000
committerjoerg <joerg@FreeBSD.org>2002-07-18 20:52:17 +0000
commit63afba9f66e6db9c328d43e463254994b758bf41 (patch)
tree6194f27b4b092874f62873ebbd9d5a0f1f0e6eb5 /usr.sbin
parent66e9d99f6c46c9edc7c7f30ae1a88510c54c0ce5 (diff)
downloadFreeBSD-src-63afba9f66e6db9c328d43e463254994b758bf41.zip
FreeBSD-src-63afba9f66e6db9c328d43e463254994b758bf41.tar.gz
Try to give a more descriptive error message for the pilot error of
attempting to export the non-root of a filesystem with -alldirs. This pilot error seems to be very common, and the "could not remount" error message doesn't give much hints about the real reason. See the old PR below for an example. While i was at it, make it possible to entirely omit the often annoying error message in that case by specifying the "quiet" exports flag. This allows to specify something like /cdrom -alldirs,ro,quiet <where to export to> which will silently fail if nothing is mounted under /cdrom, but do the rigth thing as soon as you mount something. While doing this, i've put the embedded example in the exports(5) man page into a subsection of its own as it ought to be. Thanks for Paul Southworth for reminding me about this problem. PR: bin/4448 MFC after: 1 month
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/mountd/exports.588
-rw-r--r--usr.sbin/mountd/mountd.c18
2 files changed, 81 insertions, 25 deletions
diff --git a/usr.sbin/mountd/exports.5 b/usr.sbin/mountd/exports.5
index 98e1f24..07700eb 100644
--- a/usr.sbin/mountd/exports.5
+++ b/usr.sbin/mountd/exports.5
@@ -207,6 +207,15 @@ or
.Fl webnfs
flags.
.Pp
+Specifying the
+.Fl quiet
+option will inhibit some of the syslog diagnostics for bad lines in
+.Pa /etc/exports .
+This can be useful to avoid annoying error messages for known possible
+problems (see
+.Sx EXAMPLES
+below).
+.Pp
The third component of a line specifies the host set to which the line applies.
The set may be specified in three ways.
The first way is to list the host name(s) separated by white space.
@@ -237,8 +246,34 @@ and optionally
If the mask is not specified, it will default to the mask for that network
class (A, B or C; see
.Xr inet 4 ) .
+See the
+.Sx EXAMPLES
+section below.
+.Pp
+The
+.Xr mountd 8
+utility can be made to re-read the
+.Nm
+file by sending it a hangup signal as follows:
+.Bd -literal -offset indent
+kill -s HUP `cat /var/run/mountd.pid`
+.Ed
.Pp
-For example:
+After sending the
+.Dv SIGHUP ,
+check the
+.Xr syslogd 8
+output to see whether
+.Xr mountd 8
+logged any parsing errors in the
+.Nm
+file.
+.Sh FILES
+.Bl -tag -width /etc/exports -compact
+.It Pa /etc/exports
+the default remote mount-point file
+.El
+.Sh EXAMPLES
.Bd -literal -offset indent
/usr /usr/local -maproot=0:10 friends
/usr -maproot=daemon grumpy.cis.uoguelph.ca 131.104.48.16
@@ -246,6 +281,7 @@ For example:
/u -maproot=bin: -network 131.104.48 -mask 255.255.255.0
/u2 -maproot=root friends
/u2 -alldirs -kerb -network cis-net -mask cis-mask
+/cdrom -alldirs,quiet,ro -network 192.168.33.0 -mask 255.255.255.0
.Ed
.Pp
Given that
@@ -284,29 +320,37 @@ it is exported to all hosts on network ``cis-net'' allowing mounts at any
directory within /u2 and mapping all uids to credentials for the principal
that is authenticated by a Kerberos ticket.
.Pp
+The filesystem rooted at
+.Sy /cdrom
+will exported read-only to the entire network 192.168.33.0/24, including
+all its subdirectories.
+Since
+.Sy /cdrom
+is the conventional mountpoint for a CD-ROM device, this export will
+fail if no CD-ROM medium is currently mounted there since that line
+would then attempt to export a subdirectory of the root filesystem
+with the
+.Fl alldirs
+option which is not allowed.
The
+.Fl quiet
+option will then suppress the error message for this condition that
+would normally be syslogged.
+As soon as an actual CD-ROM is going to be mounted,
+.Xr mount 8
+will notify
.Xr mountd 8
-utility can be made to re-read the
-.Nm
-file by sending it a hangup signal as follows:
-.Bd -literal -offset indent
-kill -s HUP `cat /var/run/mountd.pid`
-.Ed
-.Pp
-After sending the
-.Dv SIGHUP ,
-check the
-.Xr syslogd 8
-output to see whether
-.Xr mountd 8
-logged any parsing errors in the
-.Nm
-file.
-.Sh FILES
-.Bl -tag -width /etc/exports -compact
-.It Pa /etc/exports
-the default remote mount-point file
-.El
+about this situation, and the
+.Sy /cdrom
+filesystem will be exported as intented.
+Note that without using the
+.Fl alldirs
+option, the export would always succeed.
+While there is no CD-ROM medium mounted under
+.Sy /cdrom ,
+it would export the (normally empty) directory
+.Sy /cdrom
+of the root filesystem instead.
.Sh SEE ALSO
.Xr netgroup 5 ,
.Xr mountd 8 ,
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 3d0df88..2798915 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -243,6 +243,7 @@ int mountdlockfd;
#define OP_NET 0x10
#define OP_ALLDIRS 0x40
#define OP_HAVEMASK 0x80 /* A mask was specified or inferred. */
+#define OP_QUIET 0x100
#define OP_MASKLEN 0x200
#ifdef DEBUG
@@ -1240,7 +1241,8 @@ getexp_err(ep, grp)
{
struct grouplist *tgrp;
- syslog(LOG_ERR, "bad exports list line %s", line);
+ if (!(opt_flags & OP_QUIET))
+ syslog(LOG_ERR, "bad exports list line %s", line);
if (ep && (ep->ex_flag & EX_LINKED) == 0)
free_exp(ep);
while (grp) {
@@ -1580,6 +1582,8 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
opt_flags |= OP_MAPALL;
} else if (cpoptarg && !strcmp(cpopt, "index")) {
ep->ex_indexfile = strdup(cpoptarg);
+ } else if (!strcmp(cpopt, "quiet")) {
+ opt_flags |= OP_QUIET;
} else {
syslog(LOG_ERR, "bad opt %s", cpopt);
return (1);
@@ -1812,6 +1816,8 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
*cp-- = savedc;
else
cp = dirp + dirplen - 1;
+ if (opt_flags & OP_QUIET)
+ return (1);
if (errno == EPERM) {
if (debug)
warnx("can't change attributes for %s",
@@ -1821,8 +1827,14 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
return (1);
}
if (opt_flags & OP_ALLDIRS) {
- syslog(LOG_ERR, "could not remount %s: %m",
- dirp);
+ if (errno == EINVAL)
+ syslog(LOG_ERR,
+ "-alldirs requested but %s is not a filesystem mountpoint",
+ dirp);
+ else
+ syslog(LOG_ERR,
+ "could not remount %s: %m",
+ dirp);
return (1);
}
/* back up over the last component */
OpenPOWER on IntegriCloud