[SCM] Samba Shared Repository - branch v3-4-test updated
Karolin Seeger
kseeger at samba.org
Mon Dec 14 02:54:19 MST 2009
The branch, v3-4-test has been updated
via 874a4e3... spoolss: remove unused spoolss_StringArray2.
via b1097e3... s4-smbtorture: fix and extend enum printerkey test.
via 5323769... s4-smbtorture: enhance spoolss_EnumPrinterKey torture test.
via ef1c97b... s3-spoolss: fix enumprinter key client and server.
via c5e9df5... s3: re-run make samba3-idl.
via ab71e84... spoolss: use spoolss_KeyNames in spoolss_EnumPrinterKey.
via 969623c... spoolss: add spoolss_KeyNames union.
via fc4b430... spoolss: hand-marshall the spoolss_StringArray2 struct for spoolss_EnumPrinterKey.
via 7974ab9... s3-spoolss: handle SEC_FLAG_MAXIMUM_ALLOWED in spoolss_OpenPrinterEx.
via 191167f... samba-spoolss: use spoolss_StringArray2 in spoolss_EnumPrinterKey.
via a6bd5d6... spoolss: add spoolss_StringArray2.
via f190de0... s4-smbtorture: add tests for spoolss_EnumPrinterKey to RPC-SPOOLSS-PRINTER.
via a990887... s4-smbtorture: fix spoolss_EnumPrinterKey client in RPC-SPOOLSS-WIN.
from 24f3fb1... s3:packaging: Fix version detection.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-4-test
- Log -----------------------------------------------------------------
commit 874a4e34ff6222a4d387815f3ec896a24822f94e
Author: Günther Deschner <gd at samba.org>
Date: Thu Dec 10 14:23:49 2009 +0100
spoolss: remove unused spoolss_StringArray2.
Guenther
The last 13 commits address bug #6883 (Add Printer fails with 0x000006f7 on
Windows 7).
commit b1097e33ba4828d1dd7bf7409aa3880e6359c96e
Author: Günther Deschner <gd at samba.org>
Date: Thu Dec 10 14:21:12 2009 +0100
s4-smbtorture: fix and extend enum printerkey test.
Guenther
commit 532376914d0852ab599a6275910ab315935f37d0
Author: Günther Deschner <gd at samba.org>
Date: Wed Dec 9 15:31:51 2009 +0100
s4-smbtorture: enhance spoolss_EnumPrinterKey torture test.
This demonstrates that s3 still does not have that call implemented correctly.
Guenther
commit ef1c97b8c252feabd02f68493f1d83cab9a852d0
Author: Günther Deschner <gd at samba.org>
Date: Thu Dec 10 14:20:22 2009 +0100
s3-spoolss: fix enumprinter key client and server.
Guenther
(cherry picked from commit f20effc437970d826c5bd4f047ff47e23e7a1a73)
commit c5e9df56b3b588f2c7f6f0876204aaf9b9289ee4
Author: Günther Deschner <gd at samba.org>
Date: Fri Dec 11 11:02:55 2009 +0100
s3: re-run make samba3-idl.
Guenther
commit ab71e84ab446eb074a56f7d5d8e7ad69f02ed504
Author: Günther Deschner <gd at samba.org>
Date: Thu Dec 10 14:19:28 2009 +0100
spoolss: use spoolss_KeyNames in spoolss_EnumPrinterKey.
Guenther
(cherry picked from commit 0ecb7f6ab28d7b7c1844554289f5ae8e876b1dcf)
commit 969623c7963219ae3db3058349c257e00adc237b
Author: Günther Deschner <gd at samba.org>
Date: Thu Dec 10 14:18:46 2009 +0100
spoolss: add spoolss_KeyNames union.
Guenther
(cherry picked from commit cf2561473f7bd0bcef5c562c1e901d4ad17e6ee3)
commit fc4b43089e08578f99b99de8eff1eecebaa4ae01
Author: Günther Deschner <gd at samba.org>
Date: Wed Dec 2 21:26:10 2009 +0100
spoolss: hand-marshall the spoolss_StringArray2 struct for spoolss_EnumPrinterKey.
This call is just driving me nuts :-)
Guenther
commit 7974ab9337c7de209f1cdafbd09fd2b71ef45f19
Author: Günther Deschner <gd at samba.org>
Date: Thu Dec 3 23:23:36 2009 +0100
s3-spoolss: handle SEC_FLAG_MAXIMUM_ALLOWED in spoolss_OpenPrinterEx.
In case someone (smbtorture4) requests SEC_FLAG_MAXIMUM_ALLOWED, translate it
to a request of PRINTER_ACCESS_ADMINISTER.
Guenther
(cherry picked from commit 459a968fb4d6f96ea7f310f331d3547e2e466d6a)
commit 191167fce3cb07e286c3b1cedf4fb70126e6daf7
Author: Günther Deschner <gd at samba.org>
Date: Wed Dec 2 14:53:39 2009 +0100
samba-spoolss: use spoolss_StringArray2 in spoolss_EnumPrinterKey.
This should finally resolve the endian issues we were seeing on sparc and is
much cleaner for spoolss clients and servers.
Guenther
commit a6bd5d61685f5582a72d24ac72c6e3753f232f90
Author: Günther Deschner <gd at samba.org>
Date: Wed Dec 2 14:22:52 2009 +0100
spoolss: add spoolss_StringArray2.
The difference to spoolss_StringArray is that in spoolss_StringArray2 the string
array is put into a subcontext of _ndr_size.
Guenther
commit f190de033b9b13b5ffaaf98e86a336bc48ce84e4
Author: Günther Deschner <gd at samba.org>
Date: Fri Nov 20 16:33:29 2009 +0100
s4-smbtorture: add tests for spoolss_EnumPrinterKey to RPC-SPOOLSS-PRINTER.
Guenther
commit a990887d02de6c92f7d97631bd3f04c49007df2e
Author: Günther Deschner <gd at samba.org>
Date: Mon Nov 23 13:35:32 2009 +0100
s4-smbtorture: fix spoolss_EnumPrinterKey client in RPC-SPOOLSS-WIN.
Guenther
-----------------------------------------------------------------------
Summary of changes:
librpc/gen_ndr/cli_spoolss.c | 6 +-
librpc/gen_ndr/cli_spoolss.h | 3 +-
librpc/gen_ndr/ndr_spoolss.c | 165 ++++++++++++++++++++++++++++------
librpc/gen_ndr/ndr_spoolss.h | 1 +
librpc/gen_ndr/spoolss.h | 7 ++-
librpc/gen_ndr/srv_spoolss.c | 15 +++-
librpc/idl/spoolss.idl | 9 ++-
source3/rpc_client/cli_spoolss.c | 27 ++----
source3/rpc_server/srv_spoolss_nt.c | 17 +++-
source4/torture/rpc/spoolss.c | 145 ++++++++++++++++++++++++++++++
source4/torture/rpc/spoolss_win.c | 9 ++-
11 files changed, 343 insertions(+), 61 deletions(-)
Changeset truncated at 500 lines:
diff --git a/librpc/gen_ndr/cli_spoolss.c b/librpc/gen_ndr/cli_spoolss.c
index b605f58..10dd8b4 100644
--- a/librpc/gen_ndr/cli_spoolss.c
+++ b/librpc/gen_ndr/cli_spoolss.c
@@ -3811,7 +3811,8 @@ NTSTATUS rpccli_spoolss_EnumPrinterKey(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle /* [in] [ref] */,
const char *key_name /* [in] [charset(UTF16)] */,
- uint16_t *key_buffer /* [out] [ref,size_is(offered/2)] */,
+ uint32_t *_ndr_size /* [out] [ref] */,
+ union spoolss_KeyNames *key_buffer /* [out] [subcontext_size(*_ndr_size*2),ref,subcontext(0),switch_is(*_ndr_size)] */,
uint32_t offered /* [in] */,
uint32_t *needed /* [out] [ref] */,
WERROR *werror)
@@ -3847,7 +3848,8 @@ NTSTATUS rpccli_spoolss_EnumPrinterKey(struct rpc_pipe_client *cli,
}
/* Return variables */
- memcpy(key_buffer, r.out.key_buffer, (r.in.offered / 2) * sizeof(*key_buffer));
+ *_ndr_size = *r.out._ndr_size;
+ *key_buffer = *r.out.key_buffer;
*needed = *r.out.needed;
/* Return result */
diff --git a/librpc/gen_ndr/cli_spoolss.h b/librpc/gen_ndr/cli_spoolss.h
index 4c621f4..eb1e8dd 100644
--- a/librpc/gen_ndr/cli_spoolss.h
+++ b/librpc/gen_ndr/cli_spoolss.h
@@ -497,7 +497,8 @@ NTSTATUS rpccli_spoolss_EnumPrinterKey(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle /* [in] [ref] */,
const char *key_name /* [in] [charset(UTF16)] */,
- uint16_t *key_buffer /* [out] [ref,size_is(offered/2)] */,
+ uint32_t *_ndr_size /* [out] [ref] */,
+ union spoolss_KeyNames *key_buffer /* [out] [subcontext_size(*_ndr_size*2),ref,subcontext(0),switch_is(*_ndr_size)] */,
uint32_t offered /* [in] */,
uint32_t *needed /* [out] [ref] */,
WERROR *werror);
diff --git a/librpc/gen_ndr/ndr_spoolss.c b/librpc/gen_ndr/ndr_spoolss.c
index d03196e..d531cbf 100644
--- a/librpc/gen_ndr/ndr_spoolss.c
+++ b/librpc/gen_ndr/ndr_spoolss.c
@@ -18522,6 +18522,103 @@ _PUBLIC_ size_t ndr_size_spoolss_PrinterEnumValues(const struct spoolss_PrinterE
return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterEnumValues, ic);
}
+static enum ndr_err_code ndr_push_spoolss_KeyNames(struct ndr_push *ndr, int ndr_flags, const union spoolss_KeyNames *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case 0: {
+ break; }
+
+ case 1: {
+ break; }
+
+ default: {
+ {
+ uint32_t _flags_save_string_array = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string_array(ndr, NDR_SCALARS, r->string_array));
+ ndr->flags = _flags_save_string_array;
+ }
+ break; }
+
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case 0:
+ break;
+
+ case 1:
+ break;
+
+ default:
+ break;
+
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_KeyNames(struct ndr_pull *ndr, int ndr_flags, union spoolss_KeyNames *r)
+{
+ int level;
+ level = ndr_pull_get_switch_value(ndr, r);
+ if (ndr_flags & NDR_SCALARS) {
+ switch (level) {
+ case 0: {
+ break; }
+
+ case 1: {
+ break; }
+
+ default: {
+ {
+ uint32_t _flags_save_string_array = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string_array(ndr, NDR_SCALARS, &r->string_array));
+ ndr->flags = _flags_save_string_array;
+ }
+ break; }
+
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ switch (level) {
+ case 0:
+ break;
+
+ case 1:
+ break;
+
+ default:
+ break;
+
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_KeyNames(struct ndr_print *ndr, const char *name, const union spoolss_KeyNames *r)
+{
+ int level;
+ level = ndr_print_get_switch_value(ndr, r);
+ ndr_print_union(ndr, name, level, "spoolss_KeyNames");
+ switch (level) {
+ case 0:
+ break;
+
+ case 1:
+ break;
+
+ default:
+ ndr_print_string_array(ndr, "string_array", r->string_array);
+ break;
+
+ }
+}
+
_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DeleteDriverFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r)
{
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
@@ -26619,7 +26716,6 @@ _PUBLIC_ void ndr_print_spoolss_EnumPrinterDataEx(struct ndr_print *ndr, const c
_PUBLIC_ enum ndr_err_code ndr_push_spoolss_EnumPrinterKey(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterKey *r)
{
- uint32_t cntr_key_buffer_1;
if (flags & NDR_IN) {
if (r->in.handle == NULL) {
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
@@ -26632,12 +26728,19 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_EnumPrinterKey(struct ndr_push *ndr,
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered));
}
if (flags & NDR_OUT) {
+ if (r->out._ndr_size == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out._ndr_size));
if (r->out.key_buffer == NULL) {
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
}
- NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered / 2));
- for (cntr_key_buffer_1 = 0; cntr_key_buffer_1 < r->in.offered / 2; cntr_key_buffer_1++) {
- NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->out.key_buffer[cntr_key_buffer_1]));
+ {
+ struct ndr_push *_ndr_key_buffer;
+ NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_key_buffer, 0, *r->out._ndr_size * 2));
+ NDR_CHECK(ndr_push_set_switch_value(_ndr_key_buffer, r->out.key_buffer, *r->out._ndr_size));
+ NDR_CHECK(ndr_push_spoolss_KeyNames(_ndr_key_buffer, NDR_SCALARS|NDR_BUFFERS, r->out.key_buffer));
+ NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_key_buffer, 0, *r->out._ndr_size * 2));
}
if (r->out.needed == NULL) {
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
@@ -26650,9 +26753,9 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_EnumPrinterKey(struct ndr_push *ndr,
_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_EnumPrinterKey(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterKey *r)
{
- uint32_t cntr_key_buffer_1;
TALLOC_CTX *_mem_save_handle_0;
- TALLOC_CTX *_mem_save_key_buffer_1;
+ TALLOC_CTX *_mem_save__ndr_size_0;
+ TALLOC_CTX *_mem_save_key_buffer_0;
TALLOC_CTX *_mem_save_needed_0;
if (flags & NDR_IN) {
ZERO_STRUCT(r->out);
@@ -26672,22 +26775,34 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_EnumPrinterKey(struct ndr_pull *ndr,
NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.key_name), sizeof(uint16_t)));
NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.key_name, ndr_get_array_length(ndr, &r->in.key_name), sizeof(uint16_t), CH_UTF16));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered));
- NDR_PULL_ALLOC_N(ndr, r->out.key_buffer, r->in.offered / 2);
- memset(r->out.key_buffer, 0, (r->in.offered / 2) * sizeof(*r->out.key_buffer));
+ NDR_PULL_ALLOC(ndr, r->out._ndr_size);
+ ZERO_STRUCTP(r->out._ndr_size);
+ NDR_PULL_ALLOC(ndr, r->out.key_buffer);
+ ZERO_STRUCTP(r->out.key_buffer);
NDR_PULL_ALLOC(ndr, r->out.needed);
ZERO_STRUCTP(r->out.needed);
}
if (flags & NDR_OUT) {
- NDR_CHECK(ndr_pull_array_size(ndr, &r->out.key_buffer));
if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
- NDR_PULL_ALLOC_N(ndr, r->out.key_buffer, ndr_get_array_size(ndr, &r->out.key_buffer));
+ NDR_PULL_ALLOC(ndr, r->out._ndr_size);
+ }
+ _mem_save__ndr_size_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->out._ndr_size, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out._ndr_size));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save__ndr_size_0, LIBNDR_FLAG_REF_ALLOC);
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, r->out.key_buffer);
}
- _mem_save_key_buffer_1 = NDR_PULL_GET_MEM_CTX(ndr);
- NDR_PULL_SET_MEM_CTX(ndr, r->out.key_buffer, 0);
- for (cntr_key_buffer_1 = 0; cntr_key_buffer_1 < r->in.offered / 2; cntr_key_buffer_1++) {
- NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->out.key_buffer[cntr_key_buffer_1]));
+ _mem_save_key_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->out.key_buffer, LIBNDR_FLAG_REF_ALLOC);
+ {
+ struct ndr_pull *_ndr_key_buffer;
+ NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_key_buffer, 0, *r->out._ndr_size * 2));
+ NDR_CHECK(ndr_pull_set_switch_value(_ndr_key_buffer, r->out.key_buffer, *r->out._ndr_size));
+ NDR_CHECK(ndr_pull_spoolss_KeyNames(_ndr_key_buffer, NDR_SCALARS|NDR_BUFFERS, r->out.key_buffer));
+ NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_key_buffer, 0, *r->out._ndr_size * 2));
}
- NDR_PULL_SET_MEM_CTX(ndr, _mem_save_key_buffer_1, 0);
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_key_buffer_0, LIBNDR_FLAG_REF_ALLOC);
if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
NDR_PULL_ALLOC(ndr, r->out.needed);
}
@@ -26696,16 +26811,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_EnumPrinterKey(struct ndr_pull *ndr,
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.needed));
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_needed_0, LIBNDR_FLAG_REF_ALLOC);
NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result));
- if (r->out.key_buffer) {
- NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->out.key_buffer, r->in.offered / 2));
- }
}
return NDR_ERR_SUCCESS;
}
_PUBLIC_ void ndr_print_spoolss_EnumPrinterKey(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrinterKey *r)
{
- uint32_t cntr_key_buffer_1;
ndr_print_struct(ndr, name, "spoolss_EnumPrinterKey");
ndr->depth++;
if (flags & NDR_SET_VALUES) {
@@ -26725,18 +26836,14 @@ _PUBLIC_ void ndr_print_spoolss_EnumPrinterKey(struct ndr_print *ndr, const char
if (flags & NDR_OUT) {
ndr_print_struct(ndr, "out", "spoolss_EnumPrinterKey");
ndr->depth++;
- ndr_print_ptr(ndr, "key_buffer", r->out.key_buffer);
- ndr->depth++;
- ndr->print(ndr, "%s: ARRAY(%d)", "key_buffer", (int)r->in.offered / 2);
+ ndr_print_ptr(ndr, "_ndr_size", r->out._ndr_size);
ndr->depth++;
- for (cntr_key_buffer_1=0;cntr_key_buffer_1<r->in.offered / 2;cntr_key_buffer_1++) {
- char *idx_1=NULL;
- if (asprintf(&idx_1, "[%d]", cntr_key_buffer_1) != -1) {
- ndr_print_uint16(ndr, "key_buffer", r->out.key_buffer[cntr_key_buffer_1]);
- free(idx_1);
- }
- }
+ ndr_print_uint32(ndr, "_ndr_size", *r->out._ndr_size);
ndr->depth--;
+ ndr_print_ptr(ndr, "key_buffer", r->out.key_buffer);
+ ndr->depth++;
+ ndr_print_set_switch_value(ndr, r->out.key_buffer, *r->out._ndr_size);
+ ndr_print_spoolss_KeyNames(ndr, "key_buffer", r->out.key_buffer);
ndr->depth--;
ndr_print_ptr(ndr, "needed", r->out.needed);
ndr->depth++;
diff --git a/librpc/gen_ndr/ndr_spoolss.h b/librpc/gen_ndr/ndr_spoolss.h
index 204aad8..1b94124 100644
--- a/librpc/gen_ndr/ndr_spoolss.h
+++ b/librpc/gen_ndr/ndr_spoolss.h
@@ -480,6 +480,7 @@ enum ndr_err_code ndr_push_spoolss_PrinterEnumValues(struct ndr_push *ndr, int n
enum ndr_err_code ndr_pull_spoolss_PrinterEnumValues(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterEnumValues *r);
void ndr_print_spoolss_PrinterEnumValues(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterEnumValues *r);
size_t ndr_size_spoolss_PrinterEnumValues(const struct spoolss_PrinterEnumValues *r, struct smb_iconv_convenience *ic, int flags);
+void ndr_print_spoolss_KeyNames(struct ndr_print *ndr, const char *name, const union spoolss_KeyNames *r);
enum ndr_err_code ndr_push_spoolss_DeleteDriverFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r);
enum ndr_err_code ndr_pull_spoolss_DeleteDriverFlags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r);
void ndr_print_spoolss_DeleteDriverFlags(struct ndr_print *ndr, const char *name, uint32_t r);
diff --git a/librpc/gen_ndr/spoolss.h b/librpc/gen_ndr/spoolss.h
index 2053065..bd63485 100644
--- a/librpc/gen_ndr/spoolss.h
+++ b/librpc/gen_ndr/spoolss.h
@@ -1563,6 +1563,10 @@ struct spoolss_PrinterEnumValues {
uint32_t data_length;/* [value(ndr_size_spoolss_PrinterData(data,type,ndr->iconv_convenience,ndr->flags))] */
}/* [relative_base,gensize,public] */;
+union spoolss_KeyNames {
+ const char ** string_array;/* [default,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+}/* [nodiscriminant] */;
+
/* bitmap spoolss_DeleteDriverFlags */
#define DPD_DELETE_UNUSED_FILES ( 0x00000001 )
#define DPD_DELETE_SPECIFIC_VERSION ( 0x00000002 )
@@ -3030,7 +3034,8 @@ struct spoolss_EnumPrinterKey {
} in;
struct {
- uint16_t *key_buffer;/* [ref,size_is(offered/2)] */
+ uint32_t *_ndr_size;/* [ref] */
+ union spoolss_KeyNames *key_buffer;/* [subcontext_size(*_ndr_size*2),ref,subcontext(0),switch_is(*_ndr_size)] */
uint32_t *needed;/* [ref] */
WERROR result;
} out;
diff --git a/librpc/gen_ndr/srv_spoolss.c b/librpc/gen_ndr/srv_spoolss.c
index 3bbe401..9e58eb5 100644
--- a/librpc/gen_ndr/srv_spoolss.c
+++ b/librpc/gen_ndr/srv_spoolss.c
@@ -6296,7 +6296,13 @@ static bool api_spoolss_EnumPrinterKey(pipes_struct *p)
}
ZERO_STRUCT(r->out);
- r->out.key_buffer = talloc_zero_array(r, uint16_t, r->in.offered / 2);
+ r->out._ndr_size = talloc_zero(r, uint32_t);
+ if (r->out._ndr_size == NULL) {
+ talloc_free(r);
+ return false;
+ }
+
+ r->out.key_buffer = talloc_zero(r, union spoolss_KeyNames);
if (r->out.key_buffer == NULL) {
talloc_free(r);
return false;
@@ -8399,7 +8405,12 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
case NDR_SPOOLSS_ENUMPRINTERKEY: {
struct spoolss_EnumPrinterKey *r = (struct spoolss_EnumPrinterKey *)_r;
ZERO_STRUCT(r->out);
- r->out.key_buffer = talloc_zero_array(mem_ctx, uint16_t, r->in.offered / 2);
+ r->out._ndr_size = talloc_zero(mem_ctx, uint32_t);
+ if (r->out._ndr_size == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ r->out.key_buffer = talloc_zero(mem_ctx, union spoolss_KeyNames);
if (r->out.key_buffer == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl
index e4f03e5..1bea82e 100644
--- a/librpc/idl/spoolss.idl
+++ b/librpc/idl/spoolss.idl
@@ -2297,12 +2297,19 @@ import "misc.idl", "security.idl", "winreg.idl";
[out,ref] uint32 *needed
);
+ typedef [nodiscriminant] union {
+ [case(0)];
+ [case(1)];
+ [default] nstring_array string_array;
+ } spoolss_KeyNames;
+
/******************/
/* Function: 0x50 */
[public] WERROR spoolss_EnumPrinterKey(
[in, ref] policy_handle *handle,
[in] [string,charset(UTF16)] uint16 key_name[],
- [out,ref] [size_is(offered/2)] uint16 *key_buffer,
+ [out,ref] uint32 *_ndr_size,
+ [out,ref,subcontext(0),subcontext_size(*_ndr_size*2),switch_is(*_ndr_size)] spoolss_KeyNames *key_buffer,
[in] uint32 offered,
[out,ref] uint32 *needed
);
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index 5522ca7..bc4a4e7 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -760,44 +760,31 @@ WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
NTSTATUS status;
WERROR werror;
uint32_t needed;
- uint16_t *buffer = NULL;
-
- *key_buffer = NULL;
-
- if (offered) {
- buffer = talloc_array(mem_ctx, uint16_t, offered/2);
- W_ERROR_HAVE_NO_MEMORY(buffer);
- }
+ union spoolss_KeyNames _key_buffer;
+ uint32_t _ndr_size;
status = rpccli_spoolss_EnumPrinterKey(cli, mem_ctx,
handle,
key_name,
- buffer,
+ &_ndr_size,
+ &_key_buffer,
offered,
&needed,
&werror);
if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
offered = needed;
- buffer = talloc_realloc(mem_ctx, buffer, uint16_t, needed/2);
- W_ERROR_HAVE_NO_MEMORY(buffer);
status = rpccli_spoolss_EnumPrinterKey(cli, mem_ctx,
handle,
key_name,
- buffer,
+ &_ndr_size,
+ &_key_buffer,
offered,
&needed,
&werror);
}
- if (W_ERROR_IS_OK(werror)) {
- const char **array;
- DATA_BLOB blob = data_blob_const((uint8_t *)buffer, offered);
- if (!pull_reg_multi_sz(mem_ctx, &blob, &array)) {
- return WERR_NOMEM;
- }
- *key_buffer = array;
- }
+ *key_buffer = _key_buffer.string_array;
return werror;
}
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index af0c952..e88c733 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -1670,6 +1670,10 @@ WERROR _spoolss_OpenPrinterEx(pipes_struct *p,
return WERR_BADFID;
}
+ if (r->in.access_mask == SEC_FLAG_MAXIMUM_ALLOWED) {
+ r->in.access_mask = PRINTER_ACCESS_ADMINISTER;
+ }
+
se_map_standard(&r->in.access_mask, &printer_std_mapping);
/* map an empty access mask to the minimum access mask */
@@ -9288,12 +9292,20 @@ WERROR _spoolss_EnumPrinterKey(pipes_struct *p,
goto done;
}
- array = talloc_zero_array(r->out.key_buffer, const char *, num_keys + 1);
+ array = talloc_zero_array(r->out.key_buffer, const char *, num_keys + 2);
if (!array) {
result = WERR_NOMEM;
goto done;
}
+ if (!num_keys) {
+ array[0] = talloc_strdup(array, "");
+ if (!array[0]) {
+ result = WERR_NOMEM;
+ goto done;
+ }
+ }
+
for (i=0; i < num_keys; i++) {
DEBUG(10,("_spoolss_EnumPrinterKey: adding keyname: %s\n",
@@ -9311,13 +9323,14 @@ WERROR _spoolss_EnumPrinterKey(pipes_struct *p,
goto done;
}
+ *r->out._ndr_size = r->in.offered / 2;
*r->out.needed = blob.length;
if (r->in.offered < *r->out.needed) {
result = WERR_MORE_DATA;
} else {
result = WERR_OK;
- memcpy(r->out.key_buffer, blob.data, blob.length);
+ r->out.key_buffer->string_array = array;
}
done:
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index bfe6672..d107616 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -23,7 +23,9 @@
#include "includes.h"
#include "torture/torture.h"
#include "torture/rpc/rpc.h"
+#include "librpc/gen_ndr/ndr_misc.h"
#include "librpc/gen_ndr/ndr_spoolss_c.h"
+#include "param/param.h"
struct test_spoolss_context {
/* print server handle */
@@ -2000,6 +2002,149 @@ static bool test_EnumPrinterDrivers_old(struct torture_context *tctx,
return true;
}
+static bool test_EnumPrinterKey(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle,
--
Samba Shared Repository
More information about the samba-cvs
mailing list