1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-23 09:57:40 +03:00

Refactor 9b78af1f: Fix lookupname recursion

Pass a "flags" argument instead of the original winbind command down the
name_to_sid chain. This way we are independent of the winbind commands and
can take the decision at a much higher level
This commit is contained in:
Volker Lendecke 2009-08-02 10:43:05 +02:00
parent 62fec96819
commit 4f147388c0
7 changed files with 23 additions and 29 deletions

View File

@ -247,9 +247,9 @@ struct winbindd_methods {
/* convert one user or group name to a sid */
NTSTATUS (*name_to_sid)(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
enum winbindd_cmd orig_cmd,
const char *domain_name,
const char *name,
uint32_t flags,
DOM_SID *sid,
enum lsa_SidType *type);

View File

@ -404,14 +404,14 @@ static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
/* convert a single name to a sid in a domain - use rpc methods */
static NTSTATUS name_to_sid(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
enum winbindd_cmd orig_cmd,
const char *domain_name,
const char *name,
uint32_t flags,
DOM_SID *sid,
enum lsa_SidType *type)
{
return reconnect_methods.name_to_sid(domain, mem_ctx, orig_cmd,
domain_name, name,
return reconnect_methods.name_to_sid(domain, mem_ctx,
domain_name, name, flags,
sid, type);
}

View File

@ -1608,9 +1608,9 @@ skip_save:
/* convert a single name to a sid in a domain */
static NTSTATUS name_to_sid(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
enum winbindd_cmd orig_cmd,
const char *domain_name,
const char *name,
uint32_t flags,
DOM_SID *sid,
enum lsa_SidType *type)
{
@ -1657,8 +1657,8 @@ do_query:
DEBUG(10,("name_to_sid: [Cached] - doing backend query for name for domain %s\n",
domain->name ));
status = domain->backend->name_to_sid(domain, mem_ctx, orig_cmd,
domain_name, name, sid, type);
status = domain->backend->name_to_sid(domain, mem_ctx, domain_name,
name, flags, sid, type);
/* and save it */
refresh_sequence_number(domain, false);

View File

@ -88,25 +88,15 @@ static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
/* convert a single name to a sid in a domain */
static NTSTATUS name_to_sid(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
enum winbindd_cmd original_cmd,
const char *domain_name,
const char *name,
uint32_t flags,
DOM_SID *sid,
enum lsa_SidType *type)
{
const char *fullname;
uint32 flags = LOOKUP_NAME_ALL;
switch ( original_cmd ) {
case WINBINDD_LOOKUPNAME:
/* This call is ok */
break;
default:
/* Avoid any NSS calls in the lookup_name by default */
flags |= LOOKUP_NAME_NO_NSS;
DEBUG(10,("winbindd_passdb: limiting name_to_sid() to explicit mappings\n"));
break;
}
flags |= LOOKUP_NAME_ALL;
if (domain_name && domain_name[0] && strchr_m(name, '\\') == NULL) {
fullname = talloc_asprintf(mem_ctx, "%s\\%s",

View File

@ -83,21 +83,20 @@ static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
/* convert a single name to a sid in a domain */
static NTSTATUS name_to_sid(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
enum winbindd_cmd orig_cmd,
const char *domain_name,
const char *name,
uint32_t flags,
DOM_SID *sid,
enum lsa_SidType *type)
{
NTSTATUS result;
result = msrpc_methods.name_to_sid(domain, mem_ctx, orig_cmd,
domain_name, name,
sid, type);
result = msrpc_methods.name_to_sid(domain, mem_ctx, domain_name, name,
flags, sid, type);
if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
result = msrpc_methods.name_to_sid(domain, mem_ctx, orig_cmd,
domain_name, name,
result = msrpc_methods.name_to_sid(domain, mem_ctx,
domain_name, name, flags,
sid, type);
return result;

View File

@ -267,9 +267,9 @@ static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
/* convert a single name to a sid in a domain */
static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
enum winbindd_cmd original_cmd,
const char *domain_name,
const char *name,
uint32_t flags,
DOM_SID *sid,
enum lsa_SidType *type)
{

View File

@ -886,9 +886,14 @@ bool winbindd_lookup_sid_by_name(TALLOC_CTX *mem_ctx,
{
NTSTATUS result;
/* Lookup name */
result = domain->methods->name_to_sid(domain, mem_ctx, orig_cmd,
domain_name, name, sid, type);
/*
* For all but LOOKUPNAME we have to avoid nss calls to avoid
* recursion
*/
result = domain->methods->name_to_sid(
domain, mem_ctx, domain_name, name,
orig_cmd == WINBINDD_LOOKUPNAME ? 0 : LOOKUP_NAME_NO_NSS,
sid, type);
/* Return sid and type if lookup successful */
if (!NT_STATUS_IS_OK(result)) {