From d944b9780a132cb6c16571192f5cea8bd7b03f25 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 30 Nov 2003 11:57:40 +0000 Subject: Added EnumPrinterDriver, GetPrinterDriver (still in progress) (This used to be commit a818439b5915fd70b8aa3d3045f658b3f59a6bea) --- source4/torture/rpc/spoolss.c | 169 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 159 insertions(+), 10 deletions(-) (limited to 'source4/torture/rpc') diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 802671c8e8..2be1ddc0a2 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -612,23 +612,26 @@ static BOOL test_OpenPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static BOOL test_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - const char *name) +static BOOL call_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + const char *name, struct policy_handle *handle) { - struct policy_handle handle; struct spoolss_OpenPrinterEx r; struct spoolss_UserLevel1 userlevel1; NTSTATUS status; - BOOL ret = True; - r.in.printername = talloc_asprintf(mem_ctx, "\\\\%s\\%s", - dcerpc_server_name(p), name); + if (name && name[0]) + r.in.printername = talloc_asprintf(mem_ctx, "\\\\%s\\%s", + dcerpc_server_name(p), name); + else + r.in.printername = talloc_asprintf(mem_ctx, "\\\\%s", + dcerpc_server_name(p)); + r.in.datatype = NULL; r.in.devmode_ctr.size = 0; r.in.devmode_ctr.devmode = NULL; r.in.access_required = 0x02000000; r.in.level = 1; - r.out.handle = &handle; + r.out.handle = handle; userlevel1.size = 1234; userlevel1.client = "hello"; @@ -647,12 +650,25 @@ static BOOL test_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("OpenPrinterEx failed - %s\n", nt_errstr(status)); return False; } - + if (!W_ERROR_IS_OK(r.out.result)) { printf("OpenPrinterEx failed - %s\n", win_errstr(r.out.result)); return False; } + return True; +} + +static BOOL test_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + const char *name) +{ + struct policy_handle handle; + BOOL ret = True; + + if (!call_OpenPrinterEx(p, mem_ctx, name, &handle)) { + return False; + } + if (!test_GetPrinter(p, mem_ctx, &handle)) { ret = False; } @@ -680,11 +696,10 @@ static BOOL test_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!test_ClosePrinter(p, mem_ctx, &handle)) { ret = False; } - + return ret; } - static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { struct spoolss_EnumPrinters r; @@ -763,6 +778,136 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) return ret; } +static BOOL test_GetPrinterDriver2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, char *driver_name) +{ + NTSTATUS status; + struct spoolss_GetPrinterDriver2 r; + uint32 buf_size; + + r.in.handle = handle; + r.in.architecture = "W32X86"; + r.in.level = 1; + buf_size = 0; + r.in.buf_size = r.out.buf_size = &buf_size; + r.in.client_major_version = 0; + r.in.client_minor_version = 0; + + printf("Testing GetPrinterDriver2\n"); + + status = dcerpc_spoolss_GetPrinterDriver2(p, mem_ctx, &r); + + if (!NT_STATUS_IS_OK(status)) { + printf("GetPrinterDriver2 failed - %s\n", nt_errstr(status)); + return False; + } + + if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { + status = dcerpc_spoolss_GetPrinterDriver2(p, mem_ctx, &r); + } + + if (!NT_STATUS_IS_OK(status) || + !W_ERROR_IS_OK(r.out.result)) { + printf("GetPrinterDriver2 failed - %s/%s\n", + nt_errstr(status), win_errstr(r.out.result)); + return False; + } + + return True; +} + +static BOOL test_EnumPrinterDrivers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +{ + struct spoolss_EnumPrinterDrivers r; + NTSTATUS status; + uint16 levels[] = {1, 2, 3}; + int i; + BOOL ret = True; + + for (i=0;i