From 41b6ecfc9fb0399a53a7694d32b2a2d59e5d4225 Mon Sep 17 00:00:00 2001 From: maja Date: Sat, 14 Dec 1996 22:10:27 +0000 Subject: [PATCH] Add Theo's changes to yppush, some very ugly debugging code is now gone. -moj --- usr.sbin/ypserv/yppush/yppush.c | 48 +++++++++++++-------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/usr.sbin/ypserv/yppush/yppush.c b/usr.sbin/ypserv/yppush/yppush.c index 2afa5feed67..c17db8448d2 100644 --- a/usr.sbin/ypserv/yppush/yppush.c +++ b/usr.sbin/ypserv/yppush/yppush.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yppush.c,v 1.4 1996/11/08 21:53:32 niklas Exp $ */ +/* $OpenBSD: yppush.c,v 1.5 1996/12/14 22:10:27 maja Exp $ */ /* * Copyright (c) 1995 Mats O Jansson @@ -32,35 +32,22 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: yppush.c,v 1.4 1996/11/08 21:53:32 niklas Exp $"; +static char rcsid[] = "$OpenBSD: yppush.c,v 1.5 1996/12/14 22:10:27 maja 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 @@ -69,8 +56,9 @@ static char rcsid[] = "$OpenBSD: yppush.c,v 1.4 1996/11/08 21:53:32 niklas Exp $ #include "ypdb.h" int Verbose = 0; -char Domain[255], Map[255], *LocalHost = "meg.celsiustech.se"; +char Domain[MAXHOSTNAMELEN], Map[255]; u_long OrderNum; +char *master; extern void yppush_xfrrespprog_1(struct svc_req *request, SVCXPRT *xprt); extern bool_t xdr_ypreq_xfr(XDR *, struct ypreq_xfr *); @@ -129,7 +117,7 @@ CLIENT *client; request.map_parms.domain=(char *)&Domain; request.map_parms.map=(char *)⤅ - request.map_parms.peer=LocalHost; + request.map_parms.peer=master; request.map_parms.ordernum=OrderNum; request.transid=(u_int)pid; request.prog=prog; @@ -159,7 +147,7 @@ push(inlen, indata) int inlen; char *indata; { - char host[255]; + char host[MAXHOSTNAMELEN]; CLIENT *client; SVCXPRT *transp; int sock = RPC_ANYSOCK; @@ -169,7 +157,7 @@ char *indata; int status; struct rusage res; - sprintf(host,"%*.*s" ,inlen ,inlen, indata); + snprintf(host,sizeof host,"%*.*s" ,inlen ,inlen, indata); client = clnt_create(host, YPPROG, YPVERS, "tcp"); if (client == NULL) { @@ -236,14 +224,13 @@ int argc; char **argv; { struct ypall_callback ypcb; - char *master; extern char *optarg; extern int optind; char *domain,*map,*hostname,*parallel,*timeout; int c, r, i; char *ypmap = "ypservers"; CLIENT *client; - static char map_path[255]; + static char map_path[MAXPATHLEN]; struct stat finfo; DBM *yp_databas; char order_key[YP_LAST_LEN] = YP_LAST_KEY; @@ -281,11 +268,13 @@ char **argv; map = argv[optind]; - strcpy(Domain,domain); - strcpy(Map,map); + strncpy(Domain,domain,sizeof(Domain)-1); + Domain[sizeof(Domain)-1] = '\0'; + strncpy(Map,map,sizeof(Map)-1); + Map[sizeof(Map)-1] = '\0'; /* Check domain */ - sprintf(map_path,"%s/%s",YP_DB_PATH,domain); + snprintf(map_path,sizeof map_path,"%s/%s",YP_DB_PATH,domain); if (!((stat(map_path, &finfo) == 0) && ((finfo.st_mode & S_IFMT) == S_IFDIR))) { fprintf(stderr,"yppush: Map does not exist.\n"); @@ -293,13 +282,14 @@ char **argv; } /* Check map */ - sprintf(map_path,"%s/%s/%s%s",YP_DB_PATH,domain,Map,YPDB_SUFFIX); + snprintf(map_path,sizeof map_path,"%s/%s/%s%s", + YP_DB_PATH,domain,Map,YPDB_SUFFIX); if (!(stat(map_path, &finfo) == 0)) { fprintf(stderr,"yppush: Map does not exist.\n"); exit(1); } - sprintf(map_path,"%s/%s/%s",YP_DB_PATH,domain,Map); + snprintf(map_path,sizeof map_path,"%s/%s/%s",YP_DB_PATH,domain,Map); yp_databas = ypdb_open(map_path,0,O_RDONLY); OrderNum=0xffffffff; if (yp_databas == 0) { @@ -334,12 +324,12 @@ char **argv; yp_bind(Domain); + r = yp_master(Domain, ypmap, &master); + if (hostname != NULL) { push(strlen(hostname), hostname); } else { - r = yp_master(Domain, ypmap, &master); - if (Verbose) { printf("Contacting master for ypservers (%s).\n", master); } -- 2.20.1