diff options
author | Sumit Bose <sbose@redhat.com> | 2014-11-27 13:41:37 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-12-02 11:44:24 +0100 |
commit | 2bf1cbffaac3b4bc0bd736493c985ca865092805 (patch) | |
tree | 64049244ca4985e4262f2718834e56b070879afc | |
parent | 61d2ccf1dae3f1e7fc987ae98cb5c493cc73a782 (diff) | |
download | sssd-2bf1cbffaac3b4bc0bd736493c985ca865092805.tar.gz sssd-2bf1cbffaac3b4bc0bd736493c985ca865092805.tar.xz sssd-2bf1cbffaac3b4bc0bd736493c985ca865092805.zip |
IPA: only update view data if it really changed
https://fedorahosted.org/sssd/ticket/2510
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
-rw-r--r-- | src/providers/ipa/ipa_subdomains.c | 116 |
1 files changed, 66 insertions, 50 deletions
diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c index d053d46ac..3148389f7 100644 --- a/src/providers/ipa/ipa_subdomains.c +++ b/src/providers/ipa/ipa_subdomains.c @@ -1110,23 +1110,44 @@ static void ipa_get_view_name_done(struct tevent_req *req) "View name changed, this is not supported at runtime. " \ "Please restart SSSD to get the new view applied.\n"); } else { - ctx->sd_ctx->view_read_at_init = true; - /* View name changed */ - if (ctx->sd_ctx->id_ctx->view_name != NULL) { - ret = sysdb_transaction_start(ctx->sd_ctx->be_ctx->domain->sysdb); - if (ret != EOK) { - DEBUG(SSSDBG_OP_FAILURE, "sysdb_transaction_start failed.\n"); - goto done; - } + if (ctx->sd_ctx->id_ctx->view_name == NULL + || strcmp(ctx->sd_ctx->id_ctx->view_name, view_name) != 0) { + /* View name changed */ + + if (ctx->sd_ctx->id_ctx->view_name != NULL) { + ret = sysdb_transaction_start( + ctx->sd_ctx->be_ctx->domain->sysdb); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, + "sysdb_transaction_start failed.\n"); + goto done; + } - if (strcmp(ctx->sd_ctx->id_ctx->view_name, - SYSDB_DEFAULT_VIEW_NAME) != 0) { - /* Old view was not the default view, delete view tree */ - ret = sysdb_delete_view_tree(ctx->sd_ctx->be_ctx->domain->sysdb, + if (strcmp(ctx->sd_ctx->id_ctx->view_name, + SYSDB_DEFAULT_VIEW_NAME) != 0) { + /* Old view was not the default view, delete view tree */ + ret = sysdb_delete_view_tree( + ctx->sd_ctx->be_ctx->domain->sysdb, ctx->sd_ctx->id_ctx->view_name); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, + "sysdb_delete_view_tree failed.\n"); + sret = sysdb_transaction_cancel( + ctx->sd_ctx->be_ctx->domain->sysdb); + if (sret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, + "sysdb_transaction_cancel failed.\n"); + goto done; + } + goto done; + } + } + + ret = sysdb_invalidate_overrides( + ctx->sd_ctx->be_ctx->domain->sysdb); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, - "sysdb_delete_view_tree failed.\n"); + "sysdb_invalidate_overrides failed.\n"); sret = sysdb_transaction_cancel( ctx->sd_ctx->be_ctx->domain->sysdb); if (sret != EOK) { @@ -1136,57 +1157,52 @@ static void ipa_get_view_name_done(struct tevent_req *req) } goto done; } - } - ret = sysdb_invalidate_overrides( + ret = sysdb_transaction_commit( ctx->sd_ctx->be_ctx->domain->sysdb); - if (ret != EOK) { - DEBUG(SSSDBG_OP_FAILURE, - "sysdb_invalidate_overrides failed.\n"); - sret = sysdb_transaction_cancel( - ctx->sd_ctx->be_ctx->domain->sysdb); - if (sret != EOK) { - DEBUG(SSSDBG_OP_FAILURE, "sysdb_transaction_cancel failed.\n"); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, + "sysdb_transaction_commit failed.\n"); goto done; } - goto done; + + /* TODO: start referesh task */ } - ret = sysdb_transaction_commit(ctx->sd_ctx->be_ctx->domain->sysdb); + ret = sysdb_update_view_name(ctx->sd_ctx->be_ctx->domain->sysdb, + view_name); if (ret != EOK) { - DEBUG(SSSDBG_OP_FAILURE, "sysdb_transaction_commit failed.\n"); - goto done; + DEBUG(SSSDBG_CRIT_FAILURE, + "Cannot add/update view name to sysdb.\n"); + } else { + talloc_free(ctx->sd_ctx->id_ctx->view_name); + ctx->sd_ctx->id_ctx->view_name = talloc_strdup( + ctx->sd_ctx->id_ctx, + view_name); + if (ctx->sd_ctx->id_ctx->view_name == NULL) { + DEBUG(SSSDBG_CRIT_FAILURE, "Cannot copy view name.\n"); + } } - - /* TODO: start referesh task */ } - ret = sysdb_update_view_name(ctx->sd_ctx->be_ctx->domain->sysdb, - view_name); - if (ret != EOK) { - DEBUG(SSSDBG_CRIT_FAILURE, - "Cannot add/update view name to sysdb.\n"); - } else { - talloc_free(ctx->sd_ctx->id_ctx->view_name); - ctx->sd_ctx->id_ctx->view_name = talloc_strdup(ctx->sd_ctx->id_ctx, - view_name); - if (ctx->sd_ctx->id_ctx->view_name == NULL) { - DEBUG(SSSDBG_CRIT_FAILURE, "Cannot copy view name.\n"); + if (!ctx->sd_ctx->view_read_at_init) { + /* refresh view data of all domains at startup */ + ret = sysdb_master_domain_update(ctx->sd_ctx->be_ctx->domain); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, + "sysdb_master_domain_update failed.\n"); + goto done; } - } - /* TODO: only needed if view changed */ - ret = sysdb_master_domain_update(ctx->sd_ctx->be_ctx->domain); - if (ret != EOK) { - DEBUG(SSSDBG_OP_FAILURE, "sysdb_master_domain_update failed.\n"); - goto done; + ret = sysdb_update_subdomains(ctx->sd_ctx->be_ctx->domain); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, "sysdb_update_subdomains failed.\n"); + goto done; + } } - ret = sysdb_update_subdomains(ctx->sd_ctx->be_ctx->domain); - if (ret != EOK) { - DEBUG(SSSDBG_OP_FAILURE, "sysdb_update_subdomains failed.\n"); - goto done; - } + ctx->sd_ctx->view_read_at_init = true; + } ret = ipa_check_master(ctx); |