Correct improper use of .Sm. Document -d flag. Correct use of .Nm. Remove

unused #includes. Add usage(). Use warnx(). Correct spelling. Abort when
malloc() fails.
This commit is contained in:
Philippe Charnier 1998-07-15 06:21:41 +00:00
parent aae0aa4593
commit 7485340223
8 changed files with 378 additions and 306 deletions

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)exports.5 8.3 (Berkeley) 3/29/95
.\" $Id: exports.5,v 1.5 1997/03/12 15:08:06 mpp Exp $
.\" $Id: exports.5,v 1.6 1997/07/16 09:27:50 dfr Exp $
.\"
.Dd March 29, 1995
.Dt EXPORTS 5
@ -44,7 +44,7 @@ mount requests
.Nm exports
.Sh DESCRIPTION
The
.Nm exports
.Nm
file specifies remote mount points for the
.Tn NFS
mount protocol per the
@ -158,13 +158,16 @@ is a synonym for
.Fl ro
in an effort to be backward compatible with older export file formats.
.Pp
WebNFS exports strictly according to the spec (RFC 2054 and RFC 2055) can
.Tn WebNFS
exports strictly according to the spec (RFC 2054 and RFC 2055) can
be done with the
.Fl public
flag. However, this flag in itself allows r/w access to all files in
the filesystem, not requiring reserved ports and not remapping uids. It
is only provided to conform to the spec, and should normally not be used.
For a WebNFS export,
For a
.Tn WebNFS
export,
use the
.Fl webnfs
flag, which implies
@ -178,10 +181,11 @@ and
A
.Sm off
.Fl index No = Sy file
.Sm off
.Sm on
option can be used to specify a file whose handle will be returned if
a directory is looked up using the public filehandle (WebNFS). This
is to mimic the behavior of URLs. If no
a directory is looked up using the public filehandle (
.Tn WebNFS Ns ).
This is to mimic the behavior of URLs. If no
.Fl index
option is specified, a directory filehandle will be returned as usual.
The
@ -195,10 +199,10 @@ flags.
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.
(Standard internet ``dot'' addresses may be used in place of names.)
(Standard Internet ``dot'' addresses may be used in place of names.)
The second way is to specify a ``netgroup'' as defined in the netgroup file (see
.Xr netgroup 5 ).
The third way is to specify an internet subnetwork using a network and
The third way is to specify an Internet subnetwork using a network and
network mask that is defined as the set of all hosts with addresses within
the subnetwork.
This latter approach requires less overhead within the
@ -271,7 +275,7 @@ that is authenticated by a Kerberos ticket.
.Sh FILES
.Bl -tag -width /etc/exports -compact
.It Pa /etc/exports
The default remote mount-point file.
the default remote mount-point file
.El
.Sh SEE ALSO
.Xr netgroup 5 ,

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)mountd.8 8.4 (Berkeley) 4/28/95
.\" $Id: mountd.8,v 1.11 1997/12/09 18:43:44 guido Exp $
.\" $Id: mountd.8,v 1.12 1997/12/10 20:33:58 guido Exp $
.\"
.Dd April 28, 1995
.Dt MOUNTD 8
@ -41,16 +41,15 @@
.Tn NFS
mount requests
.Sh SYNOPSIS
.Nm /sbin/mountd
.Op Fl 2lnr
.Nm mountd
.Op Fl 2dlnr
.Op Ar exportsfile
.Sh DESCRIPTION
.Xr Mountd
.Nm Mountd
is the server for
.Tn NFS
mount requests from other client machines.
.Xr Mountd
listens for service requests at the port indicated in the
It listens for service requests at the port indicated in the
.Tn NFS
server specification; see
.%T "Network File System Protocol Specification" ,
@ -58,30 +57,27 @@ RFC1094, Appendix A and
.%T "NFS: Network File System Version 3 Protocol Specification" ,
Appendix I.
.Pp
Options and operands available for
.Nm mountd :
.Bl -tag -width Ds
The following options are available:
.Bl -tag -width indent
.It Fl 2
The
.Fl 2
option allows the administrator to force clients to use only the
version 2 NFS protocol to mount filesystems from this server.
Allow the administrator to force clients to use only the
version 2
.Tn NFS
protocol to mount filesystems from this server.
.It Fl d
Output debugging information.
.It Fl l
The
.Fl l
option will cause all succeeded mountd requests to be logged.
Cause all succeeded
.Nm
requests to be logged.
.It Fl n
The
.Fl n
option allows non-root mount requests to be served.
Allow non-root mount requests to be served.
This should only be specified if there are clients such as PC's,
that require it.
It will automatically clear the vfs.nfs.nfs_privport sysctl flag, which
controls if the kernel will accept nfs requests form reserved ports only.
controls if the kernel will accept NFS requests form reserved ports only.
.It Fl r
The
.Fl r
option allows mount RPCs requests for regular files to be served.
Allow mount RPCs requests for regular files to be served.
Although this seems to violate the mount protocol specification,
some diskless workstations do mount requests for
their swapfiles and expect them to be regular files.
@ -92,25 +88,29 @@ will have to be exported with the
.Fl alldirs
flag.
.It Ar exportsfile
The
.Ar exportsfile
argument specifies an alternate location
Specify an alternate location
for the exports file.
.El
.Pp
When mountd is started,
When
.Nm
is started,
it loads the export host addresses and options into the kernel
using the mount(2) system call.
After changing the exports file,
a hangup signal should be sent to the mountd daemon
a hangup signal should be sent to the
.Nm
daemon
to get it to reload the export information.
After sending the SIGHUP
(kill \-s HUP `cat /var/run/mountd.pid`),
check the syslog output to see if mountd logged any parsing
check the syslog output to see if
.Nm
logged any parsing
errors in the exports file.
.Pp
If
.Nm mountd
.Nm
detects that the running kernel does not include
.Tn NFS
support, it will attempt to load a loadable kernel module containing
@ -122,7 +122,7 @@ by way of
If this fails, or no
.Tn NFS
LKM was available,
.Nm mountd
.Nm
exits with an error.
.Sh FILES
.Bl -tag -width /var/run/mountd.pid -compact
@ -142,6 +142,6 @@ the current list of remote mounted filesystems
.Xr showmount 8
.Sh HISTORY
The
.Nm mountd
.Nm
utility first appeared in
.Bx 4.4 .

View File

