summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2004-07-16 09:10:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:57:40 -0500
commitdbb6b8f1ec16b266a615bfc487b3fc1487399879 (patch)
tree52fd2e0bcf5a5e170c54a13a7056828fbfd2280e /source4
parent18b511f0ce2be52c5702f4bf6b7bee8ef3f51c25 (diff)
downloadsamba-dbb6b8f1ec16b266a615bfc487b3fc1487399879.tar.gz
samba-dbb6b8f1ec16b266a615bfc487b3fc1487399879.tar.bz2
samba-dbb6b8f1ec16b266a615bfc487b3fc1487399879.zip
r1527: add NetCharDev torture tests
metze (This used to be commit dde75d3b346be33213e9f38db01945ee45eff9df)
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/rpc/srvsvc.c125
1 files changed, 125 insertions, 0 deletions
diff --git a/source4/torture/rpc/srvsvc.c b/source4/torture/rpc/srvsvc.c
index dfae04ba49..3d608d0f96 100644
--- a/source4/torture/rpc/srvsvc.c
+++ b/source4/torture/rpc/srvsvc.c
@@ -21,6 +21,127 @@
#include "includes.h"
+/**************************/
+/* srvsvc_NetCharDev */
+/**************************/
+static BOOL test_NetCharDevGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ const char *devname)
+{
+ NTSTATUS status;
+ struct srvsvc_NetCharDevGetInfo r;
+ uint32_t levels[] = {0, 1};
+ int i;
+ BOOL ret = True;
+
+ r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ r.in.device_name = devname;
+
+ for (i=0;i<ARRAY_SIZE(levels);i++) {
+ ZERO_STRUCT(r.out);
+ r.in.level = levels[i];
+ printf("testing NetCharDevGetInfo level %u on device '%s'\n",
+ r.in.level, r.in.device_name);
+ status = dcerpc_srvsvc_NetCharDevGetInfo(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("NetCharDevGetInfo level %u on device '%s' failed - %s\n",
+ r.in.level, r.in.device_name, nt_errstr(status));
+ ret = False;
+ continue;
+ }
+ if (!W_ERROR_IS_OK(r.out.result)) {
+ printf("NetCharDevGetInfo level %u on device '%s' failed - %s\n",
+ r.in.level, r.in.device_name, win_errstr(r.out.result));
+ continue;
+ }
+ }
+
+ return ret;
+}
+
+static BOOL test_NetCharDevControl(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ const char *devname)
+{
+ NTSTATUS status;
+ struct srvsvc_NetCharDevControl r;
+ uint32_t opcodes[] = {0, 1};
+ int i;
+ BOOL ret = True;
+
+ r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ r.in.device_name = devname;
+
+ for (i=0;i<ARRAY_SIZE(opcodes);i++) {
+ ZERO_STRUCT(r.out);
+ r.in.opcode = opcodes[i];
+ printf("testing NetCharDevControl opcode %u on device '%s'\n",
+ r.in.opcode, r.in.device_name);
+ status = dcerpc_srvsvc_NetCharDevControl(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("NetCharDevControl opcode %u failed - %s\n", r.in.opcode, nt_errstr(status));
+ ret = False;
+ continue;
+ }
+ if (!W_ERROR_IS_OK(r.out.result)) {
+ printf("NetCharDevControl opcode %u failed - %s\n", r.in.opcode, win_errstr(r.out.result));
+ continue;
+ }
+ }
+
+ return ret;
+}
+
+static BOOL test_NetCharDevEnum(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx)
+{
+ NTSTATUS status;
+ struct srvsvc_NetCharDevEnum r;
+ struct srvsvc_NetCharDevCtr0 c0;
+ uint32 levels[] = {0, 1};
+ int i;
+ BOOL ret = True;
+
+ r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ r.in.ctr.ctr0 = &c0;
+ r.in.ctr.ctr0->count = 0;
+ r.in.ctr.ctr0->array = NULL;
+ r.in.max_buffer = (uint32)-1;
+ r.in.resume_handle = NULL;
+
+ for (i=0;i<ARRAY_SIZE(levels);i++) {
+ int j;
+
+
+ ZERO_STRUCT(r.out);
+ r.in.level = levels[i];
+ printf("testing NetCharDevEnum level %u\n", r.in.level);
+ status = dcerpc_srvsvc_NetCharDevEnum(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("NetCharDevEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
+ ret = False;
+ continue;
+ }
+ if (!W_ERROR_IS_OK(r.out.result)) {
+ printf("NetCharDevEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
+ continue;
+ }
+
+ /* call test_NetCharDevGetInfo and test_NetCharDevControl for each returned share */
+ if (r.in.level == 1) {
+ for (j=0;j<r.out.ctr.ctr1->count;j++) {
+ const char *device;
+ device = r.out.ctr.ctr1->array[j].device;
+ if (!test_NetCharDevGetInfo(p, mem_ctx, device)) {
+ ret = False;
+ }
+ if (!test_NetCharDevControl(p, mem_ctx, device)) {
+ ret = False;
+ }
+ }
+ }
+ }
+
+ return ret;
+}
static BOOL test_NetConnEnum(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx)
@@ -369,6 +490,10 @@ BOOL torture_rpc_srvsvc(int dummy)
return False;
}
+ if (!test_NetCharDevEnum(p, mem_ctx)) {
+ ret = False;
+ }
+
if (!test_NetConnEnum(p, mem_ctx)) {
ret = False;
}