[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Wed Jul 13 04:43:02 MDT 2011


The branch, master has been updated
       via  e858ec6 s3-rpc_server: Removed no longer used functions.
       via  0b1ba88 s3-rpc_client: Migrate to dcerpc_winreg_delete_subkeys_recursive().
       via  a336cc4 s3-rpc_client: Migrate to dcerpc_winreg_enumvals() function.
       via  4558225 s3-rpc_client: Added dcerpc_winreg_delete_subkeys_recursive() function.
       via  8b3eff8 s3-rpc_client: Added dcerpc_winreg_enumvals() function.
      from  c6ece60 dynconfig: rework the logic to support --enable-fhs

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


- Log -----------------------------------------------------------------
commit e858ec6e92c0232bbf82dc117c03b71e9a413be3
Author: Vicentiu Ciorbaru <cvicentiu at gmail.com>
Date:   Tue Jul 12 19:54:45 2011 +0300

    s3-rpc_server: Removed no longer used functions.
    
    Removed winreg_printer_delete_subkeys().
    Removed winreg_printer_enumvalues().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User: Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date: Wed Jul 13 12:42:02 CEST 2011 on sn-devel-104

commit 0b1ba88f228592bd7ced01025a4045c946096ab4
Author: Vicentiu Ciorbaru <cvicentiu at gmail.com>
Date:   Tue Jul 12 19:50:57 2011 +0300

    s3-rpc_client: Migrate to dcerpc_winreg_delete_subkeys_recursive().
    
    Functions now use dcerpc_winreg_delete_subkeys_recursive() instead of the more
    specific printer function winreg_printer_delete_subkeys().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>

commit a336cc44d94532d064cb272f3c2ff3c5b9230039
Author: Vicentiu Ciorbaru <cvicentiu at gmail.com>
Date:   Tue Jul 12 19:42:15 2011 +0300

    s3-rpc_client: Migrate to dcerpc_winreg_enumvals() function.
    
    The functions that called winreg_printer_enumvalues() function now use
    dcerpc_winreg_enumvals().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>

commit 4558225cdd9c29a4b683101f39f627bf61a580af
Author: Vicentiu Ciorbaru <cvicentiu at gmail.com>
Date:   Tue Jul 12 19:38:14 2011 +0300

    s3-rpc_client: Added dcerpc_winreg_delete_subkeys_recursive() function.
    
    This function is set to replace the more specific printer function
    winreg_printer_delete_subkeys().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>

commit 8b3eff8b36129d9920685a84a902cdf109e27354
Author: Vicentiu Ciorbaru <cvicentiu at gmail.com>
Date:   Tue Jul 12 19:37:31 2011 +0300

    s3-rpc_client: Added dcerpc_winreg_enumvals() function.
    
    The function is set to replace the more specific printer function
    winreg_printer_enumvalues() function.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>

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

Summary of changes:
 source3/rpc_client/cli_winreg.c         |  280 ++++++++++++++++++
 source3/rpc_client/cli_winreg.h         |   65 ++++
 source3/rpc_client/cli_winreg_spoolss.c |  486 +++++++++++--------------------
 3 files changed, 518 insertions(+), 313 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/rpc_client/cli_winreg.c b/source3/rpc_client/cli_winreg.c
index 69982da..9fa2d31 100644
--- a/source3/rpc_client/cli_winreg.c
+++ b/source3/rpc_client/cli_winreg.c
@@ -702,4 +702,284 @@ NTSTATUS dcerpc_winreg_enum_keys(TALLOC_CTX *mem_ctx,
 	return status;
 }
 
+NTSTATUS dcerpc_winreg_enumvals(TALLOC_CTX *mem_ctx,
+					struct dcerpc_binding_handle *h,
+					struct policy_handle *key_hnd,
+					uint32_t *pnum_values,
+					const char ***pnames,
+					enum winreg_Type **_type,
+					DATA_BLOB **pdata,
+					WERROR *pwerr)
+{
+	TALLOC_CTX *tmp_ctx;
+	uint32_t num_subkeys = 0, max_subkeylen = 0, max_classlen = 0;
+	uint32_t num_values = 0, max_valnamelen = 0, max_valbufsize = 0;
+	uint32_t secdescsize = 0;
+	uint32_t i;
+	NTTIME last_changed_time = 0;
+	struct winreg_String classname;
+
+	const char **enum_names = NULL;
+	enum winreg_Type *enum_types = NULL;
+	DATA_BLOB *enum_data_blobs = NULL;
+
+
+	WERROR result = WERR_OK;
+	NTSTATUS status = NT_STATUS_OK;
+
+	tmp_ctx = talloc_stackframe();
+	if (tmp_ctx == NULL) {
+
+		status = NT_STATUS_NO_MEMORY;
+		*pwerr = ntstatus_to_werror(status);
+		return status;
+	}
+
+	ZERO_STRUCT(classname);
+
+	status = dcerpc_winreg_QueryInfoKey(h,
+					    tmp_ctx,
+					    key_hnd,
+					    &classname,
+					    &num_subkeys,
+					    &max_subkeylen,
+					    &max_classlen,
+					    &num_values,
+					    &max_valnamelen,
+					    &max_valbufsize,
+					    &secdescsize,
+					    &last_changed_time,
+					    &result);
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(0, ("dcerpc_winreg_enumvals: Could not query info: %s\n",
+			  nt_errstr(status)));
+		goto error;
+	}
+	if (!W_ERROR_IS_OK(result)) {
+		DEBUG(0, ("dcerpc_winreg_enumvals: Could not query info: %s\n",
+			  win_errstr(result)));
+		*pwerr = result;
+		goto error;
+	}
+
+	if (num_values == 0) {
+		*pnum_values = 0;
+		TALLOC_FREE(tmp_ctx);
+		*pwerr = WERR_OK;
+		return status;
+	}
+
+	enum_names = talloc_zero_array(tmp_ctx, const char *, num_values);
+
+	if (enum_names == NULL) {
+		*pwerr = WERR_NOMEM;
+		goto error;
+	}
+
+	enum_types = talloc_zero_array(tmp_ctx, enum winreg_Type, num_values);
+
+	if (enum_types == NULL) {
+		*pwerr = WERR_NOMEM;
+		goto error;
+	}
+
+	enum_data_blobs = talloc_zero_array(tmp_ctx, DATA_BLOB, num_values);
+
+	if (enum_data_blobs == NULL) {
+		*pwerr = WERR_NOMEM;
+		goto error;
+	}
+
+	for (i = 0; i < num_values; i++) {
+		const char *name;
+		struct winreg_ValNameBuf name_buf;
+		enum winreg_Type type = REG_NONE;
+		uint8_t *data;
+		uint32_t data_size;
+		uint32_t length;
+		char n = '\0';
+
+
+		name_buf.name = &n;
+		name_buf.size = max_valnamelen + 2;
+		name_buf.length = 0;
+
+		data_size = max_valbufsize;
+		data = NULL;
+		if (data_size) {
+			data = (uint8_t *) TALLOC(tmp_ctx, data_size);
+		}
+		length = 0;
+
+		status = dcerpc_winreg_EnumValue(h,
+						 tmp_ctx,
+						 key_hnd,
+						 i,
+						 &name_buf,
+						 &type,
+						 data,
+						 data_size ? &data_size : NULL,
+						 &length,
+						 &result);
+		if (W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) {
+			result = WERR_OK;
+			status = NT_STATUS_OK;
+			break;
+		}
+
+		if (!NT_STATUS_IS_OK(status)) {
+			DEBUG(0, ("dcerpc_winreg_enumvals: Could not enumerate values: %s\n",
+				  nt_errstr(status)));
+			goto error;
+		}
+		if (!W_ERROR_IS_OK(result)) {
+			DEBUG(0, ("dcerpc_winreg_enumvals: Could not enumerate values: %s\n",
+				  win_errstr(result)));
+			*pwerr = result;
+			goto error;
+		}
+
+		if (name_buf.name == NULL) {
+			result = WERR_INVALID_PARAMETER;
+			*pwerr = result;
+			goto error;
+		}
+
+		name = talloc_strdup(enum_names, name_buf.name);
+		if (name == NULL) {
+			result = WERR_NOMEM;
+			*pwerr = result;
+			goto error;
+		}
+	/* place name, type and datablob in the enum return params */
+
+		enum_data_blobs[i] = data_blob_talloc(enum_data_blobs, data, length);
+		enum_names[i] = name;
+		enum_types[i] = type;
+
+	}
+	/* move to the main mem context */
+	*pnum_values = num_values;
+	if (pnames) {
+		*pnames = talloc_move(mem_ctx, &enum_names);
+	}
+	/* can this fail in any way? */
+	if (_type) {
+		*_type = talloc_move(mem_ctx, &enum_types);
+	}
+
+	if (pdata){
+		*pdata = talloc_move(mem_ctx, &enum_data_blobs);
+	}
+
+
+	result = WERR_OK;
+
+ error:
+	TALLOC_FREE(tmp_ctx);
+	*pwerr = result;
+
+	return status;
+}
+
+NTSTATUS dcerpc_winreg_delete_subkeys_recursive(TALLOC_CTX *mem_ctx,
+						struct dcerpc_binding_handle *h,
+						struct policy_handle *hive_handle,
+						uint32_t access_mask,
+						const char *key,
+						WERROR *pwerr)
+{
+	const char **subkeys = NULL;
+	uint32_t num_subkeys = 0;
+	struct policy_handle key_hnd;
+	struct winreg_String wkey = { 0, };
+	WERROR result = WERR_OK;
+	NTSTATUS status = NT_STATUS_OK;
+	uint32_t i;
+
+	ZERO_STRUCT(key_hnd);
+	wkey.name = key;
+
+	DEBUG(2, ("dcerpc_winreg_delete_subkeys_recursive: delete key %s\n", key));
+	/* open the key */
+	status = dcerpc_winreg_OpenKey(h,
+				       mem_ctx,
+				       hive_handle,
+				       wkey,
+				       0,
+				       access_mask,
+				       &key_hnd,
+				       &result);
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(0, ("dcerpc_winreg_delete_subkeys_recursive: Could not open key %s: %s\n",
+			  wkey.name, nt_errstr(status)));
+		goto done;
+	}
+	if (!W_ERROR_IS_OK(result)) {
+		DEBUG(0, ("dcerpc_winreg_delete_subkeys_recursive: Could not open key %s: %s\n",
+			  wkey.name, win_errstr(result)));
+		*pwerr = result;
+		goto done;
+	}
+
+	status = dcerpc_winreg_enum_keys(mem_ctx,
+					 h,
+					 &key_hnd,
+					 &num_subkeys,
+					 &subkeys,
+					 &result);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto done;
+	}
+	if (!W_ERROR_IS_OK(result)) {
+		goto done;
+	}
+
+	for (i = 0; i < num_subkeys; i++) {
+		/* create key + subkey */
+		char *subkey = talloc_asprintf(mem_ctx, "%s\\%s", key, subkeys[i]);
+		if (subkey == NULL) {
+			goto done;
+		}
+
+		DEBUG(2, ("dcerpc_winreg_delete_subkeys_recursive: delete subkey %s\n", subkey));
+		status = dcerpc_winreg_delete_subkeys_recursive(mem_ctx,
+								h,
+								hive_handle,
+								access_mask,
+								subkey,
+								&result);
+		if (!W_ERROR_IS_OK(result)) {
+			goto done;
+		}
+	}
+
+	if (is_valid_policy_hnd(&key_hnd)) {
+		WERROR ignore;
+		dcerpc_winreg_CloseKey(h, mem_ctx, &key_hnd, &ignore);
+	}
+
+	wkey.name = key;
+
+	status = dcerpc_winreg_DeleteKey(h,
+					 mem_ctx,
+					 hive_handle,
+					 wkey,
+					 &result);
+	if (!NT_STATUS_IS_OK(status)) {
+		*pwerr = result;
+		goto done;
+	}
+
+done:
+	if (is_valid_policy_hnd(&key_hnd)) {
+		WERROR ignore;
+
+		dcerpc_winreg_CloseKey(h, mem_ctx, &key_hnd, &ignore);
+	}
+
+	*pwerr = result;
+	return status;
+}
+
 /* vim: set ts=8 sw=8 noet cindent syntax=c.doxygen: */
