|
|
905b4d |
From 50d00230cbbc4fd960ffd2ebfced826c2e671bc2 Mon Sep 17 00:00:00 2001
|
|
|
905b4d |
From: Sumit Bose <sbose@redhat.com>
|
|
|
905b4d |
Date: Thu, 27 Nov 2014 13:41:37 +0100
|
|
|
905b4d |
Subject: [PATCH 119/128] IPA: only update view data if it really changed
|
|
|
905b4d |
|
|
|
905b4d |
https://fedorahosted.org/sssd/ticket/2510
|
|
|
905b4d |
|
|
|
905b4d |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
905b4d |
---
|
|
|
905b4d |
src/providers/ipa/ipa_subdomains.c | 116 +++++++++++++++++++++----------------
|
|
|
905b4d |
1 file changed, 66 insertions(+), 50 deletions(-)
|
|
|
905b4d |
|
|
|
905b4d |
diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c
|
|
|
905b4d |
index d053d46ac4208bd52fcbf524a11243896b849612..3148389f71135b6c64e62d1cf7f4064dd183f595 100644
|
|
|
905b4d |
--- a/src/providers/ipa/ipa_subdomains.c
|
|
|
905b4d |
+++ b/src/providers/ipa/ipa_subdomains.c
|
|
|
905b4d |
@@ -1110,23 +1110,44 @@ static void ipa_get_view_name_done(struct tevent_req *req)
|
|
|
905b4d |
"View name changed, this is not supported at runtime. " \
|
|
|
905b4d |
"Please restart SSSD to get the new view applied.\n");
|
|
|
905b4d |
} else {
|
|
|
905b4d |
- ctx->sd_ctx->view_read_at_init = true;
|
|
|
905b4d |
- /* View name changed */
|
|
|
905b4d |
- if (ctx->sd_ctx->id_ctx->view_name != NULL) {
|
|
|
905b4d |
- ret = sysdb_transaction_start(ctx->sd_ctx->be_ctx->domain->sysdb);
|
|
|
905b4d |
- if (ret != EOK) {
|
|
|
905b4d |
- DEBUG(SSSDBG_OP_FAILURE, "sysdb_transaction_start failed.\n");
|
|
|
905b4d |
- goto done;
|
|
|
905b4d |
- }
|
|
|
905b4d |
+ if (ctx->sd_ctx->id_ctx->view_name == NULL
|
|
|
905b4d |
+ || strcmp(ctx->sd_ctx->id_ctx->view_name, view_name) != 0) {
|
|
|
905b4d |
+ /* View name changed */
|
|
|
905b4d |
|
|
|
905b4d |
- if (strcmp(ctx->sd_ctx->id_ctx->view_name,
|
|
|
905b4d |
- SYSDB_DEFAULT_VIEW_NAME) != 0) {
|
|
|
905b4d |
- /* Old view was not the default view, delete view tree */
|
|
|
905b4d |
- ret = sysdb_delete_view_tree(ctx->sd_ctx->be_ctx->domain->sysdb,
|
|
|
905b4d |
+ if (ctx->sd_ctx->id_ctx->view_name != NULL) {
|
|
|
905b4d |
+ ret = sysdb_transaction_start(
|
|
|
905b4d |
+ ctx->sd_ctx->be_ctx->domain->sysdb);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
+ "sysdb_transaction_start failed.\n");
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ if (strcmp(ctx->sd_ctx->id_ctx->view_name,
|
|
|
905b4d |
+ SYSDB_DEFAULT_VIEW_NAME) != 0) {
|
|
|
905b4d |
+ /* Old view was not the default view, delete view tree */
|
|
|
905b4d |
+ ret = sysdb_delete_view_tree(
|
|
|
905b4d |
+ ctx->sd_ctx->be_ctx->domain->sysdb,
|
|
|
905b4d |
ctx->sd_ctx->id_ctx->view_name);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
+ "sysdb_delete_view_tree failed.\n");
|
|
|
905b4d |
+ sret = sysdb_transaction_cancel(
|
|
|
905b4d |
+ ctx->sd_ctx->be_ctx->domain->sysdb);
|
|
|
905b4d |
+ if (sret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
+ "sysdb_transaction_cancel failed.\n");
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = sysdb_invalidate_overrides(
|
|
|
905b4d |
+ ctx->sd_ctx->be_ctx->domain->sysdb);
|
|
|
905b4d |
if (ret != EOK) {
|
|
|
905b4d |
DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
- "sysdb_delete_view_tree failed.\n");
|
|
|
905b4d |
+ "sysdb_invalidate_overrides failed.\n");
|
|
|
905b4d |
sret = sysdb_transaction_cancel(
|
|
|
905b4d |
ctx->sd_ctx->be_ctx->domain->sysdb);
|
|
|
905b4d |
if (sret != EOK) {
|
|
|
905b4d |
@@ -1136,57 +1157,52 @@ static void ipa_get_view_name_done(struct tevent_req *req)
|
|
|
905b4d |
}
|
|
|
905b4d |
goto done;
|
|
|
905b4d |
}
|
|
|
905b4d |
- }
|
|
|
905b4d |
|
|
|
905b4d |
- ret = sysdb_invalidate_overrides(
|
|
|
905b4d |
+ ret = sysdb_transaction_commit(
|
|
|
905b4d |
ctx->sd_ctx->be_ctx->domain->sysdb);
|
|
|
905b4d |
- if (ret != EOK) {
|
|
|
905b4d |
- DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
- "sysdb_invalidate_overrides failed.\n");
|
|
|
905b4d |
- sret = sysdb_transaction_cancel(
|
|
|
905b4d |
- ctx->sd_ctx->be_ctx->domain->sysdb);
|
|
|
905b4d |
- if (sret != EOK) {
|
|
|
905b4d |
- DEBUG(SSSDBG_OP_FAILURE, "sysdb_transaction_cancel failed.\n");
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
+ "sysdb_transaction_commit failed.\n");
|
|
|
905b4d |
goto done;
|
|
|
905b4d |
}
|
|
|
905b4d |
- goto done;
|
|
|
905b4d |
+
|
|
|
905b4d |
+ /* TODO: start referesh task */
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
- ret = sysdb_transaction_commit(ctx->sd_ctx->be_ctx->domain->sysdb);
|
|
|
905b4d |
+ ret = sysdb_update_view_name(ctx->sd_ctx->be_ctx->domain->sysdb,
|
|
|
905b4d |
+ view_name);
|
|
|
905b4d |
if (ret != EOK) {
|
|
|
905b4d |
- DEBUG(SSSDBG_OP_FAILURE, "sysdb_transaction_commit failed.\n");
|
|
|
905b4d |
- goto done;
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
+ "Cannot add/update view name to sysdb.\n");
|
|
|
905b4d |
+ } else {
|
|
|
905b4d |
+ talloc_free(ctx->sd_ctx->id_ctx->view_name);
|
|
|
905b4d |
+ ctx->sd_ctx->id_ctx->view_name = talloc_strdup(
|
|
|
905b4d |
+ ctx->sd_ctx->id_ctx,
|
|
|
905b4d |
+ view_name);
|
|
|
905b4d |
+ if (ctx->sd_ctx->id_ctx->view_name == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Cannot copy view name.\n");
|
|
|
905b4d |
+ }
|
|
|
905b4d |
}
|
|
|
905b4d |
-
|
|
|
905b4d |
- /* TODO: start referesh task */
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
- ret = sysdb_update_view_name(ctx->sd_ctx->be_ctx->domain->sysdb,
|
|
|
905b4d |
- view_name);
|
|
|
905b4d |
- if (ret != EOK) {
|
|
|
905b4d |
- DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
- "Cannot add/update view name to sysdb.\n");
|
|
|
905b4d |
- } else {
|
|
|
905b4d |
- talloc_free(ctx->sd_ctx->id_ctx->view_name);
|
|
|
905b4d |
- ctx->sd_ctx->id_ctx->view_name = talloc_strdup(ctx->sd_ctx->id_ctx,
|
|
|
905b4d |
- view_name);
|
|
|
905b4d |
- if (ctx->sd_ctx->id_ctx->view_name == NULL) {
|
|
|
905b4d |
- DEBUG(SSSDBG_CRIT_FAILURE, "Cannot copy view name.\n");
|
|
|
905b4d |
+ if (!ctx->sd_ctx->view_read_at_init) {
|
|
|
905b4d |
+ /* refresh view data of all domains at startup */
|
|
|
905b4d |
+ ret = sysdb_master_domain_update(ctx->sd_ctx->be_ctx->domain);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
+ "sysdb_master_domain_update failed.\n");
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = sysdb_update_subdomains(ctx->sd_ctx->be_ctx->domain);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "sysdb_update_subdomains failed.\n");
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
}
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
- /* TODO: only needed if view changed */
|
|
|
905b4d |
- ret = sysdb_master_domain_update(ctx->sd_ctx->be_ctx->domain);
|
|
|
905b4d |
- if (ret != EOK) {
|
|
|
905b4d |
- DEBUG(SSSDBG_OP_FAILURE, "sysdb_master_domain_update failed.\n");
|
|
|
905b4d |
- goto done;
|
|
|
905b4d |
- }
|
|
|
905b4d |
+ ctx->sd_ctx->view_read_at_init = true;
|
|
|
905b4d |
|
|
|
905b4d |
- ret = sysdb_update_subdomains(ctx->sd_ctx->be_ctx->domain);
|
|
|
905b4d |
- if (ret != EOK) {
|
|
|
905b4d |
- DEBUG(SSSDBG_OP_FAILURE, "sysdb_update_subdomains failed.\n");
|
|
|
905b4d |
- goto done;
|
|
|
905b4d |
- }
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
ret = ipa_check_master(ctx);
|
|
|
905b4d |
--
|
|
|
905b4d |
1.9.3
|
|
|
905b4d |
|