summaryrefslogtreecommitdiffstats
path: root/source/nsswitch/winbindd_util.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-01-10 06:20:03 +0000
committerTim Potter <tpot@samba.org>2002-01-10 06:20:03 +0000
commiteeb8af9c1a66bfcd80823d7b406acbab79857a16 (patch)
treec06c35946ad3102267618d02b494d21256dcc5a9 /source/nsswitch/winbindd_util.c
parent85d3ffb2709258e576191adade9c61b11e83eec5 (diff)
downloadsamba-eeb8af9c1a66bfcd80823d7b406acbab79857a16.tar.gz
samba-eeb8af9c1a66bfcd80823d7b406acbab79857a16.tar.xz
samba-eeb8af9c1a66bfcd80823d7b406acbab79857a16.zip
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
Diffstat (limited to 'source/nsswitch/winbindd_util.c')
-rw-r--r--source/nsswitch/winbindd_util.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/source/nsswitch/winbindd_util.c b/source/nsswitch/winbindd_util.c
index 2f21f81ea87..3086795a494 100644
--- a/source/nsswitch/winbindd_util.c
+++ b/source/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);