svn commit: samba r9567 - in branches/SAMBA_4_0/source: lib/registry librpc/idl rpc_server/winreg torture/rpc

tridge at samba.org tridge at samba.org
Wed Aug 24 08:31:40 GMT 2005


Author: tridge
Date: 2005-08-24 08:31:39 +0000 (Wed, 24 Aug 2005)
New Revision: 9567

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

Log:

fixed the winreg IDL for CreateKey, including a security
descriptor. To keep it simple I just use normal IDL buffers for now,
avoiding the complex methods metze used in spoolss. We might change
that later

Also added decoding of the security_descriptor in
winreg_GetKeySecurity() in smbtorture

Modified:
   branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c
   branches/SAMBA_4_0/source/librpc/idl/winreg.idl
   branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c
   branches/SAMBA_4_0/source/torture/rpc/winreg.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c	2005-08-24 08:28:49 UTC (rev 9566)
+++ branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c	2005-08-24 08:31:39 UTC (rev 9567)
@@ -29,14 +29,7 @@
 
 static void init_winreg_String(struct winreg_String *name, const char *s)
 {
-    name->name = s;
-    if (s) {
-        name->name_len = 2 * (strlen_m(s) + 1);
-        name->name_size = name->name_len;
-    } else {
-        name->name_len = 0;
-        name->name_size = 0;
-    }
+	name->name = s;
 }
 
 
@@ -255,14 +248,14 @@
 	NTSTATUS status;
 	struct winreg_CreateKey r;
 
-	init_winreg_String(&r.in.key, name);
+	init_winreg_String(&r.in.name, name);
 	init_winreg_String(&r.in.class, NULL);
 
 	r.in.handle = parent->backend_data;
-	r.out.handle = talloc(mem_ctx, struct policy_handle);	
+	r.out.new_handle = talloc(mem_ctx, struct policy_handle);	
 	r.in.options = 0;
-	r.in.access_mask = access_mask;
-	r.in.sec_desc = NULL;
+	r.in.access_required = access_mask;
+	r.in.secdesc = NULL;
 
 	status = dcerpc_winreg_CreateKey((struct dcerpc_pipe *)(parent->hive->backend_data), mem_ctx, &r);
 
@@ -274,7 +267,7 @@
 	if (W_ERROR_IS_OK(r.out.result)) {
 		*key = talloc(mem_ctx, struct registry_key);
 		(*key)->name = talloc_strdup(*key, name);
-		(*key)->backend_data = r.out.handle;
+		(*key)->backend_data = r.out.new_handle;
 	}
 
 	return r.out.result;

Modified: branches/SAMBA_4_0/source/librpc/idl/winreg.idl
===================================================================
--- branches/SAMBA_4_0/source/librpc/idl/winreg.idl	2005-08-24 08:28:49 UTC (rev 9566)
+++ branches/SAMBA_4_0/source/librpc/idl/winreg.idl	2005-08-24 08:31:39 UTC (rev 9567)
@@ -83,14 +83,28 @@
 
 	/******************/
 	/* Function: 0x06 */
+
+	typedef struct {
+		[size_is(size),length_is(len)] uint8 *data;
+		uint32 size;
+		uint32 len;
+	} KeySecurityData;
+
+	typedef struct {
+		uint32 length;
+		KeySecurityData sd;
+		bool8  inherit;
+	} winreg_SecBuf;
+
 	WERROR winreg_CreateKey(
-		[in,out,ref] policy_handle *handle,
-		[in] winreg_String key,
+		[in,ref] policy_handle *handle,
+		[in] winreg_String name,
 		[in] winreg_String class,
 		[in] uint32 options,
-		[in] uint32 access_mask,
-		[in,out,ref] uint32 *action_taken,
-		[in] sec_desc_buf *sec_desc
+		[in] uint32 access_required,
+		[in,unique] winreg_SecBuf *secdesc,
+		[out,ref] policy_handle *new_handle,
+		[in,out,unique] uint32 *action_taken
 	);
 
 	/******************/
@@ -143,18 +157,12 @@
 		[in,ref] policy_handle *handle
 	);
 