diff --git a/source3/rpc_client/cli_winreg.h b/source3/rpc_client/cli_winreg.h
index 413aba5..a516263 100644
--- a/source3/rpc_client/cli_winreg.h
+++ b/source3/rpc_client/cli_winreg.h
@@ -378,6 +378,71 @@ NTSTATUS dcerpc_winreg_enum_keys(TALLOC_CTX *mem_ctx,
 				 uint32_t *pnum_subkeys,
 				 const char ***psubkeys,
 				 WERROR *pwerr);
+/**
+ * @internal
+ *
+ * @brief Enumerate values of an opened key handle and retrieve the data.
+ *
+ * @param[in]  mem_ctx  The memory context to use.
+ *
+ * @param[in]  winreg_handle The binding handle for the rpc connection.
+ *
+ * @param[in]  key_hnd  The opened key handle.
+ *
+ * @param[out] pnum_values A pointer to store the number of values we found.
+ *
+ * @param[out] pnames A pointer to store all the names of the values we found.
+ *
+ * @param[out] _type A pointer to store all the types coresponding with the
+ * 		     values found.
+ * @param[out] pdata A pointer to store the data coresponding to the values.
+ *
+ * @param[out] pwerr A pointer to the WERROR. WERR_OK on success
+ *		     WERR_OK on success, the corresponding DOS error
+ *		     code if something's gone wrong.
+ *
+ * @return              NT_STATUS_OK on success or a corresponding error if
+ *                      there was a problem on the connection.
+ */
+
+NTSTATUS dcerpc_winreg_enumvals(TALLOC_CTX *mem_ctx,
+					struct dcerpc_binding_handle *h,
+					struct policy_handle *key_hnd,
+					uint32_t *pnum_values,
+					const char ***pnames,
+					enum winreg_Type **_type,
+					DATA_BLOB **pdata,
+					WERROR *pwerr);
+
+/**
+ * @internal
+ *
+ * @brief A function to delete a key and its subkeys recurively.
+ *
+ * @param[in]  mem_ctx  The memory context to use.
+ *
+ * @param[in]  winreg_handle The binding handle for the rpc connection.
+ *
+ * @param[in]  hive_handle A opened hive handle to the key.
+ *
+ * @param[in]  access_mask The access mask to access the key.
+ *
+ * @param[in]  key      The key to delete
+ *
+ * @param[out]          WERR_OK on success, the corresponding DOS error
+ *                      code if something gone wrong.
+ *
+ * @return              NT_STATUS_OK on success or a corresponding error if
+ *                      there was a problem on the connection.
+ */
+
+NTSTATUS dcerpc_winreg_delete_subkeys_recursive(TALLOC_CTX *mem_ctx,
+						struct dcerpc_binding_handle *h,
+						struct policy_handle *hive_handle,
+						uint32_t access_mask,
+						const char *key,
+						WERROR *pwerr);
+
 
 #endif /* CLI_WINREG_H */
 
