[SCM] Samba Shared Repository - branch v3-4-test updated - release-4-0-0alpha7-468-g6f87c10

Günther Deschner gd at samba.org
Wed Mar 18 00:33:21 GMT 2009


The branch, v3-4-test has been updated
       via  6f87c105748689bf1e902b83603e57c12f7edce3 (commit)
       via  c7660dacbcf5d6132960508104507ed1e2fca878 (commit)
       via  83b10f0405f596bf5ffb8eb7071fb85d1df62428 (commit)
       via  2ecc69851773d3a2cfa0e0e2dc1e90eff26e3fb0 (commit)
      from  8150299e89339e6bcc2e4d1d30146a91f7bc1b1c (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-4-test


- Log -----------------------------------------------------------------
commit 6f87c105748689bf1e902b83603e57c12f7edce3
Author: Günther Deschner <gd at samba.org>
Date:   Wed Mar 18 00:38:01 2009 +0100

    s3-spoolss: remove old rpccli_spoolss_enumprinterdataex.
    
    Guenther
    (cherry picked from commit 9d024d17153ad10b0df0531480b2a0a43f910dba)

commit c7660dacbcf5d6132960508104507ed1e2fca878
Author: Günther Deschner <gd at samba.org>
Date:   Wed Mar 18 01:06:22 2009 +0100

    s3-net: use rpccli_spoolss_enumprinterdataex.
    
    Guenther
    (cherry picked from commit f9712d568ab6331be5a62a34ce60331013ccd253)

commit 83b10f0405f596bf5ffb8eb7071fb85d1df62428
Author: Günther Deschner <gd at samba.org>
Date:   Tue Mar 17 23:45:16 2009 +0100

    s3-rpcclient: use rpccli_spoolss_enumprinterdataex wrapper.
    
    Guenther
    (cherry picked from commit 8c3ef2d9004f3c540bae21b92e0b568008bc1130)

commit 2ecc69851773d3a2cfa0e0e2dc1e90eff26e3fb0
Author: Günther Deschner <gd at samba.org>
Date:   Tue Mar 17 23:39:00 2009 +0100

    s3-spoolss: add rpccli_spoolss_enumprinterdataex convenience wrapper.
    
    Guenther
    (cherry picked from commit ab85fc78bd932aca14103352f784a4b5f2909f3a)

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

Summary of changes:
 source3/include/proto.h          |   13 +++---
 source3/rpc_client/cli_spoolss.c |   85 ++++++++++++++------------------------
 source3/rpcclient/cmd_spoolss.c  |   36 ++++++++--------
 source3/utils/net_rpc_printer.c  |   68 +++++++++++++++++++-----------
 4 files changed, 101 insertions(+), 101 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index d3db1e8..1c2abc6 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -5543,9 +5543,13 @@ WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
 				     const char *key_name,
 				     const char ***key_buffer,
 				     uint32_t offered);
-WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
-				     POLICY_HND *hnd, const char *keyname, 
-				     REGVAL_CTR *ctr);
+WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli,
+					TALLOC_CTX *mem_ctx,
+					struct policy_handle *handle,
+					const char *key_name,
+					uint32_t offered,
+					uint32_t *count,
+					struct spoolss_PrinterEnumValues **info);
 
 /* The following definitions come from rpc_client/init_spoolss.c  */
 
@@ -5827,9 +5831,6 @@ bool sec_io_desc_buf(const char *desc, SEC_DESC_BUF **ppsdb, prs_struct *ps, int
 
 uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p);
 bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src);
-bool make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX *q_u,
-				      const POLICY_HND *hnd, const char *key,
-				      uint32 size);
 bool spoolss_io_q_enumprinterdataex(const char *desc, SPOOL_Q_ENUMPRINTERDATAEX *q_u, prs_struct *ps, int depth);
 bool spoolss_io_r_enumprinterdataex(const char *desc, SPOOL_R_ENUMPRINTERDATAEX *r_u, prs_struct *ps, int depth);
 
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index 9ca3ab6..3f369bd 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -784,66 +784,43 @@ WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
 	return werror;
 }
 
-
-/*********************************************************************
- Decode various spoolss rpc's and info levels
- ********************************************************************/
-
 /**********************************************************************
+ convencience wrapper around rpccli_spoolss_EnumPrinterDataEx
 **********************************************************************/
 
-WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
-				     POLICY_HND *hnd, const char *keyname, 
-				     REGVAL_CTR *ctr)
+WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli,
+					TALLOC_CTX *mem_ctx,
+					struct policy_handle *handle,
+					const char *key_name,
+					uint32_t offered,
+					uint32_t *count,
+					struct spoolss_PrinterEnumValues **info)
 {
-	prs_struct qbuf, rbuf;
-	SPOOL_Q_ENUMPRINTERDATAEX in;
-	SPOOL_R_ENUMPRINTERDATAEX out;
-	int i;
-	uint32 offered;
-
-	ZERO_STRUCT(in);
-	ZERO_STRUCT(out);
-
-	offered = 0;
-	make_spoolss_q_enumprinterdataex( &in, hnd, keyname, offered );
-
-	CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMPRINTERDATAEX,
-	            in, out, 
-	            qbuf, rbuf,
-	            spoolss_io_q_enumprinterdataex,
-	            spoolss_io_r_enumprinterdataex, 
-	            WERR_GENERAL_FAILURE );
-
-	if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) {
-		offered = out.needed;
-		
-		ZERO_STRUCT(in);
-		ZERO_STRUCT(out);
-		
-	        make_spoolss_q_enumprinterdataex( &in, hnd, keyname, offered );
-
-		CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMPRINTERDATAEX,
-		            in, out, 
-		            qbuf, rbuf,
-		            spoolss_io_q_enumprinterdataex,
-		            spoolss_io_r_enumprinterdataex, 
-		            WERR_GENERAL_FAILURE );
-	}
-	
-	if (!W_ERROR_IS_OK(out.status))
-		return out.status;
+	NTSTATUS status;
+	WERROR werror;
+	uint32_t needed;
 
-	for (i = 0; i < out.returned; i++) {
-		PRINTER_ENUM_VALUES *v = &out.ctr.values[i];
-		fstring name;
+	status = rpccli_spoolss_EnumPrinterDataEx(cli, mem_ctx,
+						  handle,
+						  key_name,
+						  offered,
+						  count,
+						  info,
+						  &needed,
+						  &werror);
+
+	if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
+		offered = needed;
 
-		rpcstr_pull(name, v->valuename.buffer, sizeof(name), -1, 
-			    STR_TERMINATE);
-		regval_ctr_addvalue(ctr, name, v->type, (const char *)v->data, v->data_len);
+		status = rpccli_spoolss_EnumPrinterDataEx(cli, mem_ctx,
+							  handle,
+							  key_name,
+							  offered,
+							  count,
+							  info,
+							  &needed,
+							  &werror);
 	}
 
-	return out.status;
+	return werror;
 }
-
-/** @} **/
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 6dac397..053f0b2 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -2545,17 +2545,15 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli,
 	WERROR result;
 	uint32 i;
 	const char *printername;
-	const char *keyname = NULL;
 	POLICY_HND hnd;
-	REGVAL_CTR *ctr = NULL;
+	uint32_t count;
+	struct spoolss_PrinterEnumValues *info;
 
 	if (argc != 3) {
 		printf("Usage: %s printername <keyname>\n", argv[0]);
 		return WERR_OK;
 	}
 
-	keyname = argv[2];
-
 	/* Open printer handle */
 
 	RPCCLIENT_PRINTERNAME(printername, cli, argv[1]);
@@ -2564,28 +2562,32 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli,
 					       printername,
 					       SEC_FLAG_MAXIMUM_ALLOWED,
 					       &hnd);
-	if (!W_ERROR_IS_OK(result))
+	if (!W_ERROR_IS_OK(result)) {
 		goto done;
+	}
 
 	/* Enumerate subkeys */
 
