summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2012-07-20 12:36:43 -0400
committerJakub Hrozek <jhrozek@redhat.com>2012-08-01 22:24:44 +0200
commitefea50efda58be66638e5d38c8e57fdf9992f204 (patch)
treed4083a388034417ee130369a9ffcc5c9052028fe /src/db
parent87ed72b47859e673b636c85f35b85f1546c7ed3d (diff)
downloadsssd_unused-efea50efda58be66638e5d38c8e57fdf9992f204.tar.gz
sssd_unused-efea50efda58be66638e5d38c8e57fdf9992f204.tar.xz
sssd_unused-efea50efda58be66638e5d38c8e57fdf9992f204.zip
Change refreshing of subdomains
This patch keeps a local copy of the subdomains in the ipa subdomains plugin context. This has 2 advantages: 1. allows to check if anything changed w/o always hitting the sysdb. 2. later will allows us to dump this information w/o having to retrieve it again. The timestamp also allows to avoid refreshing too often.
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.h3
-rw-r--r--src/db/sysdb_subdomains.c13
2 files changed, 9 insertions, 7 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 0e2404c7..43ac61c2 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -371,7 +371,8 @@ errno_t sysdb_get_subdomains(TALLOC_CTX *mem_ctx,
errno_t sysdb_domain_create(struct sysdb_ctx *sysdb, const char *domain_name);
errno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb,
- struct sysdb_subdom **subdomains);
+ int num_subdoms,
+ struct sysdb_subdom *subdoms);
errno_t sysdb_get_subdomain_context(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c
index 8f1df88b..8489041b 100644
--- a/src/db/sysdb_subdomains.c
+++ b/src/db/sysdb_subdomains.c
@@ -430,7 +430,8 @@ done:
}
errno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb,
- struct sysdb_subdom **subdomains)
+ int num_subdoms,
+ struct sysdb_subdom *subdoms)
{
int ret;
int sret;
@@ -475,9 +476,9 @@ errno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb,
* - if a subdomain already exists in sysdb, mark it for preservation
* - if the subdomain doesn't exist in sysdb, create its bare structure
*/
- for (c = 0; subdomains[c] != NULL; c++) {
+ for (c = 0; c < num_subdoms; c++) {
for (d = 0; d < cur_subdomains_count; d++) {
- if (strcasecmp(subdomains[c]->name,
+ if (strcasecmp(subdoms[c].name,
cur_subdomains[d]->name) == 0) {
keep_subdomain[d] = true;
/* sub-domain already in cache, nothing to do */
@@ -487,14 +488,14 @@ errno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb,
if (d == cur_subdomains_count) {
DEBUG(SSSDBG_TRACE_FUNC, ("Adding sub-domain [%s].\n",
- subdomains[c]->name));
- ret = sysdb_domain_create(sysdb, subdomains[c]->name);
+ subdoms[c].name));
+ ret = sysdb_domain_create(sysdb, subdoms[c].name);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE, ("sysdb_domain_create failed.\n"));
goto done;
}
- ret = sysdb_add_subdomain_attributes(sysdb, subdomains[c]);
+ ret = sysdb_add_subdomain_attributes(sysdb, &subdoms[c]);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE,
("sysdb_add_subdomain_attributes failed.\n"));