From f25b645ab1946ea8d36ce2adf26fd4b6590d476c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 30 Oct 2008 18:21:49 +0100 Subject: s4-srvsvc: merge srvsvc_NetShareEnum from s3 idl. Guenther --- source4/librpc/idl/srvsvc.idl | 5 +- source4/rpc_server/srvsvc/dcesrv_srvsvc.c | 43 +++++++-------- source4/torture/rpc/samba3rpc.c | 87 +++++++++++++++++++++++++------ source4/torture/rpc/srvsvc.c | 42 ++++++++++++--- 4 files changed, 130 insertions(+), 47 deletions(-) (limited to 'source4') 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;ictr.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; icount; 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