diff options
author | Andrew Tridgell <tridge@samba.org> | 2008-10-31 13:55:26 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2008-10-31 13:55:26 +1100 |
commit | 5ecccac1c34f58019b195f6838f57366faa3575d (patch) | |
tree | 3475f5b34220e4735a1c74b24f3bddbbf76f90df /source4/torture/rpc | |
parent | 391264a1006c147d82c983701ae382005c251d75 (diff) | |
parent | 6066e1a44d041d7a5cafcb4c0276f5ff323226d9 (diff) | |
download | samba-5ecccac1c34f58019b195f6838f57366faa3575d.tar.gz samba-5ecccac1c34f58019b195f6838f57366faa3575d.tar.bz2 samba-5ecccac1c34f58019b195f6838f57366faa3575d.zip |
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'source4/torture/rpc')
-rw-r--r-- | source4/torture/rpc/bench.c | 43 | ||||
-rw-r--r-- | source4/torture/rpc/samba3rpc.c | 109 | ||||
-rw-r--r-- | source4/torture/rpc/srvsvc.c | 453 |
3 files changed, 440 insertions, 165 deletions
diff --git a/source4/torture/rpc/bench.c b/source4/torture/rpc/bench.c index cacc1d3baa..6fa3815516 100644 --- a/source4/torture/rpc/bench.c +++ b/source4/torture/rpc/bench.c @@ -31,32 +31,63 @@ static bool test_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { NTSTATUS status; struct srvsvc_NetShareEnumAll r; + struct srvsvc_NetShareInfoCtr info_ctr; struct srvsvc_NetShareCtr0 c0; + struct srvsvc_NetShareCtr1 c1; + struct srvsvc_NetShareCtr2 c2; + struct srvsvc_NetShareCtr501 c501; + struct srvsvc_NetShareCtr502 c502; + uint32_t totalentries = 0; uint32_t levels[] = {0, 1, 2, 501, 502}; int i; bool ret = true; uint32_t resume_handle; - ZERO_STRUCT(c0); + ZERO_STRUCT(info_ctr); r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p)); - r.in.ctr.ctr0 = &c0; + r.in.info_ctr = &info_ctr; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = &resume_handle; r.out.resume_handle = &resume_handle; + r.out.totalentries = &totalentries; + r.out.info_ctr = &info_ctr; for (i=0;i<ARRAY_SIZE(levels);i++) { - ZERO_STRUCT(r.out); resume_handle = 0; - r.in.level = levels[i]; + info_ctr.level = levels[i]; + + switch (info_ctr.level) { + case 0: + ZERO_STRUCT(c0); + info_ctr.ctr.ctr0 = &c0; + break; + case 1: + ZERO_STRUCT(c1); + info_ctr.ctr.ctr1 = &c1; + break; + case 2: + ZERO_STRUCT(c2); + info_ctr.ctr.ctr2 = &c2; + break; + case 501: + ZERO_STRUCT(c501); + info_ctr.ctr.ctr501 = &c501; + break; + case 502: + ZERO_STRUCT(c502); + info_ctr.ctr.ctr502 = &c502; + break; + } + status = dcerpc_srvsvc_NetShareEnumAll(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("NetShareEnumAll level %u failed - %s\n", r.in.level, nt_errstr(status)); + printf("NetShareEnumAll level %u failed - %s\n", info_ctr.level, nt_errstr(status)); ret = false; continue; } if (!W_ERROR_IS_OK(r.out.result)) { - printf("NetShareEnumAll level %u failed - %s\n", r.in.level, win_errstr(r.out.result)); + printf("NetShareEnumAll level %u failed - %s\n", info_ctr.level, win_errstr(r.out.result)); continue; } } diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index c53c4b72c7..93bcb3a1ea 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -1866,6 +1866,7 @@ static bool test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, { NTSTATUS status; struct srvsvc_NetShareGetInfo r; + union srvsvc_NetShareInfo info; uint32_t levels[] = { 0, 1, 2, 501, 502, 1004, 1005, 1006, 1007, 1501 }; int i; bool ret = true; @@ -1873,12 +1874,11 @@ static bool test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); r.in.share_name = sharename; + r.out.info = &info; for (i=0;i<ARRAY_SIZE(levels);i++) { r.in.level = levels[i]; - ZERO_STRUCT(r.out); - printf("testing NetShareGetInfo level %u on share '%s'\n", r.in.level, r.in.share_name); @@ -1907,38 +1907,87 @@ static bool test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, { NTSTATUS status; struct srvsvc_NetShareEnum r; + struct srvsvc_NetShareInfoCtr info_ctr; struct srvsvc_NetShareCtr0 c0; + struct srvsvc_NetShareCtr1 c1; + struct srvsvc_NetShareCtr2 c2; + struct srvsvc_NetShareCtr501 c501; + struct srvsvc_NetShareCtr502 c502; + struct srvsvc_NetShareCtr1004 c1004; + struct srvsvc_NetShareCtr1005 c1005; + struct srvsvc_NetShareCtr1006 c1006; + struct srvsvc_NetShareCtr1007 c1007; + uint32_t totalentries = 0; uint32_t levels[] = { 0, 1, 2, 501, 502, 1004, 1005, 1006, 1007 }; int i; bool ret = true; + ZERO_STRUCT(info_ctr); + 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.info_ctr = &info_ctr; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = NULL; + r.out.totalentries = &totalentries; + r.out.info_ctr = &info_ctr; for (i=0;i<ARRAY_SIZE(levels);i++) { - r.in.level = levels[i]; - - ZERO_STRUCT(r.out); + info_ctr.level = levels[i]; + + switch (info_ctr.level) { + case 0: + ZERO_STRUCT(c0); + info_ctr.ctr.ctr0 = &c0; + break; + case 1: + ZERO_STRUCT(c1); + info_ctr.ctr.ctr1 = &c1; + break; + case 2: + ZERO_STRUCT(c2); + info_ctr.ctr.ctr2 = &c2; + break; + case 501: + ZERO_STRUCT(c501); + info_ctr.ctr.ctr501 = &c501; + break; + case 502: + ZERO_STRUCT(c502); + info_ctr.ctr.ctr502 = &c502; + break; + case 1004: + ZERO_STRUCT(c1004); + info_ctr.ctr.ctr1004 = &c1004; + break; + case 1005: + ZERO_STRUCT(c1005); + info_ctr.ctr.ctr1005 = &c1005; + break; + case 1006: + ZERO_STRUCT(c1006); + info_ctr.ctr.ctr1006 = &c1006; + break; + case 1007: + ZERO_STRUCT(c1007); + info_ctr.ctr.ctr1007 = &c1007; + break; + } - printf("testing NetShareEnum level %u\n", r.in.level); + printf("testing NetShareEnum level %u\n", info_ctr.level); status = dcerpc_srvsvc_NetShareEnum(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("NetShareEnum level %u failed - %s\n", - r.in.level, nt_errstr(status)); + info_ctr.level, nt_errstr(status)); ret = false; continue; } if (!W_ERROR_IS_OK(r.out.result)) { printf("NetShareEnum level %u failed - %s\n", - r.in.level, win_errstr(r.out.result)); + info_ctr.level, win_errstr(r.out.result)); continue; } - if (r.in.level == 0) { - struct srvsvc_NetShareCtr0 *ctr = r.out.ctr.ctr0; + if (info_ctr.level == 0) { + struct srvsvc_NetShareCtr0 *ctr = r.out.info_ctr->ctr.ctr0; if (ctr->count > 0) { *one_sharename = ctr->array[0].name; } @@ -2114,6 +2163,7 @@ static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p; NTSTATUS status; struct srvsvc_NetShareGetInfo r; + union srvsvc_NetShareInfo info; struct security_descriptor *result; if (!(tmp_ctx = talloc_new(mem_ctx))) { @@ -2144,6 +2194,7 @@ static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx, dcerpc_server_name(p)); r.in.share_name = sharename; r.in.level = 502; + r.out.info = &info; status = dcerpc_srvsvc_NetShareGetInfo(p, tmp_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -2153,7 +2204,7 @@ static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx, return NULL; } - result = talloc_steal(mem_ctx, r.out.info.info502->sd); + result = talloc_steal(mem_ctx, info.info502->sd_buf.sd); talloc_free(tmp_ctx); return result; } @@ -2170,6 +2221,7 @@ static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx, NTSTATUS status; struct sec_desc_buf i; struct srvsvc_NetShareSetInfo r; + union srvsvc_NetShareInfo info; uint32_t error = 0; if (!(tmp_ctx = talloc_new(mem_ctx))) { @@ -2201,12 +2253,13 @@ static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx, r.in.share_name = sharename; r.in.level = 1501; i.sd = sd; - r.in.info.info1501 = &i; + info.info1501 = &i; + r.in.info = &info; r.in.parm_error = &error; status = dcerpc_srvsvc_NetShareSetInfo(p, tmp_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - d_printf("srvsvc_NetShareGetInfo failed: %s\n", + d_printf("srvsvc_NetShareSetInfo failed: %s\n", nt_errstr(status)); } @@ -2467,8 +2520,10 @@ static NTSTATUS find_printers(TALLOC_CTX *ctx, struct loadparm_context *lp_ctx, NTSTATUS status; struct dcerpc_pipe *p; struct srvsvc_NetShareEnum r; + struct srvsvc_NetShareInfoCtr info_ctr; struct srvsvc_NetShareCtr1 c1_in; struct srvsvc_NetShareCtr1 *c1; + uint32_t totalentries = 0; int i; mem_ctx = talloc_new(ctx); @@ -2485,25 +2540,29 @@ static NTSTATUS find_printers(TALLOC_CTX *ctx, struct loadparm_context *lp_ctx, return status; } + ZERO_STRUCT(c1_in); + info_ctr.level = 1; + info_ctr.ctr.ctr1 = &c1_in; + r.in.server_unc = talloc_asprintf( mem_ctx, "\\\\%s", dcerpc_server_name(p)); - r.in.level = 1; - ZERO_STRUCT(c1_in); - r.in.ctr.ctr1 = &c1_in; + r.in.info_ctr = &info_ctr; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = NULL; + r.out.totalentries = &totalentries; + r.out.info_ctr = &info_ctr; status = dcerpc_srvsvc_NetShareEnum(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { d_printf("NetShareEnum level %u failed - %s\n", - r.in.level, nt_errstr(status)); + info_ctr.level, nt_errstr(status)); talloc_free(mem_ctx); return status; } *printers = NULL; *num_printers = 0; - c1 = r.out.ctr.ctr1; + c1 = r.out.info_ctr->ctr.ctr1; for (i=0; i<c1->count; i++) { if (c1->array[i].type != STYPE_PRINTQ) { continue; @@ -3103,11 +3162,12 @@ static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, struct smbcli_state *cli, const char *share, - struct srvsvc_NetShareInfo502 **info) + struct srvsvc_NetShareInfo502 **info502) { struct smbcli_tree *ipc; struct dcerpc_pipe *p; struct srvsvc_NetShareGetInfo r; + union srvsvc_NetShareInfo info; NTSTATUS status; if (!(p = dcerpc_pipe_init(cli, @@ -3140,15 +3200,16 @@ static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx, dcerpc_server_name(p)); r.in.share_name = share; r.in.level = 502; + r.out.info = &info; status = dcerpc_srvsvc_NetShareGetInfo(p, p, &r); if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { - d_printf("(%s) OpenHKLM failed: %s, %s\n", __location__, + d_printf("(%s) srvsvc_NetShareGetInfo failed: %s, %s\n", __location__, nt_errstr(status), win_errstr(r.out.result)); goto fail; } - *info = talloc_move(mem_ctx, &r.out.info.info502); + *info502 = talloc_move(mem_ctx, &info.info502); return NT_STATUS_OK; fail: diff --git a/source4/torture/rpc/srvsvc.c b/source4/torture/rpc/srvsvc.c index 1fe1221b0d..82a8a67854 100644 --- a/source4/torture/rpc/srvsvc.c +++ b/source4/torture/rpc/srvsvc.c @@ -32,14 +32,15 @@ static bool test_NetCharDevGetInfo(struct dcerpc_pipe *p, struct torture_context { NTSTATUS status; struct srvsvc_NetCharDevGetInfo r; + union srvsvc_NetCharDevInfo info; uint32_t levels[] = {0, 1}; int i; r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.device_name = devname; + r.out.info = &info; for (i=0;i<ARRAY_SIZE(levels);i++) { - ZERO_STRUCT(r.out); r.in.level = levels[i]; torture_comment(tctx, "testing NetCharDevGetInfo level %u on device '%s'\n", r.in.level, r.in.device_name); @@ -80,23 +81,39 @@ static bool test_NetCharDevEnum(struct torture_context *tctx, { NTSTATUS status; struct srvsvc_NetCharDevEnum r; + struct srvsvc_NetCharDevInfoCtr info_ctr; struct srvsvc_NetCharDevCtr0 c0; + struct srvsvc_NetCharDevCtr0 c1; + uint32_t totalentries = 0; uint32_t levels[] = {0, 1}; int i; + ZERO_STRUCT(info_ctr); + r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); - r.in.ctr.ctr0 = &c0; - r.in.ctr.ctr0->count = 0; - r.in.ctr.ctr0->array = NULL; + r.in.info_ctr = &info_ctr; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = NULL; + r.out.info_ctr = &info_ctr; + r.out.totalentries = &totalentries; for (i=0;i<ARRAY_SIZE(levels);i++) { int j; - ZERO_STRUCT(r.out); - r.in.level = levels[i]; - torture_comment(tctx, "testing NetCharDevEnum level %u\n", r.in.level); + info_ctr.level = levels[i]; + + switch(info_ctr.level) { + case 0: + ZERO_STRUCT(c0); + info_ctr.ctr.ctr0 = &c0; + break; + case 1: + ZERO_STRUCT(c1); + info_ctr.ctr.ctr0 = &c1; + break; + } + + torture_comment(tctx, "testing NetCharDevEnum level %u\n", info_ctr.level); status = dcerpc_srvsvc_NetCharDevEnum(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetCharDevEnum failed"); if (!W_ERROR_IS_OK(r.out.result)) { @@ -105,10 +122,10 @@ static bool test_NetCharDevEnum(struct torture_context *tctx, } /* 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++) { + if (info_ctr.level == 1) { + for (j=0;j<r.out.info_ctr->ctr.ctr1->count;j++) { const char *device; - device = r.out.ctr.ctr1->array[j].device; + device = r.out.info_ctr->ctr.ctr1->array[j].device; if (!test_NetCharDevGetInfo(p, tctx, device)) { return false; } @@ -130,15 +147,16 @@ static bool test_NetCharDevQGetInfo(struct dcerpc_pipe *p, struct torture_contex { NTSTATUS status; struct srvsvc_NetCharDevQGetInfo r; + union srvsvc_NetCharDevQInfo info; uint32_t levels[] = {0, 1}; int i; r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.queue_name = devicequeue; r.in.user = talloc_asprintf(tctx,"Administrator"); + r.out.info = &info; for (i=0;i<ARRAY_SIZE(levels);i++) { - ZERO_STRUCT(r.out); r.in.level = levels[i]; torture_comment(tctx, "testing NetCharDevQGetInfo level %u on devicequeue '%s'\n", r.in.level, r.in.queue_name); @@ -210,24 +228,39 @@ static bool test_NetCharDevQEnum(struct torture_context *tctx, { NTSTATUS status; struct srvsvc_NetCharDevQEnum r; + struct srvsvc_NetCharDevQInfoCtr info_ctr; struct srvsvc_NetCharDevQCtr0 c0; + struct srvsvc_NetCharDevQCtr1 c1; + uint32_t totalentries = 0; uint32_t levels[] = {0, 1}; int i; + ZERO_STRUCT(info_ctr); + r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.user = talloc_asprintf(tctx,"%s","Administrator"); - r.in.ctr.ctr0 = &c0; - r.in.ctr.ctr0->count = 0; - r.in.ctr.ctr0->array = NULL; + r.in.info_ctr = &info_ctr; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = NULL; + r.out.totalentries = &totalentries; + r.out.info_ctr = &info_ctr; for (i=0;i<ARRAY_SIZE(levels);i++) { int j; - ZERO_STRUCT(r.out); - r.in.level = levels[i]; - torture_comment(tctx, "testing NetCharDevQEnum level %u\n", r.in.level); + info_ctr.level = levels[i]; + + switch (info_ctr.level) { + case 0: + ZERO_STRUCT(c0); + info_ctr.ctr.ctr0 = &c0; + break; + case 1: + ZERO_STRUCT(c1); + info_ctr.ctr.ctr1 = &c1; + break; + } + torture_comment(tctx, "testing NetCharDevQEnum level %u\n", info_ctr.level); status = dcerpc_srvsvc_NetCharDevQEnum(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetCharDevQEnum failed"); if (!W_ERROR_IS_OK(r.out.result)) { @@ -236,10 +269,10 @@ static bool test_NetCharDevQEnum(struct torture_context *tctx, } /* 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++) { + if (info_ctr.level == 1) { + for (j=0;j<r.out.info_ctr->ctr.ctr1->count;j++) { const char *device; - device = r.out.ctr.ctr1->array[j].device; + device = r.out.info_ctr->ctr.ctr1->array[j].device; if (!test_NetCharDevQGetInfo(p, tctx, device)) { return false; } @@ -258,22 +291,38 @@ static bool test_NetConnEnum(struct torture_context *tctx, { NTSTATUS status; struct srvsvc_NetConnEnum r; + struct srvsvc_NetConnInfoCtr info_ctr; struct srvsvc_NetConnCtr0 c0; + struct srvsvc_NetConnCtr1 c1; + uint32_t totalentries = 0; uint32_t levels[] = {0, 1}; int i; + ZERO_STRUCT(info_ctr); + r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.path = talloc_asprintf(tctx,"%s","ADMIN$"); - r.in.ctr.ctr0 = &c0; - r.in.ctr.ctr0->count = 0; - r.in.ctr.ctr0->array = NULL; + r.in.info_ctr = &info_ctr; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = NULL; + r.out.totalentries = &totalentries; + r.out.info_ctr = &info_ctr; for (i=0;i<ARRAY_SIZE(levels);i++) { - ZERO_STRUCT(r.out); - r.in.level = levels[i]; - torture_comment(tctx, "testing NetConnEnum level %u\n", r.in.level); + info_ctr.level = levels[i]; + + switch (info_ctr.level) { + case 0: + ZERO_STRUCT(c0); + info_ctr.ctr.ctr0 = &c0; + break; + case 1: + ZERO_STRUCT(c1); + info_ctr.ctr.ctr1 = &c1; + break; + } + + torture_comment(tctx, "testing NetConnEnum level %u\n", info_ctr.level); status = dcerpc_srvsvc_NetConnEnum(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetConnEnum failed"); if (!W_ERROR_IS_OK(r.out.result)) { @@ -292,23 +341,38 @@ static bool test_NetFileEnum(struct torture_context *tctx, { NTSTATUS status; struct srvsvc_NetFileEnum r; + struct srvsvc_NetFileInfoCtr info_ctr; + struct srvsvc_NetFileCtr2 c2; struct srvsvc_NetFileCtr3 c3; + uint32_t totalentries = 0; uint32_t levels[] = {2, 3}; int i; + ZERO_STRUCT(info_ctr); + r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.path = NULL; r.in.user = NULL; - r.in.ctr.ctr3 = &c3; - r.in.ctr.ctr3->count = 0; - r.in.ctr.ctr3->array = NULL; + r.in.info_ctr = &info_ctr; r.in.max_buffer = (uint32_t)4096; r.in.resume_handle = NULL; + r.out.totalentries = &totalentries; + r.out.info_ctr = &info_ctr; for (i=0;i<ARRAY_SIZE(levels);i++) { - ZERO_STRUCT(r.out); - r.in.level = levels[i]; - torture_comment(tctx, "testing NetFileEnum level %u\n", r.in.level); + info_ctr.level = levels[i]; + + switch (info_ctr.level) { + case 2: + ZERO_STRUCT(c2); + info_ctr.ctr.ctr2 = &c2; + break; + case 3: + ZERO_STRUCT(c3); + info_ctr.ctr.ctr3 = &c3; + break; + } + torture_comment(tctx, "testing NetFileEnum level %u\n", info_ctr.level); status = dcerpc_srvsvc_NetFileEnum(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetFileEnum failed"); if (!W_ERROR_IS_OK(r.out.result)) { @@ -327,23 +391,54 @@ static bool test_NetSessEnum(struct torture_context *tctx, { NTSTATUS status; struct srvsvc_NetSessEnum r; + struct srvsvc_NetSessInfoCtr info_ctr; struct srvsvc_NetSessCtr0 c0; + struct srvsvc_NetSessCtr1 c1; + struct srvsvc_NetSessCtr2 c2; + struct srvsvc_NetSessCtr10 c10; + struct srvsvc_NetSessCtr502 c502; + uint32_t totalentries = 0; uint32_t levels[] = {0, 1, 2, 10, 502}; int i; + ZERO_STRUCT(info_ctr); + r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.client = NULL; r.in.user = NULL; - r.in.ctr.ctr0 = &c0; - r.in.ctr.ctr0->count = 0; - r.in.ctr.ctr0->array = NULL; + r.in.info_ctr = &info_ctr; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = NULL; + r.out.totalentries = &totalentries; + r.out.info_ctr = &info_ctr; for (i=0;i<ARRAY_SIZE(levels);i++) { - ZERO_STRUCT(r.out); - r.in.level = levels[i]; - torture_comment(tctx, "testing NetSessEnum level %u\n", r.in.level); + info_ctr.level = levels[i]; + + switch (info_ctr.level) { + case 0: + ZERO_STRUCT(c0); + info_ctr.ctr.ctr0 = &c0; + break; + case 1: + ZERO_STRUCT(c1); + info_ctr.ctr.ctr1 = &c1; + break; + case 2: + ZERO_STRUCT(c2); + info_ctr.ctr.ctr2 = &c2; + break; + case 10: + ZERO_STRUCT(c10); + info_ctr.ctr.ctr10 = &c10; + break; + case 502: + ZERO_STRUCT(c502); + info_ctr.ctr.ctr502 = &c502; + break; + } + + torture_comment(tctx, "testing NetSessEnum level %u\n", info_ctr.level); status = dcerpc_srvsvc_NetSessEnum(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetSessEnum failed"); if (!W_ERROR_IS_OK(r.out.result)) { @@ -362,9 +457,11 @@ static bool test_NetShareCheck(struct dcerpc_pipe *p, struct torture_context *tc { NTSTATUS status; struct srvsvc_NetShareCheck r; + enum srvsvc_ShareType type; r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.device_name = device_name; + r.out.type = &type; torture_comment(tctx, "testing NetShareCheck on device '%s'\n", r.in.device_name); @@ -382,6 +479,7 @@ static bool test_NetShareGetInfo(struct torture_context *tctx, { NTSTATUS status; struct srvsvc_NetShareGetInfo r; + union srvsvc_NetShareInfo info; struct { uint32_t level; WERROR anon_status; @@ -398,6 +496,7 @@ static bool test_NetShareGetInfo(struct torture_context *tctx, r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.share_name = sharename; + r.out.info = &info; for (i=0;i<ARRAY_SIZE(levels);i++) { WERROR expected; @@ -405,7 +504,6 @@ static bool test_NetShareGetInfo(struct torture_context *tctx, r.in.level = levels[i].level; expected = levels[i].anon_status; if (admin) expected = levels[i].admin_status; - ZERO_STRUCT(r.out); torture_comment(tctx, "testing NetShareGetInfo level %u on share '%s'\n", r.in.level, r.in.share_name); @@ -415,8 +513,8 @@ static bool test_NetShareGetInfo(struct torture_context *tctx, torture_assert_werr_equal(tctx, r.out.result, expected, "NetShareGetInfo failed"); if (r.in.level != 2) continue; - if (!r.out.info.info2 || !r.out.info.info2->path) continue; - if (!test_NetShareCheck(p, tctx, r.out.info.info2->path)) { + if (!r.out.info->info2 || !r.out.info->info2->path) continue; + if (!test_NetShareCheck(p, tctx, r.out.info->info2->path)) { return false; } } @@ -444,6 +542,8 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx, struct srvsvc_NetShareSetInfo r; struct srvsvc_NetShareGetInfo q; struct srvsvc_NetShareDel d; + struct sec_desc_buf sd_buf; + union srvsvc_NetShareInfo info; struct { uint32_t level; WERROR expected; @@ -465,17 +565,18 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx, talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.share_name = talloc_strdup(tctx, "testshare"); + info.info2 = talloc(tctx, struct srvsvc_NetShareInfo2); + info.info2->name = r.in.share_name; + info.info2->type = STYPE_DISKTREE; + info.info2->comment = talloc_strdup(tctx, "test comment"); + info.info2->permissions = 123434566; + info.info2->max_users = -1; + info.info2->current_users = 0; + info.info2->path = talloc_strdup(tctx, "C:\\"); + info.info2->password = NULL; + + a.in.info = &info; a.in.level = 2; - a.in.info.info2 = talloc(tctx, struct srvsvc_NetShareInfo2); - a.in.info.info2->name = r.in.share_name; - a.in.info.info2->type = STYPE_DISKTREE; - a.in.info.info2->comment = talloc_strdup(tctx, "test comment"); - a.in.info.info2->permissions = 123434566; - a.in.info.info2->max_users = -1; - a.in.info.info2->current_users = 0; - a.in.info.info2->path = talloc_strdup(tctx, "C:\\"); - a.in.info.info2->password = NULL; - a.in.parm_error = NULL; status = dcerpc_srvsvc_NetShareAdd(p, tctx, &a); @@ -496,109 +597,112 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx, switch (levels[i].level) { case 0: - r.in.info.info0 = talloc(tctx, struct srvsvc_NetShareInfo0); - r.in.info.info0->name = r.in.share_name; + info.info0 = talloc(tctx, struct srvsvc_NetShareInfo0); + info.info0->name = r.in.share_name; break; case 1: - r.in.info.info1 = talloc(tctx, struct srvsvc_NetShareInfo1); - r.in.info.info1->name = r.in.share_name; - r.in.info.info1->type = STYPE_DISKTREE; - r.in.info.info1->comment = talloc_strdup(tctx, "test comment 1"); + info.info1 = talloc(tctx, struct srvsvc_NetShareInfo1); + info.info1->name = r.in.share_name; + info.info1->type = STYPE_DISKTREE; + info.info1->comment = talloc_strdup(tctx, "test comment 1"); break; case 2: - r.in.info.info2 = talloc(tctx, struct srvsvc_NetShareInfo2); - r.in.info.info2->name = r.in.share_name; - r.in.info.info2->type = STYPE_DISKTREE; - r.in.info.info2->comment = talloc_strdup(tctx, "test comment 2"); - r.in.info.info2->permissions = 0; - r.in.info.info2->max_users = 2; - r.in.info.info2->current_users = 1; - r.in.info.info2->path = talloc_strdup(tctx, "::BLaH::"); /* "C:\\"); */ - r.in.info.info2->password = NULL; + info.info2 = talloc(tctx, struct srvsvc_NetShareInfo2); + info.info2->name = r.in.share_name; + info.info2->type = STYPE_DISKTREE; + info.info2->comment = talloc_strdup(tctx, "test comment 2"); + info.info2->permissions = 0; + info.info2->max_users = 2; + info.info2->current_users = 1; + info.info2->path = talloc_strdup(tctx, "::BLaH::"); /* "C:\\"); */ + info.info2->password = NULL; break; case 501: - r.in.info.info501 = talloc(tctx, struct srvsvc_NetShareInfo501); - r.in.info.info501->name = r.in.share_name; - r.in.info.info501->type = STYPE_DISKTREE; - r.in.info.info501->comment = talloc_strdup(tctx, "test comment 501"); - r.in.info.info501->csc_policy = 0; + info.info501 = talloc(tctx, struct srvsvc_NetShareInfo501); + info.info501->name = r.in.share_name; + info.info501->type = STYPE_DISKTREE; + info.info501->comment = talloc_strdup(tctx, "test comment 501"); + info.info501->csc_policy = 0; break; case 502: - r.in.info.info502 = talloc(tctx, struct srvsvc_NetShareInfo502); - r.in.info.info502->name = r.in.share_name; - r.in.info.info502->type = STYPE_DISKTREE; - r.in.info.info502->comment = talloc_strdup(tctx, "test comment 502"); - r.in.info.info502->permissions = 0; - r.in.info.info502->max_users = 502; - r.in.info.info502->current_users = 1; - r.in.info.info502->path = talloc_strdup(tctx, "C:\\"); - r.in.info.info502->password = NULL; - r.in.info.info502->unknown = 0; - r.in.info.info502->sd = NULL; + ZERO_STRUCT(sd_buf); + info.info502 = talloc(tctx, struct srvsvc_NetShareInfo502); + info.info502->name = r.in.share_name; + info.info502->type = STYPE_DISKTREE; + info.info502->comment = talloc_strdup(tctx, "test comment 502"); + info.info502->permissions = 0; + info.info502->max_users = 502; + info.info502->current_users = 1; + info.info502->path = talloc_strdup(tctx, "C:\\"); + info.info502->password = NULL; + info.info502->sd_buf = sd_buf; break; case 1004: - r.in.info.info1004 = talloc(tctx, struct srvsvc_NetShareInfo1004); - r.in.info.info1004->comment = talloc_strdup(tctx, "test comment 1004"); + info.info1004 = talloc(tctx, struct srvsvc_NetShareInfo1004); + info.info1004->comment = talloc_strdup(tctx, "test comment 1004"); break; case 1005: - r.in.info.info1005 = talloc(tctx, struct srvsvc_NetShareInfo1005); - r.in.info.info1005->dfs_flags = 0; + info.info1005 = talloc(tctx, struct srvsvc_NetShareInfo1005); + info.info1005->dfs_flags = 0; break; case 1006: - r.in.info.info1006 = talloc(tctx, struct srvsvc_NetShareInfo1006); - r.in.info.info1006->max_users = 1006; + info.info1006 = talloc(tctx, struct srvsvc_NetShareInfo1006); + info.info1006->max_users = 1006; break; /* case 1007: - r.in.info.info1007 = talloc(tctx, struct srvsvc_NetShareInfo1007); - r.in.info.info1007->flags = 0; - r.in.info.info1007->alternate_directory_name = talloc_strdup(tctx, "test"); + info.info1007 = talloc(tctx, struct srvsvc_NetShareInfo1007); + info.info1007->flags = 0; + info.info1007->alternate_directory_name = talloc_strdup(tctx, "test"); break; */ case 1501: - r.in.info.info1501 = talloc_zero(tctx, struct sec_desc_buf); + info.info1501 = talloc_zero(tctx, struct sec_desc_buf); break; } - + + r.in.info = &info; + status = dcerpc_srvsvc_NetShareSetInfo(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetShareGetInfo failed"); torture_assert_werr_equal(tctx, r.out.result, levels[i].expected, "NetShareSetInfo failed"); q.in.share_name = r.in.share_name; + q.out.info = &info; status = dcerpc_srvsvc_NetShareGetInfo(p, tctx, &q); torture_assert_ntstatus_ok(tctx, status, "NetShareGetInfo failed"); torture_assert_werr_ok(tctx, q.out.result, "NetShareGetInfo failed"); - torture_assert_str_equal(tctx, q.out.info.info502->name, r.in.share_name, + torture_assert_str_equal(tctx, q.out.info->info502->name, r.in.share_name, "share name invalid"); switch (levels[i].level) { case 0: break; case 1: - torture_assert_str_equal(tctx, q.out.info.info502->comment, "test comment 1", "comment"); + torture_assert_str_equal(tctx, q.out.info->info502->comment, "test comment 1", "comment"); break; case 2: - torture_assert_str_equal(tctx, q.out.info.info502->comment, "test comment 2", "comment"); - torture_assert_int_equal(tctx, q.out.info.info2->max_users, 2, "max users"); - torture_assert_str_equal(tctx, q.out.info.info2->path, "C:\\", "path"); + torture_assert_str_equal(tctx, q.out.info->info2->comment, "test comment 2", "comment"); + torture_assert_int_equal(tctx, q.out.info->info2->max_users, 2, "max users"); + torture_assert_str_equal(tctx, q.out.info->info2->path, "C:\\", "path"); break; case 501: - torture_assert_str_equal(tctx, q.out.info.info501->comment, "test comment 501", "comment"); + torture_assert_str_equal(tctx, q.out.info->info501->comment, "test comment 501", "comment"); break; case 502: - torture_assert_str_equal(tctx, q.out.info.info502->comment, "test comment 502", "comment"); - torture_assert_int_equal(tctx, q.out.info.info2->max_users, 502, "max users"); - torture_assert_str_equal(tctx, q.out.info.info2->path, "C:\\", "path"); + torture_assert_str_equal(tctx, q.out.info->info502->comment, "test comment 502", "comment"); + torture_assert_int_equal(tctx, q.out.info->info502->max_users, 502, "max users"); + torture_assert_str_equal(tctx, q.out.info->info502->path, "C:\\", "path"); break; case 1004: - torture_assert_str_equal(tctx, q.out.info.info502->comment, "test comment 1004", + torture_assert_str_equal(tctx, q.out.info->info1004->comment, "test comment 1004", "comment"); break; case 1005: break; case 1006: - torture_assert_int_equal(tctx, q.out.info.info2->max_users, 1006, "Max users"); + torture_assert_int_equal(tctx, q.out.info->info1006->max_users, 1006, "Max users"); break; /* case 1007: break; @@ -627,7 +731,13 @@ static bool test_NetShareEnumAll(struct torture_context *tctx, { NTSTATUS status; struct srvsvc_NetShareEnumAll r; + struct srvsvc_NetShareInfoCtr info_ctr; struct srvsvc_NetShareCtr0 c0; + struct srvsvc_NetShareCtr1 c1; + struct srvsvc_NetShareCtr2 c2; + struct srvsvc_NetShareCtr501 c501; + struct srvsvc_NetShareCtr502 c502; + uint32_t totalentries = 0; struct { uint32_t level; WERROR anon_status; @@ -642,35 +752,61 @@ static bool test_NetShareEnumAll(struct torture_context *tctx, int i; uint32_t resume_handle; - ZERO_STRUCT(c0); + ZERO_STRUCT(info_ctr); r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); - r.in.ctr.ctr0 = &c0; + r.in.info_ctr = &info_ctr; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = &resume_handle; r.out.resume_handle = &resume_handle; + r.out.totalentries = &totalentries; + r.out.info_ctr = &info_ctr; for (i=0;i<ARRAY_SIZE(levels);i++) { + int j; WERROR expected; - r.in.level = levels[i].level; + info_ctr.level = levels[i].level; + + switch (info_ctr.level) { + case 0: + ZERO_STRUCT(c0); + info_ctr.ctr.ctr0 = &c0; + break; + case 1: + ZERO_STRUCT(c1); + info_ctr.ctr.ctr1 = &c1; + break; + case 2: + ZERO_STRUCT(c2); + info_ctr.ctr.ctr2 = &c2; + break; + case 501: + ZERO_STRUCT(c501); + info_ctr.ctr.ctr501 = &c501; + break; + case 502: + ZERO_STRUCT(c502); + info_ctr.ctr.ctr502 = &c502; + break; + } + expected = levels[i].anon_status; if (admin) expected = levels[i].admin_status; - ZERO_STRUCT(r.out); resume_handle = 0; - torture_comment(tctx, "testing NetShareEnumAll level %u\n", r.in.level); + torture_comment(tctx, "testing NetShareEnumAll level %u\n", info_ctr.level); status = dcerpc_srvsvc_NetShareEnumAll(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetShareEnumAll failed"); torture_assert_werr_equal(tctx, r.out.result, expected, "NetShareEnumAll failed"); /* call srvsvc_NetShareGetInfo for each returned share */ - if (r.in.level == 2 && r.out.ctr.ctr2) { - for (j=0;j<r.out.ctr.ctr2->count;j++) { + if (info_ctr.level == 2 && r.out.info_ctr->ctr.ctr2) { + for (j=0;j<r.out.info_ctr->ctr.ctr2->count;j++) { const char *name; - name = r.out.ctr.ctr2->array[j].name; + name = r.out.info_ctr->ctr.ctr2->array[j].name; if (!test_NetShareGetInfo(tctx, p, name, admin)) { return false; } @@ -698,7 +834,13 @@ static bool test_NetShareEnum(struct torture_context *tctx, { NTSTATUS status; struct srvsvc_NetShareEnum r; + struct srvsvc_NetShareInfoCtr info_ctr; struct srvsvc_NetShareCtr0 c0; + struct srvsvc_NetShareCtr1 c1; + struct srvsvc_NetShareCtr2 c2; + struct srvsvc_NetShareCtr501 c501; + struct srvsvc_NetShareCtr502 c502; + uint32_t totalentries = 0; struct { uint32_t level; WERROR anon_status; @@ -713,22 +855,44 @@ static bool test_NetShareEnum(struct torture_context *tctx, int i; r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); - r.in.ctr.ctr0 = &c0; - r.in.ctr.ctr0->count = 0; - r.in.ctr.ctr0->array = NULL; + r.in.info_ctr = &info_ctr; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = NULL; + r.out.totalentries = &totalentries; + r.out.info_ctr = &info_ctr; for (i=0;i<ARRAY_SIZE(levels);i++) { WERROR expected; - r.in.level = levels[i].level; + info_ctr.level = levels[i].level; + + switch (info_ctr.level) { + case 0: + ZERO_STRUCT(c0); + info_ctr.ctr.ctr0 = &c0; + break; + case 1: + ZERO_STRUCT(c1); + info_ctr.ctr.ctr1 = &c1; + break; + case 2: + ZERO_STRUCT(c2); + info_ctr.ctr.ctr2 = &c2; + break; + case 501: + ZERO_STRUCT(c501); + info_ctr.ctr.ctr501 = &c501; + break; + case 502: + ZERO_STRUCT(c502); + info_ctr.ctr.ctr502 = &c502; + break; + } + expected = levels[i].anon_status; if (admin) expected = levels[i].admin_status; - ZERO_STRUCT(r.out); - - torture_comment(tctx, "testing NetShareEnum level %u\n", r.in.level); + torture_comment(tctx, "testing NetShareEnum level %u\n", info_ctr.level); status = dcerpc_srvsvc_NetShareEnum(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetShareEnum failed"); torture_assert_werr_equal(tctx, r.out.result, expected, "NetShareEnum failed"); @@ -757,19 +921,15 @@ static bool test_NetSrvGetInfo(struct torture_context *tctx, { NTSTATUS status; struct srvsvc_NetSrvGetInfo r; - struct srvsvc_NetSrvInfo503 i503; + union srvsvc_NetSrvInfo info; uint32_t levels[] = {100, 101, 102, 502, 503}; int i; - uint32_t resume_handle; - - ZERO_STRUCT(i503); r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); for (i=0;i<ARRAY_SIZE(levels);i++) { - ZERO_STRUCT(r.out); - resume_handle = 0; r.in.level = levels[i]; + r.out.info = &info; torture_comment(tctx, "testing NetSrvGetInfo level %u\n", r.in.level); status = dcerpc_srvsvc_NetSrvGetInfo(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetSrvGetInfo failed"); @@ -789,16 +949,23 @@ static bool test_NetDiskEnum(struct torture_context *tctx, { NTSTATUS status; struct srvsvc_NetDiskEnum r; + struct srvsvc_NetDiskInfo info; + uint32_t totalentries = 0; uint32_t levels[] = {0}; int i; uint32_t resume_handle=0; - ZERO_STRUCT(r.in); + ZERO_STRUCT(info); + r.in.server_unc = NULL; r.in.resume_handle = &resume_handle; + r.in.info = &info; + r.out.info = &info; + r.out.totalentries = &totalentries; + r.out.resume_handle = &resume_handle; for (i=0;i<ARRAY_SIZE(levels);i++) { - ZERO_STRUCT(r.out); + ZERO_STRUCTP(r.out.info); r.in.level = levels[i]; torture_comment(tctx, "testing NetDiskEnum level %u\n", r.in.level); status = dcerpc_srvsvc_NetDiskEnum(p, tctx, &r); @@ -817,21 +984,36 @@ static bool test_NetTransportEnum(struct torture_context *tctx, { NTSTATUS status; struct srvsvc_NetTransportEnum r; - struct srvsvc_NetTransportCtr0 c0; + struct srvsvc_NetTransportInfoCtr transports; + struct srvsvc_NetTransportCtr0 ctr0; + struct srvsvc_NetTransportCtr1 ctr1; + + uint32_t totalentries = 0; uint32_t levels[] = {0, 1}; int i; + ZERO_STRUCT(transports); + r.in.server_unc = talloc_asprintf(tctx,"\\\\%s", dcerpc_server_name(p)); - r.in.transports.ctr0 = &c0; - r.in.transports.ctr0->count = 0; - r.in.transports.ctr0->array = NULL; + r.in.transports = &transports; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = NULL; + r.out.totalentries = &totalentries; + r.out.transports = &transports; for (i=0;i<ARRAY_SIZE(levels);i++) { - ZERO_STRUCT(r.out); - r.in.level = levels[i]; - torture_comment(tctx, "testing NetTransportEnum level %u\n", r.in.level); + transports.level = levels[i]; + switch (transports.level) { + case 0: + ZERO_STRUCT(ctr0); + transports.ctr.ctr0 = &ctr0; + break; + case 1: + ZERO_STRUCT(ctr1); + transports.ctr.ctr1 = &ctr1; + break; + } + torture_comment(tctx, "testing NetTransportEnum level %u\n", transports.level); status = dcerpc_srvsvc_NetTransportEnum(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetTransportEnum failed"); if (!W_ERROR_IS_OK(r.out.result)) { @@ -850,10 +1032,11 @@ static bool test_NetRemoteTOD(struct torture_context *tctx, { NTSTATUS status; struct srvsvc_NetRemoteTOD r; + struct srvsvc_NetRemoteTODInfo *info = NULL; r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); + r.out.info = &info; - ZERO_STRUCT(r.out); torture_comment(tctx, "testing NetRemoteTOD\n"); status = dcerpc_srvsvc_NetRemoteTOD(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetRemoteTOD failed"); |