winbindd: Factor out winbindd_domain_init_backend from get_cache()
authorVolker Lendecke <vl@samba.org>
Sun, 6 Aug 2017 16:11:02 +0000 (18:11 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 29 Nov 2017 15:59:16 +0000 (16:59 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/winbindd/winbindd_cache.c

index fbf4451fc33f9c79c76c54230bd068859321f9d7..76b79a3e18a4cf9de988869adc599f6d387e08f0 100644 (file)
@@ -121,12 +121,11 @@ static char *wcache_path(void)
        return state_path("winbindd_cache.tdb");
 }
 
-/* get the winbind_cache structure */
-static struct winbind_cache *get_cache(struct winbindd_domain *domain)
+static void winbindd_domain_init_backend(struct winbindd_domain *domain)
 {
-       struct winbind_cache *ret = wcache;
-
-       /* We have to know what type of domain we are dealing with first. */
+       if (domain->backend != NULL) {
+               return;
+       }
 
        if (domain->internal) {
                domain->backend = &builtin_passdb_methods;
@@ -173,6 +172,14 @@ static struct winbind_cache *get_cache(struct winbindd_domain *domain)
                DBG_INFO("Setting MS-RPC methods for domain %s\n", domain->name);
                domain->backend = &reconnect_methods;
        }
+}
+
+/* get the winbind_cache structure */
+static struct winbind_cache *get_cache(struct winbindd_domain *domain)
+{
+       struct winbind_cache *ret = wcache;
+
+       winbindd_domain_init_backend(domain);
 
        if (ret != NULL) {
                return ret;