summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-07-04 15:35:18 -0400
committerStephen Gallagher <sgallagh@redhat.com>2011-07-05 13:29:16 -0400
commit5dcaf08d0ae528318d2fb7dd9a6d37abbface6b8 (patch)
tree5477a4ad8a06f83e425191e09c1e3f58d14f6cc6
parent87f3fa68e8223111bd53e4bc7a4842b1a35f0ee7 (diff)
downloadsssd-5dcaf08d0ae528318d2fb7dd9a6d37abbface6b8.tar.gz
sssd-5dcaf08d0ae528318d2fb7dd9a6d37abbface6b8.tar.bz2
sssd-5dcaf08d0ae528318d2fb7dd9a6d37abbface6b8.zip
ipa_dyndns: Use sockaddr_storage for storing IP addresses
https://fedorahosted.org/sssd/ticket/915
-rw-r--r--src/providers/ipa/ipa_dyndns.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/providers/ipa/ipa_dyndns.c b/src/providers/ipa/ipa_dyndns.c
index cdee518b..72e4ba4d 100644
--- a/src/providers/ipa/ipa_dyndns.c
+++ b/src/providers/ipa/ipa_dyndns.c
@@ -45,7 +45,7 @@ struct ipa_ipaddress {
struct ipa_ipaddress *next;
struct ipa_ipaddress *prev;
- struct sockaddr *addr;
+ struct sockaddr_storage *addr;
bool matched;
};
@@ -93,6 +93,7 @@ ipa_dyndns_update_send(struct ipa_options *ctx)
struct ifaddrs *ifa;
struct ipa_ipaddress *address;
struct tevent_req *req, *subreq;
+ size_t addrsize;
DEBUG (9, ("Performing update\n"));
@@ -132,8 +133,12 @@ ipa_dyndns_update_send(struct ipa_options *ctx)
goto failed;
}
+ addrsize = ifa->ifa_addr->sa_family == AF_INET ? \
+ sizeof(struct sockaddr_in) : \
+ sizeof(struct sockaddr_in6);
+
address->addr = talloc_memdup(address, ifa->ifa_addr,
- sizeof(struct sockaddr));
+ addrsize);
if(address->addr == NULL) {
goto failed;
}
@@ -219,8 +224,8 @@ static int ipa_dyndns_add_ldap_iface(struct ipa_dyndns_ctx *state,
int ret;
int fd;
struct ipa_ipaddress *address;
- struct sockaddr sa;
- socklen_t sa_len = sizeof(sa);
+ struct sockaddr_storage ss;
+ socklen_t ss_len = sizeof(ss);
if (!sh) {
return EINVAL;
@@ -232,21 +237,21 @@ static int ipa_dyndns_add_ldap_iface(struct ipa_dyndns_ctx *state,
return ret;
}
- ret = getsockname(fd, &sa, &sa_len);
+ ret = getsockname(fd, (struct sockaddr *) &ss, &ss_len);
if (ret == -1) {
DEBUG(0,("Failed to get socket name\n"));
return errno;
}
- switch(sa.sa_family) {
+ switch(ss.ss_family) {
case AF_INET:
case AF_INET6:
address = talloc(state, struct ipa_ipaddress);
if (!address) {
return ENOMEM;
}
- address->addr = talloc_memdup(address, &sa,
- sizeof(struct sockaddr));
+ address->addr = talloc_memdup(address, &ss,
+ sizeof(struct sockaddr_storage));
if(address->addr == NULL) {
talloc_zfree(address);
return ENOMEM;
@@ -425,9 +430,9 @@ static int create_nsupdate_message(struct ipa_nsupdate_ctx *ctx,
}
DLIST_FOR_EACH(new_record, ctx->dyndns_ctx->addresses) {
- switch(new_record->addr->sa_family) {
+ switch(new_record->addr->ss_family) {
case AF_INET:
- ip = inet_ntop(new_record->addr->sa_family,
+ ip = inet_ntop(new_record->addr->ss_family,
&(((struct sockaddr_in *)new_record->addr)->sin_addr),
ip_addr, INET6_ADDRSTRLEN);
if (ip == NULL) {
@@ -437,7 +442,7 @@ static int create_nsupdate_message(struct ipa_nsupdate_ctx *ctx,
break;
case AF_INET6:
- ip = inet_ntop(new_record->addr->sa_family,
+ ip = inet_ntop(new_record->addr->ss_family,
&(((struct sockaddr_in6 *)new_record->addr)->sin6_addr),
ip_addr, INET6_ADDRSTRLEN);
if (ip == NULL) {
@@ -457,7 +462,7 @@ static int create_nsupdate_message(struct ipa_nsupdate_ctx *ctx,
ctx->update_msg,
"update add %s. 86400 in %s %s\n",
ctx->dyndns_ctx->hostname,
- new_record->addr->sa_family == AF_INET ? "A" : "AAAA",
+ new_record->addr->ss_family == AF_INET ? "A" : "AAAA",
ip_addr);
if (ctx->update_msg == NULL) {
ret = ENOMEM;