winbindd: only call winbindd_validate_cache when not in offline logon mode.
authorMichael Adam <obnox@samba.org>
Thu, 10 Apr 2008 09:53:53 +0000 (11:53 +0200)
committerMichael Adam <obnox@samba.org>
Thu, 10 Apr 2008 11:23:30 +0000 (13:23 +0200)
originally, the cache was cleared before calling validate, but
this way, we skipt the validation of the database when not in
offline logon mode.

This is put into a new wrapper function winbindd_cache_validate_and_initialize()
which is now called in winbindd.c instead calling validate and
initialize functions separately.

Michael

source/winbindd/winbindd.c
source/winbindd/winbindd_cache.c

index 25ceeeb3210edd983bcaf2ef81b9ad14ec22c89e..dbfd397f8bc2d77df31b72e6eae5dbb3189d5613 100644 (file)
@@ -123,19 +123,7 @@ static void flush_caches(void)
 
        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();
-               /*
-                * Ensure all cache and idmap caches are consistent
-                * before we initialize the cache again.
-                */
-               if (winbindd_validate_cache() < 0) {
-                       DEBUG(0, ("winbindd cache tdb corrupt and no backup "
-                                 "could be restore.\n"));
-               }
-
-               /* Initialize cache again. */
-               if (!initialize_winbindd_cache()) {
+               if (!winbindd_cache_validate_and_initialize()) {
                        exit(1);
                }
        }
@@ -1194,14 +1182,9 @@ int main(int argc, char **argv, char **envp)
 
        /*
         * Ensure all cache and idmap caches are consistent
-        * before we startup.
+        * and initialized before we startup.
         */
-       if (winbindd_validate_cache() < 0) {
-               DEBUG(0, ("corrupted tdb found, trying to restore backup\n"));
-       }
-
-       /* Initialize cache (ensure version is correct). */
-       if (!initialize_winbindd_cache()) {
+       if (!winbindd_cache_validate_and_initialize()) {
                exit(1);
        }
 
index e4b0a53d5d1188cb58aa45dabb057b27eea10b05..ddb0ab317e667ac8c4b23b2d61376417815a7070 100644 (file)
@@ -3476,6 +3476,20 @@ int winbindd_validate_cache_nobackup(void)
        return ret;
 }
 
+bool winbindd_cache_validate_and_initialize(void)
+{
+       close_winbindd_cache();
+
+       if (lp_winbind_offline_logon()) {
+               if (winbindd_validate_cache() < 0) {
+                       DEBUG(0, ("winbindd cache tdb corrupt and no backup "
+                                 "could be restored.\n"));
+               }
+       }
+
+       return initialize_winbindd_cache();
+}
+
 /*********************************************************************
  ********************************************************************/