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 | |
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')
-rw-r--r-- | src/providers/data_provider_fo.c | 2 | ||||
-rw-r--r-- | src/providers/fail_over.c | 9 | ||||
-rw-r--r-- | src/providers/fail_over.h | 2 | ||||
-rw-r--r-- | src/providers/ipa/ipa_common.c | 10 | ||||
-rw-r--r-- | src/providers/ldap/ldap_common.c | 11 |
5 files changed, 31 insertions, 3 deletions
diff --git a/src/providers/data_provider_fo.c b/src/providers/data_provider_fo.c index 6f9c757be..b5c417344 100644 --- a/src/providers/data_provider_fo.c +++ b/src/providers/data_provider_fo.c @@ -432,7 +432,7 @@ static void be_resolve_server_done(struct tevent_req *subreq) /* all fine we got the server */ - if (debug_level >= 4) { + if (debug_level >= 4 && fo_get_server_name(state->srv)) { struct resolv_hostent *srvaddr; char ipaddr[128]; srvaddr = fo_get_server_hostent(state->srv); diff --git a/src/providers/fail_over.c b/src/providers/fail_over.c index 2bf69848a..6b967d4db 100644 --- a/src/providers/fail_over.c +++ b/src/providers/fail_over.c @@ -1375,6 +1375,15 @@ fo_get_server_port(struct fo_server *server) return server->port; } +const char * +fo_get_server_name(struct fo_server *server) +{ + if (!server->common) { + return NULL; + } + return server->common->name; +} + const char *fo_get_server_str_name(struct fo_server *server) { if (!server->common) { diff --git a/src/providers/fail_over.h b/src/providers/fail_over.h index cb9e54e98..3ca6096c4 100644 --- a/src/providers/fail_over.h +++ b/src/providers/fail_over.h @@ -167,6 +167,8 @@ void *fo_get_server_user_data(struct fo_server *server); int fo_get_server_port(struct fo_server *server); +const char *fo_get_server_name(struct fo_server *server); + const char *fo_get_server_str_name(struct fo_server *server); struct resolv_hostent *fo_get_server_hostent(struct fo_server *server); diff --git a/src/providers/ipa/ipa_common.c b/src/providers/ipa/ipa_common.c index 70272a2a4..08b051265 100644 --- a/src/providers/ipa/ipa_common.c +++ b/src/providers/ipa/ipa_common.c @@ -602,6 +602,7 @@ static void ipa_resolve_callback(void *private_data, struct fo_server *server) char *address; const char *safe_address; char *new_uri; + const char *srv_name; int ret; tmp_ctx = talloc_new(NULL); @@ -639,7 +640,14 @@ static void ipa_resolve_callback(void *private_data, struct fo_server *server) return; } - new_uri = talloc_asprintf(service, "ldap://%s", fo_get_server_str_name(server)); + 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, "ldap://%s", srv_name); if (!new_uri) { DEBUG(2, ("Failed to copy URI ...\n")); talloc_free(tmp_ctx); 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); |