| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
#ifdef PORTMAP |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
#include <pthread.h> |
| 47 |
#include <reentrant.h> |
| 48 |
#include <sys/types.h> |
| 49 |
#include <sys/socket.h> |
| 50 |
#include <stdio.h> |
| 51 |
#include <rpc/rpc.h> |
| 52 |
#include <rpc/pmap_clnt.h> |
| 53 |
#include <rpc/pmap_prot.h> |
| 54 |
#include <rpc/nettype.h> |
| 55 |
#include <syslog.h> |
| 56 |
#include <netinet/in.h> |
| 57 |
#include <netdb.h> |
| 58 |
#include <errno.h> |
| 59 |
#include <syslog.h> |
| 60 |
#include <stdlib.h> |
| 61 |
#include <string.h> |
| 62 |
#include <unistd.h> |
| 63 |
#include <fcntl.h> |
| 64 |
|
| 65 |
#include "nis.h" |
| 66 |
#include "rpc_com.h" |
| 67 |
|
| 68 |
extern mutex_t rpcsoc_lock; |
| 69 |
|
| 70 |
static CLIENT *clnt_com_create(struct sockaddr_in *, rpcprog_t, rpcvers_t, |
| 71 |
int *, u_int, u_int, char *, int); |
| 72 |
static SVCXPRT *svc_com_create(int, u_int, u_int, char *); |
| 73 |
static bool_t rpc_wrap_bcast(char *, struct netbuf *, struct netconfig *); |
| 74 |
|
| 75 |
|
| 76 |
#define IN4_LOCALHOST_STRING "127.0.0.1" |
| 77 |
#define IN6_LOCALHOST_STRING "::1" |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
static CLIENT * |
| 83 |
clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp, flags) |
| 84 |
struct sockaddr_in *raddr; |
| 85 |
rpcprog_t prog; |
| 86 |
rpcvers_t vers; |
| 87 |
int *sockp; |
| 88 |
u_int sendsz; |
| 89 |
u_int recvsz; |
| 90 |
char *tp; |
| 91 |
int flags; |
| 92 |
{ |
| 93 |
CLIENT *cl; |
| 94 |
int madefd = FALSE; |
| 95 |
int fd = *sockp; |
| 96 |
struct netconfig *nconf; |
| 97 |
struct netbuf bindaddr; |
| 98 |
|
| 99 |
mutex_lock(&rpcsoc_lock); |
| 100 |
if ((nconf = __rpc_getconfip(tp)) == NULL) { |
| 101 |
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; |
| 102 |
mutex_unlock(&rpcsoc_lock); |
| 103 |
return (NULL); |
| 104 |
} |
| 105 |
if (fd == RPC_ANYSOCK) { |
| 106 |
static int have_cloexec; |
| 107 |
fd = __rpc_nconf2fd_flags(nconf, flags); |
| 108 |
#ifdef SOCK_CLOEXEC |
| 109 |
if (fd == -1) { |
| 110 |
if ((flags & SOCK_CLOEXEC) && have_cloexec <= 0) { |
| 111 |
fd = __rpc_nconf2fd(nconf); |
| 112 |
if (fd == -1) |
| 113 |
goto syserror; |
| 114 |
if (flags & SOCK_CLOEXEC) { |
| 115 |
have_cloexec = -1; |
| 116 |
fcntl(fd, F_SETFD, FD_CLOEXEC); |
| 117 |
} |
| 118 |
} else |
| 119 |
goto syserror; |
| 120 |
} else if (flags & SOCK_CLOEXEC) |
| 121 |
have_cloexec = 1; |
| 122 |
#else |
| 123 |
if (fd == -1) |
| 124 |
goto syserror; |
| 125 |
#endif |
| 126 |
madefd = TRUE; |
| 127 |
} |
| 128 |
|
| 129 |
if (raddr->sin_port == 0) { |
| 130 |
u_int proto; |
| 131 |
u_short sport; |
| 132 |
|
| 133 |
mutex_unlock(&rpcsoc_lock); |
| 134 |
proto = strcmp(tp, "udp") == 0 ? IPPROTO_UDP : IPPROTO_TCP; |
| 135 |
sport = pmap_getport(raddr, (u_long)prog, (u_long)vers, |
| 136 |
proto); |
| 137 |
if (sport == 0) { |
| 138 |
goto err; |
| 139 |
} |
| 140 |
raddr->sin_port = htons(sport); |
| 141 |
mutex_lock(&rpcsoc_lock); |
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
bindaddr.maxlen = bindaddr.len = sizeof (struct sockaddr_in); |
| 146 |
bindaddr.buf = raddr; |
| 147 |
|
| 148 |
bindresvport(fd, NULL); |
| 149 |
cl = clnt_tli_create(fd, nconf, &bindaddr, prog, vers, |
| 150 |
sendsz, recvsz); |
| 151 |
if (cl) { |
| 152 |
if (madefd == TRUE) { |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
(void) CLNT_CONTROL(cl, CLSET_FD_CLOSE, NULL); |
| 157 |
*sockp = fd; |
| 158 |
} |
| 159 |
(void) freenetconfigent(nconf); |
| 160 |
mutex_unlock(&rpcsoc_lock); |
| 161 |
return (cl); |
| 162 |
} |
| 163 |
goto err; |
| 164 |
|
| 165 |
syserror: |
| 166 |
rpc_createerr.cf_stat = RPC_SYSTEMERROR; |
| 167 |
rpc_createerr.cf_error.re_errno = errno; |
| 168 |
|
| 169 |
err: if (madefd == TRUE) |
| 170 |
(void)close(fd); |
| 171 |
(void) freenetconfigent(nconf); |
| 172 |
mutex_unlock(&rpcsoc_lock); |
| 173 |
return (NULL); |
| 174 |
} |
| 175 |
|
| 176 |
CLIENT * |
| 177 |
__libc_clntudp_bufcreate(raddr, prog, vers, wait, sockp, sendsz, recvsz, flags) |
| 178 |
struct sockaddr_in *raddr; |
| 179 |
u_long prog; |
| 180 |
u_long vers; |
| 181 |
struct timeval wait; |
| 182 |
int *sockp; |
| 183 |
u_int sendsz; |
| 184 |
u_int recvsz; |
| 185 |
int flags; |
| 186 |
{ |
| 187 |
CLIENT *cl; |
| 188 |
|
| 189 |
cl = clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp, |
| 190 |
sendsz, recvsz, "udp", flags); |
| 191 |
if (cl == NULL) { |
| 192 |
return (NULL); |
| 193 |
} |
| 194 |
(void) CLNT_CONTROL(cl, CLSET_RETRY_TIMEOUT, &wait); |
| 195 |
return (cl); |
| 196 |
} |
| 197 |
|
| 198 |
CLIENT * |
| 199 |
clntudp_bufcreate(raddr, prog, vers, wait, sockp, sendsz, recvsz) |
| 200 |
struct sockaddr_in *raddr; |
| 201 |
u_long prog; |
| 202 |
u_long vers; |
| 203 |
struct timeval wait; |
| 204 |
int *sockp; |
| 205 |
u_int sendsz; |
| 206 |
u_int recvsz; |
| 207 |
{ |
| 208 |
CLIENT *cl; |
| 209 |
|
| 210 |
cl = clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp, |
| 211 |
sendsz, recvsz, "udp", 0); |
| 212 |
if (cl == NULL) { |
| 213 |
return (NULL); |
| 214 |
} |
| 215 |
(void) CLNT_CONTROL(cl, CLSET_RETRY_TIMEOUT, &wait); |
| 216 |
return (cl); |
| 217 |
} |
| 218 |
|
| 219 |
CLIENT * |
| 220 |
clntudp_create(raddr, program, version, wait, sockp) |
| 221 |
struct sockaddr_in *raddr; |
| 222 |
u_long program; |
| 223 |
u_long version; |
| 224 |
struct timeval wait; |
| 225 |
int *sockp; |
| 226 |
{ |
| 227 |
return clntudp_bufcreate(raddr, program, version, wait, sockp, UDPMSGSIZE, UDPMSGSIZE); |
| 228 |
} |
| 229 |
|
| 230 |
CLIENT * |
| 231 |
clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) |
| 232 |
struct sockaddr_in *raddr; |
| 233 |
u_long prog; |
| 234 |
u_long vers; |
| 235 |
int *sockp; |
| 236 |
u_int sendsz; |
| 237 |
u_int recvsz; |
| 238 |
{ |
| 239 |
return clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp, |
| 240 |
sendsz, recvsz, "tcp", 0); |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
#ifdef INET6_NOT_USED |
| 246 |
|
| 247 |
CLIENT * |
| 248 |
clntudp6_bufcreate(raddr, prog, vers, wait, sockp, sendsz, recvsz) |
| 249 |
struct sockaddr_in6 *raddr; |
| 250 |
u_long prog; |
| 251 |
u_long vers; |
| 252 |
struct timeval wait; |
| 253 |
int *sockp; |
| 254 |
u_int sendsz; |
| 255 |
u_int recvsz; |
| 256 |
{ |
| 257 |
CLIENT *cl; |
| 258 |
|
| 259 |
cl = clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp, |
| 260 |
sendsz, recvsz, "udp6", 0); |
| 261 |
if (cl == NULL) { |
| 262 |
return (NULL); |
| 263 |
} |
| 264 |
(void) CLNT_CONTROL(cl, CLSET_RETRY_TIMEOUT, &wait); |
| 265 |
return (cl); |
| 266 |
} |
| 267 |
|
| 268 |
CLIENT * |
| 269 |
clntudp6_create(raddr, program, version, wait, sockp) |
| 270 |
struct sockaddr_in6 *raddr; |
| 271 |
u_long program; |
| 272 |
u_long version; |
| 273 |
struct timeval wait; |
| 274 |
int *sockp; |
| 275 |
{ |
| 276 |
return clntudp6_bufcreate(raddr, program, version, wait, sockp, UDPMSGSIZE, UDPMSGSIZE); |
| 277 |
} |
| 278 |
|
| 279 |
CLIENT * |
| 280 |
clnttcp6_create(raddr, prog, vers, sockp, sendsz, recvsz) |
| 281 |
struct sockaddr_in6 *raddr; |
| 282 |
u_long prog; |
| 283 |
u_long vers; |
| 284 |
int *sockp; |
| 285 |
u_int sendsz; |
| 286 |
u_int recvsz; |
| 287 |
{ |
| 288 |
return clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp, |
| 289 |
sendsz, recvsz, "tcp6", 0); |
| 290 |
} |
| 291 |
|
| 292 |
#endif |
| 293 |
|
| 294 |
CLIENT * |
| 295 |
clntraw_create(prog, vers) |
| 296 |
u_long prog; |
| 297 |
u_long vers; |
| 298 |
{ |
| 299 |
return clnt_raw_create((rpcprog_t)prog, (rpcvers_t)vers); |
| 300 |
} |
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
static SVCXPRT * |
| 306 |
svc_com_create(fd, sendsize, recvsize, netid) |
| 307 |
int fd; |
| 308 |
u_int sendsize; |
| 309 |
u_int recvsize; |
| 310 |
char *netid; |
| 311 |
{ |
| 312 |
struct netconfig *nconf; |
| 313 |
SVCXPRT *svc; |
| 314 |
int madefd = FALSE; |
| 315 |
int port; |
| 316 |
|
| 317 |
if ((nconf = __rpc_getconfip(netid)) == NULL) { |
| 318 |
(void) syslog(LOG_ERR, "Could not get %s transport", netid); |
| 319 |
return (NULL); |
| 320 |
} |
| 321 |
if (fd == RPC_ANYSOCK) { |
| 322 |
fd = __rpc_nconf2fd(nconf); |
| 323 |
if (fd == -1) { |
| 324 |
(void) freenetconfigent(nconf); |
| 325 |
(void) syslog(LOG_ERR, |
| 326 |
"svc%s_create: could not open connection", netid); |
| 327 |
return (NULL); |
| 328 |
} |
| 329 |
madefd = TRUE; |
| 330 |
} |
| 331 |
|
| 332 |
svc = svc_tli_create(fd, nconf, NULL, sendsize, recvsize); |
| 333 |
(void) freenetconfigent(nconf); |
| 334 |
if (svc == NULL) { |
| 335 |
if (madefd) |
| 336 |
(void)close(fd); |
| 337 |
return (NULL); |
| 338 |
} |
| 339 |
port = (((struct sockaddr_in *)svc->xp_ltaddr.buf)->sin_port); |
| 340 |
svc->xp_port = ntohs(port); |
| 341 |
return (svc); |
| 342 |
} |
| 343 |
|
| 344 |
SVCXPRT * |
| 345 |
svctcp_create(fd, sendsize, recvsize) |
| 346 |
int fd; |
| 347 |
u_int sendsize; |
| 348 |
u_int recvsize; |
| 349 |
{ |
| 350 |
|
| 351 |
return svc_com_create(fd, sendsize, recvsize, "tcp"); |
| 352 |
} |
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
SVCXPRT * |
| 357 |
svcudp_bufcreate(fd, sendsz, recvsz) |
| 358 |
int fd; |
| 359 |
u_int sendsz, recvsz; |
| 360 |
{ |
| 361 |
|
| 362 |
return svc_com_create(fd, sendsz, recvsz, "udp"); |
| 363 |
} |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
SVCXPRT * |
| 368 |
svcfd_create(fd, sendsize, recvsize) |
| 369 |
int fd; |
| 370 |
u_int sendsize; |
| 371 |
u_int recvsize; |
| 372 |
{ |
| 373 |
|
| 374 |
return svc_fd_create(fd, sendsize, recvsize); |
| 375 |
} |
| 376 |
|
| 377 |
|
| 378 |
SVCXPRT * |
| 379 |
svcudp_create(fd) |
| 380 |
int fd; |
| 381 |
{ |
| 382 |
|
| 383 |
return svc_com_create(fd, UDPMSGSIZE, UDPMSGSIZE, "udp"); |
| 384 |
} |
| 385 |
|
| 386 |
|
| 387 |
SVCXPRT * |
| 388 |
svcraw_create() |
| 389 |
{ |
| 390 |
|
| 391 |
return svc_raw_create(); |
| 392 |
} |
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
#ifdef INET6_NOT_USED |
| 397 |
SVCXPRT * |
| 398 |
svcudp6_bufcreate(fd, sendsz, recvsz) |
| 399 |
int fd; |
| 400 |
u_int sendsz, recvsz; |
| 401 |
{ |
| 402 |
return svc_com_create(fd, sendsz, recvsz, "udp6"); |
| 403 |
} |
| 404 |
|
| 405 |
|
| 406 |
SVCXPRT * |
| 407 |
svctcp6_create(fd, sendsize, recvsize) |
| 408 |
int fd; |
| 409 |
u_int sendsize; |
| 410 |
u_int recvsize; |
| 411 |
{ |
| 412 |
return svc_com_create(fd, sendsize, recvsize, "tcp6"); |
| 413 |
} |
| 414 |
|
| 415 |
|
| 416 |
SVCXPRT * |
| 417 |
svcudp6_create(fd) |
| 418 |
int fd; |
| 419 |
{ |
| 420 |
return svc_com_create(fd, UDPMSGSIZE, UDPMSGSIZE, "udp6"); |
| 421 |
} |
| 422 |
#endif |
| 423 |
|
| 424 |
int |
| 425 |
get_myaddress(addr) |
| 426 |
struct sockaddr_in *addr; |
| 427 |
{ |
| 428 |
|
| 429 |
memset((void *) addr, 0, sizeof(*addr)); |
| 430 |
addr->sin_family = AF_INET; |
| 431 |
addr->sin_port = htons(PMAPPORT); |
| 432 |
addr->sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
| 433 |
return (0); |
| 434 |
} |
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
int |
| 440 |
callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) |
| 441 |
const char *host; |
| 442 |
int prognum, versnum, procnum; |
| 443 |
xdrproc_t inproc, outproc; |
| 444 |
void *in, *out; |
| 445 |
{ |
| 446 |
|
| 447 |
return (int)rpc_call(host, (rpcprog_t)prognum, (rpcvers_t)versnum, |
| 448 |
(rpcproc_t)procnum, inproc, in, outproc, out, "udp"); |
| 449 |
} |
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
int |
| 455 |
registerrpc(prognum, versnum, procnum, progname, inproc, outproc) |
| 456 |
int prognum, versnum, procnum; |
| 457 |
char *(*progname)(char [UDPMSGSIZE]); |
| 458 |
xdrproc_t inproc, outproc; |
| 459 |
{ |
| 460 |
|
| 461 |
return rpc_reg((rpcprog_t)prognum, (rpcvers_t)versnum, |
| 462 |
(rpcproc_t)procnum, progname, inproc, outproc, "udp"); |
| 463 |
} |
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
extern thread_key_t clnt_broadcast_key; |
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
static bool_t |
| 477 |
rpc_wrap_bcast(resultp, addr, nconf) |
| 478 |
char *resultp; |
| 479 |
struct netbuf *addr; |
| 480 |
struct netconfig *nconf; |
| 481 |
{ |
| 482 |
resultproc_t clnt_broadcast_result; |
| 483 |
|
| 484 |
if (strcmp(nconf->nc_netid, "udp")) |
| 485 |
return (FALSE); |
| 486 |
clnt_broadcast_result = (resultproc_t)thr_getspecific(clnt_broadcast_key); |
| 487 |
return (*clnt_broadcast_result)(resultp, |
| 488 |
(struct sockaddr_in *)addr->buf); |
| 489 |
} |
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
enum clnt_stat |
| 495 |
clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) |
| 496 |
u_long prog; |
| 497 |
u_long vers; |
| 498 |
u_long proc; |
| 499 |
xdrproc_t xargs; |
| 500 |
void *argsp; |
| 501 |
xdrproc_t xresults; |
| 502 |
void *resultsp; |
| 503 |
resultproc_t eachresult; |
| 504 |
{ |
| 505 |
extern mutex_t tsd_lock; |
| 506 |
|
| 507 |
if (clnt_broadcast_key == KEY_INITIALIZER) { |
| 508 |
mutex_lock(&tsd_lock); |
| 509 |
if (clnt_broadcast_key == KEY_INITIALIZER) |
| 510 |
thr_keycreate(&clnt_broadcast_key, free); |
| 511 |
mutex_unlock(&tsd_lock); |
| 512 |
} |
| 513 |
thr_setspecific(clnt_broadcast_key, (void *) eachresult); |
| 514 |
return rpc_broadcast((rpcprog_t)prog, (rpcvers_t)vers, |
| 515 |
(rpcproc_t)proc, xargs, argsp, xresults, resultsp, |
| 516 |
(resultproc_t) rpc_wrap_bcast, "udp"); |
| 517 |
} |
| 518 |
|
| 519 |
#ifdef AUTHDES_SUPPORT |
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
AUTH * |
| 525 |
authdes_create(servername, window, syncaddr, ckey) |
| 526 |
char *servername; |
| 527 |
u_int window; |
| 528 |
struct sockaddr *syncaddr; |
| 529 |
des_block *ckey; |
| 530 |
{ |
| 531 |
AUTH *nauth; |
| 532 |
char hostname[NI_MAXHOST]; |
| 533 |
|
| 534 |
if (syncaddr) { |
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
switch (syncaddr->sa_family) { |
| 540 |
case AF_INET: |
| 541 |
if (getnameinfo(syncaddr, sizeof(struct sockaddr_in), hostname, |
| 542 |
sizeof hostname, NULL, 0, 0) != 0) |
| 543 |
goto fallback; |
| 544 |
break; |
| 545 |
case AF_INET6: |
| 546 |
if (getnameinfo(syncaddr, sizeof(struct sockaddr_in6), hostname, |
| 547 |
sizeof hostname, NULL, 0, 0) != 0) |
| 548 |
goto fallback; |
| 549 |
break; |
| 550 |
default: |
| 551 |
goto fallback; |
| 552 |
} |
| 553 |
nauth = authdes_seccreate(servername, window, hostname, ckey); |
| 554 |
return (nauth); |
| 555 |
} |
| 556 |
fallback: |
| 557 |
return authdes_seccreate(servername, window, NULL, ckey); |
| 558 |
} |
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
extern AUTH *authdes_pk_seccreate(const char *, netobj *, u_int, const char *, |
| 565 |
const des_block *, nis_server *); |
| 566 |
|
| 567 |
AUTH * |
| 568 |
authdes_pk_create(servername, pkey, window, syncaddr, ckey) |
| 569 |
char *servername; |
| 570 |
netobj *pkey; |
| 571 |
u_int window; |
| 572 |
struct sockaddr *syncaddr; |
| 573 |
des_block *ckey; |
| 574 |
{ |
| 575 |
AUTH *nauth; |
| 576 |
char hostname[NI_MAXHOST]; |
| 577 |
|
| 578 |
if (syncaddr) { |
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
switch (syncaddr->sa_family) { |
| 584 |
case AF_INET: |
| 585 |
if (getnameinfo(syncaddr, sizeof(struct sockaddr_in), hostname, |
| 586 |
sizeof hostname, NULL, 0, 0) != 0) |
| 587 |
goto fallback; |
| 588 |
break; |
| 589 |
default: |
| 590 |
goto fallback; |
| 591 |
} |
| 592 |
nauth = authdes_pk_seccreate(servername, pkey, window, hostname, ckey, NULL); |
| 593 |
return (nauth); |
| 594 |
} |
| 595 |
fallback: |
| 596 |
return authdes_pk_seccreate(servername, pkey, window, NULL, ckey, NULL); |
| 597 |
} |
| 598 |
#else |
| 599 |
AUTH * |
| 600 |
authdes_create(servername, window, syncaddr, ckey) |
| 601 |
char *servername; |
| 602 |
u_int window; |
| 603 |
struct sockaddr *syncaddr; |
| 604 |
des_block *ckey; |
| 605 |
{ return (NULL); } |
| 606 |
|
| 607 |
AUTH * |
| 608 |
authdes_pk_create(servername, pkey, window, syncaddr, ckey) |
| 609 |
char *servername; |
| 610 |
netobj *pkey; |
| 611 |
u_int window; |
| 612 |
struct sockaddr *syncaddr; |
| 613 |
des_block *ckey; |
| 614 |
{ return (NULL); } |
| 615 |
|
| 616 |
AUTH * |
| 617 |
authdes_seccreate(const char *servername, const u_int win, |
| 618 |
const char *timehost, const des_block *ckey) |
| 619 |
{ |
| 620 |
return (NULL); |
| 621 |
} |
| 622 |
|
| 623 |
#endif |
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
CLIENT * |
| 630 |
clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) |
| 631 |
struct sockaddr_un *raddr; |
| 632 |
u_long prog; |
| 633 |
u_long vers; |
| 634 |
int *sockp; |
| 635 |
u_int sendsz; |
| 636 |
u_int recvsz; |
| 637 |
{ |
| 638 |
struct netbuf svcaddr = {0, 0, NULL}; |
| 639 |
CLIENT *cl = NULL; |
| 640 |
int len; |
| 641 |
|
| 642 |
memset(&svcaddr, 0, sizeof(svcaddr)); |
| 643 |
if (__rpc_set_netbuf(&svcaddr, raddr, sizeof(*raddr)) == NULL) { |
| 644 |
rpc_createerr.cf_stat = RPC_SYSTEMERROR; |
| 645 |
rpc_createerr.cf_error.re_errno = errno; |
| 646 |
return(cl); |
| 647 |
} |
| 648 |
if (*sockp < 0) { |
| 649 |
*sockp = socket(AF_LOCAL, SOCK_STREAM, 0); |
| 650 |
len = SUN_LEN(raddr); |
| 651 |
if ((*sockp < 0) || (connect(*sockp, |
| 652 |
(struct sockaddr *)raddr, len) < 0)) { |
| 653 |
rpc_createerr.cf_stat = RPC_SYSTEMERROR; |
| 654 |
rpc_createerr.cf_error.re_errno = errno; |
| 655 |
if (*sockp != -1) |
| 656 |
(void)close(*sockp); |
| 657 |
goto done; |
| 658 |
} |
| 659 |
} |
| 660 |
cl = clnt_vc_create(*sockp, &svcaddr, prog, |
| 661 |
vers, sendsz, recvsz); |
| 662 |
done: |
| 663 |
free(svcaddr.buf); |
| 664 |
return(cl); |
| 665 |
} |
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
SVCXPRT * |
| 672 |
svcunix_create(sock, sendsize, recvsize, path) |
| 673 |
int sock; |
| 674 |
u_int sendsize; |
| 675 |
u_int recvsize; |
| 676 |
char *path; |
| 677 |
{ |
| 678 |
struct netconfig *nconf; |
| 679 |
void *localhandle; |
| 680 |
struct sockaddr_un sun; |
| 681 |
struct sockaddr *sa; |
| 682 |
struct t_bind taddr; |
| 683 |
SVCXPRT *xprt; |
| 684 |
int addrlen; |
| 685 |
|
| 686 |
xprt = (SVCXPRT *)NULL; |
| 687 |
localhandle = setnetconfig(); |
| 688 |
while ((nconf = getnetconfig(localhandle)) != NULL) { |
| 689 |
if (nconf->nc_protofmly != NULL && |
| 690 |
strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) |
| 691 |
break; |
| 692 |
} |
| 693 |
if (nconf == NULL) { |
| 694 |
endnetconfig(localhandle); |
| 695 |
return(xprt); |
| 696 |
} |
| 697 |
|
| 698 |
if ((sock = __rpc_nconf2fd(nconf)) < 0) |
| 699 |
goto done; |
| 700 |
|
| 701 |
memset(&sun, 0, sizeof sun); |
| 702 |
sun.sun_family = AF_LOCAL; |
| 703 |
strncpy(sun.sun_path, path, (sizeof(sun.sun_path)-1)); |
| 704 |
if (sun.sun_path[0] == '@') |
| 705 |
|
| 706 |
sun.sun_path[0] = '\0'; |
| 707 |
|
| 708 |
addrlen = SUN_LEN_A(&sun); |
| 709 |
sa = (struct sockaddr *)&sun; |
| 710 |
|
| 711 |
if (bind(sock, sa, addrlen) < 0) |
| 712 |
goto done; |
| 713 |
|
| 714 |
taddr.addr.len = taddr.addr.maxlen = addrlen; |
| 715 |
taddr.addr.buf = malloc(addrlen); |
| 716 |
if (taddr.addr.buf == NULL) |
| 717 |
goto done; |
| 718 |
memcpy(taddr.addr.buf, sa, addrlen); |
| 719 |
|
| 720 |
if (nconf->nc_semantics != NC_TPI_CLTS) { |
| 721 |
if (listen(sock, SOMAXCONN) < 0) { |
| 722 |
free(taddr.addr.buf); |
| 723 |
goto done; |
| 724 |
} |
| 725 |
} |
| 726 |
|
| 727 |
xprt = (SVCXPRT *)svc_tli_create(sock, nconf, &taddr, sendsize, recvsize); |
| 728 |
if (xprt == NULL) |
| 729 |
close(sock); |
| 730 |
|
| 731 |
done: |
| 732 |
endnetconfig(localhandle); |
| 733 |
return(xprt); |
| 734 |
} |
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
SVCXPRT * |
| 741 |
svcunixfd_create(fd, sendsize, recvsize) |
| 742 |
int fd; |
| 743 |
u_int sendsize; |
| 744 |
u_int recvsize; |
| 745 |
{ |
| 746 |
return (svc_fd_create(fd, sendsize, recvsize)); |
| 747 |
} |
| 748 |
|
| 749 |
#endif |