diff options
author | Michal Zidek <mzidek@redhat.com> | 2012-08-22 15:16:26 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-08-23 18:33:39 +0200 |
commit | b096321a5a02dda0b6b71ba0f9c4d8feacd979e4 (patch) | |
tree | 2c540d0dfdf7a4f84d052f85d9b8e519bf8ebc6a /src | |
parent | 21d485184df986e1a123f70c689517386e51a5ce (diff) | |
download | sssd-b096321a5a02dda0b6b71ba0f9c4d8feacd979e4.tar.gz sssd-b096321a5a02dda0b6b71ba0f9c4d8feacd979e4.tar.xz sssd-b096321a5a02dda0b6b71ba0f9c4d8feacd979e4.zip |
Fix: IPv6 address with square brackets doesn't work.
https://fedorahosted.org/sssd/ticket/1365
Diffstat (limited to 'src')
-rw-r--r-- | src/providers/ad/ad_common.c | 7 | ||||
-rw-r--r-- | src/providers/ipa/ipa_common.c | 7 | ||||
-rw-r--r-- | src/providers/krb5/krb5_common.c | 15 | ||||
-rw-r--r-- | src/providers/ldap/ldap_common.c | 7 | ||||
-rw-r--r-- | src/util/util.c | 23 | ||||
-rw-r--r-- | src/util/util.h | 9 |
6 files changed, 67 insertions, 1 deletions
diff --git a/src/providers/ad/ad_common.c b/src/providers/ad/ad_common.c index d1589c26a..2749a96e7 100644 --- a/src/providers/ad/ad_common.c +++ b/src/providers/ad/ad_common.c @@ -189,6 +189,13 @@ ad_servers_init(TALLOC_CTX *mem_ctx, continue; } + /* It could be ipv6 address in square brackets. Remove + * the brackets if needed. */ + ret = remove_ipv6_brackets(list[i]); + if (ret != EOK) { + goto done; + } + ret = be_fo_add_server(bectx, AD_SERVICE_NAME, list[i], 0, NULL, primary); if (ret && ret != EEXIST) { DEBUG(SSSDBG_FATAL_FAILURE, ("Failed to add server\n")); diff --git a/src/providers/ipa/ipa_common.c b/src/providers/ipa/ipa_common.c index 2e5047381..fe7ac91cb 100644 --- a/src/providers/ipa/ipa_common.c +++ b/src/providers/ipa/ipa_common.c @@ -841,6 +841,13 @@ errno_t ipa_servers_init(struct be_ctx *ctx, continue; } + /* It could be ipv6 address in square brackets. Remove + * the brackets if needed. */ + ret = remove_ipv6_brackets(list[i]); + if (ret != EOK) { + goto done; + } + ret = be_fo_add_server(ctx, "IPA", list[i], 0, NULL, primary); if (ret && ret != EEXIST) { DEBUG(SSSDBG_FATAL_FAILURE, ("Failed to add server\n")); diff --git a/src/providers/krb5/krb5_common.c b/src/providers/krb5/krb5_common.c index bd7a30210..0e96b806c 100644 --- a/src/providers/krb5/krb5_common.c +++ b/src/providers/krb5/krb5_common.c @@ -520,7 +520,13 @@ errno_t krb5_servers_init(struct be_ctx *ctx, continue; } - port_str = strrchr(server_spec, ':'); + /* Do not try to get port number if last character is ']' */ + if (server_spec[strlen(server_spec) - 1] != ']') { + port_str = strrchr(server_spec, ':'); + } else { + port_str = NULL; + } + if (port_str == NULL) { port = 0; } else { @@ -564,6 +570,13 @@ errno_t krb5_servers_init(struct be_ctx *ctx, } } + /* It could be ipv6 address in square brackets. Remove + * the brackets if needed. */ + ret = remove_ipv6_brackets(server_spec); + if (ret != EOK) { + goto done; + } + ret = be_fo_add_server(ctx, service_name, server_spec, (int) port, list[i], primary); if (ret && ret != EEXIST) { diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c index ce758755f..c11d036a1 100644 --- a/src/providers/ldap/ldap_common.c +++ b/src/providers/ldap/ldap_common.c @@ -1185,6 +1185,13 @@ errno_t sdap_urls_init(struct be_ctx *ctx, talloc_steal(service, list[i]); + /* It could be ipv6 address in square brackets. Remove + * the brackets if needed. */ + ret = remove_ipv6_brackets(lud->lud_host); + if (ret != EOK) { + goto done; + } + ret = be_fo_add_server(ctx, service->name, lud->lud_host, lud->lud_port, list[i], primary); ldap_free_urldesc(lud); diff --git a/src/util/util.c b/src/util/util.c index f1aaebc28..b812ef1b1 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -611,3 +611,26 @@ void to_sized_string(struct sized_string *out, const char *in) } } +/* This function only removes first and last + * character if the first character was '['. + * + * NOTE: This means, that ipv6addr must NOT be followed + * by port number. + */ +errno_t +remove_ipv6_brackets(char *ipv6addr) +{ + size_t len; + + if (ipv6addr && ipv6addr[0] == '[') { + len = strlen(ipv6addr); + if (len < 3) { + return EINVAL; + } + + memmove(ipv6addr, &ipv6addr[1], len - 2); + ipv6addr[len -2] = '\0'; + } + + return EOK; +} diff --git a/src/util/util.h b/src/util/util.h index 7ff91af56..685702fc9 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -516,6 +516,15 @@ errno_t sss_filter_sanitize(TALLOC_CTX *mem_ctx, char * sss_escape_ip_address(TALLOC_CTX *mem_ctx, int family, const char *addr); +/* This function only removes first and last + * character if the first character was '['. + * + * NOTE: This means, that ipv6addr must NOT be followed + * by port number. + */ +errno_t +remove_ipv6_brackets(char *ipv6addr); + /* from sss_tc_utf8.c */ char * sss_tc_utf8_str_tolower(TALLOC_CTX *mem_ctx, const char *s); |