Correctly inizialize local/unix transport. I broke it in rev.1.15.
PR: bin/1122566 MFC after: 1 week
This commit is contained in:
parent
5ffa507dce
commit
48e5a99e7f
@ -276,6 +276,21 @@ init_transport(struct netconfig *nconf)
|
||||
/*
|
||||
* XXX - using RPC library internal functions.
|
||||
*/
|
||||
if ((strcmp(nconf->nc_netid, "local") == 0) ||
|
||||
(strcmp(nconf->nc_netid, "unix") == 0)) {
|
||||
/*
|
||||
* For other transports we call this later, for each socket we
|
||||
* like to bind.
|
||||
*/
|
||||
if ((fd = __rpc_nconf2fd(nconf)) < 0) {
|
||||
int non_fatal = 0;
|
||||
if (errno == EPROTONOSUPPORT)
|
||||
non_fatal = 1;
|
||||
syslog(non_fatal?LOG_DEBUG:LOG_ERR, "cannot create socket for %s",
|
||||
nconf->nc_netid);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!__rpc_nconf2sockinfo(nconf, &si)) {
|
||||
syslog(LOG_ERR, "cannot get information for %s",
|
||||
@ -301,6 +316,9 @@ init_transport(struct netconfig *nconf)
|
||||
hints.ai_socktype = si.si_socktype;
|
||||
hints.ai_protocol = si.si_proto;
|
||||
}
|
||||
|
||||
if ((strcmp(nconf->nc_netid, "local") != 0) &&
|
||||
(strcmp(nconf->nc_netid, "unix") != 0)) {
|
||||
/*
|
||||
* If no hosts were specified, just bind to INADDR_ANY.
|
||||
* Otherwise make sure 127.0.0.1 is added to the list.
|
||||
@ -433,7 +451,7 @@ init_transport(struct netconfig *nconf)
|
||||
(void)free(uaddr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*ARRIVATO QUI*/
|
||||
if (nconf->nc_semantics != NC_TPI_CLTS)
|
||||
listen(fd, SOMAXCONN);
|
||||
|
||||
@ -447,6 +465,53 @@ init_transport(struct netconfig *nconf)
|
||||
}
|
||||
if (!checkbind)
|
||||
return 1;
|
||||
} else {
|
||||
oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
|
||||
if (bind(fd, sa, addrlen) < 0) {
|
||||
syslog(LOG_ERR, "cannot bind %s: %m", nconf->nc_netid);
|
||||
if (res != NULL)
|
||||
freeaddrinfo(res);
|
||||
return 1;
|
||||
}
|
||||
(void) umask(oldmask);
|
||||
|
||||
/* Copy the address */
|
||||
taddr.addr.len = taddr.addr.maxlen = addrlen;
|
||||
taddr.addr.buf = malloc(addrlen);
|
||||
if (taddr.addr.buf == NULL) {
|
||||
syslog(LOG_ERR, "cannot allocate memory for %s address",
|
||||
nconf->nc_netid);
|
||||
if (res != NULL)
|
||||
freeaddrinfo(res);
|
||||
return 1;
|
||||
}
|
||||
memcpy(taddr.addr.buf, sa, addrlen);
|
||||
#ifdef ND_DEBUG
|
||||
if (debugging) {
|
||||
/* for debugging print out our universal address */
|
||||
char *uaddr;
|
||||
struct netbuf nb;
|
||||
|
||||
nb.buf = sa;
|
||||
nb.len = nb.maxlen = sa->sa_len;
|
||||
uaddr = taddr2uaddr(nconf, &nb);
|
||||
(void) fprintf(stderr, "rpcbind : my address is %s\n",
|
||||
uaddr);
|
||||
(void) free(uaddr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (nconf->nc_semantics != NC_TPI_CLTS)
|
||||
listen(fd, SOMAXCONN);
|
||||
|
||||
my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr,
|
||||
RPC_MAXDATASIZE, RPC_MAXDATASIZE);
|
||||
if (my_xprt == (SVCXPRT *)NULL) {
|
||||
syslog(LOG_ERR, "%s: could not create service",
|
||||
nconf->nc_netid);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PORTMAP
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user