version 1.56, 2006/10/05 09:18:11 |
version 1.57, 2007/07/07 22:33:57 |
Line 148 static int direct_set(char *, int, struc |
|
Line 148 static int direct_set(char *, int, struc |
|
static void |
static void |
usage(void) |
usage(void) |
{ |
{ |
char *opt = ""; |
const char *opt = ""; |
#ifdef DEBUG |
#ifdef DEBUG |
opt = " [-d]"; |
opt = " [-d]"; |
#endif |
#endif |
|
|
(void)fprintf(stderr, |
(void)fprintf(stderr, |
"usage: %s [-broadcast] [-insecure] [-ypset] [-ypsetme] %s\n", |
"Usage: %s [-broadcast] [-insecure] [-ypset] [-ypsetme]%s\n", |
getprogname(), opt); |
getprogname(), opt); |
exit(1); |
exit(1); |
} |
} |
Line 168 yp_log(int pri, const char *fmt, ...) |
|
Line 168 yp_log(int pri, const char *fmt, ...) |
|
|
|
#if defined(DEBUG) |
#if defined(DEBUG) |
if (debug) |
if (debug) |
vfprintf(stderr, fmt, ap); |
(void)vprintf(fmt, ap); |
else |
else |
#endif |
#endif |
vsyslog(pri, fmt, ap); |
vsyslog(pri, fmt, ap); |
Line 222 removelock(struct _dom_binding *ypdb) |
|
Line 222 removelock(struct _dom_binding *ypdb) |
|
} |
} |
|
|
static void * |
static void * |
|
/*ARGSUSED*/ |
ypbindproc_null_2(SVCXPRT *transp, void *argp) |
ypbindproc_null_2(SVCXPRT *transp, void *argp) |
{ |
{ |
static char res; |
static char res; |
|
|
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("ypbindproc_null_2\n"); |
(void)printf("ypbindproc_null_2\n"); |
#endif |
#endif |
(void)memset(&res, 0, sizeof(res)); |
(void)memset(&res, 0, sizeof(res)); |
return (void *)&res; |
return (void *)&res; |
} |
} |
|
|
static void * |
static void * |
|
/*ARGSUSED*/ |
ypbindproc_domain_2(SVCXPRT *transp, void *argp) |
ypbindproc_domain_2(SVCXPRT *transp, void *argp) |
{ |
{ |
static struct ypbind_resp res; |
static struct ypbind_resp res; |
Line 245 ypbindproc_domain_2(SVCXPRT *transp, voi |
|
Line 247 ypbindproc_domain_2(SVCXPRT *transp, voi |
|
|
|
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("ypbindproc_domain_2 %s\n", arg); |
(void)printf("ypbindproc_domain_2 %s\n", arg); |
#endif |
#endif |
if (_yp_invalid_domain(arg)) |
if (_yp_invalid_domain(arg)) |
return NULL; |
return NULL; |
Line 274 ypbindproc_domain_2(SVCXPRT *transp, voi |
|
Line 276 ypbindproc_domain_2(SVCXPRT *transp, voi |
|
check++; |
check++; |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("unknown domain %s\n", arg); |
(void)printf("unknown domain %s\n", arg); |
#endif |
#endif |
return NULL; |
return NULL; |
} |
} |
Line 282 ypbindproc_domain_2(SVCXPRT *transp, voi |
|
Line 284 ypbindproc_domain_2(SVCXPRT *transp, voi |
|
if (ypdb->dom_alive == 0) { |
if (ypdb->dom_alive == 0) { |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("dead domain %s\n", arg); |
(void)printf("dead domain %s\n", arg); |
#endif |
#endif |
return NULL; |
return NULL; |
} |
} |
|
|
#ifdef HEURISTIC |
#ifdef HEURISTIC |
time(&now); |
(void)time(&now); |
if (now < ypdb->dom_ask_t + 5) { |
if (now < ypdb->dom_ask_t + 5) { |
/* |
/* |
* Hmm. More than 2 requests in 5 seconds have indicated |
* Hmm. More than 2 requests in 5 seconds have indicated |
Line 311 ypbindproc_domain_2(SVCXPRT *transp, voi |
|
Line 313 ypbindproc_domain_2(SVCXPRT *transp, voi |
|
ypdb->dom_server_addr.sin_port; |
ypdb->dom_server_addr.sin_port; |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("domain %s at %s/%d\n", ypdb->dom_domain, |
(void)printf("domain %s at %s/%d\n", ypdb->dom_domain, |
inet_ntoa(ypdb->dom_server_addr.sin_addr), |
inet_ntoa(ypdb->dom_server_addr.sin_addr), |
ntohs(ypdb->dom_server_addr.sin_port)); |
ntohs(ypdb->dom_server_addr.sin_port)); |
#endif |
#endif |
Line 327 ypbindproc_setdom_2(SVCXPRT *transp, voi |
|
Line 329 ypbindproc_setdom_2(SVCXPRT *transp, voi |
|
|
|
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("ypbindproc_setdom_2 %s\n", inet_ntoa(bindsin.sin_addr)); |
(void)printf("ypbindproc_setdom_2 %s\n", inet_ntoa(bindsin.sin_addr)); |
#endif |
#endif |
(void)memset(&res, 0, sizeof(res)); |
(void)memset(&res, 0, sizeof(res)); |
fromsin = svc_getcaller(transp); |
fromsin = svc_getcaller(transp); |
Line 337 ypbindproc_setdom_2(SVCXPRT *transp, voi |
|
Line 339 ypbindproc_setdom_2(SVCXPRT *transp, voi |
|
if (fromsin->sin_addr.s_addr != htonl(INADDR_LOOPBACK)) { |
if (fromsin->sin_addr.s_addr != htonl(INADDR_LOOPBACK)) { |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("ypset from %s denied\n", |
(void)printf("ypset from %s denied\n", |
inet_ntoa(fromsin->sin_addr)); |
inet_ntoa(fromsin->sin_addr)); |
#endif |
#endif |
return NULL; |
return NULL; |
Line 353 ypbindproc_setdom_2(SVCXPRT *transp, voi |
|
Line 355 ypbindproc_setdom_2(SVCXPRT *transp, voi |
|
default: |
default: |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("ypset denied\n"); |
(void)printf("ypset denied\n"); |
#endif |
#endif |
return NULL; |
return NULL; |
} |
} |
Line 361 ypbindproc_setdom_2(SVCXPRT *transp, voi |
|
Line 363 ypbindproc_setdom_2(SVCXPRT *transp, voi |
|
if (ntohs(fromsin->sin_port) >= IPPORT_RESERVED) { |
if (ntohs(fromsin->sin_port) >= IPPORT_RESERVED) { |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("ypset from unprivileged port denied\n"); |
(void)printf("ypset from unprivileged port denied\n"); |
#endif |
#endif |
return &res; |
return &res; |
} |
} |
Line 369 ypbindproc_setdom_2(SVCXPRT *transp, voi |
|
Line 371 ypbindproc_setdom_2(SVCXPRT *transp, voi |
|
if (sd->ypsetdom_vers != YPVERS) { |
if (sd->ypsetdom_vers != YPVERS) { |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("ypset with wrong version denied\n"); |
(void)printf("ypset with wrong version denied\n"); |
#endif |
#endif |
return &res; |
return &res; |
} |
} |
Line 383 ypbindproc_setdom_2(SVCXPRT *transp, voi |
|
Line 385 ypbindproc_setdom_2(SVCXPRT *transp, voi |
|
|
|
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("ypset to %s succeeded\n", inet_ntoa(bindsin.sin_addr)); |
(void)printf("ypset to %s succeeded\n", inet_ntoa(bindsin.sin_addr)); |
#endif |
#endif |
res = 1; |
res = 1; |
return &res; |
return &res; |
Line 439 ypbindprog_2(struct svc_req *rqstp, regi |
|
Line 441 ypbindprog_2(struct svc_req *rqstp, regi |
|
return; |
return; |
} |
} |
(void)memset(&argument, 0, sizeof(argument)); |
(void)memset(&argument, 0, sizeof(argument)); |
if (!svc_getargs(transp, xdr_argument, (caddr_t)&argument)) { |
if (!svc_getargs(transp, xdr_argument, (caddr_t)(void *)&argument)) { |
svcerr_decode(transp); |
svcerr_decode(transp); |
return; |
return; |
} |
} |
Line 460 main(int argc, char *argv[]) |
|
Line 462 main(int argc, char *argv[]) |
|
char pathname[MAXPATHLEN]; |
char pathname[MAXPATHLEN]; |
struct stat st; |
struct stat st; |
|
|
yp_get_default_domain(&domainname); |
setprogname(argv[0]); |
|
(void)yp_get_default_domain(&domainname); |
if (domainname[0] == '\0') |
if (domainname[0] == '\0') |
errx(1, "Domainname not set. Aborting."); |
errx(1, "Domainname not set. Aborting."); |
|
|
Line 471 main(int argc, char *argv[]) |
|
Line 474 main(int argc, char *argv[]) |
|
* Note that we can still override direct mode by passing |
* Note that we can still override direct mode by passing |
* the -broadcast flag. |
* the -broadcast flag. |
*/ |
*/ |
snprintf(pathname, sizeof(pathname), "%s/%s%s", BINDINGDIR, |
(void)snprintf(pathname, sizeof(pathname), "%s/%s%s", BINDINGDIR, |
domainname, YPSERVERSSUFF); |
domainname, YPSERVERSSUFF); |
if (stat(pathname, &st) < 0) { |
if (stat(pathname, &st) < 0) { |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
fprintf(stderr, |
(void)printf("%s does not exist, defaulting to " |
"%s does not exist, defaulting to broadcast\n", |
"broadcast\n", pathname); |
pathname); |
|
#endif |
#endif |
ypbindmode = YPBIND_BROADCAST; |
ypbindmode = YPBIND_BROADCAST; |
} else |
} else |
Line 543 main(int argc, char *argv[]) |
|
Line 545 main(int argc, char *argv[]) |
|
(void)fcntl(pingsock, F_SETFL, fcntl(pingsock, F_GETFL, 0) | FNDELAY); |
(void)fcntl(pingsock, F_SETFL, fcntl(pingsock, F_GETFL, 0) | FNDELAY); |
|
|
one = 1; |
one = 1; |
(void)setsockopt(rpcsock, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)); |
(void)setsockopt(rpcsock, SOL_SOCKET, SO_BROADCAST, &one, |
|
(socklen_t)sizeof(one)); |
rmtca.prog = YPPROG; |
rmtca.prog = YPPROG; |
rmtca.vers = YPVERS; |
rmtca.vers = YPVERS; |
rmtca.proc = YPPROC_DOMAIN_NONACK; |
rmtca.proc = YPPROC_DOMAIN_NONACK; |
Line 551 main(int argc, char *argv[]) |
|
Line 554 main(int argc, char *argv[]) |
|
rmtca.args_ptr = NULL; /* set at call time */ |
rmtca.args_ptr = NULL; /* set at call time */ |
rmtcr.port_ptr = &rmtcr_port; |
rmtcr.port_ptr = &rmtcr_port; |
rmtcr.xdr_results = xdr_bool; |
rmtcr.xdr_results = xdr_bool; |
rmtcr.results_ptr = (caddr_t)&rmtcr_outval; |
rmtcr.results_ptr = (caddr_t)(void *)&rmtcr_outval; |
|
|
if (_yp_invalid_domain(domainname)) |
if (_yp_invalid_domain(domainname)) |
errx(1, "bad domainname: %s", domainname); |
errx(1, "bad domainname: %s", domainname); |
Line 587 main(int argc, char *argv[]) |
|
Line 590 main(int argc, char *argv[]) |
|
break; |
break; |
default: |
default: |
if (FD_ISSET(rpcsock, &fdsr)) |
if (FD_ISSET(rpcsock, &fdsr)) |
handle_replies(); |
(void)handle_replies(); |
if (FD_ISSET(pingsock, &fdsr)) |
if (FD_ISSET(pingsock, &fdsr)) |
handle_ping(); |
(void)handle_ping(); |
svc_getreqset(&fdsr); |
svc_getreqset(&fdsr); |
if (check) |
if (check) |
checkwork(); |
checkwork(); |
Line 601 main(int argc, char *argv[]) |
|
Line 604 main(int argc, char *argv[]) |
|
#ifdef DEBUG |
#ifdef DEBUG |
if (!debug) |
if (!debug) |
#endif |
#endif |
daemon(0, 0); |
(void)daemon(0, 0); |
pidfile(NULL); |
(void)pidfile(NULL); |
} |
} |
} |
} |
} |
} |
|
|
|
|
check = 0; |
check = 0; |
|
|
time(&t); |
(void)time(&t); |
for (ypdb = ypbindlist; ypdb; ypdb = ypdb->dom_pnext) { |
for (ypdb = ypbindlist; ypdb; ypdb = ypdb->dom_pnext) { |
if (ypdb->dom_check_t < t) { |
if (ypdb->dom_check_t < t) { |
if (ypdb->dom_alive == 1) |
if (ypdb->dom_alive == 1) |
ping(ypdb); |
(void)ping(ypdb); |
else |
else |
nag_servers(ypdb); |
(void)nag_servers(ypdb); |
time(&t); |
(void)time(&t); |
ypdb->dom_check_t = t + 5; |
ypdb->dom_check_t = t + 5; |
} |
} |
} |
} |
Line 656 ping(struct _dom_binding *ypdb) |
|
Line 659 ping(struct _dom_binding *ypdb) |
|
if (rpcua == NULL) { |
if (rpcua == NULL) { |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("cannot get unix auth\n"); |
(void)printf("cannot get unix auth\n"); |
#endif |
#endif |
return RPC_SYSTEMERROR; |
return RPC_SYSTEMERROR; |
} |
} |
Line 670 ping(struct _dom_binding *ypdb) |
|
Line 673 ping(struct _dom_binding *ypdb) |
|
msg.rm_call.cb_verf = rpcua->ah_verf; |
msg.rm_call.cb_verf = rpcua->ah_verf; |
|
|
msg.rm_xid = ypdb->dom_xid; |
msg.rm_xid = ypdb->dom_xid; |
xdrmem_create(&xdr, buf, sizeof buf, XDR_ENCODE); |
xdrmem_create(&xdr, buf, (u_int)sizeof(buf), XDR_ENCODE); |
if (!xdr_callmsg(&xdr, &msg)) { |
if (!xdr_callmsg(&xdr, &msg)) { |
st = RPC_CANTENCODEARGS; |
st = RPC_CANTENCODEARGS; |
AUTH_DESTROY(rpcua); |
AUTH_DESTROY(rpcua); |
Line 691 ping(struct _dom_binding *ypdb) |
|
Line 694 ping(struct _dom_binding *ypdb) |
|
AUTH_DESTROY(rpcua); |
AUTH_DESTROY(rpcua); |
|
|
ypdb->dom_alive = 2; |
ypdb->dom_alive = 2; |
|
#ifdef DEBUG |
|
if (debug) |
|
(void)printf("ping %x\n", |
|
ypdb->dom_server_addr.sin_addr.s_addr); |
|
#endif |
if (sendto(pingsock, buf, outlen, 0, |
if (sendto(pingsock, buf, outlen, 0, |
(struct sockaddr *)&ypdb->dom_server_addr, |
(struct sockaddr *)(void *)&ypdb->dom_server_addr, |
sizeof ypdb->dom_server_addr) == -1) |
(socklen_t)sizeof ypdb->dom_server_addr) == -1) |
yp_log(LOG_WARNING, "ping: sendto: %m"); |
yp_log(LOG_WARNING, "ping: sendto: %m"); |
return 0; |
return 0; |
|
|
Line 710 nag_servers(struct _dom_binding *ypdb) |
|
Line 718 nag_servers(struct _dom_binding *ypdb) |
|
AUTH *rpcua; |
AUTH *rpcua; |
XDR xdr; |
XDR xdr; |
|
|
|
#ifdef DEBUG |
|
if (debug) |
|
(void)printf("nag_servers\n"); |
|
#endif |
rmtca.xdr_args = xdr_ypdomain_wrap_string; |
rmtca.xdr_args = xdr_ypdomain_wrap_string; |
rmtca.args_ptr = (char *)&dom; |
rmtca.args_ptr = (caddr_t)(void *)&dom; |
|
|
(void)memset(&xdr, 0, sizeof xdr); |
(void)memset(&xdr, 0, sizeof xdr); |
(void)memset(&msg, 0, sizeof msg); |
(void)memset(&msg, 0, sizeof msg); |
Line 720 nag_servers(struct _dom_binding *ypdb) |
|
Line 732 nag_servers(struct _dom_binding *ypdb) |
|
if (rpcua == NULL) { |
if (rpcua == NULL) { |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("cannot get unix auth\n"); |
(void)printf("cannot get unix auth\n"); |
#endif |
#endif |
return RPC_SYSTEMERROR; |
return RPC_SYSTEMERROR; |
} |
} |
Line 733 nag_servers(struct _dom_binding *ypdb) |
|
Line 745 nag_servers(struct _dom_binding *ypdb) |
|
msg.rm_call.cb_verf = rpcua->ah_verf; |
msg.rm_call.cb_verf = rpcua->ah_verf; |
|
|
msg.rm_xid = ypdb->dom_xid; |
msg.rm_xid = ypdb->dom_xid; |
xdrmem_create(&xdr, buf, sizeof buf, XDR_ENCODE); |
xdrmem_create(&xdr, buf, (u_int)sizeof(buf), XDR_ENCODE); |
if (!xdr_callmsg(&xdr, &msg)) { |
if (!xdr_callmsg(&xdr, &msg)) { |
st = RPC_CANTENCODEARGS; |
st = RPC_CANTENCODEARGS; |
AUTH_DESTROY(rpcua); |
AUTH_DESTROY(rpcua); |
Line 767 nag_servers(struct _dom_binding *ypdb) |
|
Line 779 nag_servers(struct _dom_binding *ypdb) |
|
*/ |
*/ |
struct sockaddr_in bindsin; |
struct sockaddr_in bindsin; |
|
|
memset(&bindsin, 0, sizeof bindsin); |
(void)memset(&bindsin, 0, sizeof bindsin); |
bindsin.sin_family = AF_INET; |
bindsin.sin_family = AF_INET; |
bindsin.sin_len = sizeof(bindsin); |
bindsin.sin_len = sizeof(bindsin); |
bindsin.sin_port = htons(PMAPPORT); |
bindsin.sin_port = htons(PMAPPORT); |
bindsin.sin_addr = ypdb->dom_server_addr.sin_addr; |
bindsin.sin_addr = ypdb->dom_server_addr.sin_addr; |
|
|
if (sendto(rpcsock, buf, outlen, 0, (struct sockaddr *)&bindsin, |
if (sendto(rpcsock, buf, outlen, 0, |
sizeof bindsin) == -1) |
(struct sockaddr *)(void *)&bindsin, |
|
(socklen_t)sizeof bindsin) == -1) |
yp_log(LOG_WARNING, "nag_servers: sendto: %m"); |
yp_log(LOG_WARNING, "nag_servers: sendto: %m"); |
} |
} |
|
|
Line 791 nag_servers(struct _dom_binding *ypdb) |
|
Line 804 nag_servers(struct _dom_binding *ypdb) |
|
case YPBIND_DIRECT: |
case YPBIND_DIRECT: |
return direct(buf, outlen); |
return direct(buf, outlen); |
} |
} |
|
/*NOTREACHED*/ |
return -1; |
return -1; |
} |
} |
|
|
Line 802 broadcast(char *buf, int outlen) |
|
Line 815 broadcast(char *buf, int outlen) |
|
struct sockaddr_in bindsin; |
struct sockaddr_in bindsin; |
struct in_addr in; |
struct in_addr in; |
|
|
memset(&bindsin, 0, sizeof bindsin); |
(void)memset(&bindsin, 0, sizeof bindsin); |
bindsin.sin_family = AF_INET; |
bindsin.sin_family = AF_INET; |
bindsin.sin_len = sizeof(bindsin); |
bindsin.sin_len = sizeof(bindsin); |
bindsin.sin_port = htons(PMAPPORT); |
bindsin.sin_port = htons(PMAPPORT); |
Line 823 broadcast(char *buf, int outlen) |
|
Line 836 broadcast(char *buf, int outlen) |
|
continue; |
continue; |
if (ifa->ifa_broadaddr->sa_family != AF_INET) |
if (ifa->ifa_broadaddr->sa_family != AF_INET) |
continue; |
continue; |
in = ((struct sockaddr_in *)ifa->ifa_broadaddr)->sin_addr; |
in = ((struct sockaddr_in *)(void *)ifa->ifa_broadaddr)->sin_addr; |
break; |
break; |
case IFF_LOOPBACK: |
case IFF_LOOPBACK: |
in = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr; |
in = ((struct sockaddr_in *)(void *)ifa->ifa_addr)->sin_addr; |
break; |
break; |
default: |
default: |
continue; |
continue; |
} |
} |
|
|
bindsin.sin_addr = in; |
bindsin.sin_addr = in; |
if (sendto(rpcsock, buf, outlen, 0, (struct sockaddr *)&bindsin, |
#ifdef DEBUG |
bindsin.sin_len) == -1) |
if (debug) |
|
(void)printf("broadcast %x\n", |
|
bindsin.sin_addr.s_addr); |
|
#endif |
|
if (sendto(rpcsock, buf, outlen, 0, |
|
(struct sockaddr *)(void *)&bindsin, |
|
(socklen_t)bindsin.sin_len) == -1) |
yp_log(LOG_WARNING, "broadcast: sendto: %m"); |
yp_log(LOG_WARNING, "broadcast: sendto: %m"); |
} |
} |
freeifaddrs(ifap); |
freeifaddrs(ifap); |
Line 855 direct(char *buf, int outlen) |
|
Line 874 direct(char *buf, int outlen) |
|
if (df) |
if (df) |
rewind(df); |
rewind(df); |
else { |
else { |
snprintf(ypservers_path, sizeof(ypservers_path), |
(void)snprintf(ypservers_path, sizeof(ypservers_path), |
"%s/%s%s", BINDINGDIR, domainname, YPSERVERSSUFF); |
"%s/%s%s", BINDINGDIR, domainname, YPSERVERSSUFF); |
df = fopen(ypservers_path, "r"); |
df = fopen(ypservers_path, "r"); |
if (df == NULL) { |
if (df == NULL) { |
Line 864 direct(char *buf, int outlen) |
|
Line 883 direct(char *buf, int outlen) |
|
} |
} |
} |
} |
|
|
memset(&bindsin, 0, sizeof bindsin); |
(void)memset(&bindsin, 0, sizeof bindsin); |
bindsin.sin_family = AF_INET; |
bindsin.sin_family = AF_INET; |
bindsin.sin_len = sizeof(bindsin); |
bindsin.sin_len = sizeof(bindsin); |
bindsin.sin_port = htons(PMAPPORT); |
bindsin.sin_port = htons(PMAPPORT); |
|
|
while(fgets(line, sizeof(line), df) != NULL) { |
while(fgets(line, (int)sizeof(line), df) != NULL) { |
/* skip lines that are too big */ |
/* skip lines that are too big */ |
p = strchr(line, '\n'); |
p = strchr(line, '\n'); |
if (p == NULL) { |
if (p == NULL) { |
Line 892 direct(char *buf, int outlen) |
|
Line 911 direct(char *buf, int outlen) |
|
} |
} |
/* step through all addresses in case first is unavailable */ |
/* step through all addresses in case first is unavailable */ |
for (i = 0; hp->h_addr_list[i]; i++) { |
for (i = 0; hp->h_addr_list[i]; i++) { |
memmove(&bindsin.sin_addr, hp->h_addr_list[0], |
(void)memcpy(&bindsin.sin_addr, hp->h_addr_list[0], |
hp->h_length); |
hp->h_length); |
if (sendto(rpcsock, buf, outlen, 0, |
if (sendto(rpcsock, buf, outlen, 0, |
(struct sockaddr *)&bindsin, sizeof bindsin) < 0) { |
(struct sockaddr *)(void *)&bindsin, |
|
(socklen_t)sizeof(bindsin)) < 0) { |
yp_log(LOG_WARNING, "direct: sendto: %m"); |
yp_log(LOG_WARNING, "direct: sendto: %m"); |
continue; |
continue; |
} else |
} else |
Line 918 direct_set(char *buf, int outlen, struct |
|
Line 938 direct_set(char *buf, int outlen, struct |
|
struct iovec iov[2]; |
struct iovec iov[2]; |
struct ypbind_resp ybr; |
struct ypbind_resp ybr; |
SVCXPRT dummy_svc; |
SVCXPRT dummy_svc; |
int fd, bytes; |
int fd; |
|
ssize_t bytes; |
|
|
/* |
/* |
* Gack, we lose if binding file went away. We reset |
* Gack, we lose if binding file went away. We reset |
* "been_set" if this happens, otherwise we'll never |
* "been_set" if this happens, otherwise we'll never |
* bind again. |
* bind again. |
*/ |
*/ |
snprintf(path, sizeof(path), "%s/%s.%ld", BINDINGDIR, |
(void)snprintf(path, sizeof(path), "%s/%s.%ld", BINDINGDIR, |
ypdb->dom_domain, ypdb->dom_vers); |
ypdb->dom_domain, ypdb->dom_vers); |
|
|
if ((fd = open(path, O_SHLOCK|O_RDONLY, 0644)) == -1) { |
if ((fd = open(path, O_SHLOCK|O_RDONLY, 0644)) == -1) { |
Line 939 direct_set(char *buf, int outlen, struct |
|
Line 960 direct_set(char *buf, int outlen, struct |
|
#endif |
#endif |
|
|
/* Read the binding file... */ |
/* Read the binding file... */ |
iov[0].iov_base = (caddr_t)&(dummy_svc.xp_port); |
iov[0].iov_base = &(dummy_svc.xp_port); |
iov[0].iov_len = sizeof(dummy_svc.xp_port); |
iov[0].iov_len = sizeof(dummy_svc.xp_port); |
iov[1].iov_base = (caddr_t)&ybr; |
iov[1].iov_base = &ybr; |
iov[1].iov_len = sizeof(ybr); |
iov[1].iov_len = sizeof(ybr); |
bytes = readv(fd, iov, 2); |
bytes = readv(fd, iov, 2); |
(void)close(fd); |
(void)close(fd); |
Line 955 direct_set(char *buf, int outlen, struct |
|
Line 976 direct_set(char *buf, int outlen, struct |
|
bindsin.sin_addr = |
bindsin.sin_addr = |
ybr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr; |
ybr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr; |
|
|
if (sendto(rpcsock, buf, outlen, 0, (struct sockaddr *)&bindsin, |
if (sendto(rpcsock, buf, outlen, 0, |
sizeof(bindsin)) < 0) { |
(struct sockaddr *)(void *)&bindsin, |
|
(socklen_t)sizeof(bindsin)) < 0) { |
yp_log(LOG_WARNING, "direct_set: sendto: %m"); |
yp_log(LOG_WARNING, "direct_set: sendto: %m"); |
return -1; |
return -1; |
} |
} |
Line 969 handle_replies(void) |
|
Line 991 handle_replies(void) |
|
{ |
{ |
char buf[BUFSIZE]; |
char buf[BUFSIZE]; |
socklen_t fromlen; |
socklen_t fromlen; |
int inlen; |
ssize_t inlen; |
struct _dom_binding *ypdb; |
struct _dom_binding *ypdb; |
struct sockaddr_in raddr; |
struct sockaddr_in raddr; |
struct rpc_msg msg; |
struct rpc_msg msg; |
XDR xdr; |
XDR xdr; |
|
|
recv_again: |
recv_again: |
|
#ifdef DEBUG |
|
if (debug) |
|
printf("handle_replies receiving\n"); |
|
#endif |
(void)memset(&xdr, 0, sizeof(xdr)); |
(void)memset(&xdr, 0, sizeof(xdr)); |
(void)memset(&msg, 0, sizeof(msg)); |
(void)memset(&msg, 0, sizeof(msg)); |
msg.acpted_rply.ar_verf = _null_auth; |
msg.acpted_rply.ar_verf = _null_auth; |
msg.acpted_rply.ar_results.where = (caddr_t)&rmtcr; |
msg.acpted_rply.ar_results.where = (caddr_t)(void *)&rmtcr; |
msg.acpted_rply.ar_results.proc = xdr_rmtcallres; |
msg.acpted_rply.ar_results.proc = xdr_rmtcallres; |
|
|
try_again: |
try_again: |
fromlen = sizeof(struct sockaddr); |
fromlen = sizeof(struct sockaddr); |
inlen = recvfrom(rpcsock, buf, sizeof buf, 0, |
inlen = recvfrom(rpcsock, buf, sizeof buf, 0, |
(struct sockaddr *)&raddr, &fromlen); |
(struct sockaddr *)(void *)&raddr, &fromlen); |
if (inlen < 0) { |
if (inlen < 0) { |
if (errno == EINTR) |
if (errno == EINTR) |
goto try_again; |
goto try_again; |
|
#ifdef DEBUG |
|
if (debug) |
|
printf("handle_replies: recvfrom failed (%s)\n", |
|
strerror(errno)); |
|
#endif |
return RPC_CANTRECV; |
return RPC_CANTRECV; |
} |
} |
if (inlen < sizeof(u_int32_t)) |
if (inlen < sizeof(u_int32_t)) |
Line 1020 handle_ping(void) |
|
Line 1051 handle_ping(void) |
|
{ |
{ |
char buf[BUFSIZE]; |
char buf[BUFSIZE]; |
socklen_t fromlen; |
socklen_t fromlen; |
int inlen; |
ssize_t inlen; |
struct _dom_binding *ypdb; |
struct _dom_binding *ypdb; |
struct sockaddr_in raddr; |
struct sockaddr_in raddr; |
struct rpc_msg msg; |
struct rpc_msg msg; |
Line 1028 handle_ping(void) |
|
Line 1059 handle_ping(void) |
|
bool_t res; |
bool_t res; |
|
|
recv_again: |
recv_again: |
|
#ifdef DEBUG |
|
if (debug) |
|
printf("handle_ping receiving\n"); |
|
#endif |
(void)memset(&xdr, 0, sizeof(xdr)); |
(void)memset(&xdr, 0, sizeof(xdr)); |
(void)memset(&msg, 0, sizeof(msg)); |
(void)memset(&msg, 0, sizeof(msg)); |
msg.acpted_rply.ar_verf = _null_auth; |
msg.acpted_rply.ar_verf = _null_auth; |
msg.acpted_rply.ar_results.where = (caddr_t)&res; |
msg.acpted_rply.ar_results.where = (caddr_t)(void *)&res; |
msg.acpted_rply.ar_results.proc = xdr_bool; |
msg.acpted_rply.ar_results.proc = xdr_bool; |
|
|
try_again: |
try_again: |
fromlen = sizeof (struct sockaddr); |
fromlen = sizeof (struct sockaddr); |
inlen = recvfrom(pingsock, buf, sizeof buf, 0, |
inlen = recvfrom(pingsock, buf, sizeof buf, 0, |
(struct sockaddr *)&raddr, &fromlen); |
(struct sockaddr *)(void *)&raddr, &fromlen); |
if (inlen < 0) { |
if (inlen < 0) { |
if (errno == EINTR) |
if (errno == EINTR) |
goto try_again; |
goto try_again; |
|
#ifdef DEBUG |
|
if (debug) |
|
printf("handle_ping: recvfrom failed (%s)\n", |
|
strerror(errno)); |
|
#endif |
return RPC_CANTRECV; |
return RPC_CANTRECV; |
} |
} |
if (inlen < sizeof(u_int32_t)) |
if (inlen < sizeof(u_int32_t)) |
Line 1079 rpc_received(char *dom, struct sockaddr_ |
|
Line 1119 rpc_received(char *dom, struct sockaddr_ |
|
|
|
#ifdef DEBUG |
#ifdef DEBUG |
if (debug) |
if (debug) |
printf("returned from %s about %s\n", |
(void)printf("returned from %s about %s\n", |
inet_ntoa(raddrp->sin_addr), dom); |
inet_ntoa(raddrp->sin_addr), dom); |
#endif |
#endif |
|
|
Line 1136 rpc_received(char *dom, struct sockaddr_ |
|
Line 1176 rpc_received(char *dom, struct sockaddr_ |
|
*/ |
*/ |
ypdb->dom_lockfd = fd; |
ypdb->dom_lockfd = fd; |
|
|
iov[0].iov_base = (caddr_t)&(udptransp->xp_port); |
iov[0].iov_base = &(udptransp->xp_port); |
iov[0].iov_len = sizeof udptransp->xp_port; |
iov[0].iov_len = sizeof udptransp->xp_port; |
iov[1].iov_base = (caddr_t)&ybr; |
iov[1].iov_base = &ybr; |
iov[1].iov_len = sizeof ybr; |
iov[1].iov_len = sizeof ybr; |
|
|
(void)memset(&ybr, 0, sizeof ybr); |
(void)memset(&ybr, 0, sizeof ybr); |
Line 1173 unique_xid(struct _dom_binding *ypdb) |
|
Line 1213 unique_xid(struct _dom_binding *ypdb) |
|
{ |
{ |
u_int32_t tmp_xid; |
u_int32_t tmp_xid; |
|
|
tmp_xid = (u_int32_t)(((u_long)ypdb) & 0xffffffff); |
tmp_xid = ((u_int32_t)(u_long)ypdb) & 0xffffffff; |
while (xid2ypdb(tmp_xid) != NULL) |
while (xid2ypdb(tmp_xid) != NULL) |
tmp_xid++; |
tmp_xid++; |
|
|