diff options
author | Mats O Jansson <maja@cvs.openbsd.org> | 1997-03-30 20:51:25 +0000 |
---|---|---|
committer | Mats O Jansson <maja@cvs.openbsd.org> | 1997-03-30 20:51:25 +0000 |
commit | e8cd4231cc31c280f819511e944c170c8d056181 (patch) | |
tree | ea4e23791d00b334d3d067c9eeacdce55cc66e8a | |
parent | 7b1f0fa815ba5fdc4f2f72dc0b1fbb236e7d1830 (diff) |
Added support for YP V1. Partly from FreeBSD. -moj
-rw-r--r-- | usr.sbin/ypserv/common/ypdef.h | 3 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/Makefile | 7 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/yp.h | 2 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/ypserv.c | 117 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/ypserv_proc.c | 427 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/ypserv_xdr_v1.c | 107 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/ypv1.h | 241 |
7 files changed, 896 insertions, 8 deletions
diff --git a/usr.sbin/ypserv/common/ypdef.h b/usr.sbin/ypserv/common/ypdef.h index d056856be89..aa960ddc232 100644 --- a/usr.sbin/ypserv/common/ypdef.h +++ b/usr.sbin/ypserv/common/ypdef.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ypdef.h,v 1.5 1996/06/30 19:45:59 maja Exp $ */ +/* $OpenBSD: ypdef.h,v 1.6 1997/03/30 20:51:14 maja Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -64,6 +64,7 @@ #endif #define YPXFR_PROC "/usr/sbin/ypxfr" +#define YPPUSH_PROC "/usr/sbin/yppush" #define YPSERV_PID_PATH "/var/run/ypserv.pid" #define YP_SECURENET_FILE "/var/yp/securenet" diff --git a/usr.sbin/ypserv/ypserv/Makefile b/usr.sbin/ypserv/ypserv/Makefile index 37280f6cd04..d95e2b7dab8 100644 --- a/usr.sbin/ypserv/ypserv/Makefile +++ b/usr.sbin/ypserv/ypserv/Makefile @@ -1,10 +1,11 @@ -# $OpenBSD: Makefile,v 1.3 1996/05/30 09:53:23 deraadt Exp $ +# $OpenBSD: Makefile,v 1.4 1997/03/30 20:51:17 maja Exp $ PROG= ypserv -SRCS= ypserv.c ypserv_proc.c ypserv_db.c acl.c yplog.c ypdb.c ypserv_xdr.c +SRCS= ypserv.c ypserv_proc.c ypserv_db.c acl.c yplog.c ypdb.c ypserv_xdr.c \ + ypserv_xdr_v1.c MAN= ypserv.acl.5 securenet.5 ypserv.8 .PATH: ${.CURDIR}/../common -CFLAGS+=-DDAEMON -I${.CURDIR}/../common +CFLAGS+=-DDAEMON -I${.CURDIR}/../common #CFLAGS=-DDAEMON -I${.CURDIR}/../common -DDEBUG -g .include <bsd.prog.mk> diff --git a/usr.sbin/ypserv/ypserv/yp.h b/usr.sbin/ypserv/ypserv/yp.h index 922a760b6c8..ab1369dcbf8 100644 --- a/usr.sbin/ypserv/ypserv/yp.h +++ b/usr.sbin/ypserv/ypserv/yp.h @@ -1,3 +1,5 @@ +/* $OpenBSD: yp.h,v 1.3 1997/03/30 20:51:19 maja Exp $ */ + /* * Please do not edit this file. * It was generated using rpcgen. diff --git a/usr.sbin/ypserv/ypserv/ypserv.c b/usr.sbin/ypserv/ypserv/ypserv.c index a6d7fc5ba45..e6fbca7de1a 100644 --- a/usr.sbin/ypserv/ypserv/ypserv.c +++ b/usr.sbin/ypserv/ypserv/ypserv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypserv.c,v 1.7 1997/01/15 23:44:34 millert Exp $ */ +/* $OpenBSD: ypserv.c,v 1.8 1997/03/30 20:51:20 maja Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -32,10 +32,11 @@ */ #ifndef LINT -static char rcsid[] = "$OpenBSD: ypserv.c,v 1.7 1997/01/15 23:44:34 millert Exp $"; +static char rcsid[] = "$OpenBSD: ypserv.c,v 1.8 1997/03/30 20:51:20 maja Exp $"; #endif #include "yp.h" +#include "ypv1.h" #include <stdio.h> #include <stdlib.h>/* getenv, exit */ #include <rpc/pmap_clnt.h> /* for pmap_unset */ @@ -116,6 +117,109 @@ closedown() } static void +ypprog_1(struct svc_req *rqstp, register SVCXPRT *transp) +{ + union { + domainname ypproc_domain_1_arg; + domainname ypproc_domain_nonack_1_arg; + yprequest ypproc_match_1_arg; + yprequest ypproc_first_1_arg; + yprequest ypproc_next_1_arg; + yprequest ypproc_poll_1_arg; + yprequest ypproc_push_1_arg; + yprequest ypproc_pull_1_arg; + yprequest ypproc_get_1_arg; + } argument; + char *result; + xdrproc_t xdr_argument, xdr_result; + char *(*local)(char *, struct svc_req *); + + _rpcsvcdirty = 1; + switch (rqstp->rq_proc) { + case YPOLDPROC_NULL: + xdr_argument = (xdrproc_t) xdr_void; + xdr_result = (xdrproc_t) xdr_void; + local = (char *(*)(char *, struct svc_req *)) ypproc_null_1_svc; + break; + + case YPOLDPROC_DOMAIN: + xdr_argument = (xdrproc_t) xdr_domainname; + xdr_result = (xdrproc_t) xdr_bool; + local = (char *(*)(char *, struct svc_req *)) ypproc_domain_1_svc; + break; + + case YPOLDPROC_DOMAIN_NONACK: + xdr_argument = (xdrproc_t) xdr_domainname; + xdr_result = (xdrproc_t) xdr_bool; + local = (char *(*)(char *, struct svc_req *)) ypproc_domain_nonack_1_svc; + break; + + case YPOLDPROC_MATCH: + xdr_argument = (xdrproc_t) xdr_yprequest; + xdr_result = (xdrproc_t) xdr_ypresponse; + local = (char *(*)(char *, struct svc_req *)) ypproc_match_1_svc; + break; + + case YPOLDPROC_FIRST: + xdr_argument = (xdrproc_t) xdr_yprequest; + xdr_result = (xdrproc_t) xdr_ypresponse; + local = (char *(*)(char *, struct svc_req *)) ypproc_first_1_svc; + break; + + case YPOLDPROC_NEXT: + xdr_argument = (xdrproc_t) xdr_yprequest; + xdr_result = (xdrproc_t) xdr_ypresponse; + local = (char *(*)(char *, struct svc_req *)) ypproc_next_1_svc; + break; + + case YPOLDPROC_POLL: + xdr_argument = (xdrproc_t) xdr_yprequest; + xdr_result = (xdrproc_t) xdr_ypresponse; + local = (char *(*)(char *, struct svc_req *)) ypproc_poll_1_svc; + break; + + case YPOLDPROC_PUSH: + xdr_argument = (xdrproc_t) xdr_yprequest; + xdr_result = (xdrproc_t) xdr_void; + local = (char *(*)(char *, struct svc_req *)) ypproc_push_1_svc; + break; + + case YPOLDPROC_PULL: + xdr_argument = (xdrproc_t) xdr_yprequest; + xdr_result = (xdrproc_t) xdr_void; + local = (char *(*)(char *, struct svc_req *)) ypproc_pull_1_svc; + break; + + case YPOLDPROC_GET: + xdr_argument = (xdrproc_t) xdr_yprequest; + xdr_result = (xdrproc_t) xdr_void; + local = (char *(*)(char *, struct svc_req *)) ypproc_get_1_svc; + break; + + default: + svcerr_noproc(transp); + _rpcsvcdirty = 0; + return; + } + (void) memset((char *)&argument, 0, sizeof (argument)); + if (!svc_getargs(transp, xdr_argument, (caddr_t) &argument)) { + svcerr_decode(transp); + _rpcsvcdirty = 0; + return; + } + result = (*local)((char *)&argument, rqstp); + if (result != NULL && !svc_sendreply(transp, xdr_result, result)) { + svcerr_systemerr(transp); + } + if (!svc_freeargs(transp, xdr_argument, (caddr_t) &argument)) { + _msgout("unable to free arguments"); + exit(1); + } + _rpcsvcdirty = 0; + return; +} + +static void ypprog_2(struct svc_req *rqstp, register SVCXPRT *transp) { union { @@ -320,6 +424,7 @@ char *argv[]; #endif sock = RPC_ANYSOCK; (void) pmap_unset(YPPROG, YPVERS); + (void) pmap_unset(YPPROG, YPOLDVERS); } ypopenlog(); /* open log file */ @@ -344,6 +449,10 @@ char *argv[]; } 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); @@ -361,6 +470,10 @@ char *argv[]; } 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); diff --git a/usr.sbin/ypserv/ypserv/ypserv_proc.c b/usr.sbin/ypserv/ypserv/ypserv_proc.c index 4d58d098b69..80bfaffe704 100644 --- a/usr.sbin/ypserv/ypserv/ypserv_proc.c +++ b/usr.sbin/ypserv/ypserv/ypserv_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypserv_proc.c,v 1.9 1997/03/11 09:12:27 maja Exp $ */ +/* $OpenBSD: ypserv_proc.c,v 1.10 1997/03/30 20:51:21 maja Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -32,11 +32,12 @@ */ #ifndef LINT -static char rcsid[] = "$OpenBSD: ypserv_proc.c,v 1.9 1997/03/11 09:12:27 maja Exp $"; +static char rcsid[] = "$OpenBSD: ypserv_proc.c,v 1.10 1997/03/30 20:51:21 maja Exp $"; #endif #include <rpc/rpc.h> #include "yp.h" +#include "ypv1.h" #include <rpcsvc/ypclnt.h> #include <sys/stat.h> #include <sys/socket.h> @@ -563,3 +564,425 @@ ypproc_maplist_2_svc(argp, rqstp) return (&res); } +void * +ypproc_null_1_svc(argp, rqstp) + void *argp; + struct svc_req *rqstp; +{ + static char *result; + struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); + int ok = acl_check_host(&caller->sin_addr); + + YPLOG("null_1: caller=[%s].%d, auth_ok=%s", + inet_ntoa(caller->sin_addr), ntohs(caller->sin_port), TORF(ok)); + + if (!ok) { + svcerr_auth(rqstp->rq_xprt, AUTH_FAILED); + return(NULL); + } + + result = NULL; + + return ((void *)&result); +} + +bool_t * +ypproc_domain_1_svc(argp, rqstp) + domainname *argp; + struct svc_req *rqstp; +{ + static bool_t result; /* is domain_served? */ + struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); + int ok = acl_check_host(&caller->sin_addr); + static char domain_path[MAXPATHLEN]; + struct stat finfo; + + snprintf(domain_path, sizeof(domain_path), "%s/%s", YP_DB_PATH, *argp); + result = (bool_t) ((stat(domain_path, &finfo) == 0) && + (finfo.st_mode & S_IFDIR)); + + YPLOG("domain_1: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s", + inet_ntoa(caller->sin_addr), ntohs(caller->sin_port), + TORF(ok), *argp, TORF(result)); + + if (!ok) { + svcerr_auth(rqstp->rq_xprt, AUTH_FAILED); + return(NULL); + } + + return (&result); +} + +bool_t * +ypproc_domain_nonack_1_svc(argp, rqstp) + domainname *argp; + struct svc_req *rqstp; +{ + static bool_t result; /* is domain served? */ + struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); + int ok = acl_check_host(&caller->sin_addr); + static char domain_path[MAXPATHLEN]; + struct stat finfo; + + snprintf(domain_path, sizeof(domain_path), "%s/%s", YP_DB_PATH, *argp); + result = (bool_t) ((stat(domain_path, &finfo) == 0) && + (finfo.st_mode & S_IFDIR)); + + YPLOG( + "domain_nonack_1: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s", + inet_ntoa(caller->sin_addr), ntohs(caller->sin_port), TORF(ok), + *argp, TORF(result)); + + if (!ok) { + svcerr_auth(rqstp->rq_xprt, AUTH_FAILED); + return(NULL); + } + + if (!result) { + return(NULL); /* don't send nack */ + } + + return (&result); +} + +ypresponse * +ypproc_match_1_svc(argp, rqstp) + yprequest *argp; + struct svc_req *rqstp; +{ + static ypresponse res; + struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); + int ok = acl_check_host(&caller->sin_addr); + int secure; + + res.yp_resptype = YPMATCH_RESPTYPE; + res.ypmatch_resp_valptr = ""; + res.ypmatch_resp_valsize = 0; + + if (argp->yp_reqtype != YPMATCH_REQTYPE) { + res.ypmatch_resp_status = YP_BADARGS; + return(&res); + } + + secure = ypdb_secure(argp->ypmatch_req_domain, argp->ypmatch_req_map); + + YPLOG( + "match_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s", + inet_ntoa(caller->sin_addr), ntohs(caller->sin_port), + TORF(ok), TORF(secure), + argp->ypmatch_req_domain, argp->ypmatch_req_map, + argp->ypmatch_req_keysize, argp->ypmatch_req_keyptr); + + if (!ok) { + svcerr_auth(rqstp->rq_xprt, AUTH_FAILED); + return(NULL); + } + + if (secure && (ntohs(caller->sin_port) >= IPPORT_RESERVED)) { + res.ypmatch_resp_status = YP_YPERR; + } else { + res.ypmatch_resp_val = + ypdb_get_record(argp->ypmatch_req_domain, + argp->ypmatch_req_map, + argp->ypmatch_req_keydat, + FALSE); + } + +#ifdef DEBUG + yplog(" match1_status: %s", + yperr_string(ypprot_err(res.ypmatch_resp_status))); +#endif + + return (&res); +} + +ypresponse * +ypproc_first_1_svc(argp, rqstp) + yprequest *argp; + struct svc_req *rqstp; +{ + static ypresponse res; + struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); + int ok = acl_check_host(&caller->sin_addr); + int secure; + + res.yp_resptype = YPFIRST_RESPTYPE; + res.ypfirst_resp_valptr = res.ypfirst_resp_keyptr = ""; + res.ypfirst_resp_valsize = res.ypfirst_resp_keysize = 0; + + if (argp->yp_reqtype != YPREQ_NOKEY) { + res.ypfirst_resp_status = YP_BADARGS; + return(&res); + } + + secure = ypdb_secure(argp->ypfirst_req_domain, argp->ypfirst_req_map); + + YPLOG( "first_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s", + inet_ntoa(caller->sin_addr), ntohs(caller->sin_port), + TORF(ok), TORF(secure), + argp->ypfirst_req_domain, argp->ypfirst_req_map); + + if (!ok) { + svcerr_auth(rqstp->rq_xprt, AUTH_FAILED); + return(NULL); + } + + if (secure && (ntohs(caller->sin_port) >= IPPORT_RESERVED)) { + res.ypfirst_resp_status = YP_YPERR; + } else { + res.ypfirst_resp_val = + ypdb_get_first(argp->ypfirst_req_domain, + argp->ypfirst_req_map, + FALSE); + } + +#ifdef DEBUG + yplog(" first1_status: %s", + yperr_string(ypprot_err(res.ypfirst_resp_status))); +#endif + + return (&res); +} + +ypresponse * +ypproc_next_1_svc(argp, rqstp) + yprequest *argp; + struct svc_req *rqstp; +{ + static ypresponse res; + struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); + int ok = acl_check_host(&caller->sin_addr); + int secure; + + res.yp_resptype = YPNEXT_RESPTYPE; + res.ypnext_resp_valptr = res.ypnext_resp_keyptr = ""; + res.ypnext_resp_valsize = res.ypnext_resp_keysize = 0; + + if (argp->yp_reqtype != YPNEXT_REQTYPE) { + res.ypnext_resp_status = YP_BADARGS; + return(&res); + } + + secure = ypdb_secure(argp->ypnext_req_domain, argp->ypnext_req_map); + + YPLOG( + "next_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s", + inet_ntoa(caller->sin_addr), ntohs(caller->sin_port), + TORF(ok), TORF(secure), + argp->ypnext_req_domain, argp->ypnext_req_map, + argp->ypnext_req_keysize, argp->ypnext_req_keyptr); + + if (!ok) { + svcerr_auth(rqstp->rq_xprt, AUTH_FAILED); + return(NULL); + } + + if (secure && (ntohs(caller->sin_port) >= IPPORT_RESERVED)) { + res.ypnext_resp_status = YP_YPERR; + } else { + res.ypnext_resp_val = + ypdb_get_next(argp->ypnext_req_domain, + argp->ypnext_req_map, + argp->ypnext_req_keydat, + FALSE); + } + +#ifdef DEBUG + yplog(" next1_status: %s", + yperr_string(ypprot_err(res.ypnext_resp_status))); +#endif + + return (&res); +} + +ypresponse * +ypproc_poll_1_svc(argp, rqstp) + yprequest *argp; + struct svc_req *rqstp; +{ + static ypresponse res; + ypresp_order order; + ypresp_master master; + struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); + int ok = acl_check_host(&caller->sin_addr); + int secure; + + res.yp_resptype = YPPOLL_RESPTYPE; + res.yppoll_resp_domain = argp->yppoll_req_domain; + res.yppoll_resp_map = argp->yppoll_req_map; + res.yppoll_resp_ordernum = 0; + res.yppoll_resp_owner = ""; + + if (argp->yp_reqtype != YPPOLL_REQTYPE) { + return(&res); + } + + secure = ypdb_secure(argp->yppoll_req_domain, argp->yppoll_req_map); + + YPLOG( "poll_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s", + inet_ntoa(caller->sin_addr), ntohs(caller->sin_port), + TORF(ok), TORF(secure), + argp->yppoll_req_domain, argp->yppoll_req_map); + + if (!ok) { + svcerr_auth(rqstp->rq_xprt, AUTH_FAILED); + return(NULL); + } + + if (!(secure && (ntohs(caller->sin_port) >= IPPORT_RESERVED))) { + order = ypdb_get_order(argp->yppoll_req_domain, + argp->yppoll_req_map); + master = ypdb_get_master(argp->yppoll_req_domain, + argp->yppoll_req_map); + res.yppoll_resp_ordernum = order.ordernum; + res.yppoll_resp_owner = master.peer; + } + +#ifdef DEBUG + yplog(" poll1_status: %s", "none"); +#endif + return (&res); +} + +void * +ypproc_push_1_svc(argp, rqstp) + yprequest *argp; + struct svc_req *rqstp; +{ + struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); + int ok = acl_check_host(&caller->sin_addr); + int secure; + pid_t pid; + char yppush_proc[] = YPPUSH_PROC; + + if (argp->yp_reqtype != YPPUSH_REQTYPE) { + return(NULL); + } + + secure = ypdb_secure(argp->yppush_req_domain, argp->yppush_req_map); + + YPLOG( "push_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s", + inet_ntoa(caller->sin_addr), ntohs(caller->sin_port), + TORF(ok), TORF(secure), + argp->yppush_req_domain, argp->yppush_req_map); + + if (ntohs(caller->sin_port) >= IPPORT_RESERVED) + ok = FALSE; + + if (!ok) { + svcerr_auth(rqstp->rq_xprt, AUTH_FAILED); + return(NULL); + } + + pid = vfork(); + + if (pid == -1) { + svcerr_systemerr(rqstp->rq_xprt); + return(NULL); + + } + + if (pid == 0) { + execl(yppush_proc, "yppush", "-d", argp->yppush_req_domain, + argp->yppush_req_map, NULL); + _exit(1); + } + + return (NULL); +} + +void * +ypproc_pull_1_svc(argp, rqstp) + yprequest *argp; + struct svc_req *rqstp; +{ + struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); + int ok = acl_check_host(&caller->sin_addr); + int secure; + pid_t pid; + char ypxfr_proc[] = YPXFR_PROC; + + if (argp->yp_reqtype != YPPULL_REQTYPE) { + return(NULL); + } + + secure = ypdb_secure(argp->yppull_req_domain, argp->yppull_req_map); + + YPLOG( "pull_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s", + inet_ntoa(caller->sin_addr), ntohs(caller->sin_port), + TORF(ok), TORF(secure), + argp->yppull_req_domain, argp->yppull_req_map); + + if (ntohs(caller->sin_port) >= IPPORT_RESERVED) + ok = FALSE; + + if (!ok) { + svcerr_auth(rqstp->rq_xprt, AUTH_FAILED); + return(NULL); + } + + pid = vfork(); + + if (pid == -1) { + svcerr_systemerr(rqstp->rq_xprt); + return(NULL); + + } + + if (pid == 0) { + execl(ypxfr_proc, "ypxfr", "-d", argp->yppull_req_domain, + argp->yppull_req_map, NULL); + _exit(1); + } + + return (NULL); +} + +void * +ypproc_get_1_svc(argp, rqstp) + yprequest *argp; + struct svc_req *rqstp; +{ + char *res; + struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); + int ok = acl_check_host(&caller->sin_addr); + int secure; + pid_t pid; + char ypxfr_proc[] = YPXFR_PROC; + + if (argp->yp_reqtype != YPGET_REQTYPE) { + return(NULL); + } + + secure = ypdb_secure(argp->ypget_req_domain, argp->ypget_req_map); + + YPLOG( "get_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, owner=%s", + inet_ntoa(caller->sin_addr), ntohs(caller->sin_port), + TORF(ok), TORF(secure), + argp->ypget_req_domain, argp->ypget_req_map, + argp->ypget_req_owner); + + if (ntohs(caller->sin_port) >= IPPORT_RESERVED) + ok = FALSE; + + if (!ok) { + svcerr_auth(rqstp->rq_xprt, AUTH_FAILED); + return(NULL); + } + + pid = vfork(); + + if (pid == -1) { + svcerr_systemerr(rqstp->rq_xprt); + return(NULL); + + } + + if (pid == 0) { + execl(ypxfr_proc, "ypxfr", "-d", argp->ypget_req_domain, "-h", + argp->ypget_req_owner, argp->yppush_req_map, NULL); + _exit(1); + } + + return (NULL); +} diff --git a/usr.sbin/ypserv/ypserv/ypserv_xdr_v1.c b/usr.sbin/ypserv/ypserv/ypserv_xdr_v1.c new file mode 100644 index 00000000000..68964cc7b02 --- /dev/null +++ b/usr.sbin/ypserv/ypserv/ypserv_xdr_v1.c @@ -0,0 +1,107 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#include "yp.h" +#include "ypv1.h" +#ifndef lint +static char rcsid[] = "$OpenBSD: ypserv_xdr_v1.c,v 1.1 1997/03/30 20:51:22 maja Exp $"; +#endif /* not lint */ + +bool_t +xdr_ypreqtype(xdrs, objp) + XDR *xdrs; + ypreqtype *objp; +{ + + register long *buf; + + if (!xdr_enum(xdrs, (enum_t *)objp)) { + return (FALSE); + } + return (TRUE); +} + +bool_t +xdr_ypresptype(xdrs, objp) + XDR *xdrs; + ypresptype *objp; +{ + + register long *buf; + + if (!xdr_enum(xdrs, (enum_t *)objp)) { + return (FALSE); + } + return (TRUE); +} + +bool_t +xdr_yprequest(xdrs, objp) + XDR *xdrs; + yprequest *objp; +{ + if (!xdr_ypreqtype(xdrs, &objp->yp_reqtype)) { + printf("error 1\n"); + return (FALSE); + } + switch (objp->yp_reqtype) { + case YPREQ_KEY: + if (!xdr_ypreq_key(xdrs, &objp->yp_reqbody.yp_req_keytype)) { + printf("error 2\n"); + return (FALSE); + } + break; + case YPREQ_NOKEY: + if (!xdr_ypreq_nokey(xdrs, &objp->yp_reqbody.yp_req_nokeytype)) { + printf("error 3\n"); + return (FALSE); + } + break; + case YPREQ_MAP_PARMS: + if (!xdr_ypmap_parms(xdrs, &objp->yp_reqbody.yp_req_map_parmstype)) { + printf("error 4\n"); + return (FALSE); + } + break; + default: + printf("error 5\n"); + return (FALSE); + } + return (TRUE); +} + +bool_t +xdr_ypresponse(xdrs, objp) + XDR *xdrs; + ypresponse *objp; +{ + + register long *buf; + + if (!xdr_ypresptype(xdrs, &objp->yp_resptype)) { + return (FALSE); + } + switch (objp->yp_resptype) { + case YPRESP_VAL: + if (!xdr_ypresp_val(xdrs, &objp->yp_respbody.yp_resp_valtype)) { + return (FALSE); + } + break; + case YPRESP_KEY_VAL: + if (!xdr_ypresp_key_val(xdrs, &objp->yp_respbody.yp_resp_key_valtype)) { + return (FALSE); + } + break; + case YPRESP_MAP_PARMS: + if (!xdr_ypmap_parms(xdrs, &objp->yp_respbody.yp_resp_map_parmstype)) { + return (FALSE); + } + break; + default: + return (FALSE); + } + return (TRUE); +} + diff --git a/usr.sbin/ypserv/ypserv/ypv1.h b/usr.sbin/ypserv/ypserv/ypv1.h new file mode 100644 index 00000000000..36264a0bccf --- /dev/null +++ b/usr.sbin/ypserv/ypserv/ypv1.h @@ -0,0 +1,241 @@ +/* $OpenBSD: ypv1.h,v 1.1 1997/03/30 20:51:24 maja Exp $ */ + +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _YPV1_H_RPCGEN +#define _YPV1_H_RPCGEN + +#include <rpc/rpc.h> + +#define YPOLDVERS ((u_long)1) + +enum ypreqtype { + YPREQ_KEY = 1, + YPREQ_NOKEY = 2, + YPREQ_MAP_PARMS = 3 +}; +typedef enum ypreqtype ypreqtype; +#ifdef __cplusplus +extern "C" bool_t xdr_ypreqtype(XDR *, ypreqtype*); +#elif __STDC__ +extern bool_t xdr_ypreqtype(XDR *, ypreqtype*); +#else /* Old Style C */ +bool_t xdr_ypreqtype(); +#endif /* Old Style C */ + +typedef struct { + ypreqtype yp_reqtype; + union { + struct ypreq_key yp_req_keytype; + struct ypreq_nokey yp_req_nokeytype; + struct ypmap_parms yp_req_map_parmstype; + }yp_reqbody; +} yprequest; +#ifdef __cplusplus +extern "C" bool_t xdr_yprequest(XDR *, yprequest*); +#elif __STDC__ +extern bool_t xdr_yprequest(XDR *, yprequest*); +#else /* Old Style C */ +bool_t xdr_yprequest(); +#endif /* Old Style C */ + +#define YPMATCH_REQTYPE YPREQ_KEY +#define ypmatch_req_domain yp_reqbody.yp_req_keytype.domain +#define ypmatch_req_map yp_reqbody.yp_req_keytype.map +#define ypmatch_req_keydat yp_reqbody.yp_req_keytype.key +#define ypmatch_req_keyptr yp_reqbody.yp_req_keytype.key.keydat_val +#define ypmatch_req_keysize yp_reqbody.yp_req_keytype.key.keydat_len + +#define YPFIRST_REQTYPE YPREQ_NOKEY +#define ypfirst_req_domain yp_reqbody.yp_req_nokeytype.domain +#define ypfirst_req_map yp_reqbody.yp_req_nokeytype.map + +#define YPNEXT_REQTYPE YPREQ_KEY +#define ypnext_req_domain yp_reqbody.yp_req_keytype.domain +#define ypnext_req_map yp_reqbody.yp_req_keytype.map +#define ypnext_req_keydat yp_reqbody.yp_req_keytype.key +#define ypnext_req_keyptr yp_reqbody.yp_req_keytype.key.keydat_val +#define ypnext_req_keysize yp_reqbody.yp_req_keytype.key.keydat_len + +#define YPPUSH_REQTYPE YPREQ_NOKEY +#define yppush_req_domain yp_reqbody.yp_req_nokeytype.domain +#define yppush_req_map yp_reqbody.yp_req_nokeytype.map + +#define YPPULL_REQTYPE YPREQ_NOKEY +#define yppull_req_domain yp_reqbody.yp_req_nokeytype.domain +#define yppull_req_map yp_reqbody.yp_req_nokeytype.map + +#define YPPOLL_REQTYPE YPREQ_NOKEY +#define yppoll_req_domain yp_reqbody.yp_req_nokeytype.domain +#define yppoll_req_map yp_reqbody.yp_req_nokeytype.map + +#define YPGET_REQTYPE YPREQ_MAP_PARMS +#define ypget_req_domain yp_reqbody.yp_req_map_parmstype.domain +#define ypget_req_map yp_reqbody.yp_req_map_parmstype.map +#define ypget_req_ordernum yp_reqbody.yp_req_map_parmstype.ordernum +#define ypget_req_owner yp_reqbody.yp_req_map_parmstype.peer + +enum ypresptype { + YPRESP_VAL = 1, + YPRESP_KEY_VAL = 2, + YPRESP_MAP_PARMS = 3 +}; +typedef enum ypresptype ypresptype; +#ifdef __cplusplus +extern "C" bool_t xdr_ypresptype(XDR *, ypresptype*); +#elif __STDC__ +extern bool_t xdr_ypresptype(XDR *, ypresptype*); +#else /* Old Style C */ +bool_t xdr_ypresptype(); +#endif /* Old Style C */ + +typedef struct { + ypresptype yp_resptype; + union { + struct ypresp_val yp_resp_valtype; + struct ypresp_key_val yp_resp_key_valtype; + struct ypmap_parms yp_resp_map_parmstype; + } yp_respbody; +} ypresponse; +#ifdef __cplusplus +extern "C" bool_t xdr_ypresponse(XDR *, ypresponse*); +#elif __STDC__ +extern bool_t xdr_ypresponse(XDR *, ypresponse*); +#else /* Old Style C */ +bool_t xdr_ypresponse(); +#endif /* Old Style C */ + +#define YPMATCH_RESPTYPE YPRESP_VAL +#define ypmatch_resp_status yp_respbody.yp_resp_valtype.stat +#define ypmatch_resp_val yp_respbody.yp_resp_valtype +#define ypmatch_resp_valdat yp_respbody.yp_resp_valtype.val +#define ypmatch_resp_valptr yp_respbody.yp_resp_valtype.val.valdat_val +#define ypmatch_resp_valsize yp_respbody.yp_resp_valtype.val.valdat_len + +#define YPFIRST_RESPTYPE YPRESP_KEY_VAL +#define ypfirst_resp_status yp_respbody.yp_resp_key_valtype.stat +#define ypfirst_resp_keydat yp_respbody.yp_resp_key_valtype.key +#define ypfirst_resp_keyptr yp_respbody.yp_resp_key_valtype.key.keydat_val +#define ypfirst_resp_keysize yp_respbody.yp_resp_key_valtype.key.keydat_len +#define ypfirst_resp_val yp_respbody.yp_resp_key_valtype +#define ypfirst_resp_valdat yp_respbody.yp_resp_key_valtype.val +#define ypfirst_resp_valptr yp_respbody.yp_resp_key_valtype.val.valdat_val +#define ypfirst_resp_valsize yp_respbody.yp_resp_key_valtype.val.valdat_len + +#define YPNEXT_RESPTYPE YPRESP_KEY_VAL +#define ypnext_resp_status yp_respbody.yp_resp_key_valtype.stat +#define ypnext_resp_keydat yp_respbody.yp_resp_key_valtype.key +#define ypnext_resp_keyptr yp_respbody.yp_resp_key_valtype.key.keydat_val +#define ypnext_resp_keysize yp_respbody.yp_resp_key_valtype.key.keydat_len +#define ypnext_resp_val yp_respbody.yp_resp_key_valtype +#define ypnext_resp_valdat yp_respbody.yp_resp_key_valtype.val +#define ypnext_resp_valptr yp_respbody.yp_resp_key_valtype.val.valdat_val +#define ypnext_resp_valsize yp_respbody.yp_resp_key_valtype.val.valdat_len + +#define YPPOLL_RESPTYPE YPRESP_MAP_PARMS +#define yppoll_resp_domain yp_respbody.yp_resp_map_parmstype.domain +#define yppoll_resp_map yp_respbody.yp_resp_map_parmstype.map +#define yppoll_resp_ordernum yp_respbody.yp_resp_map_parmstype.ordernum +#define yppoll_resp_owner yp_respbody.yp_resp_map_parmstype.peer + +#ifdef __cplusplus +#define YPOLDPROC_NULL ((u_long)0) +extern "C" void * ypproc_null_1(void *, CLIENT *); +extern "C" void * ypproc_null_1_svc(void *, struct svc_req *); +#define YPOLDPROC_DOMAIN ((u_long)1) +extern "C" bool_t * ypproc_domain_1(domainname *, CLIENT *); +extern "C" bool_t * ypproc_domain_1_svc(domainname *, struct svc_req *); +#define YPOLDPROC_DOMAIN_NONACK ((u_long)2) +extern "C" bool_t * ypproc_domain_nonack_1(domainname *, CLIENT *); +extern "C" bool_t * ypproc_domain_nonack_1_svc(domainname *, struct svc_req *); +#define YPOLDPROC_MATCH ((u_long)3) +extern "C" ypresponse * ypproc_match_1(yprequest *, CLIENT *); +extern "C" ypresponse * ypproc_match_1_svc(yprequest *, struct svc_req *); +#define YPOLDPROC_FIRST ((u_long)4) +extern "C" ypresponse * ypproc_first_1(yprequest *, CLIENT *); +extern "C" ypresponse * ypproc_first_1_svc(yprequest *, struct svc_req *); +#define YPOLDPROC_NEXT ((u_long)5) +extern "C" ypresponse * ypproc_next_1(yprequest *, CLIENT *); +extern "C" ypresponse * ypproc_next_1_svc(yprequest *, struct svc_req *); +#define YPOLDPROC_POLL ((u_long)6) +extern "C" ypresponse * ypproc_poll_1(yprequest *, CLIENT *); +extern "C" ypresponse * ypproc_poll_1_svc(yprequest *, struct svc_req *); +#define YPOLDPROC_PUSH ((u_long)7) +extern "C" void * ypproc_push_1(yprequest *, CLIENT *); +extern "C" void * ypproc_push_1_svc(yprequest *, struct svc_req *); +#define YPOLDPROC_PULL ((u_long)8) +extern "C" void * ypproc_pull_1(yprequest *, CLIENT *); +extern "C" void * ypproc_pull_1_svc(yprequest *, struct svc_req *); +#define YPOLDPROC_GET ((u_long)9) +extern "C" void * ypproc_get_1(yprequest *, CLIENT *); +extern "C" void * ypproc_get_1_svc(yprequest *, struct svc_req *); + +#elif __STDC__ +#define YPOLDPROC_NULL ((u_long)0) +extern void * ypproc_null_1(void *, CLIENT *); +extern void * ypproc_null_1_svc(void *, struct svc_req *); +#define YPOLDPROC_DOMAIN ((u_long)1) +extern bool_t * ypproc_domain_1(domainname *, CLIENT *); +extern bool_t * ypproc_domain_1_svc(domainname *, struct svc_req *); +#define YPOLDPROC_DOMAIN_NONACK ((u_long)2) +extern bool_t * ypproc_domain_nonack_1(domainname *, CLIENT *); +extern bool_t * ypproc_domain_nonack_1_svc(domainname *, struct svc_req *); +#define YPOLDPROC_MATCH ((u_long)3) +extern ypresponse * ypproc_match_1(yprequest *, CLIENT *); +extern ypresponse * ypproc_match_1_svc(yprequest *, struct svc_req *); +#define YPOLDPROC_FIRST ((u_long)4) +extern ypresponse * ypproc_first_1(yprequest *, CLIENT *); +extern ypresponse * ypproc_first_1_svc(yprequest *, struct svc_req *); +#define YPOLDPROC_NEXT ((u_long)5) +extern ypresponse * ypproc_next_1(yprequest *, CLIENT *); +extern ypresponse * ypproc_next_1_svc(yprequest *, struct svc_req *); +#define YPOLDPROC_POLL ((u_long)6) +extern ypresponse * ypproc_poll_1(yprequest *, CLIENT *); +extern ypresponse * ypproc_poll_1_svc(yprequest *, struct svc_req *); +#define YPOLDPROC_PUSH ((u_long)7) +extern void * ypproc_push_1(yprequest *, CLIENT *); +extern void * ypproc_push_1_svc(yprequest *, struct svc_req *); +#define YPOLDPROC_PULL ((u_long)8) +extern void * ypproc_pull_1(yprequest *, CLIENT *); +extern void * ypproc_pull_1_svc(yprequest *, struct svc_req *); +#define YPOLDPROC_GET ((u_long)9) +extern void * ypproc_get_1(yprequest *, CLIENT *); +extern void * ypproc_get_1_svc(yprequest *, struct svc_req *); + +#else /* Old Style C */ +#define YPOLDPROC_NULL ((u_long)0) +extern void * ypproc_null_1(); +extern void * ypproc_null_1_svc(); +#define YPOLDPROC_DOMAIN ((u_long)1) +extern bool_t * ypproc_domain_1(); +extern bool_t * ypproc_domain_1_svc(); +#define YPOLDPROC_DOMAIN_NONACK ((u_long)2) +extern bool_t * ypproc_domain_nonack_1(); +extern bool_t * ypproc_domain_nonack_1_svc(); +#define YPOLDPROC_MATCH ((u_long)3) +extern ypresponse * ypproc_match_1(); +extern ypresponse * ypproc_match_1_svc(); +#define YPOLDPROC_FIRST ((u_long)4) +extern ypresponse * ypproc_first_1(); +extern ypresponse * ypproc_first_1_svc(); +#define YPOLDPROC_NEXT ((u_long)5) +extern ypresponse * ypproc_next_1(); +extern ypresponse * ypproc_next_1_svc(); +#define YPOLDPROC_POLL ((u_long)6) +extern ypresponse * ypproc_poll_1(); +extern ypresponse * ypproc_poll_1_svc(); +#define YPOLDPROC_PUSH ((u_long)7) +extern void * ypproc_push_1(); +extern void * ypproc_push_1_svc(); +#define YPOLDPROC_PULL ((u_long)8) +extern void * ypproc_pull_1(); +extern void * ypproc_pull_1_svc(); +#define YPOLDPROC_GET ((u_long)9) +extern void * ypproc_get_1(); +extern void * ypproc_get_1_svc(); +#endif /* Old Style C */ + +#endif /* !_YPV1_H_RPCGEN */ |