-	typedef struct {
-		[size_is(size),length_is(len)] uint8 *data;
-		uint32 size;
-		uint32 len;
-	} KeySecurityData;
-
 	/******************/
 	/* Function: 0x0c */
 	WERROR winreg_GetKeySecurity(
 		[in,ref] policy_handle *handle,
 		[in] uint32 access_mask,
-		[in,out,ref] KeySecurityData *data
+		[in,out,ref] KeySecurityData *sd
 	);
 
 	/******************/

Modified: branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c	2005-08-24 08:28:49 UTC (rev 9566)
+++ branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c	2005-08-24 08:31:39 UTC (rev 9567)
@@ -99,17 +99,34 @@
 {
 	struct dcesrv_handle *h, *newh;
 	WERROR error;
+	struct security_descriptor sd;
 
 	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
 	
 	newh = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY);
 
-	error = reg_key_add_name(newh, (struct registry_key *)h->data, r->in.key.name, 
-				 r->in.access_mask, 
-				 r->in.sec_desc?r->in.sec_desc->sd:NULL, 
+	/* the security descriptor is optional */
+	if (r->in.secdesc != NULL) {
+		DATA_BLOB sdblob;
+		NTSTATUS status;
+		sdblob.data = r->in.secdesc->sd.data;
+		sdblob.length = r->in.secdesc->sd.len;
+		if (sdblob.data == NULL) {
+			return WERR_INVALID_PARAM;
+		}
+		status = ndr_pull_struct_blob_all(&sdblob, mem_ctx, &sd, 
+						  (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
+		if (!NT_STATUS_IS_OK(status)) {
+			return WERR_INVALID_PARAM;
+		}
+	}
+
+	error = reg_key_add_name(newh, (struct registry_key *)h->data, r->in.name.name, 
+				 r->in.access_required, 
+				 r->in.secdesc?&sd:NULL, 
 				 (struct registry_key **)&newh->data);
 	if (W_ERROR_IS_OK(error)) {
-		r->out.handle = &newh->wire_handle;
+		r->out.new_handle = &newh->wire_handle;
 	} else {
 		talloc_free(newh);
 	}

Modified: branches/SAMBA_4_0/source/torture/rpc/winreg.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/winreg.c	2005-08-24 08:28:49 UTC (rev 9566)
+++ branches/SAMBA_4_0/source/torture/rpc/winreg.c	2005-08-24 08:31:39 UTC (rev 9567)
@@ -108,13 +108,13 @@
 	printf("\ntesting CreateKey\n");
 
 	r.in.handle = handle;
-	r.out.handle = &newhandle;
-	init_winreg_String(&r.in.key, name);	
+	r.out.new_handle = &newhandle;
+	init_winreg_String(&r.in.name, name);	
 	init_winreg_String(&r.in.class, class);
 	r.in.options = 0x0;
-	r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+	r.in.access_required = SEC_FLAG_MAXIMUM_ALLOWED;
 	r.in.action_taken = r.out.action_taken = &action_taken;
-	r.in.sec_desc = NULL;
+	r.in.secdesc = NULL;
 
 	status = dcerpc_winreg_CreateKey(p, mem_ctx, &r);
 
@@ -136,14 +136,16 @@
 {
 	NTSTATUS status;
 	struct winreg_GetKeySecurity r;
+	struct security_descriptor sd;
+	DATA_BLOB sdblob;
 
 	printf("\ntesting GetKeySecurity\n");
 
 	ZERO_STRUCT(r);
 
 	r.in.handle = handle;
-	r.in.data = r.out.data =  talloc_zero(mem_ctx, struct KeySecurityData);
-	r.in.data->size = 0xffff;
+	r.in.sd = r.out.sd = talloc_zero(mem_ctx, struct KeySecurityData);
+	r.in.sd->size = 0xffff;
 	r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
 
 	status = dcerpc_winreg_GetKeySecurity(p, mem_ctx, &r);
@@ -158,7 +160,20 @@
 		return False;
 	}
 
-	return False;
+	sdblob.data = r.out.sd->data;
+	sdblob.length = r.out.sd->len;
+
+	status = ndr_pull_struct_blob_all(&sdblob, mem_ctx, &sd, 
+					  (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("pull_security_descriptor failed - %s\n", nt_errstr(status));
+		return False;
+	}
+	if (p->conn->flags & DCERPC_DEBUG_PRINT_OUT) {
+		NDR_PRINT_DEBUG(security_descriptor, &sd);
+	}
+
+	return True;
 }
 
 static BOOL test_CloseKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 



More information about the samba-cvs mailing list