mirror of
https://github.com/samba-team/samba.git
synced 2025-02-25 17:57:42 +03:00
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
This commit is contained in:
parent
292af4fc04
commit
5f60855ba2
@ -12207,7 +12207,7 @@ struct tevent_req *rpccli_spoolss_EnumPrinterKey_send(TALLOC_CTX *mem_ctx,
|
|||||||
struct rpc_pipe_client *cli,
|
struct rpc_pipe_client *cli,
|
||||||
struct policy_handle *_handle /* [in] [ref] */,
|
struct policy_handle *_handle /* [in] [ref] */,
|
||||||
const char *_key_name /* [in] [charset(UTF16)] */,
|
const char *_key_name /* [in] [charset(UTF16)] */,
|
||||||
uint16_t *_key_buffer /* [out] [ref,size_is(offered/2)] */,
|
struct spoolss_StringArray2 *_key_buffer /* [out] [ref] */,
|
||||||
uint32_t _offered /* [in] */,
|
uint32_t _offered /* [in] */,
|
||||||
uint32_t *_needed /* [out] [ref] */)
|
uint32_t *_needed /* [out] [ref] */)
|
||||||
{
|
{
|
||||||
@ -12278,7 +12278,7 @@ static void rpccli_spoolss_EnumPrinterKey_done(struct tevent_req *subreq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Copy out parameters */
|
/* Copy out parameters */
|
||||||
memcpy(state->orig.out.key_buffer, state->tmp.out.key_buffer, (state->tmp.in.offered / 2) * sizeof(*state->orig.out.key_buffer));
|
*state->orig.out.key_buffer = *state->tmp.out.key_buffer;
|
||||||
*state->orig.out.needed = *state->tmp.out.needed;
|
*state->orig.out.needed = *state->tmp.out.needed;
|
||||||
|
|
||||||
/* Copy result */
|
/* Copy result */
|
||||||
@ -12317,7 +12317,7 @@ NTSTATUS rpccli_spoolss_EnumPrinterKey(struct rpc_pipe_client *cli,
|
|||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
struct policy_handle *handle /* [in] [ref] */,
|
struct policy_handle *handle /* [in] [ref] */,
|
||||||
const char *key_name /* [in] [charset(UTF16)] */,
|
const char *key_name /* [in] [charset(UTF16)] */,
|
||||||
uint16_t *key_buffer /* [out] [ref,size_is(offered/2)] */,
|
struct spoolss_StringArray2 *key_buffer /* [out] [ref] */,
|
||||||
uint32_t offered /* [in] */,
|
uint32_t offered /* [in] */,
|
||||||
uint32_t *needed /* [out] [ref] */,
|
uint32_t *needed /* [out] [ref] */,
|
||||||
WERROR *werror)
|
WERROR *werror)
|
||||||
@ -12345,7 +12345,7 @@ NTSTATUS rpccli_spoolss_EnumPrinterKey(struct rpc_pipe_client *cli,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return variables */
|
/* Return variables */
|
||||||
memcpy(key_buffer, r.out.key_buffer, (r.in.offered / 2) * sizeof(*key_buffer));
|
*key_buffer = *r.out.key_buffer;
|
||||||
*needed = *r.out.needed;
|
*needed = *r.out.needed;
|
||||||
|
|
||||||
/* Return result */
|
/* Return result */
|
||||||
|
@ -1262,7 +1262,7 @@ struct tevent_req *rpccli_spoolss_EnumPrinterKey_send(TALLOC_CTX *mem_ctx,
|
|||||||
struct rpc_pipe_client *cli,
|
struct rpc_pipe_client *cli,
|
||||||
struct policy_handle *_handle /* [in] [ref] */,
|
struct policy_handle *_handle /* [in] [ref] */,
|
||||||
const char *_key_name /* [in] [charset(UTF16)] */,
|
const char *_key_name /* [in] [charset(UTF16)] */,
|
||||||
uint16_t *_key_buffer /* [out] [ref,size_is(offered/2)] */,
|
struct spoolss_StringArray2 *_key_buffer /* [out] [ref] */,
|
||||||
uint32_t _offered /* [in] */,
|
uint32_t _offered /* [in] */,
|
||||||
uint32_t *_needed /* [out] [ref] */);
|
uint32_t *_needed /* [out] [ref] */);
|
||||||
NTSTATUS rpccli_spoolss_EnumPrinterKey_recv(struct tevent_req *req,
|
NTSTATUS rpccli_spoolss_EnumPrinterKey_recv(struct tevent_req *req,
|
||||||
@ -1272,7 +1272,7 @@ NTSTATUS rpccli_spoolss_EnumPrinterKey(struct rpc_pipe_client *cli,
|
|||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
struct policy_handle *handle /* [in] [ref] */,
|
struct policy_handle *handle /* [in] [ref] */,
|
||||||
const char *key_name /* [in] [charset(UTF16)] */,
|
const char *key_name /* [in] [charset(UTF16)] */,
|
||||||
uint16_t *key_buffer /* [out] [ref,size_is(offered/2)] */,
|
struct spoolss_StringArray2 *key_buffer /* [out] [ref] */,
|
||||||
uint32_t offered /* [in] */,
|
uint32_t offered /* [in] */,
|
||||||
uint32_t *needed /* [out] [ref] */,
|
uint32_t *needed /* [out] [ref] */,
|
||||||
WERROR *werror);
|
WERROR *werror);
|
||||||
|
@ -28127,7 +28127,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)
|
_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 (flags & NDR_IN) {
|
||||||
if (r->in.handle == NULL) {
|
if (r->in.handle == NULL) {
|
||||||
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
|
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
|
||||||
@ -28143,10 +28142,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_EnumPrinterKey(struct ndr_push *ndr,
|
|||||||
if (r->out.key_buffer == NULL) {
|
if (r->out.key_buffer == NULL) {
|
||||||
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
|
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
|
||||||
}
|
}
|
||||||
NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->in.offered / 2));
|
NDR_CHECK(ndr_push_spoolss_StringArray2(ndr, NDR_SCALARS, r->out.key_buffer));
|
||||||
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]));
|
|
||||||
}
|
|
||||||
if (r->out.needed == NULL) {
|
if (r->out.needed == NULL) {
|
||||||
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
|
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
|
||||||
}
|
}
|
||||||
@ -28158,9 +28154,8 @@ _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)
|
_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_handle_0;
|
||||||
TALLOC_CTX *_mem_save_key_buffer_1;
|
TALLOC_CTX *_mem_save_key_buffer_0;
|
||||||
TALLOC_CTX *_mem_save_needed_0;
|
TALLOC_CTX *_mem_save_needed_0;
|
||||||
if (flags & NDR_IN) {
|
if (flags & NDR_IN) {
|
||||||
ZERO_STRUCT(r->out);
|
ZERO_STRUCT(r->out);
|
||||||
@ -28180,22 +28175,19 @@ _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_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_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_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered));
|
||||||
NDR_PULL_ALLOC_N(ndr, r->out.key_buffer, r->in.offered / 2);
|
NDR_PULL_ALLOC(ndr, r->out.key_buffer);
|
||||||
memset(r->out.key_buffer, 0, (r->in.offered / 2) * sizeof(*r->out.key_buffer));
|
ZERO_STRUCTP(r->out.key_buffer);
|
||||||
NDR_PULL_ALLOC(ndr, r->out.needed);
|
NDR_PULL_ALLOC(ndr, r->out.needed);
|
||||||
ZERO_STRUCTP(r->out.needed);
|
ZERO_STRUCTP(r->out.needed);
|
||||||
}
|
}
|
||||||
if (flags & NDR_OUT) {
|
if (flags & NDR_OUT) {
|
||||||
NDR_CHECK(ndr_pull_array_size(ndr, &r->out.key_buffer));
|
|
||||||
if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
|
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.key_buffer);
|
||||||
}
|
}
|
||||||
_mem_save_key_buffer_1 = NDR_PULL_GET_MEM_CTX(ndr);
|
_mem_save_key_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr);
|
||||||
NDR_PULL_SET_MEM_CTX(ndr, r->out.key_buffer, 0);
|
NDR_PULL_SET_MEM_CTX(ndr, r->out.key_buffer, LIBNDR_FLAG_REF_ALLOC);
|
||||||
for (cntr_key_buffer_1 = 0; cntr_key_buffer_1 < r->in.offered / 2; cntr_key_buffer_1++) {
|
NDR_CHECK(ndr_pull_spoolss_StringArray2(ndr, NDR_SCALARS, r->out.key_buffer));
|
||||||
NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->out.key_buffer[cntr_key_buffer_1]));
|
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_key_buffer_0, LIBNDR_FLAG_REF_ALLOC);
|
||||||
}
|
|
||||||
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_key_buffer_1, 0);
|
|
||||||
if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
|
if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
|
||||||
NDR_PULL_ALLOC(ndr, r->out.needed);
|
NDR_PULL_ALLOC(ndr, r->out.needed);
|
||||||
}
|
}
|
||||||
@ -28204,16 +28196,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_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_PULL_SET_MEM_CTX(ndr, _mem_save_needed_0, LIBNDR_FLAG_REF_ALLOC);
|
||||||
NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result));
|
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;
|
return NDR_ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
_PUBLIC_ void ndr_print_spoolss_EnumPrinterKey(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrinterKey *r)
|
_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_print_struct(ndr, name, "spoolss_EnumPrinterKey");
|
||||||
ndr->depth++;
|
ndr->depth++;
|
||||||
if (flags & NDR_SET_VALUES) {
|
if (flags & NDR_SET_VALUES) {
|
||||||
@ -28235,16 +28223,7 @@ _PUBLIC_ void ndr_print_spoolss_EnumPrinterKey(struct ndr_print *ndr, const char
|
|||||||
ndr->depth++;
|
ndr->depth++;
|
||||||
ndr_print_ptr(ndr, "key_buffer", r->out.key_buffer);
|
ndr_print_ptr(ndr, "key_buffer", r->out.key_buffer);
|
||||||
ndr->depth++;
|
ndr->depth++;
|
||||||
ndr->print(ndr, "%s: ARRAY(%d)", "key_buffer", (int)r->in.offered / 2);
|
ndr_print_spoolss_StringArray2(ndr, "key_buffer", r->out.key_buffer);
|
||||||
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->depth--;
|
|
||||||
ndr->depth--;
|
ndr->depth--;
|
||||||
ndr_print_ptr(ndr, "needed", r->out.needed);
|
ndr_print_ptr(ndr, "needed", r->out.needed);
|
||||||
ndr->depth++;
|
ndr->depth++;
|
||||||
|
@ -3557,7 +3557,7 @@ struct spoolss_EnumPrinterKey {
|
|||||||
} in;
|
} in;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint16_t *key_buffer;/* [ref,size_is(offered/2)] */
|
struct spoolss_StringArray2 *key_buffer;/* [ref] */
|
||||||
uint32_t *needed;/* [ref] */
|
uint32_t *needed;/* [ref] */
|
||||||
WERROR result;
|
WERROR result;
|
||||||
} out;
|
} out;
|
||||||
|
@ -6325,7 +6325,7 @@ static bool api_spoolss_EnumPrinterKey(pipes_struct *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ZERO_STRUCT(r->out);
|
ZERO_STRUCT(r->out);
|
||||||
r->out.key_buffer = talloc_zero_array(r, uint16_t, r->in.offered / 2);
|
r->out.key_buffer = talloc_zero(r, struct spoolss_StringArray2);
|
||||||
if (r->out.key_buffer == NULL) {
|
if (r->out.key_buffer == NULL) {
|
||||||
talloc_free(r);
|
talloc_free(r);
|
||||||
return false;
|
return false;
|
||||||
@ -9504,7 +9504,7 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|||||||
case NDR_SPOOLSS_ENUMPRINTERKEY: {
|
case NDR_SPOOLSS_ENUMPRINTERKEY: {
|
||||||
struct spoolss_EnumPrinterKey *r = (struct spoolss_EnumPrinterKey *)_r;
|
struct spoolss_EnumPrinterKey *r = (struct spoolss_EnumPrinterKey *)_r;
|
||||||
ZERO_STRUCT(r->out);
|
ZERO_STRUCT(r->out);
|
||||||
r->out.key_buffer = talloc_zero_array(mem_ctx, uint16_t, r->in.offered / 2);
|
r->out.key_buffer = talloc_zero(mem_ctx, struct spoolss_StringArray2);
|
||||||
if (r->out.key_buffer == NULL) {
|
if (r->out.key_buffer == NULL) {
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -2583,7 +2583,7 @@ import "misc.idl", "security.idl", "winreg.idl";
|
|||||||
[public] WERROR spoolss_EnumPrinterKey(
|
[public] WERROR spoolss_EnumPrinterKey(
|
||||||
[in, ref] policy_handle *handle,
|
[in, ref] policy_handle *handle,
|
||||||
[in] [string,charset(UTF16)] uint16 key_name[],
|
[in] [string,charset(UTF16)] uint16 key_name[],
|
||||||
[out,ref] [size_is(offered/2)] uint16 *key_buffer,
|
[out,ref] spoolss_StringArray2 *key_buffer,
|
||||||
[in] uint32 offered,
|
[in] uint32 offered,
|
||||||
[out,ref] uint32 *needed
|
[out,ref] uint32 *needed
|
||||||
);
|
);
|
||||||
|
@ -810,44 +810,28 @@ WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
WERROR werror;
|
WERROR werror;
|
||||||
uint32_t needed;
|
uint32_t needed;
|
||||||
uint16_t *buffer = NULL;
|
struct spoolss_StringArray2 _key_buffer;
|
||||||
|
|
||||||
*key_buffer = NULL;
|
|
||||||
|
|
||||||
if (offered) {
|
|
||||||
buffer = talloc_array(mem_ctx, uint16_t, offered/2);
|
|
||||||
W_ERROR_HAVE_NO_MEMORY(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
status = rpccli_spoolss_EnumPrinterKey(cli, mem_ctx,
|
status = rpccli_spoolss_EnumPrinterKey(cli, mem_ctx,
|
||||||
handle,
|
handle,
|
||||||
key_name,
|
key_name,
|
||||||
buffer,
|
&_key_buffer,
|
||||||
offered,
|
offered,
|
||||||
&needed,
|
&needed,
|
||||||
&werror);
|
&werror);
|
||||||
|
|
||||||
if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
|
if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
|
||||||
offered = needed;
|
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,
|
status = rpccli_spoolss_EnumPrinterKey(cli, mem_ctx,
|
||||||
handle,
|
handle,
|
||||||
key_name,
|
key_name,
|
||||||
buffer,
|
&_key_buffer,
|
||||||
offered,
|
offered,
|
||||||
&needed,
|
&needed,
|
||||||
&werror);
|
&werror);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (W_ERROR_IS_OK(werror)) {
|
*key_buffer = _key_buffer.string;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return werror;
|
return werror;
|
||||||
}
|
}
|
||||||
|
@ -9157,7 +9157,7 @@ WERROR _spoolss_EnumPrinterKey(pipes_struct *p,
|
|||||||
result = WERR_MORE_DATA;
|
result = WERR_MORE_DATA;
|
||||||
} else {
|
} else {
|
||||||
result = WERR_OK;
|
result = WERR_OK;
|
||||||
memcpy(r->out.key_buffer, blob.data, blob.length);
|
r->out.key_buffer->string = array;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -3043,44 +3043,31 @@ bool test_printer_keys(struct torture_context *tctx,
|
|||||||
struct dcerpc_pipe *p,
|
struct dcerpc_pipe *p,
|
||||||
struct policy_handle *handle)
|
struct policy_handle *handle)
|
||||||
{
|
{
|
||||||
DATA_BLOB blob;
|
|
||||||
const char **key_array = NULL;
|
const char **key_array = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
{
|
{
|
||||||
struct spoolss_EnumPrinterKey r;
|
struct spoolss_EnumPrinterKey r;
|
||||||
uint32_t needed;
|
uint32_t needed;
|
||||||
uint16_t *key_buffer = talloc_zero_array(tctx, uint16_t, 0);
|
struct spoolss_StringArray2 key_buffer;
|
||||||
|
|
||||||
r.in.handle = handle;
|
r.in.handle = handle;
|
||||||
r.in.key_name = "";
|
r.in.key_name = "";
|
||||||
r.in.offered = 0;
|
r.in.offered = 0;
|
||||||
r.out.key_buffer = key_buffer;
|
r.out.key_buffer = &key_buffer;
|
||||||
r.out.needed = &needed;
|
r.out.needed = &needed;
|
||||||
|
|
||||||
torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinterKey(p, tctx, &r),
|
torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinterKey(p, tctx, &r),
|
||||||
"failed to call EnumPrinterKey");
|
"failed to call EnumPrinterKey");
|
||||||
if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
|
if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
|
||||||
r.in.offered = needed;
|
r.in.offered = needed;
|
||||||
key_buffer = talloc_zero_array(tctx, uint16_t, needed/2);
|
|
||||||
r.out.key_buffer = key_buffer;
|
|
||||||
torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinterKey(p, tctx, &r),
|
torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinterKey(p, tctx, &r),
|
||||||
"failed to call EnumPrinterKey");
|
"failed to call EnumPrinterKey");
|
||||||
}
|
}
|
||||||
torture_assert_werr_ok(tctx, r.out.result,
|
torture_assert_werr_ok(tctx, r.out.result,
|
||||||
"failed to call EnumPrinterKey");
|
"failed to call EnumPrinterKey");
|
||||||
|
|
||||||
blob = data_blob_const(key_buffer, needed);
|
key_array = key_buffer.string;
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
union winreg_Data data;
|
|
||||||
enum ndr_err_code ndr_err;
|
|
||||||
ndr_err = ndr_pull_union_blob(&blob, tctx, lp_iconv_convenience(tctx->lp_ctx),
|
|
||||||
&data, REG_MULTI_SZ,
|
|
||||||
(ndr_pull_flags_fn_t)ndr_pull_winreg_Data);
|
|
||||||
torture_assert_ndr_success(tctx, ndr_err, "failed to pull REG_MULTI_SZ");
|
|
||||||
key_array = data.string_array;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; key_array[i]; i++) {
|
for (i=0; key_array[i]; i++) {
|
||||||
|
@ -384,17 +384,15 @@ static bool test_EnumPrinterKey(struct torture_context *tctx,
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
struct spoolss_EnumPrinterKey epk;
|
struct spoolss_EnumPrinterKey epk;
|
||||||
uint32_t needed = 0;
|
uint32_t needed = 0;
|
||||||
uint16_t *key_buffer;
|
struct spoolss_StringArray2 key_buffer;
|
||||||
|
|
||||||
torture_comment(tctx, "Testing EnumPrinterKey(%s)\n", key);
|
torture_comment(tctx, "Testing EnumPrinterKey(%s)\n", key);
|
||||||
|
|
||||||
key_buffer = talloc_zero_array(tctx, uint16_t, 0);
|
|
||||||
|
|
||||||
epk.in.handle = handle;
|
epk.in.handle = handle;
|
||||||
epk.in.key_name = talloc_strdup(tctx, key);
|
epk.in.key_name = talloc_strdup(tctx, key);
|
||||||
epk.in.offered = 0;
|
epk.in.offered = 0;
|
||||||
epk.out.needed = &needed;
|
epk.out.needed = &needed;
|
||||||
epk.out.key_buffer = key_buffer;
|
epk.out.key_buffer = &key_buffer;
|
||||||
|
|
||||||
status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
|
status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
|
||||||
torture_assert_ntstatus_ok(tctx, status, "EnumPrinterKey failed");
|
torture_assert_ntstatus_ok(tctx, status, "EnumPrinterKey failed");
|
||||||
@ -402,8 +400,6 @@ static bool test_EnumPrinterKey(struct torture_context *tctx,
|
|||||||
|
|
||||||
if (W_ERROR_EQUAL(epk.out.result, WERR_MORE_DATA)) {
|
if (W_ERROR_EQUAL(epk.out.result, WERR_MORE_DATA)) {
|
||||||
epk.in.offered = needed;
|
epk.in.offered = needed;
|
||||||
key_buffer = talloc_zero_array(tctx, uint16_t, needed/2);
|
|
||||||
epk.out.key_buffer = key_buffer;
|
|
||||||
status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
|
status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
|
||||||
torture_assert_ntstatus_ok(tctx, status,
|
torture_assert_ntstatus_ok(tctx, status,
|
||||||
"EnumPrinterKey failed");
|
"EnumPrinterKey failed");
|
||||||
@ -411,16 +407,7 @@ static bool test_EnumPrinterKey(struct torture_context *tctx,
|
|||||||
|
|
||||||
torture_assert_werr_ok(tctx, epk.out.result, "EnumPrinterKey failed");
|
torture_assert_werr_ok(tctx, epk.out.result, "EnumPrinterKey failed");
|
||||||
|
|
||||||
{
|
ctx->printer_keys = key_buffer.string;
|
||||||
union winreg_Data data;
|
|
||||||
enum ndr_err_code ndr_err;
|
|
||||||
DATA_BLOB blob = data_blob_const(key_buffer, needed);
|
|
||||||
ndr_err = ndr_pull_union_blob(&blob, tctx, lp_iconv_convenience(tctx->lp_ctx),
|
|
||||||
&data, REG_MULTI_SZ,
|
|
||||||
(ndr_pull_flags_fn_t)ndr_pull_winreg_Data);
|
|
||||||
torture_assert_ndr_success(tctx, ndr_err, "failed to pull REG_MULTI_SZ");
|
|
||||||
ctx->printer_keys = data.string_array;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user