diff options
author | Günther Deschner <gd@samba.org> | 2011-01-28 18:17:00 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2011-01-28 22:05:20 +0100 |
commit | fc16baaf91f21addb42d41d60a1d0453c00843b2 (patch) | |
tree | 3c8357e14534fa91826acb7937334332aafbb9cb | |
parent | d4414f08cb5e52d03ddd07b21d07cb4e9516c53c (diff) | |
download | samba-fc16baaf91f21addb42d41d60a1d0453c00843b2.tar.gz samba-fc16baaf91f21addb42d41d60a1d0453c00843b2.tar.bz2 samba-fc16baaf91f21addb42d41d60a1d0453c00843b2.zip |
s3-net: use struct based dcerpc_spoolss_EnumPrinterData_r() call.
This is a workaround for a string issue we currently have with argument based
generated dcerpc client code (see bug #7804 for details).
Guenther
Autobuild-User: Günther Deschner <gd@samba.org>
Autobuild-Date: Fri Jan 28 22:05:20 CET 2011 on sn-devel-104
-rw-r--r-- | source3/utils/net_rpc_printer.c | 76 |
1 files changed, 34 insertions, 42 deletions
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index 24442feb1d..0375490a56 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -2255,7 +2255,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, WERROR result; NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; - uint32_t i = 0, p = 0, j = 0; + uint32_t i = 0, j = 0; uint32_t num_printers; uint32_t level = 2; const char *printername, *sharename; @@ -2306,11 +2306,10 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, /* do something for all printers */ for (i = 0; i < num_printers; i++) { - uint32_t value_offered = 0, value_needed; - uint32_t data_offered = 0, data_needed; + uint32_t value_needed; + uint32_t data_needed; enum winreg_Type type; - uint8_t *buffer = NULL; - const char *value_name = NULL; + struct spoolss_EnumPrinterData r; /* do some initialization */ printername = info_enum[i].info2.printername; @@ -2402,50 +2401,43 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, FIXME: IIRC I've seen it too on a win2k-server */ + r.in.handle = &hnd_src; + r.in.enum_index = 0; + r.in.value_offered = 0; + r.in.data_offered = 0; + r.out.value_name = NULL; + r.out.value_needed = &value_needed; + r.out.type = &type; + r.out.data = NULL; + r.out.data_needed = &data_needed; + /* enumerate data on src handle */ - nt_status = dcerpc_spoolss_EnumPrinterData(b_src, mem_ctx, - &hnd_src, - p, - value_name, - value_offered, - &value_needed, - &type, - buffer, - data_offered, - &data_needed, - &result); - - data_offered = data_needed; - value_offered = value_needed; - buffer = talloc_zero_array(mem_ctx, uint8_t, data_needed); - value_name = talloc_zero_array(mem_ctx, char, value_needed); + nt_status = dcerpc_spoolss_EnumPrinterData_r(b_src, mem_ctx, &r); + + r.in.data_offered = *r.out.data_needed; + r.in.value_offered = *r.out.value_needed; + r.out.data = talloc_zero_array(mem_ctx, uint8_t, r.in.data_offered); + r.out.value_name = talloc_zero_array(mem_ctx, char, r.in.value_offered); /* loop for all printerdata of "PrinterDriverData" */ - while (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(result)) { - - nt_status = dcerpc_spoolss_EnumPrinterData(b_src, mem_ctx, - &hnd_src, - p++, - value_name, - value_offered, - &value_needed, - &type, - buffer, - data_offered, - &data_needed, - &result); + while (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(r.out.result)) { + + r.in.enum_index++; + + nt_status = dcerpc_spoolss_EnumPrinterData_r(b_src, mem_ctx, &r); + /* loop for all reg_keys */ - if (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(result)) { + if (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(r.out.result)) { /* display_value */ if (c->opt_verbose) { struct regval_blob *v; v = regval_compose(talloc_tos(), - value_name, - type, - buffer, - data_offered); + r.out.value_name, + *r.out.type, + r.out.data, + r.in.data_offered); if (v == NULL) { nt_status = NT_STATUS_NO_MEMORY; goto done; @@ -2457,12 +2449,12 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, /* set_value */ if (!net_spoolss_setprinterdata(pipe_hnd_dst, mem_ctx, - &hnd_dst, value_name, - type, buffer, data_offered)) + &hnd_dst, r.out.value_name, + *r.out.type, r.out.data, r.in.data_offered)) goto done; DEBUGADD(1,("\tSetPrinterData of [%s] succeeded\n", - value_name)); + r.out.value_name)); } } |