Fix bug #8521 - winbindd cache timeout expiry test was reversed
[samba.git] / source3 / winbindd / winbindd_cache.c
index 58a8e710f6f6b336212bb199109147bf7509f15b..620b8588aa06891dd883e6a2e32ade7aff24e412 100644 (file)
@@ -969,8 +969,8 @@ static void wcache_save_sid_to_name(struct winbindd_domain *domain, NTSTATUS sta
        }
 
        centry_end(centry, "SN/%s", sid_to_fstring(sid_string, sid));
-       DEBUG(10,("wcache_save_sid_to_name: %s -> %s (%s)\n", sid_string, 
-                 name, nt_errstr(status)));
+       DEBUG(10,("wcache_save_sid_to_name: %s -> %s\\%s (%s)\n", sid_string,
+                 domain_name, name, nt_errstr(status)));
        centry_free(centry);
 }
 
@@ -3106,7 +3106,7 @@ bool init_wcache(void)
                return true;
 
        /* when working offline we must not clear the cache on restart */
-       wcache->tdb = tdb_open_log(cache_path("winbindd_cache.tdb"),
+       wcache->tdb = tdb_open_log(state_path("winbindd_cache.tdb"),
                                WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE, 
                                TDB_INCOMPATIBLE_HASH |
                                        (lp_winbind_offline_logon() ? TDB_DEFAULT : (TDB_DEFAULT | TDB_CLEAR_IF_FIRST)),
@@ -3150,9 +3150,9 @@ bool initialize_winbindd_cache(void)
                tdb_close(wcache->tdb);
                wcache->tdb = NULL;
 
-               if (unlink(cache_path("winbindd_cache.tdb")) == -1) {
+               if (unlink(state_path("winbindd_cache.tdb")) == -1) {
                        DEBUG(0,("initialize_winbindd_cache: unlink %s failed %s ",
-                               cache_path("winbindd_cache.tdb"),
+                               state_path("winbindd_cache.tdb"),
                                strerror(errno) ));
                        return false;
                }
@@ -3279,7 +3279,7 @@ void wcache_flush_cache(void)
        }
 
        /* when working offline we must not clear the cache on restart */
-       wcache->tdb = tdb_open_log(cache_path("winbindd_cache.tdb"),
+       wcache->tdb = tdb_open_log(state_path("winbindd_cache.tdb"),
                                WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE, 
                                TDB_INCOMPATIBLE_HASH |
                                (lp_winbind_offline_logon() ? TDB_DEFAULT : (TDB_DEFAULT | TDB_CLEAR_IF_FIRST)),
@@ -4093,7 +4093,7 @@ static void validate_panic(const char *const why)
 int winbindd_validate_cache(void)
 {
        int ret = -1;
-       const char *tdb_path = cache_path("winbindd_cache.tdb");
+       const char *tdb_path = state_path("winbindd_cache.tdb");
        TDB_CONTEXT *tdb = NULL;
 
        DEBUG(10, ("winbindd_validate_cache: replacing panic function\n"));
@@ -4136,7 +4136,7 @@ done:
 int winbindd_validate_cache_nobackup(void)
 {
        int ret = -1;
-       const char *tdb_path = cache_path("winbindd_cache.tdb");
+       const char *tdb_path = state_path("winbindd_cache.tdb");
 
        DEBUG(10, ("winbindd_validate_cache: replacing panic function\n"));
        smb_panic_fn = validate_panic;
@@ -4571,7 +4571,7 @@ struct winbindd_tdc_domain*
        wcache_tdc_fetch_list(&dom_list, &num_domains);
 
        for (i = 0; i<num_domains; i++) {
-               if (sid_equal(sid, &(dom_list[i].sid))) {
+               if (dom_sid_equal(sid, &(dom_list[i].sid))) {
                        DEBUG(10, ("wcache_tdc_fetch_domainbysid: "
                                   "Found domain %s for SID %s\n",
                                   dom_list[i].domain_name,
@@ -4807,7 +4807,7 @@ bool wcache_fetch_ndr(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
                        goto fail;
                }
                entry_timeout = BVAL(data.dptr, 4);
-               if (entry_timeout > time(NULL)) {
+               if (time(NULL) > entry_timeout) {
                        DEBUG(10, ("Entry has timed out\n"));
                        goto fail;
                }