summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2003-11-16 04:20:29 +0000
committerTim Potter <tpot@samba.org>2003-11-16 04:20:29 +0000
commit274667be32531da20f76b7ffc039c45f86e59282 (patch)
treebff073c7791b12729402ba28e1bd6e6c2ec969a9
parent6098faca038d1127f29ec121e03fea32446bf053 (diff)
downloadsamba-274667be32531da20f76b7ffc039c45f86e59282.tar.gz
samba-274667be32531da20f76b7ffc039c45f86e59282.tar.bz2
samba-274667be32531da20f76b7ffc039c45f86e59282.zip
Added tests for EnumPrinters and ClosePrinter.
(This used to be commit 9f3b84c7d7a7e6316b2cc051b01efcfb679534ad)
-rw-r--r--source4/torture/rpc/spoolss.c78
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;
}