summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-09-03 13:36:58 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:31 -0500
commit13f44bbacb120703910cf48233444c357ccfd228 (patch)
tree675340f260821b4856f22674845ff0e4dddf290d /source4
parent0b01bdf9a3ae05a990574577c8dffa63e882d65c (diff)
downloadsamba-13f44bbacb120703910cf48233444c357ccfd228.tar.gz
samba-13f44bbacb120703910cf48233444c357ccfd228.tar.bz2
samba-13f44bbacb120703910cf48233444c357ccfd228.zip
r2209: patch from volker to add EnumPorts spoolss IDL and test code
the ndr->offset=0; stuff is ugly. We need a better way to handle this. (This used to be commit e909bfa708aeceeaa37faa6f6dff0274f8ac7920)
Diffstat (limited to 'source4')
-rw-r--r--source4/librpc/idl/spoolss.idl22
-rw-r--r--source4/librpc/ndr/ndr_spoolss_buf.c21
-rw-r--r--source4/torture/rpc/spoolss.c66
3 files changed, 109 insertions, 0 deletions
diff --git a/source4/librpc/idl/spoolss.idl b/source4/librpc/idl/spoolss.idl
index 74bfd2ea9f..72ce7d5ffc 100644
--- a/source4/librpc/idl/spoolss.idl
+++ b/source4/librpc/idl/spoolss.idl
@@ -464,9 +464,31 @@
[out] uint32 count
);
+ typedef [flag(RELATIVE_CURRENT)] struct {
+ [relative] nstring *port_name;
+ } spoolss_PortInfo1;
+
+ typedef struct {
+ [relative] nstring *port_name;
+ [relative] nstring *monitor_name;
+ [relative] nstring *description;
+ uint32 port_type;
+ uint32 reserved;
+ } spoolss_PortInfo2;
+
+ typedef [nondiscriminant,public] union {
+ [case(1)] spoolss_PortInfo1 info1;
+ [case(2)] spoolss_PortInfo2 info2;
+ } spoolss_PortInfo;
+
/******************/
/* Function: 0x23 */
WERROR spoolss_EnumPorts(
+ [in] unistr *servername,
+ [in] uint32 level,
+ [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 aa91a27ab7..9b68ec7883 100644
--- a/source4/librpc/ndr/ndr_spoolss_buf.c
+++ b/source4/librpc/ndr/ndr_spoolss_buf.c
@@ -36,6 +36,8 @@ NTSTATUS pull_spoolss_PrinterInfoArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
}
NDR_ALLOC_N(ndr, *info, count);
for (i=0;i<count;i++) {
+ ndr->data += ndr->offset;
+ ndr->offset = 0;
NDR_CHECK(ndr_pull_spoolss_PrinterInfo(ndr, NDR_SCALARS|NDR_BUFFERS, level, &(*info)[i]));
}
return NT_STATUS_OK;
@@ -91,3 +93,22 @@ NTSTATUS pull_spoolss_DriverInfoArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
}
return NT_STATUS_OK;
}
+
+NTSTATUS pull_spoolss_PortInfoArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
+ uint32_t level, uint32_t count,
+ union spoolss_PortInfo **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->data += ndr->offset;
+ ndr->offset = 0;
+ NDR_CHECK(ndr_pull_spoolss_PortInfo(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 34221a14fa..e3299b54db 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -270,6 +270,68 @@ static BOOL test_AddForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
+static BOOL test_EnumPorts(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+{
+ NTSTATUS status;
+ struct spoolss_EnumPorts r;
+ uint32_t buf_size;
+
+ r.in.servername = talloc_asprintf(mem_ctx, "\\\\%s",
+ dcerpc_server_name(p));
+ r.in.level = 2;
+ r.in.buffer = NULL;
+ buf_size = 0;
+ r.in.buf_size = &buf_size;
+ r.out.buf_size = &buf_size;
+
+ printf("Testing EnumPorts\n");
+
+ status = dcerpc_spoolss_EnumPorts(p, mem_ctx, &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("EnumPorts 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_PortInfo *info;
+ int j;
+
+ data_blob_clear(&blob);
+ r.in.buffer = &blob;
+
+ status = dcerpc_spoolss_EnumPorts(p, mem_ctx, &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("EnumPorts failed -- %s\n", nt_errstr(status));
+ return False;
+ }
+
+ if (!r.out.buffer) {
+ printf("No ports returned");
+ return False;
+ }
+
+ status = pull_spoolss_PortInfoArray(r.out.buffer, mem_ctx,
+ r.in.level, r.out.count,
+ &info);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("EnumPortArray parse failed - %s\n",
+ nt_errstr(status));
+ return False;
+ }
+
+ for (j=0;j<r.out.count;j++) {
+ printf("Port %d\n", j);
+ NDR_PRINT_UNION_DEBUG(spoolss_PortInfo, r.in.level,
+ &info[j]);
+ }
+ }
+
+ return True;
+}
+
static BOOL test_GetJob(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, uint32_t job_id)
{
@@ -973,6 +1035,10 @@ BOOL torture_rpc_spoolss(int dummy)
return False;
}
+ if (!test_EnumPorts(p, mem_ctx)) {
+ ret = False;
+ }
+
if (!test_EnumPrinters(p, mem_ctx)) {
ret = False;
}