]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3-rpcclient: add cmd_spoolss_get_core_printer_drivers
authorGünther Deschner <gd@samba.org>
Mon, 19 Sep 2016 15:03:44 +0000 (17:03 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 8 Jan 2020 23:51:30 +0000 (23:51 +0000)
Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/rpcclient/cmd_spoolss.c

index 78c381b9a594a23498e98852119c13b92a4306dd..4500ec39f9e50351a5cc8ca593d4ff59a7a4ec97 100644 (file)
@@ -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,