2001-01-16 05:50:27 +03:00
|
|
|
/* $NetBSD: nfsd.c,v 1.35 2001/01/16 02:50:32 cgd Exp $ */
|
1995-03-18 17:54:19 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-06-08 23:27:32 +04:00
|
|
|
* Copyright (c) 1989, 1993, 1994
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Rick Macklem at The University of Guelph.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1997-10-17 15:53:25 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifndef lint
|
1997-10-17 15:53:25 +04:00
|
|
|
__COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\n\
|
|
|
|
The Regents of the University of California. All rights reserved.\n");
|
2001-01-16 05:50:27 +03:00
|
|
|
#endif /* not lint */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#ifndef lint
|
1995-03-18 17:54:19 +03:00
|
|
|
#if 0
|
1996-02-18 14:58:24 +03:00
|
|
|
static char sccsid[] = "@(#)nfsd.c 8.9 (Berkeley) 3/29/95";
|
1995-03-18 17:54:19 +03:00
|
|
|
#else
|
2001-01-16 05:50:27 +03:00
|
|
|
__RCSID("$NetBSD: nfsd.c,v 1.35 2001/01/16 02:50:32 cgd Exp $");
|
1995-03-18 17:54:19 +03:00
|
|
|
#endif
|
1996-02-18 14:58:24 +03:00
|
|
|
#endif /* not lint */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-06-08 23:27:32 +04:00
|
|
|
#include <sys/param.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/wait.h>
|
1994-06-08 23:27:32 +04:00
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/ucred.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
1994-06-08 23:27:32 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <rpc/rpc.h>
|
|
|
|
#include <rpc/pmap_clnt.h>
|
|
|
|
#include <rpc/pmap_prot.h>
|
1994-06-08 23:27:32 +04:00
|
|
|
|
|
|
|
#ifdef ISO
|
|
|
|
#include <netiso/iso.h>
|
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <nfs/rpcv2.h>
|
1996-02-18 14:58:24 +03:00
|
|
|
#include <nfs/nfsproto.h>
|
1994-06-08 23:27:32 +04:00
|
|
|
#include <nfs/nfs.h>
|
|
|
|
|
1996-02-18 14:58:24 +03:00
|
|
|
#ifdef NFSKERB
|
1994-06-08 23:27:32 +04:00
|
|
|
#include <kerberosIV/des.h>
|
|
|
|
#include <kerberosIV/krb.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <err.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <grp.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
1998-02-03 07:55:59 +03:00
|
|
|
#include <string.h>
|
1996-02-19 02:18:56 +03:00
|
|
|
#include <syslog.h>
|
1994-06-08 23:27:32 +04:00
|
|
|
#include <unistd.h>
|
2000-06-09 04:05:02 +04:00
|
|
|
#include <netdb.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* Global defs */
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define syslog(e, s) fprintf(stderr,(s))
|
|
|
|
int debug = 1;
|
|
|
|
#else
|
|
|
|
int debug = 0;
|
|
|
|
#endif
|
1994-06-08 23:27:32 +04:00
|
|
|
|
|
|
|
struct nfsd_srvargs nsd;
|
|
|
|
|
1996-02-18 14:58:24 +03:00
|
|
|
#ifdef NFSKERB
|
1994-06-08 23:27:32 +04:00
|
|
|
char lnam[ANAME_SZ];
|
|
|
|
KTEXT_ST kt;
|
1996-02-18 14:58:24 +03:00
|
|
|
AUTH_DAT kauth;
|
1994-06-08 23:27:32 +04:00
|
|
|
char inst[INST_SZ];
|
1996-02-18 14:58:24 +03:00
|
|
|
struct nfsrpc_fullblock kin, kout;
|
|
|
|
struct nfsrpc_fullverf kverf;
|
|
|
|
NFSKERBKEY_T kivec;
|
|
|
|
struct timeval ktv;
|
|
|
|
NFSKERBKEYSCHED_T kerb_keysched;
|
1994-06-08 23:27:32 +04:00
|
|
|
#endif
|
|
|
|
|
1997-10-17 15:53:25 +04:00
|
|
|
int main __P((int, char **));
|
1994-06-08 23:27:32 +04:00
|
|
|
void nonfs __P((int));
|
|
|
|
void reapchild __P((int));
|
|
|
|
void usage __P((void));
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Nfs server daemon mostly just a user context for nfssvc()
|
1994-06-08 23:27:32 +04:00
|
|
|
*
|
1993-03-21 12:45:37 +03:00
|
|
|
* 1 - do file descriptor and signal cleanup
|
1994-06-08 23:27:32 +04:00
|
|
|
* 2 - fork the nfsd(s)
|
|
|
|
* 3 - create server socket(s)
|
|
|
|
* 4 - register socket with portmap
|
|
|
|
*
|
1999-03-26 10:15:23 +03:00
|
|
|
* For connectionless protocols, just pass the socket into the kernel via
|
1994-06-08 23:27:32 +04:00
|
|
|
* nfssvc().
|
|
|
|
* For connection based sockets, loop doing accepts. When you get a new
|
1999-03-26 10:15:23 +03:00
|
|
|
* socket from accept, pass the msgsock into the kernel via nfssvc().
|
1993-03-21 12:45:37 +03:00
|
|
|
* The arguments are:
|
1994-06-08 23:27:32 +04:00
|
|
|
* -c - support iso cltp clients
|
|
|
|
* -r - reregister with portmapper
|
|
|
|
* -t - support tcp nfs clients
|
|
|
|
* -u - support udp nfs clients
|
|
|
|
* followed by "n" which is the number of nfsds' to fork off
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-06-08 23:27:32 +04:00
|
|
|
int
|
1997-10-17 15:53:25 +04:00
|
|
|
main(argc, argv)
|
1993-03-21 12:45:37 +03:00
|
|
|
int argc;
|
1997-10-17 15:53:25 +04:00
|
|
|
char *argv[];
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-06-08 23:27:32 +04:00
|
|
|
struct nfsd_args nfsdargs;
|
2000-06-09 04:05:02 +04:00
|
|
|
struct addrinfo *ai_udp, *ai_tcp, *ai_udp6, *ai_tcp6, hints;
|
|
|
|
struct netconfig *nconf_udp, *nconf_tcp, *nconf_udp6, *nconf_tcp6;
|
|
|
|
struct netbuf nb_udp, nb_tcp, nb_udp6, nb_tcp6;
|
|
|
|
struct sockaddr_in inetpeer;
|
|
|
|
struct sockaddr_in6 inet6peer;
|
1994-06-08 23:27:32 +04:00
|
|
|
#ifdef ISO
|
|
|
|
struct sockaddr_iso isoaddr, isopeer;
|
|
|
|
#endif
|
|
|
|
fd_set ready, sockbits;
|
|
|
|
int ch, cltpflag, connect_type_cnt, i, len, maxsock, msgsock;
|
2000-06-09 04:05:02 +04:00
|
|
|
int nfsdcnt, nfssvc_flag, on = 1, reregister, sock, tcpflag, tcpsock;
|
|
|
|
int tcp6sock, ip6flag;
|
|
|
|
int tp4cnt, tp4flag, tpipcnt, tpipflag, udpflag, ecode, s;
|
1997-10-17 15:53:25 +04:00
|
|
|
#ifdef NFSKERB
|
|
|
|
struct group *grp;
|
|
|
|
struct passwd *pwd;
|
|
|
|
struct ucred *cr;
|
|
|
|
struct timeval ktv;
|
|
|
|
int tp4sock, tpipsock;
|
1994-06-08 23:27:32 +04:00
|
|
|
char *cp, **cpp;
|
1997-10-17 15:53:25 +04:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-06-08 23:27:32 +04:00
|
|
|
#define MAXNFSDCNT 20
|
|
|
|
#define DEFNFSDCNT 4
|
|
|
|
nfsdcnt = DEFNFSDCNT;
|
|
|
|
cltpflag = reregister = tcpflag = tp4cnt = tp4flag = tpipcnt = 0;
|
2000-06-09 04:05:02 +04:00
|
|
|
tpipflag = udpflag = ip6flag = 0;
|
1997-10-17 15:53:25 +04:00
|
|
|
maxsock = tcpsock = 0;
|
1994-06-08 23:27:32 +04:00
|
|
|
#ifdef ISO
|
2000-06-09 04:05:02 +04:00
|
|
|
#define GETOPT "6cn:rtu"
|
1994-06-08 23:27:32 +04:00
|
|
|
#define USAGE "[-crtu] [-n num_servers]"
|
|
|
|
#else
|
2000-06-09 04:05:02 +04:00
|
|
|
#define GETOPT "6n:rtu"
|
1994-06-08 23:27:32 +04:00
|
|
|
#define USAGE "[-rtu] [-n num_servers]"
|
|
|
|
#endif
|
1999-06-07 10:13:41 +04:00
|
|
|
while ((ch = getopt(argc, argv, GETOPT)) != -1) {
|
1994-06-08 23:27:32 +04:00
|
|
|
switch (ch) {
|
2000-06-09 04:05:02 +04:00
|
|
|
case '6':
|
|
|
|
ip6flag = 1;
|
|
|
|
s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
|
|
|
if (s < 0 && (errno == EPROTONOSUPPORT ||
|
|
|
|
errno == EPFNOSUPPORT || errno == EAFNOSUPPORT))
|
|
|
|
ip6flag = 0;
|
|
|
|
else
|
|
|
|
close(s);
|
|
|
|
break;
|
1994-06-08 23:27:32 +04:00
|
|
|
case 'n':
|
|
|
|
nfsdcnt = atoi(optarg);
|
|
|
|
if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
|
1997-09-05 14:52:10 +04:00
|
|
|
warnx("nfsd count %d; reset to %d", nfsdcnt, DEFNFSDCNT);
|
1994-06-08 23:27:32 +04:00
|
|
|
nfsdcnt = DEFNFSDCNT;
|
|
|
|
}
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
case 'r':
|
1994-06-08 23:27:32 +04:00
|
|
|
reregister = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 't':
|
1994-06-08 23:27:32 +04:00
|
|
|
tcpflag = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 'u':
|
1994-06-08 23:27:32 +04:00
|
|
|
udpflag = 1;
|
|
|
|
break;
|
|
|
|
#ifdef ISO
|
|
|
|
case 'c':
|
|
|
|
cltpflag = 1;
|
|
|
|
break;
|
|
|
|
#ifdef notyet
|
|
|
|
case 'i':
|
|
|
|
tp4cnt = 1;
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
tpipcnt = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-06-08 23:27:32 +04:00
|
|
|
#endif /* notyet */
|
|
|
|
#endif /* ISO */
|
1993-03-21 12:45:37 +03:00
|
|
|
default:
|
|
|
|
case '?':
|
|
|
|
usage();
|
1994-06-08 23:27:32 +04:00
|
|
|
};
|
1999-06-07 10:13:41 +04:00
|
|
|
}
|
1994-06-08 23:27:32 +04:00
|
|
|
argv += optind;
|
|
|
|
argc -= optind;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/*
|
1994-06-08 23:27:32 +04:00
|
|
|
* XXX
|
|
|
|
* Backward compatibility, trailing number is the count of daemons.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-06-08 23:27:32 +04:00
|
|
|
if (argc > 1)
|
|
|
|
usage();
|
|
|
|
if (argc == 1) {
|
|
|
|
nfsdcnt = atoi(argv[0]);
|
|
|
|
if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
|
1997-09-05 14:52:10 +04:00
|
|
|
warnx("nfsd count %d; reset to %d", nfsdcnt, DEFNFSDCNT);
|
1994-06-08 23:27:32 +04:00
|
|
|
nfsdcnt = DEFNFSDCNT;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1999-09-01 03:28:34 +04:00
|
|
|
/*
|
|
|
|
* If none of TCP or UDP are specified, default to UDP only.
|
|
|
|
*/
|
|
|
|
if (tcpflag == 0 && udpflag == 0)
|
|
|
|
udpflag = 1;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
if (debug == 0) {
|
|
|
|
daemon(0, 0);
|
1994-06-08 23:27:32 +04:00
|
|
|
(void)signal(SIGHUP, SIG_IGN);
|
|
|
|
(void)signal(SIGINT, SIG_IGN);
|
|
|
|
(void)signal(SIGQUIT, SIG_IGN);
|
|
|
|
(void)signal(SIGSYS, nonfs);
|
1993-10-05 03:36:28 +03:00
|
|
|
}
|
1994-06-08 23:27:32 +04:00
|
|
|
(void)signal(SIGCHLD, reapchild);
|
|
|
|
|
2000-06-09 04:05:02 +04:00
|
|
|
if (udpflag) {
|
|
|
|
memset(&hints, 0, sizeof hints);
|
|
|
|
hints.ai_flags = AI_PASSIVE;
|
|
|
|
hints.ai_family = PF_INET;
|
|
|
|
hints.ai_socktype = SOCK_DGRAM;
|
|
|
|
hints.ai_protocol = IPPROTO_UDP;
|
|
|
|
|
|
|
|
ecode = getaddrinfo(NULL, "nfs", &hints, &ai_udp);
|
|
|
|
if (ecode != 0) {
|
|
|
|
syslog(LOG_ERR, "getaddrinfo udp: %s",
|
|
|
|
gai_strerror(ecode));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
nconf_udp = getnetconfigent("udp");
|
|
|
|
|
|
|
|
if (nconf_udp == NULL)
|
|
|
|
err(1, "getnetconfigent udp failed");
|
|
|
|
|
|
|
|
nb_udp.buf = ai_udp->ai_addr;
|
|
|
|
nb_udp.len = nb_udp.maxlen = ai_udp->ai_addrlen;
|
|
|
|
if (reregister)
|
|
|
|
if (!rpcb_set(RPCPROG_NFS, 2, nconf_udp, &nb_udp))
|
|
|
|
err(1, "rpcb_set udp failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tcpflag) {
|
|
|
|
memset(&hints, 0, sizeof hints);
|
|
|
|
hints.ai_flags = AI_PASSIVE;
|
|
|
|
hints.ai_family = PF_INET;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
|
|
hints.ai_protocol = IPPROTO_TCP;
|
|
|
|
|
|
|
|
ecode = getaddrinfo(NULL, "nfs", &hints, &ai_tcp);
|
|
|
|
if (ecode != 0) {
|
|
|
|
syslog(LOG_ERR, "getaddrinfo udp: %s",
|
|
|
|
gai_strerror(ecode));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
nconf_tcp = getnetconfigent("tcp");
|
|
|
|
|
|
|
|
if (nconf_tcp == NULL)
|
|
|
|
err(1, "getnetconfigent tcp failed");
|
|
|
|
|
|
|
|
nb_tcp.buf = ai_tcp->ai_addr;
|
|
|
|
nb_tcp.len = nb_tcp.maxlen = ai_tcp->ai_addrlen;
|
|
|
|
if (reregister)
|
|
|
|
if (!rpcb_set(RPCPROG_NFS, 2, nconf_tcp, &nb_tcp))
|
|
|
|
err(1, "rpcb_set tcp failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (udpflag && ip6flag) {
|
|
|
|
memset(&hints, 0, sizeof hints);
|
|
|
|
hints.ai_flags = AI_PASSIVE;
|
|
|
|
hints.ai_family = PF_INET6;
|
|
|
|
hints.ai_socktype = SOCK_DGRAM;
|
|
|
|
hints.ai_protocol = IPPROTO_UDP;
|
|
|
|
|
|
|
|
ecode = getaddrinfo(NULL, "nfs", &hints, &ai_udp6);
|
|
|
|
if (ecode != 0) {
|
|
|
|
syslog(LOG_ERR, "getaddrinfo udp: %s",
|
|
|
|
gai_strerror(ecode));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
nconf_udp6 = getnetconfigent("udp6");
|
|
|
|
|
|
|
|
if (nconf_udp6 == NULL)
|
|
|
|
err(1, "getnetconfigent udp6 failed");
|
|
|
|
|
|
|
|
nb_udp6.buf = ai_udp6->ai_addr;
|
|
|
|
nb_udp6.len = nb_udp6.maxlen = ai_udp6->ai_addrlen;
|
|
|
|
if (reregister)
|
|
|
|
if (!rpcb_set(RPCPROG_NFS, 2, nconf_udp6, &nb_udp6))
|
|
|
|
err(1, "rpcb_set udp6 failed");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2000-06-09 04:05:02 +04:00
|
|
|
|
|
|
|
if (tcpflag && ip6flag) {
|
|
|
|
memset(&hints, 0, sizeof hints);
|
|
|
|
hints.ai_flags = AI_PASSIVE;
|
|
|
|
hints.ai_family = PF_INET6;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
|
|
hints.ai_protocol = IPPROTO_TCP;
|
|
|
|
|
|
|
|
ecode = getaddrinfo(NULL, "nfs", &hints, &ai_tcp6);
|
|
|
|
if (ecode != 0) {
|
|
|
|
syslog(LOG_ERR, "getaddrinfo udp: %s",
|
|
|
|
gai_strerror(ecode));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
nconf_tcp6 = getnetconfigent("tcp6");
|
|
|
|
|
|
|
|
if (nconf_tcp6 == NULL)
|
|
|
|
err(1, "getnetconfigent tcp6 failed");
|
|
|
|
|
|
|
|
nb_tcp6.buf = ai_tcp6->ai_addr;
|
|
|
|
nb_tcp6.len = nb_tcp6.maxlen = ai_tcp6->ai_addrlen;
|
|
|
|
if (reregister)
|
|
|
|
if (!rpcb_set(RPCPROG_NFS, 2, nconf_tcp6, &nb_tcp6))
|
|
|
|
err(1, "rpcb_set tcp6 failed");
|
|
|
|
}
|
|
|
|
|
2001-01-11 04:43:10 +03:00
|
|
|
openlog("nfsd", LOG_PID, LOG_DAEMON);
|
1994-06-08 23:27:32 +04:00
|
|
|
|
|
|
|
for (i = 0; i < nfsdcnt; i++) {
|
|
|
|
switch (fork()) {
|
|
|
|
case -1:
|
|
|
|
syslog(LOG_ERR, "fork: %m");
|
|
|
|
exit (1);
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1994-10-18 17:12:55 +03:00
|
|
|
setproctitle("server");
|
1994-06-08 23:27:32 +04:00
|
|
|
nfssvc_flag = NFSSVC_NFSD;
|
|
|
|
nsd.nsd_nfsd = NULL;
|
1996-02-18 14:58:24 +03:00
|
|
|
#ifdef NFSKERB
|
|
|
|
if (sizeof (struct nfsrpc_fullverf) != RPCX_FULLVERF ||
|
|
|
|
sizeof (struct nfsrpc_fullblock) != RPCX_FULLBLOCK)
|
2001-01-11 10:58:04 +03:00
|
|
|
syslog(LOG_ERR, "Yikes NFSKERB structs not packed!");
|
1996-02-18 14:58:24 +03:00
|
|
|
nsd.nsd_authstr = (u_char *)&kt;
|
|
|
|
nsd.nsd_authlen = sizeof (kt);
|
|
|
|
nsd.nsd_verfstr = (u_char *)&kverf;
|
|
|
|
nsd.nsd_verflen = sizeof (kverf);
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif
|
1994-06-08 23:27:32 +04:00
|
|
|
while (nfssvc(nfssvc_flag, &nsd) < 0) {
|
|
|
|
if (errno != ENEEDAUTH) {
|
|
|
|
syslog(LOG_ERR, "nfssvc: %m");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
nfssvc_flag = NFSSVC_NFSD | NFSSVC_AUTHINFAIL;
|
1996-02-18 14:58:24 +03:00
|
|
|
#ifdef NFSKERB
|
|
|
|
/*
|
|
|
|
* Get the Kerberos ticket out of the authenticator
|
|
|
|
* verify it and convert the principal name to a user
|
|
|
|
* name. The user name is then converted to a set of
|
|
|
|
* user credentials via the password and group file.
|
|
|
|
* Finally, decrypt the timestamp and validate it.
|
|
|
|
* For more info see the IETF Draft "Authentication
|
|
|
|
* in ONC RPC".
|
|
|
|
*/
|
|
|
|
kt.length = ntohl(kt.length);
|
|
|
|
if (gettimeofday(&ktv, (struct timezone *)0) == 0 &&
|
|
|
|
kt.length > 0 && kt.length <=
|
|
|
|
(RPCAUTH_MAXSIZ - 3 * NFSX_UNSIGNED)) {
|
1999-06-07 10:13:41 +04:00
|
|
|
kin.w1 = NFS_KERBW1(kt);
|
|
|
|
kt.mbz = 0;
|
|
|
|
(void)strcpy(inst, "*");
|
|
|
|
if (krb_rd_req(&kt, NFS_KERBSRV,
|
|
|
|
inst, nsd.nsd_haddr, &kauth, "") ==
|
|
|
|
RD_AP_OK &&
|
|
|
|
krb_kntoln(&kauth, lnam) == KSUCCESS &&
|
|
|
|
(pwd = getpwnam(lnam)) != NULL) {
|
|
|
|
cr = &nsd.nsd_cr;
|
|
|
|
cr->cr_uid = pwd->pw_uid;
|
|
|
|
cr->cr_groups[0] = pwd->pw_gid;
|
|
|
|
cr->cr_ngroups = 1;
|
|
|
|
setgrent();
|
|
|
|
while ((grp = getgrent()) != NULL) {
|
|
|
|
if (grp->gr_gid ==
|
|
|
|
cr->cr_groups[0])
|
|
|
|
continue;
|
|
|
|
for (cpp = grp->gr_mem;
|
|
|
|
*cpp != NULL; ++cpp)
|
|
|
|
if (!strcmp(*cpp, lnam))
|
|
|
|
break;
|
|
|
|
if (*cpp == NULL)
|
|
|
|
continue;
|
|
|
|
cr->cr_groups[cr->cr_ngroups++]
|
|
|
|
= grp->gr_gid;
|
|
|
|
if (cr->cr_ngroups == NGROUPS)
|
1994-06-08 23:27:32 +04:00
|
|
|
break;
|
1999-06-07 10:13:41 +04:00
|
|
|
}
|
|
|
|
endgrent();
|
1996-02-18 14:58:24 +03:00
|
|
|
|
1999-06-07 10:13:41 +04:00
|
|
|
/*
|
|
|
|
* Get the timestamp verifier out of
|
|
|
|
* the authenticator and verifier
|
|
|
|
* strings.
|
|
|
|
*/
|
|
|
|
kin.t1 = kverf.t1;
|
|
|
|
kin.t2 = kverf.t2;
|
|
|
|
kin.w2 = kverf.w2;
|
|
|
|
memset((caddr_t)kivec, 0,
|
|
|
|
sizeof(kivec));
|
|
|
|
memmove((caddr_t)nsd.nsd_key,
|
|
|
|
(caddr_t)kauth.session,
|
|
|
|
sizeof(kauth.session));
|
1996-02-18 14:58:24 +03:00
|
|
|
|
1999-06-07 10:13:41 +04:00
|
|
|
/*
|
|
|
|
* Decrypt the timestamp verifier
|
|
|
|
* in CBC mode.
|
|
|
|
*/
|
|
|
|
XXX
|
1996-02-18 14:58:24 +03:00
|
|
|
|
1999-06-07 10:13:41 +04:00
|
|
|
/*
|
|
|
|
* Validate the timestamp verifier, to
|
|
|
|
* check that the session key is ok.
|
|
|
|
*/
|
|
|
|
nsd.nsd_timestamp.tv_sec =
|
|
|
|
ntohl(kout.t1);
|
|
|
|
nsd.nsd_timestamp.tv_usec =
|
|
|
|
ntohl(kout.t2);
|
|
|
|
nsd.nsd_ttl = ntohl(kout.w1);
|
|
|
|
if ((nsd.nsd_ttl - 1) == ntohl(kout.w2))
|
|
|
|
nfssvc_flag =
|
|
|
|
NFSSVC_NFSD | NFSSVC_AUTHIN;
|
|
|
|
}
|
1994-06-08 23:27:32 +04:00
|
|
|
}
|
1996-02-18 14:58:24 +03:00
|
|
|
#endif /* NFSKERB */
|
1994-06-08 23:27:32 +04:00
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we are serving udp, set up the socket. */
|
1993-03-21 12:45:37 +03:00
|
|
|
if (udpflag) {
|
2000-06-09 04:05:02 +04:00
|
|
|
if ((sock = socket(ai_udp->ai_family, ai_udp->ai_socktype,
|
|
|
|
ai_udp->ai_protocol)) < 0) {
|
1994-06-08 23:27:32 +04:00
|
|
|
syslog(LOG_ERR, "can't create udp socket");
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
2000-06-09 04:05:02 +04:00
|
|
|
if (bind(sock, ai_udp->ai_addr, ai_udp->ai_addrlen) < 0) {
|
1994-06-08 23:27:32 +04:00
|
|
|
syslog(LOG_ERR, "can't bind udp addr");
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
2000-06-09 04:05:02 +04:00
|
|
|
if (!rpcb_set(RPCPROG_NFS, 2, nconf_udp, &nb_udp) ||
|
|
|
|
!rpcb_set(RPCPROG_NFS, 3, nconf_udp, &nb_udp)) {
|
1994-06-08 23:27:32 +04:00
|
|
|
syslog(LOG_ERR, "can't register with udp portmap");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
nfsdargs.sock = sock;
|
|
|
|
nfsdargs.name = NULL;
|
|
|
|
nfsdargs.namelen = 0;
|
|
|
|
if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) {
|
2000-06-09 04:05:02 +04:00
|
|
|
syslog(LOG_ERR, "can't add UDP socket");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
(void)close(sock);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (udpflag &&ip6flag) {
|
|
|
|
if ((sock = socket(ai_udp6->ai_family, ai_udp6->ai_socktype,
|
|
|
|
ai_udp6->ai_protocol)) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't create udp socket");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (setsockopt(sock, IPPROTO_IPV6, IPV6_BINDV6ONLY,
|
|
|
|
&on, sizeof on) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't set v6-only binding for udp6 "
|
|
|
|
"socket: %m");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (bind(sock, ai_udp6->ai_addr, ai_udp6->ai_addrlen) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't bind udp addr");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (!rpcb_set(RPCPROG_NFS, 2, nconf_udp6, &nb_udp6) ||
|
|
|
|
!rpcb_set(RPCPROG_NFS, 3, nconf_udp6, &nb_udp6)) {
|
|
|
|
syslog(LOG_ERR, "can't register with udp portmap");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
nfsdargs.sock = sock;
|
|
|
|
nfsdargs.name = NULL;
|
|
|
|
nfsdargs.namelen = 0;
|
|
|
|
if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't add UDP6 socket");
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
1994-06-08 23:27:32 +04:00
|
|
|
(void)close(sock);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ISO
|
|
|
|
/* If we are serving cltp, set up the socket. */
|
|
|
|
if (cltpflag) {
|
|
|
|
if ((sock = socket(AF_ISO, SOCK_DGRAM, 0)) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't create cltp socket");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
memset(&isoaddr, 0, sizeof(isoaddr));
|
|
|
|
isoaddr.siso_family = AF_ISO;
|
|
|
|
isoaddr.siso_tlen = 2;
|
|
|
|
cp = TSEL(&isoaddr);
|
|
|
|
*cp++ = (NFS_PORT >> 8);
|
|
|
|
*cp = (NFS_PORT & 0xff);
|
|
|
|
isoaddr.siso_len = sizeof(isoaddr);
|
|
|
|
if (bind(sock,
|
|
|
|
(struct sockaddr *)&isoaddr, sizeof(isoaddr)) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't bind cltp addr");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
#ifdef notyet
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-06-08 23:27:32 +04:00
|
|
|
* XXX
|
|
|
|
* Someday this should probably use "rpcbind", the son of
|
|
|
|
* portmap.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-06-08 23:27:32 +04:00
|
|
|
if (!pmap_set(RPCPROG_NFS, NFS_VER2, IPPROTO_UDP, NFS_PORT)) {
|
|
|
|
syslog(LOG_ERR, "can't register with udp portmap");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
#endif /* notyet */
|
|
|
|
nfsdargs.sock = sock;
|
|
|
|
nfsdargs.name = NULL;
|
|
|
|
nfsdargs.namelen = 0;
|
|
|
|
if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't add UDP socket");
|
|
|
|
exit(1);
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
close(sock);
|
|
|
|
}
|
1994-06-08 23:27:32 +04:00
|
|
|
#endif /* ISO */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-06-08 23:27:32 +04:00
|
|
|
/* Now set up the master server socket waiting for tcp connections. */
|
|
|
|
on = 1;
|
|
|
|
FD_ZERO(&sockbits);
|
|
|
|
connect_type_cnt = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
if (tcpflag) {
|
2000-06-09 04:05:02 +04:00
|
|
|
if ((tcpsock = socket(ai_tcp->ai_family, ai_tcp->ai_socktype,
|
|
|
|
ai_tcp->ai_protocol)) < 0) {
|
1994-06-08 23:27:32 +04:00
|
|
|
syslog(LOG_ERR, "can't create tcp socket");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (setsockopt(tcpsock,
|
|
|
|
SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
|
|
|
|
syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m");
|
2000-06-09 04:05:02 +04:00
|
|
|
if (bind(tcpsock, ai_tcp->ai_addr, ai_tcp->ai_addrlen) < 0) {
|
1994-06-08 23:27:32 +04:00
|
|
|
syslog(LOG_ERR, "can't bind tcp addr");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (listen(tcpsock, 5) < 0) {
|
|
|
|
syslog(LOG_ERR, "listen failed");
|
|
|
|
exit(1);
|
|
|
|
}
|
2000-06-09 04:05:02 +04:00
|
|
|
if (!rpcb_set(RPCPROG_NFS, 2, nconf_tcp, &nb_tcp) ||
|
|
|
|
!rpcb_set(RPCPROG_NFS, 3, nconf_tcp, &nb_tcp)) {
|
|
|
|
syslog(LOG_ERR, "can't register tcp with rpcbind");
|
1994-06-08 23:27:32 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
FD_SET(tcpsock, &sockbits);
|
|
|
|
maxsock = tcpsock;
|
|
|
|
connect_type_cnt++;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2000-06-09 04:05:02 +04:00
|
|
|
if (tcpflag && ip6flag) {
|
|
|
|
if ((tcp6sock = socket(ai_tcp6->ai_family, ai_tcp6->ai_socktype,
|
|
|
|
ai_tcp6->ai_protocol)) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't create tcp socket");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (setsockopt(tcp6sock,
|
|
|
|
SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
|
|
|
|
syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m");
|
|
|
|
if (setsockopt(tcp6sock, IPPROTO_IPV6, IPV6_BINDV6ONLY,
|
|
|
|
&on, sizeof on) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't set v6-only binding for tcp6 "
|
|
|
|
"socket: %m");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (bind(tcp6sock, ai_tcp6->ai_addr, ai_tcp6->ai_addrlen) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't bind tcp6 addr");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (listen(tcp6sock, 5) < 0) {
|
|
|
|
syslog(LOG_ERR, "listen failed");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (!rpcb_set(RPCPROG_NFS, 2, nconf_tcp6, &nb_tcp6) ||
|
|
|
|
!rpcb_set(RPCPROG_NFS, 3, nconf_tcp6, &nb_tcp6)) {
|
|
|
|
syslog(LOG_ERR, "can't register tcp6 with rpcbind");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
FD_SET(tcp6sock, &sockbits);
|
|
|
|
maxsock = tcp6sock;
|
|
|
|
connect_type_cnt++;
|
|
|
|
}
|
|
|
|
|
1994-06-08 23:27:32 +04:00
|
|
|
#ifdef notyet
|
|
|
|
/* Now set up the master server socket waiting for tp4 connections. */
|
|
|
|
if (tp4flag) {
|
|
|
|
if ((tp4sock = socket(AF_ISO, SOCK_SEQPACKET, 0)) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't create tp4 socket");
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
1994-06-08 23:27:32 +04:00
|
|
|
if (setsockopt(tp4sock,
|
|
|
|
SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
|
1993-03-21 12:45:37 +03:00
|
|
|
syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m");
|
1994-06-08 23:27:32 +04:00
|
|
|
memset(&isoaddr, 0, sizeof(isoaddr));
|
|
|
|
isoaddr.siso_family = AF_ISO;
|
|
|
|
isoaddr.siso_tlen = 2;
|
|
|
|
cp = TSEL(&isoaddr);
|
|
|
|
*cp++ = (NFS_PORT >> 8);
|
|
|
|
*cp = (NFS_PORT & 0xff);
|
|
|
|
isoaddr.siso_len = sizeof(isoaddr);
|
|
|
|
if (bind(tp4sock,
|
1994-09-23 18:26:58 +04:00
|
|
|
(struct sockaddr *)&isoaddr, sizeof(isoaddr)) < 0) {
|
1994-06-08 23:27:32 +04:00
|
|
|
syslog(LOG_ERR, "can't bind tp4 addr");
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
1994-06-08 23:27:32 +04:00
|
|
|
if (listen(tp4sock, 5) < 0) {
|
|
|
|
syslog(LOG_ERR, "listen failed");
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
1994-06-08 23:27:32 +04:00
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* Someday this should probably use "rpcbind", the son of
|
|
|
|
* portmap.
|
|
|
|
*/
|
1993-03-21 12:45:37 +03:00
|
|
|
if (!pmap_set(RPCPROG_NFS, NFS_VER2, IPPROTO_TCP, NFS_PORT)) {
|
1994-06-08 23:27:32 +04:00
|
|
|
syslog(LOG_ERR, "can't register tcp with portmap");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
FD_SET(tp4sock, &sockbits);
|
|
|
|
maxsock = tp4sock;
|
|
|
|
connect_type_cnt++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now set up the master server socket waiting for tpip connections. */
|
|
|
|
if (tpipflag) {
|
|
|
|
if ((tpipsock = socket(AF_INET, SOCK_SEQPACKET, 0)) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't create tpip socket");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (setsockopt(tpipsock,
|
|
|
|
SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
|
|
|
|
syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m");
|
|
|
|
inetaddr.sin_family = AF_INET;
|
|
|
|
inetaddr.sin_addr.s_addr = INADDR_ANY;
|
|
|
|
inetaddr.sin_port = htons(NFS_PORT);
|
|
|
|
inetaddr.sin_len = sizeof(inetaddr);
|
1996-09-16 21:22:04 +04:00
|
|
|
memset(inetaddr.sin_zero, 0, sizeof(inetaddr.sin_zero));
|
1994-06-08 23:27:32 +04:00
|
|
|
if (bind(tpipsock,
|
|
|
|
(struct sockaddr *)&inetaddr, sizeof (inetaddr)) < 0) {
|
|
|
|
syslog(LOG_ERR, "can't bind tcp addr");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (listen(tpipsock, 5) < 0) {
|
|
|
|
syslog(LOG_ERR, "listen failed");
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
/*
|
1994-06-08 23:27:32 +04:00
|
|
|
* XXX
|
|
|
|
* Someday this should probably use "rpcbind", the son of
|
|
|
|
* portmap.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-06-08 23:27:32 +04:00
|
|
|
if (!pmap_set(RPCPROG_NFS, NFS_VER2, IPPROTO_TCP, NFS_PORT)) {
|
|
|
|
syslog(LOG_ERR, "can't register tcp with portmap");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
FD_SET(tpipsock, &sockbits);
|
|
|
|
maxsock = tpipsock;
|
|
|
|
connect_type_cnt++;
|
|
|
|
}
|
|
|
|
#endif /* notyet */
|
|
|
|
|
|
|
|
if (connect_type_cnt == 0)
|
|
|
|
exit(0);
|
|
|
|
|
1994-10-18 17:12:55 +03:00
|
|
|
setproctitle("master");
|
1994-06-08 23:27:32 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop forever accepting connections and passing the sockets
|
|
|
|
* into the kernel for the mounts.
|
|
|
|
*/
|
|
|
|
for (;;) {
|
|
|
|
ready = sockbits;
|
|
|
|
if (connect_type_cnt > 1) {
|
|
|
|
if (select(maxsock + 1,
|
|
|
|
&ready, NULL, NULL, NULL) < 1) {
|
|
|
|
syslog(LOG_ERR, "select failed: %m");
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
1994-06-08 23:27:32 +04:00
|
|
|
}
|
|
|
|
if (tcpflag && FD_ISSET(tcpsock, &ready)) {
|
|
|
|
len = sizeof(inetpeer);
|
|
|
|
if ((msgsock = accept(tcpsock,
|
|
|
|
(struct sockaddr *)&inetpeer, &len)) < 0) {
|
|
|
|
syslog(LOG_ERR, "accept failed: %m");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
memset(inetpeer.sin_zero, 0, sizeof(inetpeer.sin_zero));
|
|
|
|
if (setsockopt(msgsock, SOL_SOCKET,
|
|
|
|
SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0)
|
|
|
|
syslog(LOG_ERR,
|
|
|
|
"setsockopt SO_KEEPALIVE: %m");
|
|
|
|
nfsdargs.sock = msgsock;
|
|
|
|
nfsdargs.name = (caddr_t)&inetpeer;
|
|
|
|
nfsdargs.namelen = sizeof(inetpeer);
|
|
|
|
nfssvc(NFSSVC_ADDSOCK, &nfsdargs);
|
|
|
|
(void)close(msgsock);
|
|
|
|
}
|
2000-06-09 04:05:02 +04:00
|
|
|
|
|
|
|
if (tcpflag && ip6flag && FD_ISSET(tcp6sock, &ready)) {
|
|
|
|
len = sizeof(inet6peer);
|
|
|
|
if ((msgsock = accept(tcp6sock,
|
|
|
|
(struct sockaddr *)&inet6peer, &len)) < 0) {
|
|
|
|
syslog(LOG_ERR, "accept failed: %m");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (setsockopt(msgsock, SOL_SOCKET,
|
|
|
|
SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0)
|
|
|
|
syslog(LOG_ERR,
|
|
|
|
"setsockopt SO_KEEPALIVE: %m");
|
|
|
|
nfsdargs.sock = msgsock;
|
|
|
|
nfsdargs.name = (caddr_t)&inet6peer;
|
|
|
|
nfsdargs.namelen = sizeof(inet6peer);
|
|
|
|
nfssvc(NFSSVC_ADDSOCK, &nfsdargs);
|
|
|
|
(void)close(msgsock);
|
|
|
|
}
|
|
|
|
|
1994-06-08 23:27:32 +04:00
|
|
|
#ifdef notyet
|
|
|
|
if (tp4flag && FD_ISSET(tp4sock, &ready)) {
|
|
|
|
len = sizeof(isopeer);
|
|
|
|
if ((msgsock = accept(tp4sock,
|
|
|
|
(struct sockaddr *)&isopeer, &len)) < 0) {
|
|
|
|
syslog(LOG_ERR, "accept failed: %m");
|
|
|
|
exit(1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-06-08 23:27:32 +04:00
|
|
|
if (setsockopt(msgsock, SOL_SOCKET,
|
|
|
|
SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0)
|
|
|
|
syslog(LOG_ERR,
|
|
|
|
"setsockopt SO_KEEPALIVE: %m");
|
|
|
|
nfsdargs.sock = msgsock;
|
|
|
|
nfsdargs.name = (caddr_t)&isopeer;
|
|
|
|
nfsdargs.namelen = len;
|
|
|
|
nfssvc(NFSSVC_ADDSOCK, &nfsdargs);
|
|
|
|
(void)close(msgsock);
|
|
|
|
}
|
|
|
|
if (tpipflag && FD_ISSET(tpipsock, &ready)) {
|
|
|
|
len = sizeof(inetpeer);
|
|
|
|
if ((msgsock = accept(tpipsock,
|
|
|
|
(struct sockaddr *)&inetpeer, &len)) < 0) {
|
|
|
|
syslog(LOG_ERR, "Accept failed: %m");
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
1994-06-08 23:27:32 +04:00
|
|
|
if (setsockopt(msgsock, SOL_SOCKET,
|
|
|
|
SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0)
|
|
|
|
syslog(LOG_ERR, "setsockopt SO_KEEPALIVE: %m");
|
|
|
|
nfsdargs.sock = msgsock;
|
|
|
|
nfsdargs.name = (caddr_t)&inetpeer;
|
|
|
|
nfsdargs.namelen = len;
|
|
|
|
nfssvc(NFSSVC_ADDSOCK, &nfsdargs);
|
|
|
|
(void)close(msgsock);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-06-08 23:27:32 +04:00
|
|
|
#endif /* notyet */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-06-08 23:27:32 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
usage()
|
|
|
|
{
|
1998-07-12 13:13:27 +04:00
|
|
|
|
1994-10-18 19:38:12 +03:00
|
|
|
(void)fprintf(stderr, "usage: nfsd %s\n", USAGE);
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1994-06-08 23:27:32 +04:00
|
|
|
nonfs(signo)
|
|
|
|
int signo;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-10-18 19:38:12 +03:00
|
|
|
|
1994-06-08 23:27:32 +04:00
|
|
|
syslog(LOG_ERR, "missing system call: NFS not available.");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-06-08 23:27:32 +04:00
|
|
|
void
|
|
|
|
reapchild(signo)
|
|
|
|
int signo;
|
1993-04-11 00:16:04 +04:00
|
|
|
{
|
1994-06-08 23:27:32 +04:00
|
|
|
|
1996-02-18 14:58:24 +03:00
|
|
|
while (wait3(NULL, WNOHANG, NULL) > 0);
|
1993-04-11 00:16:04 +04:00
|
|
|
}
|