From 1abdf56dcda5f6bed7b144e544c00dbdd501b3fc Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Thu, 4 Apr 2013 12:28:15 +0200 Subject: DNS sites support - use SRV DNS lookup plugin in all providers https://fedorahosted.org/sssd/ticket/1032 We set a plugin during an initialization of ID provider, which is an authoritative provider for a plugin choice. The plugin is set only once. When other provider is initalized (e.g. id = IPA, sudo = LDAP), we do not overwrite the plugin. Since sssm_*_id_init() is called from all module constructors, this patch relies on the fact, that ID provider is initialized before all other providers. --- src/providers/ad/ad_init.c | 10 ++++++++++ src/providers/ipa/ipa_init.c | 10 ++++++++++ src/providers/ldap/ldap_init.c | 9 +++++++++ 3 files changed, 29 insertions(+) diff --git a/src/providers/ad/ad_init.c b/src/providers/ad/ad_init.c index 2add74a2..087ec3c4 100644 --- a/src/providers/ad/ad_init.c +++ b/src/providers/ad/ad_init.c @@ -107,6 +107,7 @@ sssm_ad_id_init(struct be_ctx *bectx, errno_t ret; struct ad_id_ctx *ad_ctx; struct sdap_id_ctx *sdap_ctx; + const char *hostname; if (!ad_options) { ret = common_ad_init(bectx); @@ -175,6 +176,15 @@ sssm_ad_id_init(struct be_ctx *bectx, goto done; } + /* setup SRV lookup plugin */ + hostname = dp_opt_get_string(ad_options->basic, AD_HOSTNAME); + ret = be_fo_set_dns_srv_lookup_plugin(bectx, hostname); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Unable to set SRV lookup plugin " + "[%d]: %s\n", ret, strerror(ret))); + goto done; + } + *ops = &ad_id_ops; *pvt_data = ad_ctx; diff --git a/src/providers/ipa/ipa_init.c b/src/providers/ipa/ipa_init.c index a6c32be2..cdca706d 100644 --- a/src/providers/ipa/ipa_init.c +++ b/src/providers/ipa/ipa_init.c @@ -110,6 +110,7 @@ int sssm_ipa_id_init(struct be_ctx *bectx, struct ipa_id_ctx *ipa_ctx; struct sdap_id_ctx *sdap_ctx; struct stat stat_buf; + const char *hostname; errno_t err; int ret; @@ -207,6 +208,15 @@ int sssm_ipa_id_init(struct be_ctx *bectx, goto done; } + /* setup SRV lookup plugin */ + hostname = dp_opt_get_string(ipa_options->basic, IPA_HOSTNAME); + ret = be_fo_set_dns_srv_lookup_plugin(bectx, hostname); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Unable to set SRV lookup plugin " + "[%d]: %s\n", ret, strerror(ret))); + goto done; + } + *ops = &ipa_id_ops; *pvt_data = ipa_ctx; ret = EOK; diff --git a/src/providers/ldap/ldap_init.c b/src/providers/ldap/ldap_init.c index fa888ba7..2e30c37e 100644 --- a/src/providers/ldap/ldap_init.c +++ b/src/providers/ldap/ldap_init.c @@ -29,6 +29,7 @@ #include "providers/ldap/sdap_sudo.h" #include "providers/ldap/sdap_autofs.h" #include "providers/ldap/sdap_idmap.h" +#include "providers/fail_over_srv.h" static void sdap_shutdown(struct be_req *req); @@ -172,6 +173,14 @@ int sssm_ldap_id_init(struct be_ctx *bectx, goto done; } + /* setup SRV lookup plugin */ + ret = be_fo_set_dns_srv_lookup_plugin(bectx, NULL); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Unable to set SRV lookup plugin " + "[%d]: %s\n", ret, strerror(ret))); + goto done; + } + *ops = &sdap_id_ops; *pvt_data = ctx; ret = EOK; -- cgit