diff options
author | Jan Zeleny <jzeleny@redhat.com> | 2012-06-05 08:41:29 -0400 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-08-01 16:19:41 +0200 |
commit | 1ecdcf622920781a95e3d2040a2aad9ac2e31260 (patch) | |
tree | a76f86f587b09828960a6a8621d59ed5e29f2614 | |
parent | 10922e0293f3ebf056708acacce35e93fe07747e (diff) | |
download | sssd-1ecdcf622920781a95e3d2040a2aad9ac2e31260.tar.gz sssd-1ecdcf622920781a95e3d2040a2aad9ac2e31260.tar.bz2 sssd-1ecdcf622920781a95e3d2040a2aad9ac2e31260.zip |
Primary server support: IPA adaptation
This patch adds support for the primary server functionality into IPA
provider. No backup servers are added at the moment, just the basic
support is in place.
-rw-r--r-- | src/providers/ipa/ipa_common.c | 107 | ||||
-rw-r--r-- | src/providers/ipa/ipa_common.h | 3 | ||||
-rw-r--r-- | src/providers/ipa/ipa_init.c | 2 |
3 files changed, 77 insertions, 35 deletions
diff --git a/src/providers/ipa/ipa_common.c b/src/providers/ipa/ipa_common.c index 98a7c58f..b5f6337d 100644 --- a/src/providers/ipa/ipa_common.c +++ b/src/providers/ipa/ipa_common.c @@ -797,20 +797,74 @@ static void ipa_resolve_callback(void *private_data, struct fo_server *server) talloc_free(tmp_ctx); } +errno_t ipa_servers_init(struct be_ctx *ctx, + struct ipa_service *service, + struct ipa_options *options, + const char *servers, + bool primary) +{ + TALLOC_CTX *tmp_ctx; + char **list = NULL; + char *ipa_domain; + int ret; + int i; + + tmp_ctx = talloc_new(NULL); + if (!tmp_ctx) { + return ENOMEM; + } + + /* split server parm into a list */ + ret = split_on_separator(tmp_ctx, servers, ',', true, &list, NULL); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to parse server list!\n")); + goto done; + } + + /* now for each one add a new server to the failover service */ + for (i = 0; list[i]; i++) { + + talloc_steal(service, list[i]); + + if (be_fo_is_srv_identifier(list[i])) { + ipa_domain = dp_opt_get_string(options->basic, IPA_DOMAIN); + ret = be_fo_add_srv_server(ctx, "IPA", "ldap", ipa_domain, + BE_FO_PROTO_TCP, false, NULL); + if (ret) { + DEBUG(SSSDBG_FATAL_FAILURE, ("Failed to add server\n")); + goto done; + } + + DEBUG(SSSDBG_TRACE_FUNC, ("Added service lookup for service IPA\n")); + continue; + } + + 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")); + goto done; + } + + DEBUG(SSSDBG_TRACE_FUNC, ("Added Server %s\n", list[i])); + } + +done: + talloc_free(tmp_ctx); + return ret; +} + int ipa_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx, - const char *servers, + const char *primary_servers, + const char *backup_servers, struct ipa_options *options, struct ipa_service **_service) { TALLOC_CTX *tmp_ctx; struct ipa_service *service; - char **list = NULL; char *realm; - char *ipa_domain; int ret; - int i; - tmp_ctx = talloc_new(memctx); + tmp_ctx = talloc_new(NULL); if (!tmp_ctx) { return ENOMEM; } @@ -863,42 +917,29 @@ int ipa_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx, goto done; } - if (!servers) { - servers = BE_SRV_IDENTIFIER; + if (!primary_servers) { + if (backup_servers) { + DEBUG(SSSDBG_CONF_SETTINGS, ("Missing primary IPA server but " + "backup server given - using it as primary!\n")); + primary_servers = backup_servers; + backup_servers = NULL; + } else { + DEBUG(SSSDBG_CONF_SETTINGS, ("Missing primary and backup IPA " + "servers - using service discovery!\n")); + primary_servers = BE_SRV_IDENTIFIER; + } } - /* split server parm into a list */ - ret = split_on_separator(tmp_ctx, servers, ',', true, &list, NULL); + ret = ipa_servers_init(ctx, service, options, primary_servers, true); if (ret != EOK) { - DEBUG(1, ("Failed to parse server list!\n")); goto done; } - /* now for each one add a new server to the failover service */ - for (i = 0; list[i]; i++) { - - talloc_steal(service, list[i]); - - if (be_fo_is_srv_identifier(list[i])) { - ipa_domain = dp_opt_get_string(options->basic, IPA_DOMAIN); - ret = be_fo_add_srv_server(ctx, "IPA", "ldap", ipa_domain, - BE_FO_PROTO_TCP, false, NULL); - if (ret) { - DEBUG(0, ("Failed to add server\n")); - goto done; - } - - DEBUG(6, ("Added service lookup for service IPA\n")); - continue; - } - - ret = be_fo_add_server(ctx, "IPA", list[i], 0, NULL, true); - if (ret && ret != EEXIST) { - DEBUG(0, ("Failed to add server\n")); + if (backup_servers) { + ret = ipa_servers_init(ctx, service, options, backup_servers, false); + if (ret != EOK) { goto done; } - - DEBUG(6, ("Added Server %s\n", list[i])); } ret = be_fo_service_add_callback(memctx, ctx, "IPA", diff --git a/src/providers/ipa/ipa_common.h b/src/providers/ipa/ipa_common.h index 3e2ef284..b0944595 100644 --- a/src/providers/ipa/ipa_common.h +++ b/src/providers/ipa/ipa_common.h @@ -171,7 +171,8 @@ int ipa_autofs_init(struct be_ctx *be_ctx, void **pvt_data); int ipa_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx, - const char *servers, + const char *primary_servers, + const char *backup_servers, struct ipa_options *options, struct ipa_service **_service); diff --git a/src/providers/ipa/ipa_init.c b/src/providers/ipa/ipa_init.c index 670e00fa..65c77664 100644 --- a/src/providers/ipa/ipa_init.c +++ b/src/providers/ipa/ipa_init.c @@ -98,7 +98,7 @@ int common_ipa_init(struct be_ctx *bectx) DEBUG(1, ("Missing ipa_server option - using service discovery!\n")); } - ret = ipa_service_init(ipa_options, bectx, ipa_servers, ipa_options, + ret = ipa_service_init(ipa_options, bectx, ipa_servers, NULL, ipa_options, &ipa_options->service); if (ret != EOK) { DEBUG(0, ("Failed to init IPA failover service!\n")); |