summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2003-11-26 06:26:18 +0000
committerTim Potter <tpot@samba.org>2003-11-26 06:26:18 +0000
commitee67d68f1c6d71d4d3fbe86899d5ea9f271cfbc8 (patch)
treeb32ba1f52dcb30c43a92af8db823c36f7d9b1feb /source4
parent2edb73fbe9c33b26c3b3b892cbce56eb2e498abf (diff)
downloadsamba-ee67d68f1c6d71d4d3fbe86899d5ea9f271cfbc8.tar.gz
samba-ee67d68f1c6d71d4d3fbe86899d5ea9f271cfbc8.tar.bz2
samba-ee67d68f1c6d71d4d3fbe86899d5ea9f271cfbc8.zip
Implemented EnumForms and GetForm.
(This used to be commit 822750592cffb175aa7afb268bc7cb47bbab47e4)
Diffstat (limited to 'source4')
-rw-r--r--source4/librpc/idl/spoolss.idl24
-rw-r--r--source4/librpc/ndr/ndr_spoolss_buf.c17
-rw-r--r--source4/torture/rpc/spoolss.c106
3 files changed, 143 insertions, 4 deletions
diff --git a/source4/librpc/idl/spoolss.idl b/source4/librpc/idl/spoolss.idl
index 14cb3ed441..2c318ce4a1 100644
--- a/source4/librpc/idl/spoolss.idl
+++ b/source4/librpc/idl/spoolss.idl
@@ -58,6 +58,17 @@
} 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;
[relative] nstring *sharename;
@@ -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
);
/******************/
diff --git a/source4/librpc/ndr/ndr_spoolss_buf.c b/source4/librpc/ndr/ndr_spoolss_buf.c
index 381093a58f..6c12ab2ae5 100644
--- a/source4/librpc/ndr/ndr_spoolss_buf.c
+++ b/source4/librpc/ndr/ndr_spoolss_buf.c
@@ -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;
+}
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 166be85d57..6913290d1a 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -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;
}