From 8f10a57a445d3b4fea1d7ee09413d0cf8a6a3830 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=BCnther=20Deschner?= Date: Thu, 4 Mar 2010 15:46:28 +0100 Subject: [PATCH] s3-rpcclient: fix rpcclient after spoolss_GetPrinterData{Ex} IDL change. Guenther (cherry picked from commit 7643afa70e879efc059c75b8309bf89dbb3c459b) (cherry picked from commit 6b331e7414c80f8f2bbe4c27b07af9ac27230101) --- source3/include/proto.h | 3 +- source3/rpc_client/cli_spoolss.c | 16 ++++++++-- source3/rpcclient/cmd_spoolss.c | 54 ++++++++++++++++++++++---------- 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 26fbb44f98d..65fd9a819a2 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5567,7 +5567,8 @@ WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli, const char *value_name, uint32_t offered, enum winreg_Type *type, - union spoolss_PrinterData *data); + uint32_t *needed_p, + uint8_t **data_p); WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index d0781a0e650..2ca313d1687 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -765,34 +765,44 @@ WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli, const char *value_name, uint32_t offered, enum winreg_Type *type, - union spoolss_PrinterData *data) + uint32_t *needed_p, + uint8_t **data_p) { NTSTATUS status; WERROR werror; uint32_t needed; + uint8_t *data; + + data = talloc_zero_array(mem_ctx, uint8_t, offered); + W_ERROR_HAVE_NO_MEMORY(data); status = rpccli_spoolss_GetPrinterData(cli, mem_ctx, handle, value_name, - offered, type, data, + offered, &needed, &werror); if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) { offered = needed; + data = talloc_zero_array(mem_ctx, uint8_t, offered); + W_ERROR_HAVE_NO_MEMORY(data); status = rpccli_spoolss_GetPrinterData(cli, mem_ctx, handle, value_name, - offered, type, data, + offered, &needed, &werror); } + *data_p = data; + *needed_p = needed; + return werror; } diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 8b7152152a6..06bbbdf8233 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -749,20 +749,29 @@ static void display_reg_value(struct regval_blob value) static void display_printer_data(const char *v, enum winreg_Type type, - union spoolss_PrinterData *r) + uint8_t *data, + uint32_t length) { int i; + union spoolss_PrinterData r; + DATA_BLOB blob = data_blob_const(data, length); + WERROR result; + + result = pull_spoolss_PrinterData(talloc_tos(), &blob, &r, type); + if (!W_ERROR_IS_OK(result)) { + return; + } switch (type) { case REG_DWORD: - printf("%s: REG_DWORD: 0x%08x\n", v, r->value); + printf("%s: REG_DWORD: 0x%08x\n", v, r.value); break; case REG_SZ: - printf("%s: REG_SZ: %s\n", v, r->string); + printf("%s: REG_SZ: %s\n", v, r.string); break; case REG_BINARY: { char *hex = hex_encode_talloc(NULL, - r->binary.data, r->binary.length); + r.binary.data, r.binary.length); size_t len; printf("%s: REG_BINARY:", v); len = strlen(hex); @@ -781,8 +790,8 @@ static void display_printer_data(const char *v, } case REG_MULTI_SZ: printf("%s: REG_MULTI_SZ: ", v); - for (i=0; r->string_array[i] != NULL; i++) { - printf("%s ", r->string_array[i]); + for (i=0; r.string_array[i] != NULL; i++) { + printf("%s ", r.string_array[i]); } printf("\n"); break; @@ -804,7 +813,8 @@ static WERROR cmd_spoolss_getprinterdata(struct rpc_pipe_client *cli, fstring printername; const char *valuename; enum winreg_Type type; - union spoolss_PrinterData data; + uint8_t *data; + uint32_t needed; if (argc != 3) { printf("Usage: %s \n", argv[0]); @@ -837,13 +847,14 @@ static WERROR cmd_spoolss_getprinterdata(struct rpc_pipe_client *cli, valuename, 0, &type, + &needed, &data); if (!W_ERROR_IS_OK(result)) goto done; /* Display printer data */ - display_printer_data(valuename, type, &data); + display_printer_data(valuename, type, data, needed); done: if (is_valid_policy_hnd(&pol)) @@ -866,7 +877,7 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli, const char *valuename, *keyname; enum winreg_Type type; - union spoolss_PrinterData data; + uint8_t *data = NULL; uint32_t offered = 0; uint32_t needed; @@ -898,24 +909,33 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli, /* Get printer info */ + data = talloc_zero_array(mem_ctx, uint8_t, offered); + if (!data) { + goto done; + } + status = rpccli_spoolss_GetPrinterDataEx(cli, mem_ctx, &pol, keyname, valuename, - offered, &type, - &data, + data, + offered, &needed, &result); if (W_ERROR_EQUAL(result, WERR_MORE_DATA)) { offered = needed; + data = talloc_zero_array(mem_ctx, uint8_t, offered); + if (!data) { + goto done; + } status = rpccli_spoolss_GetPrinterDataEx(cli, mem_ctx, &pol, keyname, valuename, - offered, &type, - &data, + data, + offered, &needed, &result); } @@ -929,7 +949,7 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli, /* Display printer data */ - display_printer_data(valuename, type, &data); + display_printer_data(valuename, type, data, needed); done: @@ -2850,7 +2870,9 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli, const char **argv) { WERROR result; +#if 0 uint32_t i; +#endif const char *printername; struct policy_handle hnd; uint32_t count; @@ -2884,13 +2906,13 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli, if (!W_ERROR_IS_OK(result)) { goto done; } - +#if 0 for (i=0; i < count; i++) { display_printer_data(info[i].value_name, info[i].type, info[i].data); } - +#endif done: if (is_valid_policy_hnd(&hnd)) { rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL); -- 2.34.1