From 18699d003b1d4460ffb36db61860e6c31acbf1cb Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 26 Nov 2007 11:44:30 +0100 Subject: 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) --- source3/winbindd/winbindd.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'source3/winbindd/winbindd.c') diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 07cf22618e..dfad50bf96 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -121,7 +121,23 @@ static void flush_caches(void) otherwise cached access denied errors due to restrict anonymous hang around until the sequence number changes. */ - wcache_invalidate_cache(); + if (wcache_invalidate_cache() < 0) { + DEBUG(0, ("invalidating the cache failed; revalidate the cache\n")); + /* Close the cache to be able to valdite the cache */ + close_winbindd_cache(); + /* + * Ensure all cache and idmap caches are consistent + * before we initialize the cache again. + */ + if (winbindd_validate_cache() < 0) { + DEBUG(0, ("corrupted tdb found, trying to restore backup\n")); + } + + /* Initialize cache again. */ + if (!initialize_winbindd_cache()) { + exit(1); + } + } } /* Handle the signal by unlinking socket and exiting */ -- cgit From 696cf4d3c013f99d034c19c6762bf71c7c1ee8a6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 10:59:14 +0100 Subject: Make wcache_invalidate_cache() return bool, not int. Michael (This used to be commit dba24ceae78ffc49200b647838b6bf3657275add) --- source3/winbindd/winbindd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/winbindd/winbindd.c') diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index dfad50bf96..8ebae3f16d 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -121,7 +121,7 @@ static void flush_caches(void) otherwise cached access denied errors due to restrict anonymous hang around until the sequence number changes. */ - if (wcache_invalidate_cache() < 0) { + if (!wcache_invalidate_cache()) { DEBUG(0, ("invalidating the cache failed; revalidate the cache\n")); /* Close the cache to be able to valdite the cache */ close_winbindd_cache(); -- cgit From 0818d41697e839741b642efb8377f43686c33b7b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 11:19:27 +0100 Subject: Fix a comment. Michael (This used to be commit 62d6d4fff2edcce04e793d2a2f877cb3f4fedbdb) --- source3/winbindd/winbindd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/winbindd/winbindd.c') diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 8ebae3f16d..5e9900d1d6 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -130,7 +130,8 @@ static void flush_caches(void) * before we initialize the cache again. */ if (winbindd_validate_cache() < 0) { - DEBUG(0, ("corrupted tdb found, trying to restore backup\n")); + DEBUG(0, ("winbindd cache tdb corrupt and no backup " + "could be restore.\n")); } /* Initialize cache again. */ -- cgit