]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3-rpcclient: fix rpcclient after spoolss_GetPrinterData{Ex} IDL change.
authorGünther Deschner <gd@samba.org>
Thu, 4 Mar 2010 14:46:28 +0000 (15:46 +0100)
committerKarolin Seeger <kseeger@samba.org>
Thu, 11 Mar 2010 09:31:28 +0000 (10:31 +0100)
Guenther

source3/include/proto.h
source3/rpc_client/cli_spoolss.c
source3/rpcclient/cmd_spoolss.c

index b241437503fe6c37b4f69023615f9a57cda825d6..f078844a53f0bf4e806a858bd352ceaab9c16b1c 100644 (file)
@@ -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,
index bc4a4e78ed5cbdf229397c96f71d66eb1d5a34e3..1919da9af3f796a3ae4d9fbfc350fd2c84672cde 100644 (file)
@@ -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;
 }
 
index bd6bde5f17d1f36e5cd53c5a36403d37a2a35c5b..b0d52069fe5ef3d0afe64bf4021829b59e457a48 100644 (file)
@@ -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 <printername> <valuename>\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);