diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2002-09-24 21:18:22 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2002-09-24 21:18:22 +0000 |
commit | 529848e988fb28b54303408f31e21051ae0b94a6 (patch) | |
tree | d0d6e65463c97a8f4a6d8625b86f6138724c0cb1 /source3/sam | |
parent | 2cd64003e3b127ca5a204b801155fcb4a7447a48 (diff) | |
download | samba-529848e988fb28b54303408f31e21051ae0b94a6.tar.gz samba-529848e988fb28b54303408f31e21051ae0b94a6.tar.bz2 samba-529848e988fb28b54303408f31e21051ae0b94a6.zip |
Fix bug in get_methods_by_name
Fix bug in enum_domains
Add samtest commands:
- lookup_sid
- lookup_name
- enum_domains
- lookup_domain
(This used to be commit 0c01219850e5d9b77b3b2c0b4b87aa3c82e3292b)
Diffstat (limited to 'source3/sam')
-rw-r--r-- | source3/sam/interface.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/source3/sam/interface.c b/source3/sam/interface.c index 6e6902ab3c..e129604ca3 100644 --- a/source3/sam/interface.c +++ b/source3/sam/interface.c @@ -79,7 +79,7 @@ NTSTATUS sam_get_methods_by_name(const SAM_CONTEXT *context, SAM_METHODS **sam_m tmp_methods = context->methods; while (tmp_methods) { - if (strcmp(domainname, tmp_methods->domain_name)) + if (!strcmp(domainname, tmp_methods->domain_name)) { (*sam_method) = tmp_methods; return NT_STATUS_OK; @@ -256,6 +256,7 @@ NTSTATUS context_sam_enum_domains(const SAM_CONTEXT *context, const NT_USER_TOKE } tmp_methods= context->methods; + *domain_count = 0; while (tmp_methods) { (*domain_count)++; @@ -264,15 +265,19 @@ NTSTATUS context_sam_enum_domains(const SAM_CONTEXT *context, const NT_USER_TOKE DEBUG(6,("context_sam_enum_domains: enumerating %d domains\n", (*domain_count))); + if (*domain_count == 0) { + return NT_STATUS_OK; + } + tmp_methods = context->methods; if (((*domains) = malloc( sizeof(DOM_SID) * (*domain_count))) == NULL) { - DEBUG(0,("context_sam_enum_domains: Out of memory allocating domain list\n")); + DEBUG(0,("context_sam_enum_domains: Out of memory allocating domain SID list\n")); return NT_STATUS_NO_MEMORY; } if (((*domain_names) = malloc( sizeof(char*) * (*domain_count))) == NULL) { - DEBUG(0,("context_sam_enum_domains: Out of memory allocating domain list\n")); + DEBUG(0,("context_sam_enum_domains: Out of memory allocating domain name list\n")); SAFE_FREE((*domains)); return NT_STATUS_NO_MEMORY; } @@ -280,13 +285,7 @@ NTSTATUS context_sam_enum_domains(const SAM_CONTEXT *context, const NT_USER_TOKE while (tmp_methods) { DEBUGADD(7,(" [%d] %s: %s\n", i, tmp_methods->domain_name, sid_string_static(&tmp_methods->domain_sid))); sid_copy(domains[i],&tmp_methods->domain_sid); - if(asprintf(&(*domain_names[i]),"%s",tmp_methods->domain_name) < 0) { - DEBUG(0,("context_sam_enum_domains: asprintf failed")); - SAFE_FREE((*domains)); - SAFE_FREE((*domain_names)); - return NT_STATUS_NO_MEMORY; - } - + *domain_names[i] = smb_xstrdup(tmp_methods->domain_name); i++; tmp_methods= tmp_methods->next; } |