]>
git.saurik.com Git - apple/network_cmds.git/blob - ypserv.tproj/ypserv_proc.c
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
24 /* $OpenBSD: ypserv_proc.c,v 1.14 1997/09/12 01:44:57 deraadt Exp $ */
27 * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se>
28 * All rights reserved.
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. All advertising materials mentioning features or use of this software
39 * must display the following acknowledgement:
40 * This product includes software developed by Mats O Jansson
41 * 4. The name of the author may not be used to endorse or promote products
42 * derived from this software without specific prior written permission.
44 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
45 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
46 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
48 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 static char rcsid
[] = "$OpenBSD: ypserv_proc.c,v 1.14 1997/09/12 01:44:57 deraadt Exp $";
64 #include <rpcsvc/ypclnt.h>
66 #include <sys/socket.h>
67 #include <sys/param.h>
68 #include <netinet/in.h>
69 #include <arpa/inet.h>
83 #define YPLOG if (!ok) yplog
86 extern ypresp_val
ypdb_get_record();
87 extern ypresp_key_val
ypdb_get_first();
88 extern ypresp_key_val
ypdb_get_next();
89 extern ypresp_order
ypdb_get_order();
90 extern ypresp_master
ypdb_get_master();
91 extern bool_t
ypdb_xdr_get_all();
92 extern void ypdb_close_all();
93 extern int ypdb_secure();
95 static char *True
= "true";
96 static char *False
= "FALSE";
97 #define TORF(N) ((N) ? True : False)
99 ypproc_null_2_svc(argp
, rqstp
)
101 struct svc_req
*rqstp
;
104 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
105 int ok
= yp_acl_check_host(&caller
->sin_addr
);
107 YPLOG("null_2: caller=[%s].%d, auth_ok=%s",
108 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
));
111 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
117 return ((void *)&result
);
121 ypproc_domain_2_svc(argp
, rqstp
)
123 struct svc_req
*rqstp
;
125 static bool_t result
; /* is domain_served? */
126 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
127 int ok
= yp_acl_check_host(&caller
->sin_addr
);
128 static char domain_path
[MAXPATHLEN
];
131 if (strchr(*argp
, '/'))
133 snprintf(domain_path
, sizeof(domain_path
), "%s/%s", YP_DB_PATH
, *argp
);
134 result
= (bool_t
) ((stat(domain_path
, &finfo
) == 0) &&
135 (finfo
.st_mode
& S_IFDIR
));
137 YPLOG("domain_2: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s",
138 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
139 TORF(ok
), *argp
, TORF(result
));
143 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
151 ypproc_domain_nonack_2_svc(argp
, rqstp
)
153 struct svc_req
*rqstp
;
155 static bool_t result
; /* is domain served? */
156 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
157 int ok
= yp_acl_check_host(&caller
->sin_addr
);
158 static char domain_path
[MAXPATHLEN
];
161 if (strchr(*argp
, '/'))
163 snprintf(domain_path
, sizeof(domain_path
), "%s/%s", YP_DB_PATH
, *argp
);
164 result
= (bool_t
) ((stat(domain_path
, &finfo
) == 0) &&
165 (finfo
.st_mode
& S_IFDIR
));
168 "domain_nonack_2: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s",
169 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
170 *argp
, TORF(result
));
174 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
179 return(NULL
); /* don't send nack */
186 ypproc_match_2_svc(argp
, rqstp
)
188 struct svc_req
*rqstp
;
190 static ypresp_val res
;
191 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
192 int ok
= yp_acl_check_host(&caller
->sin_addr
);
193 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
195 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
198 "match_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s",
199 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
200 TORF(ok
), TORF(secure
),
201 argp
->domain
, argp
->map
, argp
->key
.keydat_len
, argp
->key
.keydat_val
);
205 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
209 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
212 res
= ypdb_get_record(argp
->domain
,argp
->map
,argp
->key
, FALSE
);
216 yplog(" match2_status: %s", yperr_string(ypprot_err(res
.stat
)));
223 ypproc_first_2_svc(argp
, rqstp
)
225 struct svc_req
*rqstp
;
227 static ypresp_key_val res
;
228 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
229 int ok
= yp_acl_check_host(&caller
->sin_addr
);
230 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
232 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
234 YPLOG( "first_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
235 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
236 TORF(ok
), TORF(secure
),
237 argp
->domain
, argp
->map
);
241 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
245 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
248 res
= ypdb_get_first(argp
->domain
,argp
->map
,FALSE
);
252 yplog(" first2_status: %s", yperr_string(ypprot_err(res
.stat
)));
259 ypproc_next_2_svc(argp
, rqstp
)
261 struct svc_req
*rqstp
;
263 static ypresp_key_val res
;
264 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
265 int ok
= yp_acl_check_host(&caller
->sin_addr
);
266 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
268 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
271 "next_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s",
272 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
273 TORF(ok
), TORF(secure
),
274 argp
->domain
, argp
->map
, argp
->key
.keydat_len
, argp
->key
.keydat_val
);
278 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
282 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
285 res
= ypdb_get_next(argp
->domain
,argp
->map
,argp
->key
,FALSE
);
289 yplog(" next2_status: %s", yperr_string(ypprot_err(res
.stat
)));
296 ypproc_xfr_2_svc(argp
, rqstp
)
298 struct svc_req
*rqstp
;
300 static ypresp_xfr res
;
301 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
302 int ok
= yp_acl_check_host(&caller
->sin_addr
);
307 char ypxfr_proc
[] = YPXFR_PROC
;
310 bzero((char *)&res
, sizeof(res
));
312 YPLOG("xfr_2: caller=[%s].%d, auth_ok=%s, domain=%s, tid=%d, prog=%d",
313 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
314 argp
->map_parms
.domain
, argp
->transid
, argp
->prog
);
315 YPLOG(" ipadd=%s, port=%d, map=%s", inet_ntoa(caller
->sin_addr
),
316 argp
->port
, argp
->map_parms
.map
);
318 if (strchr(argp
->map_parms
.domain
, '/') ||
319 strchr(argp
->map_parms
.map
, '/') ||
320 ntohs(caller
->sin_port
) >= IPPORT_RESERVED
) {
321 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
325 snprintf(tid
, sizeof(tid
), "%d",argp
->transid
);
326 snprintf(prog
, sizeof(prog
), "%d", argp
->prog
);
327 snprintf(port
, sizeof(port
), "%d", argp
->port
);
328 ipadd
= inet_ntoa(caller
->sin_addr
);
332 svcerr_systemerr(rqstp
->rq_xprt
);
336 execl(ypxfr_proc
, "ypxfr", "-d", argp
->map_parms
.domain
,
337 "-C",tid
, prog
, ipadd
, port
, argp
->map_parms
.map
, NULL
);
348 ypproc_clear_2_svc(argp
, rqstp
)
350 struct svc_req
*rqstp
;
353 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
354 int ok
= yp_acl_check_host(&caller
->sin_addr
);
356 YPLOG( "clear_2: caller=[%s].%d, auth_ok=%s, opt=%s",
357 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
365 if (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)
369 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
379 return ((void *)&res
);
383 ypproc_all_2_svc(argp
, rqstp
)
385 struct svc_req
*rqstp
;
387 static ypresp_all res
;
389 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
390 int ok
= yp_acl_check_host(&caller
->sin_addr
);
391 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
393 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
395 YPLOG( "all_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
396 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
397 TORF(ok
), TORF(secure
), argp
->domain
, argp
->map
);
401 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
405 bzero((char *)&res
, sizeof(res
));
407 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
408 res
.ypresp_all_u
.val
.stat
= YP_YPERR
;
417 /* XXXCDC An error has occurred */
420 return(NULL
); /* PARENT: continue */
423 /* CHILD: send result, then exit */
425 if (!svc_sendreply(rqstp
->rq_xprt
, ypdb_xdr_get_all
, (char *) argp
)) {
426 svcerr_systemerr(rqstp
->rq_xprt
);
429 /* note: no need to free args, we are exiting */
435 ypproc_master_2_svc(argp
, rqstp
)
437 struct svc_req
*rqstp
;
439 static ypresp_master res
;
440 static peername nopeer
= "";
441 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
442 int ok
= yp_acl_check_host(&caller
->sin_addr
);
443 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
445 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
447 YPLOG( "master_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
448 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
449 TORF(ok
), TORF(secure
), argp
->domain
, argp
->map
);
453 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
457 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
460 res
= ypdb_get_master(argp
->domain
,argp
->map
);
464 yplog(" master2_status: %s", yperr_string(ypprot_err(res
.stat
)));
467 /* This code was added because a yppoll <unknown-domain> */
468 /* from a sun crashed the server in xdr_string, trying */
469 /* to access the peer through a NULL-pointer. yppoll in */
470 /* this server start asking for order. If order is ok */
471 /* then it will ask for master. SunOS 4 asks for both */
472 /* always. I'm not sure this is the best place for the */
473 /* fix, but for now it will do. xdr_peername or */
474 /* xdr_string in ypserv_xdr.c may be a better place? */
476 if (res
.peer
== NULL
) {
487 ypproc_order_2_svc(argp
, rqstp
)
489 struct svc_req
*rqstp
;
491 static ypresp_order res
;
492 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
493 int ok
= yp_acl_check_host(&caller
->sin_addr
);
494 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
496 if (strchr(argp
->domain
, '/'))
498 YPLOG( "order_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
499 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
500 TORF(ok
), TORF(secure
), argp
->domain
, argp
->map
);
504 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
508 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
510 } else if (strchr(argp
->map
, '/')) {
513 res
= ypdb_get_order(argp
->domain
,argp
->map
);
517 yplog(" order2_status: %s", yperr_string(ypprot_err(res
.stat
)));
525 ypproc_maplist_2_svc(argp
, rqstp
)
527 struct svc_req
*rqstp
;
529 static ypresp_maplist res
;
530 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
531 int ok
= yp_acl_check_host(&caller
->sin_addr
);
532 static char domain_path
[MAXPATHLEN
];
541 if (strchr(*argp
, '/'))
543 YPLOG("maplist_2: caller=[%s].%d, auth_ok=%s, domain=%s",
544 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
549 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
553 bzero((char *)&res
, sizeof(res
));
555 snprintf(domain_path
,MAXPATHLEN
, "%s/%s",YP_DB_PATH
,*argp
);
561 if (!((stat(domain_path
, &finfo
) == 0) &&
562 ((finfo
.st_mode
& S_IFMT
) == S_IFDIR
)))
566 if ((dirp
= opendir(domain_path
)) == NULL
) {
572 for(dp
= readdir(dirp
); dp
!= NULL
; dp
= readdir(dirp
)) {
573 if ((!strcmp(dp
->d_name
, ".")) ||
574 ((!strcmp(dp
->d_name
, ".."))) ||
577 suffix
= (char *) &dp
->d_name
[dp
->d_namlen
-3];
578 if (strcmp(suffix
,".db") == 0) {
580 if ((m
= (struct ypmaplist
*)
581 malloc((unsigned) sizeof(struct ypmaplist
))) == NULL
) {
586 if ((map_name
= (char *)
587 malloc((unsigned) dp
->d_namlen
- 2)) == NULL
) {
595 strncpy(map_name
, dp
->d_name
, dp
->d_namlen
- 3);
596 m
->map
[dp
->d_namlen
- 3] = '\0';
609 yplog(" maplist_status: %s", yperr_string(ypprot_err(res
.stat
)));
616 ypproc_null_1_svc(argp
, rqstp
)
618 struct svc_req
*rqstp
;
621 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
622 int ok
= yp_acl_check_host(&caller
->sin_addr
);
624 YPLOG("null_1: caller=[%s].%d, auth_ok=%s",
625 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
));
628 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
634 return ((void *)&result
);
638 ypproc_domain_1_svc(argp
, rqstp
)
640 struct svc_req
*rqstp
;
642 static bool_t result
; /* is domain_served? */
643 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
644 int ok
= yp_acl_check_host(&caller
->sin_addr
);
645 static char domain_path
[MAXPATHLEN
];
648 if (strchr(*argp
, '/'))
650 snprintf(domain_path
, sizeof(domain_path
), "%s/%s", YP_DB_PATH
, *argp
);
651 result
= (bool_t
) ((stat(domain_path
, &finfo
) == 0) &&
652 (finfo
.st_mode
& S_IFDIR
));
654 YPLOG("domain_1: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s",
655 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
656 TORF(ok
), *argp
, TORF(result
));
660 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
668 ypproc_domain_nonack_1_svc(argp
, rqstp
)
670 struct svc_req
*rqstp
;
672 static bool_t result
; /* is domain served? */
673 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
674 int ok
= yp_acl_check_host(&caller
->sin_addr
);
675 static char domain_path
[MAXPATHLEN
];
678 if (strchr(*argp
, '/'))
680 snprintf(domain_path
, sizeof(domain_path
), "%s/%s", YP_DB_PATH
, *argp
);
681 result
= (bool_t
) ((stat(domain_path
, &finfo
) == 0) &&
682 (finfo
.st_mode
& S_IFDIR
));
685 "domain_nonack_1: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s",
686 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
687 *argp
, TORF(result
));
691 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
696 return(NULL
); /* don't send nack */
703 ypproc_match_1_svc(argp
, rqstp
)
705 struct svc_req
*rqstp
;
707 static ypresponse res
;
708 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
709 int ok
= yp_acl_check_host(&caller
->sin_addr
);
712 if (strchr(argp
->ypmatch_req_domain
, '/') ||
713 strchr(argp
->ypmatch_req_map
, '/'))
715 res
.yp_resptype
= YPMATCH_RESPTYPE
;
716 res
.ypmatch_resp_valptr
= "";
717 res
.ypmatch_resp_valsize
= 0;
719 if (argp
->yp_reqtype
!= YPMATCH_REQTYPE
) {
720 res
.ypmatch_resp_status
= YP_BADARGS
;
724 secure
= ypdb_secure(argp
->ypmatch_req_domain
, argp
->ypmatch_req_map
);
727 "match_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s",
728 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
729 TORF(ok
), TORF(secure
),
730 argp
->ypmatch_req_domain
, argp
->ypmatch_req_map
,
731 argp
->ypmatch_req_keysize
, argp
->ypmatch_req_keyptr
);
735 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
739 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
740 res
.ypmatch_resp_status
= YP_YPERR
;
742 res
.ypmatch_resp_val
=
743 ypdb_get_record(argp
->ypmatch_req_domain
,
744 argp
->ypmatch_req_map
,
745 argp
->ypmatch_req_keydat
,
750 yplog(" match1_status: %s",
751 yperr_string(ypprot_err(res
.ypmatch_resp_status
)));
758 ypproc_first_1_svc(argp
, rqstp
)
760 struct svc_req
*rqstp
;
762 static ypresponse res
;
763 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
764 int ok
= yp_acl_check_host(&caller
->sin_addr
);
767 if (strchr(argp
->ypfirst_req_domain
, '/') ||
768 strchr(argp
->ypfirst_req_map
, '/'))
770 res
.yp_resptype
= YPFIRST_RESPTYPE
;
771 res
.ypfirst_resp_valptr
= res
.ypfirst_resp_keyptr
= "";
772 res
.ypfirst_resp_valsize
= res
.ypfirst_resp_keysize
= 0;
774 if (argp
->yp_reqtype
!= YPREQ_NOKEY
) {
775 res
.ypfirst_resp_status
= YP_BADARGS
;
779 secure
= ypdb_secure(argp
->ypfirst_req_domain
, argp
->ypfirst_req_map
);
781 YPLOG( "first_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
782 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
783 TORF(ok
), TORF(secure
),
784 argp
->ypfirst_req_domain
, argp
->ypfirst_req_map
);
788 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
792 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
793 res
.ypfirst_resp_status
= YP_YPERR
;
795 res
.ypfirst_resp_val
=
796 ypdb_get_first(argp
->ypfirst_req_domain
,
797 argp
->ypfirst_req_map
,
802 yplog(" first1_status: %s",
803 yperr_string(ypprot_err(res
.ypfirst_resp_status
)));
810 ypproc_next_1_svc(argp
, rqstp
)
812 struct svc_req
*rqstp
;
814 static ypresponse res
;
815 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
816 int ok
= yp_acl_check_host(&caller
->sin_addr
);
819 if (strchr(argp
->ypnext_req_domain
, '/') ||
820 strchr(argp
->ypnext_req_map
, '/'))
822 res
.yp_resptype
= YPNEXT_RESPTYPE
;
823 res
.ypnext_resp_valptr
= res
.ypnext_resp_keyptr
= "";
824 res
.ypnext_resp_valsize
= res
.ypnext_resp_keysize
= 0;
826 if (argp
->yp_reqtype
!= YPNEXT_REQTYPE
) {
827 res
.ypnext_resp_status
= YP_BADARGS
;
831 secure
= ypdb_secure(argp
->ypnext_req_domain
, argp
->ypnext_req_map
);
834 "next_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s",
835 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
836 TORF(ok
), TORF(secure
),
837 argp
->ypnext_req_domain
, argp
->ypnext_req_map
,
838 argp
->ypnext_req_keysize
, argp
->ypnext_req_keyptr
);
842 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
846 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
847 res
.ypnext_resp_status
= YP_YPERR
;
849 res
.ypnext_resp_val
=
850 ypdb_get_next(argp
->ypnext_req_domain
,
851 argp
->ypnext_req_map
,
852 argp
->ypnext_req_keydat
,
857 yplog(" next1_status: %s",
858 yperr_string(ypprot_err(res
.ypnext_resp_status
)));
865 ypproc_poll_1_svc(argp
, rqstp
)
867 struct svc_req
*rqstp
;
869 static ypresponse res
;
871 ypresp_master master
;
872 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
873 int ok
= yp_acl_check_host(&caller
->sin_addr
);
876 if (strchr(argp
->yppoll_req_domain
, '/') ||
877 strchr(argp
->yppoll_req_map
, '/'))
879 res
.yp_resptype
= YPPOLL_RESPTYPE
;
880 res
.yppoll_resp_domain
= argp
->yppoll_req_domain
;
881 res
.yppoll_resp_map
= argp
->yppoll_req_map
;
882 res
.yppoll_resp_ordernum
= 0;
883 res
.yppoll_resp_owner
= "";
885 if (argp
->yp_reqtype
!= YPPOLL_REQTYPE
) {
889 secure
= ypdb_secure(argp
->yppoll_req_domain
, argp
->yppoll_req_map
);
891 YPLOG( "poll_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
892 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
893 TORF(ok
), TORF(secure
),
894 argp
->yppoll_req_domain
, argp
->yppoll_req_map
);
898 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
902 if (!(secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
))) {
903 order
= ypdb_get_order(argp
->yppoll_req_domain
,
904 argp
->yppoll_req_map
);
905 master
= ypdb_get_master(argp
->yppoll_req_domain
,
906 argp
->yppoll_req_map
);
907 res
.yppoll_resp_ordernum
= order
.ordernum
;
908 res
.yppoll_resp_owner
= master
.peer
;
912 yplog(" poll1_status: %s", "none");
918 ypproc_push_1_svc(argp
, rqstp
)
920 struct svc_req
*rqstp
;
922 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
923 int ok
= yp_acl_check_host(&caller
->sin_addr
);
926 char yppush_proc
[] = YPPUSH_PROC
;
928 if (strchr(argp
->yppush_req_domain
, '/') ||
929 strchr(argp
->yppush_req_map
, '/'))
931 if (argp
->yp_reqtype
!= YPPUSH_REQTYPE
) {
935 secure
= ypdb_secure(argp
->yppush_req_domain
, argp
->yppush_req_map
);
937 YPLOG( "push_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
938 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
939 TORF(ok
), TORF(secure
),
940 argp
->yppush_req_domain
, argp
->yppush_req_map
);
942 if (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)
947 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
953 svcerr_systemerr(rqstp
->rq_xprt
);
957 execl(yppush_proc
, "yppush", "-d", argp
->yppush_req_domain
,
958 argp
->yppush_req_map
, NULL
);
966 ypproc_pull_1_svc(argp
, rqstp
)
968 struct svc_req
*rqstp
;
970 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
971 int ok
= yp_acl_check_host(&caller
->sin_addr
);
974 char ypxfr_proc
[] = YPXFR_PROC
;
976 if (strchr(argp
->yppull_req_domain
, '/') ||
977 strchr(argp
->yppull_req_map
, '/'))
979 if (argp
->yp_reqtype
!= YPPULL_REQTYPE
) {
983 secure
= ypdb_secure(argp
->yppull_req_domain
, argp
->yppull_req_map
);
985 YPLOG( "pull_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
986 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
987 TORF(ok
), TORF(secure
),
988 argp
->yppull_req_domain
, argp
->yppull_req_map
);
990 if (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)
995 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
1001 svcerr_systemerr(rqstp
->rq_xprt
);
1005 execl(ypxfr_proc
, "ypxfr", "-d", argp
->yppull_req_domain
,
1006 argp
->yppull_req_map
, NULL
);
1014 ypproc_get_1_svc(argp
, rqstp
)
1016 struct svc_req
*rqstp
;
1019 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
1020 int ok
= yp_acl_check_host(&caller
->sin_addr
);
1023 char ypxfr_proc
[] = YPXFR_PROC
;
1025 if (strchr(argp
->ypget_req_domain
, '/') ||
1026 strchr(argp
->ypget_req_map
, '/'))
1028 if (argp
->yp_reqtype
!= YPGET_REQTYPE
) {
1032 secure
= ypdb_secure(argp
->ypget_req_domain
, argp
->ypget_req_map
);
1034 YPLOG( "get_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, owner=%s",
1035 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
1036 TORF(ok
), TORF(secure
),
1037 argp
->ypget_req_domain
, argp
->ypget_req_map
,
1038 argp
->ypget_req_owner
);
1040 if (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)
1045 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
1051 svcerr_systemerr(rqstp
->rq_xprt
);
1055 execl(ypxfr_proc
, "ypxfr", "-d", argp
->ypget_req_domain
, "-h",
1056 argp
->ypget_req_owner
, argp
->yppush_req_map
, NULL
);