[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-test-2172-gc6db963

Günther Deschner gd at samba.org
Wed Feb 13 09:57:15 GMT 2008


The branch, v3-2-test has been updated
       via  c6db963dacb04a9b2ee12705d8cfb29b843c0ea2 (commit)
       via  34c2566f026dbde4da10e2fc10c6960260eb6044 (commit)
       via  c19847a02486414117425930367dcd210e911715 (commit)
      from  fa3a78b815e0bcbb4ac08b6277f798593c0458e9 (commit)

http://gitweb.samba.org/?samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit c6db963dacb04a9b2ee12705d8cfb29b843c0ea2
Author: Günther Deschner <gd at samba.org>
Date:   Wed Feb 13 10:54:56 2008 +0100

    Remove unused marshalling for SAMR_LOOKUP_RIDS.
    
    Guenther

commit 34c2566f026dbde4da10e2fc10c6960260eb6044
Author: Günther Deschner <gd at samba.org>
Date:   Wed Feb 13 10:49:55 2008 +0100

    Convert last caller (in winbindd) to rpccli_samr_LookupRids.
    
    Guenther

commit c19847a02486414117425930367dcd210e911715
Author: Günther Deschner <gd at samba.org>
Date:   Wed Feb 13 10:54:16 2008 +0100

    Remove unused init_sam_entry routine.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source/include/rpc_samr.h      |   44 ---------
 source/rpc_client/cli_samr.c   |   74 --------------
 source/rpc_parse/parse_samr.c  |  210 ----------------------------------------
 source/winbindd/winbindd_rpc.c |   48 +++++-----
 4 files changed, 25 insertions(+), 351 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/include/rpc_samr.h b/source/include/rpc_samr.h
index 28bd807..9b9b4d2 100644
--- a/source/include/rpc_samr.h
+++ b/source/include/rpc_samr.h
@@ -227,50 +227,6 @@ typedef struct r_samr_enum_dom_aliases_info
 
 } SAMR_R_ENUM_DOM_ALIASES;
 
-/****************************************************************************
-SAMR_Q_LOOKUP_RIDS - do a conversion from RID groups to something.
-
-called to resolve domain RID groups.
-*****************************************************************************/
-/* SAMR_Q_LOOKUP_RIDS */
-typedef struct q_samr_lookup_rids_info
-{
-	POLICY_HND pol;       /* policy handle */
-
-	uint32 num_rids1;      /* number of rids being looked up */
-	uint32 flags;          /* 0x0000 03e8 - unknown */
-	uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
-	uint32 num_rids2;      /* number of rids being looked up */
-
-	uint32 *rid; /* domain RIDs being looked up */
-
-} SAMR_Q_LOOKUP_RIDS;
-
-
-/****************************************************************************
-SAMR_R_LOOKUP_RIDS - do a conversion from group RID to names
-
-*****************************************************************************/
-/* SAMR_R_LOOKUP_RIDS */
-typedef struct r_samr_lookup_rids_info
-{
-	uint32 num_names1;      /* number of aliases being looked up */
-	uint32 ptr_names;       /* pointer to aliases */
-	uint32 num_names2;      /* number of aliases being looked up */
-
-	UNIHDR  *hdr_name; /* unicode account name header */
-	UNISTR2 *uni_name; /* unicode account name string */
-
-	uint32 num_types1;      /* number of users in aliases being looked up */
-	uint32 ptr_types;       /* pointer to users in aliases */
-	uint32 num_types2;      /* number of users in aliases being looked up */
-
-	uint32 *type; /* SID_ENUM type */
-
-	NTSTATUS status;
-
-} SAMR_R_LOOKUP_RIDS;
-
 /* these are from the old rpc_samr.h - they are needed while the merge
    is still going on */
 #define MAX_SAM_SIDS 15
diff --git a/source/rpc_client/cli_samr.c b/source/rpc_client/cli_samr.c
index 2bb837b..a994db9 100644
--- a/source/rpc_client/cli_samr.c
+++ b/source/rpc_client/cli_samr.c
@@ -383,77 +383,3 @@ void get_query_dispinfo_params(int loop_count, uint32 *max_entries,
 		break;
 	}
 }