@ -35,30 +35,27 @@
*/
#ifndef lint
static char copyright[] =
static const char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /*not lint*/
#ifndef lint
/*static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; */
#if 0
static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95";
#endif
static const char rcsid[] =
"$Id: mountd.c,v 1.30 1998/06/15 15:43:13 joerg Exp $";
"$Id$";
#endif /*not lint*/
#include <sys/param.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/syslog.h>
#include <sys/ucred.h>
#include <sys/sysctl.h>
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
#include <rpc/pmap_prot.h>
#ifdef ISO
#include <netiso/iso.h>
#endif
@ -72,6 +69,7 @@ static const char rcsid[] =
#include <arpa/inet.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <grp.h>
#include <netdb.h>
@ -197,6 +195,7 @@ int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *));
int scan_tree __P((struct dirlist *, u_long));
void send_umntall __P((void));
int umntall_each __P((caddr_t, struct sockaddr_in *));
static void usage __P((void));
int xdr_dir __P((XDR *, char *));
int xdr_explist __P((XDR *, caddr_t));
int xdr_fhs __P((XDR *, caddr_t));
@ -287,9 +286,7 @@ main(argc, argv)
log = 1;
break;
default:
fprintf(stderr,
"Usage: mountd [-d] [-l] [-r] [-n] [export_file]\n");
exit(1);
usage();
};
argc -= optind;
argv += optind;
@ -303,13 +300,13 @@ main(argc, argv)
strcpy(exname, _PATH_EXPORTS);
openlog("mountd", LOG_PID, LOG_DAEMON);
if (debug)
fprintf(stderr,"Getting export list.\n");
warnx("getting export list");
get_exportlist();
if (debug)
fprintf(stderr,"Getting mount list.\n");
warnx("getting mount list");
get_mountlist();
if (debug)
fprintf(stderr,"Here we go.\n");
warnx("here we go");
if (debug == 0) {
daemon(0, 0);
signal(SIGINT, SIG_IGN);
@ -335,7 +332,7 @@ main(argc, argv)
}
if ((udptransp = svcudp_create(RPC_ANYSOCK)) == NULL ||
(tcptransp = svctcp_create(RPC_ANYSOCK, 0, 0)) == NULL) {
syslog(LOG_ERR, "Can't create socket");
syslog(LOG_ERR, "can't create socket");
exit(1);
}
pmap_unset(RPCPROG_MNT, 1);
@ -343,16 +340,24 @@ main(argc, argv)
if (!force_v2)
if (!svc_register(udptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_UDP) ||
!svc_register(tcptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_TCP)) {
syslog(LOG_ERR, "Can't register mount");
syslog(LOG_ERR, "can't register mount");
exit(1);
}
if (!svc_register(udptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_UDP) ||
!svc_register(tcptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_TCP)) {
syslog(LOG_ERR, "Can't register mount");
syslog(LOG_ERR, "can't register mount");
exit(1);
}
svc_run();
syslog(LOG_ERR, "Mountd died");
syslog(LOG_ERR, "mountd died");
exit(1);
}
static void
usage()
{
fprintf(stderr,
"usage: mountd [-2] [-d] [-l] [-n] [-r] [export_file]\n");
exit(1);
}
@ -386,7 +391,7 @@ mntsrv(rqstp, transp)
switch (rqstp->rq_proc) {
case NULLPROC:
if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
return;
case RPCMNT_MOUNT:
if (sport >= IPPORT_RESERVED && resvport_only) {
@ -415,10 +420,10 @@ mntsrv(rqstp, transp)
statfs(dirpath, &fsb) < 0) {
chdir("/"); /* Just in case realpath doesn't */
syslog(LOG_NOTICE,
"mount request from %s for non existant path %s",
"mount request from %s for non existent path %s",
inet_ntoa(saddrin), dirpath);
if (debug)
fprintf(stderr, "stat failed on %s\n", dirpath);
warnx("stat failed on %s", dirpath);
bad = ENOENT; /* We will send error reply later */
}
@ -434,7 +439,7 @@ mntsrv(rqstp, transp)
if (bad) {
if (!svc_sendreply(transp, xdr_long,
(caddr_t)&bad))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
return;
}
@ -447,15 +452,15 @@ mntsrv(rqstp, transp)
memset(&fhr.fhr_fh, 0, sizeof(nfsfh_t));
if (getfh(dirpath, (fhandle_t *)&fhr.fhr_fh) < 0) {
bad = errno;
syslog(LOG_ERR, "Can't get fh for %s", dirpath);
syslog(LOG_ERR, "can't get fh for %s", dirpath);
if (!svc_sendreply(transp, xdr_long,
(caddr_t)&bad))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
return;
}
if (!svc_sendreply(transp, xdr_fhs, (caddr_t)&fhr))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
if (hp == NULL)
hp = gethostbyaddr((caddr_t)&saddr,
sizeof(saddr), AF_INET);
@ -465,7 +470,7 @@ mntsrv(rqstp, transp)
add_mlist(inet_ntoa(saddrin),
dirpath);
if (debug)
fprintf(stderr,"Mount successfull.\n");
warnx("mount successful");
if (log)
syslog(LOG_NOTICE,
"mount request succeeded from %s for %s",
@ -478,12 +483,12 @@ mntsrv(rqstp, transp)
}
if (bad && !svc_sendreply(transp, xdr_long, (caddr_t)&bad))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
return;
case RPCMNT_DUMP:
if (!svc_sendreply(transp, xdr_mlist, (caddr_t)NULL))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
else if (log)
syslog(LOG_NOTICE,
"dump request succeeded from %s",
@ -504,7 +509,7 @@ mntsrv(rqstp, transp)
return;
}
if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
hp = gethostbyaddr((caddr_t)&saddr, sizeof(saddr), AF_INET);
if (hp)
del_mlist(hp->h_name, dirpath);
@ -523,7 +528,7 @@ mntsrv(rqstp, transp)
return;
}
if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
hp = gethostbyaddr((caddr_t)&saddr, sizeof(saddr), AF_INET);
if (hp)
del_mlist(hp->h_name, (char *)NULL);
@ -535,7 +540,7 @@ mntsrv(rqstp, transp)
return;
case RPCMNT_EXPORT:
if (!svc_sendreply(transp, xdr_explist, (caddr_t)NULL))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
if (log)
syslog(LOG_NOTICE,
"export request succeeded from %s",
@ -783,7 +788,7 @@ get_exportlist()
if (mount(fsp->f_fstypename, fsp->f_mntonname,
fsp->f_flags | MNT_UPDATE,
(caddr_t)&targs) < 0)
syslog(LOG_ERR, "Can't delete exports for %s",
syslog(LOG_ERR, "can't delete exports for %s",
fsp->f_mntonname);
}
fsp++;
@ -794,13 +799,13 @@ get_exportlist()
* mount() as we go along to push the export rules into the kernel.
*/
if ((exp_file = fopen(exname, "r")) == NULL) {
syslog(LOG_ERR, "Can't open %s", exname);
syslog(LOG_ERR, "can't open %s", exname);
exit(2);
}
dirhead = (struct dirlist *)NULL;
while (get_line()) {
if (debug)
fprintf(stderr,"Got line %s\n",line);
warnx("got line %s", line);
cp = line;
nextfield(&cp, &endcp);
if (*cp == '#')
@ -832,7 +837,7 @@ get_exportlist()
goto nextline;
}
if (debug)
fprintf(stderr, "doing opt %s\n", cp);
warnx("doing opt %s", cp);
got_nondir = 1;
if (do_opt(&cp, &endcp, ep, grp, &has_host,
&exflags, &anon)) {
@ -845,7 +850,7 @@ get_exportlist()
if (check_dirpath(cp) &&
statfs(cp, &fsb) >= 0) {
if (got_nondir) {
syslog(LOG_ERR, "Dirs must be first");
syslog(LOG_ERR, "dirs must be first");
getexp_err(ep, tgrp);
goto nextline;
}
@ -872,13 +877,11 @@ get_exportlist()
else
out_of_mem();
if (debug)
fprintf(stderr,
"Making new ep fs=0x%x,0x%x\n",
warnx("making new ep fs=0x%x,0x%x",
fsb.f_fsid.val[0],
fsb.f_fsid.val[1]);
} else if (debug)
fprintf(stderr,
"Found ep fs=0x%x,0x%x\n",
warnx("found ep fs=0x%x,0x%x",
fsb.f_fsid.val[0],
fsb.f_fsid.val[1]);
}
@ -914,14 +917,16 @@ get_exportlist()
}
if (netgrp) {
if (hst == 0) {
syslog(LOG_ERR, "Null hostname in netgroup %s, skipping", cp);
syslog(LOG_ERR,
"null hostname in netgroup %s, skipping", cp);
grp->gr_type = GT_IGNORE;
} else if (get_host(hst, grp, tgrp)) {
syslog(LOG_ERR, "Bad host %s in netgroup %s, skipping", hst, cp);
syslog(LOG_ERR,
"bad host %s in netgroup %s, skipping", hst, cp);
grp->gr_type = GT_IGNORE;
}
} else if (get_host(cp, grp, tgrp)) {
syslog(LOG_ERR, "Bad host %s, skipping", cp);
syslog(LOG_ERR, "bad host %s, skipping", cp);
grp->gr_type = GT_IGNORE;
}
has_host = TRUE;
@ -940,7 +945,7 @@ get_exportlist()
if (!has_host) {
grp->gr_type = GT_HOST;
if (debug)
fprintf(stderr,"Adding a default entry\n");
warnx("adding a default entry");
/* add a default group and make the grp list NULL */
hpe = (struct hostent *)malloc(sizeof(struct hostent));
if (hpe == (struct hostent *)NULL)
@ -1065,7 +1070,7 @@ getexp_err(ep, grp)
{
struct grouplist *tgrp;
syslog(LOG_ERR, "Bad exports list line %s", line);
syslog(LOG_ERR, "bad exports list line %s", line);
if (ep && (ep->ex_flag & EX_LINKED) == 0)
free_exp(ep);
while (grp) {
@ -1106,6 +1111,8 @@ add_expdir(dpp, cp, len)
struct dirlist *dp;
dp = (struct dirlist *)malloc(sizeof (struct dirlist) + len);
if (dp == (struct dirlist *)NULL)
out_of_mem();
dp->dp_left = *dpp;
dp->dp_right = (struct dirlist *)NULL;
dp->dp_flag = 0;
@ -1150,7 +1157,7 @@ hang_dirp(dp, grp, ep, flags)
} else {
/*
* Loop throught the directories adding them to the tree.
* Loop through the directories adding them to the tree.
*/
while (dp) {
dp2 = dp->dp_left;
@ -1343,12 +1350,12 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
while (cpopt && *cpopt) {
allflag = 1;
usedarg = -2;
if (cpoptend = strchr(cpopt, ',')) {
if ((cpoptend = strchr(cpopt, ','))) {
*cpoptend++ = '\0';
if (cpoptarg = strchr(cpopt, '='))
if ((cpoptarg = strchr(cpopt, '=')))
*cpoptarg++ = '\0';
} else {
if (cpoptarg = strchr(cpopt, '='))
if ((cpoptarg = strchr(cpopt, '=')))
*cpoptarg++ = '\0';
else {
*cp = savedc;
@ -1380,7 +1387,7 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
} else if (cpoptarg && (!strcmp(cpopt, "mask") ||
!strcmp(cpopt, "m"))) {
if (get_net(cpoptarg, &grp->gr_ptr.gt_net, 1)) {
syslog(LOG_ERR, "Bad mask: %s", cpoptarg);
syslog(LOG_ERR, "bad mask: %s", cpoptarg);
return (1);
}
usedarg++;
@ -1388,10 +1395,10 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
} else if (cpoptarg && (!strcmp(cpopt, "network") ||
!strcmp(cpopt, "n"))) {
if (grp->gr_type != GT_NULL) {
syslog(LOG_ERR, "Network/host conflict");
syslog(LOG_ERR, "network/host conflict");
return (1);
} else if (get_net(cpoptarg, &grp->gr_ptr.gt_net, 0)) {
syslog(LOG_ERR, "Bad net: %s", cpoptarg);
syslog(LOG_ERR, "bad net: %s", cpoptarg);
return (1);
}
grp->gr_type = GT_NET;
@ -1410,7 +1417,7 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
#ifdef ISO
} else if (cpoptarg && !strcmp(cpopt, "iso")) {
if (get_isoaddr(cpoptarg, grp)) {
syslog(LOG_ERR, "Bad iso addr: %s", cpoptarg);
syslog(LOG_ERR, "bad iso addr: %s", cpoptarg);
return (1);
}
*has_hostp = 1;
@ -1418,7 +1425,7 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
opt_flags |= OP_ISO;
#endif /* ISO */
} else {
syslog(LOG_ERR, "Bad opt %s", cpopt);
syslog(LOG_ERR, "bad opt %s", cpopt);
return (1);
}
if (usedarg >= 0) {
@ -1460,7 +1467,7 @@ get_host(cp, grp, tgrp)
if (isdigit(*cp)) {
saddr = inet_addr(cp);
if (saddr == -1) {
syslog(LOG_ERR, "Inet_addr failed for %s", cp);
syslog(LOG_ERR, "inet_addr failed for %s", cp);
return (1);
}
if ((hp = gethostbyaddr((caddr_t)&saddr, sizeof (saddr),
@ -1474,7 +1481,7 @@ get_host(cp, grp, tgrp)
aptr[1] = (char *)NULL;
}
} else {
syslog(LOG_ERR, "Gethostbyname failed for %s", cp);
syslog(LOG_ERR, "gethostbyname failed for %s", cp);
return (1);
}
}
@ -1510,14 +1517,12 @@ get_host(cp, grp, tgrp)
i = 1;
while (*addrp++)
i++;
naddrp = nhp->h_addr_list = (char **)
malloc(i*sizeof(char *));
naddrp = nhp->h_addr_list = (char **)malloc(i*sizeof(char *));
if (naddrp == (char **)NULL)
out_of_mem();
addrp = hp->h_addr_list;
while (*addrp) {
*naddrp = (char *)
malloc(hp->h_length);
*naddrp = (char *)malloc(hp->h_length);
if (*naddrp == (char *)NULL)
out_of_mem();
memmove(*naddrp, *addrp, hp->h_length);
@ -1526,7 +1531,7 @@ get_host(cp, grp, tgrp)
}
*naddrp = (char *)NULL;
if (debug)
fprintf(stderr, "got host %s\n", hp->h_name);
warnx("got host %s", hp->h_name);
return (0);
}
@ -1593,12 +1598,10 @@ get_isoaddr(cp, grp)
if (grp->gr_type != GT_NULL)
return (1);
if ((isop = iso_addr(cp)) == NULL) {
syslog(LOG_ERR,
"iso_addr failed, ignored");
syslog(LOG_ERR, "iso_addr failed, ignored");
return (1);
}
isoaddr = (struct sockaddr_iso *)
malloc(sizeof (struct sockaddr_iso));
isoaddr = (struct sockaddr_iso *)malloc(sizeof (struct sockaddr_iso));
if (isoaddr == (struct sockaddr_iso *)NULL)
out_of_mem();
memset(isoaddr, 0, sizeof(struct sockaddr_iso));
@ -1618,7 +1621,7 @@ void
out_of_mem()
{
syslog(LOG_ERR, "Out of memory");
syslog(LOG_ERR, "out of memory");
exit(2);
}
@ -1711,7 +1714,7 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
return(0);
break;
default:
syslog(LOG_ERR, "Bad grouptype");
syslog(LOG_ERR, "bad grouptype");
if (cp)
*cp = savedc;
return (1);
@ -1732,11 +1735,11 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
cp = dirp + dirplen - 1;
if (errno == EPERM) {
syslog(LOG_ERR,
"Can't change attributes for %s.\n", dirp);
"can't change attributes for %s", dirp);
return (1);
}
if (opt_flags & OP_ALLDIRS) {
syslog(LOG_ERR, "Could not remount %s: %m",
syslog(LOG_ERR, "could not remount %s: %m",
dirp);
return (1);
}
@ -1747,8 +1750,8 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
cp--;
if (cp == dirp) {
if (debug)
fprintf(stderr,"mnt unsucc\n");
syslog(LOG_ERR, "Can't export %s", dirp);
warnx("mnt unsucc");
syslog(LOG_ERR, "can't export %s", dirp);
return (1);
}
savedc = *cp;
@ -1783,7 +1786,7 @@ get_net(cp, net, maskflg)
if (isdigit(*cp) && ((netaddr = inet_network(cp)) != -1)) {
inetaddr = inet_makeaddr(netaddr, 0);
/*
* Due to arbritrary subnet masks, you don't know how many
* Due to arbitrary subnet masks, you don't know how many
* bits to shift the address to make it into a network,
* however you do know how to make a network address into
* a host with host == 0 and then compare them.
@ -1791,7 +1794,7 @@ get_net(cp, net, maskflg)
*/
if (!maskflg) {
setnetent(0);
while (np = getnetent()) {
while ((np = getnetent())) {
inetaddr2 = inet_makeaddr(np->n_net, 0);
if (inetaddr2.s_addr == inetaddr.s_addr)
break;
@ -1875,7 +1878,7 @@ get_line()
if (len > 0) {
totlen += len;
if (totlen >= LINESIZ) {
syslog(LOG_ERR, "Exports line too long");
syslog(LOG_ERR, "exports line too long");
exit(2);
}
p = cp;
@ -1900,7 +1903,7 @@ parsecred(namelist, cr)
int ngroups, groups[NGROUPS + 1];
/*
* Set up the unpriviledged user.
* Set up the unprivileged user.
*/
cr->cr_ref = 1;
cr->cr_uid = -2;
@ -1920,13 +1923,13 @@ parsecred(namelist, cr)
*/
if (names == NULL) {
if (pw == NULL) {
syslog(LOG_ERR, "Unknown user: %s", name);
syslog(LOG_ERR, "unknown user: %s", name);
return;
}
cr->cr_uid = pw->pw_uid;
ngroups = NGROUPS + 1;
if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups))
syslog(LOG_ERR, "Too many groups");
syslog(LOG_ERR, "too many groups");
/*
* Convert from int's to gid_t's and compress out duplicate
*/
@ -1945,7 +1948,7 @@ parsecred(namelist, cr)
else if (isdigit(*name) || *name == '-')
cr->cr_uid = atoi(name);
else {
syslog(LOG_ERR, "Unknown user: %s", name);
syslog(LOG_ERR, "unknown user: %s", name);
return;
}
cr->cr_ngroups = 0;
@ -1955,14 +1958,14 @@ parsecred(namelist, cr)
cr->cr_groups[cr->cr_ngroups++] = atoi(name);
} else {
if ((gr = getgrnam(name)) == NULL) {
syslog(LOG_ERR, "Unknown group: %s", name);
syslog(LOG_ERR, "unknown group: %s", name);
continue;
}
cr->cr_groups[cr->cr_ngroups++] = gr->gr_gid;
}
}
if (names != NULL && *names != '\0' && cr->cr_ngroups == NGROUPS)
syslog(LOG_ERR, "Too many groups");
syslog(LOG_ERR, "too many groups");
}
#define STRSIZ (RPCMNT_NAMELEN+RPCMNT_PATHLEN+50)
@ -1974,12 +1977,11 @@ get_mountlist()
{
struct mountlist *mlp, **mlpp;
char *host, *dirp, *cp;
int len;
char str[STRSIZ];
FILE *mlfile;
if ((mlfile = fopen(_PATH_RMOUNTLIST, "r")) == NULL) {
syslog(LOG_ERR, "Can't open %s", _PATH_RMOUNTLIST);
syslog(LOG_ERR, "can't open %s", _PATH_RMOUNTLIST);
return;
}
mlpp = &mlhead;
@ -1990,6 +1992,8 @@ get_mountlist()
if (host == NULL || dirp == NULL)
continue;
mlp = (struct mountlist *)malloc(sizeof (*mlp));
if (mlp == (struct mountlist *)NULL)
out_of_mem();
strncpy(mlp->ml_host, host, RPCMNT_NAMELEN);
mlp->ml_host[RPCMNT_NAMELEN] = '\0';
strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN);
@ -2026,7 +2030,7 @@ del_mlist(hostp, dirp)
}
if (fnd) {
if ((mlfile = fopen(_PATH_RMOUNTLIST, "w")) == NULL) {
syslog(LOG_ERR,"Can't update %s", _PATH_RMOUNTLIST);
syslog(LOG_ERR,"can't update %s", _PATH_RMOUNTLIST);
return;
}
mlp = mlhead;
@ -2054,6 +2058,8 @@ add_mlist(hostp, dirp)
mlp = mlp->ml_next;
}
mlp = (struct mountlist *)malloc(sizeof (*mlp));
if (mlp == (struct mountlist *)NULL)
out_of_mem();
strncpy(mlp->ml_host, hostp, RPCMNT_NAMELEN);
mlp->ml_host[RPCMNT_NAMELEN] = '\0';
strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN);
@ -2061,7 +2067,7 @@ add_mlist(hostp, dirp)
mlp->ml_next = (struct mountlist *)NULL;
*mlpp = mlp;
if ((mlfile = fopen(_PATH_RMOUNTLIST, "a")) == NULL) {
syslog(LOG_ERR, "Can't update %s", _PATH_RMOUNTLIST);
syslog(LOG_ERR, "can't update %s", _PATH_RMOUNTLIST);
return;
}
fprintf(mlfile, "%s %s\n", mlp->ml_host, mlp->ml_dirp);

View File

@ -41,7 +41,7 @@
.Nm netgroup
.Sh DESCRIPTION
The
.Nm netgroup
.Nm
file
specifies ``netgroups'', which are sets of
.Sy (host, user, domain)
@ -55,6 +55,7 @@ of a tuple as follows:
.Bd -literal -offset indent
(host, user, domain)
.Ed
.Pp
where the
.Sy host ,
.Sy user ,
@ -69,43 +70,56 @@ line continuation. Lines are limited to 1024 characters.
The functions specified in
.Xr getnetgrent 3
should normally be used to access the
.Nm netgroup
.Nm
database.
.Pp
Lines that begin with a # are treated as comments.
.Sh NIS/YP INTERACTION
On most other platforms,
.Nm netgroups
.Nm Ns s
are only used in conjunction with
NIS and local
.Tn NIS
and local
.Pa /etc/netgroup
files are ignored. With FreeBSD,
.Nm netgroups
can be used with either NIS or local files, but there are certain
files are ignored. With
.Bx Free ,
.Nm Ns s
can be used with either
.Tn NIS
or local files, but there are certain
caveats to consider. The existing
.Nm netgroup
.Nm
system is extremely inefficient where
.Fn innetgr 3
lookups are concerned since
.Nm netgroup
memberships are computed on the fly. By contrast, the NIS
.Nm netgroup
.Nm
memberships are computed on the fly. By contrast, the
.Tn NIS
.Nm
database consists of three separate maps (netgroup, netgroup.byuser
and netgroup.byhost) that are keyed to allow
.Fn innetgr 3
lookups to be done quickly. The FreeBSD
.Nm netgroup
system can interact with the NIS
.Nm netgroup
lookups to be done quickly. The
.Bx Free
.Nm
system can interact with the
.Tn NIS
.Nm
maps in the following ways:
.Bl -bullet -offset indent
.It
If the
.Pa /etc/netgroup
file does not exist, or it exists and is empty, or
it exists and contains only a '+', and NIS is running,
.Nm netgroup
lookups will be done exclusively through NIS, with
it exists and contains only a
.Sq + ,
and
.Tn NIS
is running,
.Nm
lookups will be done exclusively through
.Tn NIS ,
with
.Fn innetgr 3
taking advantage of the netgroup.byuser and
netgroup.byhost maps to speed up searches. (This
@ -115,18 +129,28 @@ similar platforms.)
If the
.Pa /etc/netgroup
exists and contains only local
.Nm netgroup
information (with no NIS '+' token), then only the local
.Nm netgroup
information will be processed (and NIS will be ignored).
.Nm
information (with no
.Tn NIS
.Sq +
token), then only the local
.Nm
information will be processed (and
.Tn NIS
will be ignored).
.It
If
.Pa /etc/netgroup
exists and contains both local netgroup data
.Pa and
the NIS '+' token, the local data and the NIS netgroup
the
.Tn NIS
.Sq +
token, the local data and the
.Tn NIS
netgroup
map will be processed as a single combined
.Nm netgroup
.Nm
database. While this configuration is the most flexible, it
is also the least efficient: in particular,
.Fn innetgr 3
@ -136,7 +160,7 @@ database is large.
.Sh FILES
.Bl -tag -width /etc/netgroup -compact
.It Pa /etc/netgroup
the netgroup database.
the netgroup database
.El
.Sh SEE ALSO
.Xr getnetgrent 3 ,
@ -148,10 +172,12 @@ appears that not all vendors use an identical format.
The interpretation of access restrictions based on the member tuples of a
netgroup is left up to the various network applications.
Also, it is not obvious how the domain specification
applies to the BSD environment.
applies to the
.Bx
environment.
.Pp
The
.Nm netgroup
.Nm
database should be stored in the form of a
hashed
.Xr db 3

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)exports.5 8.3 (Berkeley) 3/29/95
.\" $Id: exports.5,v 1.5 1997/03/12 15:08:06 mpp Exp $
.\" $Id: exports.5,v 1.6 1997/07/16 09:27:50 dfr Exp $
.\"
.Dd March 29, 1995
.Dt EXPORTS 5
@ -44,7 +44,7 @@ mount requests
.Nm exports
.Sh DESCRIPTION
The
.Nm exports
.Nm
file specifies remote mount points for the
.Tn NFS
mount protocol per the
@ -158,13 +158,16 @@ is a synonym for
.Fl ro
in an effort to be backward compatible with older export file formats.
.Pp
WebNFS exports strictly according to the spec (RFC 2054 and RFC 2055) can
.Tn WebNFS
exports strictly according to the spec (RFC 2054 and RFC 2055) can
be done with the
.Fl public
flag. However, this flag in itself allows r/w access to all files in
the filesystem, not requiring reserved ports and not remapping uids. It
is only provided to conform to the spec, and should normally not be used.
For a WebNFS export,
For a
.Tn WebNFS
export,
use the
.Fl webnfs
flag, which implies
@ -178,10 +181,11 @@ and
A
.Sm off
.Fl index No = Sy file
.Sm off
.Sm on
option can be used to specify a file whose handle will be returned if
a directory is looked up using the public filehandle (WebNFS). This
is to mimic the behavior of URLs. If no
a directory is looked up using the public filehandle (
.Tn WebNFS Ns ).
This is to mimic the behavior of URLs. If no
.Fl index
option is specified, a directory filehandle will be returned as usual.
The
@ -195,10 +199,10 @@ flags.
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.
(Standard internet ``dot'' addresses may be used in place of names.)
(Standard Internet ``dot'' addresses may be used in place of names.)
The second way is to specify a ``netgroup'' as defined in the netgroup file (see
.Xr netgroup 5 ).
The third way is to specify an internet subnetwork using a network and
The third way is to specify an Internet subnetwork using a network and
network mask that is defined as the set of all hosts with addresses within
the subnetwork.
This latter approach requires less overhead within the
@ -271,7 +275,7 @@ that is authenticated by a Kerberos ticket.
.Sh FILES
.Bl -tag -width /etc/exports -compact
.It Pa /etc/exports
The default remote mount-point file.
the default remote mount-point file
.El
.Sh SEE ALSO
.Xr netgroup 5 ,

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)mountd.8 8.4 (Berkeley) 4/28/95
.\" $Id: mountd.8,v 1.11 1997/12/09 18:43:44 guido Exp $
.\" $Id: mountd.8,v 1.12 1997/12/10 20:33:58 guido Exp $
.\"
.Dd April 28, 1995
.Dt MOUNTD 8
@ -41,16 +41,15 @@
.Tn NFS
mount requests
.Sh SYNOPSIS
.Nm /sbin/mountd
.Op Fl 2lnr
.Nm mountd
.Op Fl 2dlnr
.Op Ar exportsfile
.Sh DESCRIPTION
.Xr Mountd
.Nm Mountd
is the server for
.Tn NFS
mount requests from other client machines.
.Xr Mountd
listens for service requests at the port indicated in the
It listens for service requests at the port indicated in the
.Tn NFS
server specification; see
.%T "Network File System Protocol Specification" ,
@ -58,30 +57,27 @@ RFC1094, Appendix A and
.%T "NFS: Network File System Version 3 Protocol Specification" ,
Appendix I.
.Pp
Options and operands available for
.Nm mountd :
.Bl -tag -width Ds
The following options are available:
.Bl -tag -width indent
.It Fl 2
The
.Fl 2
option allows the administrator to force clients to use only the
version 2 NFS protocol to mount filesystems from this server.
Allow the administrator to force clients to use only the
version 2
.Tn NFS
protocol to mount filesystems from this server.
.It Fl d
Output debugging information.
.It Fl l
The
.Fl l
option will cause all succeeded mountd requests to be logged.
Cause all succeeded
.Nm
requests to be logged.
.It Fl n
The
.Fl n
option allows non-root mount requests to be served.
Allow non-root mount requests to be served.
This should only be specified if there are clients such as PC's,
that require it.
It will automatically clear the vfs.nfs.nfs_privport sysctl flag, which
controls if the kernel will accept nfs requests form reserved ports only.
controls if the kernel will accept NFS requests form reserved ports only.
.It Fl r
The
.Fl r
option allows mount RPCs requests for regular files to be served.
Allow mount RPCs requests for regular files to be served.
Although this seems to violate the mount protocol specification,
some diskless workstations do mount requests for
their swapfiles and expect them to be regular files.
@ -92,25 +88,29 @@ will have to be exported with the
.Fl alldirs
flag.
.It Ar exportsfile
The
.Ar exportsfile
argument specifies an alternate location
Specify an alternate location
for the exports file.
.El
.Pp
When mountd is started,
When
.Nm
is started,
it loads the export host addresses and options into the kernel
using the mount(2) system call.
After changing the exports file,
a hangup signal should be sent to the mountd daemon
a hangup signal should be sent to the
.Nm
daemon
to get it to reload the export information.
After sending the SIGHUP
(kill \-s HUP `cat /var/run/mountd.pid`),
check the syslog output to see if mountd logged any parsing
check the syslog output to see if
.Nm
logged any parsing
errors in the exports file.
.Pp
If
.Nm mountd
.Nm
detects that the running kernel does not include
.Tn NFS
support, it will attempt to load a loadable kernel module containing
@ -122,7 +122,7 @@ by way of
If this fails, or no
.Tn NFS
LKM was available,
.Nm mountd
.Nm
exits with an error.
.Sh FILES
.Bl -tag -width /var/run/mountd.pid -compact
@ -142,6 +142,6 @@ the current list of remote mounted filesystems
.Xr showmount 8
.Sh HISTORY
The
.Nm mountd
.Nm
utility first appeared in
.Bx 4.4 .

View File

@ -35,30 +35,27 @@
*/
#ifndef lint
static char copyright[] =
static const char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /*not lint*/
#ifndef lint
/*static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; */
#if 0
static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95";
#endif
static const char rcsid[] =
"$Id: mountd.c,v 1.30 1998/06/15 15:43:13 joerg Exp $";
"$Id$";
#endif /*not lint*/
#include <sys/param.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/syslog.h>
#include <sys/ucred.h>
#include <sys/sysctl.h>
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
#include <rpc/pmap_prot.h>
#ifdef ISO
#include <netiso/iso.h>
#endif
@ -72,6 +69,7 @@ static const char rcsid[] =
#include <arpa/inet.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <grp.h>
#include <netdb.h>
@ -197,6 +195,7 @@ int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *));
int scan_tree __P((struct dirlist *, u_long));
void send_umntall __P((void));
int umntall_each __P((caddr_t, struct sockaddr_in *));
static void usage __P((void));
int xdr_dir __P((XDR *, char *));
int xdr_explist __P((XDR *, caddr_t));
int xdr_fhs __P((XDR *, caddr_t));
@ -287,9 +286,7 @@ main(argc, argv)
log = 1;
break;
default:
fprintf(stderr,
"Usage: mountd [-d] [-l] [-r] [-n] [export_file]\n");
exit(1);
usage();
};
argc -= optind;
argv += optind;
@ -303,13 +300,13 @@ main(argc, argv)
strcpy(exname, _PATH_EXPORTS);
openlog("mountd", LOG_PID, LOG_DAEMON);
if (debug)
fprintf(stderr,"Getting export list.\n");
warnx("getting export list");
get_exportlist();
if (debug)
fprintf(stderr,"Getting mount list.\n");
warnx("getting mount list");
get_mountlist();
if (debug)
fprintf(stderr,"Here we go.\n");
warnx("here we go");
if (debug == 0) {
daemon(0, 0);
signal(SIGINT, SIG_IGN);
@ -335,7 +332,7 @@ main(argc, argv)
}
if ((udptransp = svcudp_create(RPC_ANYSOCK)) == NULL ||
(tcptransp = svctcp_create(RPC_ANYSOCK, 0, 0)) == NULL) {
syslog(LOG_ERR, "Can't create socket");
syslog(LOG_ERR, "can't create socket");
exit(1);
}
pmap_unset(RPCPROG_MNT, 1);
@ -343,16 +340,24 @@ main(argc, argv)
if (!force_v2)
if (!svc_register(udptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_UDP) ||
!svc_register(tcptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_TCP)) {
syslog(LOG_ERR, "Can't register mount");
syslog(LOG_ERR, "can't register mount");
exit(1);
}
if (!svc_register(udptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_UDP) ||
!svc_register(tcptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_TCP)) {
syslog(LOG_ERR, "Can't register mount");
syslog(LOG_ERR, "can't register mount");
exit(1);
}
svc_run();
syslog(LOG_ERR, "Mountd died");
syslog(LOG_ERR, "mountd died");
exit(1);
}
static void
usage()
{
fprintf(stderr,
"usage: mountd [-2] [-d] [-l] [-n] [-r] [export_file]\n");
exit(1);
}
@ -386,7 +391,7 @@ mntsrv(rqstp, transp)
switch (rqstp->rq_proc) {
case NULLPROC:
if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
return;
case RPCMNT_MOUNT:
if (sport >= IPPORT_RESERVED && resvport_only) {
@ -415,10 +420,10 @@ mntsrv(rqstp, transp)
statfs(dirpath, &fsb) < 0) {
chdir("/"); /* Just in case realpath doesn't */
syslog(LOG_NOTICE,
"mount request from %s for non existant path %s",
"mount request from %s for non existent path %s",
inet_ntoa(saddrin), dirpath);
if (debug)
fprintf(stderr, "stat failed on %s\n", dirpath);
warnx("stat failed on %s", dirpath);
bad = ENOENT; /* We will send error reply later */
}
@ -434,7 +439,7 @@ mntsrv(rqstp, transp)
if (bad) {
if (!svc_sendreply(transp, xdr_long,
(caddr_t)&bad))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
return;
}
@ -447,15 +452,15 @@ mntsrv(rqstp, transp)
memset(&fhr.fhr_fh, 0, sizeof(nfsfh_t));
if (getfh(dirpath, (fhandle_t *)&fhr.fhr_fh) < 0) {
bad = errno;
syslog(LOG_ERR, "Can't get fh for %s", dirpath);
syslog(LOG_ERR, "can't get fh for %s", dirpath);
if (!svc_sendreply(transp, xdr_long,
(caddr_t)&bad))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
return;
}
if (!svc_sendreply(transp, xdr_fhs, (caddr_t)&fhr))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
if (hp == NULL)
hp = gethostbyaddr((caddr_t)&saddr,
sizeof(saddr), AF_INET);
@ -465,7 +470,7 @@ mntsrv(rqstp, transp)
add_mlist(inet_ntoa(saddrin),
dirpath);
if (debug)
fprintf(stderr,"Mount successfull.\n");
warnx("mount successful");
if (log)
syslog(LOG_NOTICE,
"mount request succeeded from %s for %s",
@ -478,12 +483,12 @@ mntsrv(rqstp, transp)
}
if (bad && !svc_sendreply(transp, xdr_long, (caddr_t)&bad))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
return;
case RPCMNT_DUMP:
if (!svc_sendreply(transp, xdr_mlist, (caddr_t)NULL))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
else if (log)
syslog(LOG_NOTICE,
"dump request succeeded from %s",
@ -504,7 +509,7 @@ mntsrv(rqstp, transp)
return;
}
if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
hp = gethostbyaddr((caddr_t)&saddr, sizeof(saddr), AF_INET);
if (hp)
del_mlist(hp->h_name, dirpath);
@ -523,7 +528,7 @@ mntsrv(rqstp, transp)
return;
}
if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
hp = gethostbyaddr((caddr_t)&saddr, sizeof(saddr), AF_INET);
if (hp)
del_mlist(hp->h_name, (char *)NULL);
@ -535,7 +540,7 @@ mntsrv(rqstp, transp)
return;
case RPCMNT_EXPORT:
if (!svc_sendreply(transp, xdr_explist, (caddr_t)NULL))
syslog(LOG_ERR, "Can't send reply");
syslog(LOG_ERR, "can't send reply");
if (log)
syslog(LOG_NOTICE,
"export request succeeded from %s",
@ -783,7 +788,7 @@ get_exportlist()
if (mount(fsp->f_fstypename, fsp->f_mntonname,
fsp->f_flags | MNT_UPDATE,
(caddr_t)&targs) < 0)
syslog(LOG_ERR, "Can't delete exports for %s",
syslog(LOG_ERR, "can't delete exports for %s",
fsp->f_mntonname);
}
fsp++;
@ -794,13 +799,13 @@ get_exportlist()
* mount() as we go along to push the export rules into the kernel.
*/
if ((exp_file = fopen(exname, "r")) == NULL) {
syslog(LOG_ERR, "Can't open %s", exname);
syslog(LOG_ERR, "can't open %s", exname);
exit(2);
}
dirhead = (struct dirlist *)NULL;
while (get_line()) {
if (debug)
fprintf(stderr,"Got line %s\n",line);
warnx("got line %s", line);
cp = line;
nextfield(&cp, &endcp);
if (*cp == '#')
@ -832,7 +837,7 @@ get_exportlist()
goto nextline;
}
if (debug)
fprintf(stderr, "doing opt %s\n", cp);
warnx("doing opt %s", cp);
got_nondir = 1;
if (do_opt(&cp, &endcp, ep, grp, &has_host,
&exflags, &anon)) {
@ -845,7 +850,7 @@ get_exportlist()
if (check_dirpath(cp) &&
statfs(cp, &fsb) >= 0) {
if (got_nondir) {
syslog(LOG_ERR, "Dirs must be first");
syslog(LOG_ERR, "dirs must be first");
getexp_err(ep, tgrp);
goto nextline;
}
@ -872,13 +877,11 @@ get_exportlist()
else
out_of_mem();
if (debug)
fprintf(stderr,
"Making new ep fs=0x%x,0x%x\n",
warnx("making new ep fs=0x%x,0x%x",
fsb.f_fsid.val[0],
fsb.f_fsid.val[1]);
} else if (debug)
fprintf(stderr,
"Found ep fs=0x%x,0x%x\n",
warnx("found ep fs=0x%x,0x%x",
fsb.f_fsid.val[0],
fsb.f_fsid.val[1]);
}
@ -914,14 +917,16 @@ get_exportlist()
}
if (netgrp) {
if (hst == 0) {
syslog(LOG_ERR, "Null hostname in netgroup %s, skipping", cp);
syslog(LOG_ERR,
"null hostname in netgroup %s, skipping", cp);
grp->gr_type = GT_IGNORE;
} else if (get_host(hst, grp, tgrp)) {
syslog(LOG_ERR, "Bad host %s in netgroup %s, skipping", hst, cp);
syslog(LOG_ERR,
"bad host %s in netgroup %s, skipping", hst, cp);
grp->gr_type = GT_IGNORE;
}
} else if (get_host(cp, grp, tgrp)) {
syslog(LOG_ERR, "Bad host %s, skipping", cp);
syslog(LOG_ERR, "bad host %s, skipping", cp);
grp->gr_type = GT_IGNORE;
}
has_host = TRUE;
@ -940,7 +945,7 @@ get_exportlist()
if (!has_host) {
grp->gr_type = GT_HOST;
if (debug)
fprintf(stderr,"Adding a default entry\n");
warnx("adding a default entry");
/* add a default group and make the grp list NULL */
hpe = (struct hostent *)malloc(sizeof(struct hostent));
if (hpe == (struct hostent *)NULL)
@ -1065,7 +1070,7 @@ getexp_err(ep, grp)
{
struct grouplist *tgrp;
syslog(LOG_ERR, "Bad exports list line %s", line);
syslog(LOG_ERR, "bad exports list line %s", line);
if (ep && (ep->ex_flag & EX_LINKED) == 0)
free_exp(ep);
while (grp) {
@ -1106,6 +1111,8 @@ add_expdir(dpp, cp, len)
struct dirlist *dp;
dp = (struct dirlist *)malloc(sizeof (struct dirlist) + len);
if (dp == (struct dirlist *)NULL)
out_of_mem();
dp->dp_left = *dpp;
dp->dp_right = (struct dirlist *)NULL;
dp->dp_flag = 0;
@ -1150,7 +1157,7 @@ hang_dirp(dp, grp, ep, flags)
} else {
/*
* Loop throught the directories adding them to the tree.
* Loop through the directories adding them to the tree.
*/
while (dp) {
dp2 = dp->dp_left;
@ -1343,12 +1350,12 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
while (cpopt && *cpopt) {
allflag = 1;
usedarg = -2;
if (cpoptend = strchr(cpopt, ',')) {
if ((cpoptend = strchr(cpopt, ','))) {
*cpoptend++ = '\0';
if (cpoptarg = strchr(cpopt, '='))
if ((cpoptarg = strchr(cpopt, '=')))
*cpoptarg++ = '\0';
} else {
if (cpoptarg = strchr(cpopt, '='))
if ((cpoptarg = strchr(cpopt, '=')))
*cpoptarg++ = '\0';
else {
*cp = savedc;
@ -1380,7 +1387,7 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
} else if (cpoptarg && (!strcmp(cpopt, "mask") ||
!strcmp(cpopt, "m"))) {
if (get_net(cpoptarg, &grp->gr_ptr.gt_net, 1)) {
syslog(LOG_ERR, "Bad mask: %s", cpoptarg);
syslog(LOG_ERR, "bad mask: %s", cpoptarg);
return (1);
}
usedarg++;
@ -1388,10 +1395,10 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
} else if (cpoptarg && (!strcmp(cpopt, "network") ||
!strcmp(cpopt, "n"))) {
if (grp->gr_type != GT_NULL) {
syslog(LOG_ERR, "Network/host conflict");
syslog(LOG_ERR, "network/host conflict");
return (1);
} else if (get_net(cpoptarg, &grp->gr_ptr.gt_net, 0)) {
syslog(LOG_ERR, "Bad net: %s", cpoptarg);
syslog(LOG_ERR, "bad net: %s", cpoptarg);
return (1);
}
grp->gr_type = GT_NET;
@ -1410,7 +1417,7 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
#ifdef ISO
} else if (cpoptarg && !strcmp(cpopt, "iso")) {
if (get_isoaddr(cpoptarg, grp)) {
syslog(LOG_ERR, "Bad iso addr: %s", cpoptarg);
syslog(LOG_ERR, "bad iso addr: %s", cpoptarg);
return (1);
}
*has_hostp = 1;
@ -1418,7 +1425,7 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
opt_flags |= OP_ISO;
#endif /* ISO */
} else {
syslog(LOG_ERR, "Bad opt %s", cpopt);
syslog(LOG_ERR, "bad opt %s", cpopt);
return (1);
}
if (usedarg >= 0) {
@ -1460,7 +1467,7 @@ get_host(cp, grp, tgrp)
if (isdigit(*cp)) {
saddr = inet_addr(cp);
if (saddr == -1) {
syslog(LOG_ERR, "Inet_addr failed for %s", cp);
syslog(LOG_ERR, "inet_addr failed for %s", cp);
return (1);
}
if ((hp = gethostbyaddr((caddr_t)&saddr, sizeof (saddr),
@ -1474,7 +1481,7 @@ get_host(cp, grp, tgrp)
aptr[1] = (char *)NULL;
}
} else {
syslog(LOG_ERR, "Gethostbyname failed for %s", cp);
syslog(LOG_ERR, "gethostbyname failed for %s", cp);
return (1);
}
}
@ -1510,14 +1517,12 @@ get_host(cp, grp, tgrp)
i = 1;
while (*addrp++)
i++;
naddrp = nhp->h_addr_list = (char **)
malloc(i*sizeof(char *));
naddrp = nhp->h_addr_list = (char **)malloc(i*sizeof(char *));
if (naddrp == (char **)NULL)
out_of_mem();
addrp = hp->h_addr_list;
while (*addrp) {
*naddrp = (char *)
malloc(hp->h_length);
*naddrp = (char *)malloc(hp->h_length);
if (*naddrp == (char *)NULL)
out_of_mem();
memmove(*naddrp, *addrp, hp->h_length);
@ -1526,7 +1531,7 @@ get_host(cp, grp, tgrp)
}
*naddrp = (char *)NULL;
if (debug)
fprintf(stderr, "got host %s\n", hp->h_name);
warnx("got host %s", hp->h_name);
return (0);
}
@ -1593,12 +1598,10 @@ get_isoaddr(cp, grp)
if (grp->gr_type != GT_NULL)
return (1);
if ((isop = iso_addr(cp)) == NULL) {
syslog(LOG_ERR,
"iso_addr failed, ignored");
syslog(LOG_ERR, "iso_addr failed, ignored");
return (1);
}
isoaddr = (struct sockaddr_iso *)
malloc(sizeof (struct sockaddr_iso));
isoaddr = (struct sockaddr_iso *)malloc(sizeof (struct sockaddr_iso));
if (isoaddr == (struct sockaddr_iso *)NULL)
out_of_mem();
memset(isoaddr, 0, sizeof(struct sockaddr_iso));
@ -1618,7 +1621,7 @@ void
out_of_mem()
{
syslog(LOG_ERR, "Out of memory");
syslog(LOG_ERR, "out of memory");
exit(2);
}
@ -1711,7 +1714,7 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
return(0);
break;
default:
syslog(LOG_ERR, "Bad grouptype");
syslog(LOG_ERR, "bad grouptype");
if (cp)
*cp = savedc;
return (1);
@ -1732,11 +1735,11 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
cp = dirp + dirplen - 1;
if (errno == EPERM) {
syslog(LOG_ERR,
"Can't change attributes for %s.\n", dirp);
"can't change attributes for %s", dirp);
return (1);
}
if (opt_flags & OP_ALLDIRS) {
syslog(LOG_ERR, "Could not remount %s: %m",
syslog(LOG_ERR, "could not remount %s: %m",
dirp);
return (1);
}
@ -1747,8 +1750,8 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
cp--;
if (cp == dirp) {
if (debug)
fprintf(stderr,"mnt unsucc\n");
syslog(LOG_ERR, "Can't export %s", dirp);
warnx("mnt unsucc");
syslog(LOG_ERR, "can't export %s", dirp);
return (1);
}
savedc = *cp;
@ -1783,7 +1786,7 @@ get_net(cp, net, maskflg)
if (isdigit(*cp) && ((netaddr = inet_network(cp)) != -1)) {
inetaddr = inet_makeaddr(netaddr, 0);
/*
* Due to arbritrary subnet masks, you don't know how many
* Due to arbitrary subnet masks, you don't know how many
* bits to shift the address to make it into a network,
* however you do know how to make a network address into
* a host with host == 0 and then compare them.
@ -1791,7 +1794,7 @@ get_net(cp, net, maskflg)
*/
if (!maskflg) {
setnetent(0);
while (np = getnetent()) {
while ((np = getnetent())) {
inetaddr2 = inet_makeaddr(np->n_net, 0);
if (inetaddr2.s_addr == inetaddr.s_addr)
break;
@ -1875,7 +1878,7 @@ get_line()
if (len > 0) {
totlen += len;
if (totlen >= LINESIZ) {
syslog(LOG_ERR, "Exports line too long");
syslog(LOG_ERR, "exports line too long");
exit(2);
}
p = cp;
@ -1900,7 +1903,7 @@ parsecred(namelist, cr)
int ngroups, groups[NGROUPS + 1];
/*
* Set up the unpriviledged user.
* Set up the unprivileged user.
*/
cr->cr_ref = 1;
cr->cr_uid = -2;
@ -1920,13 +1923,13 @@ parsecred(namelist, cr)
*/
if (names == NULL) {
if (pw == NULL) {
syslog(LOG_ERR, "Unknown user: %s", name);
syslog(LOG_ERR, "unknown user: %s", name);
return;
}
cr->cr_uid = pw->pw_uid;
ngroups = NGROUPS + 1;
if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups))
syslog(LOG_ERR, "Too many groups");
syslog(LOG_ERR, "too many groups");
/*
* Convert from int's to gid_t's and compress out duplicate
*/
@ -1945,7 +1948,7 @@ parsecred(namelist, cr)
else if (isdigit(*name) || *name == '-')
cr->cr_uid = atoi(name);
else {
syslog(LOG_ERR, "Unknown user: %s", name);
syslog(LOG_ERR, "unknown user: %s", name);
return;
}
cr->cr_ngroups = 0;
@ -1955,14 +1958,14 @@ parsecred(namelist, cr)
cr->cr_groups[cr->cr_ngroups++] = atoi(name);
} else {
if ((gr = getgrnam(name)) == NULL) {
syslog(LOG_ERR, "Unknown group: %s", name);
syslog(LOG_ERR, "unknown group: %s", name);
continue;
}
cr->cr_groups[cr->cr_ngroups++] = gr->gr_gid;
}
}
if (names != NULL && *names != '\0' && cr->cr_ngroups == NGROUPS)
syslog(LOG_ERR, "Too many groups");
syslog(LOG_ERR, "too many groups");
}
#define STRSIZ (RPCMNT_NAMELEN+RPCMNT_PATHLEN+50)
@ -1974,12 +1977,11 @@ get_mountlist()
{
struct mountlist *mlp, **mlpp;
char *host, *dirp, *cp;
int len;
char str[STRSIZ];
FILE *mlfile;
if ((mlfile = fopen(_PATH_RMOUNTLIST, "r")) == NULL) {
syslog(LOG_ERR, "Can't open %s", _PATH_RMOUNTLIST);
syslog(LOG_ERR, "can't open %s", _PATH_RMOUNTLIST);
return;
}
mlpp = &mlhead;
@ -1990,6 +1992,8 @@ get_mountlist()
if (host == NULL || dirp == NULL)
continue;
mlp = (struct mountlist *)malloc(sizeof (*mlp));
if (mlp == (struct mountlist *)NULL)
out_of_mem();
strncpy(mlp->ml_host, host, RPCMNT_NAMELEN);
mlp->ml_host[RPCMNT_NAMELEN] = '\0';
strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN);
@ -2026,7 +2030,7 @@ del_mlist(hostp, dirp)
}
if (fnd) {
if ((mlfile = fopen(_PATH_RMOUNTLIST, "w")) == NULL) {
syslog(LOG_ERR,"Can't update %s", _PATH_RMOUNTLIST);
syslog(LOG_ERR,"can't update %s", _PATH_RMOUNTLIST);
return;
}
mlp = mlhead;
@ -2054,6 +2058,8 @@ add_mlist(hostp, dirp)
mlp = mlp->ml_next;
}
mlp = (struct mountlist *)malloc(sizeof (*mlp));
if (mlp == (struct mountlist *)NULL)
out_of_mem();
strncpy(mlp->ml_host, hostp, RPCMNT_NAMELEN);
mlp->ml_host[RPCMNT_NAMELEN] = '\0';
strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN);
@ -2061,7 +2067,7 @@ add_mlist(hostp, dirp)
mlp->ml_next = (struct mountlist *)NULL;
*mlpp = mlp;
if ((mlfile = fopen(_PATH_RMOUNTLIST, "a")) == NULL) {
syslog(LOG_ERR, "Can't update %s", _PATH_RMOUNTLIST);
syslog(LOG_ERR, "can't update %s", _PATH_RMOUNTLIST);
return;
}
fprintf(mlfile, "%s %s\n", mlp->ml_host, mlp->ml_dirp);

View File

@ -41,7 +41,7 @@
.Nm netgroup
.Sh DESCRIPTION
The
.Nm netgroup
.Nm
file
specifies ``netgroups'', which are sets of
.Sy (host, user, domain)
@ -55,6 +55,7 @@ of a tuple as follows:
.Bd -literal -offset indent
(host, user, domain)
.Ed
.Pp
where the
.Sy host ,
.Sy user ,
@ -69,43 +70,56 @@ line continuation. Lines are limited to 1024 characters.
The functions specified in
.Xr getnetgrent 3
should normally be used to access the
.Nm netgroup
.Nm
database.
.Pp
Lines that begin with a # are treated as comments.
.Sh NIS/YP INTERACTION
On most other platforms,
.Nm netgroups
.Nm Ns s
are only used in conjunction with
NIS and local
.Tn NIS
and local
.Pa /etc/netgroup
files are ignored. With FreeBSD,
.Nm netgroups
can be used with either NIS or local files, but there are certain
files are ignored. With
.Bx Free ,
.Nm Ns s
can be used with either
.Tn NIS
or local files, but there are certain
caveats to consider. The existing
.Nm netgroup
.Nm
system is extremely inefficient where
.Fn innetgr 3
lookups are concerned since
.Nm netgroup
memberships are computed on the fly. By contrast, the NIS
.Nm netgroup
.Nm
memberships are computed on the fly. By contrast, the
.Tn NIS
.Nm
database consists of three separate maps (netgroup, netgroup.byuser
and netgroup.byhost) that are keyed to allow
.Fn innetgr 3
lookups to be done quickly. The FreeBSD
.Nm netgroup
system can interact with the NIS
.Nm netgroup
lookups to be done quickly. The
.Bx Free
.Nm
system can interact with the
.Tn NIS
.Nm
maps in the following ways:
.Bl -bullet -offset indent
.It
If the
.Pa /etc/netgroup
file does not exist, or it exists and is empty, or
it exists and contains only a '+', and NIS is running,
.Nm netgroup
lookups will be done exclusively through NIS, with
it exists and contains only a
.Sq + ,
and
.Tn NIS
is running,
.Nm
lookups will be done exclusively through
.Tn NIS ,
with
.Fn innetgr 3
taking advantage of the netgroup.byuser and
netgroup.byhost maps to speed up searches. (This
@ -115,18 +129,28 @@ similar platforms.)
If the
.Pa /etc/netgroup
exists and contains only local
.Nm netgroup
information (with no NIS '+' token), then only the local
.Nm netgroup
information will be processed (and NIS will be ignored).
.Nm
information (with no
.Tn NIS
.Sq +
token), then only the local
.Nm
information will be processed (and
.Tn NIS
will be ignored).
.It
If
.Pa /etc/netgroup
exists and contains both local netgroup data
.Pa and
the NIS '+' token, the local data and the NIS netgroup
the
.Tn NIS
.Sq +
token, the local data and the
.Tn NIS
netgroup
map will be processed as a single combined
.Nm netgroup
.Nm
database. While this configuration is the most flexible, it
is also the least efficient: in particular,
.Fn innetgr 3
@ -136,7 +160,7 @@ database is large.
.Sh FILES
.Bl -tag -width /etc/netgroup -compact
.It Pa /etc/netgroup
the netgroup database.
the netgroup database
.El
.Sh SEE ALSO
.Xr getnetgrent 3 ,
@ -148,10 +172,12 @@ appears that not all vendors use an identical format.
The interpretation of access restrictions based on the member tuples of a
netgroup is left up to the various network applications.
Also, it is not obvious how the domain specification
applies to the BSD environment.
applies to the
.Bx
environment.
.Pp
The
.Nm netgroup
.Nm
database should be stored in the form of a
hashed
.Xr db 3