mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 23:10:58 +00:00
avoid writing loopback addresses into CellServDB
Do not use loopback addresses for the server side CellServDB file. Use getaddrinfo() instead of gethostbyname() to look up a list of IPv4 addresses for a given hostname, and take the first non-loopback address. This avoids writing a loopback address into the CellServDB on systems such as Debian, which map the address 127.0.1.1 to the hostname in the /etc/hosts file. Change-Id: I11521df50262ca80c7db21b7b44671d94bef3587 Reviewed-on: http://gerrit.openafs.org/11585 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: D Brashear <shadow@your-file-system.com>
This commit is contained in:
parent
9be7e23cc5
commit
e4a8a7a38d
@ -34,14 +34,30 @@ VerifyEntries(struct afsconf_cell *aci)
|
|||||||
if (aci->hostAddr[i].sin_addr.s_addr == 0) {
|
if (aci->hostAddr[i].sin_addr.s_addr == 0) {
|
||||||
/* no address spec'd */
|
/* no address spec'd */
|
||||||
if (*(aci->hostName[i]) != 0) {
|
if (*(aci->hostName[i]) != 0) {
|
||||||
th = gethostbyname(aci->hostName[i]);
|
int code;
|
||||||
if (!th) {
|
struct addrinfo hints;
|
||||||
printf("Host %s not found in host database...\n",
|
struct addrinfo *result;
|
||||||
aci->hostName[i]);
|
struct addrinfo *rp;
|
||||||
|
|
||||||
|
memset(&hints, 0, sizeof(struct addrinfo));
|
||||||
|
hints.ai_family = AF_INET;
|
||||||
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
|
|
||||||
|
code = getaddrinfo(aci->hostName[i], NULL, &hints, &result);
|
||||||
|
if (code) {
|
||||||
|
return AFSCONF_FAILURE;
|
||||||
|
}
|
||||||
|
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
||||||
|
struct sockaddr_in *sa = (struct sockaddr_in *)rp->ai_addr;
|
||||||
|
if (!rx_IsLoopbackAddr(ntohl(sa->sin_addr.s_addr))) {
|
||||||
|
aci->hostAddr[i].sin_addr.s_addr = sa->sin_addr.s_addr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
freeaddrinfo(result);
|
||||||
|
if (aci->hostAddr[i].sin_addr.s_addr == 0) {
|
||||||
return AFSCONF_FAILURE;
|
return AFSCONF_FAILURE;
|
||||||
}
|
}
|
||||||
memcpy(&aci->hostAddr[i].sin_addr, th->h_addr,
|
|
||||||
sizeof(afs_int32));
|
|
||||||
}
|
}
|
||||||
/* otherwise we're deleting this entry */
|
/* otherwise we're deleting this entry */
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user