summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2003-11-30 11:57:40 +0000
committerTim Potter <tpot@samba.org>2003-11-30 11:57:40 +0000
commitd944b9780a132cb6c16571192f5cea8bd7b03f25 (patch)
tree8f74aeeeb77f8e1d15f6851fee94abe1f99bcbfa /source4/torture
parentc95ae2d890a40b25b20a3a71266eae8e45e4fcba (diff)
downloadsamba-d944b9780a132cb6c16571192f5cea8bd7b03f25.tar.gz
samba-d944b9780a132cb6c16571192f5cea8bd7b03f25.tar.bz2
samba-d944b9780a132cb6c16571192f5cea8bd7b03f25.zip
Added EnumPrinterDriver, GetPrinterDriver (still in progress)
(This used to be commit a818439b5915fd70b8aa3d3045f658b3f59a6bea)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/rpc/spoolss.c169
1 files changed, 159 insertions, 10 deletions
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<ARRAY_SIZE(levels);i++) {
+ uint32 buf_size;
+ char *server;
+ union spoolss_DriverInfo *info;
+ uint32 j;
+
+ asprintf(&server, "\\\\%s", dcerpc_server_name(p));
+ r.in.server = server;
+ r.in.environment = "Windows NT x86";
+ r.in.level = levels[i];
+ r.in.buffer = NULL;
+ buf_size = 0;
+ r.in.buf_size = &buf_size;
+ r.out.buf_size = &buf_size;
+
+ printf("\nTesting EnumPrinterDrivers level %u\n", r.in.level);
+
+ status = dcerpc_spoolss_EnumPrinterDrivers(p, mem_ctx, &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("EnumPrinterDrivers failed - %s\n",
+ nt_errstr(status));
+ ret = False;
+ continue;
+ }
+
+ if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
+ DATA_BLOB blob = data_blob_talloc(
+ mem_ctx, NULL, buf_size);
+
+ data_blob_clear(&blob);
+ r.in.buffer = &blob;
+ status = dcerpc_spoolss_EnumPrinterDrivers(
+ p, mem_ctx, &r);
+ }
+
+ if (!NT_STATUS_IS_OK(status) ||
+ !W_ERROR_IS_OK(r.out.result)) {
+ printf("EnumPrinterDrivers failed - %s/%s\n",
+ nt_errstr(status), win_errstr(r.out.result));
+ goto done;
+ }
+
+ if (!r.out.buffer) {
+ printf("No printer drivers returned");
+ goto done;
+ }
+
+ status = pull_spoolss_DriverInfoArray(
+ r.out.buffer, mem_ctx, r.in.level, r.out.count, &info);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("EnumPrinterDriverArray parse failed - %s\n",
+ nt_errstr(status));
+ continue;
+ }
+
+ for (j=0;j<r.out.count;j++) {
+ printf("Printer driver %d\n", j);
+ NDR_PRINT_UNION_DEBUG(
+ spoolss_DriverInfo, r.in.level,
+ &info[j]);
+
+ if (r.in.level == 1) {
+ struct policy_handle handle;
+
+ if (!call_OpenPrinterEx(
+ p, mem_ctx, "",
+ &handle))
+ continue;
+
+ test_GetPrinterDriver2(
+ p, mem_ctx, &handle,
+ info[j].info1.driver_name);
+ }
+ }
+
+ done:
+ free(server);
+ }
+
+ return ret;
+}
+
BOOL torture_rpc_spoolss(int dummy)
{
NTSTATUS status;
@@ -786,6 +931,10 @@ BOOL torture_rpc_spoolss(int dummy)
ret = False;
}
+ if (!test_EnumPrinterDrivers(p, mem_ctx)) {
+ ret = False;
+ }
+
talloc_destroy(mem_ctx);
torture_rpc_close(p);