diff options
Diffstat (limited to 'source4/torture/rpc')
-rw-r--r-- | source4/torture/rpc/spoolss.c | 78 |
1 files changed, 72 insertions, 6 deletions
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 7f4809109a..e83e63eea4 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -21,20 +21,57 @@ #include "includes.h" -static BOOL test_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +{ + struct spoolss_EnumPrinters r; + NTSTATUS status; + + r.in.flags = 0x02; + r.in.server = "\\\\movingforward"; + r.in.level = 1; + r.in.buffer = NULL; + r.in.offered = 0; + + status = dcerpc_spoolss_EnumPrinters(p, mem_ctx, &r); + + if (NT_STATUS_IS_ERR(status)) { + printf("OpenPrinter failed - %s\n", nt_errstr(status)); + return False; + } + + if (NT_STATUS_V(status) == 0x0000007a) { + struct uint8_buf buffer; + + r.in.offered = r.out.needed; + buffer.size = r.out.needed; + buffer.data = talloc(mem_ctx, buffer.size); + memset(buffer.data, 0xfe, buffer.size); + r.in.buffer = &buffer; + status = dcerpc_spoolss_EnumPrinters(p, mem_ctx, &r); + } + + if (!NT_STATUS_IS_OK(status)) { + printf("OpenPrinter failed - %s\n", nt_errstr(status)); + return False; + } + + return True; +} + +static BOOL test_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle) { struct spoolss_OpenPrinterEx r; struct spoolss_UserLevel1 userlevel1; - struct policy_handle handle; NTSTATUS status; - r.in.printername = "p"; + r.in.printername = "\\\\movingforward\\p"; r.in.datatype = NULL; r.in.devmode_ctr.size = 0; r.in.devmode_ctr.devmode = NULL; - r.in.access_required = 0x12345678; + r.in.access_required = 0x02000000; r.in.level = 1; - r.out.handle = &handle; + r.out.handle = handle; userlevel1.size = 1234; userlevel1.client = "hello"; @@ -55,12 +92,33 @@ static BOOL test_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) return True; } +static BOOL test_ClosePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle) +{ + struct spoolss_ClosePrinter r; + struct policy_handle handle2; + NTSTATUS status; + + r.in.handle = handle; + r.out.handle = &handle2; + + status = dcerpc_spoolss_ClosePrinter(p, mem_ctx, &r); + + if (!NT_STATUS_IS_OK(status)) { + printf("ClosePrinter failed - %s\n", nt_errstr(status)); + return False; + } + + return True; +} + BOOL torture_rpc_spoolss(int dummy) { NTSTATUS status; struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; BOOL ret = True; + struct policy_handle handle; mem_ctx = talloc_init("torture_rpc_spoolss"); @@ -69,7 +127,15 @@ BOOL torture_rpc_spoolss(int dummy) return False; } - if (!test_OpenPrinterEx(p, mem_ctx)) { + if (!test_EnumPrinters(p, mem_ctx)) { + ret = False; + } + + if (!test_OpenPrinterEx(p, mem_ctx, &handle)) { + ret = False; + } + + if (!test_ClosePrinter(p, mem_ctx, &handle)) { ret = False; } |