From 1c15a33495643b4b7cd040a7dd92fe085d3b8a31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Tue, 9 Mar 2010 13:01:13 +0100 Subject: [PATCH 01/16] spoolss: rollback SetPrinterData{Ex} IDL. Guenther --- librpc/idl/spoolss.idl | 23 ++++++----------------- librpc/ndr/ndr_spoolss_buf.c | 40 ---------------------------------------- librpc/ndr/ndr_spoolss_buf.h | 1 - 3 files changed, 6 insertions(+), 58 deletions(-) diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl index 0201cba..b06f252 100644 --- a/librpc/idl/spoolss.idl +++ b/librpc/idl/spoolss.idl @@ -1351,23 +1351,12 @@ cpp_quote("#define spoolss_security_descriptor security_descriptor") /******************/ /* Function: 0x1b */ - [noopnum,nopull,noprint,public] WERROR _spoolss_SetPrinterData( + WERROR spoolss_SetPrinterData( [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 value_name[], - [in] winreg_Type type, - [in] DATA_BLOB data, - [in] uint32 _offered - ); - [noopnum,nopull,noprint,public] void __spoolss_SetPrinterData( - [in] winreg_Type type, - [out,ref,switch_is(type)] spoolss_PrinterData *data - ); - [nopush] WERROR spoolss_SetPrinterData( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 value_name[], - [in] winreg_Type type, - [in,subcontext(4),switch_is(type)] spoolss_PrinterData data, - [in,value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] uint32 _offered + [in] [string,charset(UTF16)] uint16 value_name[], + [in] winreg_Type type, + [in,ref] [size_is(offered)] uint8 *data, + [in] uint32 offered ); /******************/ @@ -2252,7 +2241,7 @@ cpp_quote("#define spoolss_security_descriptor security_descriptor") [in] [string,charset(UTF16)] uint16 key_name[], [in] [string,charset(UTF16)] uint16 value_name[], [in] winreg_Type type, - [in,ref] [size_is(offered)] uint8 *buffer, + [in,ref] [size_is(offered)] uint8 *data, [in] uint32 offered ); diff --git a/librpc/ndr/ndr_spoolss_buf.c b/librpc/ndr/ndr_spoolss_buf.c index 2ce3477..7beec3a 100644 --- a/librpc/ndr/ndr_spoolss_buf.c +++ b/librpc/ndr/ndr_spoolss_buf.c @@ -657,46 +657,6 @@ enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flag return NDR_ERR_SUCCESS; } -/* - spoolss_SetPrinterData -*/ -enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r) -{ - struct _spoolss_SetPrinterData _r; - if (flags & NDR_IN) { - struct ndr_push *_ndr_data; - struct __spoolss_SetPrinterData __r; - DATA_BLOB _data_blob_data; - - _ndr_data = ndr_push_init_ctx(ndr, ndr->iconv_convenience); - NDR_ERR_HAVE_NO_MEMORY(_ndr_data); - _ndr_data->flags= ndr->flags; - - __r.in.type = r->in.type; - __r.out.data = discard_const_p(union spoolss_PrinterData, &r->in.data); - NDR_CHECK(ndr_push___spoolss_SetPrinterData(_ndr_data, NDR_OUT, &__r)); - _data_blob_data = ndr_push_blob(_ndr_data); - - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.type = r->in.type; - _r.in.data = _data_blob_data; - _r.in._offered = _data_blob_data.length; - _r.out.result = r->out.result; - NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r)); - } - if (flags & NDR_OUT) { - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.type = r->in.type; - _r.in.data = data_blob(NULL,0), - _r.in._offered = r->in._offered; - _r.out.result = r->out.result; - NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r)); - } - return NDR_ERR_SUCCESS; -} - uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags) { if (!devmode) return 0; diff --git a/librpc/ndr/ndr_spoolss_buf.h b/librpc/ndr/ndr_spoolss_buf.h index e72d16a..b5955dd 100644 --- a/librpc/ndr/ndr_spoolss_buf.h +++ b/librpc/ndr/ndr_spoolss_buf.h @@ -44,7 +44,6 @@ uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx, struct smb uint32_t count, struct spoolss_PrinterEnumValues *info); enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r); enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r); -enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r); uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags); size_t ndr_size_spoolss_StringArray(const struct spoolss_StringArray *r, struct smb_iconv_convenience *ic, int flags); _PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo101(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo101 *r); -- 1.6.6.1 From 7ad9d1c6cc838f1769f562873aefc43c5fd37b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Sat, 5 Dec 2009 00:56:55 +0100 Subject: [PATCH 02/16] s3-spoolss: let _spoolss_SetPrinterData call into _spoolss_SetPrinterDataEx. Guenther (cherry picked from commit 167dca0cbf18baf40dd923f6f92421123d34b5a3) --- source3/rpc_server/srv_spoolss_nt.c | 104 ++++++++++------------------------- 1 files changed, 30 insertions(+), 74 deletions(-) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 266b3ae..6c834be 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8180,81 +8180,16 @@ done: WERROR _spoolss_SetPrinterData(pipes_struct *p, struct spoolss_SetPrinterData *r) { - NT_PRINTER_INFO_LEVEL *printer = NULL; - int snum=0; - WERROR result = WERR_OK; - Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle); - DATA_BLOB blob; - - DEBUG(5,("_spoolss_SetPrinterData\n")); - - if (!Printer) { - DEBUG(2,("_spoolss_SetPrinterData: Invalid handle (%s:%u:%u).\n", - OUR_HANDLE(r->in.handle))); - return WERR_BADFID; - } - - if (Printer->printer_type == SPLHND_SERVER) { - DEBUG(10,("_spoolss_SetPrinterData: " - "Not implemented for server handles yet\n")); - return WERR_INVALID_PARAM; - } - - if (!get_printer_snum(p, r->in.handle, &snum, NULL)) { - return WERR_BADFID; - } - - /* - * Access check : NT returns "access denied" if you make a - * SetPrinterData call without the necessary privildge. - * we were originally returning OK if nothing changed - * which made Win2k issue **a lot** of SetPrinterData - * when connecting to a printer --jerry - */ - - if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { - DEBUG(3,("_spoolss_SetPrinterData: " - "change denied by handle access permissions\n")); - result = WERR_ACCESS_DENIED; - goto done; - } - - result = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); - if (!W_ERROR_IS_OK(result)) { - return result; - } - - result = push_spoolss_PrinterData(p->mem_ctx, &blob, - r->in.type, &r->in.data); - if (!W_ERROR_IS_OK(result)) { - goto done; - } - - /* - * When client side code sets a magic printer data key, detect it and save - * the current printer data and the magic key's data (its the DEVMODE) for - * future printer/driver initializations. - */ - if ((r->in.type == REG_BINARY) && strequal(r->in.value_name, PHANTOM_DEVMODE_KEY)) { - /* Set devmode and printer initialization info */ - result = save_driver_init(printer, 2, blob.data, blob.length); - - srv_spoolss_reset_printerdata(printer->info_2->drivername); + struct spoolss_SetPrinterDataEx r2; - goto done; - } + r2.in.handle = r->in.handle; + r2.in.key_name = "PrinterDriverData"; + r2.in.value_name = r->in.value_name; + r2.in.type = r->in.type; + r2.in.data = r->in.data; + r2.in.offered = r->in.offered; - result = set_printer_dataex(printer, SPOOL_PRINTERDATA_KEY, - r->in.value_name, r->in.type, - blob.data, blob.length); - if (W_ERROR_IS_OK(result)) { - result = mod_a_printer(printer, 2); - } - -done: - free_a_printer(&printer, 2); - - return result; + return _spoolss_SetPrinterDataEx(p, &r2); } /**************************************************************** @@ -9202,6 +9137,7 @@ WERROR _spoolss_SetPrinterDataEx(pipes_struct *p, WERROR result = WERR_OK; Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle); char *oid_string; + DATA_BLOB blob; DEBUG(4,("_spoolss_SetPrinterDataEx\n")); @@ -9251,10 +9187,30 @@ WERROR _spoolss_SetPrinterDataEx(pipes_struct *p, oid_string++; } + result = push_spoolss_PrinterData(p->mem_ctx, &blob, + r->in.type, &r->in.data); + if (!W_ERROR_IS_OK(result)) { + goto done; + } + + /* + * When client side code sets a magic printer data key, detect it and save + * the current printer data and the magic key's data (its the DEVMODE) for + * future printer/driver initializations. + */ + if ((r->in.type == REG_BINARY) && strequal(r->in.value_name, PHANTOM_DEVMODE_KEY)) { + /* Set devmode and printer initialization info */ + result = save_driver_init(printer, 2, blob.data, blob.length); + + srv_spoolss_reset_printerdata(printer->info_2->drivername); + + goto done; + } + /* save the registry data */ result = set_printer_dataex(printer, r->in.key_name, r->in.value_name, - r->in.type, r->in.buffer, r->in.offered); + r->in.type, blob.data, blob.length); if (W_ERROR_IS_OK(result)) { /* save the OID if one was specified */ -- 1.6.6.1 From 4cc4d7450b35be2d36f76fb45cc4305810c88dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Thu, 4 Mar 2010 17:00:34 +0100 Subject: [PATCH 03/16] s3-spoolss: fix _spoolss_SetPrinterData{Ex} after IDL change. Guenther (cherry picked from commit 9a934832797c3e72859770719e05d19a5eefa14d) --- source3/rpc_server/srv_spoolss_nt.c | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6c834be..1b81fa5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -9137,7 +9137,6 @@ WERROR _spoolss_SetPrinterDataEx(pipes_struct *p, WERROR result = WERR_OK; Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle); char *oid_string; - DATA_BLOB blob; DEBUG(4,("_spoolss_SetPrinterDataEx\n")); @@ -9187,12 +9186,6 @@ WERROR _spoolss_SetPrinterDataEx(pipes_struct *p, oid_string++; } - result = push_spoolss_PrinterData(p->mem_ctx, &blob, - r->in.type, &r->in.data); - if (!W_ERROR_IS_OK(result)) { - goto done; - } - /* * When client side code sets a magic printer data key, detect it and save * the current printer data and the magic key's data (its the DEVMODE) for @@ -9200,7 +9193,7 @@ WERROR _spoolss_SetPrinterDataEx(pipes_struct *p, */ if ((r->in.type == REG_BINARY) && strequal(r->in.value_name, PHANTOM_DEVMODE_KEY)) { /* Set devmode and printer initialization info */ - result = save_driver_init(printer, 2, blob.data, blob.length); + result = save_driver_init(printer, 2, r->in.data, r->in.offered); srv_spoolss_reset_printerdata(printer->info_2->drivername); @@ -9210,7 +9203,7 @@ WERROR _spoolss_SetPrinterDataEx(pipes_struct *p, /* save the registry data */ result = set_printer_dataex(printer, r->in.key_name, r->in.value_name, - r->in.type, blob.data, blob.length); + r->in.type, r->in.data, r->in.offered); if (W_ERROR_IS_OK(result)) { /* save the OID if one was specified */ -- 1.6.6.1 From 498440f6275fa6116e2b54957c8c87647ec55153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Thu, 4 Mar 2010 15:34:49 +0100 Subject: [PATCH 04/16] s3-rpcclient: fix rpcclient after spoolss_SetPrinterData{Ex} IDL change. Guenther (cherry picked from commit 4956650369156dfff96ccc827e55697ec642240d) --- source3/rpcclient/cmd_spoolss.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 99bc129..bd6bde5 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -2381,6 +2381,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli, union spoolss_PrinterInfo info; enum winreg_Type type; union spoolss_PrinterData data; + DATA_BLOB blob; /* parse the command arguments */ if (argc < 5) { @@ -2483,12 +2484,17 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli, goto done; } + result = push_spoolss_PrinterData(mem_ctx, &blob, type, &data); + if (!W_ERROR_IS_OK(result)) { + goto done; + } + status = rpccli_spoolss_SetPrinterData(cli, mem_ctx, &pol, argv[3], /* value_name */ type, - data, - 0, /* autocalculated size */ + blob.data, + blob.length, &result); if (!W_ERROR_IS_OK(result)) { printf ("Unable to set [%s=%s]!\n", argv[3], argv[4]); -- 1.6.6.1 From fe9bfd820a67e2cd2d2518741898e22ba749f0db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Thu, 4 Mar 2010 15:34:22 +0100 Subject: [PATCH 05/16] s3-net: fix net after spoolss_SetPrinterData{Ex} IDL change. Guenther --- source3/utils/net_rpc_printer.c | 17 ++++------------- 1 files changed, 4 insertions(+), 13 deletions(-) diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index 21be2f4..70bb5f0 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -812,7 +812,8 @@ static bool net_spoolss_setprinterdata(struct rpc_pipe_client *pipe_hnd, struct policy_handle *hnd, const char *value_name, enum winreg_Type type, - union spoolss_PrinterData data) + uint8_t *data, + uint32_t offered) { WERROR result; NTSTATUS status; @@ -823,7 +824,7 @@ static bool net_spoolss_setprinterdata(struct rpc_pipe_client *pipe_hnd, value_name, type, data, - 0, /* autocalculated */ + offered, &result); if (!W_ERROR_IS_OK(result)) { @@ -2312,8 +2313,6 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, if (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(result)) { REGISTRY_VALUE v; - DATA_BLOB blob; - union spoolss_PrinterData printer_data; /* display_value */ if (c->opt_verbose) { @@ -2324,18 +2323,10 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, display_reg_value(SPOOL_PRINTERDATA_KEY, v); } - result = pull_spoolss_PrinterData(mem_ctx, - &blob, - &printer_data, - type); - if (!W_ERROR_IS_OK(result)) { - goto done; - } - /* set_value */ if (!net_spoolss_setprinterdata(pipe_hnd_dst, mem_ctx, &hnd_dst, value_name, - type, printer_data)) + type, buffer, data_offered)) goto done; DEBUGADD(1,("\tSetPrinterData of [%s] succeeded\n", -- 1.6.6.1 From 2336d294dac58d9cbd3bd602ab47b886f3f6257e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Tue, 9 Mar 2010 13:20:10 +0100 Subject: [PATCH 06/16] spoolss: rollback GetPrinterData{Ex} IDL. Guenther --- librpc/idl/spoolss.idl | 18 +------ librpc/ndr/ndr_spoolss_buf.c | 100 ------------------------------------------ librpc/ndr/ndr_spoolss_buf.h | 2 - 3 files changed, 3 insertions(+), 117 deletions(-) diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl index b06f252..f394176 100644 --- a/librpc/idl/spoolss.idl +++ b/librpc/idl/spoolss.idl @@ -1328,24 +1328,12 @@ cpp_quote("#define spoolss_security_descriptor security_descriptor") [default,flag(NDR_REMAINING)] DATA_BLOB data; } spoolss_PrinterData; - [noopnum,noprint,public] WERROR _spoolss_GetPrinterData( + WERROR spoolss_GetPrinterData( [in,ref] policy_handle *handle, [in] [string,charset(UTF16)] uint16 value_name[], - [in] uint32 offered, [out,ref] winreg_Type *type, - [out,ref] DATA_BLOB *data, - [out,ref] uint32 *needed - ); - [noopnum,noprint,public] void __spoolss_GetPrinterData( - [in] winreg_Type type, - [out,ref,switch_is(type)] spoolss_PrinterData *data - ); - [nopull,nopush,public] WERROR spoolss_GetPrinterData( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 value_name[], + [out,ref] [size_is(offered)] uint8 *data, [in] uint32 offered, - [out,ref] winreg_Type *type, - [out,ref,subcontext(4),subcontext_size(offered),switch_is(*type)] spoolss_PrinterData *data, [out,ref] uint32 *needed ); @@ -2252,7 +2240,7 @@ cpp_quote("#define spoolss_security_descriptor security_descriptor") [in] [string,charset(UTF16)] uint16 key_name[], [in] [string,charset(UTF16)] uint16 value_name[], [out,ref] winreg_Type *type, - [out,ref] [size_is(offered)] uint8 *buffer, + [out,ref] [size_is(offered)] uint8 *data, [in] uint32 offered, [out,ref] uint32 *needed ); diff --git a/librpc/ndr/ndr_spoolss_buf.c b/librpc/ndr/ndr_spoolss_buf.c index 7beec3a..9078c62 100644 --- a/librpc/ndr/ndr_spoolss_buf.c +++ b/librpc/ndr/ndr_spoolss_buf.c @@ -557,106 +557,6 @@ uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx, struct smb NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrinterDataEx); } -/* - spoolss_GetPrinterData -*/ -enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r) -{ - struct _spoolss_GetPrinterData _r; - if (flags & NDR_IN) { - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.offered = r->in.offered; - NDR_CHECK(ndr_push__spoolss_GetPrinterData(ndr, flags, &_r)); - } - if (flags & NDR_OUT) { - struct ndr_push *_ndr_info; - DATA_BLOB blob = data_blob(NULL, 0); - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.offered = r->in.offered; - _r.out.type = r->out.type; - _r.out.data = &blob; - _r.out.needed = r->out.needed; - _r.out.result = r->out.result; - { - struct __spoolss_GetPrinterData __r; - DATA_BLOB _blob; - _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience); - NDR_ERR_HAVE_NO_MEMORY(_ndr_info); - _ndr_info->flags= ndr->flags; - __r.in.type = *r->out.type; - __r.out.data = r->out.data; - NDR_CHECK(ndr_push___spoolss_GetPrinterData(_ndr_info, flags, &__r)); - if (r->in.offered > _ndr_info->offset) { - uint32_t _padding_len = r->in.offered - _ndr_info->offset; - NDR_CHECK(ndr_push_zero(_ndr_info, _padding_len)); - } - _blob = ndr_push_blob(_ndr_info); - _r.out.data = &_blob; - } - NDR_CHECK(ndr_push__spoolss_GetPrinterData(ndr, flags, &_r)); - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r) -{ - struct _spoolss_GetPrinterData _r; - if (flags & NDR_IN) { - DATA_BLOB blob = data_blob(NULL,0); - ZERO_STRUCT(r->out); - - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.offered = r->in.offered; - _r.out.type = r->out.type; - _r.out.data = &blob; - _r.out.needed = r->out.needed; - NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r)); - r->in.handle = _r.in.handle; - r->in.value_name= _r.in.value_name; - r->in.offered = _r.in.offered; - r->out.needed = _r.out.needed; - } - if (flags & NDR_OUT) { - DATA_BLOB blob = data_blob_talloc(ndr,NULL,0); - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.offered = r->in.offered; - _r.out.type = r->out.type; - _r.out.data = &blob; - _r.out.needed = r->out.needed; - _r.out.result = r->out.result; - NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r)); - r->out.type = _r.out.type; - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.data); - } - ZERO_STRUCTP(r->out.data); - r->out.needed = _r.out.needed; - r->out.result = _r.out.result; - if (_r.out.data && _r.out.data->length != r->in.offered) { - return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, - "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of out buffer[%u]", - (unsigned)r->in.offered, (unsigned)_r.out.data->length); - } - if (_r.out.data && _r.out.data->length > 0 && *r->out.needed <= _r.out.data->length) { - struct __spoolss_GetPrinterData __r; - struct ndr_pull *_ndr_data = ndr_pull_init_blob(_r.out.data, ndr, ndr->iconv_convenience); - NDR_ERR_HAVE_NO_MEMORY(_ndr_data); - _ndr_data->flags= ndr->flags; - __r.in.type = *r->out.type; - __r.out.data = r->out.data; - NDR_CHECK(ndr_pull___spoolss_GetPrinterData(_ndr_data, flags, &__r)); - r->out.data = __r.out.data; - } else { - *r->out.type = REG_NONE; - } - } - return NDR_ERR_SUCCESS; -} - uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags) { if (!devmode) return 0; diff --git a/librpc/ndr/ndr_spoolss_buf.h b/librpc/ndr/ndr_spoolss_buf.h index b5955dd..b102080 100644 --- a/librpc/ndr/ndr_spoolss_buf.h +++ b/librpc/ndr/ndr_spoolss_buf.h @@ -42,8 +42,6 @@ enum ndr_err_code ndr_push_spoolss_EnumPrinterDataEx(struct ndr_push *ndr, int f enum ndr_err_code ndr_pull_spoolss_EnumPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDataEx *r); uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t count, struct spoolss_PrinterEnumValues *info); -enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r); -enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r); uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags); size_t ndr_size_spoolss_StringArray(const struct spoolss_StringArray *r, struct smb_iconv_convenience *ic, int flags); _PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo101(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo101 *r); -- 1.6.6.1 From 0ec3e84fb369faec2124c3681f145200bb4095bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Sat, 5 Dec 2009 00:52:28 +0100 Subject: [PATCH 07/16] s3-spoolss: let _spoolss_GetPrinterData call into _spoolss_GetPrinterDataEx. Guenther --- source3/rpc_server/srv_spoolss_nt.c | 145 +++++++++++------------------------ 1 files changed, 44 insertions(+), 101 deletions(-) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1b81fa5..74e07b0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2490,6 +2490,8 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx, return WERR_OK; } + *type = REG_NONE; + return WERR_INVALID_PARAM; } @@ -2500,92 +2502,17 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx, WERROR _spoolss_GetPrinterData(pipes_struct *p, struct spoolss_GetPrinterData *r) { - WERROR result; - Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle); - NT_PRINTER_INFO_LEVEL *printer = NULL; - int snum = 0; - - /* - * Reminder: when it's a string, the length is in BYTES - * even if UNICODE is negociated. - * - * JFM, 4/19/1999 - */ - - /* in case of problem, return some default values */ - - *r->out.needed = 0; - *r->out.type = 0; - - DEBUG(4,("_spoolss_GetPrinterData\n")); - - if (!Printer) { - DEBUG(2,("_spoolss_GetPrinterData: Invalid handle (%s:%u:%u).\n", - OUR_HANDLE(r->in.handle))); - result = WERR_BADFID; - goto done; - } - - if (Printer->printer_type == SPLHND_SERVER) { - result = getprinterdata_printer_server(p->mem_ctx, - r->in.value_name, - r->out.type, - r->out.data); - } else { - if (!get_printer_snum(p, r->in.handle, &snum, NULL)) { - result = WERR_BADFID; - goto done; - } - - result = get_a_printer(Printer, &printer, 2, lp_servicename(snum)); - if (!W_ERROR_IS_OK(result)) { - goto done; - } - - /* XP sends this and wants to change id value from the PRINTER_INFO_0 */ - - if (strequal(r->in.value_name, "ChangeId")) { - *r->out.type = REG_DWORD; - r->out.data->value = printer->info_2->changeid; - result = WERR_OK; - } else { - REGISTRY_VALUE *v; - DATA_BLOB blob; - - v = get_printer_data(printer->info_2, - SPOOL_PRINTERDATA_KEY, - r->in.value_name); - if (!v) { - result = WERR_BADFILE; - goto done; - } - - *r->out.type = v->type; - - blob = data_blob_const(v->data_p, v->size); - - result = pull_spoolss_PrinterData(p->mem_ctx, &blob, - r->out.data, - *r->out.type); - } - } - - done: - /* cleanup & exit */ + struct spoolss_GetPrinterDataEx r2; - if (printer) { - free_a_printer(&printer, 2); - } - - if (!W_ERROR_IS_OK(result)) { - return result; - } - - *r->out.needed = ndr_size_spoolss_PrinterData(r->out.data, *r->out.type, NULL, 0); - *r->out.type = SPOOLSS_BUFFER_OK(*r->out.type, REG_NONE); - r->out.data = SPOOLSS_BUFFER_OK(r->out.data, r->out.data); + r2.in.handle = r->in.handle; + r2.in.key_name = "PrinterDriverData"; + r2.in.value_name = r->in.value_name; + r2.in.offered = r->in.offered; + r2.out.type = r->out.type; + r2.out.data = r->out.data; + r2.out.needed = r->out.needed; - return SPOOLSS_BUFFER_OK(WERR_OK, WERR_MORE_DATA); + return _spoolss_GetPrinterDataEx(p, &r2); } /********************************************************* @@ -9034,9 +8961,6 @@ WERROR _spoolss_GetJob(pipes_struct *p, /**************************************************************** _spoolss_GetPrinterDataEx - - From MSDN documentation of GetPrinterDataEx: pass request - to GetPrinterData if key is "PrinterDriverData". ****************************************************************/ WERROR _spoolss_GetPrinterDataEx(pipes_struct *p, @@ -9048,6 +8972,7 @@ WERROR _spoolss_GetPrinterDataEx(pipes_struct *p, NT_PRINTER_INFO_LEVEL *printer = NULL; int snum = 0; WERROR result = WERR_OK; + DATA_BLOB blob; DEBUG(4,("_spoolss_GetPrinterDataEx\n")); @@ -9069,14 +8994,17 @@ WERROR _spoolss_GetPrinterDataEx(pipes_struct *p, /* Is the handle to a printer or to the server? */ if (Printer->printer_type == SPLHND_SERVER) { - DEBUG(10,("_spoolss_GetPrinterDataEx: " - "Not implemented for server handles yet\n")); - result = WERR_INVALID_PARAM; + + result = getprinterdata_printer_server(p->mem_ctx, + r->in.value_name, + r->out.type, + r->out.data); goto done; } if (!get_printer_snum(p, r->in.handle, &snum, NULL)) { - return WERR_BADFID; + result = WERR_BADFID; + goto done; } result = get_a_printer(Printer, &printer, 2, lp_servicename(snum)); @@ -9090,6 +9018,17 @@ WERROR _spoolss_GetPrinterDataEx(pipes_struct *p, goto done; } + /* XP sends this and wants to change id value from the PRINTER_INFO_0 */ + + if (strequal(r->in.key_name, SPOOL_PRINTERDATA_KEY) && + strequal(r->in.value_name, "ChangeId")) { + *r->out.type = REG_DWORD; + *r->out.needed = 4; + r->out.data->value = printer->info_2->changeid; + result = WERR_OK; + goto done; + } + if (lookup_printerkey(printer->info_2->data, r->in.key_name) == -1) { DEBUG(4,("_spoolss_GetPrinterDataEx: " "Invalid keyname [%s]\n", r->in.key_name )); @@ -9097,8 +9036,6 @@ WERROR _spoolss_GetPrinterDataEx(pipes_struct *p, goto done; } - /* When given a new keyname, we should just create it */ - val = get_printer_data(printer->info_2, r->in.key_name, r->in.value_name); if (!val) { @@ -9107,22 +9044,28 @@ WERROR _spoolss_GetPrinterDataEx(pipes_struct *p, } *r->out.needed = regval_size(val); - - if (*r->out.needed > r->in.offered) { - result = WERR_MORE_DATA; - goto done; - } - *r->out.type = regval_type(val); - memcpy(r->out.buffer, regval_data_p(val), regval_size(val)); + blob = data_blob_const(regval_data_p(val), regval_size(val)); + + result = pull_spoolss_PrinterData(p->mem_ctx, &blob, + r->out.data, + *r->out.type); done: if (printer) { free_a_printer(&printer, 2); } - return result; + if (!W_ERROR_IS_OK(result)) { + return result; + } + + *r->out.needed = ndr_size_spoolss_PrinterData(r->out.data, *r->out.type, NULL, 0); + *r->out.type = SPOOLSS_BUFFER_OK(*r->out.type, REG_NONE); + r->out.data = SPOOLSS_BUFFER_OK(r->out.data, r->out.data); + + return SPOOLSS_BUFFER_OK(WERR_OK, WERR_MORE_DATA); } /**************************************************************** -- 1.6.6.1 From 204fee74aecda9be145eae79f7be84100cf3776d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Thu, 4 Mar 2010 15:39:59 +0100 Subject: [PATCH 08/16] s3-spoolss: fix _spoolss_GetPrinterDataEx after IDL change. Guenther (cherry picked from commit fbb6d00eed6bca960aa53a5967a2dea426cacfe2) --- source3/rpc_server/srv_spoolss_nt.c | 38 ++++++++++++++++++++++++---------- 1 files changed, 27 insertions(+), 11 deletions(-) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 74e07b0..052e406 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8995,11 +8995,29 @@ WERROR _spoolss_GetPrinterDataEx(pipes_struct *p, if (Printer->printer_type == SPLHND_SERVER) { + union spoolss_PrinterData data; + result = getprinterdata_printer_server(p->mem_ctx, r->in.value_name, r->out.type, - r->out.data); - goto done; + &data); + if (!W_ERROR_IS_OK(result)) { + goto done; + } + + result = push_spoolss_PrinterData(p->mem_ctx, &blob, + *r->out.type, &data); + if (!W_ERROR_IS_OK(result)) { + goto done; + } + + *r->out.needed = blob.length; + + if (r->in.offered >= *r->out.needed) { + memcpy(r->out.data, blob.data, blob.length); + } + + return SPOOLSS_BUFFER_OK(WERR_OK, WERR_MORE_DATA); } if (!get_printer_snum(p, r->in.handle, &snum, NULL)) { @@ -9024,8 +9042,10 @@ WERROR _spoolss_GetPrinterDataEx(pipes_struct *p, strequal(r->in.value_name, "ChangeId")) { *r->out.type = REG_DWORD; *r->out.needed = 4; - r->out.data->value = printer->info_2->changeid; - result = WERR_OK; + if (r->in.offered >= *r->out.needed) { + SIVAL(r->out.data, 0, printer->info_2->changeid); + result = WERR_OK; + } goto done; } @@ -9046,12 +9066,9 @@ WERROR _spoolss_GetPrinterDataEx(pipes_struct *p, *r->out.needed = regval_size(val); *r->out.type = regval_type(val); - blob = data_blob_const(regval_data_p(val), regval_size(val)); - - result = pull_spoolss_PrinterData(p->mem_ctx, &blob, - r->out.data, - *r->out.type); - + if (r->in.offered >= *r->out.needed) { + memcpy(r->out.data, regval_data_p(val), regval_size(val)); + } done: if (printer) { free_a_printer(&printer, 2); @@ -9061,7 +9078,6 @@ WERROR _spoolss_GetPrinterDataEx(pipes_struct *p, return result; } - *r->out.needed = ndr_size_spoolss_PrinterData(r->out.data, *r->out.type, NULL, 0); *r->out.type = SPOOLSS_BUFFER_OK(*r->out.type, REG_NONE); r->out.data = SPOOLSS_BUFFER_OK(r->out.data, r->out.data); -- 1.6.6.1 From 7803fa72c1c556b83c181855294d43c1a390fe6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Thu, 4 Mar 2010 15:46:28 +0100 Subject: [PATCH 09/16] s3-rpcclient: fix rpcclient after spoolss_GetPrinterData{Ex} IDL change. Guenther --- source3/include/proto.h | 3 +- source3/rpc_client/cli_spoolss.c | 16 ++++++++-- source3/rpcclient/cmd_spoolss.c | 57 ++++++++++++++++++++++++-------------- 3 files changed, 51 insertions(+), 25 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index b241437..f078844 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5557,7 +5557,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 bc4a4e7..1919da9 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -715,34 +715,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 bd6bde5..b0d5206 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -751,20 +751,29 @@ static void display_reg_value(REGISTRY_VALUE 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); @@ -783,8 +792,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; @@ -806,7 +815,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]); @@ -839,13 +849,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,10 +877,9 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli, NTSTATUS status; fstring printername; const char *valuename, *keyname; - REGISTRY_VALUE value; enum winreg_Type type; - uint8_t *buffer = NULL; + uint8_t *data = NULL; uint32_t offered = 0; uint32_t needed; @@ -901,24 +911,32 @@ 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, &type, - buffer, + data, offered, &needed, &result); if (W_ERROR_EQUAL(result, WERR_MORE_DATA)) { offered = needed; - buffer = talloc_array(mem_ctx, uint8_t, needed); + data = talloc_zero_array(mem_ctx, uint8_t, offered); + if (!data) { + goto done; + } status = rpccli_spoolss_GetPrinterDataEx(cli, mem_ctx, &pol, keyname, valuename, &type, - buffer, + data, offered, &needed, &result); @@ -938,12 +956,7 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli, /* Display printer data */ - fstrcpy(value.valuename, valuename); - value.type = type; - value.size = needed; - value.data_p = buffer; - - display_reg_value(value); + display_printer_data(valuename, type, data, needed); done: if (is_valid_policy_hnd(&pol)) @@ -2863,7 +2876,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; @@ -2897,13 +2912,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); -- 1.6.6.1 From 6e104b91af1017488e12721ed238c58dcc39304c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Thu, 4 Mar 2010 16:40:31 +0100 Subject: [PATCH 10/16] spoolss: fix spoolss_EnumPrinterDataEx IDL. Guenther (cherry picked from commit 4df1047e8398a9af4df94c7e245d993d1f60ef5f) --- librpc/idl/spoolss.idl | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl index f394176..ee3a891 100644 --- a/librpc/idl/spoolss.idl +++ b/librpc/idl/spoolss.idl @@ -2252,8 +2252,8 @@ cpp_quote("#define spoolss_security_descriptor security_descriptor") [relative] nstring *value_name; [value(2*strlen_m_term(value_name))] uint32 value_name_len; winreg_Type type; - [relative,switch_is(type),subcontext(0),subcontext_size(r->data_length)] spoolss_PrinterData *data; - [value(ndr_size_spoolss_PrinterData(data, type, ndr->iconv_convenience, ndr->flags))] uint32 data_length; + [relative,subcontext(0),subcontext_size(data_length),flag(NDR_REMAINING)] DATA_BLOB *data; + [value(data->length)] uint32 data_length; } spoolss_PrinterEnumValues; [public,noopnum,noprint] WERROR _spoolss_EnumPrinterDataEx( -- 1.6.6.1 From eec2fd4692a7e97bc97ece1cf000da11ca21c029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Thu, 4 Mar 2010 16:47:33 +0100 Subject: [PATCH 11/16] s3-spoolss: fix _spoolss_EnumPrinterDataEx after idl Guenther (cherry picked from commit 55326549852a3ab1114a8cb1536578ae02183eb8) --- source3/rpc_server/srv_spoolss_nt.c | 13 ++----------- 1 files changed, 2 insertions(+), 11 deletions(-) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 052e406..5eaa51c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -9400,9 +9400,7 @@ static WERROR registry_value_to_printer_enum_value(TALLOC_CTX *mem_ctx, REGISTRY_VALUE *v, struct spoolss_PrinterEnumValues *r) { - WERROR result; - - r->data = TALLOC_ZERO_P(mem_ctx, union spoolss_PrinterData); + r->data = TALLOC_ZERO_P(mem_ctx, DATA_BLOB); W_ERROR_HAVE_NO_MEMORY(r->data); r->value_name = talloc_strdup(mem_ctx, regval_name(v)); @@ -9412,14 +9410,7 @@ static WERROR registry_value_to_printer_enum_value(TALLOC_CTX *mem_ctx, r->data_length = regval_size(v); if (r->data_length) { - DATA_BLOB blob = data_blob_const(regval_data_p(v), - regval_size(v)); - result = pull_spoolss_PrinterData(mem_ctx, &blob, - r->data, - r->type); - if (!W_ERROR_IS_OK(result)) { - return result; - } + *r->data = data_blob_talloc(r->data, regval_data_p(v), regval_size(v)); } return WERR_OK; -- 1.6.6.1 From 2b2b3ea029d29ed2d89f0858890c2cdacd07f6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Thu, 4 Mar 2010 16:46:53 +0100 Subject: [PATCH 12/16] s3-net: fix net after spoolss_EnumPrinterDataEx IDL change. Guenther (cherry picked from commit a99ac4f236d9a93d4ca8bd874cbab89b155c644a) --- source3/utils/net_rpc_printer.c | 12 ++---------- 1 files changed, 2 insertions(+), 10 deletions(-) diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index 70bb5f0..16a9b07 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -2444,19 +2444,11 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, } else { 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; + v.data_p = info[j].data->data; + v.size = info[j].data->length; if (c->opt_verbose) { display_reg_value(subkey, v); -- 1.6.6.1 From 4908b759b941dbbdc78165b54d94b096633272c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Thu, 4 Mar 2010 16:47:10 +0100 Subject: [PATCH 13/16] s3-rpcclient: fix rpcclient after spoolss_EnumPrinterDataEx IDL change. Guenther (cherry picked from commit becbb624eb90b84ff20b128de1aee5f5acfc3dbc) --- source3/rpcclient/cmd_spoolss.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index b0d5206..3d078d7 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -2876,9 +2876,7 @@ 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; @@ -2912,13 +2910,14 @@ 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); + info[i].data->data, + info[i].data->length); } -#endif + done: if (is_valid_policy_hnd(&hnd)) { rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL); -- 1.6.6.1 From 3c7bcf38b03cb529a55411a29a2a156daace1cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Thu, 4 Mar 2010 17:58:49 +0100 Subject: [PATCH 14/16] s3-libads: fix get_remote_printer_publishing_data after spoolss_EnumPrinterDataEx IDL change. Guenther --- source3/libads/ldap_printer.c | 40 ++++++++++++++-------------------------- 1 files changed, 14 insertions(+), 26 deletions(-) diff --git a/source3/libads/ldap_printer.c b/source3/libads/ldap_printer.c index 7fec58c..13be6a6 100644 --- a/source3/libads/ldap_printer.c +++ b/source3/libads/ldap_printer.c @@ -345,19 +345,13 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli, /* Have the data we need now, so start building */ for (i=0; i < count; i++) { REGISTRY_VALUE v; - DATA_BLOB blob; - - result = push_spoolss_PrinterData(mem_ctx, &blob, - info[i].type, - info[i].data); - if (W_ERROR_IS_OK(result)) { - fstrcpy(v.valuename, info[i].value_name); - v.type = info[i].type; - v.data_p = blob.data; - v.size = blob.length; - - map_regval_to_ads(mem_ctx, mods, &v); - } + + fstrcpy(v.valuename, info[i].value_name); + v.type = info[i].type; + v.data_p = info[i].data->data; + v.size = info[i].data->length; + + map_regval_to_ads(mem_ctx, mods, &v); } } @@ -372,19 +366,13 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli, } else { for (i=0; i < count; i++) { REGISTRY_VALUE v; - DATA_BLOB blob = data_blob_null; - - result = push_spoolss_PrinterData(mem_ctx, &blob, - info[i].type, - info[i].data); - if (W_ERROR_IS_OK(result)) { - fstrcpy(v.valuename, info[i].value_name); - v.type = info[i].type; - v.data_p = blob.data; - v.size = blob.length; - - map_regval_to_ads(mem_ctx, mods, &v); - } + + fstrcpy(v.valuename, info[i].value_name); + v.type = info[i].type; + v.data_p = info[i].data->data; + v.size = info[i].data->length; + + map_regval_to_ads(mem_ctx, mods, &v); } } -- 1.6.6.1 From 2bdb128d102ec84652203ebe31dbde503bd4eeb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Mon, 7 Dec 2009 11:28:56 +0100 Subject: [PATCH 15/16] s3-spoolss: let _spoolss_DeletePrinterData call into _spoolss_DeletePrinterDataEx. Guenther (cherry picked from commit ef9d6580efc55ee040458b7cd76ebdc2e1276e98) --- source3/rpc_server/srv_spoolss_nt.c | 43 ++++------------------------------ 1 files changed, 5 insertions(+), 38 deletions(-) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5eaa51c..c1bffa2 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8158,46 +8158,13 @@ WERROR _spoolss_ResetPrinter(pipes_struct *p, WERROR _spoolss_DeletePrinterData(pipes_struct *p, struct spoolss_DeletePrinterData *r) { - NT_PRINTER_INFO_LEVEL *printer = NULL; - int snum=0; - WERROR status = WERR_OK; - Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle); - - DEBUG(5,("_spoolss_DeletePrinterData\n")); - - if (!Printer) { - DEBUG(2,("_spoolss_DeletePrinterData: Invalid handle (%s:%u:%u).\n", - OUR_HANDLE(r->in.handle))); - return WERR_BADFID; - } - - if (!get_printer_snum(p, r->in.handle, &snum, NULL)) - return WERR_BADFID; - - if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { - DEBUG(3, ("_spoolss_DeletePrinterData: " - "printer properties change denied by handle\n")); - return WERR_ACCESS_DENIED; - } + struct spoolss_DeletePrinterDataEx r2; - status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); - if (!W_ERROR_IS_OK(status)) - return status; - - if (!r->in.value_name) { - free_a_printer(&printer, 2); - return WERR_NOMEM; - } - - status = delete_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, - r->in.value_name ); - - if ( W_ERROR_IS_OK(status) ) - mod_a_printer( printer, 2 ); - - free_a_printer(&printer, 2); + r2.in.handle = r->in.handle; + r2.in.key_name = "PrinterDriverData"; + r2.in.value_name = r->in.value_name; - return status; + return _spoolss_DeletePrinterDataEx(p, &r2); } /**************************************************************** -- 1.6.6.1 From 2a151c065fe4cae628f87d77ea9c8d77bbc48ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Tue, 9 Mar 2010 14:08:57 +0100 Subject: [PATCH 16/16] s3: re-run make samba3-idl. Guenther --- librpc/gen_ndr/cli_spoolss.c | 20 ++-- librpc/gen_ndr/cli_spoolss.h | 12 +- librpc/gen_ndr/ndr_spoolss.c | 235 ++++++++++++++++++----------------------- librpc/gen_ndr/ndr_spoolss.h | 15 --- librpc/gen_ndr/spoolss.h | 71 ++------------ librpc/gen_ndr/srv_spoolss.c | 12 +- 6 files changed, 132 insertions(+), 233 deletions(-) diff --git a/librpc/gen_ndr/cli_spoolss.c b/librpc/gen_ndr/cli_spoolss.c index 10dd8b4..8820971 100644 --- a/librpc/gen_ndr/cli_spoolss.c +++ b/librpc/gen_ndr/cli_spoolss.c @@ -1301,9 +1301,9 @@ NTSTATUS rpccli_spoolss_GetPrinterData(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle /* [in] [ref] */, const char *value_name /* [in] [charset(UTF16)] */, - uint32_t offered /* [in] */, enum winreg_Type *type /* [out] [ref] */, - union spoolss_PrinterData *data /* [out] [subcontext_size(offered),ref,subcontext(4),switch_is(*type)] */, + uint8_t *data /* [out] [ref,size_is(offered)] */, + uint32_t offered /* [in] */, uint32_t *needed /* [out] [ref] */, WERROR *werror) { @@ -1339,7 +1339,7 @@ NTSTATUS rpccli_spoolss_GetPrinterData(struct rpc_pipe_client *cli, /* Return variables */ *type = *r.out.type; - *data = *r.out.data; + memcpy(data, r.out.data, (r.in.offered) * sizeof(*data)); *needed = *r.out.needed; /* Return result */ @@ -1355,8 +1355,8 @@ NTSTATUS rpccli_spoolss_SetPrinterData(struct rpc_pipe_client *cli, struct policy_handle *handle /* [in] [ref] */, const char *value_name /* [in] [charset(UTF16)] */, enum winreg_Type type /* [in] */, - union spoolss_PrinterData data /* [in] [subcontext(4),switch_is(type)] */, - uint32_t _offered /* [in] [value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] */, + uint8_t *data /* [in] [ref,size_is(offered)] */, + uint32_t offered /* [in] */, WERROR *werror) { struct spoolss_SetPrinterData r; @@ -1367,7 +1367,7 @@ NTSTATUS rpccli_spoolss_SetPrinterData(struct rpc_pipe_client *cli, r.in.value_name = value_name; r.in.type = type; r.in.data = data; - r.in._offered = _offered; + r.in.offered = offered; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(spoolss_SetPrinterData, &r); @@ -3652,7 +3652,7 @@ NTSTATUS rpccli_spoolss_SetPrinterDataEx(struct rpc_pipe_client *cli, const char *key_name /* [in] [charset(UTF16)] */, const char *value_name /* [in] [charset(UTF16)] */, enum winreg_Type type /* [in] */, - uint8_t *buffer /* [in] [ref,size_is(offered)] */, + uint8_t *data /* [in] [ref,size_is(offered)] */, uint32_t offered /* [in] */, WERROR *werror) { @@ -3664,7 +3664,7 @@ NTSTATUS rpccli_spoolss_SetPrinterDataEx(struct rpc_pipe_client *cli, r.in.key_name = key_name; r.in.value_name = value_name; r.in.type = type; - r.in.buffer = buffer; + r.in.data = data; r.in.offered = offered; if (DEBUGLEVEL >= 10) { @@ -3705,7 +3705,7 @@ NTSTATUS rpccli_spoolss_GetPrinterDataEx(struct rpc_pipe_client *cli, const char *key_name /* [in] [charset(UTF16)] */, const char *value_name /* [in] [charset(UTF16)] */, enum winreg_Type *type /* [out] [ref] */, - uint8_t *buffer /* [out] [ref,size_is(offered)] */, + uint8_t *data /* [out] [ref,size_is(offered)] */, uint32_t offered /* [in] */, uint32_t *needed /* [out] [ref] */, WERROR *werror) @@ -3743,7 +3743,7 @@ NTSTATUS rpccli_spoolss_GetPrinterDataEx(struct rpc_pipe_client *cli, /* Return variables */ *type = *r.out.type; - memcpy(buffer, r.out.buffer, (r.in.offered) * sizeof(*buffer)); + memcpy(data, r.out.data, (r.in.offered) * sizeof(*data)); *needed = *r.out.needed; /* Return result */ diff --git a/librpc/gen_ndr/cli_spoolss.h b/librpc/gen_ndr/cli_spoolss.h index eb1e8dd..0ee28e5 100644 --- a/librpc/gen_ndr/cli_spoolss.h +++ b/librpc/gen_ndr/cli_spoolss.h @@ -190,9 +190,9 @@ NTSTATUS rpccli_spoolss_GetPrinterData(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle /* [in] [ref] */, const char *value_name /* [in] [charset(UTF16)] */, - uint32_t offered /* [in] */, enum winreg_Type *type /* [out] [ref] */, - union spoolss_PrinterData *data /* [out] [subcontext_size(offered),ref,subcontext(4),switch_is(*type)] */, + uint8_t *data /* [out] [ref,size_is(offered)] */, + uint32_t offered /* [in] */, uint32_t *needed /* [out] [ref] */, WERROR *werror); NTSTATUS rpccli_spoolss_SetPrinterData(struct rpc_pipe_client *cli, @@ -200,8 +200,8 @@ NTSTATUS rpccli_spoolss_SetPrinterData(struct rpc_pipe_client *cli, struct policy_handle *handle /* [in] [ref] */, const char *value_name /* [in] [charset(UTF16)] */, enum winreg_Type type /* [in] */, - union spoolss_PrinterData data /* [in] [subcontext(4),switch_is(type)] */, - uint32_t _offered /* [in] [value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] */, + uint8_t *data /* [in] [ref,size_is(offered)] */, + uint32_t offered /* [in] */, WERROR *werror); NTSTATUS rpccli_spoolss_WaitForPrinterChange(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, @@ -471,7 +471,7 @@ NTSTATUS rpccli_spoolss_SetPrinterDataEx(struct rpc_pipe_client *cli, const char *key_name /* [in] [charset(UTF16)] */, const char *value_name /* [in] [charset(UTF16)] */, enum winreg_Type type /* [in] */, - uint8_t *buffer /* [in] [ref,size_is(offered)] */, + uint8_t *data /* [in] [ref,size_is(offered)] */, uint32_t offered /* [in] */, WERROR *werror); NTSTATUS rpccli_spoolss_GetPrinterDataEx(struct rpc_pipe_client *cli, @@ -480,7 +480,7 @@ NTSTATUS rpccli_spoolss_GetPrinterDataEx(struct rpc_pipe_client *cli, const char *key_name /* [in] [charset(UTF16)] */, const char *value_name /* [in] [charset(UTF16)] */, enum winreg_Type *type /* [out] [ref] */, - uint8_t *buffer /* [out] [ref,size_is(offered)] */, + uint8_t *data /* [out] [ref,size_is(offered)] */, uint32_t offered /* [in] */, uint32_t *needed /* [out] [ref] */, WERROR *werror); diff --git a/librpc/gen_ndr/ndr_spoolss.c b/librpc/gen_ndr/ndr_spoolss.c index cca1b12..59d987f 100644 --- a/librpc/gen_ndr/ndr_spoolss.c +++ b/librpc/gen_ndr/ndr_spoolss.c @@ -18650,8 +18650,13 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrinterEnumValues(struct ndr_push *n } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2 * strlen_m_term(r->value_name))); NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, r->type)); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->data)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_spoolss_PrinterData(r->data, r->type, ndr->iconv_convenience, ndr->flags))); + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->data)); + ndr->flags = _flags_save_DATA_BLOB; + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->data->length)); } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, r)); @@ -18665,16 +18670,20 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrinterEnumValues(struct ndr_push *n } ndr->flags = _flags_save_string; } - if (r->data) { - NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->data)); - { - struct ndr_push *_ndr_data; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_data, 0, r->data_length)); - NDR_CHECK(ndr_push_set_switch_value(_ndr_data, r->data, r->type)); - NDR_CHECK(ndr_push_spoolss_PrinterData(_ndr_data, NDR_SCALARS|NDR_BUFFERS, r->data)); - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_data, 0, r->data_length)); + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + if (r->data) { + NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->data)); + { + struct ndr_push *_ndr_data; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_data, 0, r->data->length)); + NDR_CHECK(ndr_push_DATA_BLOB(_ndr_data, NDR_SCALARS, *r->data)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_data, 0, r->data->length)); + } + NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->data)); } - NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->data)); + ndr->flags = _flags_save_DATA_BLOB; } } ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset); @@ -18705,12 +18714,17 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrinterEnumValues(struct ndr_pull *n } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->value_name_len)); NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, &r->type)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data)); - if (_ptr_data) { - NDR_PULL_ALLOC(ndr, r->data); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->data, _ptr_data)); - } else { - r->data = NULL; + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data)); + if (_ptr_data) { + NDR_PULL_ALLOC(ndr, r->data); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->data, _ptr_data)); + } else { + r->data = NULL; + } + ndr->flags = _flags_save_DATA_BLOB; } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->data_length)); } @@ -18731,21 +18745,25 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrinterEnumValues(struct ndr_pull *n } ndr->flags = _flags_save_string; } - if (r->data) { - uint32_t _relative_save_offset; - _relative_save_offset = ndr->offset; - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->data)); - _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->data, 0); - { - struct ndr_pull *_ndr_data; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_data, 0, r->data_length)); - NDR_CHECK(ndr_pull_set_switch_value(_ndr_data, r->data, r->type)); - NDR_CHECK(ndr_pull_spoolss_PrinterData(_ndr_data, NDR_SCALARS|NDR_BUFFERS, r->data)); - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_data, 0, r->data_length)); + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + if (r->data) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->data)); + _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->data, 0); + { + struct ndr_pull *_ndr_data; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_data, 0, r->data_length)); + NDR_CHECK(ndr_pull_DATA_BLOB(_ndr_data, NDR_SCALARS, r->data)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_data, 0, r->data_length)); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0); + ndr->offset = _relative_save_offset; } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0); - ndr->offset = _relative_save_offset; + ndr->flags = _flags_save_DATA_BLOB; } } ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset); @@ -18767,11 +18785,10 @@ _PUBLIC_ void ndr_print_spoolss_PrinterEnumValues(struct ndr_print *ndr, const c ndr_print_ptr(ndr, "data", r->data); ndr->depth++; if (r->data) { - ndr_print_set_switch_value(ndr, r->data, r->type); - ndr_print_spoolss_PrinterData(ndr, "data", r->data); + ndr_print_DATA_BLOB(ndr, "data", *r->data); } ndr->depth--; - ndr_print_uint32(ndr, "data_length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_spoolss_PrinterData(r->data, r->type, ndr->iconv_convenience, ndr->flags):r->data_length); + ndr_print_uint32(ndr, "data_length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?r->data->length:r->data_length); ndr->depth--; } @@ -22235,7 +22252,7 @@ _PUBLIC_ void ndr_print_spoolss_ScheduleJob(struct ndr_print *ndr, const char *n ndr->depth--; } -_PUBLIC_ enum ndr_err_code ndr_push__spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct _spoolss_GetPrinterData *r) +static enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { @@ -22256,7 +22273,8 @@ _PUBLIC_ enum ndr_err_code ndr_push__spoolss_GetPrinterData(struct ndr_push *ndr if (r->out.data == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.data)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->out.data, r->in.offered)); if (r->out.needed == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -22266,11 +22284,10 @@ _PUBLIC_ enum ndr_err_code ndr_push__spoolss_GetPrinterData(struct ndr_push *ndr return NDR_ERR_SUCCESS; } -_PUBLIC_ enum ndr_err_code ndr_pull__spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct _spoolss_GetPrinterData *r) +static enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r) { TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_type_0; - TALLOC_CTX *_mem_save_data_0; TALLOC_CTX *_mem_save_needed_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -22292,8 +22309,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull__spoolss_GetPrinterData(struct ndr_pull *ndr NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); NDR_PULL_ALLOC(ndr, r->out.type); ZERO_STRUCTP(r->out.type); - NDR_PULL_ALLOC(ndr, r->out.data); - ZERO_STRUCTP(r->out.data); + NDR_PULL_ALLOC_N(ndr, r->out.data, r->in.offered); + memset(r->out.data, 0, (r->in.offered) * sizeof(*r->out.data)); NDR_PULL_ALLOC(ndr, r->out.needed); ZERO_STRUCTP(r->out.needed); } @@ -22305,13 +22322,11 @@ _PUBLIC_ enum ndr_err_code ndr_pull__spoolss_GetPrinterData(struct ndr_pull *ndr NDR_PULL_SET_MEM_CTX(ndr, r->out.type, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, r->out.type)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_type_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->out.data)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.data); + NDR_PULL_ALLOC_N(ndr, r->out.data, ndr_get_array_size(ndr, &r->out.data)); } - _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.data, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.data)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->out.data, ndr_get_array_size(ndr, &r->out.data))); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.needed); } @@ -22320,44 +22335,9 @@ _PUBLIC_ enum ndr_err_code ndr_pull__spoolss_GetPrinterData(struct ndr_pull *ndr NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.needed)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_needed_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_push___spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct __spoolss_GetPrinterData *r) -{ - if (flags & NDR_IN) { - NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, r->in.type)); - } - if (flags & NDR_OUT) { - if (r->out.data == NULL) { - return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); - } - NDR_CHECK(ndr_push_set_switch_value(ndr, r->out.data, r->in.type)); - NDR_CHECK(ndr_push_spoolss_PrinterData(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.data)); - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull___spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct __spoolss_GetPrinterData *r) -{ - TALLOC_CTX *_mem_save_data_0; - if (flags & NDR_IN) { - ZERO_STRUCT(r->out); - - NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, &r->in.type)); - NDR_PULL_ALLOC(ndr, r->out.data); - ZERO_STRUCTP(r->out.data); - } - if (flags & NDR_OUT) { - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.data); + if (r->out.data) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->out.data, r->in.offered)); } - _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.data, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_set_switch_value(ndr, r->out.data, r->in.type)); - NDR_CHECK(ndr_pull_spoolss_PrinterData(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.data)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, LIBNDR_FLAG_REF_ALLOC); } return NDR_ERR_SUCCESS; } @@ -22389,8 +22369,7 @@ _PUBLIC_ void ndr_print_spoolss_GetPrinterData(struct ndr_print *ndr, const char ndr->depth--; ndr_print_ptr(ndr, "data", r->out.data); ndr->depth++; - ndr_print_set_switch_value(ndr, r->out.data, *r->out.type); - ndr_print_spoolss_PrinterData(ndr, "data", r->out.data); + ndr_print_array_uint8(ndr, "data", r->out.data, r->in.offered); ndr->depth--; ndr_print_ptr(ndr, "needed", r->out.needed); ndr->depth++; @@ -22402,7 +22381,7 @@ _PUBLIC_ void ndr_print_spoolss_GetPrinterData(struct ndr_print *ndr, const char ndr->depth--; } -_PUBLIC_ enum ndr_err_code ndr_push__spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct _spoolss_SetPrinterData *r) +static enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { @@ -22414,8 +22393,12 @@ _PUBLIC_ enum ndr_err_code ndr_push__spoolss_SetPrinterData(struct ndr_push *ndr NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.value_name, ndr_charset_length(r->in.value_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, r->in.type)); - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->in.data)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in._offered)); + if (r->in.data == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->in.data, r->in.offered)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); @@ -22423,21 +22406,6 @@ _PUBLIC_ enum ndr_err_code ndr_push__spoolss_SetPrinterData(struct ndr_push *ndr return NDR_ERR_SUCCESS; } -_PUBLIC_ enum ndr_err_code ndr_push___spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct __spoolss_SetPrinterData *r) -{ - if (flags & NDR_IN) { - NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, r->in.type)); - } - if (flags & NDR_OUT) { - if (r->out.data == NULL) { - return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); - } - NDR_CHECK(ndr_push_set_switch_value(ndr, r->out.data, r->in.type)); - NDR_CHECK(ndr_push_spoolss_PrinterData(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.data)); - } - return NDR_ERR_SUCCESS; -} - static enum ndr_err_code ndr_pull_spoolss_SetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_SetPrinterData *r) { TALLOC_CTX *_mem_save_handle_0; @@ -22457,14 +22425,15 @@ static enum ndr_err_code ndr_pull_spoolss_SetPrinterData(struct ndr_pull *ndr, i NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t))); NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.value_name, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t), CH_UTF16)); NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, &r->in.type)); - { - struct ndr_pull *_ndr_data; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_data, 4, -1)); - NDR_CHECK(ndr_pull_set_switch_value(_ndr_data, &r->in.data, r->in.type)); - NDR_CHECK(ndr_pull_spoolss_PrinterData(_ndr_data, NDR_SCALARS|NDR_BUFFERS, &r->in.data)); - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_data, 4, -1)); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.data)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC_N(ndr, r->in.data, ndr_get_array_size(ndr, &r->in.data)); + } + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->in.data, ndr_get_array_size(ndr, &r->in.data))); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + if (r->in.data) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->in.data, r->in.offered)); } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in._offered)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); @@ -22488,9 +22457,11 @@ _PUBLIC_ void ndr_print_spoolss_SetPrinterData(struct ndr_print *ndr, const char ndr->depth--; ndr_print_string(ndr, "value_name", r->in.value_name); ndr_print_winreg_Type(ndr, "type", r->in.type); - ndr_print_set_switch_value(ndr, &r->in.data, r->in.type); - ndr_print_spoolss_PrinterData(ndr, "data", &r->in.data); - ndr_print_uint32(ndr, "_offered", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_spoolss_PrinterData(&r->in.data, r->in.type, ndr->iconv_convenience, flags):r->in._offered); + ndr_print_ptr(ndr, "data", r->in.data); + ndr->depth++; + ndr_print_array_uint8(ndr, "data", r->in.data, r->in.offered); + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); ndr->depth--; } if (flags & NDR_OUT) { @@ -26571,11 +26542,11 @@ static enum ndr_err_code ndr_push_spoolss_SetPrinterDataEx(struct ndr_push *ndr, NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.value_name, ndr_charset_length(r->in.value_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, r->in.type)); - if (r->in.buffer == NULL) { + if (r->in.data == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); - NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->in.buffer, r->in.offered)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->in.data, r->in.offered)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); } if (flags & NDR_OUT) { @@ -26610,14 +26581,14 @@ static enum ndr_err_code ndr_pull_spoolss_SetPrinterDataEx(struct ndr_pull *ndr, NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t))); NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.value_name, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t), CH_UTF16)); NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, &r->in.type)); - NDR_CHECK(ndr_pull_array_size(ndr, &r->in.buffer)); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.data)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC_N(ndr, r->in.buffer, ndr_get_array_size(ndr, &r->in.buffer)); + NDR_PULL_ALLOC_N(ndr, r->in.data, ndr_get_array_size(ndr, &r->in.data)); } - NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->in.buffer, ndr_get_array_size(ndr, &r->in.buffer))); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->in.data, ndr_get_array_size(ndr, &r->in.data))); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); - if (r->in.buffer) { - NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->in.buffer, r->in.offered)); + if (r->in.data) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->in.data, r->in.offered)); } } if (flags & NDR_OUT) { @@ -26643,9 +26614,9 @@ _PUBLIC_ void ndr_print_spoolss_SetPrinterDataEx(struct ndr_print *ndr, const ch ndr_print_string(ndr, "key_name", r->in.key_name); ndr_print_string(ndr, "value_name", r->in.value_name); ndr_print_winreg_Type(ndr, "type", r->in.type); - ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr_print_ptr(ndr, "data", r->in.data); ndr->depth++; - ndr_print_array_uint8(ndr, "buffer", r->in.buffer, r->in.offered); + ndr_print_array_uint8(ndr, "data", r->in.data, r->in.offered); ndr->depth--; ndr_print_uint32(ndr, "offered", r->in.offered); ndr->depth--; @@ -26681,11 +26652,11 @@ static enum ndr_err_code ndr_push_spoolss_GetPrinterDataEx(struct ndr_push *ndr, return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, *r->out.type)); - if (r->out.buffer == NULL) { + if (r->out.data == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); - NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->out.buffer, r->in.offered)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->out.data, r->in.offered)); if (r->out.needed == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -26727,8 +26698,8 @@ static enum ndr_err_code ndr_pull_spoolss_GetPrinterDataEx(struct ndr_pull *ndr, NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); NDR_PULL_ALLOC(ndr, r->out.type); ZERO_STRUCTP(r->out.type); - NDR_PULL_ALLOC_N(ndr, r->out.buffer, r->in.offered); - memset(r->out.buffer, 0, (r->in.offered) * sizeof(*r->out.buffer)); + NDR_PULL_ALLOC_N(ndr, r->out.data, r->in.offered); + memset(r->out.data, 0, (r->in.offered) * sizeof(*r->out.data)); NDR_PULL_ALLOC(ndr, r->out.needed); ZERO_STRUCTP(r->out.needed); } @@ -26740,11 +26711,11 @@ static enum ndr_err_code ndr_pull_spoolss_GetPrinterDataEx(struct ndr_pull *ndr, NDR_PULL_SET_MEM_CTX(ndr, r->out.type, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, r->out.type)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_type_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_array_size(ndr, &r->out.buffer)); + NDR_CHECK(ndr_pull_array_size(ndr, &r->out.data)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC_N(ndr, r->out.buffer, ndr_get_array_size(ndr, &r->out.buffer)); + NDR_PULL_ALLOC_N(ndr, r->out.data, ndr_get_array_size(ndr, &r->out.data)); } - NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->out.buffer, ndr_get_array_size(ndr, &r->out.buffer))); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->out.data, ndr_get_array_size(ndr, &r->out.data))); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.needed); } @@ -26753,8 +26724,8 @@ static enum ndr_err_code ndr_pull_spoolss_GetPrinterDataEx(struct ndr_pull *ndr, NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.needed)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_needed_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); - if (r->out.buffer) { - NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->out.buffer, r->in.offered)); + if (r->out.data) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->out.data, r->in.offered)); } } return NDR_ERR_SUCCESS; @@ -26786,9 +26757,9 @@ _PUBLIC_ void ndr_print_spoolss_GetPrinterDataEx(struct ndr_print *ndr, const ch ndr->depth++; ndr_print_winreg_Type(ndr, "type", *r->out.type); ndr->depth--; - ndr_print_ptr(ndr, "buffer", r->out.buffer); + ndr_print_ptr(ndr, "data", r->out.data); ndr->depth++; - ndr_print_array_uint8(ndr, "buffer", r->out.buffer, r->in.offered); + ndr_print_array_uint8(ndr, "data", r->out.data, r->in.offered); ndr->depth--; ndr_print_ptr(ndr, "needed", r->out.needed); ndr->depth++; diff --git a/librpc/gen_ndr/ndr_spoolss.h b/librpc/gen_ndr/ndr_spoolss.h index 00f89b6..288ef3c 100644 --- a/librpc/gen_ndr/ndr_spoolss.h +++ b/librpc/gen_ndr/ndr_spoolss.h @@ -563,22 +563,7 @@ void ndr_print_spoolss_ReadPrinter(struct ndr_print *ndr, const char *name, int void ndr_print_spoolss_EndDocPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EndDocPrinter *r); void ndr_print_spoolss_AddJob(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddJob *r); void ndr_print_spoolss_ScheduleJob(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ScheduleJob *r); -enum ndr_err_code ndr_push__spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct _spoolss_GetPrinterData *r); -enum ndr_err_code ndr_pull__spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct _spoolss_GetPrinterData *r); -void ndr_print__spoolss_GetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_GetPrinterData *r); -enum ndr_err_code ndr_push___spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct __spoolss_GetPrinterData *r); -enum ndr_err_code ndr_pull___spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct __spoolss_GetPrinterData *r); -void ndr_print___spoolss_GetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_GetPrinterData *r); -enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r); -enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r); void ndr_print_spoolss_GetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterData *r); -enum ndr_err_code ndr_push__spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct _spoolss_SetPrinterData *r); -enum ndr_err_code ndr_pull__spoolss_SetPrinterData(struct ndr_pull *ndr, int flags, struct _spoolss_SetPrinterData *r); -void ndr_print__spoolss_SetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_SetPrinterData *r); -enum ndr_err_code ndr_push___spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct __spoolss_SetPrinterData *r); -enum ndr_err_code ndr_pull___spoolss_SetPrinterData(struct ndr_pull *ndr, int flags, struct __spoolss_SetPrinterData *r); -void ndr_print___spoolss_SetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_SetPrinterData *r); -enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r); void ndr_print_spoolss_SetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SetPrinterData *r); void ndr_print_spoolss_WaitForPrinterChange(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_WaitForPrinterChange *r); enum ndr_err_code ndr_push_spoolss_ClosePrinter(struct ndr_push *ndr, int flags, const struct spoolss_ClosePrinter *r); diff --git a/librpc/gen_ndr/spoolss.h b/librpc/gen_ndr/spoolss.h index a2487b2..04bdbcc 100644 --- a/librpc/gen_ndr/spoolss.h +++ b/librpc/gen_ndr/spoolss.h @@ -1560,8 +1560,8 @@ struct spoolss_PrinterEnumValues { const char * value_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */ uint32_t value_name_len;/* [value(2*strlen_m_term(value_name))] */ enum winreg_Type type; - union spoolss_PrinterData *data;/* [relative,subcontext_size(r->data_length),subcontext(0),switch_is(type)] */ - uint32_t data_length;/* [value(ndr_size_spoolss_PrinterData(data,type,ndr->iconv_convenience,ndr->flags))] */ + DATA_BLOB *data;/* [relative,subcontext_size(data_length),subcontext(0),flag(LIBNDR_FLAG_REMAINING)] */ + uint32_t data_length;/* [value(data->length)] */ }/* [relative_base,gensize,public] */; union spoolss_KeyNames { @@ -2153,35 +2153,6 @@ struct spoolss_ScheduleJob { }; -struct _spoolss_GetPrinterData { - struct { - struct policy_handle *handle;/* [ref] */ - const char *value_name;/* [charset(UTF16)] */ - uint32_t offered; - } in; - - struct { - enum winreg_Type *type;/* [ref] */ - DATA_BLOB *data;/* [ref] */ - uint32_t *needed;/* [ref] */ - WERROR result; - } out; - -}; - - -struct __spoolss_GetPrinterData { - struct { - enum winreg_Type type; - } in; - - struct { - union spoolss_PrinterData *data;/* [ref,switch_is(type)] */ - } out; - -}; - - struct spoolss_GetPrinterData { struct { struct policy_handle *handle;/* [ref] */ @@ -2191,7 +2162,7 @@ struct spoolss_GetPrinterData { struct { enum winreg_Type *type;/* [ref] */ - union spoolss_PrinterData *data;/* [subcontext_size(offered),ref,subcontext(4),switch_is(*type)] */ + uint8_t *data;/* [ref,size_is(offered)] */ uint32_t *needed;/* [ref] */ WERROR result; } out; @@ -2199,41 +2170,13 @@ struct spoolss_GetPrinterData { }; -struct _spoolss_SetPrinterData { - struct { - struct policy_handle *handle;/* [ref] */ - const char *value_name;/* [charset(UTF16)] */ - enum winreg_Type type; - DATA_BLOB data; - uint32_t _offered; - } in; - - struct { - WERROR result; - } out; - -}; - - -struct __spoolss_SetPrinterData { - struct { - enum winreg_Type type; - } in; - - struct { - union spoolss_PrinterData *data;/* [ref,switch_is(type)] */ - } out; - -}; - - struct spoolss_SetPrinterData { struct { struct policy_handle *handle;/* [ref] */ const char *value_name;/* [charset(UTF16)] */ enum winreg_Type type; - union spoolss_PrinterData data;/* [subcontext(4),switch_is(type)] */ - uint32_t _offered;/* [value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] */ + uint8_t *data;/* [ref,size_is(offered)] */ + uint32_t offered; } in; struct { @@ -2952,7 +2895,7 @@ struct spoolss_SetPrinterDataEx { const char *key_name;/* [charset(UTF16)] */ const char *value_name;/* [charset(UTF16)] */ enum winreg_Type type; - uint8_t *buffer;/* [ref,size_is(offered)] */ + uint8_t *data;/* [ref,size_is(offered)] */ uint32_t offered; } in; @@ -2973,7 +2916,7 @@ struct spoolss_GetPrinterDataEx { struct { enum winreg_Type *type;/* [ref] */ - uint8_t *buffer;/* [ref,size_is(offered)] */ + uint8_t *data;/* [ref,size_is(offered)] */ uint32_t *needed;/* [ref] */ WERROR result; } out; diff --git a/librpc/gen_ndr/srv_spoolss.c b/librpc/gen_ndr/srv_spoolss.c index 9e58eb5..3cfe40c 100644 --- a/librpc/gen_ndr/srv_spoolss.c +++ b/librpc/gen_ndr/srv_spoolss.c @@ -2119,7 +2119,7 @@ static bool api_spoolss_GetPrinterData(pipes_struct *p) return false; } - r->out.data = talloc_zero(r, union spoolss_PrinterData); + r->out.data = talloc_zero_array(r, uint8_t, r->in.offered); if (r->out.data == NULL) { talloc_free(r); return false; @@ -6118,8 +6118,8 @@ static bool api_spoolss_GetPrinterDataEx(pipes_struct *p) return false; } - r->out.buffer = talloc_zero_array(r, uint8_t, r->in.offered); - if (r->out.buffer == NULL) { + r->out.data = talloc_zero_array(r, uint8_t, r->in.offered); + if (r->out.data == NULL) { talloc_free(r); return false; } @@ -7882,7 +7882,7 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - r->out.data = talloc_zero(mem_ctx, union spoolss_PrinterData); + r->out.data = talloc_zero_array(mem_ctx, uint8_t, r->in.offered); if (r->out.data == NULL) { return NT_STATUS_NO_MEMORY; } @@ -8366,8 +8366,8 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - r->out.buffer = talloc_zero_array(mem_ctx, uint8_t, r->in.offered); - if (r->out.buffer == NULL) { + r->out.data = talloc_zero_array(mem_ctx, uint8_t, r->in.offered); + if (r->out.data == NULL) { return NT_STATUS_NO_MEMORY; } -- 1.6.6.1