From 610f530aee4da9b63cb1cb9005650d27e4846bc0 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 10 Jan 2002 06:20:03 +0000 Subject: A big tidyup while thinking about getting trusted domains being re-read when they are added or removed on the PDC. - renamed GETPWNAM_FROM_{UID,USER} constants and functions to GETPW{NAM,UID} - renamed GETGRNAM_FROM_{GID,GROUP} constants and functions to GETGR{NAM,GID} - use SIGUSR2 in winbindd for debugging/logging instead of SIGUSR1 in preparation for moving to smbcontrol type messages (not sure whether to ditch this altogether or not) - tidy debugging messages in top level winbind user and group routines - convert talloc_init() to talloc_init_named() - make enumerations of the domain list use the same local variable names (This used to be commit eeb8af9c1a66bfcd80823d7b406acbab79857a16) --- source3/nsswitch/winbindd_util.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'source3/nsswitch/winbindd_util.c') diff --git a/source3/nsswitch/winbindd_util.c b/source3/nsswitch/winbindd_util.c index 2f21f81ea8..3086795a49 100644 --- a/source3/nsswitch/winbindd_util.c +++ b/source3/nsswitch/winbindd_util.c @@ -47,17 +47,17 @@ struct winbindd_domain *domain_list = NULL; struct winbindd_domain *find_domain_from_name(char *domain_name) { - struct winbindd_domain *tmp; + struct winbindd_domain *domain; if (domain_list == NULL) get_domain_info(); /* Search through list */ - for (tmp = domain_list; tmp != NULL; tmp = tmp->next) { - if (strcasecmp(domain_name, tmp->name) == 0 || - strcasecmp(domain_name, tmp->full_name) == 0) - return tmp; + for (domain = domain_list; domain != NULL; domain = domain->next) { + if (strcasecmp(domain_name, domain->name) == 0 || + strcasecmp(domain_name, domain->full_name) == 0) + return domain; } /* Not found */ @@ -69,15 +69,15 @@ struct winbindd_domain *find_domain_from_name(char *domain_name) struct winbindd_domain *find_domain_from_sid(DOM_SID *sid) { - struct winbindd_domain *tmp; + struct winbindd_domain *domain; if (domain_list == NULL) get_domain_info(); /* Search through list */ - for (tmp = domain_list; tmp != NULL; tmp = tmp->next) { - if (sid_compare_domain(sid, &tmp->sid) == 0) - return tmp; + for (domain = domain_list; domain != NULL; domain = domain->next) { + if (sid_compare_domain(sid, &domain->sid) == 0) + return domain; } /* Not found */ @@ -90,22 +90,26 @@ struct winbindd_domain *find_domain_from_sid(DOM_SID *sid) static struct winbindd_domain *add_trusted_domain(char *domain_name, struct winbindd_methods *methods) { - struct winbindd_domain *domain, *tmp; + struct winbindd_domain *domain; - for (tmp = domain_list; tmp != NULL; tmp = tmp->next) { - if (strcmp(domain_name, tmp->name) == 0) { - DEBUG(3, ("domain %s already in domain list\n", domain_name)); - return tmp; + for (domain = domain_list; domain; domain = domain->next) { + if (strcmp(domain_name, domain->name) == 0) { + DEBUG(3, ("domain %s already in domain list\n", + domain_name)); + return domain; } } /* Create new domain entry */ - if ((domain = (struct winbindd_domain *)malloc(sizeof(*domain))) == NULL) + + if ((domain = (struct winbindd_domain *) + malloc(sizeof(*domain))) == NULL) return NULL; /* Fill in fields */ ZERO_STRUCTP(domain); + fstrcpy(domain->name, domain_name); domain->methods = methods; domain->sequence_number = DOM_SEQUENCE_NONE; @@ -130,7 +134,7 @@ BOOL get_domain_info(void) char **names; int num_domains = 0; - if (!(mem_ctx = talloc_init())) + if (!(mem_ctx = talloc_init_named("get_domain_info"))) return False; domain = add_trusted_domain(lp_workgroup(), &cache_methods); @@ -222,6 +226,7 @@ BOOL winbindd_lookup_name_by_sid(DOM_SID *sid, struct winbindd_domain *domain; domain = find_domain_from_sid(sid); + if (!domain) { DEBUG(1,("Can't find domain from sid\n")); return False; @@ -229,7 +234,7 @@ BOOL winbindd_lookup_name_by_sid(DOM_SID *sid, /* Lookup name */ - if (!(mem_ctx = talloc_init())) + if (!(mem_ctx = talloc_init_named("winbindd_lookup_name_by_sid"))) return False; result = domain->methods->sid_to_name(domain, mem_ctx, sid, &names, type); -- cgit