svn commit: samba r25247 - in branches: SAMBA_3_2/source/rpc_client SAMBA_3_2/source/winbindd SAMBA_3_2_0/source/rpc_client SAMBA_3_2_0/source/winbindd

obnox at samba.org obnox at samba.org
Wed Sep 19 22:11:12 GMT 2007


Author: obnox
Date: 2007-09-19 22:11:09 +0000 (Wed, 19 Sep 2007)
New Revision: 25247

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25247

Log:
Rename the rpccli_lsa_lookup_sids_all() function to rpccli_lsa_lookup_sids()
and remove the old rpccli_lsa_lookup_sids() function. The old function would
fail due to server limits when requesting to resolve too many sids at once
(20480 for W2k3). The new version passes the list of sids in hunks to the
server. It has up to now been used (and tested) in the winbindd_ads
lookup_groupmem() function, and I think the time has come to replace the actual
function with this correct version.

Michael


Modified:
   branches/SAMBA_3_2/source/rpc_client/cli_lsarpc.c
   branches/SAMBA_3_2/source/winbindd/winbindd_ads.c
   branches/SAMBA_3_2_0/source/rpc_client/cli_lsarpc.c
   branches/SAMBA_3_2_0/source/winbindd/winbindd_ads.c


Changeset:
Modified: branches/SAMBA_3_2/source/rpc_client/cli_lsarpc.c
===================================================================
--- branches/SAMBA_3_2/source/rpc_client/cli_lsarpc.c	2007-09-19 20:54:13 UTC (rev 25246)
+++ branches/SAMBA_3_2/source/rpc_client/cli_lsarpc.c	2007-09-19 22:11:09 UTC (rev 25247)
@@ -244,14 +244,14 @@
  * at 20480 for win2k3, but we keep it at a save 1000 for now. */
 #define LOOKUP_SIDS_HUNK_SIZE 1000
 
