Deleted Added
full compact
yp_server.c (43847) yp_server.c (46186)
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

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

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
34#ifndef lint
35static 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

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

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
34#ifndef lint
35static const char rcsid[] =
36 "$Id: yp_server.c,v 1.26 1998/02/11 19:15:32 wpaul Exp $";
36 "$Id: yp_server.c,v 1.27 1999/02/10 16:16:14 wpaul Exp $";
37#endif /* not lint */
38
39#include "yp.h"
40#include "yp_extern.h"
41#include <dirent.h>
42#include <errno.h>
43#include <stdlib.h>
44#include <sys/stat.h>
45#include <sys/param.h>
46#include <sys/types.h>
47#include <sys/socket.h>
48#include <netinet/in.h>
49#include <arpa/inet.h>
50#include <rpc/rpc.h>
51
37#endif /* not lint */
38
39#include "yp.h"
40#include "yp_extern.h"
41#include <dirent.h>
42#include <errno.h>
43#include <stdlib.h>
44#include <sys/stat.h>
45#include <sys/param.h>
46#include <sys/types.h>
47#include <sys/socket.h>
48#include <netinet/in.h>
49#include <arpa/inet.h>
50#include <rpc/rpc.h>
51
52int forked = 0;
53int children = 0;
54
55#define MASTER_STRING "YP_MASTER_NAME"
56#define MASTER_SZ sizeof(MASTER_STRING) - 1
57#define ORDER_STRING "YP_LAST_MODIFIED"
58#define ORDER_SZ sizeof(ORDER_STRING) - 1
59
52int children = 0;
53
54#define MASTER_STRING "YP_MASTER_NAME"
55#define MASTER_SZ sizeof(MASTER_STRING) - 1
56#define ORDER_STRING "YP_LAST_MODIFIED"
57#define ORDER_SZ sizeof(ORDER_STRING) - 1
58
59static pid_t yp_fork()
60{
61 if (yp_pid != getpid()) {
62 yp_error("child %d trying to fork!", getpid());
63 errno = EEXIST;
64 return(-1);
65 }
66
67 return(fork());
68}
69
60/*
61 * NIS v2 support. This is where most of the action happens.
62 */
63
64void *
65ypproc_null_2_svc(void *argp, struct svc_req *rqstp)
66{
67 static char * result;

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

345 argp->map_parms.map,
346 argp->map_parms.domain);
347 yp_error("host at %s (%s) may be pulling my leg",
348 argp->map_parms.peer,
349 inet_ntoa(rqhost->sin_addr));
350 YPXFR_RETURN(YPXFR_REFUSED)
351 }
352
70/*
71 * NIS v2 support. This is where most of the action happens.
72 */
73
74void *
75ypproc_null_2_svc(void *argp, struct svc_req *rqstp)
76{
77 static char * result;

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

355 argp->map_parms.map,
356 argp->map_parms.domain);
357 yp_error("host at %s (%s) may be pulling my leg",
358 argp->map_parms.peer,
359 inet_ntoa(rqhost->sin_addr));
360 YPXFR_RETURN(YPXFR_REFUSED)
361 }
362
353 switch(fork()) {
363 switch(yp_fork()) {
354 case 0:
355 {
356 char g[11], t[11], p[11];
357 char ypxfr_command[MAXPATHLEN + 2];
358
359 sprintf (ypxfr_command, "%sypxfr", _PATH_LIBEXEC);
360 sprintf (t, "%u", argp->transid);
361 sprintf (g, "%u", argp->prog);

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

375 execl(ypxfr_command, "ypxfr",
376 "-d", argp->map_parms.domain,
377 "-h", mres->peer,
378 "-C", t,
379 g, inet_ntoa(rqhost->sin_addr),
380 p, argp->map_parms.map,
381 NULL);
382 }
364 case 0:
365 {
366 char g[11], t[11], p[11];
367 char ypxfr_command[MAXPATHLEN + 2];
368
369 sprintf (ypxfr_command, "%sypxfr", _PATH_LIBEXEC);
370 sprintf (t, "%u", argp->transid);
371 sprintf (g, "%u", argp->prog);

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

385 execl(ypxfr_command, "ypxfr",
386 "-d", argp->map_parms.domain,
387 "-h", mres->peer,
388 "-C", t,
389 g, inet_ntoa(rqhost->sin_addr),
390 p, argp->map_parms.map,
391 NULL);
392 }
383 forked++;
384 yp_error("ypxfr execl(%s): %s", ypxfr_command, strerror(errno));
385 YPXFR_RETURN(YPXFR_XFRERR)
386 break;
387 }
388 case -1:
389 yp_error("ypxfr fork(): %s", strerror(errno));
390 YPXFR_RETURN(YPXFR_XFRERR)
391 break;
392 default:
393 result.xfrstat = YPXFR_SUCC;
394 children++;
393 yp_error("ypxfr execl(%s): %s", ypxfr_command, strerror(errno));
394 YPXFR_RETURN(YPXFR_XFRERR)
395 break;
396 }
397 case -1:
398 yp_error("ypxfr fork(): %s", strerror(errno));
399 YPXFR_RETURN(YPXFR_XFRERR)
400 break;
401 default:
402 result.xfrstat = YPXFR_SUCC;
403 children++;
395 forked = 0;
396 break;
397 }
398
399 return (&result);
400}
401#undef YPXFR_RETURN
402
403void *

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

502
503 /*
504 * The ypproc_all procedure can take a while to complete.
505 * Best to handle it in a subprocess so the parent doesn't
506 * block. (Is there a better way to do this? Maybe with
507 * async socket I/O?)
508 */
509 if (!debug) {
404 break;
405 }
406
407 return (&result);
408}
409#undef YPXFR_RETURN
410
411void *

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

510
511 /*
512 * The ypproc_all procedure can take a while to complete.
513 * Best to handle it in a subprocess so the parent doesn't
514 * block. (Is there a better way to do this? Maybe with
515 * async socket I/O?)
516 */
517 if (!debug) {
510 switch(fork()) {
518 switch(yp_fork()) {
511 case 0:
519 case 0:
512 forked++;
513 break;
514 case -1:
515 yp_error("ypall fork(): %s", strerror(errno));
516 result.ypresp_all_u.val.stat = YP_YPERR;
517 return(&result);
518 break;
519 default:
520 children++;
520 break;
521 case -1:
522 yp_error("ypall fork(): %s", strerror(errno));
523 result.ypresp_all_u.val.stat = YP_YPERR;
524 return(&result);
525 break;
526 default:
527 children++;
521 forked = 0;
522 return (NULL);
523 break;
524 }
525 }
526
527 if (yp_select_map(argp->map, argp->domain,
528 &result.ypresp_all_u.val.key, 0) != YP_TRUE) {
529 result.ypresp_all_u.val.stat = yp_errno;

--- 432 unchanged lines hidden ---
528 return (NULL);
529 break;
530 }
531 }
532
533 if (yp_select_map(argp->map, argp->domain,
534 &result.ypresp_all_u.val.key, 0) != YP_TRUE) {
535 result.ypresp_all_u.val.stat = yp_errno;

--- 432 unchanged lines hidden ---