]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:winbind: Code cleanup for initialize_winbindd_cache()
authorAndreas Schneider <asn@samba.org>
Tue, 11 May 2021 09:34:40 +0000 (11:34 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 12 May 2021 20:29:32 +0000 (20:29 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/winbindd/winbindd_cache.c

index 6c467daaa820609de0164d5243d8b2b0baee06c7..01bf94855c0ea06c35e44b5eb3df9b8cb91c6168 100644 (file)
@@ -3057,8 +3057,9 @@ static bool init_wcache(void)
 
 bool initialize_winbindd_cache(void)
 {
-       bool cache_bad = true;
-       uint32_t vers;
+       bool cache_bad = false;
+       uint32_t vers = 0;
+       bool ok;
 
        if (!init_wcache()) {
                DEBUG(0,("initialize_winbindd_cache: init_wcache failed.\n"));
@@ -3066,9 +3067,16 @@ bool initialize_winbindd_cache(void)
        }
 
        /* Check version number. */
-       if (tdb_fetch_uint32(wcache->tdb, WINBINDD_CACHE_VERSION_KEYSTR, &vers) &&
-                       vers == WINBINDD_CACHE_VERSION) {
-               cache_bad = false;
+       ok = tdb_fetch_uint32(wcache->tdb, WINBINDD_CACHE_VERSION_KEYSTR, &vers);
+       if (!ok) {
+               DBG_DEBUG("Failed to get cache version\n");
+               cache_bad = true;
+       }
+       if (vers != WINBINDD_CACHE_VERSION) {
+               DBG_DEBUG("Invalid cache version %u != %u\n",
+                         vers,
+                         WINBINDD_CACHE_VERSION);
+               cache_bad = true;
        }
 
        if (cache_bad) {