summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-10-30 18:21:49 +0100
committerGünther Deschner <gd@samba.org>2008-10-31 02:44:34 +0100
commitf25b645ab1946ea8d36ce2adf26fd4b6590d476c (patch)
treeb678f33ecf72250dcb10b8a3812b0032439c5342
parent7204deac821289bbf901bf4f82a8965506669020 (diff)
downloadsamba-f25b645ab1946ea8d36ce2adf26fd4b6590d476c.tar.gz
samba-f25b645ab1946ea8d36ce2adf26fd4b6590d476c.tar.bz2
samba-f25b645ab1946ea8d36ce2adf26fd4b6590d476c.zip
s4-srvsvc: merge srvsvc_NetShareEnum from s3 idl.
Guenther
-rw-r--r--source4/librpc/idl/srvsvc.idl5
-rw-r--r--source4/rpc_server/srvsvc/dcesrv_srvsvc.c43
-rw-r--r--source4/torture/rpc/samba3rpc.c87
-rw-r--r--source4/torture/rpc/srvsvc.c42
4 files changed, 130 insertions, 47 deletions
diff --git a/source4/librpc/idl/srvsvc.idl b/source4/librpc/idl/srvsvc.idl
index 93a523f1de..4304dbed96 100644
--- a/source4/librpc/idl/srvsvc.idl
+++ b/source4/librpc/idl/srvsvc.idl
@@ -1421,10 +1421,9 @@ import "security.idl", "svcctl.idl";
total entries ... */
WERROR srvsvc_NetShareEnum(
[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 a3e7fd293c..b4e08896e5 100644
--- a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
+++ b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
@@ -1815,10 +1815,7 @@ static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TAL
struct share_config *scfg;
struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
- 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
*/
@@ -1833,7 +1830,7 @@ static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TAL
return ntstatus_to_werror(nterr);
}
- switch (r->in.level) {
+ switch (r->in.info_ctr->level) {
case 0:
{
int i, y = 0;
@@ -1848,7 +1845,7 @@ static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TAL
ctr0->array = NULL;
if (ctr0->count == 0) {
- r->out.ctr.ctr0 = ctr0;
+ r->out.info_ctr->ctr.ctr0 = ctr0;
return WERR_OK;
}
@@ -1874,15 +1871,16 @@ static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TAL
}
info.info0 = &ctr0->array[y];
- 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);
W_ERROR_NOT_OK_RETURN(status);
talloc_free(scfg);
y++;
}
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:
@@ -1899,7 +1897,7 @@ static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TAL
ctr1->array = NULL;
if (ctr1->count == 0) {
- r->out.ctr.ctr1 = ctr1;
+ r->out.info_ctr->ctr.ctr1 = ctr1;
return WERR_OK;
}
@@ -1925,15 +1923,16 @@ static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TAL
}
info.info1 = &ctr1->array[y];
- 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);
W_ERROR_NOT_OK_RETURN(status);
talloc_free(scfg);
y++;
}
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:
@@ -1952,7 +1951,7 @@ static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TAL
ctr2->array = NULL;
if (ctr2->count == 0) {
- r->out.ctr.ctr2 = ctr2;
+ r->out.info_ctr->ctr.ctr2 = ctr2;
return WERR_OK;
}
@@ -1978,15 +1977,16 @@ static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TAL
}
info.info2 = &ctr2->array[y];
- 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);
W_ERROR_NOT_OK_RETURN(status);
talloc_free(scfg);
y++;
}
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 502:
@@ -2005,7 +2005,7 @@ static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TAL
ctr502->array = NULL;
if (ctr502->count == 0) {
- r->out.ctr.ctr502 = ctr502;
+ r->out.info_ctr->ctr.ctr502 = ctr502;
return WERR_OK;
}
@@ -2031,15 +2031,16 @@ static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TAL
}
info.info502 = &ctr502->array[y];
- 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);
W_ERROR_NOT_OK_RETURN(status);
talloc_free(scfg);
y++;
}
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/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index bd23327e70..93bcb3a1ea 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -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;
}
@@ -2471,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);
@@ -2489,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;
diff --git a/source4/torture/rpc/srvsvc.c b/source4/torture/rpc/srvsvc.c
index 13563d809c..82a8a67854 100644
--- a/source4/torture/rpc/srvsvc.c
+++ b/source4/torture/rpc/srvsvc.c
@@ -834,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;
@@ -849,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");