Allow exporting whole directory trees with -alldir option in /etc/exports
This commit is contained in:
parent
c87683c012
commit
d3725de8aa
@ -30,7 +30,7 @@
|
|||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" from: @(#)exports.5 5.2 (Berkeley) 5/10/91
|
.\" from: @(#)exports.5 5.2 (Berkeley) 5/10/91
|
||||||
.\" $Id: exports.5,v 1.4 1993/08/01 07:38:52 mycroft Exp $
|
.\" $Id: exports.5,v 1.5 1993/09/09 16:34:33 ws Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd May 10, 1991
|
.Dd May 10, 1991
|
||||||
.Dt EXPORTS 5
|
.Dt EXPORTS 5
|
||||||
@ -83,12 +83,20 @@ is synonyms for
|
|||||||
.Fl ro
|
.Fl ro
|
||||||
in an effort to be backward compatible with older export file formats.
|
in an effort to be backward compatible with older export file formats.
|
||||||
.Pp
|
.Pp
|
||||||
|
.Fl alldirs
|
||||||
|
specifies that all subdirectories of the given directory are exported.
|
||||||
|
This is sometimes necessary, e.g. for PCNFS spool directories.
|
||||||
|
The option
|
||||||
|
.Fl a
|
||||||
|
is synonym for
|
||||||
|
.Fl alldirs.
|
||||||
|
.Pp
|
||||||
For example:
|
For example:
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
/usr -root=0 rickers snowhite.cis.uoguelph.ca
|
/usr -root=0 rickers snowhite.cis.uoguelph.ca
|
||||||
/usr/local 131.104.48.16
|
/usr/local 131.104.48.16
|
||||||
/u -root=5
|
/u -root=5
|
||||||
/u2 -ro
|
/u2 -ro -alldirs
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Given that
|
Given that
|
||||||
@ -116,7 +124,8 @@ with root mapped to root.
|
|||||||
is exported to all hosts with root mapped to uid 5.
|
is exported to all hosts with root mapped to uid 5.
|
||||||
.Pp
|
.Pp
|
||||||
.Sy /u2
|
.Sy /u2
|
||||||
is exported to all hosts Read-only with root mapped to -2.
|
is exported to all hosts Read-only with root mapped to -2. All subdirectories
|
||||||
|
of /u2 may be mounted by remote hosts.
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Note that
|
Note that
|
||||||
|
@ -42,7 +42,7 @@ char copyright[] =
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
/*static char sccsid[] = "from: @(#)mountd.c 5.14 (Berkeley) 2/26/91";*/
|
/*static char sccsid[] = "from: @(#)mountd.c 5.14 (Berkeley) 2/26/91";*/
|
||||||
static char rcsid[] = "$Id: mountd.c,v 1.8 1993/09/07 15:40:37 ws Exp $";
|
static char rcsid[] = "$Id: mountd.c,v 1.9 1993/09/09 16:34:34 ws Exp $";
|
||||||
#endif not lint
|
#endif not lint
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -84,6 +84,7 @@ struct exportlist {
|
|||||||
struct grouplist *ex_groups;
|
struct grouplist *ex_groups;
|
||||||
int ex_rootuid;
|
int ex_rootuid;
|
||||||
int ex_exflags;
|
int ex_exflags;
|
||||||
|
int ex_alldirflg;
|
||||||
dev_t ex_dev;
|
dev_t ex_dev;
|
||||||
char ex_dirp[MNTPATHLEN+1];
|
char ex_dirp[MNTPATHLEN+1];
|
||||||
};
|
};
|
||||||
@ -251,7 +252,8 @@ mntsrv(rqstp, transp)
|
|||||||
omask = sigblock(sigmask(SIGHUP));
|
omask = sigblock(sigmask(SIGHUP));
|
||||||
ep = exphead.ex_next;
|
ep = exphead.ex_next;
|
||||||
while (ep != NULL) {
|
while (ep != NULL) {
|
||||||
if (!strcmp(ep->ex_dirp, dirpath)) {
|
if (!strcmp(ep->ex_dirp, dirpath) ||
|
||||||
|
(stb.st_dev == ep->ex_dev && ep->ex_alldirflg)) {
|
||||||
grp = ep->ex_groups;
|
grp = ep->ex_groups;
|
||||||
if (grp == NULL)
|
if (grp == NULL)
|
||||||
break;
|
break;
|
||||||
@ -458,7 +460,7 @@ get_exportlist()
|
|||||||
char *cp, *endcp;
|
char *cp, *endcp;
|
||||||
char savedc;
|
char savedc;
|
||||||
int len, dirplen;
|
int len, dirplen;
|
||||||
int rootuid, exflags;
|
int rootuid, exflags, alldirflg;
|
||||||
u_long saddr;
|
u_long saddr;
|
||||||
struct exportlist *fep;
|
struct exportlist *fep;
|
||||||
static int first = 0;
|
static int first = 0;
|
||||||
@ -504,6 +506,7 @@ get_exportlist()
|
|||||||
while (fgets(line, LINESIZ, inf)) {
|
while (fgets(line, LINESIZ, inf)) {
|
||||||
exflags = MNT_EXPORTED;
|
exflags = MNT_EXPORTED;
|
||||||
rootuid = def_rootuid;
|
rootuid = def_rootuid;
|
||||||
|
alldirflg = 0;
|
||||||
cp = line;
|
cp = line;
|
||||||
nextfield(&cp, &endcp);
|
nextfield(&cp, &endcp);
|
||||||
|
|
||||||
@ -556,7 +559,8 @@ get_exportlist()
|
|||||||
if (len > MNTNAMLEN)
|
if (len > MNTNAMLEN)
|
||||||
goto more;
|
goto more;
|
||||||
if (*cp == '-') {
|
if (*cp == '-') {
|
||||||
do_opt(cp + 1, fep, ep, &exflags, &rootuid);
|
do_opt(cp + 1, fep, ep, &exflags, &rootuid,
|
||||||
|
&alldirflg);
|
||||||
goto more;
|
goto more;
|
||||||
}
|
}
|
||||||
if (isdigit(*cp)) {
|
if (isdigit(*cp)) {
|
||||||
@ -652,9 +656,17 @@ get_exportlist()
|
|||||||
*cp = savedc;
|
*cp = savedc;
|
||||||
ep->ex_rootuid = rootuid;
|
ep->ex_rootuid = rootuid;
|
||||||
ep->ex_exflags = exflags;
|
ep->ex_exflags = exflags;
|
||||||
|
ep->ex_alldirflg = alldirflg;
|
||||||
} else {
|
} else {
|
||||||
|
if (alldirflg || fep->ex_alldirflg) {
|
||||||
|
syslog(LOG_WARNING,
|
||||||
|
"Can't export alldirs plus other exports");
|
||||||
|
free_exp(ep);
|
||||||
|
goto nextline;
|
||||||
|
}
|
||||||
ep->ex_rootuid = fep->ex_rootuid;
|
ep->ex_rootuid = fep->ex_rootuid;
|
||||||
ep->ex_exflags = fep->ex_exflags;
|
ep->ex_exflags = fep->ex_exflags;
|
||||||
|
ep->ex_alldirflg = 0;
|
||||||
}
|
}
|
||||||
ep->ex_dev = sb.st_dev;
|
ep->ex_dev = sb.st_dev;
|
||||||
ep->ex_next = exphead.ex_next;
|
ep->ex_next = exphead.ex_next;
|
||||||
@ -697,10 +709,10 @@ nextfield(cp, endcp)
|
|||||||
/*
|
/*
|
||||||
* Parse the option string
|
* Parse the option string
|
||||||
*/
|
*/
|
||||||
do_opt(cpopt, fep, ep, exflagsp, rootuidp)
|
do_opt(cpopt, fep, ep, exflagsp, rootuidp, alldirflgp)
|
||||||
register char *cpopt;
|
register char *cpopt;
|
||||||
struct exportlist *fep, *ep;
|
struct exportlist *fep, *ep;
|
||||||
int *exflagsp, *rootuidp;
|
int *exflagsp, *rootuidp, *alldirflgp;
|
||||||
{
|
{
|
||||||
register char *cpoptarg, *cpoptend;
|
register char *cpoptarg, *cpoptend;
|
||||||
|
|
||||||
@ -726,6 +738,8 @@ do_opt(cpopt, fep, ep, exflagsp, rootuidp)
|
|||||||
syslog(LOG_WARNING,
|
syslog(LOG_WARNING,
|
||||||
"uid failed for %s",
|
"uid failed for %s",
|
||||||
ep->ex_dirp);
|
ep->ex_dirp);
|
||||||
|
} else if (!strcmp(cpopt, "alldirs") || !strcmp(cpopt, "a")) {
|
||||||
|
*alldirflgp = 1;
|
||||||
} else
|
} else
|
||||||
syslog(LOG_WARNING, "opt %s ignored for %s", cpopt,
|
syslog(LOG_WARNING, "opt %s ignored for %s", cpopt,
|
||||||
ep->ex_dirp);
|
ep->ex_dirp);
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" from: @(#)exports.5 5.2 (Berkeley) 5/10/91
|
.\" from: @(#)exports.5 5.2 (Berkeley) 5/10/91
|
||||||
.\" $Id: exports.5,v 1.4 1993/08/01 07:38:52 mycroft Exp $
|
.\" $Id: exports.5,v 1.5 1993/09/09 16:34:33 ws Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd May 10, 1991
|
.Dd May 10, 1991
|
||||||
.Dt EXPORTS 5
|
.Dt EXPORTS 5
|
||||||
@ -83,12 +83,20 @@ is synonyms for
|
|||||||
.Fl ro
|
.Fl ro
|
||||||
in an effort to be backward compatible with older export file formats.
|
in an effort to be backward compatible with older export file formats.
|
||||||
.Pp
|
.Pp
|
||||||
|
.Fl alldirs
|
||||||
|
specifies that all subdirectories of the given directory are exported.
|
||||||
|
This is sometimes necessary, e.g. for PCNFS spool directories.
|
||||||
|
The option
|
||||||
|
.Fl a
|
||||||
|
is synonym for
|
||||||
|
.Fl alldirs.
|
||||||
|
.Pp
|
||||||
For example:
|
For example:
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
/usr -root=0 rickers snowhite.cis.uoguelph.ca
|
/usr -root=0 rickers snowhite.cis.uoguelph.ca
|
||||||
/usr/local 131.104.48.16
|
/usr/local 131.104.48.16
|
||||||
/u -root=5
|
/u -root=5
|
||||||
/u2 -ro
|
/u2 -ro -alldirs
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Given that
|
Given that
|
||||||
@ -116,7 +124,8 @@ with root mapped to root.
|
|||||||
is exported to all hosts with root mapped to uid 5.
|
is exported to all hosts with root mapped to uid 5.
|
||||||
.Pp
|
.Pp
|
||||||
.Sy /u2
|
.Sy /u2
|
||||||
is exported to all hosts Read-only with root mapped to -2.
|
is exported to all hosts Read-only with root mapped to -2. All subdirectories
|
||||||
|
of /u2 may be mounted by remote hosts.
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Note that
|
Note that
|
||||||
|
@ -42,7 +42,7 @@ char copyright[] =
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
/*static char sccsid[] = "from: @(#)mountd.c 5.14 (Berkeley) 2/26/91";*/
|
/*static char sccsid[] = "from: @(#)mountd.c 5.14 (Berkeley) 2/26/91";*/
|
||||||
static char rcsid[] = "$Id: mountd.c,v 1.8 1993/09/07 15:40:37 ws Exp $";
|
static char rcsid[] = "$Id: mountd.c,v 1.9 1993/09/09 16:34:34 ws Exp $";
|
||||||
#endif not lint
|
#endif not lint
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -84,6 +84,7 @@ struct exportlist {
|
|||||||
struct grouplist *ex_groups;
|
struct grouplist *ex_groups;
|
||||||
int ex_rootuid;
|
int ex_rootuid;
|
||||||
int ex_exflags;
|
int ex_exflags;
|
||||||
|
int ex_alldirflg;
|
||||||
dev_t ex_dev;
|
dev_t ex_dev;
|
||||||
char ex_dirp[MNTPATHLEN+1];
|
char ex_dirp[MNTPATHLEN+1];
|
||||||
};
|
};
|
||||||
@ -251,7 +252,8 @@ mntsrv(rqstp, transp)
|
|||||||
omask = sigblock(sigmask(SIGHUP));
|
omask = sigblock(sigmask(SIGHUP));
|
||||||
ep = exphead.ex_next;
|
ep = exphead.ex_next;
|
||||||
while (ep != NULL) {
|
while (ep != NULL) {
|
||||||
if (!strcmp(ep->ex_dirp, dirpath)) {
|
if (!strcmp(ep->ex_dirp, dirpath) ||
|
||||||
|
(stb.st_dev == ep->ex_dev && ep->ex_alldirflg)) {
|
||||||
grp = ep->ex_groups;
|
grp = ep->ex_groups;
|
||||||
if (grp == NULL)
|
if (grp == NULL)
|
||||||
break;
|
break;
|
||||||
@ -458,7 +460,7 @@ get_exportlist()
|
|||||||
char *cp, *endcp;
|
char *cp, *endcp;
|
||||||
char savedc;
|
char savedc;
|
||||||
int len, dirplen;
|
int len, dirplen;
|
||||||
int rootuid, exflags;
|
int rootuid, exflags, alldirflg;
|
||||||
u_long saddr;
|
u_long saddr;
|
||||||
struct exportlist *fep;
|
struct exportlist *fep;
|
||||||
static int first = 0;
|
static int first = 0;
|
||||||
@ -504,6 +506,7 @@ get_exportlist()
|
|||||||
while (fgets(line, LINESIZ, inf)) {
|
while (fgets(line, LINESIZ, inf)) {
|
||||||
exflags = MNT_EXPORTED;
|
exflags = MNT_EXPORTED;
|
||||||
rootuid = def_rootuid;
|
rootuid = def_rootuid;
|
||||||
|
alldirflg = 0;
|
||||||
cp = line;
|
cp = line;
|
||||||
nextfield(&cp, &endcp);
|
nextfield(&cp, &endcp);
|
||||||
|
|
||||||
@ -556,7 +559,8 @@ get_exportlist()
|
|||||||
if (len > MNTNAMLEN)
|
if (len > MNTNAMLEN)
|
||||||
goto more;
|
goto more;
|
||||||
if (*cp == '-') {
|
if (*cp == '-') {
|
||||||
do_opt(cp + 1, fep, ep, &exflags, &rootuid);
|
do_opt(cp + 1, fep, ep, &exflags, &rootuid,
|
||||||
|
&alldirflg);
|
||||||
goto more;
|
goto more;
|
||||||
}
|
}
|
||||||
if (isdigit(*cp)) {
|
if (isdigit(*cp)) {
|
||||||
@ -652,9 +656,17 @@ get_exportlist()
|
|||||||
*cp = savedc;
|
*cp = savedc;
|
||||||
ep->ex_rootuid = rootuid;
|
ep->ex_rootuid = rootuid;
|
||||||
ep->ex_exflags = exflags;
|
ep->ex_exflags = exflags;
|
||||||
|
ep->ex_alldirflg = alldirflg;
|
||||||
} else {
|
} else {
|
||||||
|
if (alldirflg || fep->ex_alldirflg) {
|
||||||
|
syslog(LOG_WARNING,
|
||||||
|
"Can't export alldirs plus other exports");
|
||||||
|
free_exp(ep);
|
||||||
|
goto nextline;
|
||||||
|
}
|
||||||
ep->ex_rootuid = fep->ex_rootuid;
|
ep->ex_rootuid = fep->ex_rootuid;
|
||||||
ep->ex_exflags = fep->ex_exflags;
|
ep->ex_exflags = fep->ex_exflags;
|
||||||
|
ep->ex_alldirflg = 0;
|
||||||
}
|
}
|
||||||
ep->ex_dev = sb.st_dev;
|
ep->ex_dev = sb.st_dev;
|
||||||
ep->ex_next = exphead.ex_next;
|
ep->ex_next = exphead.ex_next;
|
||||||
@ -697,10 +709,10 @@ nextfield(cp, endcp)
|
|||||||
/*
|
/*
|
||||||
* Parse the option string
|
* Parse the option string
|
||||||
*/
|
*/
|
||||||
do_opt(cpopt, fep, ep, exflagsp, rootuidp)
|
do_opt(cpopt, fep, ep, exflagsp, rootuidp, alldirflgp)
|
||||||
register char *cpopt;
|
register char *cpopt;
|
||||||
struct exportlist *fep, *ep;
|
struct exportlist *fep, *ep;
|
||||||
int *exflagsp, *rootuidp;
|
int *exflagsp, *rootuidp, *alldirflgp;
|
||||||
{
|
{
|
||||||
register char *cpoptarg, *cpoptend;
|
register char *cpoptarg, *cpoptend;
|
||||||
|
|
||||||
@ -726,6 +738,8 @@ do_opt(cpopt, fep, ep, exflagsp, rootuidp)
|
|||||||
syslog(LOG_WARNING,
|
syslog(LOG_WARNING,
|
||||||
"uid failed for %s",
|
"uid failed for %s",
|
||||||
ep->ex_dirp);
|
ep->ex_dirp);
|
||||||
|
} else if (!strcmp(cpopt, "alldirs") || !strcmp(cpopt, "a")) {
|
||||||
|
*alldirflgp = 1;
|
||||||
} else
|
} else
|
||||||
syslog(LOG_WARNING, "opt %s ignored for %s", cpopt,
|
syslog(LOG_WARNING, "opt %s ignored for %s", cpopt,
|
||||||
ep->ex_dirp);
|
ep->ex_dirp);
|
||||||
|
Loading…
Reference in New Issue
Block a user