diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2011-07-16 18:00:40 +0200 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2011-07-21 08:23:17 -0400 |
commit | 9b85268eabe33d624b9d184251e89c0c7ae829a2 (patch) | |
tree | 21ccb9734873f246657a78fb4cb8b60032b20075 /src/providers/ldap/ldap_common.c | |
parent | 363d2fba991eae199d017f5b2d1b458f070fac6b (diff) | |
download | sssd-9b85268eabe33d624b9d184251e89c0c7ae829a2.tar.gz sssd-9b85268eabe33d624b9d184251e89c0c7ae829a2.tar.xz sssd-9b85268eabe33d624b9d184251e89c0c7ae829a2.zip |
fo_get_server_name() getter for a server name
Allows to be more concise in tests and more defensive in resolve
callbacks
Diffstat (limited to 'src/providers/ldap/ldap_common.c')
-rw-r--r-- | src/providers/ldap/ldap_common.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c index 656c10263..78176ba8a 100644 --- a/src/providers/ldap/ldap_common.c +++ b/src/providers/ldap/ldap_common.c @@ -542,6 +542,7 @@ static void sdap_uri_callback(void *private_data, struct fo_server *server) struct resolv_hostent *srvaddr; struct sockaddr_storage *sockaddr; const char *tmp; + const char *srv_name; char *new_uri; tmp_ctx = talloc_new(NULL); @@ -579,8 +580,16 @@ static void sdap_uri_callback(void *private_data, struct fo_server *server) DEBUG(1, ("Unknown service, using ldap\n")); tmp = SSS_LDAP_SRV_NAME; } + + srv_name = fo_get_server_name(server); + if (srv_name == NULL) { + DEBUG(1, ("Could not get server host name\n")); + talloc_free(tmp_ctx); + return; + } + new_uri = talloc_asprintf(service, "%s://%s:%d", - tmp, fo_get_server_str_name(server), + tmp, srv_name, fo_get_server_port(server)); } else { new_uri = talloc_strdup(service, tmp); |