winbindd: Introduce helper function for winbindd_cache.tdb directory
authorChristof Schmitt <cs@samba.org>
Thu, 18 Aug 2016 21:01:50 +0000 (14:01 -0700)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 19 Aug 2016 11:30:22 +0000 (13:30 +0200)
Also add a comment why the file is placed in the state directory.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Aug 19 13:30:23 CEST 2016 on sn-devel-144

source3/winbindd/winbindd_cache.c

index b2c0ae287ed45fb5ef0c7f8d76613d6eee56d821..b921b75720942dad7017faa3c9a80869d5f0136a 100644 (file)
@@ -111,6 +111,15 @@ void (*smb_panic_fn)(const char *const why) = smb_panic;
 
 static struct winbind_cache *wcache;
 
+static char *wcache_path(void)
+{
+       /*
+        * Data needs to be kept persistent in state directory for
+        * running with "winbindd offline logon".
+        */
+       return state_path("winbindd_cache.tdb");
+}
+
 /* get the winbind_cache structure */
 static struct winbind_cache *get_cache(struct winbindd_domain *domain)
 {
@@ -3195,7 +3204,7 @@ bool init_wcache(void)
        if (wcache->tdb != NULL)
                return true;
 
-       db_path = state_path("winbindd_cache.tdb");
+       db_path = wcache_path();
        if (db_path == NULL) {
                return false;
        }
@@ -3247,7 +3256,7 @@ bool initialize_winbindd_cache(void)
                tdb_close(wcache->tdb);
                wcache->tdb = NULL;
 
-               db_path = state_path("winbindd_cache.tdb");
+               db_path = wcache_path();
                if (db_path == NULL) {
                        return false;
                }
@@ -3384,7 +3393,7 @@ void wcache_flush_cache(void)
                return;
        }
 
-       db_path = state_path("winbindd_cache.tdb");
+       db_path = wcache_path();
        if (db_path == NULL) {
                return;
        }
@@ -4281,7 +4290,7 @@ int winbindd_validate_cache(void)
        DEBUG(10, ("winbindd_validate_cache: replacing panic function\n"));
        smb_panic_fn = validate_panic;
 
-       tdb_path = state_path("winbindd_cache.tdb");
+       tdb_path = wcache_path();
        if (tdb_path == NULL) {
                goto done;
        }
@@ -4352,7 +4361,7 @@ int winbindd_validate_cache_nobackup(void)
        DEBUG(10, ("winbindd_validate_cache: replacing panic function\n"));
        smb_panic_fn = validate_panic;
 
-       tdb_path = state_path("winbindd_cache.tdb");
+       tdb_path = wcache_path();
        if (tdb_path == NULL) {
                goto err_panic_restore;
        }