diff options
author | wpaul <wpaul@FreeBSD.org> | 1995-04-02 20:01:50 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1995-04-02 20:01:50 +0000 |
commit | f49687c8a49f95e856b43515877ec61dff48cc59 (patch) | |
tree | c905bda0813776f5f7be038da3a1d8ba3c7e648d /gnu/usr.bin/yppush | |
parent | 3c90ffcb6f0515de9d2ef79420da734f5c3249ba (diff) | |
download | FreeBSD-src-f49687c8a49f95e856b43515877ec61dff48cc59.zip FreeBSD-src-f49687c8a49f95e856b43515877ec61dff48cc59.tar.gz |
Add back some stuff to yppush.c that I was a little over-zealous in
removing. Also do away with compiling yp_svc.c: yppush doesn't need it.
Diffstat (limited to 'gnu/usr.bin/yppush')
-rw-r--r-- | gnu/usr.bin/yppush/Makefile | 7 | ||||
-rw-r--r-- | gnu/usr.bin/yppush/yppush.c | 97 |
2 files changed, 92 insertions, 12 deletions
diff --git a/gnu/usr.bin/yppush/Makefile b/gnu/usr.bin/yppush/Makefile index 4939ff9..af345ca 100644 --- a/gnu/usr.bin/yppush/Makefile +++ b/gnu/usr.bin/yppush/Makefile @@ -2,16 +2,11 @@ # $Id: Makefile,v 1.3 1995/04/02 01:10:08 wpaul Exp $ PROG= yppush -SRCS= yp_svc.c yp_clnt.c yppush.c +SRCS= yp_clnt.c yppush.c MAN8= yppush.8 CLEANFILES= yp_svc.c yp_clnt.c yp.h yp.x -yp_svc.c: yp.h - rm -f yp.x - cp ${DESTDIR}/usr/include/rpcsvc/yp.x . - rpcgen -m -o yp_svc.c yp.x - yp_clnt.c: yp.h rm -f yp.x cp ${DESTDIR}/usr/include/rpcsvc/yp.x . diff --git a/gnu/usr.bin/yppush/yppush.c b/gnu/usr.bin/yppush/yppush.c index 58008f4..5c1a623 100644 --- a/gnu/usr.bin/yppush/yppush.c +++ b/gnu/usr.bin/yppush/yppush.c @@ -51,7 +51,7 @@ struct dom_binding { #include <sys/stat.h> #ifndef _PATH_YP -#define _PATH_YP "/var/yp" +#define _PATH_YP "/var/yp/" #endif char *progname; @@ -83,6 +83,93 @@ static u_int CallbackTransid; static u_int CallbackProg=0; static SVCXPRT *CallbackXprt; +static inline char * +yppush_err_string(enum yppush_status y) { + switch(y) { + case YPPUSH_SUCC: return "Success"; + case YPPUSH_AGE: return "Master's version not newer"; + case YPPUSH_NOMAP: return "Can't find server for map"; + case YPPUSH_NODOM: return "Domain not supported"; + case YPPUSH_RSRC: return "Local resource alloc failure"; + case YPPUSH_RPC: return "RPC failure talking to server"; + case YPPUSH_MADDR: return "Can't get master address"; + case YPPUSH_YPERR: return "YP server/map db error"; + case YPPUSH_BADARGS: return "Request arguments bad"; + case YPPUSH_DBM: return "Local dbm operation failed"; + case YPPUSH_FILE: return "Local file I/O operation failed"; + case YPPUSH_SKEW: return "Map version skew during transfer"; + case YPPUSH_CLEAR: return "Can't send \"Clear\" req to local ypserv"; + case YPPUSH_FORCE: return "No local order number in map use -f flag."; + case YPPUSH_XFRERR: return "ypxfr error"; + case YPPUSH_REFUSED: return "Transfer request refused by ypserv"; + } +} + +#define YPPUSH_XFRRESPPROG ((u_long)0x40000000) +#define YPPUSH_XFRRESPVERS ((u_long)1) + +#define YPPUSHPROC_NULL ((u_long)0) +static inline void * +__yppushproc_null_1(void * req, struct svc_req * rqstp) { + static int resp; + return &resp; +} + +#define YPPUSHPROC_XFRRESP ((u_long)1) +static inline void * +__yppushproc_xfrresp_1(yppushresp_xfr *req, struct svc_req * rqstp) { + static int resp; + + if (req->status!=YPPUSH_SUCC) + fprintf(stderr, "%s: %s\n", progname, yppush_err_string(req->status)); + return &resp; +} + +void +__yppush_xfrrespprog_1( struct svc_req *rqstp, SVCXPRT *transp) +{ + union { + int fill; + } argument; + char *result; + bool_t (*xdr_argument)(XDR *, void *), (*xdr_result)(XDR *, void *); + char *(*local)( void *, struct svc_req *); + + switch (rqstp->rq_proc) { + case YPPUSHPROC_NULL: + xdr_argument = (bool_t (*)(XDR *, void *))xdr_void; + xdr_result = (bool_t (*)(XDR *, void *))xdr_void; + local = (char *(*)( void *, struct svc_req *)) __yppushproc_null_1; + break; + + case YPPUSHPROC_XFRRESP: + xdr_argument = xdr_yppushresp_xfr; + xdr_result = (bool_t (*)(XDR *, void *))xdr_void; + local = (char *(*)( void *, struct svc_req *)) __yppushproc_xfrresp_1; + break; + + default: + svcerr_noproc(transp); + exit(1); + } + bzero((char *)&argument, sizeof(argument)); + if (!svc_getargs(transp, xdr_argument, &argument)) { + svcerr_decode(transp); + exit(1); + } + result = (*local)(&argument, rqstp); + if (result != NULL && !svc_sendreply(transp, xdr_result, result)) { + svcerr_systemerr(transp); + } + if (!svc_freeargs(transp, xdr_argument, &argument)) { + (void)fprintf(stderr, "%s: unable to free arguments\n", progname); + exit(1); + if (rqstp->rq_proc!=YPPUSHPROC_NULL) + exit(0); + } + exit(0); +} + /* * This is the rpc server side idle loop * Wait for input, call server program. @@ -159,10 +246,10 @@ getOrderNum( void) int i; strcpy(mapPath, _PATH_YP); - strcat(mapPath, "/"); strcat(mapPath, DomainName); strcat(mapPath, "/"); strcat(mapPath, MapName); + if ((db = dbopen(mapPath, O_RDWR|O_EXCL, PERM_SECURE, DB_HASH, &openinfo)) == NULL) { fprintf(stderr, "%s: %s: cannot open\n", progname, mapPath); @@ -194,7 +281,7 @@ doPushClient( const char *targetHost) struct ypreq_xfr req; static struct timeval tv={0,0}; - req.map_parms.domain=DomainName ; + req.map_parms.domain=DomainName; req.map_parms.map=(char *)MapName; req.map_parms.peer=ThisHost; req.map_parms.ordernum=MapOrderNum; @@ -219,8 +306,6 @@ doPushClient( const char *targetHost) return; } -extern void yppush_xfrrespprog_1(struct svc_req *request, SVCXPRT *xprt); - static bool_t registerServer(void) { @@ -234,7 +319,7 @@ registerServer(void) } for (CallbackProg=0x40000000; CallbackProg<0x5fffffff; CallbackProg++) { if (svc_register(CallbackXprt, CallbackProg, 1, - yppush_xfrrespprog_1, IPPROTO_UDP)) + __yppush_xfrrespprog_1, IPPROTO_UDP)) return TRUE; } return FALSE; |