1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

Implemented EnumForms and GetForm.

This commit is contained in:
Tim Potter 0001-01-01 00:00:00 +00:00
parent 939d832e5e
commit 822750592c
3 changed files with 143 additions and 4 deletions

View File

@ -57,6 +57,17 @@
[relative] nstring *comment;
} spoolss_PrinterInfo1;
typedef struct {
uint32 flags;
[relative] nstring *name;
uint32 width;
uint32 length;
uint32 left;
uint32 top;
uint32 right;
uint32 bottom;
} spoolss_FormInfo1;
typedef struct {
[relative] nstring *servername;
[relative] nstring *printername;
@ -309,7 +320,8 @@
[in,ref] policy_handle *handle,
[in] unistr formname,
[in] uint32 level,
[out,subcontext(4),switch_is(level)] spoolss_PrinterInfo *info,
[in] DATA_BLOB *buffer,
[out,subcontext(4),switch_is(level)] spoolss_FormInfo *info,
[in,out,ref] uint32 *buf_size
);
@ -318,14 +330,18 @@
WERROR spoolss_21(
);
typedef [nodiscriminant,public] union {
[case(1)] spoolss_FormInfo1 info1;
} spoolss_FormInfo;
/******************/
/* Function: 0x22 */
WERROR spoolss_EnumForms(
[in,ref] policy_handle *handle,
[in] uint32 level,
[in] DATA_BLOB *buffer,
[out,subcontext(4),switch_is(level)] spoolss_PrinterInfo *info,
[in,out,ref] uint32 *buf_size
[in,out] DATA_BLOB *buffer,
[in,out,ref] uint32 *buf_size,
[out] uint32 count
);
/******************/

View File

@ -40,3 +40,20 @@ NTSTATUS pull_spoolss_PrinterInfoArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
}
return NT_STATUS_OK;
}
NTSTATUS pull_spoolss_FormInfoArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
uint32 level, uint32 count,
union spoolss_FormInfo **info)
{
int i;
struct ndr_pull *ndr;
ndr = ndr_pull_init_blob(blob, mem_ctx);
if (!ndr) {
return NT_STATUS_NO_MEMORY;
}
NDR_ALLOC_N(ndr, *info, count);
for (i=0;i<count;i++) {
NDR_CHECK(ndr_pull_spoolss_FormInfo(ndr, NDR_SCALARS|NDR_BUFFERS, level, &(*info)[i]));
}
return NT_STATUS_OK;
}

View File

@ -87,6 +87,108 @@ BOOL test_ClosePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return True;
}
BOOL test_GetForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, char *formname)
{
NTSTATUS status;
struct spoolss_GetForm r;
uint32 buf_size;
r.in.handle = handle;
r.in.formname = formname;
r.in.level = 1;
r.in.buffer = NULL;
buf_size = 0;
r.in.buf_size = r.out.buf_size = &buf_size;
printf("Testing GetForm\n");
status = dcerpc_spoolss_GetForm(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("GetForm failed - %s\n", nt_errstr(status));
return False;
}
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_GetForm(p, mem_ctx, &r);
if (!r.out.info) {
printf("No form info returned");
return False;
}
}
return True;
}
BOOL test_EnumForms(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct spoolss_EnumForms r;
uint32 buf_size;
r.in.handle = handle;
r.in.level = 1;
r.in.buffer = NULL;
buf_size = 0;
r.in.buf_size = &buf_size;
r.out.buf_size = &buf_size;
printf("Testing EnumForms\n");
status = dcerpc_spoolss_EnumForms(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("EnumForms failed - %s\n", nt_errstr(status));
return False;
}
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, buf_size);
union spoolss_FormInfo *info;
int j;
data_blob_clear(&blob);
r.in.buffer = &blob;
status = dcerpc_spoolss_EnumForms(p, mem_ctx, &r);
if (!r.out.buffer) {
printf("No forms returned");
return False;
}
status = pull_spoolss_FormInfoArray(r.out.buffer, mem_ctx, r.in.level, r.out.count, &info);
if (!NT_STATUS_IS_OK(status)) {
printf("EnumFormsArray parse failed - %s\n", nt_errstr(status));
return False;
}
for (j=0;j<r.out.count;j++) {
printf("Form %d\n", j);
NDR_PRINT_UNION_DEBUG(spoolss_FormInfo, r.in.level, &info[j]);
}
for (j = 0; j < r.out.count; j++)
test_GetForm(p, mem_ctx, handle, info[j].info1.name);
}
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
printf("EnumForms failed - %s/%s\n",
nt_errstr(status), win_errstr(r.out.result));
return False;
}
return True;
}
BOOL test_EnumPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@ -212,6 +314,10 @@ static BOOL test_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
ret = False;
}
if (!test_EnumForms(p, mem_ctx, &handle)) {
ret = False;
}
if (!test_EnumPrinterData(p, mem_ctx, &handle)) {
ret = False;
}