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