[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-3328-gdc0f737

Günther Deschner gd at samba.org
Fri Jul 18 15:24:12 GMT 2008


The branch, v3-3-test has been updated
       via  dc0f737bd5e86369b2bbfbef420a095205c2d3cb (commit)
       via  401d6ce210817d9ab6915ed838e1495ae220559a (commit)
      from  5000d4c743b09665405776569782f46eeb6c2e36 (commit)

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


- Log -----------------------------------------------------------------
commit dc0f737bd5e86369b2bbfbef420a095205c2d3cb
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jul 18 15:10:43 2008 +0200

    netapi: make map_alias_info_to_buffer suitable for arrays in the buffer.
    
    Guenther

commit 401d6ce210817d9ab6915ed838e1495ae220559a
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jul 18 15:01:21 2008 +0200

    netapi: add libnetapi_samr_open_alias_queryinfo.
    
    Guenther

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

Summary of changes:
 source/lib/netapi/localgroup.c |   75 ++++++++++++++++++++++++++++++++++------
 1 files changed, 64 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/netapi/localgroup.c b/source/lib/netapi/localgroup.c
index d3a9aa1..d91045b 100644
--- a/source/lib/netapi/localgroup.c
+++ b/source/lib/netapi/localgroup.c
@@ -73,6 +73,50 @@ static WERROR libnetapi_samr_lookup_and_open_alias(TALLOC_CTX *mem_ctx,
 /****************************************************************
 ****************************************************************/
 
+static NTSTATUS libnetapi_samr_open_alias_queryinfo(TALLOC_CTX *mem_ctx,
+						    struct rpc_pipe_client *pipe_cli,
+						    struct policy_handle *handle,
+						    uint32_t rid,
+						    uint32_t access_rights,
+						    enum samr_AliasInfoEnum level,
+						    union samr_AliasInfo **alias_info)
+{
+	NTSTATUS status;
+	struct policy_handle alias_handle;
+	union samr_AliasInfo *_alias_info = NULL;
+
+	ZERO_STRUCT(alias_handle);
+
+	status = rpccli_samr_OpenAlias(pipe_cli, mem_ctx,
+				       handle,
+				       access_rights,
+				       rid,
+				       &alias_handle);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto done;
+	}
+
+	status = rpccli_samr_QueryAliasInfo(pipe_cli, mem_ctx,
+					    &alias_handle,
+					    level,
+					    &_alias_info);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto done;
+	}
+
+	*alias_info = _alias_info;
+
+ done:
+	if (is_valid_policy_hnd(&alias_handle)) {
+		rpccli_samr_Close(pipe_cli, mem_ctx, &alias_handle);
+	}
+
+	return status;
+}
+
+/****************************************************************
+****************************************************************/
+
 WERROR NetLocalGroupAdd_r(struct libnetapi_ctx *ctx,
 			  struct NetLocalGroupAdd *r)
 {
@@ -349,8 +393,10 @@ WERROR NetLocalGroupDel_l(struct libnetapi_ctx *ctx,
 ****************************************************************/
 
 static WERROR map_alias_info_to_buffer(TALLOC_CTX *mem_ctx,
+				       const char *alias_name,
 				       struct samr_AliasInfoAll *info,
 				       uint32_t level,
+				       uint32_t *entries_read,
 				       uint8_t **buffer)
 {
 	struct LOCALGROUP_INFO_0 g0;
@@ -359,30 +405,33 @@ static WERROR map_alias_info_to_buffer(TALLOC_CTX *mem_ctx,
 
 	switch (level) {
 		case 0:
-			g0.lgrpi0_name		= info->name.string;
+			g0.lgrpi0_name		= talloc_strdup(mem_ctx, alias_name);
+			W_ERROR_HAVE_NO_MEMORY(g0.lgrpi0_name);
 
-			*buffer = (uint8_t *)talloc_memdup(mem_ctx, &g0, sizeof(g0));
+			ADD_TO_ARRAY(mem_ctx, struct LOCALGROUP_INFO_0, g0,
+				     (struct LOCALGROUP_INFO_0 **)buffer, entries_read);
 
 			break;
 		case 1:
-			g1.lgrpi1_name		= info->name.string;
-			g1.lgrpi1_comment	= info->description.string;
+			g1.lgrpi1_name		= talloc_strdup(mem_ctx, alias_name);
+			g1.lgrpi1_comment	= talloc_strdup(mem_ctx, info->description.string);
+			W_ERROR_HAVE_NO_MEMORY(g1.lgrpi1_name);
 
-			*buffer = (uint8_t *)talloc_memdup(mem_ctx, &g1, sizeof(g1));
+			ADD_TO_ARRAY(mem_ctx, struct LOCALGROUP_INFO_1, g1,
+				     (struct LOCALGROUP_INFO_1 **)buffer, entries_read);
 
 			break;
 		case 1002:
-			g1002.lgrpi1002_comment	= info->description.string;
+			g1002.lgrpi1002_comment	= talloc_strdup(mem_ctx, info->description.string);
 
-			*buffer = (uint8_t *)talloc_memdup(mem_ctx, &g1002, sizeof(g1002));
+			ADD_TO_ARRAY(mem_ctx, struct LOCALGROUP_INFO_1002, g1002,
+				     (struct LOCALGROUP_INFO_1002 **)buffer, entries_read);
 
 			break;
 		default:
 			return WERR_UNKNOWN_LEVEL;
 	}
 
-	W_ERROR_HAVE_NO_MEMORY(*buffer);
-
 	return WERR_OK;
 }
 
@@ -400,6 +449,7 @@ WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx,
 	struct policy_handle connect_handle, domain_handle, builtin_handle, alias_handle;
 	struct dom_sid2 *domain_sid = NULL;
 	union samr_AliasInfo *alias_info = NULL;
+	uint32_t entries_read = 0;
 
 	if (!r->in.group_name) {
 		return WERR_INVALID_PARAM;
@@ -487,8 +537,11 @@ WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx,
 		goto done;
 	}
 
-	werr = map_alias_info_to_buffer(ctx, &alias_info->all,
-					r->in.level, r->out.buf);
+	werr = map_alias_info_to_buffer(ctx,
+					r->in.group_name,
+					&alias_info->all,
+					r->in.level, &entries_read,
+					r->out.buf);
 
  done:
 	if (!cli) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list