From cc050e01370633a985c9878bdce297f9175fdbf7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 31 Dec 2003 05:26:29 +0000 Subject: [PATCH] Jerry rightly complained that we can't assume that the first domain is our primary domain - new domains are added to the front of the list. :-( Use a much more reliable 'flag test' instead. (note: changes winbind structures, make clean). Andrew Bartlett --- source/nsswitch/winbindd_util.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/source/nsswitch/winbindd_util.c b/source/nsswitch/winbindd_util.c index a0619594b56..a9bb851a7a2 100644 --- a/source/nsswitch/winbindd_util.c +++ b/source/nsswitch/winbindd_util.c @@ -168,9 +168,7 @@ void rescan_trusted_domains( void ) if ( (now > last_scan) && ((now-last_scan) < WINBINDD_RESCAN_FREQ) ) return; - /* get the handle for our domain (it is always the first in the list) */ - - if ( (mydomain = domain_list()) == NULL ) { + if ( (mydomain = find_our_domain()) == NULL ) { DEBUG(0,("rescan_trusted_domains: Can't find my own domain!\n")); return; } @@ -272,6 +270,8 @@ BOOL init_domain_list(void) domain = add_trusted_domain( lp_workgroup(), lp_realm(), &cache_methods, NULL); + domain->primary = True; + /* get any alternate name for the primary domain */ cache_methods.alternate_name(domain); @@ -341,6 +341,24 @@ struct winbindd_domain *find_domain_from_sid(DOM_SID *sid) return NULL; } +/* Given a domain sid, return the struct winbindd domain info for it */ + +struct winbindd_domain *find_our_domain() +{ + struct winbindd_domain *domain; + + /* Search through list */ + + for (domain = domain_list(); domain != NULL; domain = domain->next) { + if (domain->primary) + return domain; + } + + /* Not found */ + + return NULL; +} + /* Lookup a sid in a domain from a name */ BOOL winbindd_lookup_sid_by_name(struct winbindd_domain *domain,