summaryrefslogtreecommitdiff
path: root/usr.sbin/ypserv/yppush
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/ypserv/yppush')
-rw-r--r--usr.sbin/ypserv/yppush/yppush.c112
-rw-r--r--usr.sbin/ypserv/yppush/yppush.h4
-rw-r--r--usr.sbin/ypserv/yppush/yppush_err.c44
-rw-r--r--usr.sbin/ypserv/yppush/yppush_proc.c10
-rw-r--r--usr.sbin/ypserv/yppush/yppush_svc.c19
-rw-r--r--usr.sbin/ypserv/yppush/yppush_xdr.c23
6 files changed, 102 insertions, 110 deletions
diff --git a/usr.sbin/ypserv/yppush/yppush.c b/usr.sbin/ypserv/yppush/yppush.c
index 551b2be12b7..0b1ec49dd87 100644
--- a/usr.sbin/ypserv/yppush/yppush.c
+++ b/usr.sbin/ypserv/yppush/yppush.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yppush.c,v 1.11 1998/02/24 04:29:06 deraadt Exp $ */
+/* $OpenBSD: yppush.c,v 1.12 2000/10/12 09:47:27 deraadt Exp $ */
/*
* Copyright (c) 1995 Mats O Jansson <moj@stacken.kth.se>
@@ -32,21 +32,26 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: yppush.c,v 1.11 1998/02/24 04:29:06 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: yppush.c,v 1.12 2000/10/12 09:47:27 deraadt Exp $";
#endif /* not lint */
#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/resource.h>
+#include <sys/signal.h>
+#include <sys/wait.h>
+
#include <stdio.h>
#include <unistd.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <signal.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
-#include <sys/stat.h>
-#include <sys/resource.h>
-#include <sys/signal.h>
#include <netdb.h>
#include <string.h>
#include <errno.h>
@@ -68,9 +73,6 @@ void
usage()
{
fprintf(stderr, "Usage:\n");
-/*
- fprintf(stderr, "\typpush [-d domainname] [-t seconds] [-p #paralleljobs] [-h host] [-v] mapname\n");
-*/
fprintf(stderr, "\typpush [-d domainname] [-h host] [-v] mapname\n");
exit(1);
}
@@ -81,16 +83,16 @@ _svc_run()
fd_set readfds;
struct timeval timeout;
- timeout.tv_sec=60; timeout.tv_usec=0;
+ timeout.tv_sec = 60;
+ timeout.tv_usec = 0;
- for(;;) {
+ for (;;) {
readfds = svc_fdset;
- switch (select(_rpc_dtablesize(), &readfds, (void *) 0,
- (void *) 0, &timeout)) {
+ switch (select(_rpc_dtablesize(), &readfds, NULL,
+ NULL, &timeout)) {
case -1:
- if (errno == EINTR) {
+ if (errno == EINTR)
continue;
- }
perror("yppush: _svc_run: select failed");
return;
case 0:
@@ -98,9 +100,9 @@ _svc_run()
exit(0);
default:
svc_getreqset(&readfds);
+ break;
}
}
-
}
void
@@ -114,7 +116,8 @@ CLIENT *client;
struct ypreq_xfr request;
struct timeval tv;
- tv.tv_sec=0; tv.tv_usec=0;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
request.map_parms.domain=(char *)&Domain;
request.map_parms.map=(char *)&Map;
@@ -126,20 +129,18 @@ CLIENT *client;
if (Verbose)
printf("%d: %s(%u@%s) -> %s@%s\n",
- request.transid,
- request.map_parms.map,
- request.map_parms.ordernum,
- host,
- request.map_parms.peer,
- request.map_parms.domain);
+ request.transid, request.map_parms.map,
+ request.map_parms.ordernum, host,
+ request.map_parms.peer, request.map_parms.domain);
switch (clnt_call(client, YPPROC_XFR, xdr_ypreq_xfr, &request,
- xdr_void, NULL, tv)) {
+ xdr_void, NULL, tv)) {
case RPC_SUCCESS:
case RPC_TIMEDOUT:
break;
default:
clnt_perror(client, "yppush: Cannot call YPPROC_XFR");
kill(pid, SIGTERM);
+ break;
}
}
@@ -153,7 +154,7 @@ char *indata;
SVCXPRT *transp;
int sock = RPC_ANYSOCK;
u_int prog;
- bool_t sts;
+ bool_t sts = 0;
pid_t pid;
int status;
struct rusage res;
@@ -180,8 +181,8 @@ char *indata;
}
for (prog=0x40000000; prog<0x5fffffff; prog++) {
- if (sts = svc_register(transp, prog, 1,
- yppush_xfrrespprog_1, IPPROTO_UDP))
+ if ((sts = svc_register(transp, prog, 1,
+ yppush_xfrrespprog_1, IPPROTO_UDP)))
break;
}
@@ -219,7 +220,7 @@ char *inval;
int invallen;
char *indata;
{
- if(instatus != YP_TRUE)
+ if (instatus != YP_TRUE)
return instatus;
push(invallen, inval);
return 0;
@@ -243,15 +244,12 @@ char **argv;
char order_key[YP_LAST_LEN] = YP_LAST_KEY;
datum o;
- yp_get_default_domain(&domain);
+ yp_get_default_domain(&domain);
hostname = NULL;
-/*
- while( (c=getopt(argc, argv, "d:h:p:t:v?")) != -1)
-*/
- while( (c=getopt(argc, argv, "d:h:v?")) != -1)
+ while ((c=getopt(argc, argv, "d:h:v")) != -1)
switch(c) {
case 'd':
- domain = optarg;
+ domain = optarg;
break;
case 'h':
hostname = optarg;
@@ -262,15 +260,15 @@ char **argv;
case 't':
timeout = optarg;
break;
- case 'v':
- Verbose = 1;
- break;
- case '?':
- usage();
- /*NOTREACHED*/
+ case 'v':
+ Verbose = 1;
+ break;
+ default:
+ usage();
+ /*NOTREACHED*/
}
- if(optind + 1 != argc )
+ if (optind + 1 != argc )
usage();
map = argv[optind];
@@ -313,47 +311,45 @@ char **argv;
Map);
} else {
OrderNum=0;
- for(i=0; i<o.dsize-1; i++) {
+ for (i=0; i<o.dsize-1; i++) {
if (!isdigit(o.dptr[i])) {
OrderNum=0xffffffff;
}
}
if (OrderNum != 0) {
fprintf(stderr,
- "yppush: %s: Invalid order number '%s'\n",
- Map,
- o.dptr);
+ "yppush: %s: Invalid order number '%s'\n",
+ Map, o.dptr);
} else {
OrderNum = atoi(o.dptr);
}
}
- }
+ }
yp_bind(Domain);
r = yp_master(Domain, ypmap, &master);
- if (r != 0) {
+ if (r != 0) {
fprintf(stderr, "yppush: could not get ypservers map\n");
exit(1);
}
if (hostname != NULL) {
- push(strlen(hostname), hostname);
+ push(strlen(hostname), hostname);
} else {
-
- if (Verbose) {
- printf("Contacting master for ypservers (%s).\n", master);
- }
-
- client = yp_bind_host(master, YPPROG, YPVERS, 0, 1);
+ if (Verbose) {
+ printf("Contacting master for ypservers (%s).\n",
+ master);
+ }
- ypcb.foreach = pushit;
- ypcb.data = NULL;
+ client = yp_bind_host(master, YPPROG, YPVERS, 0, 1);
- r = yp_all_host(client,Domain, ypmap, &ypcb);
+ ypcb.foreach = pushit;
+ ypcb.data = NULL;
+ r = yp_all_host(client,Domain, ypmap, &ypcb);
}
-
- exit(0);
+
+ exit(0);
}
diff --git a/usr.sbin/ypserv/yppush/yppush.h b/usr.sbin/ypserv/yppush/yppush.h
index 67284763adf..9414d8073a4 100644
--- a/usr.sbin/ypserv/yppush/yppush.h
+++ b/usr.sbin/ypserv/yppush/yppush.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: yppush.h,v 1.3 1997/07/25 20:12:32 mickey Exp $ */
+/* $OpenBSD: yppush.h,v 1.4 2000/10/12 09:47:27 deraadt Exp $ */
/*
* Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
@@ -107,4 +107,6 @@ extern void * yppushproc_xfrresp_1();
extern void * yppushproc_xfrresp_1_svc();
#endif /* Old Style C */
+char * yppush_err_string(enum yppush_status y);
+
#endif /* !_YPPUSH_H_RPCGEN */
diff --git a/usr.sbin/ypserv/yppush/yppush_err.c b/usr.sbin/ypserv/yppush/yppush_err.c
index 4f32648b134..070bba2a9ab 100644
--- a/usr.sbin/ypserv/yppush/yppush_err.c
+++ b/usr.sbin/ypserv/yppush/yppush_err.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yppush_err.c,v 1.2 1996/05/30 09:53:20 deraadt Exp $ */
+/* $OpenBSD: yppush_err.c,v 1.3 2000/10/12 09:47:27 deraadt Exp $ */
/*
* Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
@@ -32,45 +32,49 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: yppush_err.c,v 1.2 1996/05/30 09:53:20 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: yppush_err.c,v 1.3 2000/10/12 09:47:27 deraadt Exp $";
#endif /* not lint */
#include <rpcsvc/yp.h>
char *
-yppush_err_string(enum yppush_status y) {
+yppush_err_string(y)
+ enum yppush_status y;
+{
+
switch(y) {
case YPPUSH_SUCC:
- return "Success";
+ return ("Success");
case YPPUSH_AGE:
- return "Master's version not newer";
+ return ("Master's version not newer");
case YPPUSH_NOMAP:
- return "Can't find server for map";
+ return ("Can't find server for map");
case YPPUSH_NODOM:
- return "Domain not supported";
+ return ("Domain not supported");
case YPPUSH_RSRC:
- return "Local resource alloc failure";
+ return ("Local resource alloc failure");
case YPPUSH_RPC:
- return "RPC failure talking to server";
+ return ("RPC failure talking to server");
case YPPUSH_MADDR:
- return "Can't get master address";
+ return ("Can't get master address");
case YPPUSH_YPERR:
- return "YP server/map db error";
+ return ("YP server/map db error");
case YPPUSH_BADARGS:
- return "Request arguments bad";
+ return ("Request arguments bad");
case YPPUSH_DBM:
- return "Local dbm operation failed";
+ return ("Local dbm operation failed");
case YPPUSH_FILE:
- return "Local file I/O operation failed";
+ return ("Local file I/O operation failed");
case YPPUSH_SKEW:
- return "Map version skew during transfer";
+ return ("Map version skew during transfer");
case YPPUSH_CLEAR:
- return "Can't send \"Clear\" req to local ypserv";
+ return ("Can't send \"Clear\" req to local ypserv");
case YPPUSH_FORCE:
- return "No local order number in map use -f flag.";
+ return ("No local order number in map use -f flag.");
case YPPUSH_XFRERR:
- return "ypxfr error";
+ return ("ypxfr error");
case YPPUSH_REFUSED:
- return "Transfer request refused by ypserv";
+ return ("Transfer request refused by ypserv");
}
-};
+ return ("unknown error");
+}
diff --git a/usr.sbin/ypserv/yppush/yppush_proc.c b/usr.sbin/ypserv/yppush/yppush_proc.c
index 496723bce65..6b5cab3abae 100644
--- a/usr.sbin/ypserv/yppush/yppush_proc.c
+++ b/usr.sbin/ypserv/yppush/yppush_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yppush_proc.c,v 1.3 1997/08/21 12:52:08 maja Exp $ */
+/* $OpenBSD: yppush_proc.c,v 1.4 2000/10/12 09:47:28 deraadt Exp $ */
/*
* Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: yppush_proc.c,v 1.3 1997/08/21 12:52:08 maja Exp $";
+static char rcsid[] = "$OpenBSD: yppush_proc.c,v 1.4 2000/10/12 09:47:28 deraadt Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -65,9 +65,9 @@ yppushproc_xfrresp_1_svc(argp, rqstp)
/*
* insert server code here
*/
- if ((argp->status<YPPUSH_SUCC) || Verbose)
- fprintf(stderr,"yppush: %s\n",
- yppush_err_string(argp->status));
+ if ((argp->status < YPPUSH_SUCC) || Verbose)
+ fprintf(stderr, "yppush: %s\n",
+ yppush_err_string(argp->status));
return((void*) &result);
}
diff --git a/usr.sbin/ypserv/yppush/yppush_svc.c b/usr.sbin/ypserv/yppush/yppush_svc.c
index 3d67eadd507..f54abd9fca2 100644
--- a/usr.sbin/ypserv/yppush/yppush_svc.c
+++ b/usr.sbin/ypserv/yppush/yppush_svc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yppush_svc.c,v 1.3 2000/06/28 23:58:24 deraadt Exp $ */
+/* $OpenBSD: yppush_svc.c,v 1.4 2000/10/12 09:47:28 deraadt Exp $ */
/*
* Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
@@ -32,24 +32,21 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: yppush_svc.c,v 1.3 2000/06/28 23:58:24 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: yppush_svc.c,v 1.4 2000/10/12 09:47:28 deraadt Exp $";
#endif /* not lint */
#include "yppush.h"
+
+#include <sys/types.h>
+#include <sys/ttycom.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <stdio.h>
-#include <stdlib.h>/* getenv, exit */
+#include <stdlib.h>
#include <netdb.h>
#include <signal.h>
-#include <sys/ttycom.h>/* TIOCNOTTY */
#include <memory.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#ifdef SYSLOG
#include <syslog.h>
-#else
-#define LOG_ERR 1
-#define openlog(a, b, c)
-#endif
#ifdef __STDC__
#define SIG_PF void(*)(int)
diff --git a/usr.sbin/ypserv/yppush/yppush_xdr.c b/usr.sbin/ypserv/yppush/yppush_xdr.c
index 155283e53f1..e25e993b789 100644
--- a/usr.sbin/ypserv/yppush/yppush_xdr.c
+++ b/usr.sbin/ypserv/yppush/yppush_xdr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yppush_xdr.c,v 1.2 1996/05/30 09:53:22 deraadt Exp $ */
+/* $OpenBSD: yppush_xdr.c,v 1.3 2000/10/12 09:47:28 deraadt Exp $ */
/*
* Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
@@ -32,7 +32,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: yppush_xdr.c,v 1.2 1996/05/30 09:53:22 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: yppush_xdr.c,v 1.3 2000/10/12 09:47:28 deraadt Exp $";
#endif
#include <rpc/rpc.h>
@@ -116,11 +116,8 @@ xdr_yppush_status(xdrs, objp)
XDR *xdrs;
yppush_status *objp;
{
- register long *buf;
-
- if (!xdr_enum(xdrs, (enum_t *)objp)) {
- return (FALSE);
- }
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
return (TRUE);
}
@@ -130,14 +127,10 @@ xdr_yppushresp_xfr(xdrs, objp)
yppushresp_xfr *objp;
{
- register long *buf;
-
- if (!xdr_u_int(xdrs, &objp->transid)) {
- return (FALSE);
- }
- if (!xdr_yppush_status(xdrs, &objp->status)) {
- return (FALSE);
- }
+ if (!xdr_u_int(xdrs, &objp->transid))
+ return (FALSE);
+ if (!xdr_yppush_status(xdrs, &objp->status))
+ return (FALSE);
return (TRUE);
}