]>
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 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 /* $OpenBSD: ypserv_proc.c,v 1.14 1997/09/12 01:44:57 deraadt Exp $ */
28 * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se>
29 * All rights reserved.
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
34 * 1. Redistributions of source code must retain the above copyright
35 * notice, this list of conditions and the following disclaimer.
36 * 2. Redistributions in binary form must reproduce the above copyright
37 * notice, this list of conditions and the following disclaimer in the
38 * documentation and/or other materials provided with the distribution.
39 * 3. All advertising materials mentioning features or use of this software
40 * must display the following acknowledgement:
41 * This product includes software developed by Mats O Jansson
42 * 4. The name of the author may not be used to endorse or promote products
43 * derived from this software without specific prior written permission.
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
46 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
49 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 static char rcsid
[] = "$OpenBSD: ypserv_proc.c,v 1.14 1997/09/12 01:44:57 deraadt Exp $";
65 #include <rpcsvc/ypclnt.h>
67 #include <sys/socket.h>
68 #include <sys/param.h>
69 #include <netinet/in.h>
70 #include <arpa/inet.h>
84 #define YPLOG if (!ok) yplog
87 extern ypresp_val
ypdb_get_record();
88 extern ypresp_key_val
ypdb_get_first();
89 extern ypresp_key_val
ypdb_get_next();
90 extern ypresp_order
ypdb_get_order();
91 extern ypresp_master
ypdb_get_master();
92 extern bool_t
ypdb_xdr_get_all();
93 extern void ypdb_close_all();
94 extern int ypdb_secure();
96 static char *True
= "true";
97 static char *False
= "FALSE";
98 #define TORF(N) ((N) ? True : False)
100 ypproc_null_2_svc(argp
, rqstp
)
102 struct svc_req
*rqstp
;
105 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
106 int ok
= acl_check_host(&caller
->sin_addr
);
108 YPLOG("null_2: caller=[%s].%d, auth_ok=%s",
109 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
));
112 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
118 return ((void *)&result
);
122 ypproc_domain_2_svc(argp
, rqstp
)
124 struct svc_req
*rqstp
;
126 static bool_t result
; /* is domain_served? */
127 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
128 int ok
= acl_check_host(&caller
->sin_addr
);
129 static char domain_path
[MAXPATHLEN
];
132 if (strchr(*argp
, '/'))
134 snprintf(domain_path
, sizeof(domain_path
), "%s/%s", YP_DB_PATH
, *argp
);
135 result
= (bool_t
) ((stat(domain_path
, &finfo
) == 0) &&
136 (finfo
.st_mode
& S_IFDIR
));
138 YPLOG("domain_2: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s",
139 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
140 TORF(ok
), *argp
, TORF(result
));
144 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
152 ypproc_domain_nonack_2_svc(argp
, rqstp
)
154 struct svc_req
*rqstp
;
156 static bool_t result
; /* is domain served? */
157 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
158 int ok
= acl_check_host(&caller
->sin_addr
);
159 static char domain_path
[MAXPATHLEN
];
162 if (strchr(*argp
, '/'))
164 snprintf(domain_path
, sizeof(domain_path
), "%s/%s", YP_DB_PATH
, *argp
);
165 result
= (bool_t
) ((stat(domain_path
, &finfo
) == 0) &&
166 (finfo
.st_mode
& S_IFDIR
));
169 "domain_nonack_2: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s",
170 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
171 *argp
, TORF(result
));
175 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
180 return(NULL
); /* don't send nack */
187 ypproc_match_2_svc(argp
, rqstp
)
189 struct svc_req
*rqstp
;
191 static ypresp_val res
;
192 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
193 int ok
= acl_check_host(&caller
->sin_addr
);
194 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
196 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
199 "match_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s",
200 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
201 TORF(ok
), TORF(secure
),
202 argp
->domain
, argp
->map
, argp
->key
.keydat_len
, argp
->key
.keydat_val
);
206 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
210 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
213 res
= ypdb_get_record(argp
->domain
,argp
->map
,argp
->key
, FALSE
);
217 yplog(" match2_status: %s", yperr_string(ypprot_err(res
.stat
)));
224 ypproc_first_2_svc(argp
, rqstp
)
226 struct svc_req
*rqstp
;
228 static ypresp_key_val res
;
229 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
230 int ok
= acl_check_host(&caller
->sin_addr
);
231 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
233 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
235 YPLOG( "first_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
236 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
237 TORF(ok
), TORF(secure
),
238 argp
->domain
, argp
->map
);
242 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
246 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
249 res
= ypdb_get_first(argp
->domain
,argp
->map
,FALSE
);
253 yplog(" first2_status: %s", yperr_string(ypprot_err(res
.stat
)));
260 ypproc_next_2_svc(argp
, rqstp
)
262 struct svc_req
*rqstp
;
264 static ypresp_key_val res
;
265 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
266 int ok
= acl_check_host(&caller
->sin_addr
);
267 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
269 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
272 "next_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s",
273 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
274 TORF(ok
), TORF(secure
),
275 argp
->domain
, argp
->map
, argp
->key
.keydat_len
, argp
->key
.keydat_val
);
279 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
283 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
286 res
= ypdb_get_next(argp
->domain
,argp
->map
,argp
->key
,FALSE
);
290 yplog(" next2_status: %s", yperr_string(ypprot_err(res
.stat
)));
297 ypproc_xfr_2_svc(argp
, rqstp
)
299 struct svc_req
*rqstp
;
301 static ypresp_xfr res
;
302 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
303 int ok
= acl_check_host(&caller
->sin_addr
);
308 char ypxfr_proc
[] = YPXFR_PROC
;
311 bzero((char *)&res
, sizeof(res
));
313 YPLOG("xfr_2: caller=[%s].%d, auth_ok=%s, domain=%s, tid=%d, prog=%d",
314 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
315 argp
->map_parms
.domain
, argp
->transid
, argp
->prog
);
316 YPLOG(" ipadd=%s, port=%d, map=%s", inet_ntoa(caller
->sin_addr
),
317 argp
->port
, argp
->map_parms
.map
);
319 if (strchr(argp
->map_parms
.domain
, '/') ||
320 strchr(argp
->map_parms
.map
, '/') ||
321 ntohs(caller
->sin_port
) >= IPPORT_RESERVED
) {
322 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
326 snprintf(tid
, sizeof(tid
), "%d",argp
->transid
);
327 snprintf(prog
, sizeof(prog
), "%d", argp
->prog
);
328 snprintf(port
, sizeof(port
), "%d", argp
->port
);
329 ipadd
= inet_ntoa(caller
->sin_addr
);
333 svcerr_systemerr(rqstp
->rq_xprt
);
337 execl(ypxfr_proc
, "ypxfr", "-d", argp
->map_parms
.domain
,
338 "-C",tid
, prog
, ipadd
, port
, argp
->map_parms
.map
, NULL
);
349 ypproc_clear_2_svc(argp
, rqstp
)
351 struct svc_req
*rqstp
;
354 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
355 int ok
= acl_check_host(&caller
->sin_addr
);
357 YPLOG( "clear_2: caller=[%s].%d, auth_ok=%s, opt=%s",
358 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
366 if (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)
370 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
380 return ((void *)&res
);
384 ypproc_all_2_svc(argp
, rqstp
)
386 struct svc_req
*rqstp
;
388 static ypresp_all res
;
390 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
391 int ok
= acl_check_host(&caller
->sin_addr
);
392 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
394 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
396 YPLOG( "all_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
397 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
398 TORF(ok
), TORF(secure
), argp
->domain
, argp
->map
);
402 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
406 bzero((char *)&res
, sizeof(res
));
408 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
409 res
.ypresp_all_u
.val
.stat
= YP_YPERR
;
418 /* XXXCDC An error has occurred */
421 return(NULL
); /* PARENT: continue */
424 /* CHILD: send result, then exit */
426 if (!svc_sendreply(rqstp
->rq_xprt
, ypdb_xdr_get_all
, (char *) argp
)) {
427 svcerr_systemerr(rqstp
->rq_xprt
);
430 /* note: no need to free args, we are exiting */
436 ypproc_master_2_svc(argp
, rqstp
)
438 struct svc_req
*rqstp
;
440 static ypresp_master res
;
441 static peername nopeer
= "";
442 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
443 int ok
= acl_check_host(&caller
->sin_addr
);
444 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
446 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
448 YPLOG( "master_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
449 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
450 TORF(ok
), TORF(secure
), argp
->domain
, argp
->map
);
454 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
458 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
461 res
= ypdb_get_master(argp
->domain
,argp
->map
);
465 yplog(" master2_status: %s", yperr_string(ypprot_err(res
.stat
)));
468 /* This code was added because a yppoll <unknown-domain> */
469 /* from a sun crashed the server in xdr_string, trying */
470 /* to access the peer through a NULL-pointer. yppoll in */
471 /* this server start asking for order. If order is ok */
472 /* then it will ask for master. SunOS 4 asks for both */
473 /* always. I'm not sure this is the best place for the */
474 /* fix, but for now it will do. xdr_peername or */
475 /* xdr_string in ypserv_xdr.c may be a better place? */
477 if (res
.peer
== NULL
) {
488 ypproc_order_2_svc(argp
, rqstp
)
490 struct svc_req
*rqstp
;
492 static ypresp_order res
;
493 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
494 int ok
= acl_check_host(&caller
->sin_addr
);
495 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
497 if (strchr(argp
->domain
, '/'))
499 YPLOG( "order_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
500 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
501 TORF(ok
), TORF(secure
), argp
->domain
, argp
->map
);
505 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
509 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
511 } else if (strchr(argp
->map
, '/')) {
514 res
= ypdb_get_order(argp
->domain
,argp
->map
);
518 yplog(" order2_status: %s", yperr_string(ypprot_err(res
.stat
)));
526 ypproc_maplist_2_svc(argp
, rqstp
)
528 struct svc_req
*rqstp
;
530 static ypresp_maplist res
;
531 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
532 int ok
= acl_check_host(&caller
->sin_addr
);
533 static char domain_path
[MAXPATHLEN
];
542 if (strchr(*argp
, '/'))
544 YPLOG("maplist_2: caller=[%s].%d, auth_ok=%s, domain=%s",
545 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
550 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
554 bzero((char *)&res
, sizeof(res
));
556 snprintf(domain_path
,MAXPATHLEN
, "%s/%s",YP_DB_PATH
,*argp
);
562 if (!((stat(domain_path
, &finfo
) == 0) &&
563 ((finfo
.st_mode
& S_IFMT
) == S_IFDIR
)))
567 if ((dirp
= opendir(domain_path
)) == NULL
) {
573 for(dp
= readdir(dirp
); dp
!= NULL
; dp
= readdir(dirp
)) {
574 if ((!strcmp(dp
->d_name
, ".")) ||
575 ((!strcmp(dp
->d_name
, ".."))) ||
578 suffix
= (char *) &dp
->d_name
[dp
->d_namlen
-3];
579 if (strcmp(suffix
,".db") == 0) {
581 if ((m
= (struct ypmaplist
*)
582 malloc((unsigned) sizeof(struct ypmaplist
))) == NULL
) {
587 if ((map_name
= (char *)
588 malloc((unsigned) dp
->d_namlen
- 2)) == NULL
) {
596 strncpy(map_name
, dp
->d_name
, dp
->d_namlen
- 3);
597 m
->map
[dp
->d_namlen
- 3] = '\0';
610 yplog(" maplist_status: %s", yperr_string(ypprot_err(res
.stat
)));
617 ypproc_null_1_svc(argp
, rqstp
)
619 struct svc_req
*rqstp
;
622 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
623 int ok
= acl_check_host(&caller
->sin_addr
);
625 YPLOG("null_1: caller=[%s].%d, auth_ok=%s",
626 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
));
629 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
635 return ((void *)&result
);
639 ypproc_domain_1_svc(argp
, rqstp
)
641 struct svc_req
*rqstp
;
643 static bool_t result
; /* is domain_served? */
644 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
645 int ok
= acl_check_host(&caller
->sin_addr
);
646 static char domain_path
[MAXPATHLEN
];
649 if (strchr(*argp
, '/'))
651 snprintf(domain_path
, sizeof(domain_path
), "%s/%s", YP_DB_PATH
, *argp
);
652 result
= (bool_t
) ((stat(domain_path
, &finfo
) == 0) &&
653 (finfo
.st_mode
& S_IFDIR
));
655 YPLOG("domain_1: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s",
656 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
657 TORF(ok
), *argp
, TORF(result
));
661 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
669 ypproc_domain_nonack_1_svc(argp
, rqstp
)
671 struct svc_req
*rqstp
;
673 static bool_t result
; /* is domain served? */
674 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
675 int ok
= acl_check_host(&caller
->sin_addr
);
676 static char domain_path
[MAXPATHLEN
];
679 if (strchr(*argp
, '/'))
681 snprintf(domain_path
, sizeof(domain_path
), "%s/%s", YP_DB_PATH
, *argp
);
682 result
= (bool_t
) ((stat(domain_path
, &finfo
) == 0) &&
683 (finfo
.st_mode
& S_IFDIR
));
686 "domain_nonack_1: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s",
687 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
688 *argp
, TORF(result
));
692 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
697 return(NULL
); /* don't send nack */
704 ypproc_match_1_svc(argp
, rqstp
)
706 struct svc_req
*rqstp
;
708 static ypresponse res
;
709 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
710 int ok
= acl_check_host(&caller
->sin_addr
);
713 if (strchr(argp
->ypmatch_req_domain
, '/') ||
714 strchr(argp
->ypmatch_req_map
, '/'))
716 res
.yp_resptype
= YPMATCH_RESPTYPE
;
717 res
.ypmatch_resp_valptr
= "";
718 res
.ypmatch_resp_valsize
= 0;
720 if (argp
->yp_reqtype
!= YPMATCH_REQTYPE
) {
721 res
.ypmatch_resp_status
= YP_BADARGS
;
725 secure
= ypdb_secure(argp
->ypmatch_req_domain
, argp
->ypmatch_req_map
);
728 "match_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s",
729 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
730 TORF(ok
), TORF(secure
),
731 argp
->ypmatch_req_domain
, argp
->ypmatch_req_map
,
732 argp
->ypmatch_req_keysize
, argp
->ypmatch_req_keyptr
);
736 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
740 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
741 res
.ypmatch_resp_status
= YP_YPERR
;
743 res
.ypmatch_resp_val
=
744 ypdb_get_record(argp
->ypmatch_req_domain
,
745 argp
->ypmatch_req_map
,
746 argp
->ypmatch_req_keydat
,
751 yplog(" match1_status: %s",
752 yperr_string(ypprot_err(res
.ypmatch_resp_status
)));
759 ypproc_first_1_svc(argp
, rqstp
)
761 struct svc_req
*rqstp
;
763 static ypresponse res
;
764 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
765 int ok
= acl_check_host(&caller
->sin_addr
);
768 if (strchr(argp
->ypfirst_req_domain
, '/') ||
769 strchr(argp
->ypfirst_req_map
, '/'))
771 res
.yp_resptype
= YPFIRST_RESPTYPE
;
772 res
.ypfirst_resp_valptr
= res
.ypfirst_resp_keyptr
= "";
773 res
.ypfirst_resp_valsize
= res
.ypfirst_resp_keysize
= 0;
775 if (argp
->yp_reqtype
!= YPREQ_NOKEY
) {
776 res
.ypfirst_resp_status
= YP_BADARGS
;
780 secure
= ypdb_secure(argp
->ypfirst_req_domain
, argp
->ypfirst_req_map
);
782 YPLOG( "first_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
783 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
784 TORF(ok
), TORF(secure
),
785 argp
->ypfirst_req_domain
, argp
->ypfirst_req_map
);
789 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
793 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
794 res
.ypfirst_resp_status
= YP_YPERR
;
796 res
.ypfirst_resp_val
=
797 ypdb_get_first(argp
->ypfirst_req_domain
,
798 argp
->ypfirst_req_map
,
803 yplog(" first1_status: %s",
804 yperr_string(ypprot_err(res
.ypfirst_resp_status
)));
811 ypproc_next_1_svc(argp
, rqstp
)
813 struct svc_req
*rqstp
;
815 static ypresponse res
;
816 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
817 int ok
= acl_check_host(&caller
->sin_addr
);
820 if (strchr(argp
->ypnext_req_domain
, '/') ||
821 strchr(argp
->ypnext_req_map
, '/'))
823 res
.yp_resptype
= YPNEXT_RESPTYPE
;
824 res
.ypnext_resp_valptr
= res
.ypnext_resp_keyptr
= "";
825 res
.ypnext_resp_valsize
= res
.ypnext_resp_keysize
= 0;
827 if (argp
->yp_reqtype
!= YPNEXT_REQTYPE
) {
828 res
.ypnext_resp_status
= YP_BADARGS
;
832 secure
= ypdb_secure(argp
->ypnext_req_domain
, argp
->ypnext_req_map
);
835 "next_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s",
836 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
837 TORF(ok
), TORF(secure
),
838 argp
->ypnext_req_domain
, argp
->ypnext_req_map
,
839 argp
->ypnext_req_keysize
, argp
->ypnext_req_keyptr
);
843 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
847 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
848 res
.ypnext_resp_status
= YP_YPERR
;
850 res
.ypnext_resp_val
=
851 ypdb_get_next(argp
->ypnext_req_domain
,
852 argp
->ypnext_req_map
,
853 argp
->ypnext_req_keydat
,
858 yplog(" next1_status: %s",
859 yperr_string(ypprot_err(res
.ypnext_resp_status
)));
866 ypproc_poll_1_svc(argp
, rqstp
)
868 struct svc_req
*rqstp
;
870 static ypresponse res
;
872 ypresp_master master
;
873 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
874 int ok
= acl_check_host(&caller
->sin_addr
);
877 if (strchr(argp
->yppoll_req_domain
, '/') ||
878 strchr(argp
->yppoll_req_map
, '/'))
880 res
.yp_resptype
= YPPOLL_RESPTYPE
;
881 res
.yppoll_resp_domain
= argp
->yppoll_req_domain
;
882 res
.yppoll_resp_map
= argp
->yppoll_req_map
;
883 res
.yppoll_resp_ordernum
= 0;
884 res
.yppoll_resp_owner
= "";
886 if (argp
->yp_reqtype
!= YPPOLL_REQTYPE
) {
890 secure
= ypdb_secure(argp
->yppoll_req_domain
, argp
->yppoll_req_map
);
892 YPLOG( "poll_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
893 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
894 TORF(ok
), TORF(secure
),
895 argp
->yppoll_req_domain
, argp
->yppoll_req_map
);
899 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
903 if (!(secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
))) {
904 order
= ypdb_get_order(argp
->yppoll_req_domain
,
905 argp
->yppoll_req_map
);
906 master
= ypdb_get_master(argp
->yppoll_req_domain
,
907 argp
->yppoll_req_map
);
908 res
.yppoll_resp_ordernum
= order
.ordernum
;
909 res
.yppoll_resp_owner
= master
.peer
;
913 yplog(" poll1_status: %s", "none");
919 ypproc_push_1_svc(argp
, rqstp
)
921 struct svc_req
*rqstp
;
923 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
924 int ok
= acl_check_host(&caller
->sin_addr
);
927 char yppush_proc
[] = YPPUSH_PROC
;
929 if (strchr(argp
->yppush_req_domain
, '/') ||
930 strchr(argp
->yppush_req_map
, '/'))
932 if (argp
->yp_reqtype
!= YPPUSH_REQTYPE
) {
936 secure
= ypdb_secure(argp
->yppush_req_domain
, argp
->yppush_req_map
);
938 YPLOG( "push_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
939 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
940 TORF(ok
), TORF(secure
),
941 argp
->yppush_req_domain
, argp
->yppush_req_map
);
943 if (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)
948 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
954 svcerr_systemerr(rqstp
->rq_xprt
);
958 execl(yppush_proc
, "yppush", "-d", argp
->yppush_req_domain
,
959 argp
->yppush_req_map
, NULL
);
967 ypproc_pull_1_svc(argp
, rqstp
)
969 struct svc_req
*rqstp
;
971 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
972 int ok
= acl_check_host(&caller
->sin_addr
);
975 char ypxfr_proc
[] = YPXFR_PROC
;
977 if (strchr(argp
->yppull_req_domain
, '/') ||
978 strchr(argp
->yppull_req_map
, '/'))
980 if (argp
->yp_reqtype
!= YPPULL_REQTYPE
) {
984 secure
= ypdb_secure(argp
->yppull_req_domain
, argp
->yppull_req_map
);
986 YPLOG( "pull_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
987 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
988 TORF(ok
), TORF(secure
),
989 argp
->yppull_req_domain
, argp
->yppull_req_map
);
991 if (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)
996 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
1002 svcerr_systemerr(rqstp
->rq_xprt
);
1006 execl(ypxfr_proc
, "ypxfr", "-d", argp
->yppull_req_domain
,
1007 argp
->yppull_req_map
, NULL
);
1015 ypproc_get_1_svc(argp
, rqstp
)
1017 struct svc_req
*rqstp
;
1020 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
1021 int ok
= acl_check_host(&caller
->sin_addr
);
1024 char ypxfr_proc
[] = YPXFR_PROC
;
1026 if (strchr(argp
->ypget_req_domain
, '/') ||
1027 strchr(argp
->ypget_req_map
, '/'))
1029 if (argp
->yp_reqtype
!= YPGET_REQTYPE
) {
1033 secure
= ypdb_secure(argp
->ypget_req_domain
, argp
->ypget_req_map
);
1035 YPLOG( "get_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, owner=%s",
1036 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
1037 TORF(ok
), TORF(secure
),
1038 argp
->ypget_req_domain
, argp
->ypget_req_map
,
1039 argp
->ypget_req_owner
);
1041 if (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)
1046 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
1052 svcerr_systemerr(rqstp
->rq_xprt
);
1056 execl(ypxfr_proc
, "ypxfr", "-d", argp
->ypget_req_domain
, "-h",
1057 argp
->ypget_req_owner
, argp
->yppush_req_map
, NULL
);