[SSSD] [PATCH] LDAP: Store cleanup timeout after initial cleanup
Jakub Hrozek
jhrozek at redhat.com
Wed Sep 11 15:01:32 UTC 2013
See attached patch. As an effect, subsequent enumerations didn't honor
lastUSN. The bug was reported by Lukas.
-------------- next part --------------
>From b7f9ea27df879296f20b92a67ec65565acffa892 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed, 11 Sep 2013 16:57:30 +0200
Subject: [PATCH] LDAP: Store cleanup timeout after initial cleanup
When the SSSD changes serves (and hence lastUSN) we perform a cleanup as
well. However, after recent changes, we didn't set the cleanup timestamp
correctly, which made the lastUSN logic fail.
---
src/providers/ldap/ldap_common.h | 2 +-
src/providers/ldap/ldap_id_cleanup.c | 16 ++++++++--------
src/providers/ldap/sdap_async_enum.c | 2 +-
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h
index e5b7f1151e57fd22bce856c81801c2df7a60f0c3..a5f3dee94c14eb2fb5f72eb9768d24b7a20ccce9 100644
--- a/src/providers/ldap/ldap_common.h
+++ b/src/providers/ldap/ldap_common.h
@@ -171,7 +171,7 @@ errno_t ldap_setup_enumeration(struct sdap_id_ctx *ctx,
struct sdap_id_conn_ctx *conn,
struct sdap_domain *sdom);
errno_t ldap_id_cleanup(struct sdap_options *opts,
- struct sss_domain_info *dom);
+ struct sdap_domain *sdom);
int ldap_id_cleanup_create_timer(struct sdap_id_ctx *ctx,
struct sdap_domain *sdom,
struct timeval tv);
diff --git a/src/providers/ldap/ldap_id_cleanup.c b/src/providers/ldap/ldap_id_cleanup.c
index 1fd2ff49fe7e80fc9856eb7fadb9017145fb4b45..eb4d42fe18a68116b1417d5d0e659c4e8ce03794 100644
--- a/src/providers/ldap/ldap_id_cleanup.c
+++ b/src/providers/ldap/ldap_id_cleanup.c
@@ -60,7 +60,7 @@ static void ldap_id_cleanup_timer(struct tevent_context *ev,
return;
}
- ret = ldap_id_cleanup(cctx->ctx->opts, cctx->sdom->dom);
+ ret = ldap_id_cleanup(cctx->ctx->opts, cctx->sdom);
if (ret != EOK) {
/* On error schedule starting from now, not the last run */
tv = tevent_timeval_current();
@@ -71,7 +71,6 @@ static void ldap_id_cleanup_timer(struct tevent_context *ev,
delay = dp_opt_get_int(cctx->ctx->opts->basic, SDAP_CACHE_PURGE_TIMEOUT);
tv = tevent_timeval_add(&tv, delay, 0);
ldap_id_cleanup_set_timer(cctx, tv);
- cctx->sdom->last_purge = tevent_timeval_current();
}
static errno_t ldap_id_cleanup_set_timer(struct ldap_id_cleanup_ctx *cctx,
@@ -116,7 +115,7 @@ static int cleanup_groups(TALLOC_CTX *memctx,
struct sss_domain_info *domain);
errno_t ldap_id_cleanup(struct sdap_options *opts,
- struct sss_domain_info *dom)
+ struct sdap_domain *sdom)
{
int ret, tret;
bool in_transaction = false;
@@ -127,34 +126,35 @@ errno_t ldap_id_cleanup(struct sdap_options *opts,
return ENOMEM;
}
- ret = sysdb_transaction_start(dom->sysdb);
+ ret = sysdb_transaction_start(sdom->dom->sysdb);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to start transaction\n"));
goto done;
}
in_transaction = true;
- ret = cleanup_users(opts, dom);
+ ret = cleanup_users(opts, sdom->dom);
if (ret && ret != ENOENT) {
goto done;
}
- ret = cleanup_groups(tmp_ctx, dom->sysdb, dom);
+ ret = cleanup_groups(tmp_ctx, sdom->dom->sysdb, sdom->dom);
if (ret) {
goto done;
}
- ret = sysdb_transaction_commit(dom->sysdb);
+ ret = sysdb_transaction_commit(sdom->dom->sysdb);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to commit transaction\n"));
goto done;
}
in_transaction = false;
+ sdom->last_purge = tevent_timeval_current();
ret = EOK;
done:
if (in_transaction) {
- tret = sysdb_transaction_cancel(dom->sysdb);
+ tret = sysdb_transaction_cancel(sdom->dom->sysdb);
if (tret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, ("Could not cancel transaction\n"));
}
diff --git a/src/providers/ldap/sdap_async_enum.c b/src/providers/ldap/sdap_async_enum.c
index 625db645f3061d0b5b6538b7193e997e22bf3429..9a520ba5f35b56e26ec354b133b06379a1072465 100644
--- a/src/providers/ldap/sdap_async_enum.c
+++ b/src/providers/ldap/sdap_async_enum.c
@@ -311,7 +311,7 @@ static void sdap_dom_enum_services_done(struct tevent_req *subreq)
}
if (state->purge) {
- ret = ldap_id_cleanup(state->ctx->opts, state->sdom->dom);
+ ret = ldap_id_cleanup(state->ctx->opts, state->sdom);
if (ret != EOK) {
/* Not fatal, worst case we'll have stale entries that would be
* removed on a subsequent online lookup
--
1.8.3.1
More information about the sssd-devel
mailing list