diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-17 02:58:10 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-17 02:58:10 +0000 |
commit | 90916de4a5303601a59938237a551d976cde0589 (patch) | |
tree | bff267e385e910b9ad69505da6964669d9318073 /source4 | |
parent | ff9558bdf99901793dad9182254164e1472e9cfe (diff) | |
download | samba-90916de4a5303601a59938237a551d976cde0589.tar.gz samba-90916de4a5303601a59938237a551d976cde0589.tar.bz2 samba-90916de4a5303601a59938237a551d976cde0589.zip |
* more info levels for EnumPrinter
* use WERROR return type in spoolss EnumPrinter
(This used to be commit 8301a6b6ad45f76a42d0fcab6347c187eee615a9)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/librpc/idl/spoolss.idl | 43 | ||||
-rw-r--r-- | source4/librpc/ndr/libndr.h | 1 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_basic.c | 11 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss.c | 346 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss.h | 43 | ||||
-rw-r--r-- | source4/librpc/rpc/rpc_spoolss.c | 14 | ||||
-rw-r--r-- | source4/torture/rpc/spoolss.c | 12 |
7 files changed, 426 insertions, 44 deletions
diff --git a/source4/librpc/idl/spoolss.idl b/source4/librpc/idl/spoolss.idl index 2da15652e5..515ac0fd51 100644 --- a/source4/librpc/idl/spoolss.idl +++ b/source4/librpc/idl/spoolss.idl @@ -53,7 +53,7 @@ [relative] nstring name; [relative] nstring description; [relative] nstring comment; - } spoolss_PrinterEnum1; + } spoolss_PrinterInfo1; typedef struct { [relative] nstring servername; @@ -77,14 +77,47 @@ uint32 status; uint32 cjobs; uint32 averageppm; - } spoolss_PrinterEnum2; + } spoolss_PrinterInfo2; + + typedef struct { + uint32 flags; + [relative] security_descriptor *secdesc; + } spoolss_PrinterInfo3; + + typedef struct { + [relative] nstring printername; + [relative] nstring servername; + uint32 attributes; + } spoolss_PrinterInfo4; + + typedef struct { + [relative] nstring printername; + [relative] nstring portname; + uint32 attributes; + uint32 device_not_selected_timeout; + uint32 transmission_retry_timeout; + } spoolss_PrinterInfo5; + + typedef struct { + uint32 foo; + } spoolss_PrinterInfo6; + + typedef struct { + [relative] nstring guid; /* text form of printer guid */ + uint32 action; + } spoolss_PrinterInfo7; typedef [nodiscriminant,public] union { - case(1) spoolss_PrinterEnum1 info1; - case(2) spoolss_PrinterEnum2 info2; + case(1) spoolss_PrinterInfo1 info1; + case(2) spoolss_PrinterInfo2 info2; + case(3) spoolss_PrinterInfo3 info3; + case(4) spoolss_PrinterInfo4 info4; + case(5) spoolss_PrinterInfo5 info5; + case(6) spoolss_PrinterInfo6 info6; + case(7) spoolss_PrinterInfo7 info7; } spoolss_PrinterEnum; - NTSTATUS spoolss_EnumPrinters( + WERROR spoolss_EnumPrinters( [in] uint32 flags, [in] unistr *server, [in] uint32 level, diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h index b826e024f9..f210765497 100644 --- a/source4/librpc/ndr/libndr.h +++ b/source4/librpc/ndr/libndr.h @@ -182,4 +182,3 @@ typedef void (*ndr_print_union_fn_t)(struct ndr_print *, const char *, uint16, v #include "librpc/ndr/ndr_spoolss.h" #include "librpc/ndr/ndr_spoolss_buf.h" #include "librpc/ndr/ndr_samr.h" - diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 2c6a3aac96..8e90fc990f 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -84,6 +84,17 @@ NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, NTSTATUS *status) } /* + pull a WERROR +*/ +NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, WERROR *status) +{ + uint32 v; + NDR_CHECK(ndr_pull_uint32(ndr, &v)); + *status = W_ERROR(v); + return NT_STATUS_OK; +} + +/* parse a set of bytes */ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, char *data, uint32 n) diff --git a/source4/librpc/ndr/ndr_spoolss.c b/source4/librpc/ndr/ndr_spoolss.c index 0b6e088e8f..f88e46890a 100644 --- a/source4/librpc/ndr/ndr_spoolss.c +++ b/source4/librpc/ndr/ndr_spoolss.c @@ -50,7 +50,7 @@ done: return NT_STATUS_OK; } -NTSTATUS ndr_push_spoolss_PrinterEnum1(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterEnum1 *r) +NTSTATUS ndr_push_spoolss_PrinterInfo1(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterInfo1 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_push_struct_start(ndr)); @@ -69,7 +69,7 @@ done: return NT_STATUS_OK; } -NTSTATUS ndr_push_spoolss_PrinterEnum2(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterEnum2 *r) +NTSTATUS ndr_push_spoolss_PrinterInfo2(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterInfo2 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_push_struct_start(ndr)); @@ -119,17 +119,118 @@ done: return NT_STATUS_OK; } +NTSTATUS ndr_push_spoolss_PrinterInfo3(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterInfo3 *r) +{ + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, r->flags)); + NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->secdesc, (ndr_push_const_fn_t) ndr_push_security_descriptor)); + ndr_push_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + if (r->secdesc) { + NDR_CHECK(ndr_push_relative(ndr, NDR_BUFFERS, r->secdesc, (ndr_push_const_fn_t) ndr_push_security_descriptor)); + } +done: + return NT_STATUS_OK; +} + +NTSTATUS ndr_push_spoolss_PrinterInfo4(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterInfo4 *r) +{ + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->printername, (ndr_push_const_fn_t) ndr_push_nstring)); + NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->servername, (ndr_push_const_fn_t) ndr_push_nstring)); + NDR_CHECK(ndr_push_uint32(ndr, r->attributes)); + ndr_push_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + NDR_CHECK(ndr_push_relative(ndr, NDR_BUFFERS, &r->printername, (ndr_push_const_fn_t) ndr_push_nstring)); + NDR_CHECK(ndr_push_relative(ndr, NDR_BUFFERS, &r->servername, (ndr_push_const_fn_t) ndr_push_nstring)); +done: + return NT_STATUS_OK; +} + +NTSTATUS ndr_push_spoolss_PrinterInfo5(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterInfo5 *r) +{ + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->printername, (ndr_push_const_fn_t) ndr_push_nstring)); + NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->portname, (ndr_push_const_fn_t) ndr_push_nstring)); + NDR_CHECK(ndr_push_uint32(ndr, r->attributes)); + NDR_CHECK(ndr_push_uint32(ndr, r->device_not_selected_timeout)); + NDR_CHECK(ndr_push_uint32(ndr, r->transmission_retry_timeout)); + ndr_push_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + NDR_CHECK(ndr_push_relative(ndr, NDR_BUFFERS, &r->printername, (ndr_push_const_fn_t) ndr_push_nstring)); + NDR_CHECK(ndr_push_relative(ndr, NDR_BUFFERS, &r->portname, (ndr_push_const_fn_t) ndr_push_nstring)); +done: + return NT_STATUS_OK; +} + +NTSTATUS ndr_push_spoolss_PrinterInfo6(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterInfo6 *r) +{ + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, r->foo)); + ndr_push_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; +done: + return NT_STATUS_OK; +} + +NTSTATUS ndr_push_spoolss_PrinterInfo7(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterInfo7 *r) +{ + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->guid, (ndr_push_const_fn_t) ndr_push_nstring)); + NDR_CHECK(ndr_push_uint32(ndr, r->action)); + ndr_push_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + NDR_CHECK(ndr_push_relative(ndr, NDR_BUFFERS, &r->guid, (ndr_push_const_fn_t) ndr_push_nstring)); +done: + return NT_STATUS_OK; +} + NTSTATUS ndr_push_spoolss_PrinterEnum(struct ndr_push *ndr, int ndr_flags, uint16 level, union spoolss_PrinterEnum *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_push_struct_start(ndr)); switch (level) { case 1: - NDR_CHECK(ndr_push_spoolss_PrinterEnum1(ndr, NDR_SCALARS, &r->info1)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo1(ndr, NDR_SCALARS, &r->info1)); break; case 2: - NDR_CHECK(ndr_push_spoolss_PrinterEnum2(ndr, NDR_SCALARS, &r->info2)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo2(ndr, NDR_SCALARS, &r->info2)); + break; + + case 3: + NDR_CHECK(ndr_push_spoolss_PrinterInfo3(ndr, NDR_SCALARS, &r->info3)); + break; + + case 4: + NDR_CHECK(ndr_push_spoolss_PrinterInfo4(ndr, NDR_SCALARS, &r->info4)); + break; + + case 5: + NDR_CHECK(ndr_push_spoolss_PrinterInfo5(ndr, NDR_SCALARS, &r->info5)); + break; + + case 6: + NDR_CHECK(ndr_push_spoolss_PrinterInfo6(ndr, NDR_SCALARS, &r->info6)); + break; + + case 7: + NDR_CHECK(ndr_push_spoolss_PrinterInfo7(ndr, NDR_SCALARS, &r->info7)); break; default: @@ -140,11 +241,31 @@ buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; switch (level) { case 1: - NDR_CHECK(ndr_push_spoolss_PrinterEnum1(ndr, ndr_flags, &r->info1)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo1(ndr, ndr_flags, &r->info1)); break; case 2: - NDR_CHECK(ndr_push_spoolss_PrinterEnum2(ndr, ndr_flags, &r->info2)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo2(ndr, ndr_flags, &r->info2)); + break; + + case 3: + NDR_CHECK(ndr_push_spoolss_PrinterInfo3(ndr, ndr_flags, &r->info3)); + break; + + case 4: + NDR_CHECK(ndr_push_spoolss_PrinterInfo4(ndr, ndr_flags, &r->info4)); + break; + + case 5: + NDR_CHECK(ndr_push_spoolss_PrinterInfo5(ndr, ndr_flags, &r->info5)); + break; + + case 6: + NDR_CHECK(ndr_push_spoolss_PrinterInfo6(ndr, ndr_flags, &r->info6)); + break; + + case 7: + NDR_CHECK(ndr_push_spoolss_PrinterInfo7(ndr, ndr_flags, &r->info7)); break; default: @@ -909,7 +1030,7 @@ done: return NT_STATUS_OK; } -NTSTATUS ndr_pull_spoolss_PrinterEnum1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterEnum1 *r) +NTSTATUS ndr_pull_spoolss_PrinterInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo1 *r) { NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; @@ -925,7 +1046,7 @@ done: return NT_STATUS_OK; } -NTSTATUS ndr_pull_spoolss_PrinterEnum2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterEnum2 *r) +NTSTATUS ndr_pull_spoolss_PrinterInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo2 *r) { uint32 _ptr_devmode; uint32 _ptr_secdesc; @@ -960,17 +1081,111 @@ done: return NT_STATUS_OK; } +NTSTATUS ndr_pull_spoolss_PrinterInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo3 *r) +{ + uint32 _ptr_secdesc; + NDR_CHECK(ndr_pull_struct_start(ndr)); + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->flags)); + NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->secdesc, sizeof(*r->secdesc), (ndr_pull_flags_fn_t)ndr_pull_security_descriptor)); + ndr_pull_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; +done: + return NT_STATUS_OK; +} + +NTSTATUS ndr_pull_spoolss_PrinterInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo4 *r) +{ + NDR_CHECK(ndr_pull_struct_start(ndr)); + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->printername, sizeof(*r->printername), (ndr_pull_flags_fn_t)ndr_pull_nstring)); + NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->servername, sizeof(*r->servername), (ndr_pull_flags_fn_t)ndr_pull_nstring)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->attributes)); + ndr_pull_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; +done: + return NT_STATUS_OK; +} + +NTSTATUS ndr_pull_spoolss_PrinterInfo5(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo5 *r) +{ + NDR_CHECK(ndr_pull_struct_start(ndr)); + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->printername, sizeof(*r->printername), (ndr_pull_flags_fn_t)ndr_pull_nstring)); + NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->portname, sizeof(*r->portname), (ndr_pull_flags_fn_t)ndr_pull_nstring)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->attributes)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->device_not_selected_timeout)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->transmission_retry_timeout)); + ndr_pull_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; +done: + return NT_STATUS_OK; +} + +NTSTATUS ndr_pull_spoolss_PrinterInfo6(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo6 *r) +{ + NDR_CHECK(ndr_pull_struct_start(ndr)); + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->foo)); + ndr_pull_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; +done: + return NT_STATUS_OK; +} + +NTSTATUS ndr_pull_spoolss_PrinterInfo7(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo7 *r) +{ + NDR_CHECK(ndr_pull_struct_start(ndr)); + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->guid, sizeof(*r->guid), (ndr_pull_flags_fn_t)ndr_pull_nstring)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->action)); + ndr_pull_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; +done: + return NT_STATUS_OK; +} + NTSTATUS ndr_pull_spoolss_PrinterEnum(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union spoolss_PrinterEnum *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_struct_start(ndr)); switch (*level) { case 1: { - NDR_CHECK(ndr_pull_spoolss_PrinterEnum1(ndr, NDR_SCALARS, &r->info1)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo1(ndr, NDR_SCALARS, &r->info1)); break; } case 2: { - NDR_CHECK(ndr_pull_spoolss_PrinterEnum2(ndr, NDR_SCALARS, &r->info2)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo2(ndr, NDR_SCALARS, &r->info2)); + break; } + + case 3: { + NDR_CHECK(ndr_pull_spoolss_PrinterInfo3(ndr, NDR_SCALARS, &r->info3)); + break; } + + case 4: { + NDR_CHECK(ndr_pull_spoolss_PrinterInfo4(ndr, NDR_SCALARS, &r->info4)); + break; } + + case 5: { + NDR_CHECK(ndr_pull_spoolss_PrinterInfo5(ndr, NDR_SCALARS, &r->info5)); + break; } + + case 6: { + NDR_CHECK(ndr_pull_spoolss_PrinterInfo6(ndr, NDR_SCALARS, &r->info6)); + break; } + + case 7: { + NDR_CHECK(ndr_pull_spoolss_PrinterInfo7(ndr, NDR_SCALARS, &r->info7)); break; } default: @@ -981,11 +1196,31 @@ buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; switch (*level) { case 1: - NDR_CHECK(ndr_pull_spoolss_PrinterEnum1(ndr, NDR_BUFFERS, &r->info1)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo1(ndr, NDR_BUFFERS, &r->info1)); break; case 2: - NDR_CHECK(ndr_pull_spoolss_PrinterEnum2(ndr, NDR_BUFFERS, &r->info2)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo2(ndr, NDR_BUFFERS, &r->info2)); + break; + + case 3: + NDR_CHECK(ndr_pull_spoolss_PrinterInfo3(ndr, NDR_BUFFERS, &r->info3)); + break; + + case 4: + NDR_CHECK(ndr_pull_spoolss_PrinterInfo4(ndr, NDR_BUFFERS, &r->info4)); + break; + + case 5: + NDR_CHECK(ndr_pull_spoolss_PrinterInfo5(ndr, NDR_BUFFERS, &r->info5)); + break; + + case 6: + NDR_CHECK(ndr_pull_spoolss_PrinterInfo6(ndr, NDR_BUFFERS, &r->info6)); + break; + + case 7: + NDR_CHECK(ndr_pull_spoolss_PrinterInfo7(ndr, NDR_BUFFERS, &r->info7)); break; default: @@ -1009,7 +1244,7 @@ NTSTATUS ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, struct spoolss_Enum } NDR_CHECK(ndr_pull_uint32(ndr, r->out.buf_size)); NDR_CHECK(ndr_pull_uint32(ndr, &r->out.count)); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); + NDR_CHECK(ndr_pull_WERROR(ndr, &r->out.result)); return NT_STATUS_OK; } @@ -1761,9 +1996,9 @@ void ndr_print_spoolss_DeviceMode(struct ndr_print *ndr, const char *name, struc ndr->depth--; } -void ndr_print_spoolss_PrinterEnum1(struct ndr_print *ndr, const char *name, struct spoolss_PrinterEnum1 *r) +void ndr_print_spoolss_PrinterInfo1(struct ndr_print *ndr, const char *name, struct spoolss_PrinterInfo1 *r) { - ndr_print_struct(ndr, name, "spoolss_PrinterEnum1"); + ndr_print_struct(ndr, name, "spoolss_PrinterInfo1"); ndr->depth++; ndr_print_uint32(ndr, "flags", r->flags); ndr_print_nstring(ndr, "name", &r->name); @@ -1772,9 +2007,9 @@ void ndr_print_spoolss_PrinterEnum1(struct ndr_print *ndr, const char *name, str ndr->depth--; } -void ndr_print_spoolss_PrinterEnum2(struct ndr_print *ndr, const char *name, struct spoolss_PrinterEnum2 *r) +void ndr_print_spoolss_PrinterInfo2(struct ndr_print *ndr, const char *name, struct spoolss_PrinterInfo2 *r) { - ndr_print_struct(ndr, name, "spoolss_PrinterEnum2"); + ndr_print_struct(ndr, name, "spoolss_PrinterInfo2"); ndr->depth++; ndr_print_nstring(ndr, "servername", &r->servername); ndr_print_nstring(ndr, "printername", &r->printername); @@ -1810,16 +2045,89 @@ void ndr_print_spoolss_PrinterEnum2(struct ndr_print *ndr, const char *name, str ndr->depth--; } +void ndr_print_spoolss_PrinterInfo3(struct ndr_print *ndr, const char *name, struct spoolss_PrinterInfo3 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo3"); + ndr->depth++; + ndr_print_uint32(ndr, "flags", r->flags); + ndr_print_ptr(ndr, "secdesc", r->secdesc); + ndr->depth++; + if (r->secdesc) { + ndr_print_security_descriptor(ndr, "secdesc", r->secdesc); + } + ndr->depth--; + ndr->depth--; +} + +void ndr_print_spoolss_PrinterInfo4(struct ndr_print *ndr, const char *name, struct spoolss_PrinterInfo4 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo4"); + ndr->depth++; + ndr_print_nstring(ndr, "printername", &r->printername); + ndr_print_nstring(ndr, "servername", &r->servername); + ndr_print_uint32(ndr, "attributes", r->attributes); + ndr->depth--; +} + +void ndr_print_spoolss_PrinterInfo5(struct ndr_print *ndr, const char *name, struct spoolss_PrinterInfo5 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo5"); + ndr->depth++; + ndr_print_nstring(ndr, "printername", &r->printername); + ndr_print_nstring(ndr, "portname", &r->portname); + ndr_print_uint32(ndr, "attributes", r->attributes); + ndr_print_uint32(ndr, "device_not_selected_timeout", r->device_not_selected_timeout); + ndr_print_uint32(ndr, "transmission_retry_timeout", r->transmission_retry_timeout); + ndr->depth--; +} + +void ndr_print_spoolss_PrinterInfo6(struct ndr_print *ndr, const char *name, struct spoolss_PrinterInfo6 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo6"); + ndr->depth++; + ndr_print_uint32(ndr, "foo", r->foo); + ndr->depth--; +} + +void ndr_print_spoolss_PrinterInfo7(struct ndr_print *ndr, const char *name, struct spoolss_PrinterInfo7 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo7"); + ndr->depth++; + ndr_print_nstring(ndr, "guid", &r->guid); + ndr_print_uint32(ndr, "action", r->action); + ndr->depth--; +} + void ndr_print_spoolss_PrinterEnum(struct ndr_print *ndr, const char *name, uint16 level, union spoolss_PrinterEnum *r) { ndr_print_union(ndr, name, level, "spoolss_PrinterEnum"); switch (level) { case 1: - ndr_print_spoolss_PrinterEnum1(ndr, "info1", &r->info1); + ndr_print_spoolss_PrinterInfo1(ndr, "info1", &r->info1); break; case 2: - ndr_print_spoolss_PrinterEnum2(ndr, "info2", &r->info2); + ndr_print_spoolss_PrinterInfo2(ndr, "info2", &r->info2); + break; + + case 3: + ndr_print_spoolss_PrinterInfo3(ndr, "info3", &r->info3); + break; + + case 4: + ndr_print_spoolss_PrinterInfo4(ndr, "info4", &r->info4); + break; + + case 5: + ndr_print_spoolss_PrinterInfo5(ndr, "info5", &r->info5); + break; + + case 6: + ndr_print_spoolss_PrinterInfo6(ndr, "info6", &r->info6); + break; + + case 7: + ndr_print_spoolss_PrinterInfo7(ndr, "info7", &r->info7); break; default: diff --git a/source4/librpc/ndr/ndr_spoolss.h b/source4/librpc/ndr/ndr_spoolss.h index 3c6dffadaf..61aeed9b54 100644 --- a/source4/librpc/ndr/ndr_spoolss.h +++ b/source4/librpc/ndr/ndr_spoolss.h @@ -37,14 +37,14 @@ struct spoolss_DeviceMode { uint32 panningheight; }; -struct spoolss_PrinterEnum1 { +struct spoolss_PrinterInfo1 { uint32 flags; const char * name; const char * description; const char * comment; }; -struct spoolss_PrinterEnum2 { +struct spoolss_PrinterInfo2 { const char * servername; const char * printername; const char * sharename; @@ -68,9 +68,42 @@ struct spoolss_PrinterEnum2 { uint32 averageppm; }; +struct spoolss_PrinterInfo3 { + uint32 flags; + struct security_descriptor *secdesc; +}; + +struct spoolss_PrinterInfo4 { + const char * printername; + const char * servername; + uint32 attributes; +}; + +struct spoolss_PrinterInfo5 { + const char * printername; + const char * portname; + uint32 attributes; + uint32 device_not_selected_timeout; + uint32 transmission_retry_timeout; +}; + +struct spoolss_PrinterInfo6 { + uint32 foo; +}; + +struct spoolss_PrinterInfo7 { + const char * guid; + uint32 action; +}; + union spoolss_PrinterEnum { -/* [case(1)] */ struct spoolss_PrinterEnum1 info1; -/* [case(2)] */ struct spoolss_PrinterEnum2 info2; +/* [case(1)] */ struct spoolss_PrinterInfo1 info1; +/* [case(2)] */ struct spoolss_PrinterInfo2 info2; +/* [case(3)] */ struct spoolss_PrinterInfo3 info3; +/* [case(4)] */ struct spoolss_PrinterInfo4 info4; +/* [case(5)] */ struct spoolss_PrinterInfo5 info5; +/* [case(6)] */ struct spoolss_PrinterInfo6 info6; +/* [case(7)] */ struct spoolss_PrinterInfo7 info7; }; struct spoolss_EnumPrinters { @@ -86,7 +119,7 @@ struct spoolss_EnumPrinters { DATA_BLOB *buffer; uint32 *buf_size; uint32 count; - NTSTATUS result; + WERROR result; } out; }; diff --git a/source4/librpc/rpc/rpc_spoolss.c b/source4/librpc/rpc/rpc_spoolss.c index f7613b82d1..366072c42c 100644 --- a/source4/librpc/rpc/rpc_spoolss.c +++ b/source4/librpc/rpc/rpc_spoolss.c @@ -5,16 +5,10 @@ NTSTATUS dcerpc_spoolss_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinters *r) { - NTSTATUS status; - status = dcerpc_ndr_request(p, DCERPC_SPOOLSS_ENUMPRINTERS, mem_ctx, - (ndr_push_fn_t) ndr_push_spoolss_EnumPrinters, - (ndr_pull_fn_t) ndr_pull_spoolss_EnumPrinters, - r); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - return r->out.result; + return dcerpc_ndr_request(p, DCERPC_SPOOLSS_ENUMPRINTERS, mem_ctx, + (ndr_push_fn_t) ndr_push_spoolss_EnumPrinters, + (ndr_pull_fn_t) ndr_pull_spoolss_EnumPrinters, + r); } NTSTATUS dcerpc_spoolss_01(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_01 *r) diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index d203be2d47..13e2b2642f 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -25,7 +25,7 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { struct spoolss_EnumPrinters r; NTSTATUS status; - uint16 levels[] = {1, 2}; + uint16 levels[] = {1, 2, 3, 4, 5, 6, 7}; int i; BOOL ret = True; @@ -50,20 +50,24 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) continue; } - if (NT_STATUS_V(status) == ERRinsufficientbuffer) { + 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_EnumPrinters(p, mem_ctx, &r); } - if (!NT_STATUS_IS_OK(status)) { - printf("EnumPrinters failed - %s\n", nt_errstr(status)); + if (!NT_STATUS_IS_OK(status) || + !W_ERROR_IS_OK(r.out.result)) { + printf("EnumPrinters failed - %s/%s\n", + nt_errstr(status), win_errstr(r.out.result)); + continue; } status = pull_spoolss_PrinterEnumArray(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; } for (j=0;j<r.out.count;j++) { |