svn commit: samba r6398 - in trunk/source: include rpc_client rpc_parse utils

jerry at samba.org jerry at samba.org
Wed Apr 20 02:59:38 GMT 2005


Author: jerry
Date: 2005-04-20 02:59:37 +0000 (Wed, 20 Apr 2005)
New Revision: 6398

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

Log:
got RegEnumVal() working against a Windows 2000 server
Modified:
   trunk/source/include/rpc_reg.h
   trunk/source/rpc_client/cli_reg.c
   trunk/source/rpc_parse/parse_reg.c
   trunk/source/utils/net_rpc_registry.c


Changeset:
Modified: trunk/source/include/rpc_reg.h
===================================================================
--- trunk/source/include/rpc_reg.h	2005-04-19 22:45:51 UTC (rev 6397)
+++ trunk/source/include/rpc_reg.h	2005-04-20 02:59:37 UTC (rev 6398)
@@ -233,8 +233,8 @@
 	UNISTR4 name;
 	uint32 *type;
 	REGVAL_BUFFER *value;
-	uint32 *buffer_len;
-	uint32 *name_len;
+	uint32 *buffer_len1;
+	uint32 *buffer_len2;
 	WERROR status;
 } REG_R_ENUM_VALUE;
 

Modified: trunk/source/rpc_client/cli_reg.c
===================================================================
--- trunk/source/rpc_client/cli_reg.c	2005-04-19 22:45:51 UTC (rev 6397)
+++ trunk/source/rpc_client/cli_reg.c	2005-04-20 02:59:37 UTC (rev 6398)
@@ -566,7 +566,7 @@
 
 		ZERO_STRUCT (in);
 
-		init_reg_q_enum_val(&in, hnd, idx, *out.needed_name_len, *out.needed_buffer_len);
+		init_reg_q_enum_val(&in, hnd, idx, 0x0100, *out.buffer_len1);
 
 		ZERO_STRUCT (out);
 

Modified: trunk/source/rpc_parse/parse_reg.c
===================================================================
--- trunk/source/rpc_parse/parse_reg.c	2005-04-19 22:45:51 UTC (rev 6397)
+++ trunk/source/rpc_parse/parse_reg.c	2005-04-20 02:59:37 UTC (rev 6398)
@@ -1067,7 +1067,9 @@
 
 	q_u->val_index = val_idx;
 
-	q_u->name.length = max_name_len;
+	q_u->name.size = max_name_len*2;
+	q_u->name.string = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR2 );
+	q_u->name.string->uni_max_len = max_name_len;
 	
 	q_u->type = TALLOC_P( get_talloc_ctx(), uint32 );
 	*q_u->type = 0x0;
@@ -1110,12 +1112,10 @@
 	
 	/* lengths */
 
-	r_u->buffer_len  = TALLOC_P( get_talloc_ctx(), uint32 );
-	*r_u->buffer_len = real_size;
-	
-	r_u->name_len  = TALLOC_P( get_talloc_ctx(), uint32 );
-	*r_u->name_len = r_u->name.string->uni_str_len;
-		
+	r_u->buffer_len1  = TALLOC_P( get_talloc_ctx(), uint32 );
+	*r_u->buffer_len1 = real_size;
+	r_u->buffer_len2  = TALLOC_P( get_talloc_ctx(), uint32 );
+	*r_u->buffer_len2 = real_size;
 }
 
 /*******************************************************************
@@ -1188,9 +1188,9 @@
 	if(!prs_align(ps))
 		return False;
 
-	if(!prs_pointer("buffer_len", ps, depth, (void**)&r_u->buffer_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
+	if(!prs_pointer("buffer_len1", ps, depth, (void**)&r_u->buffer_len1, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
 		return False;
-	if(!prs_pointer("name_len", ps, depth, (void**)&r_u->name_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
+	if(!prs_pointer("buffer_len2", ps, depth, (void**)&r_u->buffer_len2, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
 		return False;
 
 	if(!prs_werror("status", ps, depth, &r_u->status))

Modified: trunk/source/utils/net_rpc_registry.c
===================================================================
--- trunk/source/utils/net_rpc_registry.c	2005-04-19 22:45:51 UTC (rev 6397)
+++ trunk/source/utils/net_rpc_registry.c	2005-04-20 02:59:37 UTC (rev 6398)
@@ -24,6 +24,27 @@
 /********************************************************************
 ********************************************************************/
 
+void dump_regval_buffer( uint32 type, REGVAL_BUFFER *buffer )
+{
+	switch (type) {
+	case REG_SZ:
+		break;
+	case REG_MULTI_SZ:
+		break;
+	case REG_DWORD:
+		break;
+	case REG_BINARY:
+		break;
+	
+	
+	default:
+		d_printf( "\tUnknown type [%d]\n", type );
+	}
+}
+
+/********************************************************************
+********************************************************************/
+
 static NTSTATUS rpc_registry_enumerate_internal( const DOM_SID *domain_sid, const char *domain_name, 
                                            struct cli_state *cli, TALLOC_CTX *mem_ctx, 
                                            int argc, const char **argv )
@@ -71,8 +92,10 @@
 		result = cli_reg_enum_key( cli, mem_ctx, &pol_key, idx, 
 			keyname, &unknown1, &unknown2, &modtime );
 			
-		if ( !W_ERROR_IS_OK(result) )
+		if ( W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) {
+			result = WERR_OK;
 			break;
+		}
 			
 		d_printf("Keyname  = %s\n", keyname );
 		d_printf("Unknown1 = 0x%x\n", unknown1 );
@@ -81,6 +104,9 @@
 		d_printf("\n" );
 		idx++;
 	}
+
+	if ( !W_ERROR_IS_OK(result) )
+		goto out;
 	
 	/* get the values */
 	
@@ -97,16 +123,21 @@
 		result = cli_reg_enum_val( cli, mem_ctx, &pol_key, idx, 
 			name, &type, &value );
 			
-		if ( !W_ERROR_IS_OK(result) )
+		if ( W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) {
+			result = WERR_OK;
 			break;
+		}
 			
 		d_printf("Valuename  = %s\n", name );
 		d_printf("Type       = %d\n", type );
+		d_printf("Data       =\n" );
+		dump_regval_buffer( type, &value );
 		d_printf("\n" );
 		idx++;
 	}
 	
 	
+out:
 	/* cleanup */
 	
 	cli_reg_close( cli, mem_ctx, &pol_key );



More information about the samba-cvs mailing list