summaryrefslogtreecommitdiff
path: root/src/providers
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-07-16 18:00:40 +0200
committerSimo Sorce <ssorce@redhat.com>2011-07-21 08:23:17 -0400
commit9b85268eabe33d624b9d184251e89c0c7ae829a2 (patch)
tree21ccb9734873f246657a78fb4cb8b60032b20075 /src/providers
parent363d2fba991eae199d017f5b2d1b458f070fac6b (diff)
downloadsssd-9b85268eabe33d624b9d184251e89c0c7ae829a2.tar.gz
sssd-9b85268eabe33d624b9d184251e89c0c7ae829a2.tar.bz2
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.c2
-rw-r--r--src/providers/fail_over.c9
-rw-r--r--src/providers/fail_over.h2
-rw-r--r--src/providers/ipa/ipa_common.c10
-rw-r--r--src/providers/ldap/ldap_common.c11
5 files changed, 31 insertions, 3 deletions
diff --git a/src/providers/data_provider_fo.c b/src/providers/data_provider_fo.c
index 6f9c757b..b5c41734 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 2bf69848..6b967d4d 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 cb9e54e9..3ca6096c 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 70272a2a..08b05126 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 656c1026..78176ba8 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);