-
-/* Lookup rids.  Note that NT4 seems to crash if more than ~1000 rids are
-   looked up in one packet. */
-
-NTSTATUS rpccli_samr_lookup_rids(struct rpc_pipe_client *cli,
-				 TALLOC_CTX *mem_ctx, 
-				 POLICY_HND *domain_pol,
-				 uint32 num_rids, uint32 *rids, 
-				 uint32 *num_names, char ***names,
-				 uint32 **name_types)
-{
-	prs_struct qbuf, rbuf;
-	SAMR_Q_LOOKUP_RIDS q;
-	SAMR_R_LOOKUP_RIDS r;
-	NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-	uint32 i;
-
-	DEBUG(10,("cli_samr_lookup_rids\n"));
-
-        if (num_rids > 1000) {
-                DEBUG(2, ("cli_samr_lookup_rids: warning: NT4 can crash if "
-                          "more than ~1000 rids are looked up at once.\n"));
-        }
-
-	ZERO_STRUCT(q);
-	ZERO_STRUCT(r);
-
-	/* Marshall data and send request */
-
-	init_samr_q_lookup_rids(mem_ctx, &q, domain_pol, 1000, num_rids, rids);
-
-	CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_LOOKUP_RIDS,
-		q, r,
-		qbuf, rbuf,
-		samr_io_q_lookup_rids,
-		samr_io_r_lookup_rids,
-		NT_STATUS_UNSUCCESSFUL); 
-
-	/* Return output parameters */
-
-	result = r.status;
-
-	if (!NT_STATUS_IS_OK(result) &&
-	    !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED))
-		goto done;
-
-	if (r.num_names1 == 0) {
-		*num_names = 0;
-		*names = NULL;
-		goto done;
-	}
-
-	*num_names = r.num_names1;
-	*names = TALLOC_ARRAY(mem_ctx, char *, r.num_names1);
-	*name_types = TALLOC_ARRAY(mem_ctx, uint32, r.num_names1);
-
-	if ((*names == NULL) || (*name_types == NULL)) {
-		TALLOC_FREE(*names);
-		TALLOC_FREE(*name_types);
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	for (i = 0; i < r.num_names1; i++) {
-		fstring tmp;
-
-		unistr2_to_ascii(tmp, &r.uni_name[i], sizeof(tmp));
-		(*names)[i] = talloc_strdup(mem_ctx, tmp);
-		(*name_types)[i] = r.type[i];
-	}
-
- done:
-
-	return result;
-}
diff --git a/source/rpc_parse/parse_samr.c b/source/rpc_parse/parse_samr.c
index 298ad69..14b6e2a 100644
--- a/source/rpc_parse/parse_samr.c
+++ b/source/rpc_parse/parse_samr.c
@@ -29,18 +29,6 @@
 #define DBGC_CLASS DBGC_RPC_PARSE
 
 /*******************************************************************
-inits a SAM_ENTRY structure.
-********************************************************************/
-
-void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
-{
-	DEBUG(10, ("init_sam_entry: %d\n", rid));
-
-	sam->rid = rid;
-	init_uni_hdr(&sam->hdr_name, uni2);
-}
-
-/*******************************************************************
 reads or writes a SAM_ENTRY structure.
 ********************************************************************/
 
@@ -331,201 +319,3 @@ bool samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
 
 	return True;
 }
-
-/*******************************************************************
-inits a SAMR_Q_LOOKUP_RIDS structure.
-********************************************************************/
-
-void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
-			     POLICY_HND *pol, uint32 flags,
-			     uint32 num_rids, uint32 *rid)
-{
-	DEBUG(5, ("init_samr_q_lookup_rids\n"));
-
-	q_u->pol = *pol;
-
-	q_u->num_rids1 = num_rids;
-	q_u->flags = flags;
-	q_u->ptr = 0;
-	q_u->num_rids2 = num_rids;
-	if (num_rids) {
-		q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
-	} else {
-		q_u->rid = NULL;
-	}
-	if (q_u->rid == NULL) {
-		q_u->num_rids1 = 0;
-		q_u->num_rids2 = 0;
-	} else {
-		memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
-	}
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
-			   prs_struct *ps, int depth)
-{
-	uint32 i;
-	fstring tmp;
-
-	if (q_u == NULL)
-		return False;
-
-	prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
-	depth++;
-
-	if (UNMARSHALLING(ps))
-		ZERO_STRUCTP(q_u);
-
-	if(!prs_align(ps))
-		return False;
-
-	if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
-		return False;
-
-	if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
-		return False;
-	if(!prs_uint32("flags    ", ps, depth, &q_u->flags))
-		return False;
-	if(!prs_uint32("ptr      ", ps, depth, &q_u->ptr))
-		return False;
-	if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
-		return False;
-
-	if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
-		q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
-		if (q_u->rid == NULL)
-			return False;
-	}
-
-	for (i = 0; i < q_u->num_rids2; i++) {
-		slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]  ", i);
-		if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
-			return False;
-	}
-
-	return True;
-}
-
-/*******************************************************************
-inits a SAMR_R_LOOKUP_RIDS structure.
-********************************************************************/
-
-void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
-			     uint32 num_names, UNIHDR * hdr_name,
-			     UNISTR2 *uni_name, uint32 *type)
-{
-	DEBUG(5, ("init_samr_r_lookup_rids\n"));
-
-	r_u->hdr_name = NULL;
-	r_u->uni_name = NULL;
-	r_u->type = NULL;
-
-	if (num_names != 0) {
-		r_u->num_names1 = num_names;
-		r_u->ptr_names = 1;
-		r_u->num_names2 = num_names;
-
-		r_u->num_types1 = num_names;
-		r_u->ptr_types = 1;
-		r_u->num_types2 = num_names;
-
-		r_u->hdr_name = hdr_name;
-		r_u->uni_name = uni_name;
-		r_u->type = type;
-	} else {
-		r_u->num_names1 = num_names;
-		r_u->ptr_names = 0;
-		r_u->num_names2 = num_names;
-
-		r_u->num_types1 = num_names;
-		r_u->ptr_types = 0;
-		r_u->num_types2 = num_names;
-	}
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
-			   prs_struct *ps, int depth)
-{
-	uint32 i;
-	fstring tmp;
-	if (r_u == NULL)
-		return False;
-
-	prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
-	depth++;
-
-	if(!prs_align(ps))
-		return False;
-
-	if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
-		return False;
-	if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
-		return False;
-
-	if (r_u->ptr_names != 0) {
-
-		if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
-			return False;
-
-
-		if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
-			r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
-			if (r_u->hdr_name == NULL)
-				return False;
-
-			r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
-			if (r_u->uni_name == NULL)
-				return False;
-		}
-		
-		for (i = 0; i < r_u->num_names2; i++) {
-			slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d]  ", i);
-			if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
-				return False;
-		}
-		for (i = 0; i < r_u->num_names2; i++) {
-			slprintf(tmp, sizeof(tmp) - 1, "str[%02d]  ", i);
-			if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
-				return False;
-		}
-
-	}
-	
-	if(!prs_align(ps))
-		return False;
-	if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
-		return False;
-	if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
-		return False;
-
-	if (r_u->ptr_types != 0) {
-
-		if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
-			return False;
-
-		if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
-			r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
-			if (r_u->type == NULL)
-				return False;
-		}
-
-		for (i = 0; i < r_u->num_types2; i++) {
-			slprintf(tmp, sizeof(tmp) - 1, "type[%02d]  ", i);
-			if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
-				return False;
-		}
-	}
-
-	if(!prs_ntstatus("status", ps, depth, &r_u->status))
-		return False;
-
-	return True;
-}
diff --git a/source/winbindd/winbindd_rpc.c b/source/winbindd/winbindd_rpc.c
index 473d2a5..8136175 100644
--- a/source/winbindd/winbindd_rpc.c
+++ b/source/winbindd/winbindd_rpc.c
@@ -693,7 +693,7 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
         uint32 des_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
 	uint32 *rid_mem = NULL;
 	uint32 group_rid;
