summaryrefslogtreecommitdiffstats
path: root/src/providers
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2012-11-09 21:31:23 +0100
committerJakub Hrozek <jhrozek@redhat.com>2012-11-14 11:20:23 +0100
commita7a2839f8bbeec894a4e35031806f1702502e150 (patch)
tree237bdce0556fd0b7b120264e6b1abfac98fd9dde /src/providers
parent0a564940c04dd9500b8d72bae723b165c3690b26 (diff)
downloadsssd-a7a2839f8bbeec894a4e35031806f1702502e150.tar.gz
sssd-a7a2839f8bbeec894a4e35031806f1702502e150.tar.xz
sssd-a7a2839f8bbeec894a4e35031806f1702502e150.zip
Run IPA subdomain provider if IPA ID provider is configured
To make configuration easier the IPA subdomain provider should be always loaded if the IPA ID provider is configured and the subdomain provider is not explicitly disabled. But to avoid the overhead of regular subdomain requests in setups where no subdomains are used the IPA subdomain provider should behave differently if configured explicit or implicit. If the IPA subdomain provider is configured explicitly, i.e. 'subdomains_provider = ipa' can be found in the domain section of sssd.conf subdomain request are always send to the server if needed. If it is configured implicitly and a request to the server fails with an indication that the server currently does not support subdomains at all, e.g. is not configured to handle trust relationships, a new request will be only send to the server after a long timeout or after a going-online event. To be able to make this distinction this patch save the configuration status to the subdomain context. Fixes https://fedorahosted.org/sssd/ticket/1613
Diffstat (limited to 'src/providers')
-rw-r--r--src/providers/data_provider_be.c3
-rw-r--r--src/providers/ipa/ipa_subdomains.c68
2 files changed, 69 insertions, 2 deletions
diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
index 4e4bdab28..88f968695 100644
--- a/src/providers/data_provider_be.c
+++ b/src/providers/data_provider_be.c
@@ -2315,7 +2315,8 @@ int be_process_init(TALLOC_CTX *mem_ctx,
}
ret = load_backend_module(ctx, BET_SUBDOMAINS,
- &ctx->bet_info[BET_SUBDOMAINS], NULL);
+ &ctx->bet_info[BET_SUBDOMAINS],
+ ctx->bet_info[BET_ID].mod_name);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, ("Subdomains are not supported for [%s] !!\n", be_domain));
} else {
diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c
index 36ffafd92..0bf2e5d8e 100644
--- a/src/providers/ipa/ipa_subdomains.c
+++ b/src/providers/ipa/ipa_subdomains.c
@@ -47,6 +47,7 @@
/* refresh automatically every 4 hours */
#define IPA_SUBDOMAIN_REFRESH_PERIOD (3600 * 4)
+#define IPA_SUBDOMAIN_DISABLED_PERIOD 3600
/* the directory domain - realm mappings are written to */
#define IPA_SUBDOMAIN_MAPPING_DIR PUBCONF_PATH"/krb5.include.d"
@@ -74,6 +75,8 @@ struct ipa_subdomains_ctx {
time_t last_refreshed;
struct tevent_timer *timer_event;
+ bool configured_explicit;
+ time_t disabled_until;
/* subdomain map cache */
int num_subdoms;
@@ -899,6 +902,12 @@ static void ipa_subdomains_handler_master_done(struct tevent_req *req)
* and we don't have the master domain record
*/
DEBUG(SSSDBG_CRIT_FAILURE, ("Master domain record not found!\n"));
+
+ if (!ctx->sd_ctx->configured_explicit) {
+ ctx->sd_ctx->disabled_until = time(NULL) +
+ IPA_SUBDOMAIN_DISABLED_PERIOD;
+ }
+
ret = EIO;
goto done;
}
@@ -932,6 +941,7 @@ static void ipa_subdom_online_cb(void *pvt)
return;
}
+ ctx->disabled_until = 0;
ipa_subdomains_retrieve(ctx, NULL);
tv = tevent_timeval_current_ofs(IPA_SUBDOMAIN_REFRESH_PERIOD, 0);
@@ -953,9 +963,48 @@ static void ipa_subdom_offline_cb(void *pvt)
}
}
+static errno_t get_config_status(struct be_ctx *be_ctx,
+ bool *configured_explicit)
+{
+ int ret;
+ TALLOC_CTX *tmp_ctx = NULL;
+ char *tmp_str;
+
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, ("talloc_new failed.\n"));
+ return ENOMEM;
+ }
+
+ ret = confdb_get_string(be_ctx->cdb, tmp_ctx, be_ctx->conf_path,
+ CONFDB_DOMAIN_SUBDOMAINS_PROVIDER, NULL,
+ &tmp_str);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, ("confdb_get_string failed.\n"));
+ goto done;
+ }
+
+ if (tmp_str == NULL) {
+ *configured_explicit = false;
+ } else {
+ *configured_explicit = true;
+ }
+
+ DEBUG(SSSDBG_TRACE_ALL, ("IPA subdomain provider is configured %s.\n",
+ *configured_explicit ? "explicit" : "implicit"));
+
+ ret = EOK;
+
+done:
+ talloc_free(tmp_ctx);
+
+ return ret;
+}
+
void ipa_subdomains_handler(struct be_req *be_req)
{
struct ipa_subdomains_ctx *ctx;
+ time_t now;
ctx = talloc_get_type(be_req->be_ctx->bet_info[BET_SUBDOMAINS].pvt_bet_data,
struct ipa_subdomains_ctx);
@@ -964,7 +1013,15 @@ void ipa_subdomains_handler(struct be_req *be_req)
return;
}
- if (ctx->last_refreshed > time(NULL) - IPA_SUBDOMAIN_REFRESH_LIMIT) {
+ now = time(NULL);
+
+ if (ctx->disabled_until > now) {
+ DEBUG(SSSDBG_TRACE_ALL, ("Subdomain provider disabled.\n"));
+ ipa_subdomains_reply(be_req, DP_ERR_OK, EOK);
+ return;
+ }
+
+ if (ctx->last_refreshed > now - IPA_SUBDOMAIN_REFRESH_LIMIT) {
ipa_subdomains_reply(be_req, DP_ERR_OK, EOK);
return;
}
@@ -984,6 +1041,13 @@ int ipa_subdom_init(struct be_ctx *be_ctx,
{
struct ipa_subdomains_ctx *ctx;
int ret;
+ bool configured_explicit = false;
+
+ ret = get_config_status(be_ctx, &configured_explicit);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, ("get_config_status failed.\n"));
+ return ret;
+ }
ctx = talloc_zero(id_ctx, struct ipa_subdomains_ctx);
if (ctx == NULL) {
@@ -996,6 +1060,8 @@ int ipa_subdom_init(struct be_ctx *be_ctx,
ctx->search_bases = id_ctx->ipa_options->subdomains_search_bases;
ctx->master_search_bases = id_ctx->ipa_options->master_domain_search_bases;
ctx->ranges_search_bases = id_ctx->ipa_options->ranges_search_bases;
+ ctx->configured_explicit = configured_explicit;
+ ctx->disabled_until = 0;
*ops = &ipa_subdomains_ops;
*pvt_data = ctx;