From 80c6afa474d8a1e0198832bddfe5da75a9818b29 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 7 Jan 2013 23:53:02 -0500 Subject: Add domain argument to sysdb_has/set_enumerated() --- src/db/sysdb.c | 12 +++++------- src/db/sysdb.h | 2 ++ src/providers/ldap/ldap_common.c | 3 ++- src/providers/ldap/ldap_id_enum.c | 2 +- src/providers/ldap/sdap_reinit.c | 2 +- src/tests/sysdb-tests.c | 8 +++----- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/db/sysdb.c b/src/db/sysdb.c index 623cf2b5..65a0140f 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -1492,6 +1492,7 @@ done: } errno_t sysdb_has_enumerated(struct sysdb_ctx *sysdb, + struct sss_domain_info *domain, bool *has_enumerated) { errno_t ret; @@ -1505,9 +1506,7 @@ errno_t sysdb_has_enumerated(struct sysdb_ctx *sysdb, goto done; } - dn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, - SYSDB_DOM_BASE, - sysdb->domain->name); + dn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, SYSDB_DOM_BASE, domain->name); if (!dn) { ret = ENOMEM; goto done; @@ -1521,6 +1520,7 @@ done: } errno_t sysdb_set_enumerated(struct sysdb_ctx *sysdb, + struct sss_domain_info *domain, bool enumerated) { errno_t ret; @@ -1533,15 +1533,13 @@ errno_t sysdb_set_enumerated(struct sysdb_ctx *sysdb, goto done; } - dn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, - SYSDB_DOM_BASE, - sysdb->domain->name); + dn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, SYSDB_DOM_BASE, domain->name); if (!dn) { ret = ENOMEM; goto done; } - ret = sysdb_set_bool(sysdb, dn, sysdb->domain->name, + ret = sysdb_set_bool(sysdb, dn, domain->name, SYSDB_HAS_ENUMERATED, enumerated); done: diff --git a/src/db/sysdb.h b/src/db/sysdb.h index de5953c2..96bbb8d2 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -806,9 +806,11 @@ errno_t sysdb_set_bool(struct sysdb_ctx *sysdb, bool value); errno_t sysdb_has_enumerated(struct sysdb_ctx *sysdb, + struct sss_domain_info *domain, bool *has_enumerated); errno_t sysdb_set_enumerated(struct sysdb_ctx *sysdb, + struct sss_domain_info *domain, bool enumerated); errno_t sysdb_remove_attrs(struct sysdb_ctx *sysdb, diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c index a97dc34e..0dcd5a4d 100644 --- a/src/providers/ldap/ldap_common.c +++ b/src/providers/ldap/ldap_common.c @@ -767,7 +767,8 @@ int sdap_id_setup_tasks(struct sdap_id_ctx *ctx) * clients requesting get*ent information won't get an * immediate reply with no entries */ - ret = sysdb_has_enumerated(ctx->be->sysdb, &has_enumerated); + ret = sysdb_has_enumerated(ctx->be->sysdb, ctx->be->domain, + &has_enumerated); if (ret != EOK) { return ret; } diff --git a/src/providers/ldap/ldap_id_enum.c b/src/providers/ldap/ldap_id_enum.c index 88036cc2..ecd1a6e7 100644 --- a/src/providers/ldap/ldap_id_enum.c +++ b/src/providers/ldap/ldap_id_enum.c @@ -145,7 +145,7 @@ static void ldap_id_enumerate_reschedule(struct tevent_req *req) * process on the next SSSD service restart (to avoid * slowing down system boot-up */ - ret = sysdb_set_enumerated(ctx->be->sysdb, true); + ret = sysdb_set_enumerated(ctx->be->sysdb, ctx->be->domain, true); if (ret != EOK) { DEBUG(1, ("Could not mark domain as having enumerated.\n")); /* This error is non-fatal, so continue */ diff --git a/src/providers/ldap/sdap_reinit.c b/src/providers/ldap/sdap_reinit.c index 41d10249..dd49c7b8 100644 --- a/src/providers/ldap/sdap_reinit.c +++ b/src/providers/ldap/sdap_reinit.c @@ -211,7 +211,7 @@ static void sdap_reinit_cleanup_done(struct tevent_req *subreq) * process on the next SSSD service restart (to avoid * slowing down system boot-up */ - ret = sysdb_set_enumerated(state->sysdb, true); + ret = sysdb_set_enumerated(state->sysdb, state->domain, true); if (ret != EOK) { DEBUG(SSSDBG_MINOR_FAILURE, ("Could not mark domain as having " "enumerated.\n")); diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c index ab0cdb96..76d5e483 100644 --- a/src/tests/sysdb-tests.c +++ b/src/tests/sysdb-tests.c @@ -4224,20 +4224,18 @@ START_TEST(test_sysdb_has_enumerated) ret = setup_sysdb_tests(&test_ctx); fail_if(ret != EOK, "Could not set up the test"); - ret = sysdb_has_enumerated(test_ctx->sysdb, &enumerated); + ret = sysdb_has_enumerated(test_ctx->sysdb, test_ctx->domain, &enumerated); fail_if(ret != EOK, "Error [%d][%s] checking enumeration", ret, strerror(ret)); fail_if(enumerated, "Enumeration should default to false"); - ret = sysdb_set_enumerated(test_ctx->sysdb, - true); + ret = sysdb_set_enumerated(test_ctx->sysdb, test_ctx->domain, true); fail_if(ret != EOK, "Error [%d][%s] setting enumeration", ret, strerror(ret)); /* Recheck enumeration status */ - ret = sysdb_has_enumerated(test_ctx->sysdb, - &enumerated); + ret = sysdb_has_enumerated(test_ctx->sysdb, test_ctx->domain, &enumerated); fail_if(ret != EOK, "Error [%d][%s] checking enumeration", ret, strerror(ret)); -- cgit