1 /* $NetBSD: nfsd.c,v 1.21 1997/09/05 10:52:10 fvdl Exp $ */ 2 3 /* 4 * Copyright (c) 1989, 1993, 1994 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Rick Macklem at The University of Guelph. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 */ 38 39 #ifndef lint 40 static char copyright[] = 41 "@(#) Copyright (c) 1989, 1993, 1994\n\ 42 The Regents of the University of California. All rights reserved.\n"; 43 #endif not lint 44 45 #ifndef lint 46 #if 0 47 static char sccsid[] = "@(#)nfsd.c 8.9 (Berkeley) 3/29/95"; 48 #else 49 static char rcsid[] = "$NetBSD: nfsd.c,v 1.21 1997/09/05 10:52:10 fvdl Exp $"; 50 #endif 51 #endif /* not lint */ 52 53 #include <sys/param.h> 54 #include <sys/ioctl.h> 55 #include <sys/stat.h> 56 #include <sys/wait.h> 57 #include <sys/uio.h> 58 #include <sys/ucred.h> 59 #include <sys/mount.h> 60 #include <sys/socket.h> 61 #include <sys/socketvar.h> 62 63 #include <rpc/rpc.h> 64 #include <rpc/pmap_clnt.h> 65 #include <rpc/pmap_prot.h> 66 67 #ifdef ISO 68 #include <netiso/iso.h> 69 #endif 70 #include <nfs/rpcv2.h> 71 #include <nfs/nfsproto.h> 72 #include <nfs/nfs.h> 73 74 #ifdef NFSKERB 75 #include <kerberosIV/des.h> 76 #include <kerberosIV/krb.h> 77 #endif 78 79 #include <err.h> 80 #include <errno.h> 81 #include <fcntl.h> 82 #include <grp.h> 83 #include <pwd.h> 84 #include <signal.h> 85 #include <stdio.h> 86 #include <stdlib.h> 87 #include <strings.h> 88 #include <syslog.h> 89 #include <unistd.h> 90 91 /* Global defs */ 92 #ifdef DEBUG 93 #define syslog(e, s) fprintf(stderr,(s)) 94 int debug = 1; 95 #else 96 int debug = 0; 97 #endif 98 99 struct nfsd_srvargs nsd; 100 101 #ifdef NFSKERB 102 char lnam[ANAME_SZ]; 103 KTEXT_ST kt; 104 AUTH_DAT kauth; 105 char inst[INST_SZ]; 106 struct nfsrpc_fullblock kin, kout; 107 struct nfsrpc_fullverf kverf; 108 NFSKERBKEY_T kivec; 109 struct timeval ktv; 110 NFSKERBKEYSCHED_T kerb_keysched; 111 #endif 112 113 void nonfs __P((int)); 114 void reapchild __P((int)); 115 void usage __P((void)); 116 117 /* 118 * Nfs server daemon mostly just a user context for nfssvc() 119 * 120 * 1 - do file descriptor and signal cleanup 121 * 2 - fork the nfsd(s) 122 * 3 - create server socket(s) 123 * 4 - register socket with portmap 124 * 125 * For connectionless protocols, just pass the socket into the kernel via. 126 * nfssvc(). 127 * For connection based sockets, loop doing accepts. When you get a new 128 * socket from accept, pass the msgsock into the kernel via. nfssvc(). 129 * The arguments are: 130 * -c - support iso cltp clients 131 * -r - reregister with portmapper 132 * -t - support tcp nfs clients 133 * -u - support udp nfs clients 134 * followed by "n" which is the number of nfsds' to fork off 135 */ 136 int 137 main(argc, argv, envp) 138 int argc; 139 char *argv[], *envp[]; 140 { 141 extern int optind; 142 struct group *grp; 143 struct nfsd_args nfsdargs; 144 struct passwd *pwd; 145 struct ucred *cr; 146 struct sockaddr_in inetaddr, inetpeer; 147 #ifdef ISO 148 struct sockaddr_iso isoaddr, isopeer; 149 #endif 150 struct timeval ktv; 151 fd_set ready, sockbits; 152 int ch, cltpflag, connect_type_cnt, i, len, maxsock, msgsock; 153 int nfsdcnt, nfssvc_flag, on, reregister, sock, tcpflag, tcpsock; 154 int tp4cnt, tp4flag, tp4sock, tpipcnt, tpipflag, tpipsock, udpflag; 155 char *cp, **cpp; 156 157 #define MAXNFSDCNT 20 158 #define DEFNFSDCNT 4 159 nfsdcnt = DEFNFSDCNT; 160 cltpflag = reregister = tcpflag = tp4cnt = tp4flag = tpipcnt = 0; 161 tpipflag = udpflag = 0; 162 #ifdef ISO 163 #define GETOPT "cn:rtu" 164 #define USAGE "[-crtu] [-n num_servers]" 165 #else 166 #define GETOPT "n:rtu" 167 #define USAGE "[-rtu] [-n num_servers]" 168 #endif 169 while ((ch = getopt(argc, argv, GETOPT)) != EOF) 170 switch (ch) { 171 case 'n': 172 nfsdcnt = atoi(optarg); 173 if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) { 174 warnx("nfsd count %d; reset to %d", nfsdcnt, DEFNFSDCNT); 175 nfsdcnt = DEFNFSDCNT; 176 } 177 break; 178 case 'r': 179 reregister = 1; 180 break; 181 case 't': 182 tcpflag = 1; 183 break; 184 case 'u': 185 udpflag = 1; 186 break; 187 #ifdef ISO 188 case 'c': 189 cltpflag = 1; 190 break; 191 #ifdef notyet 192 case 'i': 193 tp4cnt = 1; 194 break; 195 case 'p': 196 tpipcnt = 1; 197 break; 198 #endif /* notyet */ 199 #endif /* ISO */ 200 default: 201 case '?': 202 usage(); 203 }; 204 argv += optind; 205 argc -= optind; 206 207 /* 208 * XXX 209 * Backward compatibility, trailing number is the count of daemons. 210 */ 211 if (argc > 1) 212 usage(); 213 if (argc == 1) { 214 nfsdcnt = atoi(argv[0]); 215 if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) { 216 warnx("nfsd count %d; reset to %d", nfsdcnt, DEFNFSDCNT); 217 nfsdcnt = DEFNFSDCNT; 218 } 219 } 220 221 if (debug == 0) { 222 daemon(0, 0); 223 (void)signal(SIGHUP, SIG_IGN); 224 (void)signal(SIGINT, SIG_IGN); 225 (void)signal(SIGQUIT, SIG_IGN); 226 (void)signal(SIGSYS, nonfs); 227 (void)signal(SIGTERM, SIG_IGN); 228 } 229 (void)signal(SIGCHLD, reapchild); 230 231 if (reregister) { 232 if (udpflag && 233 (!pmap_set(RPCPROG_NFS, 2, IPPROTO_UDP, NFS_PORT) || 234 !pmap_set(RPCPROG_NFS, 3, IPPROTO_UDP, NFS_PORT))) 235 err(1, "can't register with portmap for UDP."); 236 if (tcpflag && 237 (!pmap_set(RPCPROG_NFS, 2, IPPROTO_TCP, NFS_PORT) || 238 !pmap_set(RPCPROG_NFS, 3, IPPROTO_TCP, NFS_PORT))) 239 err(1, "can't register with portmap for TCP."); 240 exit(0); 241 } 242 openlog("nfsd:", LOG_PID, LOG_DAEMON); 243 244 for (i = 0; i < nfsdcnt; i++) { 245 switch (fork()) { 246 case -1: 247 syslog(LOG_ERR, "fork: %m"); 248 exit (1); 249 case 0: 250 break; 251 default: 252 continue; 253 } 254 255 setproctitle("server"); 256 nfssvc_flag = NFSSVC_NFSD; 257 nsd.nsd_nfsd = NULL; 258 #ifdef NFSKERB 259 if (sizeof (struct nfsrpc_fullverf) != RPCX_FULLVERF || 260 sizeof (struct nfsrpc_fullblock) != RPCX_FULLBLOCK) 261 syslog(LOG_ERR, "Yikes NFSKERB structs not packed!"); 262 nsd.nsd_authstr = (u_char *)&kt; 263 nsd.nsd_authlen = sizeof (kt); 264 nsd.nsd_verfstr = (u_char *)&kverf; 265 nsd.nsd_verflen = sizeof (kverf); 266 #endif 267 while (nfssvc(nfssvc_flag, &nsd) < 0) { 268 if (errno != ENEEDAUTH) { 269 syslog(LOG_ERR, "nfssvc: %m"); 270 exit(1); 271 } 272 nfssvc_flag = NFSSVC_NFSD | NFSSVC_AUTHINFAIL; 273 #ifdef NFSKERB 274 /* 275 * Get the Kerberos ticket out of the authenticator 276 * verify it and convert the principal name to a user 277 * name. The user name is then converted to a set of 278 * user credentials via the password and group file. 279 * Finally, decrypt the timestamp and validate it. 280 * For more info see the IETF Draft "Authentication 281 * in ONC RPC". 282 */ 283 kt.length = ntohl(kt.length); 284 if (gettimeofday(&ktv, (struct timezone *)0) == 0 && 285 kt.length > 0 && kt.length <= 286 (RPCAUTH_MAXSIZ - 3 * NFSX_UNSIGNED)) { 287 kin.w1 = NFS_KERBW1(kt); 288 kt.mbz = 0; 289 (void)strcpy(inst, "*"); 290 if (krb_rd_req(&kt, NFS_KERBSRV, 291 inst, nsd.nsd_haddr, &kauth, "") == RD_AP_OK && 292 krb_kntoln(&kauth, lnam) == KSUCCESS && 293 (pwd = getpwnam(lnam)) != NULL) { 294 cr = &nsd.nsd_cr; 295 cr->cr_uid = pwd->pw_uid; 296 cr->cr_groups[0] = pwd->pw_gid; 297 cr->cr_ngroups = 1; 298 setgrent(); 299 while ((grp = getgrent()) != NULL) { 300 if (grp->gr_gid == cr->cr_groups[0]) 301 continue; 302 for (cpp = grp->gr_mem; 303 *cpp != NULL; ++cpp) 304 if (!strcmp(*cpp, lnam)) 305 break; 306 if (*cpp == NULL) 307 continue; 308 cr->cr_groups[cr->cr_ngroups++] 309 = grp->gr_gid; 310 if (cr->cr_ngroups == NGROUPS) 311 break; 312 } 313 endgrent(); 314 315 /* 316 * Get the timestamp verifier out of the 317 * authenticator and verifier strings. 318 */ 319 kin.t1 = kverf.t1; 320 kin.t2 = kverf.t2; 321 kin.w2 = kverf.w2; 322 bzero((caddr_t)kivec, sizeof (kivec)); 323 bcopy((caddr_t)kauth.session, 324 (caddr_t)nsd.nsd_key,sizeof(kauth.session)); 325 326 /* 327 * Decrypt the timestamp verifier in CBC mode. 328 */ 329 XXX 330 331 /* 332 * Validate the timestamp verifier, to 333 * check that the session key is ok. 334 */ 335 nsd.nsd_timestamp.tv_sec = ntohl(kout.t1); 336 nsd.nsd_timestamp.tv_usec = ntohl(kout.t2); 337 nsd.nsd_ttl = ntohl(kout.w1); 338 if ((nsd.nsd_ttl - 1) == ntohl(kout.w2)) 339 nfssvc_flag = NFSSVC_NFSD | NFSSVC_AUTHIN; 340 } 341 #endif /* NFSKERB */ 342 } 343 exit(0); 344 } 345 346 /* If we are serving udp, set up the socket. */ 347 if (udpflag) { 348 if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 349 syslog(LOG_ERR, "can't create udp socket"); 350 exit(1); 351 } 352 inetaddr.sin_family = AF_INET; 353 inetaddr.sin_addr.s_addr = INADDR_ANY; 354 inetaddr.sin_port = htons(NFS_PORT); 355 inetaddr.sin_len = sizeof(inetaddr); 356 memset(inetaddr.sin_zero, 0, sizeof(inetaddr.sin_zero)); 357 if (bind(sock, 358 (struct sockaddr *)&inetaddr, sizeof(inetaddr)) < 0) { 359 syslog(LOG_ERR, "can't bind udp addr"); 360 exit(1); 361 } 362 if (!pmap_set(RPCPROG_NFS, 2, IPPROTO_UDP, NFS_PORT) || 363 !pmap_set(RPCPROG_NFS, 3, IPPROTO_UDP, NFS_PORT)) { 364 syslog(LOG_ERR, "can't register with udp portmap"); 365 exit(1); 366 } 367 nfsdargs.sock = sock; 368 nfsdargs.name = NULL; 369 nfsdargs.namelen = 0; 370 if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) { 371 syslog(LOG_ERR, "can't Add UDP socket"); 372 exit(1); 373 } 374 (void)close(sock); 375 } 376 377 #ifdef ISO 378 /* If we are serving cltp, set up the socket. */ 379 if (cltpflag) { 380 if ((sock = socket(AF_ISO, SOCK_DGRAM, 0)) < 0) { 381 syslog(LOG_ERR, "can't create cltp socket"); 382 exit(1); 383 } 384 memset(&isoaddr, 0, sizeof(isoaddr)); 385 isoaddr.siso_family = AF_ISO; 386 isoaddr.siso_tlen = 2; 387 cp = TSEL(&isoaddr); 388 *cp++ = (NFS_PORT >> 8); 389 *cp = (NFS_PORT & 0xff); 390 isoaddr.siso_len = sizeof(isoaddr); 391 if (bind(sock, 392 (struct sockaddr *)&isoaddr, sizeof(isoaddr)) < 0) { 393 syslog(LOG_ERR, "can't bind cltp addr"); 394 exit(1); 395 } 396 #ifdef notyet 397 /* 398 * XXX 399 * Someday this should probably use "rpcbind", the son of 400 * portmap. 401 */ 402 if (!pmap_set(RPCPROG_NFS, NFS_VER2, IPPROTO_UDP, NFS_PORT)) { 403 syslog(LOG_ERR, "can't register with udp portmap"); 404 exit(1); 405 } 406 #endif /* notyet */ 407 nfsdargs.sock = sock; 408 nfsdargs.name = NULL; 409 nfsdargs.namelen = 0; 410 if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) { 411 syslog(LOG_ERR, "can't add UDP socket"); 412 exit(1); 413 } 414 close(sock); 415 } 416 #endif /* ISO */ 417 418 /* Now set up the master server socket waiting for tcp connections. */ 419 on = 1; 420 FD_ZERO(&sockbits); 421 connect_type_cnt = 0; 422 if (tcpflag) { 423 if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { 424 syslog(LOG_ERR, "can't create tcp socket"); 425 exit(1); 426 } 427 if (setsockopt(tcpsock, 428 SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) 429 syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m"); 430 inetaddr.sin_family = AF_INET; 431 inetaddr.sin_addr.s_addr = INADDR_ANY; 432 inetaddr.sin_port = htons(NFS_PORT); 433 inetaddr.sin_len = sizeof(inetaddr); 434 memset(inetaddr.sin_zero, 0, sizeof(inetaddr.sin_zero)); 435 if (bind(tcpsock, 436 (struct sockaddr *)&inetaddr, sizeof (inetaddr)) < 0) { 437 syslog(LOG_ERR, "can't bind tcp addr"); 438 exit(1); 439 } 440 if (listen(tcpsock, 5) < 0) { 441 syslog(LOG_ERR, "listen failed"); 442 exit(1); 443 } 444 if (!pmap_set(RPCPROG_NFS, 2, IPPROTO_TCP, NFS_PORT) || 445 !pmap_set(RPCPROG_NFS, 3, IPPROTO_TCP, NFS_PORT)) { 446 syslog(LOG_ERR, "can't register tcp with portmap"); 447 exit(1); 448 } 449 FD_SET(tcpsock, &sockbits); 450 maxsock = tcpsock; 451 connect_type_cnt++; 452 } 453 454 #ifdef notyet 455 /* Now set up the master server socket waiting for tp4 connections. */ 456 if (tp4flag) { 457 if ((tp4sock = socket(AF_ISO, SOCK_SEQPACKET, 0)) < 0) { 458 syslog(LOG_ERR, "can't create tp4 socket"); 459 exit(1); 460 } 461 if (setsockopt(tp4sock, 462 SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) 463 syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m"); 464 memset(&isoaddr, 0, sizeof(isoaddr)); 465 isoaddr.siso_family = AF_ISO; 466 isoaddr.siso_tlen = 2; 467 cp = TSEL(&isoaddr); 468 *cp++ = (NFS_PORT >> 8); 469 *cp = (NFS_PORT & 0xff); 470 isoaddr.siso_len = sizeof(isoaddr); 471 if (bind(tp4sock, 472 (struct sockaddr *)&isoaddr, sizeof(isoaddr)) < 0) { 473 syslog(LOG_ERR, "can't bind tp4 addr"); 474 exit(1); 475 } 476 if (listen(tp4sock, 5) < 0) { 477 syslog(LOG_ERR, "listen failed"); 478 exit(1); 479 } 480 /* 481 * XXX 482 * Someday this should probably use "rpcbind", the son of 483 * portmap. 484 */ 485 if (!pmap_set(RPCPROG_NFS, NFS_VER2, IPPROTO_TCP, NFS_PORT)) { 486 syslog(LOG_ERR, "can't register tcp with portmap"); 487 exit(1); 488 } 489 FD_SET(tp4sock, &sockbits); 490 maxsock = tp4sock; 491 connect_type_cnt++; 492 } 493 494 /* Now set up the master server socket waiting for tpip connections. */ 495 if (tpipflag) { 496 if ((tpipsock = socket(AF_INET, SOCK_SEQPACKET, 0)) < 0) { 497 syslog(LOG_ERR, "can't create tpip socket"); 498 exit(1); 499 } 500 if (setsockopt(tpipsock, 501 SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) 502 syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m"); 503 inetaddr.sin_family = AF_INET; 504 inetaddr.sin_addr.s_addr = INADDR_ANY; 505 inetaddr.sin_port = htons(NFS_PORT); 506 inetaddr.sin_len = sizeof(inetaddr); 507 memset(inetaddr.sin_zero, 0, sizeof(inetaddr.sin_zero)); 508 if (bind(tpipsock, 509 (struct sockaddr *)&inetaddr, sizeof (inetaddr)) < 0) { 510 syslog(LOG_ERR, "can't bind tcp addr"); 511 exit(1); 512 } 513 if (listen(tpipsock, 5) < 0) { 514 syslog(LOG_ERR, "listen failed"); 515 exit(1); 516 } 517 /* 518 * XXX 519 * Someday this should probably use "rpcbind", the son of 520 * portmap. 521 */ 522 if (!pmap_set(RPCPROG_NFS, NFS_VER2, IPPROTO_TCP, NFS_PORT)) { 523 syslog(LOG_ERR, "can't register tcp with portmap"); 524 exit(1); 525 } 526 FD_SET(tpipsock, &sockbits); 527 maxsock = tpipsock; 528 connect_type_cnt++; 529 } 530 #endif /* notyet */ 531 532 if (connect_type_cnt == 0) 533 exit(0); 534 535 setproctitle("master"); 536 537 /* 538 * Loop forever accepting connections and passing the sockets 539 * into the kernel for the mounts. 540 */ 541 for (;;) { 542 ready = sockbits; 543 if (connect_type_cnt > 1) { 544 if (select(maxsock + 1, 545 &ready, NULL, NULL, NULL) < 1) { 546 syslog(LOG_ERR, "select failed: %m"); 547 exit(1); 548 } 549 } 550 if (tcpflag && FD_ISSET(tcpsock, &ready)) { 551 len = sizeof(inetpeer); 552 if ((msgsock = accept(tcpsock, 553 (struct sockaddr *)&inetpeer, &len)) < 0) { 554 syslog(LOG_ERR, "accept failed: %m"); 555 exit(1); 556 } 557 memset(inetpeer.sin_zero, 0, sizeof(inetpeer.sin_zero)); 558 if (setsockopt(msgsock, SOL_SOCKET, 559 SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0) 560 syslog(LOG_ERR, 561 "setsockopt SO_KEEPALIVE: %m"); 562 nfsdargs.sock = msgsock; 563 nfsdargs.name = (caddr_t)&inetpeer; 564 nfsdargs.namelen = sizeof(inetpeer); 565 nfssvc(NFSSVC_ADDSOCK, &nfsdargs); 566 (void)close(msgsock); 567 } 568 #ifdef notyet 569 if (tp4flag && FD_ISSET(tp4sock, &ready)) { 570 len = sizeof(isopeer); 571 if ((msgsock = accept(tp4sock, 572 (struct sockaddr *)&isopeer, &len)) < 0) { 573 syslog(LOG_ERR, "accept failed: %m"); 574 exit(1); 575 } 576 if (setsockopt(msgsock, SOL_SOCKET, 577 SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0) 578 syslog(LOG_ERR, 579 "setsockopt SO_KEEPALIVE: %m"); 580 nfsdargs.sock = msgsock; 581 nfsdargs.name = (caddr_t)&isopeer; 582 nfsdargs.namelen = len; 583 nfssvc(NFSSVC_ADDSOCK, &nfsdargs); 584 (void)close(msgsock); 585 } 586 if (tpipflag && FD_ISSET(tpipsock, &ready)) { 587 len = sizeof(inetpeer); 588 if ((msgsock = accept(tpipsock, 589 (struct sockaddr *)&inetpeer, &len)) < 0) { 590 syslog(LOG_ERR, "Accept failed: %m"); 591 exit(1); 592 } 593 if (setsockopt(msgsock, SOL_SOCKET, 594 SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0) 595 syslog(LOG_ERR, "setsockopt SO_KEEPALIVE: %m"); 596 nfsdargs.sock = msgsock; 597 nfsdargs.name = (caddr_t)&inetpeer; 598 nfsdargs.namelen = len; 599 nfssvc(NFSSVC_ADDSOCK, &nfsdargs); 600 (void)close(msgsock); 601 } 602 #endif /* notyet */ 603 } 604 } 605 606 void 607 usage() 608 { 609 (void)fprintf(stderr, "usage: nfsd %s\n", USAGE); 610 exit(1); 611 } 612 613 void 614 nonfs(signo) 615 int signo; 616 { 617 618 syslog(LOG_ERR, "missing system call: NFS not available."); 619 } 620 621 void 622 reapchild(signo) 623 int signo; 624 { 625 626 while (wait3(NULL, WNOHANG, NULL) > 0); 627 } 628