]>
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 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 /* $OpenBSD: ypserv_proc.c,v 1.14 1997/09/12 01:44:57 deraadt Exp $ */
26 * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se>
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
32 * 1. Redistributions of source code must retain the above copyright
33 * notice, this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in the
36 * documentation and/or other materials provided with the distribution.
37 * 3. All advertising materials mentioning features or use of this software
38 * must display the following acknowledgement:
39 * This product includes software developed by Mats O Jansson
40 * 4. The name of the author may not be used to endorse or promote products
41 * derived from this software without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
44 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
45 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
47 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 static char rcsid
[] = "$OpenBSD: ypserv_proc.c,v 1.14 1997/09/12 01:44:57 deraadt Exp $";
63 #include <rpcsvc/ypclnt.h>
65 #include <sys/socket.h>
66 #include <sys/param.h>
67 #include <netinet/in.h>
68 #include <arpa/inet.h>
82 #define YPLOG if (!ok) yplog
85 extern ypresp_val
ypdb_get_record();
86 extern ypresp_key_val
ypdb_get_first();
87 extern ypresp_key_val
ypdb_get_next();
88 extern ypresp_order
ypdb_get_order();
89 extern ypresp_master
ypdb_get_master();
90 extern bool_t
ypdb_xdr_get_all();
91 extern void ypdb_close_all();
92 extern int ypdb_secure();
94 static char *True
= "true";
95 static char *False
= "FALSE";
96 #define TORF(N) ((N) ? True : False)
98 ypproc_null_2_svc(argp
, rqstp
)
100 struct svc_req
*rqstp
;
103 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
104 int ok
= yp_acl_check_host(&caller
->sin_addr
);
106 YPLOG("null_2: caller=[%s].%d, auth_ok=%s",
107 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
));
110 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
116 return ((void *)&result
);
120 ypproc_domain_2_svc(argp
, rqstp
)
122 struct svc_req
*rqstp
;
124 static bool_t result
; /* is domain_served? */
125 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
126 int ok
= yp_acl_check_host(&caller
->sin_addr
);
127 static char domain_path
[MAXPATHLEN
];
130 if (strchr(*argp
, '/'))
132 snprintf(domain_path
, sizeof(domain_path
), "%s/%s", YP_DB_PATH
, *argp
);
133 result
= (bool_t
) ((stat(domain_path
, &finfo
) == 0) &&
134 (finfo
.st_mode
& S_IFDIR
));
136 YPLOG("domain_2: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s",
137 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
138 TORF(ok
), *argp
, TORF(result
));
142 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
150 ypproc_domain_nonack_2_svc(argp
, rqstp
)
152 struct svc_req
*rqstp
;
154 static bool_t result
; /* is domain served? */
155 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
156 int ok
= yp_acl_check_host(&caller
->sin_addr
);
157 static char domain_path
[MAXPATHLEN
];
160 if (strchr(*argp
, '/'))
162 snprintf(domain_path
, sizeof(domain_path
), "%s/%s", YP_DB_PATH
, *argp
);
163 result
= (bool_t
) ((stat(domain_path
, &finfo
) == 0) &&
164 (finfo
.st_mode
& S_IFDIR
));
167 "domain_nonack_2: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s",
168 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
169 *argp
, TORF(result
));
173 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
178 return(NULL
); /* don't send nack */
185 ypproc_match_2_svc(argp
, rqstp
)
187 struct svc_req
*rqstp
;
189 static ypresp_val res
;
190 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
191 int ok
= yp_acl_check_host(&caller
->sin_addr
);
192 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
194 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
197 "match_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s",
198 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
199 TORF(ok
), TORF(secure
),
200 argp
->domain
, argp
->map
, argp
->key
.keydat_len
, argp
->key
.keydat_val
);
204 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
208 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
211 res
= ypdb_get_record(argp
->domain
,argp
->map
,argp
->key
, FALSE
);
215 yplog(" match2_status: %s", yperr_string(ypprot_err(res
.stat
)));
222 ypproc_first_2_svc(argp
, rqstp
)
224 struct svc_req
*rqstp
;
226 static ypresp_key_val res
;
227 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
228 int ok
= yp_acl_check_host(&caller
->sin_addr
);
229 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
231 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
233 YPLOG( "first_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
234 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
235 TORF(ok
), TORF(secure
),
236 argp
->domain
, argp
->map
);
240 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
244 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
247 res
= ypdb_get_first(argp
->domain
,argp
->map
,FALSE
);
251 yplog(" first2_status: %s", yperr_string(ypprot_err(res
.stat
)));
258 ypproc_next_2_svc(argp
, rqstp
)
260 struct svc_req
*rqstp
;
262 static ypresp_key_val res
;
263 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
264 int ok
= yp_acl_check_host(&caller
->sin_addr
);
265 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
267 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
270 "next_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s",
271 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
272 TORF(ok
), TORF(secure
),
273 argp
->domain
, argp
->map
, argp
->key
.keydat_len
, argp
->key
.keydat_val
);
277 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
281 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
284 res
= ypdb_get_next(argp
->domain
,argp
->map
,argp
->key
,FALSE
);
288 yplog(" next2_status: %s", yperr_string(ypprot_err(res
.stat
)));
295 ypproc_xfr_2_svc(argp
, rqstp
)
297 struct svc_req
*rqstp
;
299 static ypresp_xfr res
;
300 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
301 int ok
= yp_acl_check_host(&caller
->sin_addr
);
306 char ypxfr_proc
[] = YPXFR_PROC
;
309 bzero((char *)&res
, sizeof(res
));
311 YPLOG("xfr_2: caller=[%s].%d, auth_ok=%s, domain=%s, tid=%d, prog=%d",
312 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
313 argp
->map_parms
.domain
, argp
->transid
, argp
->prog
);
314 YPLOG(" ipadd=%s, port=%d, map=%s", inet_ntoa(caller
->sin_addr
),
315 argp
->port
, argp
->map_parms
.map
);
317 if (strchr(argp
->map_parms
.domain
, '/') ||
318 strchr(argp
->map_parms
.map
, '/') ||
319 ntohs(caller
->sin_port
) >= IPPORT_RESERVED
) {
320 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
324 snprintf(tid
, sizeof(tid
), "%d",argp
->transid
);
325 snprintf(prog
, sizeof(prog
), "%d", argp
->prog
);
326 snprintf(port
, sizeof(port
), "%d", argp
->port
);
327 ipadd
= inet_ntoa(caller
->sin_addr
);
331 svcerr_systemerr(rqstp
->rq_xprt
);
335 execl(ypxfr_proc
, "ypxfr", "-d", argp
->map_parms
.domain
,
336 "-C",tid
, prog
, ipadd
, port
, argp
->map_parms
.map
, NULL
);
347 ypproc_clear_2_svc(argp
, rqstp
)
349 struct svc_req
*rqstp
;
352 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
353 int ok
= yp_acl_check_host(&caller
->sin_addr
);
355 YPLOG( "clear_2: caller=[%s].%d, auth_ok=%s, opt=%s",
356 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
364 if (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)
368 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
378 return ((void *)&res
);
382 ypproc_all_2_svc(argp
, rqstp
)
384 struct svc_req
*rqstp
;
386 static ypresp_all res
;
388 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
389 int ok
= yp_acl_check_host(&caller
->sin_addr
);
390 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
392 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
394 YPLOG( "all_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
395 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
396 TORF(ok
), TORF(secure
), argp
->domain
, argp
->map
);
400 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
404 bzero((char *)&res
, sizeof(res
));
406 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
407 res
.ypresp_all_u
.val
.stat
= YP_YPERR
;
416 /* XXXCDC An error has occurred */
419 return(NULL
); /* PARENT: continue */
422 /* CHILD: send result, then exit */
424 if (!svc_sendreply(rqstp
->rq_xprt
, ypdb_xdr_get_all
, (char *) argp
)) {
425 svcerr_systemerr(rqstp
->rq_xprt
);
428 /* note: no need to free args, we are exiting */
434 ypproc_master_2_svc(argp
, rqstp
)
436 struct svc_req
*rqstp
;
438 static ypresp_master res
;
439 static peername nopeer
= "";
440 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
441 int ok
= yp_acl_check_host(&caller
->sin_addr
);
442 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
444 if (strchr(argp
->domain
, '/') || strchr(argp
->map
, '/'))
446 YPLOG( "master_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
447 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
448 TORF(ok
), TORF(secure
), argp
->domain
, argp
->map
);
452 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
456 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
459 res
= ypdb_get_master(argp
->domain
,argp
->map
);
463 yplog(" master2_status: %s", yperr_string(ypprot_err(res
.stat
)));
466 /* This code was added because a yppoll <unknown-domain> */
467 /* from a sun crashed the server in xdr_string, trying */
468 /* to access the peer through a NULL-pointer. yppoll in */
469 /* this server start asking for order. If order is ok */
470 /* then it will ask for master. SunOS 4 asks for both */
471 /* always. I'm not sure this is the best place for the */
472 /* fix, but for now it will do. xdr_peername or */
473 /* xdr_string in ypserv_xdr.c may be a better place? */
475 if (res
.peer
== NULL
) {
486 ypproc_order_2_svc(argp
, rqstp
)
488 struct svc_req
*rqstp
;
490 static ypresp_order res
;
491 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
492 int ok
= yp_acl_check_host(&caller
->sin_addr
);
493 int secure
= ypdb_secure(argp
->domain
,argp
->map
);
495 if (strchr(argp
->domain
, '/'))
497 YPLOG( "order_2: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
498 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
499 TORF(ok
), TORF(secure
), argp
->domain
, argp
->map
);
503 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
507 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
509 } else if (strchr(argp
->map
, '/')) {
512 res
= ypdb_get_order(argp
->domain
,argp
->map
);
516 yplog(" order2_status: %s", yperr_string(ypprot_err(res
.stat
)));
524 ypproc_maplist_2_svc(argp
, rqstp
)
526 struct svc_req
*rqstp
;
528 static ypresp_maplist res
;
529 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
530 int ok
= yp_acl_check_host(&caller
->sin_addr
);
531 static char domain_path
[MAXPATHLEN
];
540 if (strchr(*argp
, '/'))
542 YPLOG("maplist_2: caller=[%s].%d, auth_ok=%s, domain=%s",
543 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
548 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
552 bzero((char *)&res
, sizeof(res
));
554 snprintf(domain_path
,MAXPATHLEN
, "%s/%s",YP_DB_PATH
,*argp
);
560 if (!((stat(domain_path
, &finfo
) == 0) &&
561 ((finfo
.st_mode
& S_IFMT
) == S_IFDIR
)))
565 if ((dirp
= opendir(domain_path
)) == NULL
) {
571 for(dp
= readdir(dirp
); dp
!= NULL
; dp
= readdir(dirp
)) {
572 if ((!strcmp(dp
->d_name
, ".")) ||
573 ((!strcmp(dp
->d_name
, ".."))) ||
576 suffix
= (char *) &dp
->d_name
[dp
->d_namlen
-3];
577 if (strcmp(suffix
,".db") == 0) {
579 if ((m
= (struct ypmaplist
*)
580 malloc((unsigned) sizeof(struct ypmaplist
))) == NULL
) {
585 if ((map_name
= (char *)
586 malloc((unsigned) dp
->d_namlen
- 2)) == NULL
) {
594 strncpy(map_name
, dp
->d_name
, dp
->d_namlen
- 3);
595 m
->map
[dp
->d_namlen
- 3] = '\0';
608 yplog(" maplist_status: %s", yperr_string(ypprot_err(res
.stat
)));
615 ypproc_null_1_svc(argp
, rqstp
)
617 struct svc_req
*rqstp
;
620 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
621 int ok
= yp_acl_check_host(&caller
->sin_addr
);
623 YPLOG("null_1: caller=[%s].%d, auth_ok=%s",
624 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
));
627 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
633 return ((void *)&result
);
637 ypproc_domain_1_svc(argp
, rqstp
)
639 struct svc_req
*rqstp
;
641 static bool_t result
; /* is domain_served? */
642 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
643 int ok
= yp_acl_check_host(&caller
->sin_addr
);
644 static char domain_path
[MAXPATHLEN
];
647 if (strchr(*argp
, '/'))
649 snprintf(domain_path
, sizeof(domain_path
), "%s/%s", YP_DB_PATH
, *argp
);
650 result
= (bool_t
) ((stat(domain_path
, &finfo
) == 0) &&
651 (finfo
.st_mode
& S_IFDIR
));
653 YPLOG("domain_1: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s",
654 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
655 TORF(ok
), *argp
, TORF(result
));
659 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
667 ypproc_domain_nonack_1_svc(argp
, rqstp
)
669 struct svc_req
*rqstp
;
671 static bool_t result
; /* is domain served? */
672 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
673 int ok
= yp_acl_check_host(&caller
->sin_addr
);
674 static char domain_path
[MAXPATHLEN
];
677 if (strchr(*argp
, '/'))
679 snprintf(domain_path
, sizeof(domain_path
), "%s/%s", YP_DB_PATH
, *argp
);
680 result
= (bool_t
) ((stat(domain_path
, &finfo
) == 0) &&
681 (finfo
.st_mode
& S_IFDIR
));
684 "domain_nonack_1: caller=[%s].%d, auth_ok=%s, domain=%s, served=%s",
685 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
), TORF(ok
),
686 *argp
, TORF(result
));
690 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
695 return(NULL
); /* don't send nack */
702 ypproc_match_1_svc(argp
, rqstp
)
704 struct svc_req
*rqstp
;
706 static ypresponse res
;
707 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
708 int ok
= yp_acl_check_host(&caller
->sin_addr
);
711 if (strchr(argp
->ypmatch_req_domain
, '/') ||
712 strchr(argp
->ypmatch_req_map
, '/'))
714 res
.yp_resptype
= YPMATCH_RESPTYPE
;
715 res
.ypmatch_resp_valptr
= "";
716 res
.ypmatch_resp_valsize
= 0;
718 if (argp
->yp_reqtype
!= YPMATCH_REQTYPE
) {
719 res
.ypmatch_resp_status
= YP_BADARGS
;
723 secure
= ypdb_secure(argp
->ypmatch_req_domain
, argp
->ypmatch_req_map
);
726 "match_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s",
727 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
728 TORF(ok
), TORF(secure
),
729 argp
->ypmatch_req_domain
, argp
->ypmatch_req_map
,
730 argp
->ypmatch_req_keysize
, argp
->ypmatch_req_keyptr
);
734 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
738 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
739 res
.ypmatch_resp_status
= YP_YPERR
;
741 res
.ypmatch_resp_val
=
742 ypdb_get_record(argp
->ypmatch_req_domain
,
743 argp
->ypmatch_req_map
,
744 argp
->ypmatch_req_keydat
,
749 yplog(" match1_status: %s",
750 yperr_string(ypprot_err(res
.ypmatch_resp_status
)));
757 ypproc_first_1_svc(argp
, rqstp
)
759 struct svc_req
*rqstp
;
761 static ypresponse res
;
762 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
763 int ok
= yp_acl_check_host(&caller
->sin_addr
);
766 if (strchr(argp
->ypfirst_req_domain
, '/') ||
767 strchr(argp
->ypfirst_req_map
, '/'))
769 res
.yp_resptype
= YPFIRST_RESPTYPE
;
770 res
.ypfirst_resp_valptr
= res
.ypfirst_resp_keyptr
= "";
771 res
.ypfirst_resp_valsize
= res
.ypfirst_resp_keysize
= 0;
773 if (argp
->yp_reqtype
!= YPREQ_NOKEY
) {
774 res
.ypfirst_resp_status
= YP_BADARGS
;
778 secure
= ypdb_secure(argp
->ypfirst_req_domain
, argp
->ypfirst_req_map
);
780 YPLOG( "first_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
781 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
782 TORF(ok
), TORF(secure
),
783 argp
->ypfirst_req_domain
, argp
->ypfirst_req_map
);
787 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
791 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
792 res
.ypfirst_resp_status
= YP_YPERR
;
794 res
.ypfirst_resp_val
=
795 ypdb_get_first(argp
->ypfirst_req_domain
,
796 argp
->ypfirst_req_map
,
801 yplog(" first1_status: %s",
802 yperr_string(ypprot_err(res
.ypfirst_resp_status
)));
809 ypproc_next_1_svc(argp
, rqstp
)
811 struct svc_req
*rqstp
;
813 static ypresponse res
;
814 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
815 int ok
= yp_acl_check_host(&caller
->sin_addr
);
818 if (strchr(argp
->ypnext_req_domain
, '/') ||
819 strchr(argp
->ypnext_req_map
, '/'))
821 res
.yp_resptype
= YPNEXT_RESPTYPE
;
822 res
.ypnext_resp_valptr
= res
.ypnext_resp_keyptr
= "";
823 res
.ypnext_resp_valsize
= res
.ypnext_resp_keysize
= 0;
825 if (argp
->yp_reqtype
!= YPNEXT_REQTYPE
) {
826 res
.ypnext_resp_status
= YP_BADARGS
;
830 secure
= ypdb_secure(argp
->ypnext_req_domain
, argp
->ypnext_req_map
);
833 "next_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, key=%.*s",
834 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
835 TORF(ok
), TORF(secure
),
836 argp
->ypnext_req_domain
, argp
->ypnext_req_map
,
837 argp
->ypnext_req_keysize
, argp
->ypnext_req_keyptr
);
841 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
845 if (secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)) {
846 res
.ypnext_resp_status
= YP_YPERR
;
848 res
.ypnext_resp_val
=
849 ypdb_get_next(argp
->ypnext_req_domain
,
850 argp
->ypnext_req_map
,
851 argp
->ypnext_req_keydat
,
856 yplog(" next1_status: %s",
857 yperr_string(ypprot_err(res
.ypnext_resp_status
)));
864 ypproc_poll_1_svc(argp
, rqstp
)
866 struct svc_req
*rqstp
;
868 static ypresponse res
;
870 ypresp_master master
;
871 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
872 int ok
= yp_acl_check_host(&caller
->sin_addr
);
875 if (strchr(argp
->yppoll_req_domain
, '/') ||
876 strchr(argp
->yppoll_req_map
, '/'))
878 res
.yp_resptype
= YPPOLL_RESPTYPE
;
879 res
.yppoll_resp_domain
= argp
->yppoll_req_domain
;
880 res
.yppoll_resp_map
= argp
->yppoll_req_map
;
881 res
.yppoll_resp_ordernum
= 0;
882 res
.yppoll_resp_owner
= "";
884 if (argp
->yp_reqtype
!= YPPOLL_REQTYPE
) {
888 secure
= ypdb_secure(argp
->yppoll_req_domain
, argp
->yppoll_req_map
);
890 YPLOG( "poll_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
891 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
892 TORF(ok
), TORF(secure
),
893 argp
->yppoll_req_domain
, argp
->yppoll_req_map
);
897 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
901 if (!(secure
&& (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
))) {
902 order
= ypdb_get_order(argp
->yppoll_req_domain
,
903 argp
->yppoll_req_map
);
904 master
= ypdb_get_master(argp
->yppoll_req_domain
,
905 argp
->yppoll_req_map
);
906 res
.yppoll_resp_ordernum
= order
.ordernum
;
907 res
.yppoll_resp_owner
= master
.peer
;
911 yplog(" poll1_status: %s", "none");
917 ypproc_push_1_svc(argp
, rqstp
)
919 struct svc_req
*rqstp
;
921 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
922 int ok
= yp_acl_check_host(&caller
->sin_addr
);
925 char yppush_proc
[] = YPPUSH_PROC
;
927 if (strchr(argp
->yppush_req_domain
, '/') ||
928 strchr(argp
->yppush_req_map
, '/'))
930 if (argp
->yp_reqtype
!= YPPUSH_REQTYPE
) {
934 secure
= ypdb_secure(argp
->yppush_req_domain
, argp
->yppush_req_map
);
936 YPLOG( "push_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
937 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
938 TORF(ok
), TORF(secure
),
939 argp
->yppush_req_domain
, argp
->yppush_req_map
);
941 if (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)
946 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
952 svcerr_systemerr(rqstp
->rq_xprt
);
956 execl(yppush_proc
, "yppush", "-d", argp
->yppush_req_domain
,
957 argp
->yppush_req_map
, NULL
);
965 ypproc_pull_1_svc(argp
, rqstp
)
967 struct svc_req
*rqstp
;
969 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
970 int ok
= yp_acl_check_host(&caller
->sin_addr
);
973 char ypxfr_proc
[] = YPXFR_PROC
;
975 if (strchr(argp
->yppull_req_domain
, '/') ||
976 strchr(argp
->yppull_req_map
, '/'))
978 if (argp
->yp_reqtype
!= YPPULL_REQTYPE
) {
982 secure
= ypdb_secure(argp
->yppull_req_domain
, argp
->yppull_req_map
);
984 YPLOG( "pull_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s",
985 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
986 TORF(ok
), TORF(secure
),
987 argp
->yppull_req_domain
, argp
->yppull_req_map
);
989 if (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)
994 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
1000 svcerr_systemerr(rqstp
->rq_xprt
);
1004 execl(ypxfr_proc
, "ypxfr", "-d", argp
->yppull_req_domain
,
1005 argp
->yppull_req_map
, NULL
);
1013 ypproc_get_1_svc(argp
, rqstp
)
1015 struct svc_req
*rqstp
;
1018 struct sockaddr_in
*caller
= svc_getcaller(rqstp
->rq_xprt
);
1019 int ok
= yp_acl_check_host(&caller
->sin_addr
);
1022 char ypxfr_proc
[] = YPXFR_PROC
;
1024 if (strchr(argp
->ypget_req_domain
, '/') ||
1025 strchr(argp
->ypget_req_map
, '/'))
1027 if (argp
->yp_reqtype
!= YPGET_REQTYPE
) {
1031 secure
= ypdb_secure(argp
->ypget_req_domain
, argp
->ypget_req_map
);
1033 YPLOG( "get_1: caller=[%s].%d, auth_ok=%s, secure=%s, domain=%s, map=%s, owner=%s",
1034 inet_ntoa(caller
->sin_addr
), ntohs(caller
->sin_port
),
1035 TORF(ok
), TORF(secure
),
1036 argp
->ypget_req_domain
, argp
->ypget_req_map
,
1037 argp
->ypget_req_owner
);
1039 if (ntohs(caller
->sin_port
) >= IPPORT_RESERVED
)
1044 svcerr_auth(rqstp
->rq_xprt
, AUTH_FAILED
);
1050 svcerr_systemerr(rqstp
->rq_xprt
);
1054 execl(ypxfr_proc
, "ypxfr", "-d", argp
->ypget_req_domain
, "-h",
1055 argp
->ypget_req_owner
, argp
->yppush_req_map
, NULL
);