-	unsigned int j;
+	unsigned int j, r;
 	struct rpc_pipe_client *cli;
 	unsigned int orig_timeout;
 	struct samr_RidTypeArray *rids = NULL;
@@ -772,38 +772,40 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
 	if (*num_names>0 && (!*names || !*name_types))
 		return NT_STATUS_NO_MEMORY;
 
-        for (i = 0; i < *num_names; i += MAX_LOOKUP_RIDS) {
-                int num_lookup_rids = MIN(*num_names - i, MAX_LOOKUP_RIDS);
-                uint32 tmp_num_names = 0;
-                char **tmp_names = NULL;
-                uint32 *tmp_types = NULL;
+	for (i = 0; i < *num_names; i += MAX_LOOKUP_RIDS) {
+		int num_lookup_rids = MIN(*num_names - i, MAX_LOOKUP_RIDS);
+		struct lsa_Strings tmp_names;
+		struct samr_Ids tmp_types;
 
-                /* Lookup a chunk of rids */
+		/* Lookup a chunk of rids */
 
-                result = rpccli_samr_lookup_rids(cli, mem_ctx,
-						 &dom_pol,
-						 num_lookup_rids,
-						 &rid_mem[i],
-						 &tmp_num_names,
-						 &tmp_names, &tmp_types);
+		result = rpccli_samr_LookupRids(cli, mem_ctx,
+						&dom_pol,
+						num_lookup_rids,
+						&rid_mem[i],
+						&tmp_names,
+						&tmp_types);
 
 		/* see if we have a real error (and yes the
 		   STATUS_SOME_UNMAPPED is the one returned from 2k) */
-		
+
                 if (!NT_STATUS_IS_OK(result) &&
 		    !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED))
 			return result;
-			
-                /* Copy result into array.  The talloc system will take
-                   care of freeing the temporary arrays later on. */
 
-                memcpy(&(*names)[i], tmp_names, sizeof(char *) * 
-                       tmp_num_names);
+		/* Copy result into array.  The talloc system will take
+		   care of freeing the temporary arrays later on. */
 
-                memcpy(&(*name_types)[i], tmp_types, sizeof(uint32) *
-                       tmp_num_names);
-		
-                total_names += tmp_num_names;
+		if (tmp_names.count != tmp_types.count) {
+			return NT_STATUS_UNSUCCESSFUL;
+		}
+
+		for (r=0; r<tmp_names.count; r++) {
+			(*names)[i+r] = CONST_DISCARD(char *, tmp_names.names[r].string);
+			(*name_types)[i+r] = tmp_types.ids[r];
+		}
+
+		total_names += tmp_names.count;
         }
 
         *num_names = total_names;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list