summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/client/client.c17
-rw-r--r--source4/libnet/libnet_share.c24
-rw-r--r--source4/librpc/idl/srvsvc.idl5
-rw-r--r--source4/rpc_server/srvsvc/dcesrv_srvsvc.c51
-rw-r--r--source4/torture/rpc/bench.c43
-rw-r--r--source4/torture/rpc/srvsvc.c48
6 files changed, 131 insertions, 57 deletions
diff --git a/source4/client/client.c b/source4/client/client.c
index 56b923974b..7eb14a2ce1 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -2563,9 +2563,11 @@ static bool browse_host(struct loadparm_context *lp_ctx,
char *binding;
NTSTATUS status;
struct srvsvc_NetShareEnumAll r;
+ struct srvsvc_NetShareInfoCtr info_ctr;
uint32_t resume_handle = 0;
TALLOC_CTX *mem_ctx = talloc_init("browse_host");
struct srvsvc_NetShareCtr1 ctr1;
+ uint32_t totalentries = 0;
binding = talloc_asprintf(mem_ctx, "ncacn_np:%s", query_host);
@@ -2580,11 +2582,16 @@ static bool browse_host(struct loadparm_context *lp_ctx,
return false;
}
+ info_ctr.level = 1;
+ info_ctr.ctr.ctr1 = &ctr1;
+
r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
- r.in.level = 1;
- r.in.ctr.ctr1 = &ctr1;
+ r.in.info_ctr = &info_ctr;
r.in.max_buffer = ~0;
r.in.resume_handle = &resume_handle;
+ r.out.resume_handle = &resume_handle;
+ r.out.totalentries = &totalentries;
+ r.out.info_ctr = &info_ctr;
d_printf("\n\tSharename Type Comment\n");
d_printf("\t--------- ---- -------\n");
@@ -2596,9 +2603,9 @@ static bool browse_host(struct loadparm_context *lp_ctx,
if (NT_STATUS_IS_OK(status) &&
(W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA) ||
W_ERROR_IS_OK(r.out.result)) &&
- r.out.ctr.ctr1) {
- display_share_result(r.out.ctr.ctr1);
- resume_handle += r.out.ctr.ctr1->count;
+ r.out.info_ctr->ctr.ctr1) {
+ display_share_result(r.out.info_ctr->ctr.ctr1);
+ resume_handle += r.out.info_ctr->ctr.ctr1->count;
}
} while (NT_STATUS_IS_OK(status) && W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA));
diff --git a/source4/libnet/libnet_share.c b/source4/libnet/libnet_share.c
index 5affb27ead..0bf6749a9c 100644
--- a/source4/libnet/libnet_share.c
+++ b/source4/libnet/libnet_share.c
@@ -28,7 +28,9 @@ NTSTATUS libnet_ListShares(struct libnet_context *ctx,
NTSTATUS status;
struct libnet_RpcConnect c;
struct srvsvc_NetShareEnumAll s;
+ struct srvsvc_NetShareInfoCtr info_ctr;
uint32_t resume_handle = 0;
+ uint32_t totalentries = 0;
struct srvsvc_NetShareCtr0 ctr0;
struct srvsvc_NetShareCtr1 ctr1;
struct srvsvc_NetShareCtr2 ctr2;
@@ -51,37 +53,39 @@ NTSTATUS libnet_ListShares(struct libnet_context *ctx,
return status;
}
- s.in.level = r->in.level;
- switch (s.in.level) {
+ info_ctr.level = r->in.level;
+ switch (info_ctr.level) {
case 0:
- s.in.ctr.ctr0 = &ctr0;
+ info_ctr.ctr.ctr0 = &ctr0;
ZERO_STRUCT(ctr0);
break;
case 1:
- s.in.ctr.ctr1 = &ctr1;
+ info_ctr.ctr.ctr1 = &ctr1;
ZERO_STRUCT(ctr1);
break;
case 2:
- s.in.ctr.ctr2 = &ctr2;
+ info_ctr.ctr.ctr2 = &ctr2;
ZERO_STRUCT(ctr2);
break;
case 501:
- s.in.ctr.ctr501 = &ctr501;
+ info_ctr.ctr.ctr501 = &ctr501;
ZERO_STRUCT(ctr501);
break;
case 502:
- s.in.ctr.ctr502 = &ctr502;
+ info_ctr.ctr.ctr502 = &ctr502;
ZERO_STRUCT(ctr502);
break;
default:
r->out.error_string = talloc_asprintf(mem_ctx,
"libnet_ListShares: Invalid info level requested: %d",
- s.in.level);
+ info_ctr.level);
return NT_STATUS_INVALID_PARAMETER;
}
s.in.max_buffer = ~0;
s.in.resume_handle = &resume_handle;
-
+ s.in.info_ctr = &info_ctr;
+ s.out.info_ctr = &info_ctr;
+ s.out.totalentries = &totalentries;
status = dcerpc_srvsvc_NetShareEnumAll(c.out.dcerpc_pipe, mem_ctx, &s);
@@ -100,7 +104,7 @@ NTSTATUS libnet_ListShares(struct libnet_context *ctx,
goto disconnect;
}
- r->out.ctr = s.out.ctr;
+ r->out.ctr = s.out.info_ctr->ctr;
disconnect:
talloc_free(c.out.dcerpc_pipe);
diff --git a/source4/librpc/idl/srvsvc.idl b/source4/librpc/idl/srvsvc.idl
index bbabd8e2dc..93a523f1de 100644
--- a/source4/librpc/idl/srvsvc.idl
+++ b/source4/librpc/idl/srvsvc.idl
@@ -578,10 +578,9 @@ import "security.idl", "svcctl.idl";
/* Function: 0x0f */
WERROR srvsvc_NetShareEnumAll (
[in,unique] [string,charset(UTF16)] uint16 *server_unc,
- [in,out] uint32 level,
- [in,out,switch_is(level)] srvsvc_NetShareCtr ctr,
+ [in,out,ref] srvsvc_NetShareInfoCtr *info_ctr,
[in] uint32 max_buffer,
- [out] uint32 totalentries,
+ [out,ref] uint32 *totalentries,
[in,out,unique] uint32 *resume_handle
);
diff --git a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
index bdb617a72a..a3e7fd293c 100644
--- a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
+++ b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
@@ -716,10 +716,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
struct share_context *sctx;
struct share_config *scfg;
- r->out.level = r->in.level;
- ZERO_STRUCT(r->out.ctr);
- r->out.totalentries = 0;
- r->out.resume_handle = NULL;
+ *r->out.totalentries = 0;
/* TODO: - paging of results
*/
@@ -734,7 +731,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
return ntstatus_to_werror(nterr);
}
- switch (r->in.level) {
+ switch (r->in.info_ctr->level) {
case 0:
{
int i;
@@ -747,7 +744,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
ctr0->array = NULL;
if (ctr0->count == 0) {
- r->out.ctr.ctr0 = ctr0;
+ r->out.info_ctr->ctr.ctr0 = ctr0;
return WERR_OK;
}
@@ -764,7 +761,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
return WERR_GENERAL_FAILURE;
}
info.info0 = &ctr0->array[i];
- status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
+ status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
if (!W_ERROR_IS_OK(status)) {
return status;
}
@@ -772,8 +769,8 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
}
talloc_free(snames);
- r->out.ctr.ctr0 = ctr0;
- r->out.totalentries = r->out.ctr.ctr0->count;
+ r->out.info_ctr->ctr.ctr0 = ctr0;
+ *r->out.totalentries = r->out.info_ctr->ctr.ctr0->count;
return WERR_OK;
}
case 1:
@@ -788,7 +785,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
ctr1->array = NULL;
if (ctr1->count == 0) {
- r->out.ctr.ctr1 = ctr1;
+ r->out.info_ctr->ctr.ctr1 = ctr1;
return WERR_OK;
}
@@ -805,7 +802,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
return WERR_GENERAL_FAILURE;
}
info.info1 = &ctr1->array[i];
- status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
+ status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
if (!W_ERROR_IS_OK(status)) {
return status;
}
@@ -813,8 +810,9 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
}
talloc_free(snames);
- r->out.ctr.ctr1 = ctr1;
- r->out.totalentries = r->out.ctr.ctr1->count;
+ r->out.info_ctr->ctr.ctr1 = ctr1;
+ *r->out.totalentries = r->out.info_ctr->ctr.ctr1->count;
+
return WERR_OK;
}
case 2:
@@ -831,7 +829,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
ctr2->array = NULL;
if (ctr2->count == 0) {
- r->out.ctr.ctr2 = ctr2;
+ r->out.info_ctr->ctr.ctr2 = ctr2;
return WERR_OK;
}
@@ -848,7 +846,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
return WERR_GENERAL_FAILURE;
}
info.info2 = &ctr2->array[i];
- status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
+ status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
if (!W_ERROR_IS_OK(status)) {
return status;
}
@@ -856,8 +854,9 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
}
talloc_free(snames);
- r->out.ctr.ctr2 = ctr2;
- r->out.totalentries = r->out.ctr.ctr2->count;
+ r->out.info_ctr->ctr.ctr2 = ctr2;
+ *r->out.totalentries = r->out.info_ctr->ctr.ctr2->count;
+
return WERR_OK;
}
case 501:
@@ -874,7 +873,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
ctr501->array = NULL;
if (ctr501->count == 0) {
- r->out.ctr.ctr501 = ctr501;
+ r->out.info_ctr->ctr.ctr501 = ctr501;
return WERR_OK;
}
@@ -891,7 +890,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
return WERR_GENERAL_FAILURE;
}
info.info501 = &ctr501->array[i];
- status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
+ status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
if (!W_ERROR_IS_OK(status)) {
return status;
}
@@ -899,8 +898,9 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
}
talloc_free(snames);
- r->out.ctr.ctr501 = ctr501;
- r->out.totalentries = r->out.ctr.ctr501->count;
+ r->out.info_ctr->ctr.ctr501 = ctr501;
+ *r->out.totalentries = r->out.info_ctr->ctr.ctr501->count;
+
return WERR_OK;
}
case 502:
@@ -917,7 +917,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
ctr502->array = NULL;
if (ctr502->count == 0) {
- r->out.ctr.ctr502 = ctr502;
+ r->out.info_ctr->ctr.ctr502 = ctr502;
return WERR_OK;
}
@@ -934,7 +934,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
return WERR_GENERAL_FAILURE;
}
info.info502 = &ctr502->array[i];
- status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
+ status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
if (!W_ERROR_IS_OK(status)) {
return status;
}
@@ -942,8 +942,9 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
}
talloc_free(snames);
- r->out.ctr.ctr502 = ctr502;
- r->out.totalentries = r->out.ctr.ctr502->count;
+ r->out.info_ctr->ctr.ctr502 = ctr502;
+ *r->out.totalentries = r->out.info_ctr->ctr.ctr502->count;
+
return WERR_OK;
}
default:
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/srvsvc.c b/source4/torture/rpc/srvsvc.c
index 783dfd328b..13563d809c 100644
--- a/source4/torture/rpc/srvsvc.c
+++ b/source4/torture/rpc/srvsvc.c
@@ -731,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;
@@ -746,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;
}