The branch, master has been updated
       via  0608d6b... s4-smbtorture: fix spoolss_EnumPrinterKey client in 
RPC-SPOOLSS-WIN.
       via  513d6da... s3-printing: remove duplicate code while cleaning up 
driver structs.
      from  800d6b7... s3-spoolss: move more defines out of nt_printing.h to 
spoolss.idl where they belong.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 0608d6b125d379221bff801a7bcc1c930bb4ed67
Author: Günther Deschner <[email protected]>
Date:   Mon Nov 23 13:35:32 2009 +0100

    s4-smbtorture: fix spoolss_EnumPrinterKey client in RPC-SPOOLSS-WIN.
    
    Guenther

commit 513d6da404fb37f87e5b658198ecfd9e35985353
Author: Günther Deschner <[email protected]>
Date:   Mon Nov 23 12:57:46 2009 +0100

    s3-printing: remove duplicate code while cleaning up driver structs.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source3/printing/nt_printing.c    |  107 +++++++++++++-----------------------
 source4/torture/rpc/spoolss_win.c |   23 +++++++--
 2 files changed, 58 insertions(+), 72 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 8fa29aa..7c449f9 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -1608,10 +1608,17 @@ static uint32 get_correct_cversion(struct pipes_struct 
*p,
        } \
 } while (0);
 