-	if ( !(ctr = TALLOC_ZERO_P( mem_ctx, REGVAL_CTR )) )
-		return WERR_NOMEM;
-
-	result = rpccli_spoolss_enumprinterdataex(cli, mem_ctx, &hnd, keyname, ctr);
-
-	if (!W_ERROR_IS_OK(result))
+	result = rpccli_spoolss_enumprinterdataex(cli, mem_ctx,
+						  &hnd,
+						  argv[2],
+						  0,
+						  &count,
+						  &info);
+	if (!W_ERROR_IS_OK(result)) {
 		goto done;
-
-	for (i=0; i < ctr->num_values; i++) {
-		display_reg_value(*(ctr->values[i]));
 	}
 
-	TALLOC_FREE( ctr );
+	for (i=0; i < count; i++) {
+		display_printer_data(info[i].value_name,
+				     info[i].type,
+				     info[i].data);
+	}
 
-done:
-	if (is_valid_policy_hnd(&hnd))
+ done:
+	if (is_valid_policy_hnd(&hnd)) {
 		rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
+	}
 
 	return result;
 }
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index effd236..6c55487 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -866,12 +866,18 @@ static bool net_spoolss_enumprinterdataex(struct rpc_pipe_client *pipe_hnd,
 					uint32 offered,
 					POLICY_HND *hnd,
 					const char *keyname,
-					REGVAL_CTR *ctr)
+					uint32_t *count,
+					struct spoolss_PrinterEnumValues **info)
 {
 	WERROR result;
 
 	/* enumprinterdataex call */
-	result = rpccli_spoolss_enumprinterdataex(pipe_hnd, mem_ctx, hnd, keyname, ctr);
+	result = rpccli_spoolss_enumprinterdataex(pipe_hnd, mem_ctx,
+						  hnd,
+						  keyname,
+						  0, /* offered */
+						  count,
+						  info);
 
 	if (!W_ERROR_IS_OK(result)) {
 		printf("enumprinterdataex failed: %s\n", win_errstr(result));
@@ -2142,7 +2148,6 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
 	union spoolss_PrinterInfo *info_enum;
 	union spoolss_PrinterInfo info_dst_publish;
 	union spoolss_PrinterInfo info_dst;
-	REGVAL_CTR *reg_ctr;
 	struct cli_state *cli_dst = NULL;
 	char *devicename = NULL, *unc_name = NULL, *url = NULL;
 	const char *longname;
@@ -2369,17 +2374,17 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
 		for (i=0; keylist && keylist[i] != NULL; i++) {
 
 			const char *subkey = keylist[i];
-
-			if ( !(reg_ctr = TALLOC_ZERO_P( mem_ctx, REGVAL_CTR )) )
-				return NT_STATUS_NO_MEMORY;
+			uint32_t count;
+			struct spoolss_PrinterEnumValues *info;
 
 			/* enumerate all src subkeys */
 			if (!net_spoolss_enumprinterdataex(pipe_hnd, mem_ctx, 0,
 							   &hnd_src, subkey,
-							   reg_ctr))
+							   &count, &info)) {
 				goto done;
+			}
 
-			for (j=0; j < reg_ctr->num_values; j++) {
+			for (j=0; j < count; j++) {
 
 				REGISTRY_VALUE value;
 				UNISTR2 data;
@@ -2387,20 +2392,20 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
 				/* although samba replies with sane data in most cases we
 				   should try to avoid writing wrong registry data */
 
-				if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_PORTNAME) ||
-				    strequal(reg_ctr->values[j]->valuename, SPOOL_REG_UNCNAME) ||
-				    strequal(reg_ctr->values[j]->valuename, SPOOL_REG_URL) ||
-				    strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SHORTSERVERNAME) ||
-				    strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SERVERNAME)) {
+				if (strequal(info[j].value_name, SPOOL_REG_PORTNAME) ||
+				    strequal(info[j].value_name, SPOOL_REG_UNCNAME) ||
+				    strequal(info[j].value_name, SPOOL_REG_URL) ||
+				    strequal(info[j].value_name, SPOOL_REG_SHORTSERVERNAME) ||
+				    strequal(info[j].value_name, SPOOL_REG_SERVERNAME)) {
 
-					if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_PORTNAME)) {
+					if (strequal(info[j].value_name, SPOOL_REG_PORTNAME)) {
 
 						/* although windows uses a multi-sz, we use a sz */
 						init_unistr2(&data, SAMBA_PRINTER_PORT_NAME, UNI_STR_TERMINATE);
 						fstrcpy(value.valuename, SPOOL_REG_PORTNAME);
 					}
 
-					if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_UNCNAME)) {
+					if (strequal(info[j].value_name, SPOOL_REG_UNCNAME)) {
 
 						if (asprintf(&unc_name, "\\\\%s\\%s", longname, sharename) < 0) {
 							nt_status = NT_STATUS_NO_MEMORY;
@@ -2410,7 +2415,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
 						fstrcpy(value.valuename, SPOOL_REG_UNCNAME);
 					}
 
-					if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_URL)) {
+					if (strequal(info[j].value_name, SPOOL_REG_URL)) {
 
 						continue;
 
@@ -2425,13 +2430,13 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
 #endif
 					}
 
-					if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SERVERNAME)) {
+					if (strequal(info[j].value_name, SPOOL_REG_SERVERNAME)) {
 
 						init_unistr2(&data, longname, UNI_STR_TERMINATE);
 						fstrcpy(value.valuename, SPOOL_REG_SERVERNAME);
 					}
 
-					if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SHORTSERVERNAME)) {
+					if (strequal(info[j].value_name, SPOOL_REG_SHORTSERVERNAME)) {
 
 						init_unistr2(&data, global_myname(), UNI_STR_TERMINATE);
 						fstrcpy(value.valuename, SPOOL_REG_SHORTSERVERNAME);
@@ -2455,22 +2460,37 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
 
 				} else {
 
-					if (c->opt_verbose)
-						display_reg_value(subkey, *(reg_ctr->values[j]));
+					REGISTRY_VALUE v;
+					DATA_BLOB blob;
+
+					result = push_spoolss_PrinterData(mem_ctx, &blob,
+									  info[j].type,
+									  info[j].data);
+					if (!W_ERROR_IS_OK(result)) {
+						goto done;
+					}
+
+					fstrcpy(v.valuename, info[j].value_name);
+					v.type = info[j].type;
+					v.data_p = blob.data;
+					v.size = blob.length;
+
+					if (c->opt_verbose) {
+						display_reg_value(subkey, v);
+					}
 
 					/* here we have to set all subkeys on the dst server */
 					if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
-							subkey, reg_ctr->values[j]))
+							subkey, &v)) {
 						goto done;
+					}
 
 				}
 
 				DEBUGADD(1,("\tSetPrinterDataEx of key [%s\\%s] succeeded\n",
-						subkey, reg_ctr->values[j]->valuename));
+						subkey, info[j].value_name));
 
 			}
-
-			TALLOC_FREE( reg_ctr );
 		}
 
 		TALLOC_FREE(keylist);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list