summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2013-01-23 09:31:01 +0100
committerAndreas Schneider <asn@samba.org>2013-01-24 17:42:26 +0100
commit21aa7fe633d2360d529e93b5599988eabff1d7d1 (patch)
treec8231d24e61671b13ad0bc9600766a3de755eb80
parent0364658632f8a68537bd3e7c99ecca4c5c968455 (diff)
downloadsamba-21aa7fe633d2360d529e93b5599988eabff1d7d1.tar.gz
samba-21aa7fe633d2360d529e93b5599988eabff1d7d1.tar.bz2
samba-21aa7fe633d2360d529e93b5599988eabff1d7d1.zip
s3-rpcclient: add cmd_spoolss_play_gdi_script_on_printer_ic.
Guenther Signed-off-by: Günther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
-rw-r--r--source3/rpcclient/cmd_spoolss.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 35fbb9b8af..5c499d4638 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -3733,6 +3733,108 @@ static WERROR cmd_spoolss_create_printer_ic(struct rpc_pipe_client *cli,
return result;
}
+static WERROR cmd_spoolss_play_gdi_script_on_printer_ic(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ WERROR result;
+ NTSTATUS status;
+ struct policy_handle handle, gdi_handle;
+ const char *printername;
+ struct spoolss_DevmodeContainer devmode_ctr;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
+ DATA_BLOB in,out;
+ uint32_t count = 0;
+
+ RPCCLIENT_PRINTERNAME(printername, cli, argv[1]);
+
+ result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+ printername,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &handle);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
+ ZERO_STRUCT(devmode_ctr);
+
+ status = dcerpc_spoolss_CreatePrinterIC(b, mem_ctx,
+ &handle,
+ &gdi_handle,
+ &devmode_ctr,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
+ goto done;
+ }
+ if (!W_ERROR_IS_OK(result)) {
+ goto done;
+ }
+
+ in = data_blob_string_const("");
+ out = data_blob_talloc_zero(mem_ctx, 4);
+
+ status = dcerpc_spoolss_PlayGDIScriptOnPrinterIC(b, mem_ctx,
+ &gdi_handle,
+ in.data,
+ in.length,
+ out.data,
+ out.length,
+ 0, /* ul */
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
+ goto done;
+ }
+ if (!W_ERROR_IS_OK(result)) {
+ goto done;
+ }
+
+ count = IVAL(out.data, 0);
+
+ out = data_blob_talloc_zero(mem_ctx,
+ count * sizeof(struct UNIVERSAL_FONT_ID) + 4);
+
+ status = dcerpc_spoolss_PlayGDIScriptOnPrinterIC(b, mem_ctx,
+ &gdi_handle,
+ in.data,
+ in.length,
+ out.data,
+ out.length,
+ 0, /* ul */
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
+ goto done;
+ }
+ if (!W_ERROR_IS_OK(result)) {
+ goto done;
+ }
+
+ {
+ enum ndr_err_code ndr_err;
+ struct UNIVERSAL_FONT_ID_ctr r;
+
+ ndr_err = ndr_pull_struct_blob(&out, mem_ctx, &r,
+ (ndr_pull_flags_fn_t)ndr_pull_UNIVERSAL_FONT_ID_ctr);
+ if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ NDR_PRINT_DEBUG(UNIVERSAL_FONT_ID_ctr, &r);
+ }
+ }
+
+ done:
+ if (is_valid_policy_hnd(&gdi_handle)) {
+ WERROR _result;
+ dcerpc_spoolss_DeletePrinterIC(b, mem_ctx, &gdi_handle, &_result);
+ }
+ if (is_valid_policy_hnd(&handle)) {
+ WERROR _result;
+ dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result);
+ }
+
+ return result;
+}
+
/* List of commands exported by this module */
struct cmd_set spoolss_commands[] = {
@@ -3774,6 +3876,7 @@ struct cmd_set spoolss_commands[] = {
{ "enumprocdatatypes", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_proc_data_types, &ndr_table_spoolss, NULL, "Enumerate Print Processor Data Types", "" },
{ "enummonitors", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_monitors, &ndr_table_spoolss, NULL, "Enumerate Print Monitors", "" },
{ "createprinteric", RPC_RTYPE_WERROR, NULL, cmd_spoolss_create_printer_ic, &ndr_table_spoolss, NULL, "Create Printer IC", "" },
+ { "playgdiscriptonprinteric", RPC_RTYPE_WERROR, NULL, cmd_spoolss_play_gdi_script_on_printer_ic, &ndr_table_spoolss, NULL, "Create Printer IC", "" },
{ NULL }
};