s3: winbindd: Move the logic of whether to set 'domain->primary' into add_trusted_dom...
authorJeremy Allison <jra@samba.org>
Mon, 6 Jan 2014 23:15:37 +0000 (15:15 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 8 Jan 2014 17:46:03 +0000 (09:46 -0800)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=10358

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/winbindd/winbindd_util.c

index 85b014d97ccc5965ca423b66a948205ce50f259e..10ca13222b4e8cdb22d6a577de03f29d68b0842c 100644 (file)
@@ -99,6 +99,7 @@ static struct winbindd_domain *add_trusted_domain(const char *domain_name, const
        char *idmap_config_option;
        const char *param;
        const char **ignored_domains, **dom;
+       int role = lp_server_role();
 
        ignored_domains = lp_parm_string_list(-1, "winbind", "ignore domains", NULL);
        for (dom=ignored_domains; dom && *dom; dom++) {
@@ -196,6 +197,15 @@ static struct winbindd_domain *add_trusted_domain(const char *domain_name, const
                sid_copy(&domain->sid, sid);
        }
 
+       /* Is this our primary domain ? */
+       if (strequal(domain_name, get_global_sam_name()) &&
+                       (role != ROLE_DOMAIN_MEMBER)) {
+               domain->primary = true;
+       } else if (strequal(domain_name, lp_workgroup()) &&
+                       (role == ROLE_DOMAIN_MEMBER)) {
+               domain->primary = true;
+       }
+
        /* Link to domain list */
        DLIST_ADD_END(_domain_list, domain, struct winbindd_domain *);
 
@@ -628,9 +638,6 @@ bool init_domain_list(void)
        domain = add_trusted_domain(get_global_sam_name(), NULL,
                                    &cache_methods, get_global_sam_sid());
        if (domain) {
-               if ( role != ROLE_DOMAIN_MEMBER ) {
-                       domain->primary = True;
-               }
                setup_domain_child(domain);
        }
 
@@ -647,7 +654,6 @@ bool init_domain_list(void)
                domain = add_trusted_domain( lp_workgroup(), lp_realm(),
                                             &cache_methods, &our_sid);
                if (domain) {
-                       domain->primary = True;
                        setup_domain_child(domain);
 
                        /* Even in the parent winbindd we'll need to