From: Justin Stephenson Date: Wed, 15 Aug 2018 15:10:21 +0000 (-0400) Subject: iremotewinspool-tests: Allow modification of OS client version information X-Git-Tag: tdb-1.3.17~1674 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4fc0602d975277287ef5257929dff49d21b05adc;p=thirdparty%2Fsamba.git iremotewinspool-tests: Allow modification of OS client version information Add test_get_client_info() function to set and, or modify the client OS version values advertised in the iremotewinspool torture tests. The OS build numbers are used from the table in: [MS-RPRN] <168> Section 2.2.3.10.1 Signed-off-by: Justin Stephenson Reviewed-by: Jeremy Allison Reviewed-by: Andreas Schneider --- diff --git a/source4/torture/rpc/iremotewinspool.c b/source4/torture/rpc/iremotewinspool.c index d419e9c082b..d80f2f74c65 100644 --- a/source4/torture/rpc/iremotewinspool.c +++ b/source4/torture/rpc/iremotewinspool.c @@ -33,31 +33,77 @@ struct test_iremotewinspool_context { const char *environment; }; +enum client_os_version +{ + WIN_2000, + WIN_VISTA, + WIN_SERVER_2008, + WIN_7, + WIN_SERVER_2008R2, + WIN_8, + WIN_SERVER_2012, + WIN_10, + WIN_SERVER_2016 +}; + +static struct spoolss_UserLevel1 test_get_client_info(struct torture_context *tctx, + enum client_os_version os, + enum spoolss_MajorVersion major_number, + enum spoolss_MinorVersion minor_number) +{ + struct spoolss_UserLevel1 level1; + + level1.size = 28; + level1.client = talloc_asprintf(tctx, "\\\\%s", "mthelena"); + level1.user = "GD"; + level1.processor = PROCESSOR_ARCHITECTURE_AMD64; + level1.major = major_number; + level1.minor = minor_number; + + switch (os) { + case WIN_SERVER_2016: + case WIN_10: + level1.build = 10586; + break; + case WIN_SERVER_2012: + case WIN_8: + level1.build = 9200; + break; + case WIN_SERVER_2008R2: + case WIN_7: + level1.build = 7007; + break; + case WIN_SERVER_2008: + case WIN_VISTA: + level1.build = 6000; + break; + case WIN_2000: + level1.build = 1382; + break; + default: + level1.build = 7007; + } + + return level1; +} + static bool test_AsyncOpenPrinter_byprinter(struct torture_context *tctx, struct test_iremotewinspool_context *ctx, struct dcerpc_pipe *p, const char *printer_name, + struct spoolss_UserLevel1 cinfo, struct policy_handle *handle) { struct dcerpc_binding_handle *b = p->binding_handle; struct spoolss_DevmodeContainer devmode_ctr; struct spoolss_UserLevelCtr client_info_ctr; - struct spoolss_UserLevel1 level1; uint32_t access_mask = SERVER_ALL_ACCESS; struct winspool_AsyncOpenPrinter r; ZERO_STRUCT(devmode_ctr); - level1.size = 28; - level1.client = talloc_asprintf(tctx, "\\\\%s", "mthelena"); - level1.user = "GD"; - level1.build = 1381; - level1.major = 3; - level1.minor = 0; - level1.processor = PROCESSOR_ARCHITECTURE_AMD64; - client_info_ctr.level = 1; - client_info_ctr.user_info.level1 = &level1; + client_info_ctr.user_info.level1 = &cinfo; r.in.pPrinterName = printer_name; r.in.pDatatype = NULL; @@ -196,6 +242,7 @@ static bool torture_rpc_iremotewinspool_setup_common(struct torture_context *tct struct test_iremotewinspool_context *t) { const char *printer_name; + struct spoolss_UserLevel1 client_info; struct dcerpc_binding *binding; torture_assert_ntstatus_ok(tctx, @@ -216,10 +263,12 @@ static bool torture_rpc_iremotewinspool_setup_common(struct torture_context *tct printer_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(t->iremotewinspool_pipe)); + client_info = test_get_client_info(tctx, WIN_2000, 3, SPOOLSS_MINOR_VERSION_0); + torture_assert(tctx, test_AsyncOpenPrinter_byprinter(tctx, t, t->iremotewinspool_pipe, printer_name, - &t->server_handle), + client_info, &t->server_handle), "failed to open printserver"); torture_assert(tctx, test_get_environment(tctx, @@ -269,12 +318,15 @@ static bool test_AsyncClosePrinter(struct torture_context *tctx, struct dcerpc_pipe *p = ctx->iremotewinspool_pipe; const char *printer_name; + struct spoolss_UserLevel1 client_info; struct policy_handle handle; printer_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); + client_info = test_get_client_info(tctx, WIN_2000, 3, SPOOLSS_MINOR_VERSION_0); + torture_assert(tctx, - test_AsyncOpenPrinter_byprinter(tctx, ctx, p, printer_name, &handle), + test_AsyncOpenPrinter_byprinter(tctx, ctx, p, printer_name, client_info, &handle), "failed to test AsyncOpenPrinter"); torture_assert(tctx, @@ -292,12 +344,15 @@ static bool test_AsyncOpenPrinter(struct torture_context *tctx, struct dcerpc_pipe *p = ctx->iremotewinspool_pipe; const char *printer_name; + struct spoolss_UserLevel1 client_info; struct policy_handle handle; printer_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); + client_info = test_get_client_info(tctx, WIN_2000, 3, SPOOLSS_MINOR_VERSION_0); + torture_assert(tctx, - test_AsyncOpenPrinter_byprinter(tctx, ctx, p, printer_name, &handle), + test_AsyncOpenPrinter_byprinter(tctx, ctx, p, printer_name, client_info, &handle), "failed to test AsyncOpenPrinter"); test_AsyncClosePrinter_byhandle(tctx, ctx, p, &handle); @@ -871,6 +926,7 @@ static bool test_OpenPrinter(struct torture_context *tctx, struct policy_handle handle; struct dcerpc_pipe *s; struct dcerpc_binding *binding; + struct spoolss_UserLevel1 client_info; struct spoolss_ClosePrinter r; torture_assert_ntstatus_ok(tctx, @@ -891,8 +947,10 @@ static bool test_OpenPrinter(struct torture_context *tctx, printer_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); + client_info = test_get_client_info(tctx, WIN_2000, 3, SPOOLSS_MINOR_VERSION_0); + torture_assert(tctx, - test_AsyncOpenPrinter_byprinter(tctx, ctx, p, printer_name, &handle), + test_AsyncOpenPrinter_byprinter(tctx, ctx, p, printer_name, client_info, &handle), "failed to open printserver via winspool");