diff options
-rw-r--r-- | source4/librpc/idl/spoolss.idl | 20 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr.c | 29 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss.c | 23 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss.h | 17 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss_buf.c | 6 | ||||
-rw-r--r-- | source4/librpc/rpc/rpc_spoolss.c | 42 | ||||
-rw-r--r-- | source4/torture/rpc/spoolss.c | 236 |
7 files changed, 233 insertions, 140 deletions
diff --git a/source4/librpc/idl/spoolss.idl b/source4/librpc/idl/spoolss.idl index be6f9a8f51..7abf3effde 100644 --- a/source4/librpc/idl/spoolss.idl +++ b/source4/librpc/idl/spoolss.idl @@ -115,7 +115,7 @@ case(5) spoolss_PrinterInfo5 info5; case(6) spoolss_PrinterInfo6 info6; case(7) spoolss_PrinterInfo7 info7; - } spoolss_PrinterEnum; + } spoolss_PrinterInfo; WERROR spoolss_EnumPrinters( [in] uint32 flags, @@ -176,13 +176,11 @@ /******************/ /* Function: 0x08 */ - NTSTATUS spoolss_GetPrinter( - [in,ref] policy_handle *handle, - [in] uint32 level, - [in,out] uint8_buf *buffer, - [in] uint32 offered, - [out] uint32 needed, - [out] uint32 returned + WERROR spoolss_GetPrinter( + [in,ref] policy_handle *handle, + [in] uint32 level, + [in,out] DATA_BLOB *buffer, + [in,out,ref] uint32 *buf_size ); /******************/ @@ -289,8 +287,8 @@ /******************/ /* Function: 0x1d */ - NTSTATUS spoolss_ClosePrinter( - [in,out,ref] policy_handle *handle + WERROR spoolss_ClosePrinter( + [in,out,ref] policy_handle *handle ); /******************/ @@ -513,7 +511,7 @@ /******************/ /* Function: 0x45 */ - NTSTATUS spoolss_OpenPrinterEx( + WERROR spoolss_OpenPrinterEx( [in] unistr *printername, [in] unistr *datatype, [in] spoolss_DevmodeContainer devmode_ctr, diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 97eee70dfe..5f941c703d 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -533,3 +533,32 @@ NTSTATUS ndr_push_relative(struct ndr_push *ndr, int ndr_flags, const void *p, } return NT_STATUS_OK; } + + +/* + pull a union from a blob using NDR +*/ +NTSTATUS ndr_pull_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, uint16 level, void *p, + NTSTATUS (*fn)(struct ndr_pull *, int ndr_flags, uint16 *, void *)) +{ + struct ndr_pull *ndr; + ndr = ndr_pull_init_blob(blob, mem_ctx); + if (!ndr) { + return NT_STATUS_NO_MEMORY; + } + return fn(ndr, NDR_SCALARS|NDR_BUFFERS, &level, p); +} + +/* + pull a struct from a blob using NDR +*/ +NTSTATUS ndr_pull_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, + NTSTATUS (*fn)(struct ndr_pull *, int ndr_flags, void *)) +{ + struct ndr_pull *ndr; + ndr = ndr_pull_init_blob(blob, mem_ctx); + if (!ndr) { + return NT_STATUS_NO_MEMORY; + } + return fn(ndr, NDR_SCALARS|NDR_BUFFERS, p); +} diff --git a/source4/librpc/ndr/ndr_spoolss.c b/source4/librpc/ndr/ndr_spoolss.c index 5b64f9067a..2e2e911311 100644 --- a/source4/librpc/ndr/ndr_spoolss.c +++ b/source4/librpc/ndr/ndr_spoolss.c @@ -200,7 +200,7 @@ done: return NT_STATUS_OK; } -NTSTATUS ndr_push_spoolss_PrinterEnum(struct ndr_push *ndr, int ndr_flags, uint16 level, union spoolss_PrinterEnum *r) +NTSTATUS ndr_push_spoolss_PrinterInfo(struct ndr_push *ndr, int ndr_flags, uint16 level, union spoolss_PrinterInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_push_struct_start(ndr)); @@ -362,9 +362,9 @@ NTSTATUS ndr_push_spoolss_GetPrinter(struct ndr_push *ndr, struct spoolss_GetPri NDR_CHECK(ndr_push_uint32(ndr, r->in.level)); NDR_CHECK(ndr_push_ptr(ndr, r->in.buffer)); if (r->in.buffer) { - NDR_CHECK(ndr_push_uint8_buf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer)); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, *r->in.buffer)); } - NDR_CHECK(ndr_push_uint32(ndr, r->in.offered)); + NDR_CHECK(ndr_push_uint32(ndr, *r->in.buf_size)); return NT_STATUS_OK; } @@ -1168,7 +1168,7 @@ done: return NT_STATUS_OK; } -NTSTATUS ndr_pull_spoolss_PrinterEnum(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union spoolss_PrinterEnum *r) +NTSTATUS ndr_pull_spoolss_PrinterInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union spoolss_PrinterInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_struct_start(ndr)); @@ -1334,11 +1334,10 @@ NTSTATUS ndr_pull_spoolss_GetPrinter(struct ndr_pull *ndr, struct spoolss_GetPri r->out.buffer = NULL; } if (r->out.buffer) { - NDR_CHECK(ndr_pull_uint8_buf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.buffer)); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, r->out.buffer)); } - NDR_CHECK(ndr_pull_uint32(ndr, &r->out.needed)); - NDR_CHECK(ndr_pull_uint32(ndr, &r->out.returned)); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); + NDR_CHECK(ndr_pull_uint32(ndr, r->out.buf_size)); + NDR_CHECK(ndr_pull_WERROR(ndr, &r->out.result)); return NT_STATUS_OK; } @@ -1486,7 +1485,7 @@ NTSTATUS ndr_pull_spoolss_1c(struct ndr_pull *ndr, struct spoolss_1c *r) NTSTATUS ndr_pull_spoolss_ClosePrinter(struct ndr_pull *ndr, struct spoolss_ClosePrinter *r) { NDR_CHECK(ndr_pull_policy_handle(ndr, r->out.handle)); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); + NDR_CHECK(ndr_pull_WERROR(ndr, &r->out.result)); return NT_STATUS_OK; } @@ -1767,7 +1766,7 @@ NTSTATUS ndr_pull_spoolss_44(struct ndr_pull *ndr, struct spoolss_44 *r) NTSTATUS ndr_pull_spoolss_OpenPrinterEx(struct ndr_pull *ndr, struct spoolss_OpenPrinterEx *r) { NDR_CHECK(ndr_pull_policy_handle(ndr, r->out.handle)); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); + NDR_CHECK(ndr_pull_WERROR(ndr, &r->out.result)); return NT_STATUS_OK; } @@ -2112,9 +2111,9 @@ void ndr_print_spoolss_PrinterInfo7(struct ndr_print *ndr, const char *name, str ndr->depth--; } -void ndr_print_spoolss_PrinterEnum(struct ndr_print *ndr, const char *name, uint16 level, union spoolss_PrinterEnum *r) +void ndr_print_spoolss_PrinterInfo(struct ndr_print *ndr, const char *name, uint16 level, union spoolss_PrinterInfo *r) { - ndr_print_union(ndr, name, level, "spoolss_PrinterEnum"); + ndr_print_union(ndr, name, level, "spoolss_PrinterInfo"); switch (level) { case 1: ndr_print_spoolss_PrinterInfo1(ndr, "info1", &r->info1); diff --git a/source4/librpc/ndr/ndr_spoolss.h b/source4/librpc/ndr/ndr_spoolss.h index 60738b494a..61aac510d9 100644 --- a/source4/librpc/ndr/ndr_spoolss.h +++ b/source4/librpc/ndr/ndr_spoolss.h @@ -96,7 +96,7 @@ struct spoolss_PrinterInfo7 { uint32 action; }; -union spoolss_PrinterEnum { +union spoolss_PrinterInfo { /* [case(1)] */ struct spoolss_PrinterInfo1 info1; /* [case(2)] */ struct spoolss_PrinterInfo2 info2; /* [case(3)] */ struct spoolss_PrinterInfo3 info3; @@ -212,15 +212,14 @@ struct spoolss_GetPrinter { struct { struct policy_handle *handle; uint32 level; - struct uint8_buf *buffer; - uint32 offered; + DATA_BLOB *buffer; + uint32 *buf_size; } in; struct { - struct uint8_buf *buffer; - uint32 needed; - uint32 returned; - NTSTATUS result; + DATA_BLOB *buffer; + uint32 *buf_size; + WERROR result; } out; }; @@ -434,7 +433,7 @@ struct spoolss_ClosePrinter { struct { struct policy_handle *handle; - NTSTATUS result; + WERROR result; } out; }; @@ -864,7 +863,7 @@ struct spoolss_OpenPrinterEx { struct { struct policy_handle *handle; - NTSTATUS result; + WERROR result; } out; }; diff --git a/source4/librpc/ndr/ndr_spoolss_buf.c b/source4/librpc/ndr/ndr_spoolss_buf.c index c53a691417..c06d6704b2 100644 --- a/source4/librpc/ndr/ndr_spoolss_buf.c +++ b/source4/librpc/ndr/ndr_spoolss_buf.c @@ -24,9 +24,9 @@ #include "includes.h" -NTSTATUS pull_spoolss_PrinterEnumArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, +NTSTATUS pull_spoolss_PrinterInfoArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, uint16 level, uint32 count, - union spoolss_PrinterEnum **info) + union spoolss_PrinterInfo **info) { int i; struct ndr_pull *ndr; @@ -36,7 +36,7 @@ NTSTATUS pull_spoolss_PrinterEnumArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, } NDR_ALLOC_N(ndr, *info, count); for (i=0;i<count;i++) { - NDR_CHECK(ndr_pull_spoolss_PrinterEnum(ndr, NDR_SCALARS|NDR_BUFFERS, &level, &(*info)[i])); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &level, &(*info)[i])); } return NT_STATUS_OK; } diff --git a/source4/librpc/rpc/rpc_spoolss.c b/source4/librpc/rpc/rpc_spoolss.c index e2d3a1ae35..026798df70 100644 --- a/source4/librpc/rpc/rpc_spoolss.c +++ b/source4/librpc/rpc/rpc_spoolss.c @@ -105,16 +105,10 @@ NTSTATUS dcerpc_spoolss_07(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct sp NTSTATUS dcerpc_spoolss_GetPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinter *r) { - NTSTATUS status; - status = dcerpc_ndr_request(p, DCERPC_SPOOLSS_GETPRINTER, mem_ctx, - (ndr_push_fn_t) ndr_push_spoolss_GetPrinter, - (ndr_pull_fn_t) ndr_pull_spoolss_GetPrinter, - r); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - return r->out.result; + return dcerpc_ndr_request(p, DCERPC_SPOOLSS_GETPRINTER, mem_ctx, + (ndr_push_fn_t) ndr_push_spoolss_GetPrinter, + (ndr_pull_fn_t) ndr_pull_spoolss_GetPrinter, + r); } NTSTATUS dcerpc_spoolss_09(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_09 *r) @@ -399,16 +393,10 @@ NTSTATUS dcerpc_spoolss_1c(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct sp NTSTATUS dcerpc_spoolss_ClosePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ClosePrinter *r) { - NTSTATUS status; - status = dcerpc_ndr_request(p, DCERPC_SPOOLSS_CLOSEPRINTER, mem_ctx, - (ndr_push_fn_t) ndr_push_spoolss_ClosePrinter, - (ndr_pull_fn_t) ndr_pull_spoolss_ClosePrinter, - r); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - return r->out.result; + return dcerpc_ndr_request(p, DCERPC_SPOOLSS_CLOSEPRINTER, mem_ctx, + (ndr_push_fn_t) ndr_push_spoolss_ClosePrinter, + (ndr_pull_fn_t) ndr_pull_spoolss_ClosePrinter, + r); } NTSTATUS dcerpc_spoolss_1e(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_1e *r) @@ -959,16 +947,10 @@ NTSTATUS dcerpc_spoolss_44(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct sp NTSTATUS dcerpc_spoolss_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_OpenPrinterEx *r) { - NTSTATUS status; - status = dcerpc_ndr_request(p, DCERPC_SPOOLSS_OPENPRINTEREX, mem_ctx, - (ndr_push_fn_t) ndr_push_spoolss_OpenPrinterEx, - (ndr_pull_fn_t) ndr_pull_spoolss_OpenPrinterEx, - r); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - return r->out.result; + return dcerpc_ndr_request(p, DCERPC_SPOOLSS_OPENPRINTEREX, mem_ctx, + (ndr_push_fn_t) ndr_push_spoolss_OpenPrinterEx, + (ndr_pull_fn_t) ndr_pull_spoolss_OpenPrinterEx, + r); } NTSTATUS dcerpc_spoolss_46(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_46 *r) diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 0f104491b6..c44c2a1db8 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -21,23 +21,102 @@ #include "includes.h" +BOOL test_GetPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle) +{ + NTSTATUS status; + struct spoolss_GetPrinter r; + uint32 buf_size = 0; + DATA_BLOB blob; + union spoolss_PrinterInfo info; + uint16 levels[] = {1, 2, 3, 4, 5, 6, 7}; + int i; + BOOL ret = True; + + for (i=0;i<ARRAY_SIZE(levels);i++) { + r.in.handle = handle; + r.in.level = levels[i]; + r.in.buffer = NULL; + r.in.buf_size = &buf_size; + r.out.buf_size = &buf_size; + + printf("Testing GetPrinter level %u\n", r.in.level); + + status = dcerpc_spoolss_GetPrinter(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("GetPrinter failed - %s\n", nt_errstr(status)); + ret = False; + continue; + } + + if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { + blob = data_blob_talloc(mem_ctx, NULL, buf_size); + data_blob_clear(&blob); + r.in.buffer = &blob; + status = dcerpc_spoolss_GetPrinter(p, mem_ctx, &r); + } + + if (!NT_STATUS_IS_OK(status) || + !W_ERROR_IS_OK(r.out.result)) { + printf("GetPrinter failed - %s/%s\n", + nt_errstr(status), win_errstr(r.out.result)); + ret = False; + continue; + } + + status = ndr_pull_union_blob(r.out.buffer, mem_ctx, r.in.level, &info, + (ndr_pull_union_fn_t)ndr_pull_spoolss_PrinterInfo); + if (!NT_STATUS_IS_OK(status)) { + printf("PrinterInfo parse failed - %s\n", nt_errstr(status)); + ret = False; + continue; + } + + NDR_PRINT_UNION_DEBUG(spoolss_PrinterInfo, r.in.level, &info); + } + + return ret; +} + + +BOOL test_ClosePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle) +{ + NTSTATUS status; + struct spoolss_ClosePrinter r; + + r.in.handle = handle; + r.out.handle = handle; + + printf("Testing ClosePrinter\n"); + + 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; +} + static BOOL test_OpenPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct spoolss_PrinterInfo1 *info1) + const char *name) { NTSTATUS status; struct spoolss_OpenPrinter r; struct policy_handle handle; DATA_BLOB blob; + BOOL ret = True; blob = data_blob(NULL, 0); r.in.server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); - r.in.printer = info1->name; + r.in.printer = name; r.in.buffer = &blob; - r.in.access_mask = SEC_RIGHT_MAXIMUM_ALLOWED; + r.in.access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED; r.out.handle = &handle; - printf("Testing OpenPrinter(\\\\%s\\%s)\n", r.in.server, r.in.printer); + printf("\nTesting OpenPrinter(\\\\%s\\%s)\n", r.in.server, r.in.printer); status = dcerpc_spoolss_OpenPrinter(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { @@ -46,10 +125,71 @@ static BOOL test_OpenPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return False; } + + if (!test_GetPrinter(p, mem_ctx, &handle)) { + ret = False; + } + + if (!test_ClosePrinter(p, mem_ctx, &handle)) { + ret = False; + } - return True; + return ret; +} + +static BOOL test_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + const char *name) +{ + 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); + 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; + + userlevel1.size = 1234; + userlevel1.client = "hello"; + userlevel1.user = "spottyfoot!"; + userlevel1.build = 1; + userlevel1.major = 2; + userlevel1.minor = 3; + userlevel1.processor = 4; + r.in.userlevel.level1 = &userlevel1; + + printf("Testing OpenPrinterEx(%s)\n", r.in.printername); + + status = dcerpc_spoolss_OpenPrinterEx(p, mem_ctx, &r); + + if (!NT_STATUS_IS_OK(status)) { + 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; + } + + if (!test_GetPrinter(p, mem_ctx, &handle)) { + ret = False; + } + + 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; @@ -60,7 +200,7 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) for (i=0;i<ARRAY_SIZE(levels);i++) { uint32 buf_size = 0; - union spoolss_PrinterEnum *info; + union spoolss_PrinterInfo *info; int j; r.in.flags = 0x02; @@ -73,7 +213,7 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) printf("\nTesting EnumPrinters level %u\n", r.in.level); status = dcerpc_spoolss_EnumPrinters(p, mem_ctx, &r); - if (NT_STATUS_IS_ERR(status)) { + if (!NT_STATUS_IS_OK(status)) { printf("EnumPrinters failed - %s\n", nt_errstr(status)); ret = False; continue; @@ -93,7 +233,7 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) continue; } - status = pull_spoolss_PrinterEnumArray(r.out.buffer, mem_ctx, r.in.level, r.out.count, &info); + status = pull_spoolss_PrinterInfoArray(r.out.buffer, mem_ctx, r.in.level, r.out.count, &info); if (!NT_STATUS_IS_OK(status)) { printf("EnumPrintersArray parse failed - %s\n", nt_errstr(status)); continue; @@ -101,13 +241,22 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) for (j=0;j<r.out.count;j++) { printf("Printer %d\n", j); - NDR_PRINT_UNION_DEBUG(spoolss_PrinterEnum, r.in.level, &info[j]); + NDR_PRINT_UNION_DEBUG(spoolss_PrinterInfo, r.in.level, &info[j]); } for (j=0;j<r.out.count;j++) { - if (r.in.level == 1 && - !test_OpenPrinter(p, mem_ctx, &info[j].info1)) { - ret = False; + if (r.in.level == 1) { + /* the names appear to be comma-separated name lists? */ + char *name = talloc_strdup(mem_ctx, info[j].info1.name); + char *comma = strchr(name, ','); + if (comma) *comma = 0; + if (!test_OpenPrinter(p, mem_ctx, name)) { + ret = False; + } + + if (!test_OpenPrinterEx(p, mem_ctx, name)) { + ret = False; + } } } } @@ -115,67 +264,12 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) return ret; } -static BOOL test_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) -{ - struct spoolss_OpenPrinterEx r; - struct spoolss_UserLevel1 userlevel1; - NTSTATUS status; - - 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 = 0x02000000; - r.in.level = 1; - r.out.handle = handle; - - userlevel1.size = 1234; - userlevel1.client = "hello"; - userlevel1.user = "spottyfoot!"; - userlevel1.build = 1; - userlevel1.major = 2; - userlevel1.minor = 3; - userlevel1.processor = 4; - r.in.userlevel.level1 = &userlevel1; - - status = dcerpc_spoolss_OpenPrinterEx(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_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"); @@ -188,14 +282,6 @@ BOOL torture_rpc_spoolss(int dummy) ret = False; } - if (!test_OpenPrinterEx(p, mem_ctx, &handle)) { - ret = False; - } - - if (!test_ClosePrinter(p, mem_ctx, &handle)) { - ret = False; - } - torture_rpc_close(p); return ret; |