get mxge to build, stage 29/many
[dragonfly.git] / usr.sbin / rpcbind / rpcbind.c
blobcbd6812cb4a7306102e18ed6b954a73687e59291
1 /*
2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3 * unrestricted use provided that this legend is included on all tape
4 * media and as a part of the software program in whole or part. Users
5 * may copy or modify Sun RPC without charge, but are not authorized
6 * to license or distribute it to anyone else except as part of a product or
7 * program developed by the user.
9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
13 * Sun RPC is provided with no support and without any obligation on the
14 * part of Sun Microsystems, Inc. to assist in its use, correction,
15 * modification or enhancement.
17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19 * OR ANY PART THEREOF.
21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22 * or profits or other special, indirect and consequential damages, even if
23 * Sun has been advised of the possibility of such damages.
25 * Sun Microsystems, Inc.
26 * 2550 Garcia Avenue
27 * Mountain View, California 94043
29 * @(#)rpcbind.c 1.19 94/04/25 SMI; 1.35 89/04/21 Copyr 1984 Sun Micro
30 * $NetBSD: rpcbind.c,v 1.3 2002/11/08 00:16:40 fvdl Exp $
31 * $FreeBSD: src/usr.sbin/rpcbind/rpcbind.c,v 1.20 2008/02/14 20:12:23 yar Exp $
34 * Copyright (c) 1984 - 1991 by Sun Microsystems, Inc.
38 * rpcbind.c
39 * Implements the program, version to address mapping for rpc.
43 #include <sys/types.h>
44 #include <sys/stat.h>
45 #include <sys/errno.h>
46 #include <sys/time.h>
47 #include <sys/resource.h>
48 #include <sys/wait.h>
49 #include <sys/signal.h>
50 #include <sys/socket.h>
51 #include <sys/un.h>
52 #include <rpc/rpc.h>
53 #include <rpc/rpc_com.h>
54 #ifdef PORTMAP
55 #include <netinet/in.h>
56 #endif
57 #include <arpa/inet.h>
58 #include <fcntl.h>
59 #include <netdb.h>
60 #include <stdio.h>
61 #include <netconfig.h>
62 #include <stdlib.h>
63 #include <unistd.h>
64 #include <syslog.h>
65 #include <err.h>
66 #include <libutil.h>
67 #include <pwd.h>
68 #include <string.h>
69 #include <errno.h>
70 #include "rpcbind.h"
72 /* Global variables */
73 int debugging = 0; /* Tell me what's going on */
74 int doabort = 0; /* When debugging, do an abort on errors */
75 rpcblist_ptr list_rbl; /* A list of version 3/4 rpcbind services */
77 /* who to suid to if -s is given */
78 #define RUN_AS "daemon"
80 #define RPCBINDDLOCK "/var/run/rpcbind.lock"
82 int runasdaemon = 0;
83 int insecure = 0;
84 int oldstyle_local = 0;
85 int verboselog = 0;
87 char **hosts = NULL;
88 int ipv6_only = 0;
89 int nhosts = 0;
90 int on = 1;
91 int rpcbindlockfd;
93 #ifdef WARMSTART
94 /* Local Variable */
95 static int warmstart = 0; /* Grab an old copy of registrations. */
96 #endif
98 #ifdef PORTMAP
99 struct pmaplist *list_pml; /* A list of version 2 rpcbind services */
100 char *udptrans; /* Name of UDP transport */
101 char *tcptrans; /* Name of TCP transport */
102 char *udp_uaddr; /* Universal UDP address */
103 char *tcp_uaddr; /* Universal TCP address */
104 #endif
105 static char servname[] = "rpcbind";
106 static char superuser[] = "superuser";
108 static int init_transport(struct netconfig *);
109 static void rbllist_add(rpcprog_t, rpcvers_t, struct netconfig *,
110 struct netbuf *);
111 static void terminate(int);
112 static void parseargs(int, char *[]);
115 main(int argc, char *argv[])
117 struct netconfig *nconf;
118 void *nc_handle; /* Net config handle */
119 struct rlimit rl;
120 int maxrec = RPC_MAXDATASIZE;
122 parseargs(argc, argv);
124 /* Check that another rpcbind isn't already running. */
125 if ((rpcbindlockfd = (open(RPCBINDDLOCK,
126 O_RDONLY|O_CREAT, 0444))) == -1)
127 err(1, "%s", RPCBINDDLOCK);
129 if(flock(rpcbindlockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK)
130 errx(1, "another rpcbind is already running. Aborting");
132 getrlimit(RLIMIT_NOFILE, &rl);
133 if (rl.rlim_cur < 128) {
134 if (rl.rlim_max <= 128)
135 rl.rlim_cur = rl.rlim_max;
136 else
137 rl.rlim_cur = 128;
138 setrlimit(RLIMIT_NOFILE, &rl);
140 openlog("rpcbind", LOG_CONS, LOG_DAEMON);
141 if (geteuid()) { /* This command allowed only to root */
142 fprintf(stderr, "Sorry. You are not superuser\n");
143 exit(1);
145 nc_handle = setnetconfig(); /* open netconfig file */
146 if (nc_handle == NULL) {
147 syslog(LOG_ERR, "could not read /etc/netconfig");
148 exit(1);
150 #ifdef PORTMAP
151 udptrans = "";
152 tcptrans = "";
153 #endif
155 nconf = getnetconfigent("local");
156 if (nconf == NULL)
157 nconf = getnetconfigent("unix");
158 if (nconf == NULL) {
159 syslog(LOG_ERR, "%s: can't find local transport\n", argv[0]);
160 exit(1);
163 rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec);
165 init_transport(nconf);
167 while ((nconf = getnetconfig(nc_handle))) {
168 if (nconf->nc_flag & NC_VISIBLE)
169 if (ipv6_only == 1 && strcmp(nconf->nc_protofmly,
170 "inet") == 0) {
171 /* DO NOTHING */
172 } else
173 init_transport(nconf);
175 endnetconfig(nc_handle);
177 /* catch the usual termination signals for graceful exit */
178 signal(SIGCHLD, reap);
179 signal(SIGINT, terminate);
180 signal(SIGTERM, terminate);
181 signal(SIGQUIT, terminate);
182 /* ignore others that could get sent */
183 signal(SIGPIPE, SIG_IGN);
184 signal(SIGHUP, SIG_IGN);
185 signal(SIGUSR1, SIG_IGN);
186 signal(SIGUSR2, SIG_IGN);
187 #ifdef WARMSTART
188 if (warmstart) {
189 read_warmstart();
191 #endif
192 if (debugging) {
193 printf("rpcbind debugging enabled.");
194 if (doabort) {
195 printf(" Will abort on errors!\n");
196 } else {
197 printf("\n");
199 } else {
200 if (daemon(0, 0))
201 err(1, "fork failed");
204 if (runasdaemon) {
205 struct passwd *p;
207 if((p = getpwnam(RUN_AS)) == NULL) {
208 syslog(LOG_ERR, "cannot get uid of daemon: %m");
209 exit(1);
211 if (setuid(p->pw_uid) == -1) {
212 syslog(LOG_ERR, "setuid to daemon failed: %m");
213 exit(1);
217 network_init();
219 my_svc_run();
220 syslog(LOG_ERR, "svc_run returned unexpectedly");
221 rpcbind_abort();
222 /* NOTREACHED */
224 return 0;
228 * Adds the entry into the rpcbind database.
229 * If PORTMAP, then for UDP and TCP, it adds the entries for version 2 also
230 * Returns 0 if succeeds, else fails
232 static int
233 init_transport(struct netconfig *nconf)
235 int fd;
236 struct t_bind taddr;
237 struct addrinfo hints, *res = NULL;
238 struct __rpc_sockinfo si;
239 SVCXPRT *my_xprt;
240 int status; /* bound checking ? */
241 int aicode;
242 int addrlen;
243 int nhostsbak;
244 int bound;
245 struct sockaddr *sa;
246 u_int32_t host_addr[4]; /* IPv4 or IPv6 */
247 struct sockaddr_un sun;
248 mode_t oldmask;
250 if ((nconf->nc_semantics != NC_TPI_CLTS) &&
251 (nconf->nc_semantics != NC_TPI_COTS) &&
252 (nconf->nc_semantics != NC_TPI_COTS_ORD))
253 return (1); /* not my type */
254 #ifdef ND_DEBUG
255 if (debugging) {
256 int i;
257 char **s;
259 fprintf(stderr, "%s: %ld lookup routines :\n",
260 nconf->nc_netid, nconf->nc_nlookups);
261 for (i = 0, s = nconf->nc_lookups; i < nconf->nc_nlookups;
262 i++, s++)
263 fprintf(stderr, "[%d] - %s\n", i, *s);
265 #endif
268 * XXX - using RPC library internal functions.
270 if ((strcmp(nconf->nc_netid, "local") == 0) ||
271 (strcmp(nconf->nc_netid, "unix") == 0)) {
273 * For other transports we call this later, for each socket we
274 * like to bind.
276 if ((fd = __rpc_nconf2fd(nconf)) < 0) {
277 int non_fatal = 0;
278 if (errno == EPROTONOSUPPORT)
279 non_fatal = 1;
280 syslog(non_fatal?LOG_DEBUG:LOG_ERR, "cannot create socket for %s",
281 nconf->nc_netid);
282 return (1);
286 if (!__rpc_nconf2sockinfo(nconf, &si)) {
287 syslog(LOG_ERR, "cannot get information for %s",
288 nconf->nc_netid);
289 return (1);
292 if ((strcmp(nconf->nc_netid, "local") == 0) ||
293 (strcmp(nconf->nc_netid, "unix") == 0)) {
294 memset(&sun, 0, sizeof sun);
295 sun.sun_family = AF_LOCAL;
296 unlink(_PATH_RPCBINDSOCK);
297 strcpy(sun.sun_path, _PATH_RPCBINDSOCK);
298 sun.sun_len = SUN_LEN(&sun);
299 addrlen = sizeof (struct sockaddr_un);
300 sa = (struct sockaddr *)&sun;
301 } else {
302 /* Get rpcbind's address on this transport */
304 memset(&hints, 0, sizeof hints);
305 hints.ai_flags = AI_PASSIVE;
306 hints.ai_family = si.si_af;
307 hints.ai_socktype = si.si_socktype;
308 hints.ai_protocol = si.si_proto;
311 if ((strcmp(nconf->nc_netid, "local") != 0) &&
312 (strcmp(nconf->nc_netid, "unix") != 0)) {
314 * If no hosts were specified, just bind to INADDR_ANY.
315 * Otherwise make sure 127.0.0.1 is added to the list.
317 nhostsbak = nhosts;
318 nhostsbak++;
319 hosts = realloc(hosts, nhostsbak * sizeof(char *));
320 if (nhostsbak == 1)
321 hosts[0] = "*";
322 else {
323 if (hints.ai_family == AF_INET) {
324 hosts[nhostsbak - 1] = "127.0.0.1";
325 } else if (hints.ai_family == AF_INET6) {
326 hosts[nhostsbak - 1] = "::1";
327 } else
328 return 1;
332 * Bind to specific IPs if asked to
334 bound = 0;
335 while (nhostsbak > 0) {
336 --nhostsbak;
338 * XXX - using RPC library internal functions.
340 if ((fd = __rpc_nconf2fd(nconf)) < 0) {
341 int non_fatal = 0;
342 if (errno == EPROTONOSUPPORT &&
343 nconf->nc_semantics != NC_TPI_CLTS)
344 non_fatal = 1;
345 syslog(non_fatal ? LOG_DEBUG : LOG_ERR,
346 "cannot create socket for %s", nconf->nc_netid);
347 return (1);
349 switch (hints.ai_family) {
350 case AF_INET:
351 if (inet_pton(AF_INET, hosts[nhostsbak],
352 host_addr) == 1) {
353 hints.ai_flags &= AI_NUMERICHOST;
354 } else {
356 * Skip if we have an AF_INET6 address.
358 if (inet_pton(AF_INET6,
359 hosts[nhostsbak], host_addr) == 1) {
360 close(fd);
361 continue;
364 break;
365 case AF_INET6:
366 if (inet_pton(AF_INET6, hosts[nhostsbak],
367 host_addr) == 1) {
368 hints.ai_flags &= AI_NUMERICHOST;
369 } else {
371 * Skip if we have an AF_INET address.
373 if (inet_pton(AF_INET, hosts[nhostsbak],
374 host_addr) == 1) {
375 close(fd);
376 continue;
379 if (setsockopt(fd, IPPROTO_IPV6,
380 IPV6_V6ONLY, &on, sizeof on) < 0) {
381 syslog(LOG_ERR,
382 "can't set v6-only binding for "
383 "ipv6 socket: %m");
384 continue;
386 break;
387 default:
388 break;
392 * If no hosts were specified, just bind to INADDR_ANY
394 if (strcmp("*", hosts[nhostsbak]) == 0)
395 hosts[nhostsbak] = NULL;
396 if ((strcmp(nconf->nc_netid, "local") != 0) &&
397 (strcmp(nconf->nc_netid, "unix") != 0)) {
398 if ((aicode = getaddrinfo(hosts[nhostsbak],
399 servname, &hints, &res)) != 0) {
400 syslog(LOG_ERR,
401 "cannot get local address for %s: %s",
402 nconf->nc_netid, gai_strerror(aicode));
403 continue;
405 addrlen = res->ai_addrlen;
406 sa = (struct sockaddr *)res->ai_addr;
408 oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
409 if (bind(fd, sa, addrlen) != 0) {
410 syslog(LOG_ERR, "cannot bind %s on %s: %m",
411 (hosts[nhostsbak] == NULL) ? "*" :
412 hosts[nhostsbak], nconf->nc_netid);
413 if (res != NULL)
414 freeaddrinfo(res);
415 continue;
416 } else
417 bound = 1;
418 umask(oldmask);
420 /* Copy the address */
421 taddr.addr.len = taddr.addr.maxlen = addrlen;
422 taddr.addr.buf = malloc(addrlen);
423 if (taddr.addr.buf == NULL) {
424 syslog(LOG_ERR,
425 "cannot allocate memory for %s address",
426 nconf->nc_netid);
427 if (res != NULL)
428 freeaddrinfo(res);
429 return 1;
431 memcpy(taddr.addr.buf, sa, addrlen);
432 #ifdef ND_DEBUG
433 if (debugging) {
435 * for debugging print out our universal
436 * address
438 char *uaddr;
439 struct netbuf nb;
441 nb.buf = sa;
442 nb.len = nb.maxlen = sa->sa_len;
443 uaddr = taddr2uaddr(nconf, &nb);
444 fprintf(stderr, "rpcbind : my address is %s\n", uaddr);
445 free(uaddr);
447 #endif
449 if (nconf->nc_semantics != NC_TPI_CLTS)
450 listen(fd, SOMAXCONN);
452 my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr,
453 RPC_MAXDATASIZE, RPC_MAXDATASIZE);
454 if (my_xprt == NULL) {
455 syslog(LOG_ERR, "%s: could not create service",
456 nconf->nc_netid);
457 goto error;
460 if (!bound)
461 return 1;
462 } else {
463 oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
464 if (bind(fd, sa, addrlen) < 0) {
465 syslog(LOG_ERR, "cannot bind %s: %m", nconf->nc_netid);
466 if (res != NULL)
467 freeaddrinfo(res);
468 return 1;
470 umask(oldmask);
472 /* Copy the address */
473 taddr.addr.len = taddr.addr.maxlen = addrlen;
474 taddr.addr.buf = malloc(addrlen);
475 if (taddr.addr.buf == NULL) {
476 syslog(LOG_ERR, "cannot allocate memory for %s address",
477 nconf->nc_netid);
478 if (res != NULL)
479 freeaddrinfo(res);
480 return 1;
482 memcpy(taddr.addr.buf, sa, addrlen);
483 #ifdef ND_DEBUG
484 if (debugging) {
485 /* for debugging print out our universal address */
486 char *uaddr;
487 struct netbuf nb;
489 nb.buf = sa;
490 nb.len = nb.maxlen = sa->sa_len;
491 uaddr = taddr2uaddr(nconf, &nb);
492 fprintf(stderr, "rpcbind : my address is %s\n", uaddr);
493 free(uaddr);
495 #endif
497 if (nconf->nc_semantics != NC_TPI_CLTS)
498 listen(fd, SOMAXCONN);
500 my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr,
501 RPC_MAXDATASIZE, RPC_MAXDATASIZE);
502 if (my_xprt == NULL) {
503 syslog(LOG_ERR, "%s: could not create service",
504 nconf->nc_netid);
505 goto error;
509 #ifdef PORTMAP
511 * Register both the versions for tcp/ip, udp/ip and local.
513 if ((strcmp(nconf->nc_protofmly, NC_INET) == 0 &&
514 (strcmp(nconf->nc_proto, NC_TCP) == 0 ||
515 strcmp(nconf->nc_proto, NC_UDP) == 0)) ||
516 (strcmp(nconf->nc_netid, "unix") == 0) ||
517 (strcmp(nconf->nc_netid, "local") == 0)) {
518 struct pmaplist *pml;
520 if (!svc_register(my_xprt, PMAPPROG, PMAPVERS,
521 pmap_service, 0)) {
522 syslog(LOG_ERR, "could not register on %s",
523 nconf->nc_netid);
524 goto error;
526 pml = malloc(sizeof (struct pmaplist));
527 if (pml == NULL) {
528 syslog(LOG_ERR, "no memory!");
529 exit(1);
531 pml->pml_map.pm_prog = PMAPPROG;
532 pml->pml_map.pm_vers = PMAPVERS;
533 pml->pml_map.pm_port = PMAPPORT;
534 if (strcmp(nconf->nc_proto, NC_TCP) == 0) {
535 if (tcptrans[0]) {
536 syslog(LOG_ERR,
537 "cannot have more than one TCP transport");
538 goto error;
540 tcptrans = strdup(nconf->nc_netid);
541 pml->pml_map.pm_prot = IPPROTO_TCP;
543 /* Let's snarf the universal address */
544 /* "h1.h2.h3.h4.p1.p2" */
545 tcp_uaddr = taddr2uaddr(nconf, &taddr.addr);
546 } else if (strcmp(nconf->nc_proto, NC_UDP) == 0) {
547 if (udptrans[0]) {
548 syslog(LOG_ERR,
549 "cannot have more than one UDP transport");
550 goto error;
552 udptrans = strdup(nconf->nc_netid);
553 pml->pml_map.pm_prot = IPPROTO_UDP;
555 /* Let's snarf the universal address */
556 /* "h1.h2.h3.h4.p1.p2" */
557 udp_uaddr = taddr2uaddr(nconf, &taddr.addr);
558 } else if (strcmp(nconf->nc_netid, "local") == 0)
559 pml->pml_map.pm_prot = IPPROTO_ST;
560 else if (strcmp(nconf->nc_netid, "unix") == 0)
561 pml->pml_map.pm_prot = IPPROTO_ST;
562 pml->pml_next = list_pml;
563 list_pml = pml;
565 /* Add version 3 information */
566 pml = malloc(sizeof (struct pmaplist));
567 if (pml == NULL) {
568 syslog(LOG_ERR, "no memory!");
569 exit(1);
571 pml->pml_map = list_pml->pml_map;
572 pml->pml_map.pm_vers = RPCBVERS;
573 pml->pml_next = list_pml;
574 list_pml = pml;
576 /* Add version 4 information */
577 pml = malloc (sizeof (struct pmaplist));
578 if (pml == NULL) {
579 syslog(LOG_ERR, "no memory!");
580 exit(1);
582 pml->pml_map = list_pml->pml_map;
583 pml->pml_map.pm_vers = RPCBVERS4;
584 pml->pml_next = list_pml;
585 list_pml = pml;
587 /* Also add version 2 stuff to rpcbind list */
588 rbllist_add(PMAPPROG, PMAPVERS, nconf, &taddr.addr);
590 #endif
592 /* version 3 registration */
593 if (!svc_reg(my_xprt, RPCBPROG, RPCBVERS, rpcb_service_3, NULL)) {
594 syslog(LOG_ERR, "could not register %s version 3",
595 nconf->nc_netid);
596 goto error;
598 rbllist_add(RPCBPROG, RPCBVERS, nconf, &taddr.addr);
600 /* version 4 registration */
601 if (!svc_reg(my_xprt, RPCBPROG, RPCBVERS4, rpcb_service_4, NULL)) {
602 syslog(LOG_ERR, "could not register %s version 4",
603 nconf->nc_netid);
604 goto error;
606 rbllist_add(RPCBPROG, RPCBVERS4, nconf, &taddr.addr);
608 /* decide if bound checking works for this transport */
609 status = add_bndlist(nconf, &taddr.addr);
610 #ifdef BIND_DEBUG
611 if (debugging) {
612 if (status < 0) {
613 fprintf(stderr, "Error in finding bind status for %s\n",
614 nconf->nc_netid);
615 } else if (status == 0) {
616 fprintf(stderr, "check binding for %s\n",
617 nconf->nc_netid);
618 } else if (status > 0) {
619 fprintf(stderr, "No check binding for %s\n",
620 nconf->nc_netid);
623 #endif
625 * rmtcall only supported on CLTS transports for now.
627 if (nconf->nc_semantics == NC_TPI_CLTS) {
628 status = create_rmtcall_fd(nconf);
630 #ifdef BIND_DEBUG
631 if (debugging) {
632 if (status < 0) {
633 fprintf(stderr,
634 "Could not create rmtcall fd for %s\n",
635 nconf->nc_netid);
636 } else {
637 fprintf(stderr, "rmtcall fd for %s is %d\n",
638 nconf->nc_netid, status);
641 #endif
643 return (0);
644 error:
645 close(fd);
646 return (1);
649 static void
650 rbllist_add(rpcprog_t prog, rpcvers_t vers, struct netconfig *nconf,
651 struct netbuf *addr)
653 rpcblist_ptr rbl;
655 rbl = malloc(sizeof (rpcblist));
656 if (rbl == NULL) {
657 syslog(LOG_ERR, "no memory!");
658 exit(1);
661 rbl->rpcb_map.r_prog = prog;
662 rbl->rpcb_map.r_vers = vers;
663 rbl->rpcb_map.r_netid = strdup(nconf->nc_netid);
664 rbl->rpcb_map.r_addr = taddr2uaddr(nconf, addr);
665 rbl->rpcb_map.r_owner = strdup(superuser);
666 rbl->rpcb_next = list_rbl; /* Attach to global list */
667 list_rbl = rbl;
671 * Catch the signal and die
673 static void
674 terminate(int dummy __unused)
676 close(rpcbindlockfd);
677 #ifdef WARMSTART
678 syslog(LOG_ERR,
679 "rpcbind terminating on signal. Restart with \"rpcbind -w\"");
680 write_warmstart(); /* Dump yourself */
681 #endif
682 exit(2);
685 void
686 rpcbind_abort(void)
688 #ifdef WARMSTART
689 write_warmstart(); /* Dump yourself */
690 #endif
691 abort();
694 /* get command line options */
695 static void
696 parseargs(int argc, char *argv[])
698 int c;
700 #ifdef WARMSTART
701 #define WSOP "w"
702 #else
703 #define WSOP ""
704 #endif
705 while ((c = getopt(argc, argv, "6adh:iLls" WSOP)) != -1) {
706 switch (c) {
707 case '6':
708 ipv6_only = 1;
709 break;
710 case 'a':
711 doabort = 1; /* when debugging, do an abort on */
712 break; /* errors; for rpcbind developers */
713 /* only! */
714 case 'd':
715 debugging = 1;
716 break;
717 case 'h':
718 ++nhosts;
719 hosts = realloc(hosts, nhosts * sizeof(char *));
720 if (hosts == NULL)
721 errx(1, "Out of memory");
722 hosts[nhosts - 1] = strdup(optarg);
723 if (hosts[nhosts - 1] == NULL)
724 errx(1, "Out of memory");
725 break;
726 case 'i':
727 insecure = 1;
728 break;
729 case 'L':
730 oldstyle_local = 1;
731 break;
732 case 'l':
733 verboselog = 1;
734 break;
735 case 's':
736 runasdaemon = 1;
737 break;
738 #ifdef WARMSTART
739 case 'w':
740 warmstart = 1;
741 break;
742 #endif
743 default: /* error */
744 fprintf(stderr,
745 "usage: rpcbind [-6adiLls%s] [-h bindip]\n",
746 WSOP);
747 exit (1);
750 if (doabort && !debugging) {
751 fprintf(stderr,
752 "-a (abort) specified without -d (debugging) -- ignored.\n");
753 doabort = 0;
755 #undef WSOP
758 void
759 reap(int dummy __unused)
761 int save_errno = errno;
763 while (wait3(NULL, WNOHANG, NULL) > 0)
765 errno = save_errno;
768 void
769 toggle_verboselog(int dummy __unused)
771 verboselog = !verboselog;