diff --git a/source3/rpc_client/cli_winreg_spoolss.c b/source3/rpc_client/cli_winreg_spoolss.c
index f742a47..9b7c724 100644
--- a/source3/rpc_client/cli_winreg_spoolss.c
+++ b/source3/rpc_client/cli_winreg_spoolss.c
@@ -320,287 +320,6 @@ static char *winreg_printer_data_keyname(TALLOC_CTX *mem_ctx, const char *printe
 	return talloc_asprintf(mem_ctx, "%s\\%s", TOP_LEVEL_PRINT_PRINTERS_KEY, printer);
 }
 
-/**
- * @internal
- *
- * @brief Enumerate values of an opened key handle and retrieve the data.
- *
- * @param[in]  mem_ctx  The memory context to use.
- *
- * @param[in]  winreg_handle The binding handle for the rpc connection.
- *
- * @param[in]  key_hnd  The opened key handle.
- *
- * @param[out] pnum_values A pointer to store he number of values found.
- *
- * @param[out] pnum_values A pointer to store the number of values we found.
- *
- * @return                   WERR_OK on success, the corresponding DOS error
- *                           code if something gone wrong.
- */
-static WERROR winreg_printer_enumvalues(TALLOC_CTX *mem_ctx,
-					struct dcerpc_binding_handle *winreg_handle,
-					struct policy_handle *key_hnd,
-					uint32_t *pnum_values,
-					struct spoolss_PrinterEnumValues **penum_values)
-{
-	TALLOC_CTX *tmp_ctx;
-	uint32_t num_subkeys, max_subkeylen, max_classlen;
-	uint32_t num_values, max_valnamelen, max_valbufsize;
-	uint32_t secdescsize;
-	uint32_t i;
-	NTTIME last_changed_time;
-	struct winreg_String classname;
-
-	struct spoolss_PrinterEnumValues *enum_values;
-
-	WERROR result = WERR_OK;
-	NTSTATUS status;
-
-	tmp_ctx = talloc_stackframe();
-	if (tmp_ctx == NULL) {
-		return WERR_NOMEM;
-	}
-
-	ZERO_STRUCT(classname);
-
-	status = dcerpc_winreg_QueryInfoKey(winreg_handle,
-					    tmp_ctx,
-					    key_hnd,
-					    &classname,
-					    &num_subkeys,
-					    &max_subkeylen,
-					    &max_classlen,
-					    &num_values,
-					    &max_valnamelen,
-					    &max_valbufsize,
-					    &secdescsize,
-					    &last_changed_time,
-					    &result);
-	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(0, ("winreg_printer_enumvalues: Could not query info: %s\n",
-			  nt_errstr(status)));
-		result = ntstatus_to_werror(status);
-		goto error;
-	}
-	if (!W_ERROR_IS_OK(result)) {
-		DEBUG(0, ("winreg_printer_enumvalues: Could not query info: %s\n",
-			  win_errstr(result)));
-		goto error;
-	}
-
-	if (num_values == 0) {
-		*pnum_values = 0;
-		TALLOC_FREE(tmp_ctx);
-		return WERR_OK;
-	}
-
-	enum_values = talloc_array(tmp_ctx, struct spoolss_PrinterEnumValues, num_values);
-	if (enum_values == NULL) {
-		result = WERR_NOMEM;
-		goto error;
-	}
-
-	for (i = 0; i < num_values; i++) {
-		struct spoolss_PrinterEnumValues val;
-		struct winreg_ValNameBuf name_buf;
-		enum winreg_Type type = REG_NONE;
-		uint8_t *data;
-		uint32_t data_size;
-		uint32_t length;
-		char n = '\0';
-
-		name_buf.name = &n;
-		name_buf.size = max_valnamelen + 2;
-		name_buf.length = 0;
-
-		data_size = max_valbufsize;
-		data = NULL;
-		if (data_size) {
-			data = (uint8_t *) talloc_zero_size(tmp_ctx, data_size);
-		}
-		length = 0;
-
-		status = dcerpc_winreg_EnumValue(winreg_handle,
-						 tmp_ctx,
-						 key_hnd,
-						 i,
-						 &name_buf,
-						 &type,
-						 data,
-						 data_size ? &data_size : NULL,
-						 &length,
-						 &result);
-		if (W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) {
-			result = WERR_OK;
-			status = NT_STATUS_OK;
-			break;
-		}
-
-		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(0, ("winreg_printer_enumvalues: Could not enumerate values: %s\n",
-				  nt_errstr(status)));
-			result = ntstatus_to_werror(status);
-			goto error;
-		}
-		if (!W_ERROR_IS_OK(result)) {
-			DEBUG(0, ("winreg_printer_enumvalues: Could not enumerate values: %s\n",
-				  win_errstr(result)));
-			goto error;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list