From: Günther Deschner Date: Mon, 19 Sep 2016 15:03:44 +0000 (+0200) Subject: s3-rpcclient: add cmd_spoolss_get_core_printer_drivers X-Git-Tag: ldb-2.1.0~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ceddba1f3b1aad4c2935e5a1207277f591cace8;p=thirdparty%2Fsamba.git s3-rpcclient: add cmd_spoolss_get_core_printer_drivers Guenther Signed-off-by: Guenther Deschner Reviewed-by: Jeremy Allison --- diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 78c381b9a59..4500ec39f9e 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -3926,6 +3926,69 @@ static WERROR cmd_spoolss_play_gdi_script_on_printer_ic(struct rpc_pipe_client * return result; } +static WERROR cmd_spoolss_get_core_printer_drivers(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + NTSTATUS status; + HRESULT result; + struct dcerpc_binding_handle *b = cli->binding_handle; + const char *architecture = SPOOLSS_ARCHITECTURE_x64; + struct spoolss_CorePrinterDriver core_printer_drivers; + DATA_BLOB blob; + bool ok; + int i; + uint32_t count; + const char **array; + + if (argc == 1) { + count = 1; + array = talloc_zero_array(mem_ctx, const char *, count + 1); + if (array == NULL) { + return WERR_NOT_ENOUGH_MEMORY; + } + array[0] = talloc_strdup(array, SPOOLSS_CORE_PRINT_PACKAGE_FILES_XPSDRV); + if (array[0] == NULL) { + return WERR_NOT_ENOUGH_MEMORY; + } + } else { + count = argc -1; + array = talloc_zero_array(mem_ctx, const char *, count + 1); + if (array == NULL) { + return WERR_NOT_ENOUGH_MEMORY; + } + for (i = 0; i < argc - 1; i++) { + array[i] = talloc_strdup(array, argv[i + 1]); + if (array[i] == NULL) { + return WERR_NOT_ENOUGH_MEMORY; + } + } + } + + ok = push_reg_multi_sz(mem_ctx, &blob, array); + if (!ok) { + return WERR_NOT_ENOUGH_MEMORY; + } + + status = dcerpc_spoolss_GetCorePrinterDrivers(b, mem_ctx, + cli->srv_name_slash, + architecture, + blob.length/2, + (uint16_t *)blob.data, + count, + &core_printer_drivers, + &result); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (!HRES_IS_OK(result)) { + return W_ERROR(WIN32_FROM_HRESULT(result)); + } + + return WERR_OK; +} + /* List of commands exported by this module */ struct cmd_set spoolss_commands[] = { @@ -4314,6 +4377,16 @@ struct cmd_set spoolss_commands[] = { .description = "Create Printer IC", .usage = "", }, + { + .name = "getcoreprinterdrivers", + .returntype = RPC_RTYPE_WERROR, + .ntfn = NULL, + .wfn = cmd_spoolss_get_core_printer_drivers, + .table = &ndr_table_spoolss, + .rpc_pipe = NULL, + .description = "Get CorePrinterDriver", + .usage = "", + }, { .name = NULL,