More XDR routine cleanups. These three programs should be the only
ones that require this: the others call the yplib functions in libc.
This commit is contained in:
parent
1bce25d080
commit
44e05499de
@ -39,7 +39,8 @@ static char rcsid[] = "ypwhich.c,v 1.2 1993/05/16 02:49:10 deraadt Exp";
|
||||
#include <netdb.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include <rpcsvc/yp_prot.h>
|
||||
#include <rpcsvc/yp.h>
|
||||
struct dom_binding{};
|
||||
#include <rpcsvc/ypclnt.h>
|
||||
|
||||
#define ERR_USAGE 1 /* bad arguments - display 'usage' message */
|
||||
@ -100,7 +101,7 @@ struct sockaddr_in *sin;
|
||||
tv.tv_sec = 5;
|
||||
tv.tv_usec = 0;
|
||||
r = clnt_call(client, YPBINDPROC_DOMAIN,
|
||||
xdr_domainname, dom, xdr_ypbind_resp, &ypbr, tv);
|
||||
xdr_domainname, &dom, xdr_ypbind_resp, &ypbr, tv);
|
||||
if( r != RPC_SUCCESS) {
|
||||
fprintf(stderr, "can't clnt_call: %s\n",
|
||||
yperr_string(YPERR_YPBIND));
|
||||
@ -109,14 +110,14 @@ struct sockaddr_in *sin;
|
||||
} else {
|
||||
if (ypbr.ypbind_status != YPBIND_SUCC_VAL) {
|
||||
fprintf(stderr, "can't yp_bind: Reason: %s\n",
|
||||
ypbinderr_string(ypbr.ypbind_respbody.ypbind_error));
|
||||
ypbinderr_string(ypbr.ypbind_resp_u.ypbind_error));
|
||||
clnt_destroy(client);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
clnt_destroy(client);
|
||||
|
||||
ss_addr = ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr.s_addr;
|
||||
ss_addr = *(u_long *)ypbr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr;
|
||||
/*printf("%08x\n", ss_addr);*/
|
||||
hent = gethostbyaddr((char *)&ss_addr, sizeof(ss_addr), AF_INET);
|
||||
if (hent)
|
||||
@ -227,19 +228,19 @@ char **argv;
|
||||
case 0:
|
||||
for(y=ypml; y; ) {
|
||||
ypml = y;
|
||||
r = yp_master(domainname, ypml->ypml_name, &master);
|
||||
r = yp_master(domainname, ypml->map, &master);
|
||||
switch(r) {
|
||||
case 0:
|
||||
printf("%s %s\n", ypml->ypml_name, master);
|
||||
printf("%s %s\n", ypml->map, master);
|
||||
free(master);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"YP: can't find the master of %s: Reason: %s\n",
|
||||
ypml->ypml_name, yperr_string(r));
|
||||
ypml->map, yperr_string(r));
|
||||
break;
|
||||
}
|
||||
y = ypml->ypml_next;
|
||||
y = ypml->next;
|
||||
free(ypml);
|
||||
}
|
||||
break;
|
||||
|
@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
#ifndef LINT
|
||||
static char rcsid[] = "$Id: ypbind.c,v 1.16 1995/07/15 23:27:27 wpaul Exp $";
|
||||
static char rcsid[] = "$Id: ypbind.c,v 1.17 1995/07/20 22:32:59 wpaul Exp $";
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -58,7 +58,8 @@ static char rcsid[] = "$Id: ypbind.c,v 1.16 1995/07/15 23:27:27 wpaul Exp $";
|
||||
#include <rpc/pmap_rmt.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <rpcsvc/yp_prot.h>
|
||||
#include <rpcsvc/yp.h>
|
||||
struct dom_binding{};
|
||||
#include <rpcsvc/ypclnt.h>
|
||||
|
||||
#ifndef BINDINGDIR
|
||||
@ -102,7 +103,7 @@ void terminate __P((int));
|
||||
void yp_restricted_mode __P((char *));
|
||||
int verify __P((struct in_addr));
|
||||
|
||||
char *domainname;
|
||||
char *domain_name;
|
||||
struct _dom_binding *ypbindlist;
|
||||
static struct _dom_binding *broad_domain;
|
||||
|
||||
@ -162,7 +163,7 @@ CLIENT *clnt;
|
||||
struct ypbind_resp *
|
||||
ypbindproc_domain_2(transp, argp, clnt)
|
||||
SVCXPRT *transp;
|
||||
char *argp;
|
||||
domainname *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
static struct ypbind_resp res;
|
||||
@ -171,33 +172,33 @@ CLIENT *clnt;
|
||||
|
||||
bzero((char *)&res, sizeof res);
|
||||
res.ypbind_status = YPBIND_FAIL_VAL;
|
||||
res.ypbind_respbody.ypbind_error = YPBIND_ERR_NOSERV;
|
||||
res.ypbind_resp_u.ypbind_error = YPBIND_ERR_NOSERV;
|
||||
|
||||
for(ypdb=ypbindlist; ypdb; ypdb=ypdb->dom_pnext) {
|
||||
if( strcmp(ypdb->dom_domain, argp) == 0)
|
||||
if( strcmp(ypdb->dom_domain, *argp) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if(ypdb==NULL) {
|
||||
if (yp_restricted) {
|
||||
syslog(LOG_NOTICE, "Running in restricted mode -- request to bind domain \"%s\" rejected.\n", argp);
|
||||
syslog(LOG_NOTICE, "Running in restricted mode -- request to bind domain \"%s\" rejected.\n", *argp);
|
||||
return &res;
|
||||
}
|
||||
|
||||
if (domains >= MAX_DOMAINS) {
|
||||
syslog(LOG_WARNING, "domain limit (%d) exceeded",
|
||||
MAX_DOMAINS);
|
||||
res.ypbind_respbody.ypbind_error = YPBIND_ERR_RESC;
|
||||
res.ypbind_resp_u.ypbind_error = YPBIND_ERR_RESC;
|
||||
return &res;
|
||||
}
|
||||
ypdb = (struct _dom_binding *)malloc(sizeof *ypdb);
|
||||
if (ypdb == NULL) {
|
||||
syslog(LOG_WARNING, "malloc: %s", strerror(errno));
|
||||
res.ypbind_respbody.ypbind_error = YPBIND_ERR_RESC;
|
||||
res.ypbind_resp_u.ypbind_error = YPBIND_ERR_RESC;
|
||||
return &res;
|
||||
}
|
||||
bzero((char *)ypdb, sizeof *ypdb);
|
||||
strncpy(ypdb->dom_domain, argp, sizeof ypdb->dom_domain);
|
||||
strncpy(ypdb->dom_domain, *argp, sizeof ypdb->dom_domain);
|
||||
ypdb->dom_vers = YPVERS;
|
||||
ypdb->dom_alive = 0;
|
||||
ypdb->dom_default = 0;
|
||||
@ -215,10 +216,10 @@ CLIENT *clnt;
|
||||
}
|
||||
|
||||
res.ypbind_status = YPBIND_SUCC_VAL;
|
||||
res.ypbind_respbody.ypbind_error = 0; /* Success */
|
||||
res.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr.s_addr =
|
||||
res.ypbind_resp_u.ypbind_error = 0; /* Success */
|
||||
*(u_long *)&res.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr =
|
||||
ypdb->dom_server_addr.sin_addr.s_addr;
|
||||
res.ypbind_respbody.ypbind_bindinfo.ypbind_binding_port =
|
||||
*(u_short *)&res.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port =
|
||||
ypdb->dom_server_addr.sin_port;
|
||||
/*printf("domain %s at %s/%d\n", ypdb->dom_domain,
|
||||
inet_ntoa(ypdb->dom_server_addr.sin_addr),
|
||||
@ -229,7 +230,7 @@ CLIENT *clnt;
|
||||
void *
|
||||
ypbindproc_setdom_2(transp, argp, clnt)
|
||||
SVCXPRT *transp;
|
||||
struct ypbind_setdom *argp;
|
||||
ypbind_setdom *argp;
|
||||
CLIENT *clnt;
|
||||
{
|
||||
struct sockaddr_in *fromsin, bindsin;
|
||||
@ -263,8 +264,8 @@ CLIENT *clnt;
|
||||
|
||||
bzero((char *)&bindsin, sizeof bindsin);
|
||||
bindsin.sin_family = AF_INET;
|
||||
bindsin.sin_addr.s_addr = argp->ypsetdom_addr.s_addr;
|
||||
bindsin.sin_port = argp->ypsetdom_port;
|
||||
bindsin.sin_addr.s_addr = *(u_long *)argp->ypsetdom_binding.ypbind_binding_addr;
|
||||
bindsin.sin_port = *(u_short *)argp->ypsetdom_binding.ypbind_binding_port;
|
||||
rpc_received(argp->ypsetdom_domain, &bindsin, 1);
|
||||
|
||||
return;
|
||||
@ -276,7 +277,7 @@ struct svc_req *rqstp;
|
||||
register SVCXPRT *transp;
|
||||
{
|
||||
union {
|
||||
char ypbindproc_domain_2_arg[MAXHOSTNAMELEN];
|
||||
domainname ypbindproc_domain_2_arg;
|
||||
struct ypbind_setdom ypbindproc_setdom_2_arg;
|
||||
} argument;
|
||||
struct authunix_parms *creds;
|
||||
@ -386,8 +387,8 @@ char **argv;
|
||||
}
|
||||
|
||||
/* XXX domainname will be overriden if we use restricted mode */
|
||||
yp_get_default_domain(&domainname);
|
||||
if( domainname[0] == '\0') {
|
||||
yp_get_default_domain(&domain_name);
|
||||
if( domain_name[0] == '\0') {
|
||||
fprintf(stderr, "domainname not set. Aborting.\n");
|
||||
exit(1);
|
||||
}
|
||||
@ -455,7 +456,7 @@ char **argv;
|
||||
exit(1);
|
||||
}
|
||||
bzero((char *)ypbindlist, sizeof *ypbindlist);
|
||||
strncpy(ypbindlist->dom_domain, domainname, sizeof ypbindlist->dom_domain);
|
||||
strncpy(ypbindlist->dom_domain, domain_name, sizeof ypbindlist->dom_domain);
|
||||
ypbindlist->dom_vers = YPVERS;
|
||||
ypbindlist->dom_alive = 0;
|
||||
ypbindlist->dom_lockfd = -1;
|
||||
@ -655,9 +656,14 @@ struct _dom_binding *ypdb;
|
||||
|
||||
retries = 0;
|
||||
|
||||
stat = clnt_broadcast(YPPROG, YPVERS, YPPROC_DOMAIN_NONACK,
|
||||
xdr_domainname, (char *)ypdb->dom_domain, xdr_bool, (char *)&out,
|
||||
broadcast_result);
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
ptr = (char *)&ypdb->dom_domain;
|
||||
stat = clnt_broadcast(YPPROG, YPVERS, YPPROC_DOMAIN_NONACK,
|
||||
xdr_domainname, (char *)&ptr, xdr_bool, (char *)&out,
|
||||
broadcast_result);
|
||||
}
|
||||
|
||||
if (stat != RPC_SUCCESS) {
|
||||
bzero((char *)&ypdb->dom_server_addr,
|
||||
@ -710,14 +716,20 @@ struct _dom_binding *ypdb;
|
||||
return(1);
|
||||
}
|
||||
|
||||
if ((stat = clnt_call(client_handle, YPPROC_DOMAIN,
|
||||
xdr_domainname, (char *)ypdb->dom_domain, xdr_bool,
|
||||
(char *)&out, timeout)) != RPC_SUCCESS || out == FALSE) {
|
||||
ypdb->dom_alive = 0;
|
||||
ypdb->dom_vers = -1;
|
||||
clnt_destroy(client_handle);
|
||||
broadcast(ypdb);
|
||||
return(1);
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
ptr = (char *)&ypdb->dom_domain;
|
||||
|
||||
if ((stat = clnt_call(client_handle, YPPROC_DOMAIN,
|
||||
xdr_domainname, (char *)&ptr, xdr_bool, (char *)&out,
|
||||
timeout)) != RPC_SUCCESS || out == FALSE) {
|
||||
ypdb->dom_alive = 0;
|
||||
ypdb->dom_vers = -1;
|
||||
clnt_destroy(client_handle);
|
||||
broadcast(ypdb);
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
clnt_destroy(client_handle);
|
||||
@ -854,8 +866,8 @@ int force;
|
||||
|
||||
bzero(&ybr, sizeof ybr);
|
||||
ybr.ypbind_status = YPBIND_SUCC_VAL;
|
||||
ybr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr = raddrp->sin_addr;
|
||||
ybr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_port = raddrp->sin_port;
|
||||
*(u_long *)&ybr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr = raddrp->sin_addr.s_addr;
|
||||
*(u_short *)&ybr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port = raddrp->sin_port;
|
||||
|
||||
if( writev(ypdb->dom_lockfd, iov, 2) != iov[0].iov_len + iov[1].iov_len) {
|
||||
syslog(LOG_WARNING, "write: %s", strerror(errno));
|
||||
@ -898,7 +910,7 @@ char *args;
|
||||
/* Find the restricted domain. */
|
||||
if ((s = strsep(&args, ",")) == NULL)
|
||||
return;
|
||||
domainname = s;
|
||||
domain_name = s;
|
||||
|
||||
/* Get the addresses of the servers. */
|
||||
while ((s = strsep(&args, ",")) != NULL && i < RESTRICTED_SERVERS) {
|
||||
|
@ -38,7 +38,8 @@ static char rcsid[] = "ypset.c,v 1.3 1993/06/12 00:02:37 deraadt Exp";
|
||||
#include <netdb.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include <rpcsvc/yp_prot.h>
|
||||
#include <rpcsvc/yp.h>
|
||||
struct dom_binding{};
|
||||
#include <rpcsvc/ypclnt.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
@ -72,17 +73,20 @@ char *dom, *server;
|
||||
|
||||
if( (hp = gethostbyname (server)) != NULL ) {
|
||||
/* is this the most compatible way?? */
|
||||
bcopy (hp->h_addr_list[0], &ypsd.ypsetdom_addr,
|
||||
sizeof (ypsd.ypsetdom_addr));
|
||||
bcopy (hp->h_addr_list[0],
|
||||
(u_long *)&ypsd.ypsetdom_binding.ypbind_binding_addr,
|
||||
sizeof (unsigned long));
|
||||
} else if( (long)(server_addr = inet_addr (server)) == -1) {
|
||||
fprintf(stderr, "can't find address for %s\n", server);
|
||||
exit(1);
|
||||
} else
|
||||
bcopy (&server_addr, &ypsd.ypsetdom_addr,
|
||||
bcopy (&server_addr,
|
||||
*(u_long *)&ypsd.ypsetdom_binding.ypbind_binding_addr,
|
||||
sizeof (server_addr));
|
||||
|
||||
strncpy(ypsd.ypsetdom_domain, dom, sizeof ypsd.ypsetdom_domain);
|
||||
ypsd.ypsetdom_port = port;
|
||||
/* strncpy(ypsd.ypsetdom_domain, dom, sizeof ypsd.ypsetdom_domain); */
|
||||
ypsd.ypsetdom_domain = dom;
|
||||
*(u_long *)&ypsd.ypsetdom_binding.ypbind_binding_port = port;
|
||||
ypsd.ypsetdom_vers = YPVERS;
|
||||
|
||||
tv.tv_sec = 15;
|
||||
|
Loading…
x
Reference in New Issue
Block a user