-static WERROR clean_up_driver_struct_level_3(struct pipes_struct *rpc_pipe,
-                                            struct spoolss_AddDriverInfo3 
*driver)
+static WERROR clean_up_driver_struct_level(TALLOC_CTX *mem_ctx,
+                                          struct pipes_struct *rpc_pipe,
+                                          const char *architecture,
+                                          const char **driver_path,
+                                          const char **data_file,
+                                          const char **config_file,
+                                          const char **help_file,
+                                          struct spoolss_StringArray 
*dependent_files,
+                                          uint32_t *version)
 {
-       const char *architecture;
+       const char *short_architecture;
        int i;
        WERROR err;
        char *_p;
@@ -1622,19 +1629,19 @@ static WERROR clean_up_driver_struct_level_3(struct 
pipes_struct *rpc_pipe,
         */
        /* using an intermediate string to not have overlaping memcpy()'s */
 
-       strip_driver_path(driver, driver->driver_path);
-       strip_driver_path(driver, driver->data_file);
-       strip_driver_path(driver, driver->config_file);
-       strip_driver_path(driver, driver->help_file);
+       strip_driver_path(mem_ctx, *driver_path);
+       strip_driver_path(mem_ctx, *data_file);
+       strip_driver_path(mem_ctx, *config_file);
+       strip_driver_path(mem_ctx, *help_file);
 
-       if (driver->dependent_files && driver->dependent_files->string) {
-               for (i=0; driver->dependent_files->string[i]; i++) {
-                       strip_driver_path(driver, 
driver->dependent_files->string[i]);
+       if (dependent_files && dependent_files->string) {
+               for (i=0; dependent_files->string[i]; i++) {
+                       strip_driver_path(mem_ctx, dependent_files->string[i]);
                }
        }
 
-       architecture = get_short_archi(driver->architecture);
-       if (!architecture) {
+       short_architecture = get_short_archi(architecture);
+       if (!short_architecture) {
                return WERR_UNKNOWN_PRINTER_DRIVER;
        }
 
@@ -1650,76 +1657,40 @@ static WERROR clean_up_driver_struct_level_3(struct 
pipes_struct *rpc_pipe,
         *      NT2K: cversion=3
         */
 
-       if ((driver->version = get_correct_cversion(rpc_pipe, architecture,
-                                                    driver->driver_path,
-                                                    &err)) == -1)
+       *version = get_correct_cversion(rpc_pipe, short_architecture,
+                                       *driver_path, &err);
+       if (*version == -1) {
                return err;
-
-       return WERR_OK;
-}
-
-/****************************************************************************
-****************************************************************************/
-static WERROR clean_up_driver_struct_level_6(struct pipes_struct *rpc_pipe,
-                                            struct spoolss_AddDriverInfo6 
*driver)
-{
-       const char *architecture;
-       char *_p;
-       int i;
-       WERROR err;
-
-       /* clean up the driver name.
-        * we can get .\driver.dll
-        * or worse c:\windows\system\driver.dll !
-        */
-       /* using an intermediate string to not have overlaping memcpy()'s */
-
-       strip_driver_path(driver, driver->driver_path);
-       strip_driver_path(driver, driver->data_file);
-       strip_driver_path(driver, driver->config_file);
-       strip_driver_path(driver, driver->help_file);
-
-       if (driver->dependent_files && driver->dependent_files->string) {
-               for (i=0; driver->dependent_files->string[i]; i++) {
-                       strip_driver_path(driver, 
driver->dependent_files->string[i]);
-               }
-       }
-
-       architecture = get_short_archi(driver->architecture);
-       if (!architecture) {
-               return WERR_UNKNOWN_PRINTER_DRIVER;
        }
 
-       /* jfm:7/16/2000 the client always sends the cversion=0.
-        * The server should check which version the driver is by reading
-        * the PE header of driver->driverpath.
-        *
-        * For Windows 95/98 the version is 0 (so the value sent is correct)
-        * For Windows NT (the architecture doesn't matter)
-        *      NT 3.1: cversion=0
-        *      NT 3.5/3.51: cversion=1
-        *      NT 4: cversion=2
-        *      NT2K: cversion=3
-        */
-
-       if ((driver->version = get_correct_cversion(rpc_pipe, architecture,
-                                                   driver->driver_path,
-                                                   &err)) == -1)
-                       return err;
-
        return WERR_OK;
 }
 
 /****************************************************************************
 ****************************************************************************/
+
 WERROR clean_up_driver_struct(struct pipes_struct *rpc_pipe,
                              struct spoolss_AddDriverInfoCtr *r)
 {
        switch (r->level) {
        case 3:
-               return clean_up_driver_struct_level_3(rpc_pipe, r->info.info3);
+               return clean_up_driver_struct_level(r, rpc_pipe,
+                                                   r->info.info3->architecture,
+                                                   &r->info.info3->driver_path,
+                                                   &r->info.info3->data_file,
+                                                   &r->info.info3->config_file,
+                                                   &r->info.info3->help_file,
+                                                   
r->info.info3->dependent_files,
+                                                   &r->info.info3->version);
        case 6:
-               return clean_up_driver_struct_level_6(rpc_pipe, r->info.info6);
+               return clean_up_driver_struct_level(r, rpc_pipe,
+                                                   r->info.info6->architecture,
+                                                   &r->info.info6->driver_path,
+                                                   &r->info.info6->data_file,
+                                                   &r->info.info6->config_file,
+                                                   &r->info.info6->help_file,
+                                                   
r->info.info6->dependent_files,
+                                                   &r->info.info6->version);
        default:
                return WERR_NOT_SUPPORTED;
        }
diff --git a/source4/torture/rpc/spoolss_win.c 
b/source4/torture/rpc/spoolss_win.c
index 2e81139..3a3245d 100644
--- a/source4/torture/rpc/spoolss_win.c
+++ b/source4/torture/rpc/spoolss_win.c
@@ -21,7 +21,9 @@
 #include "includes.h"
 #include "torture/rpc/rpc.h"
 #include "librpc/gen_ndr/ndr_spoolss_c.h"
+#include "librpc/gen_ndr/ndr_misc.h"
 #include "ntvfs/ntvfs.h"
+#include "param/param.h"
 
 struct test_spoolss_win_context {
        /* EnumPrinters */
@@ -174,7 +176,7 @@ static bool test_GetPrinterData(struct torture_context 
*tctx,
        if (W_ERROR_IS_OK(expected_werr)) {
                torture_assert_int_equal(tctx, data.value,
                        expected_value,
-                       "GetPrinterData did not return expected value.");
+                       talloc_asprintf(tctx, "GetPrinterData for %s did not 
return expected value.", value_name));
        }
        return true;
 }
@@ -382,15 +384,17 @@ static bool test_EnumPrinterKey(struct torture_context 
*tctx,
        NTSTATUS status;
        struct spoolss_EnumPrinterKey epk;
        uint32_t needed = 0;
-       const char **key_buffer = NULL;
+       uint16_t *key_buffer;
 
        torture_comment(tctx, "Testing EnumPrinterKey(%s)\n", key);
 
+       key_buffer = talloc_zero_array(tctx, uint16_t, 0);
+
        epk.in.handle = handle;
        epk.in.key_name = talloc_strdup(tctx, key);
        epk.in.offered = 0;
        epk.out.needed = &needed;
-       epk.out.key_buffer = &key_buffer;
+       epk.out.key_buffer = key_buffer;
 
        status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
        torture_assert_ntstatus_ok(tctx, status, "EnumPrinterKey failed");
@@ -398,6 +402,8 @@ static bool test_EnumPrinterKey(struct torture_context 
*tctx,
 
        if (W_ERROR_EQUAL(epk.out.result, WERR_MORE_DATA)) {
                epk.in.offered = needed;
+               key_buffer = talloc_zero_array(tctx, uint16_t, needed/2);
+               epk.out.key_buffer = key_buffer;
                status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
                torture_assert_ntstatus_ok(tctx, status,
                                "EnumPrinterKey failed");
@@ -405,7 +411,16 @@ static bool test_EnumPrinterKey(struct torture_context 
*tctx,
 
        torture_assert_werr_ok(tctx, epk.out.result, "EnumPrinterKey failed");
 
-       ctx->printer_keys = key_buffer;
+       {
+               union winreg_Data data;
+               enum ndr_err_code ndr_err;
+               DATA_BLOB blob = data_blob_const(key_buffer, needed);
+               ndr_err = ndr_pull_union_blob(&blob, tctx, 
lp_iconv_convenience(tctx->lp_ctx),
+                                       &data, REG_MULTI_SZ,
+                                       
(ndr_pull_flags_fn_t)ndr_pull_winreg_Data);
+               torture_assert_ndr_success(tctx, ndr_err, "failed to pull 
REG_MULTI_SZ");
+               ctx->printer_keys = data.string_array;
+       }
 
        return true;
 }


-- 
Samba Shared Repository

Reply via email to