summaryrefslogtreecommitdiff
path: root/source3/winbindd/winbindd_cache.c
diff options
context:
space:
mode:
authorAndreas Schneider <anschneider@suse.de>2007-11-26 11:44:30 +0100
committerMichael Adam <obnox@samba.org>2008-01-07 10:24:34 +0100
commit18699d003b1d4460ffb36db61860e6c31acbf1cb (patch)
tree51bb97c90b9328c8b60d237029223972f1c810b1 /source3/winbindd/winbindd_cache.c
parent3f4699f5a3f3c7a2ad11119c266e5a018d71b0fe (diff)
downloadsamba-18699d003b1d4460ffb36db61860e6c31acbf1cb.tar.gz
samba-18699d003b1d4460ffb36db61860e6c31acbf1cb.tar.bz2
samba-18699d003b1d4460ffb36db61860e6c31acbf1cb.zip
Prevent winbindd from segfaulting due to corrupted cache tdb.
If we try to flush the caches and due to a corrupted tdb we and have no tdb context close the tdb and validate it. Initialize the cache afterwards again. (This used to be commit d0c0f91fb9f3438a18c6f47ed894f525beb75cbf)
Diffstat (limited to 'source3/winbindd/winbindd_cache.c')
-rw-r--r--source3/winbindd/winbindd_cache.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index f63c7a5b2f..62a68aa8aa 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -2261,7 +2261,7 @@ void wcache_invalidate_samlogon(struct winbindd_domain *domain,
netsamlogon_clear_cached_user(cache->tdb, info3);
}
-void wcache_invalidate_cache(void)
+int wcache_invalidate_cache(void)
{
struct winbindd_domain *domain;
@@ -2270,9 +2270,15 @@ void wcache_invalidate_cache(void)
DEBUG(10, ("wcache_invalidate_cache: invalidating cache "
"entries for %s\n", domain->name));
- if (cache)
- tdb_traverse(cache->tdb, traverse_fn, NULL);
+ if (cache) {
+ if (cache->tdb) {
+ tdb_traverse(cache->tdb, traverse_fn, NULL);
+ } else {
+ return -1;
+ }
+ }
}
+ return 0;
}
bool init_wcache(void)
@@ -2354,6 +2360,16 @@ bool initialize_winbindd_cache(void)
return True;
}
+void close_winbindd_cache()
+{
+ if (!wcache)
+ return;
+ if (wcache->tdb) {
+ tdb_close(wcache->tdb);
+ wcache->tdb = NULL;
+ }
+}
+
void cache_store_response(pid_t pid, struct winbindd_response *response)
{
fstring key_str;