svn commit: samba r6393 - in trunk/source: lib rpc_client rpc_parse utils

jerry at samba.org jerry at samba.org
Tue Apr 19 19:36:49 GMT 2005


Author: jerry
Date: 2005-04-19 19:36:49 +0000 (Tue, 19 Apr 2005)
New Revision: 6393

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

Log:
* fix parsing errors in reg_q_open_hive()
* fix bug in cli_open_entry() that was overwriting the 
  parent handle
* start adding code to 'net rpc registry'



Modified:
   trunk/source/lib/util.c
   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/lib/util.c
===================================================================
--- trunk/source/lib/util.c	2005-04-19 19:23:49 UTC (rev 6392)
+++ trunk/source/lib/util.c	2005-04-19 19:36:49 UTC (rev 6393)
@@ -2195,44 +2195,6 @@
 }
 
 /*****************************************************************
- Splits out the start of the key (HKLM or HKU) and the rest of the key.
-*****************************************************************/  
-
-BOOL reg_split_key(const char *full_keyname, uint32 *reg_type, char *key_name)
-{
-	pstring tmp;
-
-	if (!next_token(&full_keyname, tmp, "\\", sizeof(tmp)))
-		return False;
-
-	(*reg_type) = 0;
-
-	DEBUG(10, ("reg_split_key: hive %s\n", tmp));
-
-	if (strequal(tmp, "HKLM") || strequal(tmp, "HKEY_LOCAL_MACHINE"))
-		(*reg_type) = HKEY_LOCAL_MACHINE;
-	else if (strequal(tmp, "HKCR") || strequal(tmp, "HKEY_CLASSES_ROOT"))
-		(*reg_type) = HKEY_CLASSES_ROOT;
-	else if (strequal(tmp, "HKU") || strequal(tmp, "HKEY_USERS"))
-		(*reg_type) = HKEY_USERS;
-	else if (strequal(tmp, "HKPD")||strequal(tmp, "HKEY_PERFORMANCE_DATA"))
-		(*reg_type) = HKEY_PERFORMANCE_DATA;
-	else {
-		DEBUG(10,("reg_split_key: unrecognised hive key %s\n", tmp));
-		return False;
-	}
-	
-	if (next_token(&full_keyname, tmp, "\n\r", sizeof(tmp)))
-		fstrcpy(key_name, tmp);
-	else
-		key_name[0] = 0;
-
-	DEBUG(10, ("reg_split_key: name %s\n", key_name));
-
-	return True;
-}
-
-/*****************************************************************
  Possibly replace mkstemp if it is broken.
 *****************************************************************/  
 

Modified: trunk/source/rpc_client/cli_reg.c
===================================================================
--- trunk/source/rpc_client/cli_reg.c	2005-04-19 19:23:49 UTC (rev 6392)
+++ trunk/source/rpc_client/cli_reg.c	2005-04-19 19:36:49 UTC (rev 6393)
@@ -596,7 +596,7 @@
 	if ( !W_ERROR_IS_OK( out.status ) )
 		return out.status;
 
-	memcpy( hnd, &out.pol, sizeof(POLICY_HND) );
+	memcpy( key_hnd, &out.pol, sizeof(POLICY_HND) );
 	
 	return out.status;
 }
@@ -627,3 +627,48 @@
 }
 
 
+/* 
+ #################################################################
+  Utility functions
+ #################################################################
+ */
+
+/*****************************************************************
+ Splits out the start of the key (HKLM or HKU) and the rest of the key.
+*****************************************************************/  
+
+BOOL reg_split_hive(const char *full_keyname, uint32 *reg_type, pstring key_name)
+{
+	pstring tmp;
+
+	if (!next_token(&full_keyname, tmp, "\\", sizeof(tmp)))
+		return False;
+
+	(*reg_type) = 0;
+
+	DEBUG(10, ("reg_split_key: hive %s\n", tmp));
+
+	if (strequal(tmp, "HKLM") || strequal(tmp, "HKEY_LOCAL_MACHINE"))
+		(*reg_type) = HKEY_LOCAL_MACHINE;
+	else if (strequal(tmp, "HKCR") || strequal(tmp, "HKEY_CLASSES_ROOT"))
+		(*reg_type) = HKEY_CLASSES_ROOT;
+	else if (strequal(tmp, "HKU") || strequal(tmp, "HKEY_USERS"))
+		(*reg_type) = HKEY_USERS;
+	else if (strequal(tmp, "HKPD")||strequal(tmp, "HKEY_PERFORMANCE_DATA"))
+		(*reg_type) = HKEY_PERFORMANCE_DATA;
+	else {
+		DEBUG(10,("reg_split_key: unrecognised hive key %s\n", tmp));
+		return False;
+	}
+	
+	if (next_token(&full_keyname, tmp, "\n\r", sizeof(tmp)))
+		pstrcpy(key_name, tmp);
+	else
+		key_name[0] = 0;
+
+	DEBUG(10, ("reg_split_key: name %s\n", key_name));
+
+	return True;
+}
+
+

Modified: trunk/source/rpc_parse/parse_reg.c
===================================================================
--- trunk/source/rpc_parse/parse_reg.c	2005-04-19 19:23:49 UTC (rev 6392)
+++ trunk/source/rpc_parse/parse_reg.c	2005-04-19 19:36:49 UTC (rev 6393)
@@ -75,6 +75,8 @@
 	if(!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
 		return False;
 
+	if(!prs_align(ps))
+		return False;
 	if(!prs_uint32("access", ps, depth, &q_u->access))
 		return False;
 

Modified: trunk/source/utils/net_rpc_registry.c
===================================================================
--- trunk/source/utils/net_rpc_registry.c	2005-04-19 19:23:49 UTC (rev 6392)
+++ trunk/source/utils/net_rpc_registry.c	2005-04-19 19:36:49 UTC (rev 6393)
@@ -29,12 +29,38 @@
                                            int argc, const char **argv )
 {
 	WERROR result = WERR_GENERAL_FAILURE;
+	uint32 hive;
+	pstring subpath;
+	POLICY_HND pol_hive, pol_key; 
 	
-	if (argc != 0 ) {
-		d_printf("Usage:    net rpc enuemrate <path> [recurse]\n");
-		d_printf("Example:: net rpc enuemrate 'HKLM\\Software\\Samba'\n");
+	if (argc != 1 ) {
+		d_printf("Usage:    net rpc enumerate <path> [recurse]\n");
+		d_printf("Example:: net rpc enumerate 'HKLM\\Software\\Samba'\n");
 		return NT_STATUS_OK;
 	}
+	
+	if ( !reg_split_hive( argv[0], &hive, subpath ) ) {
+		d_printf("invalid registry path\n");
+		return NT_STATUS_OK;
+	}
+	
+	result = cli_reg_connect( cli, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive );
+	if ( !W_ERROR_IS_OK(result) ) {
+		d_printf("Unable to connect to remote registry\n");
+		return NT_STATUS_OK;
+	}
+	
+	result = cli_reg_open_entry( cli, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key );
+	if ( !W_ERROR_IS_OK(result) ) {
+		d_printf("Unable to open [%s]\n", argv[0]);
+		return NT_STATUS_OK;
+	}
+	
+	
+	/* cleanup */
+	
+	cli_reg_close( cli, mem_ctx, &pol_key );
+	cli_reg_close( cli, mem_ctx, &pol_hive );
 
 	return werror_to_ntstatus(result);
 }



More information about the samba-cvs mailing list