Deleted Added
full compact
yppush_main.c (77838) yppush_main.c (90297)
1/*
2 * Copyright (c) 1995
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#ifndef lint
34static const char rcsid[] =
1/*
2 * Copyright (c) 1995
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#ifndef lint
34static const char rcsid[] =
35 "$FreeBSD: head/usr.sbin/yppush/yppush_main.c 77838 2001-06-06 21:08:15Z jdp $";
35 "$FreeBSD: head/usr.sbin/yppush/yppush_main.c 90297 2002-02-06 13:30:31Z des $";
36#endif /* not lint */
37
38#include <errno.h>
39#include <signal.h>
40#include <stdio.h>
41#include <stdlib.h>
42#include <string.h>
43#include <time.h>

--- 42 unchanged lines hidden (view full) ---

86struct jobs *yppush_joblist; /* Linked list of running jobs. */
87
88/*
89 * Local error messages.
90 */
91static char *yppusherr_string(err)
92 int err;
93{
36#endif /* not lint */
37
38#include <errno.h>
39#include <signal.h>
40#include <stdio.h>
41#include <stdlib.h>
42#include <string.h>
43#include <time.h>

--- 42 unchanged lines hidden (view full) ---

86struct jobs *yppush_joblist; /* Linked list of running jobs. */
87
88/*
89 * Local error messages.
90 */
91static char *yppusherr_string(err)
92 int err;
93{
94 switch(err) {
94 switch (err) {
95 case YPPUSH_TIMEDOUT: return("transfer or callback timed out");
96 case YPPUSH_YPSERV: return("failed to contact ypserv");
97 case YPPUSH_NOHOST: return("no such host");
98 case YPPUSH_PMAP: return("portmapper failure");
99 default: return("unknown error code");
100 }
101}
102
103/*
104 * Report state of a job.
105 */
106static int yppush_show_status(status, tid)
107 ypxfrstat status;
108 unsigned long tid;
109{
110 struct jobs *job;
111
112 job = yppush_joblist;
113
95 case YPPUSH_TIMEDOUT: return("transfer or callback timed out");
96 case YPPUSH_YPSERV: return("failed to contact ypserv");
97 case YPPUSH_NOHOST: return("no such host");
98 case YPPUSH_PMAP: return("portmapper failure");
99 default: return("unknown error code");
100 }
101}
102
103/*
104 * Report state of a job.
105 */
106static int yppush_show_status(status, tid)
107 ypxfrstat status;
108 unsigned long tid;
109{
110 struct jobs *job;
111
112 job = yppush_joblist;
113
114 while(job) {
114 while (job) {
115 if (job->tid == tid)
116 break;
117 job = job->next;
118 }
119
120 if (job->polled) {
121 return(0);
122 }
123
124 if (verbose > 1)
125 yp_error("checking return status: transaction ID: %lu",
126 job->tid);
127 if (status != YPPUSH_SUCC || verbose) {
128 yp_error("transfer of map %s to server %s %s",
129 job->map, job->server, status == YPPUSH_SUCC ?
130 "succeeded" : "failed");
131 yp_error("status returned by ypxfr: %s", status > YPPUSH_AGE ?
115 if (job->tid == tid)
116 break;
117 job = job->next;
118 }
119
120 if (job->polled) {
121 return(0);
122 }
123
124 if (verbose > 1)
125 yp_error("checking return status: transaction ID: %lu",
126 job->tid);
127 if (status != YPPUSH_SUCC || verbose) {
128 yp_error("transfer of map %s to server %s %s",
129 job->map, job->server, status == YPPUSH_SUCC ?
130 "succeeded" : "failed");
131 yp_error("status returned by ypxfr: %s", status > YPPUSH_AGE ?
132 yppusherr_string(status) :
132 yppusherr_string(status) :
133 ypxfrerr_string(status));
134 }
135
136 job->polled = 1;
137
138 svc_unregister(job->prognum, 1);
133 ypxfrerr_string(status));
134 }
135
136 job->polled = 1;
137
138 svc_unregister(job->prognum, 1);
139
139
140 yppush_running_jobs--;
141 return(0);
142}
143
144/* Exit routine. */
145static void yppush_exit(now)
146 int now;
147{
148 struct jobs *jptr;
149 int still_pending = 1;
150
151 /* Let all the information trickle in. */
140 yppush_running_jobs--;
141 return(0);
142}
143
144/* Exit routine. */
145static void yppush_exit(now)
146 int now;
147{
148 struct jobs *jptr;
149 int still_pending = 1;
150
151 /* Let all the information trickle in. */
152 while(!now && still_pending) {
152 while (!now && still_pending) {
153 jptr = yppush_joblist;
154 still_pending = 0;
155 while (jptr) {
156 if (jptr->polled == 0) {
157 still_pending++;
158 if (verbose > 1)
159 yp_error("%s has not responded",
160 jptr->server);

--- 22 unchanged lines hidden (view full) ---

183 yp_error("all transfers complete");
184 break;
185 }
186 }
187
188
189 /* All stats collected and reported -- kill all the stragglers. */
190 jptr = yppush_joblist;
153 jptr = yppush_joblist;
154 still_pending = 0;
155 while (jptr) {
156 if (jptr->polled == 0) {
157 still_pending++;
158 if (verbose > 1)
159 yp_error("%s has not responded",
160 jptr->server);

--- 22 unchanged lines hidden (view full) ---

183 yp_error("all transfers complete");
184 break;
185 }
186 }
187
188
189 /* All stats collected and reported -- kill all the stragglers. */
190 jptr = yppush_joblist;
191 while(jptr) {
191 while (jptr) {
192 if (!jptr->polled)
193 yp_error("warning: exiting with transfer \
194to %s (transid = %lu) still pending", jptr->server, jptr->tid);
195 svc_unregister(jptr->prognum, 1);
196 jptr = jptr->next;
197 }
198
199 exit(0);

--- 21 unchanged lines hidden (view full) ---

221
222/*
223 * Dispatch loop for callback RPC services.
224 */
225static void yppush_svc_run()
226{
227#ifdef FD_SETSIZE
228 fd_set readfds;
192 if (!jptr->polled)
193 yp_error("warning: exiting with transfer \
194to %s (transid = %lu) still pending", jptr->server, jptr->tid);
195 svc_unregister(jptr->prognum, 1);
196 jptr = jptr->next;
197 }
198
199 exit(0);

--- 21 unchanged lines hidden (view full) ---

221
222/*
223 * Dispatch loop for callback RPC services.
224 */
225static void yppush_svc_run()
226{
227#ifdef FD_SETSIZE
228 fd_set readfds;
229#else
230 int readfds;
229#else
230 int readfds;
231#endif /* def FD_SETSIZE */
232 struct timeval timeout;
233
234 timeout.tv_usec = 0;
235 timeout.tv_sec = 5;
236
237retry:
238#ifdef FD_SETSIZE

--- 51 unchanged lines hidden (view full) ---

290{
291 static char * result;
292 yppush_show_status(argp->status, argp->transid);
293 return((void *) &result);
294}
295
296/*
297 * Transmit a YPPROC_XFR request to ypserv.
231#endif /* def FD_SETSIZE */
232 struct timeval timeout;
233
234 timeout.tv_usec = 0;
235 timeout.tv_sec = 5;
236
237retry:
238#ifdef FD_SETSIZE

--- 51 unchanged lines hidden (view full) ---

290{
291 static char * result;
292 yppush_show_status(argp->status, argp->transid);
293 return((void *) &result);
294}
295
296/*
297 * Transmit a YPPROC_XFR request to ypserv.
298 */
298 */
299static int yppush_send_xfr(job)
300 struct jobs *job;
301{
302 ypreq_xfr req;
303/* ypresp_xfr *resp; */
304 DBT key, data;
305 CLIENT *clnt;
306 struct rpc_err err;

--- 28 unchanged lines hidden (view full) ---

335 req.transid = job->tid;
336 req.prog = job->prognum;
337 req.port = job->port;
338
339 /* Get a handle to the remote ypserv. */
340 if ((clnt = clnt_create(job->server, YPPROG, YPVERS, "udp")) == NULL) {
341 yp_error("%s: %s",job->server,clnt_spcreateerror("couldn't \
342create udp handle to NIS server"));
299static int yppush_send_xfr(job)
300 struct jobs *job;
301{
302 ypreq_xfr req;
303/* ypresp_xfr *resp; */
304 DBT key, data;
305 CLIENT *clnt;
306 struct rpc_err err;

--- 28 unchanged lines hidden (view full) ---

335 req.transid = job->tid;
336 req.prog = job->prognum;
337 req.port = job->port;
338
339 /* Get a handle to the remote ypserv. */
340 if ((clnt = clnt_create(job->server, YPPROG, YPVERS, "udp")) == NULL) {
341 yp_error("%s: %s",job->server,clnt_spcreateerror("couldn't \
342create udp handle to NIS server"));
343 switch(rpc_createerr.cf_stat) {
343 switch (rpc_createerr.cf_stat) {
344 case RPC_UNKNOWNHOST:
345 job->stat = YPPUSH_NOHOST;
346 break;
347 case RPC_PMAPFAILURE:
348 job->stat = YPPUSH_PMAP;
349 break;
350 default:
351 job->stat = YPPUSH_RPC;

--- 189 unchanged lines hidden (view full) ---

541 char *name;
542 struct hostlist *next;
543 };
544 struct hostlist *yppush_hostlist = NULL;
545 struct hostlist *tmp;
546 struct sigaction sa;
547
548 while ((ch = getopt(argc, argv, "d:j:p:h:t:v")) != -1) {
344 case RPC_UNKNOWNHOST:
345 job->stat = YPPUSH_NOHOST;
346 break;
347 case RPC_PMAPFAILURE:
348 job->stat = YPPUSH_PMAP;
349 break;
350 default:
351 job->stat = YPPUSH_RPC;

--- 189 unchanged lines hidden (view full) ---

541 char *name;
542 struct hostlist *next;
543 };
544 struct hostlist *yppush_hostlist = NULL;
545 struct hostlist *tmp;
546 struct sigaction sa;
547
548 while ((ch = getopt(argc, argv, "d:j:p:h:t:v")) != -1) {
549 switch(ch) {
549 switch (ch) {
550 case 'd':
551 yppush_domain = optarg;
552 break;
553 case 'j':
554 yppush_jobs = atoi(optarg);
555 if (yppush_jobs <= 0)
556 yppush_jobs = 1;
557 break;

--- 101 unchanged lines hidden (view full) ---

659 yppush_transid = time((time_t *)NULL);
660
661 if (yppush_hostlist) {
662 /*
663 * Host list was specified on the command line:
664 * kick off the transfers by hand.
665 */
666 tmp = yppush_hostlist;
550 case 'd':
551 yppush_domain = optarg;
552 break;
553 case 'j':
554 yppush_jobs = atoi(optarg);
555 if (yppush_jobs <= 0)
556 yppush_jobs = 1;
557 break;

--- 101 unchanged lines hidden (view full) ---

659 yppush_transid = time((time_t *)NULL);
660
661 if (yppush_hostlist) {
662 /*
663 * Host list was specified on the command line:
664 * kick off the transfers by hand.
665 */
666 tmp = yppush_hostlist;
667 while(tmp) {
667 while (tmp) {
668 yppush_foreach(YP_TRUE, NULL, 0, tmp->name,
669 strlen(tmp->name));
670 tmp = tmp->next;
671 }
672 } else {
673 /*
674 * Do a yp_all() on the ypservers map and initiate a ypxfr
675 * for each one.

--- 14 unchanged lines hidden ---
668 yppush_foreach(YP_TRUE, NULL, 0, tmp->name,
669 strlen(tmp->name));
670 tmp = tmp->next;
671 }
672 } else {
673 /*
674 * Do a yp_all() on the ypservers map and initiate a ypxfr
675 * for each one.

--- 14 unchanged lines hidden ---