-NTSTATUS rpccli_lsa_lookup_sids_all(struct rpc_pipe_client *cli,
-				    TALLOC_CTX *mem_ctx,
-				    POLICY_HND *pol,
-				    int num_sids,
-				    const DOM_SID *sids,
-				    char ***domains,
-				    char ***names,
-				    enum lsa_SidType **types)
+NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
+				TALLOC_CTX *mem_ctx,
+				POLICY_HND *pol,
+				int num_sids,
+				const DOM_SID *sids,
+				char ***domains,
+				char ***names,
+				enum lsa_SidType **types)
 {
 	NTSTATUS result = NT_STATUS_OK;
 	int sids_left = 0;
@@ -263,19 +263,19 @@
 
 	if (num_sids) {
 		if (!((*domains) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
-			DEBUG(0, ("rpccli_lsa_lookup_sids_all(): out of memory\n"));
+			DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
 			result = NT_STATUS_NO_MEMORY;
 			goto fail;
 		}
 
 		if (!((*names) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
-			DEBUG(0, ("rpccli_lsa_lookup_sids_all(): out of memory\n"));
+			DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
 			result = NT_STATUS_NO_MEMORY;
 			goto fail;
 		}
 
 		if (!((*types) = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_sids))) {
-			DEBUG(0, ("rpccli_lsa_lookup_sids_all(): out of memory\n"));
+			DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
 			result = NT_STATUS_NO_MEMORY;
 			goto fail;
 		}
@@ -298,7 +298,7 @@
 				? LOOKUP_SIDS_HUNK_SIZE
 				: sids_left);
 
-		DEBUG(10, ("rpccli_lsa_lookup_sids_all: processing items "
+		DEBUG(10, ("rpccli_lsa_lookup_sids: processing items "
 			   "%d -- %d of %d.\n",
 			   sids_processed,
 			   sids_processed + hunk_num_sids - 1,
@@ -349,114 +349,6 @@
 	return result;
 }
 
-/** Lookup a list of sids */
-
-NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
-				TALLOC_CTX *mem_ctx,
-				POLICY_HND *pol, int num_sids,
-				const DOM_SID *sids,
-				char ***domains,
-				char ***names,
-				enum lsa_SidType **types)
-{
-	prs_struct qbuf, rbuf;
-	LSA_Q_LOOKUP_SIDS q;
-	LSA_R_LOOKUP_SIDS r;
-	DOM_R_REF ref;
-	NTSTATUS result = NT_STATUS_OK;
-	int i;
-
-	ZERO_STRUCT(q);
-	ZERO_STRUCT(r);
-
-	init_q_lookup_sids(mem_ctx, &q, pol, num_sids, sids, 1);
-
-	ZERO_STRUCT(ref);
-
-	r.dom_ref = &ref;
-
-	CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_LOOKUPSIDS,
-			q, r,
-			qbuf, rbuf,
-			lsa_io_q_lookup_sids,
-			lsa_io_r_lookup_sids,
-			NT_STATUS_UNSUCCESSFUL );
-
-	if (!NT_STATUS_IS_OK(r.status) &&
-	    !NT_STATUS_EQUAL(r.status, STATUS_SOME_UNMAPPED)) {
-
-		/* An actual error occured */
-		result = r.status;
-
-		goto done;
-	}
-
-	/* Return output parameters */
-
-	if (r.mapped_count == 0) {
-		result = NT_STATUS_NONE_MAPPED;
-		goto done;
-	}
-
-	if (num_sids) {
-		if (!((*domains) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
-			DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
-			result = NT_STATUS_NO_MEMORY;
-			goto done;
-		}
-
-		if (!((*names) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
-			DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
-			result = NT_STATUS_NO_MEMORY;
-			goto done;
-		}
-
-		if (!((*types) = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_sids))) {
-			DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
-			result = NT_STATUS_NO_MEMORY;
-			goto done;
-		}
-	} else {
-		(*domains) = NULL;
-		(*names) = NULL;
-		(*types) = NULL;
-	}
-
-	for (i = 0; i < num_sids; i++) {
-		fstring name, dom_name;
-		uint32 dom_idx = r.names.name[i].domain_idx;
-
-		/* Translate optimised name through domain index array */
-
-		if (dom_idx != 0xffffffff) {
-
-			rpcstr_pull_unistr2_fstring(
-                                dom_name, &ref.ref_dom[dom_idx].uni_dom_name);
-			rpcstr_pull_unistr2_fstring(
-                                name, &r.names.uni_name[i]);
-
-			(*names)[i] = talloc_strdup(mem_ctx, name);
-			(*domains)[i] = talloc_strdup(mem_ctx, dom_name);
-			(*types)[i] = (enum lsa_SidType)r.names.name[i].sid_name_use;
-
-			if (((*names)[i] == NULL) || ((*domains)[i] == NULL)) {
-				DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
-				result = NT_STATUS_UNSUCCESSFUL;
-				goto done;
-			}
-
-		} else {
-			(*names)[i] = NULL;
-			(*domains)[i] = NULL;
-			(*types)[i] = SID_NAME_UNKNOWN;
-		}
-	}
-
- done:
-
-	return result;
-}
-
 /** Lookup a list of names */
 
 NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,

Modified: branches/SAMBA_3_2/source/winbindd/winbindd_ads.c
===================================================================
--- branches/SAMBA_3_2/source/winbindd/winbindd_ads.c	2007-09-19 20:54:13 UTC (rev 25246)
+++ branches/SAMBA_3_2/source/winbindd/winbindd_ads.c	2007-09-19 22:11:09 UTC (rev 25247)
@@ -1049,13 +1049,13 @@
 			goto done;
 		}
 
-		status = rpccli_lsa_lookup_sids_all(cli, tmp_ctx, 
-						    &lsa_policy,
-						    num_nocache, 
-						    sid_mem_nocache, 
-						    &domains_nocache, 
-						    &names_nocache, 
-						    &name_types_nocache);
+		status = rpccli_lsa_lookup_sids(cli, tmp_ctx, 
+						&lsa_policy,
+						num_nocache, 
+						sid_mem_nocache, 
+						&domains_nocache, 
+						&names_nocache, 
+						&name_types_nocache);
 
 		if (NT_STATUS_IS_OK(status) ||
 		    NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) 

Modified: branches/SAMBA_3_2_0/source/rpc_client/cli_lsarpc.c
===================================================================
--- branches/SAMBA_3_2_0/source/rpc_client/cli_lsarpc.c	2007-09-19 20:54:13 UTC (rev 25246)
+++ branches/SAMBA_3_2_0/source/rpc_client/cli_lsarpc.c	2007-09-19 22:11:09 UTC (rev 25247)
@@ -215,7 +215,7 @@
 			(types)[i] = r.names.name[i].sid_name_use;
 
 			if (((names)[i] == NULL) || ((domains)[i] == NULL)) {
-				DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
+				DEBUG(0, ("cli_lsa_lookup_sids_noalloc(): out of memory\n"));
 				result = NT_STATUS_UNSUCCESSFUL;
 				goto done;
 			}
@@ -244,14 +244,14 @@
  * at 20480 for win2k3, but we keep it at a save 1000 for now. */
 #define LOOKUP_SIDS_HUNK_SIZE 1000
 
-NTSTATUS rpccli_lsa_lookup_sids_all(struct rpc_pipe_client *cli,
-				    TALLOC_CTX *mem_ctx,
-				    POLICY_HND *pol,
-				    int num_sids,
-				    const DOM_SID *sids,
-				    char ***domains,
-				    char ***names,
-				    uint32 **types)
+NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
+				TALLOC_CTX *mem_ctx,
+				POLICY_HND *pol,
+				int num_sids,
+				const DOM_SID *sids,
+				char ***domains,
+				char ***names,
+				uint32 **types)
 {
 	NTSTATUS result = NT_STATUS_OK;
 	int sids_left = 0;
@@ -263,19 +263,19 @@
 
 	if (num_sids) {
 		if (!((*domains) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
-			DEBUG(0, ("rpccli_lsa_lookup_sids_all(): out of memory\n"));
+			DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
 			result = NT_STATUS_NO_MEMORY;
 			goto fail;
 		}
 
 		if (!((*names) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
-			DEBUG(0, ("rpccli_lsa_lookup_sids_all(): out of memory\n"));
+			DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
 			result = NT_STATUS_NO_MEMORY;
 			goto fail;
 		}
 
 		if (!((*types) = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_sids))) {
-			DEBUG(0, ("rpccli_lsa_lookup_sids_all(): out of memory\n"));
+			DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
 			result = NT_STATUS_NO_MEMORY;
 			goto fail;
 		}
@@ -298,7 +298,7 @@
 				? LOOKUP_SIDS_HUNK_SIZE
 				: sids_left);
 
-		DEBUG(10, ("rpccli_lsa_lookup_sids_all: processing items "
+		DEBUG(10, ("rpccli_lsa_lookup_sids: processing items "
 			   "%d -- %d of %d.\n",
 			   sids_processed,
 			   sids_processed + hunk_num_sids - 1,
@@ -349,112 +349,6 @@
 	return result;
 }
 
-/** Lookup a list of sids */
-
-NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
-				TALLOC_CTX *mem_ctx,
-				POLICY_HND *pol, int num_sids,
-				const DOM_SID *sids,
-				char ***domains, char ***names, uint32 **types)
-{
-	prs_struct qbuf, rbuf;
-	LSA_Q_LOOKUP_SIDS q;
-	LSA_R_LOOKUP_SIDS r;
-	DOM_R_REF ref;
-	NTSTATUS result = NT_STATUS_OK;
-	int i;
-
-	ZERO_STRUCT(q);
-	ZERO_STRUCT(r);
-
-	init_q_lookup_sids(mem_ctx, &q, pol, num_sids, sids, 1);
-
-	ZERO_STRUCT(ref);
-
-	r.dom_ref = &ref;
-
-	CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_LOOKUPSIDS,
-			q, r,
-			qbuf, rbuf,
-			lsa_io_q_lookup_sids,
-			lsa_io_r_lookup_sids,
-			NT_STATUS_UNSUCCESSFUL );
-
-	if (!NT_STATUS_IS_OK(r.status) &&
-	    NT_STATUS_V(r.status) != NT_STATUS_V(STATUS_SOME_UNMAPPED)) {
-
-		/* An actual error occured */
-		result = r.status;
-
-		goto done;
-	}
-
-	/* Return output parameters */
-
-	if (r.mapped_count == 0) {
-		result = NT_STATUS_NONE_MAPPED;
-		goto done;
-	}
-
-	if (num_sids) {
-		if (!((*domains) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
-			DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
-			result = NT_STATUS_NO_MEMORY;
-			goto done;
-		}
-
-		if (!((*names) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
-			DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
-			result = NT_STATUS_NO_MEMORY;
-			goto done;
-		}
-
-		if (!((*types) = TALLOC_ARRAY(mem_ctx, uint32, num_sids))) {
-			DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
-			result = NT_STATUS_NO_MEMORY;
-			goto done;
-		}
-	} else {
-		(*domains) = NULL;
-		(*names) = NULL;
-		(*types) = NULL;
-	}
-
-	for (i = 0; i < num_sids; i++) {
-		fstring name, dom_name;
-		uint32 dom_idx = r.names.name[i].domain_idx;
-
-		/* Translate optimised name through domain index array */
-
-		if (dom_idx != 0xffffffff) {
-
-			rpcstr_pull_unistr2_fstring(
-                                dom_name, &ref.ref_dom[dom_idx].uni_dom_name);
-			rpcstr_pull_unistr2_fstring(
-                                name, &r.names.uni_name[i]);
-
-			(*names)[i] = talloc_strdup(mem_ctx, name);
-			(*domains)[i] = talloc_strdup(mem_ctx, dom_name);
-			(*types)[i] = r.names.name[i].sid_name_use;
-
-			if (((*names)[i] == NULL) || ((*domains)[i] == NULL)) {
-				DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
-				result = NT_STATUS_UNSUCCESSFUL;
-				goto done;
-			}
-
-		} else {
-			(*names)[i] = NULL;
-			(*domains)[i] = NULL;
-			(*types)[i] = SID_NAME_UNKNOWN;
-		}
-	}
-
- done:
-
-	return result;
-}
-
 /** Lookup a list of names */
 
 NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,

Modified: branches/SAMBA_3_2_0/source/winbindd/winbindd_ads.c
===================================================================
--- branches/SAMBA_3_2_0/source/winbindd/winbindd_ads.c	2007-09-19 20:54:13 UTC (rev 25246)
+++ branches/SAMBA_3_2_0/source/winbindd/winbindd_ads.c	2007-09-19 22:11:09 UTC (rev 25247)
@@ -1049,13 +1049,13 @@
 			goto done;
 		}
 
-		status = rpccli_lsa_lookup_sids_all(cli, tmp_ctx, 
-						    &lsa_policy,
-						    num_nocache, 
-						    sid_mem_nocache, 
-						    &domains_nocache, 
-						    &names_nocache, 
-						    &name_types_nocache);
+		status = rpccli_lsa_lookup_sids(cli, tmp_ctx, 
+						&lsa_policy,
+						num_nocache, 
+						sid_mem_nocache, 
+						&domains_nocache, 
+						&names_nocache, 
+						&name_types_nocache);
 
 		if (NT_STATUS_IS_OK(status) ||
 		    NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) 



More information about the samba-cvs mailing list