summaryrefslogtreecommitdiff
path: root/source4/torture/rpc/srvsvc.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/rpc/srvsvc.c')
-rw-r--r--source4/torture/rpc/srvsvc.c306
1 files changed, 162 insertions, 144 deletions
diff --git a/source4/torture/rpc/srvsvc.c b/source4/torture/rpc/srvsvc.c
index e066b08596..b99570f81d 100644
--- a/source4/torture/rpc/srvsvc.c
+++ b/source4/torture/rpc/srvsvc.c
@@ -93,8 +93,8 @@ static BOOL test_NetCharDevControl(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
-static BOOL test_NetCharDevEnum(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx)
+static bool test_NetCharDevEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetCharDevEnum r;
@@ -103,7 +103,7 @@ static BOOL test_NetCharDevEnum(struct dcerpc_pipe *p,
int i;
BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ 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;
@@ -117,7 +117,7 @@ static BOOL test_NetCharDevEnum(struct dcerpc_pipe *p,
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);
+ status = dcerpc_srvsvc_NetCharDevEnum(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetCharDevEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
ret = False;
@@ -133,10 +133,10 @@ static BOOL test_NetCharDevEnum(struct dcerpc_pipe *p,
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)) {
+ if (!test_NetCharDevGetInfo(p, tctx, device)) {
ret = False;
}
- if (!test_NetCharDevControl(p, mem_ctx, device)) {
+ if (!test_NetCharDevControl(p, tctx, device)) {
ret = False;
}
}
@@ -239,8 +239,8 @@ static BOOL test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
#endif
-static BOOL test_NetCharDevQEnum(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx)
+static BOOL test_NetCharDevQEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetCharDevQEnum r;
@@ -249,8 +249,8 @@ static BOOL test_NetCharDevQEnum(struct dcerpc_pipe *p,
int i;
BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
- r.in.user = talloc_asprintf(mem_ctx,"%s","Administrator");
+ 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;
@@ -263,7 +263,7 @@ static BOOL test_NetCharDevQEnum(struct dcerpc_pipe *p,
ZERO_STRUCT(r.out);
r.in.level = levels[i];
printf("testing NetCharDevQEnum level %u\n", r.in.level);
- status = dcerpc_srvsvc_NetCharDevQEnum(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetCharDevQEnum(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetCharDevQEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
ret = False;
@@ -279,7 +279,7 @@ static BOOL test_NetCharDevQEnum(struct dcerpc_pipe *p,
for (j=0;j<r.out.ctr.ctr1->count;j++) {
const char *device;
device = r.out.ctr.ctr1->array[j].device;
- if (!test_NetCharDevQGetInfo(p, mem_ctx, device)) {
+ if (!test_NetCharDevQGetInfo(p, tctx, device)) {
ret = False;
}
}
@@ -292,8 +292,8 @@ static BOOL test_NetCharDevQEnum(struct dcerpc_pipe *p,
/**************************/
/* srvsvc_NetConn */
/**************************/
-static BOOL test_NetConnEnum(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx)
+static BOOL test_NetConnEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetConnEnum r;
@@ -302,8 +302,8 @@ static BOOL test_NetConnEnum(struct dcerpc_pipe *p,
int i;
BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
- r.in.path = talloc_asprintf(mem_ctx,"%s","ADMIN$");
+ 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;
@@ -314,7 +314,7 @@ static BOOL test_NetConnEnum(struct dcerpc_pipe *p,
ZERO_STRUCT(r.out);
r.in.level = levels[i];
d_printf("testing NetConnEnum level %u\n", r.in.level);
- status = dcerpc_srvsvc_NetConnEnum(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetConnEnum(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetConnEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
ret = False;
@@ -332,8 +332,8 @@ static BOOL test_NetConnEnum(struct dcerpc_pipe *p,
/**************************/
/* srvsvc_NetFile */
/**************************/
-static BOOL test_NetFileEnum(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx)
+static BOOL test_NetFileEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetFileEnum r;
@@ -342,7 +342,7 @@ static BOOL test_NetFileEnum(struct dcerpc_pipe *p,
int i;
BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ 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;
@@ -355,7 +355,7 @@ static BOOL test_NetFileEnum(struct dcerpc_pipe *p,
ZERO_STRUCT(r.out);
r.in.level = levels[i];
d_printf("testing NetFileEnum level %u\n", r.in.level);
- status = dcerpc_srvsvc_NetFileEnum(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetFileEnum(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetFileEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
ret = False;
@@ -373,8 +373,8 @@ static BOOL test_NetFileEnum(struct dcerpc_pipe *p,
/**************************/
/* srvsvc_NetSess */
/**************************/
-static BOOL test_NetSessEnum(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx)
+static BOOL test_NetSessEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetSessEnum r;
@@ -383,7 +383,7 @@ static BOOL test_NetSessEnum(struct dcerpc_pipe *p,
int i;
BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ 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;
@@ -396,7 +396,7 @@ static BOOL test_NetSessEnum(struct dcerpc_pipe *p,
ZERO_STRUCT(r.out);
r.in.level = levels[i];
d_printf("testing NetSessEnum level %u\n", r.in.level);
- status = dcerpc_srvsvc_NetSessEnum(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetSessEnum(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetSessEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
ret = False;
@@ -440,8 +440,9 @@ static BOOL test_NetShareCheck(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
-static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- const char *sharename, BOOL admin)
+static bool test_NetShareGetInfo(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ const char *sharename, bool admin)
{
NTSTATUS status;
struct srvsvc_NetShareGetInfo r;
@@ -460,7 +461,7 @@ static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
int i;
BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.share_name = sharename;
for (i=0;i<ARRAY_SIZE(levels);i++) {
@@ -474,7 +475,7 @@ static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
d_printf("testing NetShareGetInfo level %u on share '%s'\n",
r.in.level, r.in.share_name);
- status = dcerpc_srvsvc_NetShareGetInfo(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetShareGetInfo(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetShareGetInfo level %u on share '%s' failed - %s\n",
r.in.level, r.in.share_name, nt_errstr(status));
@@ -491,7 +492,7 @@ static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (r.in.level != 2) continue;
if (!r.out.info.info2 || !r.out.info.info2->path) continue;
- if (!test_NetShareCheck(p, mem_ctx, r.out.info.info2->path)) {
+ if (!test_NetShareCheck(p, tctx, r.out.info.info2->path)) {
ret = False;
}
}
@@ -499,7 +500,20 @@ static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
-static BOOL test_NetShareAddSetDel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_NetShareGetInfoAdminFull(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ return test_NetShareGetInfo(tctx, p, "ADMIN$", true);
+}
+
+static bool test_NetShareGetInfoAdminAnon(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ return test_NetShareGetInfo(tctx, p, "ADMIN$", false);
+}
+
+static bool test_NetShareAddSetDel(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetShareAdd a;
@@ -530,23 +544,23 @@ static BOOL test_NetShareAddSetDel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
}
a.in.server_unc = r.in.server_unc = q.in.server_unc = d.in.server_unc =
- talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
- r.in.share_name = talloc_strdup(mem_ctx, "testshare");
+ talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.share_name = talloc_strdup(tctx, "testshare");
a.in.level = 2;
- a.in.info.info2 = talloc(mem_ctx, struct srvsvc_NetShareInfo2);
+ 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(mem_ctx, "test comment");
+ 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(mem_ctx, "C:\\");
+ 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, mem_ctx, &a);
+ status = dcerpc_srvsvc_NetShareAdd(p, tctx, &a);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetShareAdd level 2 on share 'testshare' failed - %s\n",
nt_errstr(status));
@@ -571,70 +585,70 @@ static BOOL test_NetShareAddSetDel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
switch (levels[i].level) {
case 0:
- r.in.info.info0 = talloc(mem_ctx, struct srvsvc_NetShareInfo0);
+ r.in.info.info0 = talloc(tctx, struct srvsvc_NetShareInfo0);
r.in.info.info0->name = r.in.share_name;
break;
case 1:
- r.in.info.info1 = talloc(mem_ctx, struct srvsvc_NetShareInfo1);
+ 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(mem_ctx, "test comment 1");
+ r.in.info.info1->comment = talloc_strdup(tctx, "test comment 1");
break;
case 2:
- r.in.info.info2 = talloc(mem_ctx, struct srvsvc_NetShareInfo2);
+ 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(mem_ctx, "test comment 2");
+ 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(mem_ctx, "::BLaH::"); /* "C:\\"); */
+ r.in.info.info2->path = talloc_strdup(tctx, "::BLaH::"); /* "C:\\"); */
r.in.info.info2->password = NULL;
break;
case 501:
- r.in.info.info501 = talloc(mem_ctx, struct srvsvc_NetShareInfo501);
+ 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(mem_ctx, "test comment 501");
+ r.in.info.info501->comment = talloc_strdup(tctx, "test comment 501");
r.in.info.info501->csc_policy = 0;
break;
case 502:
- r.in.info.info502 = talloc(mem_ctx, struct srvsvc_NetShareInfo502);
+ 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(mem_ctx, "test comment 502");
+ 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(mem_ctx, "C:\\");
+ 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;
break;
case 1004:
- r.in.info.info1004 = talloc(mem_ctx, struct srvsvc_NetShareInfo1004);
- r.in.info.info1004->comment = talloc_strdup(mem_ctx, "test comment 1004");
+ r.in.info.info1004 = talloc(tctx, struct srvsvc_NetShareInfo1004);
+ r.in.info.info1004->comment = talloc_strdup(tctx, "test comment 1004");
break;
case 1005:
- r.in.info.info1005 = talloc(mem_ctx, struct srvsvc_NetShareInfo1005);
+ r.in.info.info1005 = talloc(tctx, struct srvsvc_NetShareInfo1005);
r.in.info.info1005->dfs_flags = 0;
break;
case 1006:
- r.in.info.info1006 = talloc(mem_ctx, struct srvsvc_NetShareInfo1006);
+ r.in.info.info1006 = talloc(tctx, struct srvsvc_NetShareInfo1006);
r.in.info.info1006->max_users = 1006;
break;
/* case 1007:
- r.in.info.info1007 = talloc(mem_ctx, struct srvsvc_NetShareInfo1007);
+ r.in.info.info1007 = talloc(tctx, struct srvsvc_NetShareInfo1007);
r.in.info.info1007->flags = 0;
- r.in.info.info1007->alternate_directory_name = talloc_strdup(mem_ctx, "test");
+ r.in.info.info1007->alternate_directory_name = talloc_strdup(tctx, "test");
break;
*/
case 1501:
- r.in.info.info1501 = talloc_zero(mem_ctx, struct sec_desc_buf);
+ r.in.info.info1501 = talloc_zero(tctx, struct sec_desc_buf);
break;
}
- status = dcerpc_srvsvc_NetShareSetInfo(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetShareSetInfo(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetShareGetInfo level %u on share '%s' failed - %s\n",
r.in.level, r.in.share_name, nt_errstr(status));
@@ -650,7 +664,7 @@ static BOOL test_NetShareAddSetDel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
q.in.share_name = r.in.share_name;
- status = dcerpc_srvsvc_NetShareGetInfo(p, mem_ctx, &q);
+ status = dcerpc_srvsvc_NetShareGetInfo(p, tctx, &q);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetShareGetInfo level %u on share '%s' failed - %s\n",
q.in.level, q.in.share_name, nt_errstr(status));
@@ -714,7 +728,7 @@ static BOOL test_NetShareAddSetDel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
d.in.share_name = r.in.share_name;
d.in.reserved = 0;
- status = dcerpc_srvsvc_NetShareDel(p, mem_ctx, &d);
+ status = dcerpc_srvsvc_NetShareDel(p, tctx, &d);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetShareDel on share 'testshare502' failed - %s\n",
nt_errstr(status));
@@ -731,8 +745,9 @@ static BOOL test_NetShareAddSetDel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
/**************************/
/* srvsvc_NetShare */
/**************************/
-static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx, BOOL admin)
+static bool test_NetShareEnumAll(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ bool admin)
{
NTSTATUS status;
struct srvsvc_NetShareEnumAll r;
@@ -754,7 +769,7 @@ static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p,
ZERO_STRUCT(c0);
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
r.in.ctr.ctr0 = &c0;
r.in.max_buffer = (uint32_t)-1;
r.in.resume_handle = &resume_handle;
@@ -772,7 +787,7 @@ static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p,
resume_handle = 0;
d_printf("testing NetShareEnumAll level %u\n", r.in.level);
- status = dcerpc_srvsvc_NetShareEnumAll(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetShareEnumAll(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetShareEnumAll level %u failed - %s\n", r.in.level, nt_errstr(status));
ret = False;
@@ -790,7 +805,7 @@ static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p,
for (j=0;j<r.out.ctr.ctr2->count;j++) {
const char *name;
name = r.out.ctr.ctr2->array[j].name;
- if (!test_NetShareGetInfo(p, mem_ctx, name, admin)) {
+ if (!test_NetShareGetInfo(tctx, p, name, admin)) {
ret = False;
}
}
@@ -800,8 +815,20 @@ static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p,
return ret;
}
-static BOOL test_NetShareEnum(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx, BOOL admin)
+static bool test_NetShareEnumAllFull(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ return test_NetShareEnumAll(tctx, p, true);
+}
+
+static bool test_NetShareEnumAllAnon(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ return test_NetShareEnumAll(tctx, p, false);
+}
+
+static bool test_NetShareEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p, bool admin)
{
NTSTATUS status;
struct srvsvc_NetShareEnum r;
@@ -820,7 +847,7 @@ static BOOL test_NetShareEnum(struct dcerpc_pipe *p,
int i;
BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ 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;
@@ -837,7 +864,7 @@ static BOOL test_NetShareEnum(struct dcerpc_pipe *p,
ZERO_STRUCT(r.out);
d_printf("testing NetShareEnum level %u\n", r.in.level);
- status = dcerpc_srvsvc_NetShareEnum(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetShareEnum(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetShareEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
ret = False;
@@ -854,11 +881,23 @@ static BOOL test_NetShareEnum(struct dcerpc_pipe *p,
return ret;
}
+static bool test_NetShareEnumFull(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ return test_NetShareEnum(tctx, p, true);
+}
+
+static bool test_NetShareEnumAnon(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ return test_NetShareEnum(tctx, p, false);
+}
+
/**************************/
/* srvsvc_NetSrv */
/**************************/
-static BOOL test_NetSrvGetInfo(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx)
+static bool test_NetSrvGetInfo(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetSrvGetInfo r;
@@ -870,14 +909,14 @@ static BOOL test_NetSrvGetInfo(struct dcerpc_pipe *p,
ZERO_STRUCT(i503);
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ 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];
d_printf("testing NetSrvGetInfo level %u\n", r.in.level);
- status = dcerpc_srvsvc_NetSrvGetInfo(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetSrvGetInfo(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetSrvGetInfo level %u failed - %s\n", r.in.level, nt_errstr(status));
ret = False;
@@ -895,8 +934,8 @@ static BOOL test_NetSrvGetInfo(struct dcerpc_pipe *p,
/**************************/
/* srvsvc_NetDisk */
/**************************/
-static BOOL test_NetDiskEnum(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx)
+static BOOL test_NetDiskEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetDiskEnum r;
@@ -913,7 +952,7 @@ static BOOL test_NetDiskEnum(struct dcerpc_pipe *p,
ZERO_STRUCT(r.out);
r.in.level = levels[i];
d_printf("testing NetDiskEnum level %u\n", r.in.level);
- status = dcerpc_srvsvc_NetDiskEnum(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetDiskEnum(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
NDR_PRINT_OUT_DEBUG(srvsvc_NetDiskEnum, &r);
d_printf("NetDiskEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
@@ -932,8 +971,8 @@ static BOOL test_NetDiskEnum(struct dcerpc_pipe *p,
/**************************/
/* srvsvc_NetTransport */
/**************************/
-static BOOL test_NetTransportEnum(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx)
+static bool test_NetTransportEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetTransportEnum r;
@@ -942,7 +981,7 @@ static BOOL test_NetTransportEnum(struct dcerpc_pipe *p,
int i;
BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ 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;
@@ -953,7 +992,7 @@ static BOOL test_NetTransportEnum(struct dcerpc_pipe *p,
ZERO_STRUCT(r.out);
r.in.level = levels[i];
d_printf("testing NetTransportEnum level %u\n", r.in.level);
- status = dcerpc_srvsvc_NetTransportEnum(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetTransportEnum(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetTransportEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
ret = False;
@@ -971,18 +1010,18 @@ static BOOL test_NetTransportEnum(struct dcerpc_pipe *p,
/**************************/
/* srvsvc_NetRemoteTOD */
/**************************/
-static BOOL test_NetRemoteTOD(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx)
+static BOOL test_NetRemoteTOD(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetRemoteTOD r;
BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
ZERO_STRUCT(r.out);
d_printf("testing NetRemoteTOD\n");
- status = dcerpc_srvsvc_NetRemoteTOD(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetRemoteTOD(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetRemoteTOD failed - %s\n", nt_errstr(status));
ret = False;
@@ -998,8 +1037,8 @@ static BOOL test_NetRemoteTOD(struct dcerpc_pipe *p,
/* srvsvc_NetName */
/**************************/
-static BOOL test_NetNameValidate(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx)
+static bool test_NetNameValidate(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetNameValidate r;
@@ -1007,7 +1046,7 @@ static BOOL test_NetNameValidate(struct dcerpc_pipe *p,
char *name;
int i, n, min, max;
- r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.flags = 0x0;
d_printf("testing NetNameValidate\n");
@@ -1017,7 +1056,7 @@ static BOOL test_NetNameValidate(struct dcerpc_pipe *p,
again:
/* let's limit ourselves to a maximum of 4096 bytes */
- r.in.name = name = talloc_array(mem_ctx, char, 4097);
+ r.in.name = name = talloc_array(tctx, char, 4097);
max = 4096;
min = 0;
n = max;
@@ -1030,7 +1069,7 @@ again:
memset(name, 'A', n);
name[n] = '\0';
- status = dcerpc_srvsvc_NetNameValidate(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetNameValidate(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetNameValidate failed while checking maximum size (%s)\n",
nt_errstr(status));
@@ -1057,12 +1096,12 @@ again:
/* find invalid chars for this type check only ASCII between 0x20 and 0x7e */
- invalidc = talloc_strdup(mem_ctx, "");
+ invalidc = talloc_strdup(tctx, "");
for (n = 0x20; n < 0x7e; n++) {
- r.in.name = name = talloc_asprintf(mem_ctx, "%c", (char)n);
+ r.in.name = name = talloc_asprintf(tctx, "%c", (char)n);
- status = dcerpc_srvsvc_NetNameValidate(p, mem_ctx, &r);
+ status = dcerpc_srvsvc_NetNameValidate(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetNameValidate failed while checking valid chars (%s)\n",
nt_errstr(status));
@@ -1090,60 +1129,39 @@ again:
return True;
}
-BOOL torture_rpc_srvsvc(struct torture_context *torture)
+struct torture_suite *torture_rpc_srvsvc(TALLOC_CTX *mem_ctx)
{
- NTSTATUS status;
- struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
- const char *binding = torture_setting_string(torture, "binding", NULL);
- struct cli_credentials *anon_credentials;
-
- mem_ctx = talloc_init("torture_rpc_srvsvc");
-
- status = torture_rpc_connection(torture, &p, &ndr_table_srvsvc);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
- return False;
- }
-
- ret &= test_NetCharDevEnum(p, mem_ctx);
- ret &= test_NetCharDevQEnum(p, mem_ctx);
- ret &= test_NetConnEnum(p, mem_ctx);
- ret &= test_NetFileEnum(p, mem_ctx);
- ret &= test_NetSessEnum(p, mem_ctx);
- ret &= test_NetShareEnumAll(p, mem_ctx, True);
- ret &= test_NetSrvGetInfo(p, mem_ctx);
- ret &= test_NetDiskEnum(p, mem_ctx);
- ret &= test_NetTransportEnum(p, mem_ctx);
- ret &= test_NetRemoteTOD(p, mem_ctx);
- ret &= test_NetShareEnum(p, mem_ctx, True);
- ret &= test_NetShareGetInfo(p, mem_ctx, "ADMIN$", True);
- ret &= test_NetShareAddSetDel(p, mem_ctx);
- ret &= test_NetNameValidate(p, mem_ctx);
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "SRVSVC");
+ struct torture_tcase *tcase;
+
+ tcase = torture_suite_add_rpc_iface_tcase(suite, "srvsvc (admin access)", &ndr_table_srvsvc);
+
+ torture_rpc_tcase_add_test(tcase, "NetCharDevEnum", test_NetCharDevEnum);
+ torture_rpc_tcase_add_test(tcase, "NetCharDevQEnum", test_NetCharDevQEnum);
+ torture_rpc_tcase_add_test(tcase, "NetConnEnum", test_NetConnEnum);
+ torture_rpc_tcase_add_test(tcase, "NetFileEnum", test_NetFileEnum);
+ torture_rpc_tcase_add_test(tcase, "NetSessEnum", test_NetSessEnum);
+ torture_rpc_tcase_add_test(tcase, "NetShareEnumAll", test_NetShareEnumAllFull);
+ torture_rpc_tcase_add_test(tcase, "NetSrvGetInfo", test_NetSrvGetInfo);
+ torture_rpc_tcase_add_test(tcase, "NetDiskEnum", test_NetDiskEnum);
+ torture_rpc_tcase_add_test(tcase, "NetTransportEnum", test_NetTransportEnum);
+ torture_rpc_tcase_add_test(tcase, "NetRemoteTOD", test_NetRemoteTOD);
+ torture_rpc_tcase_add_test(tcase, "NetShareEnum", test_NetShareEnumFull);
+ torture_rpc_tcase_add_test(tcase, "NetShareGetInfo", test_NetShareGetInfoAdminFull);
+ torture_rpc_tcase_add_test(tcase, "NetShareAddSetDel",
+ test_NetShareAddSetDel);
+ torture_rpc_tcase_add_test(tcase, "NetNameValidate", test_NetNameValidate);
- status = torture_rpc_connection(torture, &p, &ndr_table_srvsvc);
-
- if (!binding) {
- d_printf("You must specify a ncacn binding string\n");
- return False;
- }
-
- anon_credentials = cli_credentials_init_anon(mem_ctx);
-
- status = dcerpc_pipe_connect(mem_ctx,
- &p, binding, &ndr_table_srvsvc,
- anon_credentials, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
- return False;
- }
-
- ret &= test_NetShareEnumAll(p, mem_ctx, False);
- ret &= test_NetShareEnum(p, mem_ctx, False);
- ret &= test_NetShareGetInfo(p, mem_ctx, "ADMIN$", False);
-
- talloc_free(mem_ctx);
-
- return ret;
+ tcase = torture_suite_add_anon_rpc_iface_tcase(suite,
+ "srvsvc anonymous access",
+ &ndr_table_srvsvc);
+
+ torture_rpc_tcase_add_test(tcase, "NetShareEnumAll",
+ test_NetShareEnumAllAnon);
+ torture_rpc_tcase_add_test(tcase, "NetShareEnum",
+ test_NetShareEnumAnon);
+ torture_rpc_tcase_add_test(tcase, "NetShareGetInfo",
+ test_NetShareGetInfoAdminAnon);
+
+ return suite;
}