Index: stable/2.2/usr.sbin/portmap/portmap.c =================================================================== --- stable/2.2/usr.sbin/portmap/portmap.c (revision 36642) +++ stable/2.2/usr.sbin/portmap/portmap.c (revision 36643) @@ -1,608 +1,612 @@ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * 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. */ #ifndef lint static const char copyright[] = "@(#) Copyright (c) 1990, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)portmap.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id: portmap.c,v 1.4.2.2 1997/10/10 06:16:58 charnier Exp $"; + "$Id: portmap.c,v 1.4.2.3 1998/03/09 13:51:55 jkh Exp $"; #endif /* not lint */ /* @(#)portmap.c 2.3 88/08/11 4.0 RPCSRC static char sccsid[] = "@(#)portmap.c 1.32 87/08/06 Copyr 1984 Sun Micro"; */ /* * portmap.c, Implements the program,version to port number mapping for * rpc. */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "pmap_check.h" void reg_service(); void reap(); static void callit(); static void usage __P((void)); struct pmaplist *pmaplist; int debugging = 0; int main(argc, argv) int argc; char **argv; { SVCXPRT *xprt; int sock, c; struct sockaddr_in addr; int len = sizeof(struct sockaddr_in); register struct pmaplist *pml; while ((c = getopt(argc, argv, "dv")) != -1) { switch (c) { case 'd': debugging = 1; break; case 'v': verboselog = 1; break; default: usage(); } } if (!debugging && daemon(0, 0)) err(1, "fork"); openlog("portmap", debugging ? LOG_PID | LOG_PERROR : LOG_PID, LOG_DAEMON); if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { syslog(LOG_ERR, "cannot create udp socket: %m"); exit(1); } addr.sin_addr.s_addr = 0; addr.sin_family = AF_INET; addr.sin_port = htons(PMAPPORT); if (bind(sock, (struct sockaddr *)&addr, len) != 0) { syslog(LOG_ERR, "cannot bind udp: %m"); exit(1); } if ((xprt = svcudp_create(sock)) == (SVCXPRT *)NULL) { syslog(LOG_ERR, "couldn't do udp_create"); exit(1); } /* make an entry for ourself */ pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist)); pml->pml_next = 0; pml->pml_map.pm_prog = PMAPPROG; pml->pml_map.pm_vers = PMAPVERS; pml->pml_map.pm_prot = IPPROTO_UDP; pml->pml_map.pm_port = PMAPPORT; pmaplist = pml; if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { syslog(LOG_ERR, "cannot create tcp socket: %m"); exit(1); } if (bind(sock, (struct sockaddr *)&addr, len) != 0) { syslog(LOG_ERR, "cannot bind tcp: %m"); exit(1); } if ((xprt = svctcp_create(sock, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE)) == (SVCXPRT *)NULL) { syslog(LOG_ERR, "couldn't do tcp_create"); exit(1); } /* make an entry for ourself */ pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist)); pml->pml_map.pm_prog = PMAPPROG; pml->pml_map.pm_vers = PMAPVERS; pml->pml_map.pm_prot = IPPROTO_TCP; pml->pml_map.pm_port = PMAPPORT; pml->pml_next = pmaplist; pmaplist = pml; (void)svc_register(xprt, PMAPPROG, PMAPVERS, reg_service, FALSE); /* additional initializations */ check_startup(); (void)signal(SIGCHLD, reap); svc_run(); syslog(LOG_ERR, "svc_run returned unexpectedly"); abort(); } static void usage() { fprintf(stderr, "usage: portmap [-dv]\n"); exit(1); } #ifndef lint /* need to override perror calls in rpc library */ void perror(what) const char *what; { syslog(LOG_ERR, "%s: %m", what); } #endif static struct pmaplist * find_service(prog, vers, prot) u_long prog, vers, prot; { register struct pmaplist *hit = NULL; register struct pmaplist *pml; for (pml = pmaplist; pml != NULL; pml = pml->pml_next) { if ((pml->pml_map.pm_prog != prog) || (pml->pml_map.pm_prot != prot)) continue; hit = pml; if (pml->pml_map.pm_vers == vers) break; } return (hit); } /* * 1 OK, 0 not */ void reg_service(rqstp, xprt) struct svc_req *rqstp; SVCXPRT *xprt; { struct pmap reg; struct pmaplist *pml, *prevpml, *fnd; int ans, port; caddr_t t; /* * Later wrappers change the logging severity on the fly. Reset to * defaults before handling the next request. */ allow_severity = LOG_INFO; deny_severity = LOG_WARNING; if (debugging) (void) fprintf(stderr, "server: about to do a switch\n"); switch (rqstp->rq_proc) { case PMAPPROC_NULL: /* * Null proc call */ /* remote host authorization check */ check_default(svc_getcaller(xprt), rqstp->rq_proc, (u_long) 0); if (!svc_sendreply(xprt, xdr_void, (caddr_t)0) && debugging) { abort(); } break; case PMAPPROC_SET: /* * Set a program,version to port mapping */ if (!svc_getargs(xprt, xdr_pmap, (caddr_t)®)) svcerr_decode(xprt); else { /* reject non-local requests, protect priv. ports */ if (!check_setunset(svc_getcaller(xprt), rqstp->rq_proc, reg.pm_prog, reg.pm_port)) { ans = 0; goto done; } /* * check to see if already used * find_service returns a hit even if * the versions don't match, so check for it */ fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot); if (fnd && fnd->pml_map.pm_vers == reg.pm_vers) { if (fnd->pml_map.pm_port == reg.pm_port) { ans = 1; goto done; } else { ans = 0; goto done; } } else { /* * add to END of list */ pml = (struct pmaplist *) malloc((u_int)sizeof(struct pmaplist)); pml->pml_map = reg; pml->pml_next = 0; if (pmaplist == 0) { pmaplist = pml; } else { for (fnd= pmaplist; fnd->pml_next != 0; fnd = fnd->pml_next); fnd->pml_next = pml; } ans = 1; } done: if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&ans)) && debugging) { (void) fprintf(stderr, "svc_sendreply\n"); abort(); } } break; case PMAPPROC_UNSET: /* * Remove a program,version to port mapping. */ if (!svc_getargs(xprt, xdr_pmap, (caddr_t)®)) svcerr_decode(xprt); else { ans = 0; /* reject non-local requests */ if (!check_setunset(svc_getcaller(xprt), rqstp->rq_proc, reg.pm_prog, (u_long) 0)) goto done; for (prevpml = NULL, pml = pmaplist; pml != NULL; ) { if ((pml->pml_map.pm_prog != reg.pm_prog) || (pml->pml_map.pm_vers != reg.pm_vers)) { /* both pml & prevpml move forwards */ prevpml = pml; pml = pml->pml_next; continue; } /* found it; pml moves forward, prevpml stays */ /* privileged port check */ if (!check_privileged_port(svc_getcaller(xprt), rqstp->rq_proc, reg.pm_prog, pml->pml_map.pm_port)) { ans = 0; break; } ans = 1; t = (caddr_t)pml; pml = pml->pml_next; if (prevpml == NULL) pmaplist = pml; else prevpml->pml_next = pml; free(t); } if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&ans)) && debugging) { (void) fprintf(stderr, "svc_sendreply\n"); abort(); } } break; case PMAPPROC_GETPORT: /* * Lookup the mapping for a program,version and return its port */ if (!svc_getargs(xprt, xdr_pmap, (caddr_t)®)) svcerr_decode(xprt); else { /* remote host authorization check */ if (!check_default(svc_getcaller(xprt), rqstp->rq_proc, reg.pm_prog)) { ans = 0; goto done; } fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot); if (fnd) port = fnd->pml_map.pm_port; else port = 0; if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&port)) && debugging) { (void) fprintf(stderr, "svc_sendreply\n"); abort(); } } break; case PMAPPROC_DUMP: /* * Return the current set of mapped program,version */ if (!svc_getargs(xprt, xdr_void, NULL)) svcerr_decode(xprt); else { /* remote host authorization check */ struct pmaplist *p; if (!check_default(svc_getcaller(xprt), rqstp->rq_proc, (u_long) 0)) { p = 0; /* send empty list */ } else { p = pmaplist; } if ((!svc_sendreply(xprt, xdr_pmaplist, (caddr_t)&p)) && debugging) { (void) fprintf(stderr, "svc_sendreply\n"); abort(); } } break; case PMAPPROC_CALLIT: /* * Calls a procedure on the local machine. If the requested * procedure is not registered this procedure does not return * error information!! * This procedure is only supported on rpc/udp and calls via * rpc/udp. It passes null authentication parameters. */ callit(rqstp, xprt); break; default: /* remote host authorization check */ check_default(svc_getcaller(xprt), rqstp->rq_proc, (u_long) 0); svcerr_noproc(xprt); break; } } /* * Stuff for the rmtcall service */ #define ARGSIZE 9000 struct encap_parms { u_int arglen; char *args; }; static bool_t xdr_encap_parms(xdrs, epp) XDR *xdrs; struct encap_parms *epp; { return (xdr_bytes(xdrs, &(epp->args), &(epp->arglen), ARGSIZE)); } struct rmtcallargs { u_long rmt_prog; u_long rmt_vers; u_long rmt_port; u_long rmt_proc; struct encap_parms rmt_args; }; static bool_t xdr_rmtcall_args(xdrs, cap) register XDR *xdrs; register struct rmtcallargs *cap; { /* does not get a port number */ if (xdr_u_long(xdrs, &(cap->rmt_prog)) && xdr_u_long(xdrs, &(cap->rmt_vers)) && xdr_u_long(xdrs, &(cap->rmt_proc))) { return (xdr_encap_parms(xdrs, &(cap->rmt_args))); } return (FALSE); } static bool_t xdr_rmtcall_result(xdrs, cap) register XDR *xdrs; register struct rmtcallargs *cap; { if (xdr_u_long(xdrs, &(cap->rmt_port))) return (xdr_encap_parms(xdrs, &(cap->rmt_args))); return (FALSE); } /* * only worries about the struct encap_parms part of struct rmtcallargs. * The arglen must already be set!! */ static bool_t xdr_opaque_parms(xdrs, cap) XDR *xdrs; struct rmtcallargs *cap; { return (xdr_opaque(xdrs, cap->rmt_args.args, cap->rmt_args.arglen)); } /* * This routine finds and sets the length of incoming opaque paraters * and then calls xdr_opaque_parms. */ static bool_t xdr_len_opaque_parms(xdrs, cap) register XDR *xdrs; struct rmtcallargs *cap; { register u_int beginpos, lowpos, highpos, currpos, pos; beginpos = lowpos = pos = xdr_getpos(xdrs); highpos = lowpos + ARGSIZE; while ((int)(highpos - lowpos) >= 0) { currpos = (lowpos + highpos) / 2; if (xdr_setpos(xdrs, currpos)) { pos = currpos; lowpos = currpos + 1; } else { highpos = currpos - 1; } } xdr_setpos(xdrs, beginpos); cap->rmt_args.arglen = pos - beginpos; return (xdr_opaque_parms(xdrs, cap)); } /* * Call a remote procedure service * This procedure is very quiet when things go wrong. * The proc is written to support broadcast rpc. In the broadcast case, * a machine should shut-up instead of complain, less the requestor be * overrun with complaints at the expense of not hearing a valid reply ... * * This now forks so that the program & process that it calls can call * back to the portmapper. */ static void callit(rqstp, xprt) struct svc_req *rqstp; SVCXPRT *xprt; { struct rmtcallargs a; struct pmaplist *pml; u_short port; struct sockaddr_in me; int pid, so = -1; CLIENT *client; struct authunix_parms *au = (struct authunix_parms *)rqstp->rq_clntcred; struct timeval timeout; char buf[ARGSIZE]; timeout.tv_sec = 5; timeout.tv_usec = 0; a.rmt_args.args = buf; if (!svc_getargs(xprt, xdr_rmtcall_args, (caddr_t)&a)) return; /* host and service access control */ if (!check_callit(svc_getcaller(xprt), rqstp->rq_proc, a.rmt_prog, a.rmt_proc)) return; if ((pml = find_service(a.rmt_prog, a.rmt_vers, (u_long)IPPROTO_UDP)) == NULL) return; /* * fork a child to do the work. Parent immediately returns. * Child exits upon completion. */ if ((pid = fork()) != 0) { if (pid < 0) syslog(LOG_ERR, "CALLIT (prog %lu): fork: %m", a.rmt_prog); return; } port = pml->pml_map.pm_port; get_myaddress(&me); me.sin_port = htons(port); client = clntudp_create(&me, a.rmt_prog, a.rmt_vers, timeout, &so); if (client != (CLIENT *)NULL) { if (rqstp->rq_cred.oa_flavor == AUTH_UNIX) { client->cl_auth = authunix_create(au->aup_machname, au->aup_uid, au->aup_gid, au->aup_len, au->aup_gids); } a.rmt_port = (u_long)port; if (clnt_call(client, a.rmt_proc, xdr_opaque_parms, &a, xdr_len_opaque_parms, &a, timeout) == RPC_SUCCESS) { svc_sendreply(xprt, xdr_rmtcall_result, (caddr_t)&a); } AUTH_DESTROY(client->cl_auth); clnt_destroy(client); } (void)close(so); exit(0); } void reap() { + int save_errno; + + save_errno = errno; while (wait3((int *)NULL, WNOHANG, (struct rusage *)NULL) > 0); + errno = save_errno; } Index: stable/2.2/usr.sbin/rpc.yppasswdd/yppasswdd_server.c =================================================================== --- stable/2.2/usr.sbin/rpc.yppasswdd/yppasswdd_server.c (revision 36642) +++ stable/2.2/usr.sbin/rpc.yppasswdd/yppasswdd_server.c (revision 36643) @@ -1,845 +1,850 @@ /* * Copyright (c) 1995, 1996 * Bill Paul . All rights reserved. * * 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 Bill Paul. * 4. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul 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. */ #ifndef lint static const char rcsid[] = - "$Id$"; + "$Id: yppasswdd_server.c,v 1.9.2.2 1997/11/05 07:37:01 charnier Exp $"; #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include struct dom_binding {}; #include #include "yppasswdd_extern.h" #include "yppasswd.h" #include "yppasswd_private.h" #include "yppasswd_comm.h" char *tempname; void reaper(sig) int sig; { extern pid_t pid; extern int pstat; int st; + int saved_errno; + saved_errno = errno; + if (sig > 0) { if (sig == SIGCHLD) while(wait3(&st, WNOHANG, NULL) > 0) ; } else { pid = waitpid(pid, &pstat, 0); } + + errno = saved_errno; return; } void install_reaper(on) int on; { if (on) { signal(SIGCHLD, reaper); } else { signal(SIGCHLD, SIG_DFL); } return; } static struct passwd yp_password; static void copy_yp_pass(p, x, m) char *p; int x, m; { register char *t, *s = p; static char *buf; yp_password.pw_fields = 0; buf = (char *)realloc(buf, m + 10); bzero(buf, m + 10); /* Turn all colons into NULLs */ while (strchr(s, ':')) { s = (strchr(s, ':') + 1); *(s - 1)= '\0'; } t = buf; #define EXPAND(e) e = t; while ((*t++ = *p++)); EXPAND(yp_password.pw_name); yp_password.pw_fields |= _PWF_NAME; EXPAND(yp_password.pw_passwd); yp_password.pw_fields |= _PWF_PASSWD; yp_password.pw_uid = atoi(p); p += (strlen(p) + 1); yp_password.pw_fields |= _PWF_UID; yp_password.pw_gid = atoi(p); p += (strlen(p) + 1); yp_password.pw_fields |= _PWF_GID; if (x) { EXPAND(yp_password.pw_class); yp_password.pw_fields |= _PWF_CLASS; yp_password.pw_change = atol(p); p += (strlen(p) + 1); yp_password.pw_fields |= _PWF_CHANGE; yp_password.pw_expire = atol(p); p += (strlen(p) + 1); yp_password.pw_fields |= _PWF_EXPIRE; } EXPAND(yp_password.pw_gecos); yp_password.pw_fields |= _PWF_GECOS; EXPAND(yp_password.pw_dir); yp_password.pw_fields |= _PWF_DIR; EXPAND(yp_password.pw_shell); yp_password.pw_fields |= _PWF_SHELL; return; } static int validchars(arg) char *arg; { int i; for (i = 0; i < strlen(arg); i++) { if (iscntrl(arg[i])) { yp_error("string contains a control character"); return(1); } if (arg[i] == ':') { yp_error("string contains a colon"); return(1); } /* Be evil: truncate strings with \n in them silently. */ if (arg[i] == '\n') { arg[i] = '\0'; return(0); } } return(0); } static int validate_master(opw, npw) struct passwd *opw; struct x_master_passwd *npw; { if (npw->pw_name[0] == '+' || npw->pw_name[0] == '-') { yp_error("client tried to modify an NIS entry"); return(1); } if (validchars(npw->pw_shell)) { yp_error("specified shell contains invalid characters"); return(1); } if (validchars(npw->pw_gecos)) { yp_error("specified gecos field contains invalid characters"); return(1); } if (validchars(npw->pw_passwd)) { yp_error("specified password contains invalid characters"); return(1); } return(0); } static int validate(opw, npw) struct passwd *opw; struct x_passwd *npw; { if (npw->pw_name[0] == '+' || npw->pw_name[0] == '-') { yp_error("client tried to modify an NIS entry"); return(1); } if (npw->pw_uid != opw->pw_uid) { yp_error("UID mismatch: client says user %s has UID %d", npw->pw_name, npw->pw_uid); yp_error("database says user %s has UID %d", opw->pw_name, opw->pw_uid); return(1); } if (npw->pw_gid != opw->pw_gid) { yp_error("GID mismatch: client says user %s has GID %d", npw->pw_name, npw->pw_gid); yp_error("database says user %s has GID %d", opw->pw_name, opw->pw_gid); return(1); } /* * Don't allow the user to shoot himself in the foot, * even on purpose. */ if (!ok_shell(npw->pw_shell)) { yp_error("%s is not a valid shell", npw->pw_shell); return(1); } if (validchars(npw->pw_shell)) { yp_error("specified shell contains invalid characters"); return(1); } if (validchars(npw->pw_gecos)) { yp_error("specified gecos field contains invalid characters"); return(1); } if (validchars(npw->pw_passwd)) { yp_error("specified password contains invalid characters"); return(1); } return(0); } /* * Kludge alert: * In order to have one rpc.yppasswdd support multiple domains, * we have to cheat: we search each directory under /var/yp * and try to match the user in each master.passwd.byname * map that we find. If the user matches (username, uid and gid * all agree), then we use that domain. If we match the user in * more than one database, we must abort. */ static char *find_domain(pw) struct x_passwd *pw; { struct stat statbuf; struct dirent *dirp; DIR *dird; char yp_mapdir[MAXPATHLEN + 2]; static char domain[YPMAXDOMAIN]; char *tmp = NULL; DBT key, data; int hit = 0; yp_error("performing multidomain lookup"); if ((dird = opendir(yp_dir)) == NULL) { yp_error("opendir(%s) failed: %s", yp_dir, strerror(errno)); return(NULL); } while ((dirp = readdir(dird)) != NULL) { snprintf(yp_mapdir, sizeof(yp_mapdir), "%s/%s", yp_dir, dirp->d_name); if (stat(yp_mapdir, &statbuf) < 0) { yp_error("stat(%s) failed: %s", yp_mapdir, strerror(errno)); closedir(dird); return(NULL); } if (S_ISDIR(statbuf.st_mode)) { tmp = (char *)dirp->d_name; key.data = pw->pw_name; key.size = strlen(pw->pw_name); if (yp_get_record(tmp,"master.passwd.byname", &key, &data, 0) != YP_TRUE) { continue; } *(char *)(data.data + data.size) = '\0'; copy_yp_pass(data.data, 1, data.size); if (yp_password.pw_uid == pw->pw_uid && yp_password.pw_gid == pw->pw_gid) { hit++; snprintf(domain, YPMAXDOMAIN, "%s", tmp); } } } closedir(dird); if (hit > 1) { yp_error("found same user in two different domains"); return(NULL); } else return((char *)&domain); } static int update_inplace(pw, domain) struct passwd *pw; char *domain; { DB *dbp = NULL; DBT key = { NULL, 0 }; DBT data = { NULL, 0 }; char pwbuf[YPMAXRECORD]; char keybuf[20]; int i; char *maps[] = { "master.passwd.byname", "master.passwd.byuid", "passwd.byname", "passwd.byuid" }; char *formats[] = { "%s:%s:%d:%d:%s:%ld:%ld:%s:%s:%s", "%s:%s:%d:%d:%s:%ld:%ld:%s:%s:%s", "%s:%s:%d:%d:%s:%s:%s", "%s:%s:%d:%d:%s:%s:%s" }; char *ptr = NULL; char *yp_last = "YP_LAST_MODIFIED"; char yplastbuf[YPMAXRECORD]; snprintf(yplastbuf, sizeof(yplastbuf), "%lu", time(NULL)); for (i = 0; i < 4; i++) { if (i % 2) { snprintf(keybuf, sizeof(keybuf), "%ld", pw->pw_uid); key.data = (char *)&keybuf; key.size = strlen(keybuf); } else { key.data = pw->pw_name; key.size = strlen(pw->pw_name); } /* * XXX The passwd.byname and passwd.byuid maps come in * two flavors: secure and insecure. The secure version * has a '*' in the password field whereas the insecure one * has a real crypted password. The maps will be insecure * if they were built with 'unsecure = TRUE' enabled in * /var/yp/Makefile, but we'd have no way of knowing if * this has been done unless we were to try parsing the * Makefile, which is a disgusting thought. Instead, we * read the records from the maps, skip to the first ':' * in them, and then look at the character immediately * following it. If it's an '*' then the map is 'secure' * and we must not insert a real password into the pw_passwd * field. If it's not an '*', then we put the real crypted * password in. */ if (yp_get_record(domain,maps[i],&key,&data,1) != YP_TRUE) { yp_error("couldn't read %s/%s: %s", domain, maps[i], strerror(errno)); return(1); } if ((ptr = strchr(data.data, ':')) == NULL) { yp_error("no colon in passwd record?!"); return(1); } /* * XXX Supposing we have more than one user with the same * UID? (Or more than one user with the same name?) We could * end up modifying the wrong record if were not careful. */ if (i % 2) { if (strncmp(data.data, pw->pw_name, strlen(pw->pw_name))) { yp_error("warning: found entry for UID %d \ in map %s@%s with wrong name (%.*s)", pw->pw_uid, maps[i], domain, ptr - (char *)data.data, data.data); yp_error("there may be more than one user \ with the same UID - continuing"); continue; } } else { /* * We're really being ultra-paranoid here. * This is generally a 'can't happen' condition. */ snprintf(pwbuf, sizeof(pwbuf), ":%d:%d:", pw->pw_uid, pw->pw_gid); if (!strstr(data.data, pwbuf)) { yp_error("warning: found entry for user %s \ in map %s@%s with wrong UID", pw->pw_name, maps[i], domain); yp_error("there may ne more than one user with the same name - continuing"); continue; } } if (i < 2) { snprintf(pwbuf, sizeof(pwbuf), formats[i], pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid, pw->pw_class, pw->pw_change, pw->pw_expire, pw->pw_gecos, pw->pw_dir, pw->pw_shell); } else { snprintf(pwbuf, sizeof(pwbuf), formats[i], pw->pw_name, *(ptr+1) == '*' ? "*" : pw->pw_passwd, pw->pw_uid, pw->pw_gid, pw->pw_gecos, pw->pw_dir, pw->pw_shell); } #define FLAGS O_RDWR|O_CREAT if ((dbp = yp_open_db_rw(domain, maps[i], FLAGS)) == NULL) { yp_error("couldn't open %s/%s r/w: %s",domain, maps[i],strerror(errno)); return(1); } data.data = pwbuf; data.size = strlen(pwbuf); if (yp_put_record(dbp, &key, &data, 1) != YP_TRUE) { yp_error("failed to update record in %s/%s", domain, maps[i]); (void)(dbp->close)(dbp); return(1); } key.data = yp_last; key.size = strlen(yp_last); data.data = (char *)&yplastbuf; data.size = strlen(yplastbuf); if (yp_put_record(dbp, &key, &data, 1) != YP_TRUE) { yp_error("failed to update timestamp in %s/%s", domain, maps[i]); (void)(dbp->close)(dbp); return(1); } (void)(dbp->close)(dbp); } return(0); } static char *yp_mktmpnam() { static char path[MAXPATHLEN]; char *p; sprintf(path,"%s",passfile); if ((p = strrchr(path, '/'))) ++p; else p = path; strcpy(p, "yppwtmp.XXXXXX"); return(mktemp(path)); } int * yppasswdproc_update_1_svc(yppasswd *argp, struct svc_req *rqstp) { static int result; struct sockaddr_in *rqhost; DBT key, data; int rval = 0; int pfd, tfd; int pid; int passwd_changed = 0; int shell_changed = 0; int gecos_changed = 0; char *oldshell = NULL; char *oldgecos = NULL; char *passfile_hold; char passfile_buf[MAXPATHLEN + 2]; char *domain = yppasswd_domain; static struct sockaddr_in clntaddr; static struct timeval t_saved, t_test; /* * Normal user updates always use the 'default' master.passwd file. */ passfile = passfile_default; result = 1; rqhost = svc_getcaller(rqstp->rq_xprt); gettimeofday(&t_test, NULL); if (!bcmp((char *)rqhost, (char *)&clntaddr, sizeof(struct sockaddr_in)) && t_test.tv_sec > t_saved.tv_sec && t_test.tv_sec - t_saved.tv_sec < 300) { bzero((char *)&clntaddr, sizeof(struct sockaddr_in)); bzero((char *)&t_saved, sizeof(struct timeval)); return(NULL); } bcopy((char *)rqhost, (char *)&clntaddr, sizeof(struct sockaddr_in)); gettimeofday(&t_saved, NULL); if (yp_access(resvport ? "master.passwd.byname" : NULL, rqstp)) { yp_error("rejected update request from unauthorized host"); svcerr_auth(rqstp->rq_xprt, AUTH_BADCRED); return(&result); } /* * Step one: find the user. (It's kinda pointless to * proceed if the user doesn't exist.) We look for the * user in the master.passwd.byname database, _NOT_ by * using getpwent() and friends! We can't use getpwent() * since the NIS master server is not guaranteed to be * configured as an NIS client. */ if (multidomain) { if ((domain = find_domain(&argp->newpw)) == NULL) { yp_error("multidomain lookup failed - aborting update"); return(&result); } else yp_error("updating user %s in domain %s", argp->newpw.pw_name, domain); } key.data = argp->newpw.pw_name; key.size = strlen(argp->newpw.pw_name); if ((rval=yp_get_record(domain,"master.passwd.byname", &key, &data, 0)) != YP_TRUE) { if (rval == YP_NOKEY) { yp_error("user %s not found in passwd database", argp->newpw.pw_name); } else { yp_error("database access error: %s", yperr_string(rval)); } return(&result); } /* Nul terminate, please. */ *(char *)(data.data + data.size) = '\0'; copy_yp_pass(data.data, 1, data.size); /* Step 2: check that the supplied oldpass is valid. */ if (strcmp(crypt(argp->oldpass, yp_password.pw_passwd), yp_password.pw_passwd)) { yp_error("rejected change attempt -- bad password"); yp_error("client address: %s username: %s", inet_ntoa(rqhost->sin_addr), argp->newpw.pw_name); return(&result); } /* Step 3: validate the arguments passed to us by the client. */ if (validate(&yp_password, &argp->newpw)) { yp_error("rejecting change attempt: bad arguments"); yp_error("client address: %s username: %s", inet_ntoa(rqhost->sin_addr), argp->newpw.pw_name); svcerr_decode(rqstp->rq_xprt); return(&result); } /* Step 4: update the user's passwd structure. */ if (!no_chsh && strcmp(argp->newpw.pw_shell, yp_password.pw_shell)) { oldshell = yp_password.pw_shell; yp_password.pw_shell = argp->newpw.pw_shell; shell_changed++; } if (!no_chfn && strcmp(argp->newpw.pw_gecos, yp_password.pw_gecos)) { oldgecos = yp_password.pw_gecos; yp_password.pw_gecos = argp->newpw.pw_gecos; gecos_changed++; } if (strcmp(argp->newpw.pw_passwd, yp_password.pw_passwd)) { yp_password.pw_passwd = argp->newpw.pw_passwd; yp_password.pw_change = 0; passwd_changed++; } /* * If the caller specified a domain other than our 'default' * domain, change the path to master.passwd accordingly. */ if (strcmp(domain, yppasswd_domain)) { snprintf(passfile_buf, sizeof(passfile_buf), "%s/%s/master.passwd", yp_dir, domain); passfile = (char *)&passfile_buf; } /* Step 5: make a new password file with the updated info. */ if ((pfd = pw_lock()) < 0) { return (&result); } if ((tfd = pw_tmp()) < 0) { return (&result); } if (pw_copy(pfd, tfd, &yp_password)) { yp_error("failed to created updated password file -- \ cleaning up and bailing out"); unlink(tempname); return(&result); } passfile_hold = yp_mktmpnam(); rename(passfile, passfile_hold); if (strcmp(passfile, _PATH_MASTERPASSWD)) { rename(tempname, passfile); } else { if (pw_mkdb(argp->newpw.pw_name) < 0) { yp_error("pwd_mkdb failed"); return(&result); } } if (inplace) { if ((rval = update_inplace(&yp_password, domain))) { yp_error("inplace update failed -- rebuilding maps"); } } switch((pid = fork())) { case 0: if (inplace && !rval) { execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile, yppasswd_domain, "pushpw", NULL); } else { execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile, yppasswd_domain, NULL); } yp_error("couldn't exec map update process: %s", strerror(errno)); unlink(passfile); rename(passfile_hold, passfile); exit(1); break; case -1: yp_error("fork() failed: %s", strerror(errno)); unlink(passfile); rename(passfile_hold, passfile); return(&result); break; default: unlink(passfile_hold); break; } if (verbose) { yp_error("update completed for user %s (uid %d):", argp->newpw.pw_name, argp->newpw.pw_uid); if (passwd_changed) yp_error("password changed"); if (gecos_changed) yp_error("gecos changed ('%s' -> '%s')", oldgecos, argp->newpw.pw_gecos); if (shell_changed) yp_error("shell changed ('%s' -> '%s')", oldshell, argp->newpw.pw_shell); } result = 0; return (&result); } /* * Note that this function performs a little less sanity checking * than the last one. Since only the superuser is allowed to use it, * it is assumed that the caller knows what he's doing. */ static int update_master(master_yppasswd *argp) { int result; int pfd, tfd; int pid; int rval = 0; DBT key, data; char *passfile_hold; char passfile_buf[MAXPATHLEN + 2]; result = 1; passfile = passfile_default; key.data = argp->newpw.pw_name; key.size = strlen(argp->newpw.pw_name); /* * The superuser may add entries to the passwd maps if * rpc.yppasswdd is started with the -a flag. Paranoia * prevents me from allowing additions by default. */ if ((rval = yp_get_record(argp->domain, "master.passwd.byname", &key, &data, 0)) != YP_TRUE) { if (rval == YP_NOKEY) { yp_error("user %s not found in passwd database", argp->newpw.pw_name); if (allow_additions) yp_error("notice: adding user %s to \ master.passwd database for domain %s", argp->newpw.pw_name, argp->domain); else yp_error("restart rpc.yppasswdd with the -a flag to \ allow additions to be made to the password database"); } else { yp_error("database access error: %s", yperr_string(rval)); } if (!allow_additions) return(result); } else { /* Nul terminate, please. */ *(char *)(data.data + data.size) = '\0'; copy_yp_pass(data.data, 1, data.size); } /* * Perform a small bit of sanity checking. */ if (validate_master(rval == YP_TRUE ? &yp_password:NULL,&argp->newpw)){ yp_error("rejecting update attempt for %s: bad arguments", argp->newpw.pw_name); return(result); } /* * If the caller specified a domain other than our 'default' * domain, change the path to master.passwd accordingly. */ if (strcmp(argp->domain, yppasswd_domain)) { snprintf(passfile_buf, sizeof(passfile_buf), "%s/%s/master.passwd", yp_dir, argp->domain); passfile = (char *)&passfile_buf; } if ((pfd = pw_lock()) < 0) { return (result); } if ((tfd = pw_tmp()) < 0) { return (result); } if (pw_copy(pfd, tfd, (struct passwd *)&argp->newpw)) { yp_error("failed to created updated password file -- \ cleaning up and bailing out"); unlink(tempname); return(result); } passfile_hold = yp_mktmpnam(); rename(passfile, passfile_hold); if (strcmp(passfile, _PATH_MASTERPASSWD)) { rename(tempname, passfile); } else { if (pw_mkdb(argp->newpw.pw_name) < 0) { yp_error("pwd_mkdb failed"); return(result); } } if (inplace) { if ((rval = update_inplace((struct passwd *)&argp->newpw, argp->domain))) { yp_error("inplace update failed -- rebuilding maps"); } } switch((pid = fork())) { case 0: close(yp_sock); if (inplace && !rval) { execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile, argp->domain, "pushpw", NULL); } else { execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile, argp->domain, NULL); } yp_error("couldn't exec map update process: %s", strerror(errno)); unlink(passfile); rename(passfile_hold, passfile); exit(1); break; case -1: yp_error("fork() failed: %s", strerror(errno)); unlink(passfile); rename(passfile_hold, passfile); return(result); break; default: unlink(passfile_hold); break; } yp_error("performed update of user %s (uid %d) domain %s", argp->newpw.pw_name, argp->newpw.pw_uid, argp->domain); result = 0; return(result); } /* * Pseudo-dispatcher for private 'superuser-only' update handler. */ void do_master() { struct master_yppasswd *pw; if ((pw = getdat(yp_sock)) == NULL) { return; } yp_error("received update request from superuser on localhost"); sendresp(update_master(pw)); /* Remember to free args. */ xdr_free(xdr_master_yppasswd, (char *)pw); return; } Index: stable/2.2/usr.sbin/ypserv/yp_main.c =================================================================== --- stable/2.2/usr.sbin/ypserv/yp_main.c (revision 36642) +++ stable/2.2/usr.sbin/ypserv/yp_main.c (revision 36643) @@ -1,330 +1,337 @@ /* * Copyright (c) 1995 * Bill Paul . All rights reserved. * * 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 Bill Paul. * 4. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul 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. */ #ifndef lint static const char rcsid[] = - "$Id: yp_main.c,v 1.6.2.3 1997/11/18 07:52:04 charnier Exp $"; + "$Id: yp_main.c,v 1.6.2.4 1998/02/12 16:55:27 wpaul Exp $"; #endif /* not lint */ /* * ypserv startup function. * We need out own main() since we have to do some additional work * that rpcgen won't do for us. Most of this file was generated using * rpcgen.new, and later modified. */ #include "yp.h" #include #include #include #include #include #include /* getenv, exit */ #include /* strcmp */ #include #include #include /* for pmap_unset */ #include /* TIOCNOTTY */ #ifdef __cplusplus #include /* getdtablesize, open */ #endif /* __cplusplus */ #include #include #include #include "yp_extern.h" #include #ifndef SIG_PF #define SIG_PF void(*)(int) #endif #define _RPCSVC_CLOSEDOWN 120 int _rpcpmstart; /* Started by a port monitor ? */ static int _rpcfdtype; /* Whether Stream or Datagram ? */ /* States a server can be in wrt request */ #define _IDLE 0 #define _SERVED 1 #define _SERVING 2 extern void ypprog_1 __P((struct svc_req *, register SVCXPRT *)); extern void ypprog_2 __P((struct svc_req *, register SVCXPRT *)); extern int _rpc_dtablesize __P((void)); extern int _rpcsvcstate; /* Set when a request is serviced */ char *progname = "ypserv"; char *yp_dir = _PATH_YP; int do_dns = 0; int resfd; static void _msgout(char* msg) { if (debug) { if (_rpcpmstart) syslog(LOG_ERR, msg); else warnx("%s", msg); } else syslog(LOG_ERR, msg); } static void yp_svc_run() { #ifdef FD_SETSIZE fd_set readfds; #else int readfds; #endif /* def FD_SETSIZE */ extern int forked; int pid; int fd_setsize = _rpc_dtablesize(); struct timeval timeout; /* Establish the identity of the parent ypserv process. */ pid = getpid(); for (;;) { #ifdef FD_SETSIZE readfds = svc_fdset; #else readfds = svc_fds; #endif /* def FD_SETSIZE */ FD_SET(resfd, &readfds); timeout.tv_sec = RESOLVER_TIMEOUT; timeout.tv_usec = 0; switch (select(fd_setsize, &readfds, NULL, NULL, &timeout)) { case -1: if (errno == EINTR) { continue; } warn("svc_run: - select failed"); return; case 0: yp_prune_dnsq(); break; default: if (FD_ISSET(resfd, &readfds)) { yp_run_dnsq(); FD_CLR(resfd, &readfds); } svc_getreqset(&readfds); if (forked && pid != getpid()) exit(0); } } } static void unregister() { (void) pmap_unset(YPPROG, YPVERS); (void) pmap_unset(YPPROG, YPOLDVERS); } static void reaper(sig) int sig; { - int status; + int status; + int saved_errno; + saved_errno = errno; + if (sig == SIGHUP) { load_securenets(); #ifdef DB_CACHE yp_flush_all(); #endif + errno = saved_errno; return; } if (sig == SIGCHLD) { while (wait3(&status, WNOHANG, NULL) > 0) children--; } else { unregister(); exit(0); } + + errno = saved_errno; + return; } static void usage() { fprintf(stderr, "usage: ypserv [-h] [-d] [-n] [-p path]\n"); exit(1); } static void closedown(int sig) { if (_rpcsvcstate == _IDLE) { extern fd_set svc_fdset; static int size; int i, openfd; if (_rpcfdtype == SOCK_DGRAM) { unregister(); exit(0); } if (size == 0) { size = getdtablesize(); } for (i = 0, openfd = 0; i < size && openfd < 2; i++) if (FD_ISSET(i, &svc_fdset)) openfd++; if (openfd <= 1) { unregister(); exit(0); } } if (_rpcsvcstate == _SERVED) _rpcsvcstate = _IDLE; (void) signal(SIGALRM, (SIG_PF) closedown); (void) alarm(_RPCSVC_CLOSEDOWN/2); } int main(argc, argv) int argc; char *argv[]; { register SVCXPRT *transp = NULL; int sock; int proto = 0; struct sockaddr_in saddr; int asize = sizeof (saddr); int ch; while ((ch = getopt(argc, argv, "hdnp:")) != -1) { switch(ch) { case 'd': debug = ypdb_debug = 1; break; case 'n': do_dns = 1; break; case 'p': yp_dir = optarg; break; case 'h': default: usage(); } } load_securenets(); yp_init_resolver(); #ifdef DB_CACHE yp_init_dbs(); #endif if (getsockname(0, (struct sockaddr *)&saddr, &asize) == 0) { int ssize = sizeof (int); if (saddr.sin_family != AF_INET) exit(1); if (getsockopt(0, SOL_SOCKET, SO_TYPE, (char *)&_rpcfdtype, &ssize) == -1) exit(1); sock = 0; _rpcpmstart = 1; proto = 0; openlog("ypserv", LOG_PID, LOG_DAEMON); } else { if (!debug) { if (daemon(0,0)) { err(1,"cannot fork"); } openlog("ypserv", LOG_PID, LOG_DAEMON); } sock = RPC_ANYSOCK; (void) pmap_unset(YPPROG, YPVERS); (void) pmap_unset(YPPROG, 1); } if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_DGRAM)) { transp = svcudp_create(sock); if (transp == NULL) { _msgout("cannot create udp service"); exit(1); } if (!_rpcpmstart) proto = IPPROTO_UDP; if (!svc_register(transp, YPPROG, YPOLDVERS, ypprog_1, proto)) { _msgout("unable to register (YPPROG, YPOLDVERS, udp)"); exit(1); } if (!svc_register(transp, YPPROG, YPVERS, ypprog_2, proto)) { _msgout("unable to register (YPPROG, YPVERS, udp)"); exit(1); } } if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_STREAM)) { transp = svctcp_create(sock, 0, 0); if (transp == NULL) { _msgout("cannot create tcp service"); exit(1); } if (!_rpcpmstart) proto = IPPROTO_TCP; if (!svc_register(transp, YPPROG, YPOLDVERS, ypprog_1, proto)) { _msgout("unable to register (YPPROG, YPOLDVERS, tcp)"); exit(1); } if (!svc_register(transp, YPPROG, YPVERS, ypprog_2, proto)) { _msgout("unable to register (YPPROG, YPVERS, tcp)"); exit(1); } } if (transp == (SVCXPRT *)NULL) { _msgout("could not create a handle"); exit(1); } if (_rpcpmstart) { (void) signal(SIGALRM, (SIG_PF) closedown); (void) alarm(_RPCSVC_CLOSEDOWN/2); } /* * Make sure SIGPIPE doesn't blow us away while servicing TCP * connections. */ (void) signal(SIGPIPE, SIG_IGN); (void) signal(SIGCHLD, (SIG_PF) reaper); (void) signal(SIGTERM, (SIG_PF) reaper); (void) signal(SIGINT, (SIG_PF) reaper); (void) signal(SIGHUP, (SIG_PF) reaper); yp_svc_run(); _msgout("svc_run returned"); exit(1); /* NOTREACHED */ }