From fa1b86c60c4405febf08e3dbc522ef9d8b089602 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Mon, 27 Jun 2011 15:44:40 +0200 Subject: [PATCH 3/4] Use name based URI instead of IP address based URIs --- src/providers/ldap/ldap_common.c | 39 +------------------------------------ 1 files changed, 2 insertions(+), 37 deletions(-) diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c index 997e027..2ffa878 100644 --- a/src/providers/ldap/ldap_common.c +++ b/src/providers/ldap/ldap_common.c @@ -534,13 +534,9 @@ static void sdap_uri_callback(void *private_data, struct fo_server *server) TALLOC_CTX *tmp_ctx = NULL; struct sdap_service *service; struct resolv_hostent *srvaddr; - char *address; - const char *safe_address; struct sockaddr_storage *sockaddr; const char *tmp; char *new_uri; - LDAPURLDesc *lud; - int ret; tmp_ctx = talloc_new(NULL); if (tmp_ctx == NULL) { @@ -564,13 +560,6 @@ static void sdap_uri_callback(void *private_data, struct fo_server *server) return; } - address = resolv_get_string_address(tmp_ctx, srvaddr); - if (address == NULL) { - DEBUG(1, ("resolv_get_string_address failed.\n")); - talloc_free(tmp_ctx); - return; - } - sockaddr = resolv_get_sockaddr_address(tmp_ctx, srvaddr, fo_get_server_port(server)); if (sockaddr == NULL) { @@ -579,40 +568,16 @@ static void sdap_uri_callback(void *private_data, struct fo_server *server) return; } - safe_address = sss_ldap_escape_ip_address(tmp_ctx, - srvaddr->family, - address); - talloc_zfree(address); - if (safe_address == NULL) { - DEBUG(1, ("sss_ldap_escape_ip_address failed.\n")); - talloc_free(tmp_ctx); - return; - } - if (fo_is_srv_lookup(server)) { if (!tmp) { DEBUG(1, ("Unknown service, using ldap\n")); tmp = SSS_LDAP_SRV_NAME; } new_uri = talloc_asprintf(service, "%s://%s:%d", - tmp, safe_address, + tmp, fo_get_server_name(server), fo_get_server_port(server)); } else { - if (tmp && ldap_is_ldap_url(tmp)) { - ret = ldap_url_parse(tmp, &lud); - if (ret != LDAP_SUCCESS) { - DEBUG(0, ("Failed to parse ldap URI (%s)!\n", tmp)); - talloc_free(tmp_ctx); - return; - } - new_uri = talloc_asprintf(service, "%s://%s:%d", - lud->lud_scheme, - safe_address, - fo_get_server_port(server)); - ldap_free_urldesc(lud); - } else { - new_uri = talloc_asprintf(service, "ldap://%s", safe_address); - } + new_uri = talloc_strdup(service, tmp); } if (!new_uri) { -- 1.7.5.4