[SCM] Samba Shared Repository - branch master updated - f9d691d9d808ec2f91f3f469fe2201b0909a8552

Günther Deschner gd at samba.org
Wed Nov 19 22:27:44 GMT 2008


The branch, master has been updated
       via  f9d691d9d808ec2f91f3f469fe2201b0909a8552 (commit)
       via  12fdb5eb4628db08a665791fb76d15e9f5894478 (commit)
       via  9b40d26e30518c666e4dad9cf55ec319cf19e28e (commit)
      from  07b3a1e988deae2e2d8d619fb2792dd0a719504f (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f9d691d9d808ec2f91f3f469fe2201b0909a8552
Author: Günther Deschner <gd at samba.org>
Date:   Tue Nov 11 12:49:20 2008 +0100

    s3-ntsvcs: remove old hand-marshalling for ntsvcs getdevregprop.
    
    Guenther

commit 12fdb5eb4628db08a665791fb76d15e9f5894478
Author: Günther Deschner <gd at samba.org>
Date:   Tue Nov 11 11:21:45 2008 +0100

    s3-ntsvcs: use pidl for _PNP_GetDeviceRegProp.
    
    Guenther

commit 9b40d26e30518c666e4dad9cf55ec319cf19e28e
Author: Günther Deschner <gd at samba.org>
Date:   Wed Nov 19 23:02:49 2008 +0100

    s3-rpcclient: fix cmd_ntsvcs_get_dev_reg_prop.
    
    Guenther

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

Summary of changes:
 source3/include/proto.h            |    7 ----
 source3/include/rpc_ntsvcs.h       |   19 ----------
 source3/rpc_client/cli_reg.c       |   17 ---------
 source3/rpc_parse/parse_misc.c     |   54 ----------------------------
 source3/rpc_parse/parse_ntsvcs.c   |   68 ------------------------------------
 source3/rpc_parse/parse_prs.c      |   33 -----------------
 source3/rpc_server/srv_ntsvcs.c    |   18 +---------
 source3/rpc_server/srv_ntsvcs_nt.c |   43 +++++++++++-----------
 source3/rpcclient/cmd_ntsvcs.c     |    9 +++--
 9 files changed, 29 insertions(+), 239 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index 45f6620..dd4b9d1 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -5296,7 +5296,6 @@ NTSTATUS cli_get_session_key(TALLOC_CTX *mem_ctx,
 NTSTATUS rpccli_winreg_Connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
                          uint32 reg_type, uint32 access_mask,
                          POLICY_HND *reg_hnd);
-uint32 reg_init_regval_buffer( REGVAL_BUFFER *buf2, REGISTRY_VALUE *val );
 
 /* The following definitions come from rpc_client/cli_samr.c  */
 
@@ -5910,8 +5909,6 @@ void init_rpc_blob_str(RPC_DATA_BLOB *str, const char *buf, int len);
 void init_rpc_blob_hex(RPC_DATA_BLOB *str, const char *buf);
 void init_rpc_blob_bytes(RPC_DATA_BLOB *str, uint8 *buf, size_t len);
 bool smb_io_buffer5(const char *desc, BUFFER5 *buf5, prs_struct *ps, int depth);
-void init_regval_buffer(REGVAL_BUFFER *str, const uint8 *buf, size_t len);
-bool smb_io_regval_buffer(const char *desc, prs_struct *ps, int depth, REGVAL_BUFFER *buf2);
 void init_buf_unistr2(UNISTR2 *str, uint32 *ptr, const char *buf);
 void copy_unistr2(UNISTR2 *str, const UNISTR2 *from);
 void init_string2(STRING2 *str, const char *buf, size_t max_len, size_t str_len);
@@ -5974,8 +5971,6 @@ bool policy_handle_is_valid(const POLICY_HND *hnd);
 
 bool ntsvcs_io_q_get_device_list(const char *desc, NTSVCS_Q_GET_DEVICE_LIST *q_u, prs_struct *ps, int depth);
 bool ntsvcs_io_r_get_device_list(const char *desc, NTSVCS_R_GET_DEVICE_LIST *r_u, prs_struct *ps, int depth);
-bool ntsvcs_io_q_get_device_reg_property(const char *desc, NTSVCS_Q_GET_DEVICE_REG_PROPERTY *q_u, prs_struct *ps, int depth);
-bool ntsvcs_io_r_get_device_reg_property(const char *desc, NTSVCS_R_GET_DEVICE_REG_PROPERTY *r_u, prs_struct *ps, int depth);
 
 /* The following definitions come from rpc_parse/parse_prs.c  */
 
@@ -6031,7 +6026,6 @@ bool prs_uint16s(bool charmode, const char *name, prs_struct *ps, int depth, uin
 bool prs_uint16uni(bool charmode, const char *name, prs_struct *ps, int depth, uint16 *data16s, int len);
 bool prs_uint32s(bool charmode, const char *name, prs_struct *ps, int depth, uint32 *data32s, int len);
 bool prs_buffer5(bool charmode, const char *name, prs_struct *ps, int depth, BUFFER5 *str);
-bool prs_regval_buffer(bool charmode, const char *name, prs_struct *ps, int depth, REGVAL_BUFFER *buf);
 bool prs_string2(bool charmode, const char *name, prs_struct *ps, int depth, STRING2 *str);
 bool prs_unistr2(bool charmode, const char *name, prs_struct *ps, int depth, UNISTR2 *str);
 bool prs_unistr3(bool charmode, const char *name, UNISTR3 *str, prs_struct *ps, int depth);
@@ -6824,7 +6818,6 @@ WERROR _PNP_GetVersion(pipes_struct *p,
 WERROR _PNP_GetDeviceListSize(pipes_struct *p,
 			      struct PNP_GetDeviceListSize *r);
 WERROR _ntsvcs_get_device_list( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST *q_u, NTSVCS_R_GET_DEVICE_LIST *r_u );
-WERROR _ntsvcs_get_device_reg_property( pipes_struct *p, NTSVCS_Q_GET_DEVICE_REG_PROPERTY *q_u, NTSVCS_R_GET_DEVICE_REG_PROPERTY *r_u );
 WERROR _PNP_ValidateDeviceInstance(pipes_struct *p,
 				   struct PNP_ValidateDeviceInstance *r);
 WERROR _PNP_GetHwProfInfo(pipes_struct *p,
diff --git a/source3/include/rpc_ntsvcs.h b/source3/include/rpc_ntsvcs.h
index 0056d16..dc74298 100644
--- a/source3/include/rpc_ntsvcs.h
+++ b/source3/include/rpc_ntsvcs.h
@@ -47,23 +47,4 @@ typedef struct {
 	WERROR status;
 } NTSVCS_R_GET_DEVICE_LIST;
 
-/**************************/
-
-typedef struct {
-	UNISTR2 devicepath;
-	uint32 property;
-	uint32 unknown2;
-	uint32 buffer_size1;
-	uint32 buffer_size2;
-	uint32 unknown5;
-} NTSVCS_Q_GET_DEVICE_REG_PROPERTY;
-
-typedef struct {
-	uint32 unknown1;
-	REGVAL_BUFFER value;
-	uint32 size;
-	uint32 needed;
-	WERROR status;
-} NTSVCS_R_GET_DEVICE_REG_PROPERTY;
-
 #endif /* _RPC_NTSVCS_H */
diff --git a/source3/rpc_client/cli_reg.c b/source3/rpc_client/cli_reg.c
index ba98e25..2ed7119 100644
--- a/source3/rpc_client/cli_reg.c
+++ b/source3/rpc_client/cli_reg.c
@@ -60,20 +60,3 @@ NTSTATUS rpccli_winreg_Connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
 
 	return NT_STATUS_INVALID_PARAMETER;
 }
-
-/*******************************************************************
- Fill in a REGVAL_BUFFER for the data given a REGISTRY_VALUE
- *******************************************************************/
-
-uint32 reg_init_regval_buffer( REGVAL_BUFFER *buf2, REGISTRY_VALUE *val )
-{
-	uint32		real_size = 0;
-	
-	if ( !buf2 || !val )
-		return 0;
-		
-	real_size = regval_size(val);
-	init_regval_buffer( buf2, (unsigned char*)regval_data_p(val), real_size );
-
-	return real_size;
-}
diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c
index cf989c8..169e5cb 100644
--- a/source3/rpc_parse/parse_misc.c
+++ b/source3/rpc_parse/parse_misc.c
@@ -558,60 +558,6 @@ bool smb_io_buffer5(const char *desc, BUFFER5 *buf5, prs_struct *ps, int depth)
 }
 
 /*******************************************************************
- Inits a REGVAL_BUFFER structure.
-********************************************************************/
-
-void init_regval_buffer(REGVAL_BUFFER *str, const uint8 *buf, size_t len)
-{
-	ZERO_STRUCTP(str);
-
-	/* max buffer size (allocated size) */
-	str->buf_max_len = len;
-	str->offset = 0;
-	str->buf_len = buf != NULL ? len : 0;
-
-	if (buf != NULL) {
-		SMB_ASSERT(str->buf_max_len >= str->buf_len);
-		str->buffer = (uint16 *)TALLOC_ZERO(talloc_tos(),
-						    str->buf_max_len);
-		if (str->buffer == NULL)
-			smb_panic("init_regval_buffer: talloc fail");
-		memcpy(str->buffer, buf, str->buf_len);
-	}
-}
-
-/*******************************************************************
- Reads or writes a REGVAL_BUFFER structure.
-   the uni_max_len member tells you how large the buffer is.
-   the uni_str_len member tells you how much of the buffer is really used.
-********************************************************************/
-
-bool smb_io_regval_buffer(const char *desc, prs_struct *ps, int depth, REGVAL_BUFFER *buf2)
-{
-
-	prs_debug(ps, depth, desc, "smb_io_regval_buffer");
-	depth++;
-
-	if(!prs_align(ps))
-		return False;
-		
-	if(!prs_uint32("buf_max_len", ps, depth, &buf2->buf_max_len))
-		return False;
-	if(!prs_uint32("offset     ", ps, depth, &buf2->offset))
-		return False;
-	if(!prs_uint32("buf_len    ", ps, depth, &buf2->buf_len))
-		return False;
-
-	/* buffer advanced by indicated length of string
-	   NOT by searching for null-termination */
-
-	if(!prs_regval_buffer(True, "buffer     ", ps, depth, buf2))
-		return False;
-
-	return True;
-}
-
-/*******************************************************************
 creates a UNISTR2 structure: sets up the buffer, too
 ********************************************************************/
 
diff --git a/source3/rpc_parse/parse_ntsvcs.c b/source3/rpc_parse/parse_ntsvcs.c
index 2b15a45..17b51fa 100644
--- a/source3/rpc_parse/parse_ntsvcs.c
+++ b/source3/rpc_parse/parse_ntsvcs.c
@@ -77,71 +77,3 @@ bool ntsvcs_io_r_get_device_list(const char *desc, NTSVCS_R_GET_DEVICE_LIST *r_u
 
 	return True;
 }
-
-/*******************************************************************
-********************************************************************/
-
-bool ntsvcs_io_q_get_device_reg_property(const char *desc, NTSVCS_Q_GET_DEVICE_REG_PROPERTY *q_u, prs_struct *ps, int depth)
-{
-	if (q_u == NULL)
-		return False;
-
-	prs_debug(ps, depth, desc, "ntsvcs_io_q_get_device_reg_property");
-	depth++;
-	
-	if(!prs_align(ps))
-		return False;
-
-	if ( !prs_io_unistr2("devicepath", ps, depth, &q_u->devicepath) )
-		return False;
-	if( !prs_align(ps) )
-		return False;
-
-	if ( !prs_uint32("property", ps, depth, &q_u->property) )
-		return False;
-	if ( !prs_uint32("unknown2", ps, depth, &q_u->unknown2) )
-		return False;
-	if ( !prs_uint32("buffer_size1", ps, depth, &q_u->buffer_size1) )
-		return False;
-	if ( !prs_uint32("buffer_size2", ps, depth, &q_u->buffer_size2) )
-		return False;
-	if ( !prs_uint32("unknown5", ps, depth, &q_u->unknown5) )
-		return False;
-	
-	return True;
-
-}
-
-/*******************************************************************
-********************************************************************/
-
-bool ntsvcs_io_r_get_device_reg_property(const char *desc, NTSVCS_R_GET_DEVICE_REG_PROPERTY *r_u, prs_struct *ps, int depth)
-{
-	if ( !r_u )
-		return False;
-
-	prs_debug(ps, depth, desc, "ntsvcs_io_r_get_device_reg_property");
-	depth++;
-
-	if ( !prs_align(ps) )
-		return False;
-
-	if ( !prs_uint32("unknown1", ps, depth, &r_u->unknown1) )
-		return False;
-
-	if ( !smb_io_regval_buffer("value", ps, depth, &r_u->value) )
-		return False;
-	if ( !prs_align(ps) )
-		return False;
-
-	if ( !prs_uint32("size", ps, depth, &r_u->size) )
-		return False;
-
-	if ( !prs_uint32("needed", ps, depth, &r_u->needed) )
-		return False;
-
-	if(!prs_werror("status", ps, depth, &r_u->status))
-		return False;
-
-	return True;
-}
diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c
index a0d3ed7..acc0cc8 100644
--- a/source3/rpc_parse/parse_prs.c
+++ b/source3/rpc_parse/parse_prs.c
@@ -1056,39 +1056,6 @@ bool prs_buffer5(bool charmode, const char *name, prs_struct *ps, int depth, BUF
 }
 
 /******************************************************************
- Stream a "not" unicode string, length/buffer specified separately,
- in byte chars. String is in little-endian format.
- ********************************************************************/
-
-bool prs_regval_buffer(bool charmode, const char *name, prs_struct *ps, int depth, REGVAL_BUFFER *buf)
-{
-	char *p;
-	char *q = prs_mem_get(ps, buf->buf_len);
-	if (q == NULL)
-		return False;
-
-	if (UNMARSHALLING(ps)) {
-		if (buf->buf_len > buf->buf_max_len) {
-			return False;
-		}
-		if ( buf->buf_max_len ) {
-			buf->buffer = PRS_ALLOC_MEM(ps, uint16, buf->buf_max_len);
-			if ( buf->buffer == NULL )
-				return False;
-		} else {
-			buf->buffer = NULL;
-		}
-	}
-
-	p = (char *)buf->buffer;
-
-	dbg_rw_punival(charmode, name, depth, ps, q, p, buf->buf_len/2);
-	ps->data_offset += buf->buf_len;
-
-	return True;
-}
-
-/******************************************************************
  Stream a string, length/buffer specified separately,
  in uint8 chars.
  ********************************************************************/
diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c
index 5010990..840da3e 100644
--- a/source3/rpc_server/srv_ntsvcs.c
+++ b/source3/rpc_server/srv_ntsvcs.c
@@ -97,23 +97,7 @@ static bool api_ntsvcs_validate_device_instance(pipes_struct *p)
 
 static bool api_ntsvcs_get_device_reg_property(pipes_struct *p)
 {
-	NTSVCS_Q_GET_DEVICE_REG_PROPERTY q_u;
-	NTSVCS_R_GET_DEVICE_REG_PROPERTY r_u;
-	prs_struct *data = &p->in_data.data;
-	prs_struct *rdata = &p->out_data.rdata;
-
-	ZERO_STRUCT(q_u);
-	ZERO_STRUCT(r_u);
-
-	if(!ntsvcs_io_q_get_device_reg_property("", &q_u, data, 0))
-		return False;
-
-	r_u.status = _ntsvcs_get_device_reg_property(p, &q_u, &r_u);
-
-	if(!ntsvcs_io_r_get_device_reg_property("", &r_u, rdata, 0))
-		return False;
-
-	return True;
+	return proxy_ntsvcs_call(p, NDR_PNP_GETDEVICEREGPROP);
 }
 
 /*******************************************************************
diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c
index 268da52..abeb2ca 100644
--- a/source3/rpc_server/srv_ntsvcs_nt.c
+++ b/source3/rpc_server/srv_ntsvcs_nt.c
@@ -93,26 +93,26 @@ WERROR _ntsvcs_get_device_list( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST *q_u,
 }
 
 /********************************************************************
+_PNP_GetDeviceRegProp
 ********************************************************************/
 
-WERROR _ntsvcs_get_device_reg_property( pipes_struct *p, NTSVCS_Q_GET_DEVICE_REG_PROPERTY *q_u, NTSVCS_R_GET_DEVICE_REG_PROPERTY *r_u )
+WERROR _PNP_GetDeviceRegProp(pipes_struct *p,
+			     struct PNP_GetDeviceRegProp *r)
 {
-	fstring devicepath;
 	char *ptr;
 	REGVAL_CTR *values;
 	REGISTRY_VALUE *val;
 
-	rpcstr_pull(devicepath, q_u->devicepath.buffer, sizeof(devicepath), q_u->devicepath.uni_str_len*2, 0);
-
-	switch( q_u->property ) {
+	switch( r->in.property ) {
 	case DEV_REGPROP_DESC:
+
 		/* just parse the service name from the device path and then
 		   lookup the display name */
-		if ( !(ptr = strrchr_m( devicepath, '\\' )) )
+		if ( !(ptr = strrchr_m( r->in.devicepath, '\\' )) )
 			return WERR_GENERAL_FAILURE;
 		*ptr = '\0';
 
-		if ( !(ptr = strrchr_m( devicepath, '_' )) )
+		if ( !(ptr = strrchr_m( r->in.devicepath, '_' )) )
 			return WERR_GENERAL_FAILURE;
 		ptr++;
 
@@ -124,16 +124,27 @@ WERROR _ntsvcs_get_device_reg_property( pipes_struct *p, NTSVCS_Q_GET_DEVICE_REG
 			return WERR_GENERAL_FAILURE;
 		}
 
-		r_u->unknown1 = 0x1;	/* always 1...tested using a remove device manager connection */
-		r_u->size = reg_init_regval_buffer( &r_u->value, val );
-		r_u->needed = r_u->size;
+		if (*r->in.buffer_size < val->size) {
+			*r->out.needed = val->size;
+			*r->out.buffer_size = 0;
+			TALLOC_FREE( values );
+			return WERR_CM_BUFFER_SMALL;
+		}
 
+		r->out.buffer = (uint8_t *)talloc_memdup(p->mem_ctx, val->data_p, val->size);
 		TALLOC_FREE(values);
+		if (!r->out.buffer) {
+			return WERR_NOMEM;
+		}
+
+		*r->out.reg_data_type = REG_SZ;	/* always 1...tested using a remove device manager connection */
+		*r->out.buffer_size = val->size;
+		*r->out.needed = val->size;
 
 		break;
 
 	default:
-		r_u->unknown1 = 0x00437c98;
+		*r->out.reg_data_type = 0x00437c98; /* ??? */
 		return WERR_CM_NO_SUCH_VALUE;
 	}
 
@@ -279,16 +290,6 @@ WERROR _PNP_GetDepth(pipes_struct *p,
 /****************************************************************
 ****************************************************************/
 
-WERROR _PNP_GetDeviceRegProp(pipes_struct *p,
-			     struct PNP_GetDeviceRegProp *r)
-{
-	p->rng_fault_state = true;
-	return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
-****************************************************************/
-
 WERROR _PNP_SetDeviceRegProp(pipes_struct *p,
 			     struct PNP_SetDeviceRegProp *r)
 {
diff --git a/source3/rpcclient/cmd_ntsvcs.c b/source3/rpcclient/cmd_ntsvcs.c
index 11f16d3..eb620d0 100644
--- a/source3/rpcclient/cmd_ntsvcs.c
+++ b/source3/rpcclient/cmd_ntsvcs.c
@@ -149,13 +149,13 @@ static WERROR cmd_ntsvcs_get_dev_reg_prop(struct rpc_pipe_client *cli,
 	const char *devicepath = NULL;
 	uint32_t property = DEV_REGPROP_DESC;
 	uint32_t reg_data_type = REG_NONE;
-	uint8_t buffer;
+	uint8_t *buffer;
 	uint32_t buffer_size = 0;
 	uint32_t needed = 0;
 	uint32_t flags = 0;
 
 	if (argc < 2) {
-		printf("usage: %s [devicepath]\n", argv[0]);
+		printf("usage: %s [devicepath] [buffersize]\n", argv[0]);
 		return WERR_OK;
 	}
 
@@ -166,11 +166,14 @@ static WERROR cmd_ntsvcs_get_dev_reg_prop(struct rpc_pipe_client *cli,
 		needed = buffer_size;
 	}
 
+	buffer = talloc_array(mem_ctx, uint8_t, buffer_size);
+	W_ERROR_HAVE_NO_MEMORY(buffer);
+
 	status = rpccli_PNP_GetDeviceRegProp(cli, mem_ctx,
 					     devicepath,
 					     property,
 					     &reg_data_type,
-					     &buffer,
+					     buffer,
 					     &buffer_size,
 					     &needed,
 					     flags,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list