summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-06-30 23:35:35 +0200
committerStephen Gallagher <sgallagh@redhat.com>2011-07-11 16:52:52 -0400
commit19c6d0bf5346dc1862d14f7f3d886895cfb4d548 (patch)
tree2635f201f7ab2ee115d671a12e8ca7790fddb8e4 /src
parent3136a82b9d76283b10244a9768e1f325503995d5 (diff)
downloadsssd-19c6d0bf5346dc1862d14f7f3d886895cfb4d548.tar.gz
sssd-19c6d0bf5346dc1862d14f7f3d886895cfb4d548.tar.bz2
sssd-19c6d0bf5346dc1862d14f7f3d886895cfb4d548.zip
Allow returning arbitrary address from resolv_hostent as string
Diffstat (limited to 'src')
-rw-r--r--src/resolv/async_resolv.c6
-rw-r--r--src/resolv/async_resolv.h7
2 files changed, 10 insertions, 3 deletions
diff --git a/src/resolv/async_resolv.c b/src/resolv/async_resolv.c
index 4cbb56d8..ef76f171 100644
--- a/src/resolv/async_resolv.c
+++ b/src/resolv/async_resolv.c
@@ -1314,7 +1314,9 @@ resolv_gethostbyname_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
}
char *
-resolv_get_string_address(TALLOC_CTX *mem_ctx, struct resolv_hostent *hostent)
+resolv_get_string_address_index(TALLOC_CTX *mem_ctx,
+ struct resolv_hostent *hostent,
+ unsigned int addrindex)
{
char *address;
@@ -1327,7 +1329,7 @@ resolv_get_string_address(TALLOC_CTX *mem_ctx, struct resolv_hostent *hostent)
}
errno = 0;
- if (inet_ntop(hostent->family, hostent->addr_list[0]->ipaddr,
+ if (inet_ntop(hostent->family, hostent->addr_list[addrindex]->ipaddr,
address, 128) == NULL) {
DEBUG(1, ("inet_ntop failed [%d][%s].\n", errno, strerror(errno)));
talloc_free(address);
diff --git a/src/resolv/async_resolv.h b/src/resolv/async_resolv.h
index 0e203032..8f8ddcbd 100644
--- a/src/resolv/async_resolv.h
+++ b/src/resolv/async_resolv.h
@@ -122,7 +122,12 @@ int resolv_gethostbyname_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
struct resolv_hostent **rhostent);
char *
-resolv_get_string_address(TALLOC_CTX *mem_ctx, struct resolv_hostent *hostent);
+resolv_get_string_address_index(TALLOC_CTX *mem_ctx,
+ struct resolv_hostent *hostent,
+ unsigned int addrindex);
+
+#define resolv_get_string_address(mem_ctx, hostent) \
+ resolv_get_string_address_index(mem_ctx, hostent, 0)
struct sockaddr_storage *
resolv_get_sockaddr_address(TALLOC_CTX *mem_ctx, struct resolv_hostent *hostent,