diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/client/client.c | 17 | ||||
-rw-r--r-- | source4/libnet/libnet_share.c | 29 | ||||
-rw-r--r-- | source4/libnet/libnet_time.c | 16 | ||||
-rw-r--r-- | source4/librpc/idl/srvsvc.idl | 103 | ||||
-rw-r--r-- | source4/rpc_server/common/share_info.c | 6 | ||||
-rw-r--r-- | source4/rpc_server/srvsvc/dcesrv_srvsvc.c | 463 | ||||
-rw-r--r-- | source4/torture/libnet/libnet_share.c | 9 | ||||
-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 |
10 files changed, 769 insertions, 479 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 e24ba8161a..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); @@ -115,6 +119,7 @@ NTSTATUS libnet_AddShare(struct libnet_context *ctx, NTSTATUS status; struct libnet_RpcConnect c; struct srvsvc_NetShareAdd s; + union srvsvc_NetShareInfo info; c.level = LIBNET_RPC_CONNECT_SERVER; c.in.name = r->in.server_name; @@ -129,8 +134,10 @@ NTSTATUS libnet_AddShare(struct libnet_context *ctx, return status; } + info.info2 = &r->in.share; + s.in.level = 2; - s.in.info.info2 = &r->in.share; + s.in.info = &info; s.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", r->in.server_name); status = dcerpc_srvsvc_NetShareAdd(c.out.dcerpc_pipe, mem_ctx, &s); diff --git a/source4/libnet/libnet_time.c b/source4/libnet/libnet_time.c index e1e53fb947..61a451d3fd 100644 --- a/source4/libnet/libnet_time.c +++ b/source4/libnet/libnet_time.c @@ -30,6 +30,7 @@ static NTSTATUS libnet_RemoteTOD_srvsvc(struct libnet_context *ctx, TALLOC_CTX * NTSTATUS status; struct libnet_RpcConnect c; struct srvsvc_NetRemoteTOD tod; + struct srvsvc_NetRemoteTODInfo *info = NULL; struct tm tm; /* prepare connect to the SRVSVC pipe of a timeserver */ @@ -48,6 +49,7 @@ static NTSTATUS libnet_RemoteTOD_srvsvc(struct libnet_context *ctx, TALLOC_CTX * /* prepare srvsvc_NetrRemoteTOD */ tod.in.server_unc = talloc_asprintf(mem_ctx, "\\%s", c.in.name); + tod.out.info = &info; /* 2. try srvsvc_NetRemoteTOD */ status = dcerpc_srvsvc_NetRemoteTOD(c.out.dcerpc_pipe, mem_ctx, &tod); @@ -68,18 +70,18 @@ static NTSTATUS libnet_RemoteTOD_srvsvc(struct libnet_context *ctx, TALLOC_CTX * } /* need to set the out parameters */ - tm.tm_sec = (int)tod.out.info->secs; - tm.tm_min = (int)tod.out.info->mins; - tm.tm_hour = (int)tod.out.info->hours; - tm.tm_mday = (int)tod.out.info->day; - tm.tm_mon = (int)tod.out.info->month -1; - tm.tm_year = (int)tod.out.info->year - 1900; + tm.tm_sec = (int)info->secs; + tm.tm_min = (int)info->mins; + tm.tm_hour = (int)info->hours; + tm.tm_mday = (int)info->day; + tm.tm_mon = (int)info->month -1; + tm.tm_year = (int)info->year - 1900; tm.tm_wday = -1; tm.tm_yday = -1; tm.tm_isdst = -1; r->srvsvc.out.time = timegm(&tm); - r->srvsvc.out.time_zone = tod.out.info->timezone * 60; + r->srvsvc.out.time_zone = info->timezone * 60; goto disconnect; diff --git a/source4/librpc/idl/srvsvc.idl b/source4/librpc/idl/srvsvc.idl index 2d6242e6d1..4304dbed96 100644 --- a/source4/librpc/idl/srvsvc.idl +++ b/source4/librpc/idl/srvsvc.idl @@ -51,14 +51,18 @@ import "security.idl", "svcctl.idl"; [default] ; } srvsvc_NetCharDevCtr; + typedef struct { + uint32 level; + [switch_is(level)] srvsvc_NetCharDevCtr ctr; + } srvsvc_NetCharDevInfoCtr; + /******************/ /* Function: 0x00 */ WERROR srvsvc_NetCharDevEnum( [in,unique] [string,charset(UTF16)] uint16 *server_unc, - [in,out] uint32 level, - [in,out,switch_is(level)] srvsvc_NetCharDevCtr ctr, + [in,out,ref] srvsvc_NetCharDevInfoCtr *info_ctr, [in] uint32 max_buffer, - [out] uint32 totalentries, + [out,ref] uint32 *totalentries, [in,out,unique] uint32 *resume_handle ); @@ -68,7 +72,7 @@ import "security.idl", "svcctl.idl"; [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] [string,charset(UTF16)] uint16 device_name[], [in] uint32 level, - [out,switch_is(level)] srvsvc_NetCharDevInfo info + [out,ref,switch_is(level)] srvsvc_NetCharDevInfo *info ); /******************/ @@ -116,15 +120,19 @@ import "security.idl", "svcctl.idl"; [default] ; } srvsvc_NetCharDevQCtr; + typedef struct { + uint32 level; + [switch_is(level)] srvsvc_NetCharDevQCtr ctr; + } srvsvc_NetCharDevQInfoCtr; + /******************/ /* Function: 0x03 */ WERROR srvsvc_NetCharDevQEnum( [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in,unique] [string,charset(UTF16)] uint16 *user, - [in,out] uint32 level, - [in,out,switch_is(level)] srvsvc_NetCharDevQCtr ctr, + [in,out,ref] srvsvc_NetCharDevQInfoCtr *info_ctr, [in] uint32 max_buffer, - [out] uint32 totalentries, + [out,ref] uint32 *totalentries, [in,out,unique] uint32 *resume_handle ); @@ -135,13 +143,13 @@ import "security.idl", "svcctl.idl"; [in] [string,charset(UTF16)] uint16 queue_name[], [in] [string,charset(UTF16)] uint16 user[], [in] uint32 level, - [out,switch_is(level)] srvsvc_NetCharDevQInfo info + [out,switch_is(level),ref] srvsvc_NetCharDevQInfo *info ); /******************/ /* Function: 0x05 */ WERROR srvsvc_NetCharDevQSetInfo( - [in,unique] [string,charset(UTF16)] uint16 *server_unc, + [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] [string,charset(UTF16)] uint16 queue_name[], [in] uint32 level, [in,switch_is(level)] srvsvc_NetCharDevQInfo info, @@ -206,10 +214,9 @@ import "security.idl", "svcctl.idl"; WERROR srvsvc_NetConnEnum( [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in,unique] [string,charset(UTF16)] uint16 *path, - [in,out] uint32 level, - [in,out,switch_is(level)] srvsvc_NetConnCtr ctr, + [in,out,ref] srvsvc_NetConnInfoCtr *info_ctr, [in] uint32 max_buffer, - [out] uint32 totalentries, + [out,ref] uint32 *totalentries, [in,out,unique] uint32 *resume_handle ); @@ -261,10 +268,9 @@ import "security.idl", "svcctl.idl"; [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in,unique] [string,charset(UTF16)] uint16 *path, [in,unique] [string,charset(UTF16)] uint16 *user, - [in,out] uint32 level, - [in,out,switch_is(level)] srvsvc_NetFileCtr ctr, + [in,out,ref] srvsvc_NetFileInfoCtr *info_ctr, [in] uint32 max_buffer, - [out] uint32 totalentries, + [out,ref] uint32 *totalentries, [in,out,unique] uint32 *resume_handle ); @@ -274,7 +280,7 @@ import "security.idl", "svcctl.idl"; [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] uint32 fid, [in] uint32 level, - [out,switch_is(level)] srvsvc_NetFileInfo info + [out,switch_is(level),ref] srvsvc_NetFileInfo *info ); /******************/ @@ -374,10 +380,9 @@ import "security.idl", "svcctl.idl"; [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in,unique] [string,charset(UTF16)] uint16 *client, [in,unique] [string,charset(UTF16)] uint16 *user, - [in,out] uint32 level, - [in,out,switch_is(level)] srvsvc_NetSessCtr ctr, + [in,out,ref] srvsvc_NetSessInfoCtr *info_ctr, [in] uint32 max_buffer, - [out] uint32 totalentries, + [out,ref] uint32 *totalentries, [in,out,unique] uint32 *resume_handle ); @@ -465,13 +470,11 @@ import "security.idl", "svcctl.idl"; srvsvc_ShareType type; [string,charset(UTF16)] uint16 *comment; uint32 permissions; - int32 max_users; + uint32 max_users; uint32 current_users; [string,charset(UTF16)] uint16 *path; [string,charset(UTF16)] uint16 *password; - /* maybe here is a struct sec_desc_buf following */ - uint32 unknown; - [subcontext(4)] security_descriptor *sd; + sec_desc_buf sd_buf; } srvsvc_NetShareInfo502; typedef struct { @@ -506,7 +509,7 @@ import "security.idl", "svcctl.idl"; } srvsvc_NetShareCtr1005; typedef struct { - int32 max_users; + uint32 max_users; } srvsvc_NetShareInfo1006; typedef struct { @@ -567,7 +570,7 @@ import "security.idl", "svcctl.idl"; WERROR srvsvc_NetShareAdd( [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] uint32 level, - [in,switch_is(level)] srvsvc_NetShareInfo info, + [in,ref,switch_is(level)] srvsvc_NetShareInfo *info, [in,out,unique] uint32 *parm_error ); @@ -575,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 ); @@ -588,7 +590,7 @@ import "security.idl", "svcctl.idl"; [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] [string,charset(UTF16)] uint16 share_name[], [in] uint32 level, - [out,switch_is(level)] srvsvc_NetShareInfo info + [out,ref,switch_is(level)] srvsvc_NetShareInfo *info ); /******************/ @@ -597,7 +599,7 @@ import "security.idl", "svcctl.idl"; [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] [string,charset(UTF16)] uint16 share_name[], [in] uint32 level, - [in,switch_is(level)] srvsvc_NetShareInfo info, + [in,ref,switch_is(level)] srvsvc_NetShareInfo *info, [in,out,unique] uint32 *parm_error ); @@ -622,7 +624,7 @@ import "security.idl", "svcctl.idl"; WERROR srvsvc_NetShareCheck( [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] [string,charset(UTF16)] uint16 device_name[], - [out] srvsvc_ShareType type + [out,ref] srvsvc_ShareType *type ); /**************************/ @@ -686,6 +688,7 @@ import "security.idl", "svcctl.idl"; uint32 sessreqs; uint32 opensearch; uint32 activelocks; + uint32 numreqbufs; uint32 sizereqbufs; uint32 numbigbufs; uint32 numfiletasks; @@ -719,6 +722,7 @@ import "security.idl", "svcctl.idl"; uint32 sessreqs; uint32 opensearch; uint32 activelocks; + uint32 numreqbufs; uint32 sizereqbufs; uint32 numbigbufs; uint32 numfiletasks; @@ -1132,7 +1136,7 @@ import "security.idl", "svcctl.idl"; WERROR srvsvc_NetSrvGetInfo( [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] uint32 level, - [out,switch_is(level)] srvsvc_NetSrvInfo info + [out,ref,switch_is(level)] srvsvc_NetSrvInfo *info ); /******************/ @@ -1140,7 +1144,7 @@ import "security.idl", "svcctl.idl"; WERROR srvsvc_NetSrvSetInfo( [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] uint32 level, - [in,switch_is(level)] srvsvc_NetSrvInfo info, + [in,ref,switch_is(level)] srvsvc_NetSrvInfo *info, [in,out,unique] uint32 *parm_error ); @@ -1170,9 +1174,9 @@ import "security.idl", "svcctl.idl"; WERROR srvsvc_NetDiskEnum( [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] uint32 level, - [in,out] srvsvc_NetDiskInfo info, + [in,out,ref] srvsvc_NetDiskInfo *info, [in] uint32 maxlen, - [out] uint32 totalentries, + [out,ref] uint32 *totalentries, [in,out,unique] uint32 *resume_handle ); @@ -1206,7 +1210,7 @@ import "security.idl", "svcctl.idl"; [in,unique] [string,charset(UTF16)] uint16 *service, [in] uint32 level, [in] uint32 options, - [out] srvsvc_Statistics stat + [out,ref] srvsvc_Statistics **stats ); /**************************/ @@ -1287,14 +1291,18 @@ import "security.idl", "svcctl.idl"; [default]; } srvsvc_NetTransportCtr; + typedef struct { + uint32 level; + [switch_is(level)] srvsvc_NetTransportCtr ctr; + } srvsvc_NetTransportInfoCtr; + /******************/ /* Function: 0x1a */ WERROR srvsvc_NetTransportEnum( [in,unique] [string,charset(UTF16)] uint16 *server_unc, - [in,out] uint32 level, - [in,out,switch_is(level)] srvsvc_NetTransportCtr transports, + [in,out,ref] srvsvc_NetTransportInfoCtr *transports, [in] uint32 max_buffer, - [out] uint32 totalentries, + [out,ref] uint32 *totalentries, [in,out,unique] uint32 *resume_handle ); @@ -1303,7 +1311,7 @@ import "security.idl", "svcctl.idl"; WERROR srvsvc_NetTransportDel( [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] uint32 level, - [in,switch_is(level)] srvsvc_NetTransportInfo info + [in] srvsvc_NetTransportInfo0 *info0 ); /**************************/ @@ -1328,7 +1336,7 @@ import "security.idl", "svcctl.idl"; /* Function: 0x1c */ WERROR srvsvc_NetRemoteTOD( [in,unique] [string,charset(UTF16)] uint16 *server_unc, - [out,unique] srvsvc_NetRemoteTODInfo *info + [out,ref] srvsvc_NetRemoteTODInfo **info ); /**************************/ @@ -1352,7 +1360,7 @@ import "security.idl", "svcctl.idl"; [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] [string,charset(UTF16)] uint16 path[], [in] uint32 pathflags, - [out] uint32 pathtype + [out,ref] uint32 *pathtype ); /******************/ @@ -1363,7 +1371,7 @@ import "security.idl", "svcctl.idl"; [out] [size_is(maxbuf)] uint8 can_path[], [in] uint32 maxbuf, [in] [string,charset(UTF16)] uint16 prefix[], - [in,out] uint32 pathtype, + [in,out,ref] uint32 *pathtype, [in] uint32 pathflags ); @@ -1413,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 ); @@ -1442,7 +1449,7 @@ import "security.idl", "svcctl.idl"; [in,unique] [string,charset(UTF16)] uint16 *share, [in] [string,charset(UTF16)] uint16 file[], [in] security_secinfo securityinformation, - [out,unique] sec_desc_buf *sd_buf + [out,ref] sec_desc_buf **sd_buf ); /******************/ @@ -1452,7 +1459,7 @@ import "security.idl", "svcctl.idl"; [in,unique] [string,charset(UTF16)] uint16 *share, [in] [string,charset(UTF16)] uint16 file[], [in] security_secinfo securityinformation, - [in] sec_desc_buf sd_buf + [in,ref] sec_desc_buf *sd_buf ); diff --git a/source4/rpc_server/common/share_info.c b/source4/rpc_server/common/share_info.c index 130babd175..48870e602f 100644 --- a/source4/rpc_server/common/share_info.c +++ b/source4/rpc_server/common/share_info.c @@ -107,12 +107,6 @@ uint32_t dcesrv_common_get_share_dfs_flags(TALLOC_CTX *mem_ctx, struct dcesrv_co } /* This hardcoded value should go into a ldb database! */ -uint32_t dcesrv_common_get_share_unknown(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg) -{ - return 0; -} - -/* This hardcoded value should go into a ldb database! */ struct security_descriptor *dcesrv_common_get_security_descriptor(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg) { return NULL; diff --git a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c index 58eed57f0f..b4e08896e5 100644 --- a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c +++ b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c @@ -45,26 +45,24 @@ static WERROR dcesrv_srvsvc_NetCharDevEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct srvsvc_NetCharDevEnum *r) { - r->out.level = r->in.level; - r->out.totalentries = 0; - r->out.resume_handle = NULL; + *r->out.totalentries = 0; - switch (r->in.level) { + switch (r->in.info_ctr->level) { case 0: - r->out.ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetCharDevCtr0); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr0); + r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetCharDevCtr0); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0); - r->out.ctr.ctr0->count = 0; - r->out.ctr.ctr0->array = NULL; + r->out.info_ctr->ctr.ctr0->count = 0; + r->out.info_ctr->ctr.ctr0->array = NULL; return WERR_NOT_SUPPORTED; case 1: - r->out.ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetCharDevCtr1); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr1); + r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetCharDevCtr1); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1); - r->out.ctr.ctr1->count = 0; - r->out.ctr.ctr1->array = NULL; + r->out.info_ctr->ctr.ctr1->count = 0; + r->out.info_ctr->ctr.ctr1->array = NULL; return WERR_NOT_SUPPORTED; @@ -82,7 +80,7 @@ static WERROR dcesrv_srvsvc_NetCharDevEnum(struct dcesrv_call_state *dce_call, T static WERROR dcesrv_srvsvc_NetCharDevGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct srvsvc_NetCharDevGetInfo *r) { - ZERO_STRUCT(r->out); + ZERO_STRUCTP(r->out.info); switch (r->in.level) { case 0: @@ -117,28 +115,26 @@ static WERROR dcesrv_srvsvc_NetCharDevControl(struct dcesrv_call_state *dce_call static WERROR dcesrv_srvsvc_NetCharDevQEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct srvsvc_NetCharDevQEnum *r) { - r->out.level = r->in.level; - r->out.totalentries = 0; - r->out.resume_handle = NULL; + *r->out.totalentries = 0; - switch (r->in.level) { + switch (r->in.info_ctr->level) { case 0: { - r->out.ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetCharDevQCtr0); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr0); + r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetCharDevQCtr0); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0); - r->out.ctr.ctr0->count = 0; - r->out.ctr.ctr0->array = NULL; + r->out.info_ctr->ctr.ctr0->count = 0; + r->out.info_ctr->ctr.ctr0->array = NULL; return WERR_NOT_SUPPORTED; } case 1: { - r->out.ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetCharDevQCtr1); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr1); + r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetCharDevQCtr1); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1); - r->out.ctr.ctr1->count = 0; - r->out.ctr.ctr1->array = NULL; + r->out.info_ctr->ctr.ctr1->count = 0; + r->out.info_ctr->ctr.ctr1->array = NULL; return WERR_NOT_SUPPORTED; } @@ -156,7 +152,7 @@ static WERROR dcesrv_srvsvc_NetCharDevQEnum(struct dcesrv_call_state *dce_call, static WERROR dcesrv_srvsvc_NetCharDevQGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct srvsvc_NetCharDevQGetInfo *r) { - ZERO_STRUCT(r->out); + ZERO_STRUCTP(r->out.info); switch (r->in.level) { case 0: @@ -230,28 +226,26 @@ static WERROR dcesrv_srvsvc_NetCharDevQPurgeSelf(struct dcesrv_call_state *dce_c static WERROR dcesrv_srvsvc_NetConnEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct srvsvc_NetConnEnum *r) { - r->out.level = r->in.level; - r->out.totalentries = 0; - r->out.resume_handle = NULL; + *r->out.totalentries = 0; - switch (r->in.level) { + switch (r->in.info_ctr->level) { case 0: { - r->out.ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetConnCtr0); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr0); + r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetConnCtr0); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0); - r->out.ctr.ctr0->count = 0; - r->out.ctr.ctr0->array = NULL; + r->out.info_ctr->ctr.ctr0->count = 0; + r->out.info_ctr->ctr.ctr0->array = NULL; return WERR_NOT_SUPPORTED; } case 1: { - r->out.ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetConnCtr1); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr1); + r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetConnCtr1); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1); - r->out.ctr.ctr1->count = 0; - r->out.ctr.ctr1->array = NULL; + r->out.info_ctr->ctr.ctr1->count = 0; + r->out.info_ctr->ctr.ctr1->array = NULL; return WERR_NOT_SUPPORTED; } @@ -269,28 +263,26 @@ static WERROR dcesrv_srvsvc_NetConnEnum(struct dcesrv_call_state *dce_call, TALL static WERROR dcesrv_srvsvc_NetFileEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct srvsvc_NetFileEnum *r) { - r->out.level = r->in.level; - r->out.totalentries = 0; - r->out.resume_handle = NULL; + *r->out.totalentries = 0; - switch (r->in.level) { + switch (r->in.info_ctr->level) { case 2: { - r->out.ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetFileCtr2); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr2); + r->out.info_ctr->ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetFileCtr2); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr2); - r->out.ctr.ctr2->count = 0; - r->out.ctr.ctr2->array = NULL; + r->out.info_ctr->ctr.ctr2->count = 0; + r->out.info_ctr->ctr.ctr2->array = NULL; return WERR_NOT_SUPPORTED; } case 3: { - r->out.ctr.ctr3 = talloc(mem_ctx, struct srvsvc_NetFileCtr3); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr3); + r->out.info_ctr->ctr.ctr3 = talloc(mem_ctx, struct srvsvc_NetFileCtr3); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr3); - r->out.ctr.ctr3->count = 0; - r->out.ctr.ctr3->array = NULL; + r->out.info_ctr->ctr.ctr3->count = 0; + r->out.info_ctr->ctr.ctr3->array = NULL; return WERR_NOT_SUPPORTED; } @@ -308,7 +300,7 @@ static WERROR dcesrv_srvsvc_NetFileEnum(struct dcesrv_call_state *dce_call, TALL static WERROR dcesrv_srvsvc_NetFileGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct srvsvc_NetFileGetInfo *r) { - ZERO_STRUCT(r->out); + ZERO_STRUCTP(r->out.info); switch (r->in.level) { case 2: @@ -343,58 +335,56 @@ static WERROR dcesrv_srvsvc_NetFileClose(struct dcesrv_call_state *dce_call, TAL static WERROR dcesrv_srvsvc_NetSessEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct srvsvc_NetSessEnum *r) { - r->out.level = r->in.level; - r->out.totalentries = 0; - r->out.resume_handle = NULL; + *r->out.totalentries = 0; - switch (r->in.level) { + switch (r->in.info_ctr->level) { case 0: { - r->out.ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetSessCtr0); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr0); + r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetSessCtr0); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0); - r->out.ctr.ctr0->count = 0; - r->out.ctr.ctr0->array = NULL; + r->out.info_ctr->ctr.ctr0->count = 0; + r->out.info_ctr->ctr.ctr0->array = NULL; return WERR_NOT_SUPPORTED; } case 1: { - r->out.ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetSessCtr1); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr1); + r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetSessCtr1); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1); - r->out.ctr.ctr1->count = 0; - r->out.ctr.ctr1->array = NULL; + r->out.info_ctr->ctr.ctr1->count = 0; + r->out.info_ctr->ctr.ctr1->array = NULL; return WERR_NOT_SUPPORTED; } case 2: { - r->out.ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetSessCtr2); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr2); + r->out.info_ctr->ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetSessCtr2); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr2); - r->out.ctr.ctr2->count = 0; - r->out.ctr.ctr2->array = NULL; + r->out.info_ctr->ctr.ctr2->count = 0; + r->out.info_ctr->ctr.ctr2->array = NULL; return WERR_NOT_SUPPORTED; } case 10: { - r->out.ctr.ctr10 = talloc(mem_ctx, struct srvsvc_NetSessCtr10); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr10); + r->out.info_ctr->ctr.ctr10 = talloc(mem_ctx, struct srvsvc_NetSessCtr10); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr10); - r->out.ctr.ctr2->count = 0; - r->out.ctr.ctr2->array = NULL; + r->out.info_ctr->ctr.ctr10->count = 0; + r->out.info_ctr->ctr.ctr10->array = NULL; return WERR_NOT_SUPPORTED; } case 502: { - r->out.ctr.ctr502 = talloc(mem_ctx, struct srvsvc_NetSessCtr502); - W_ERROR_HAVE_NO_MEMORY(r->out.ctr.ctr502); + r->out.info_ctr->ctr.ctr502 = talloc(mem_ctx, struct srvsvc_NetSessCtr502); + W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr502); - r->out.ctr.ctr2->count = 0; - r->out.ctr.ctr2->array = NULL; + r->out.info_ctr->ctr.ctr502->count = 0; + r->out.info_ctr->ctr.ctr502->array = NULL; return WERR_NOT_SUPPORTED; } @@ -458,7 +448,7 @@ static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALL info[i].name = SHARE_TYPE; info[i].type = SHARE_INFO_STRING; - switch (r->in.info.info2->type) { + switch (r->in.info->info2->type) { case 0x00: info[i].value = talloc_strdup(info, "DISK"); break; @@ -474,16 +464,16 @@ static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALL W_ERROR_HAVE_NO_MEMORY(info[i].value); i++; - if (r->in.info.info2->path && r->in.info.info2->path[0]) { + if (r->in.info->info2->path && r->in.info->info2->path[0]) { info[i].name = SHARE_PATH; info[i].type = SHARE_INFO_STRING; /* Windows will send a path in a form of C:\example\path */ - if (r->in.info.info2->path[1] == ':') { - info[i].value = talloc_strdup(info, &r->in.info.info2->path[2]); + if (r->in.info->info2->path[1] == ':') { + info[i].value = talloc_strdup(info, &r->in.info->info2->path[2]); } else { /* very strange let's try to set as is */ - info[i].value = talloc_strdup(info, r->in.info.info2->path); + info[i].value = talloc_strdup(info, r->in.info->info2->path); } W_ERROR_HAVE_NO_MEMORY(info[i].value); all_string_sub((char *)info[i].value, "\\", "/", 0); @@ -491,19 +481,19 @@ static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALL i++; } - if (r->in.info.info2->comment && r->in.info.info2->comment[0]) { + if (r->in.info->info2->comment && r->in.info->info2->comment[0]) { info[i].name = SHARE_COMMENT; info[i].type = SHARE_INFO_STRING; - info[i].value = talloc_strdup(info, r->in.info.info2->comment); + info[i].value = talloc_strdup(info, r->in.info->info2->comment); W_ERROR_HAVE_NO_MEMORY(info[i].value); i++; } - if (r->in.info.info2->password && r->in.info.info2->password[0]) { + if (r->in.info->info2->password && r->in.info->info2->password[0]) { info[i].name = SHARE_PASSWORD; info[i].type = SHARE_INFO_STRING; - info[i].value = talloc_strdup(info, r->in.info.info2->password); + info[i].value = talloc_strdup(info, r->in.info->info2->password); W_ERROR_HAVE_NO_MEMORY(info[i].value); i++; @@ -512,12 +502,12 @@ static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALL info[i].name = SHARE_MAX_CONNECTIONS; info[i].type = SHARE_INFO_INT; info[i].value = talloc(info, int); - *((int *)info[i].value) = r->in.info.info2->max_users; + *((int *)info[i].value) = r->in.info->info2->max_users; i++; /* TODO: security descriptor */ - nterr = share_create(sctx, r->in.info.info2->name, info, i); + nterr = share_create(sctx, r->in.info->info2->name, info, i); if (!NT_STATUS_IS_OK(nterr)) { return ntstatus_to_werror(nterr); } @@ -556,7 +546,7 @@ static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALL info[i].name = SHARE_TYPE; info[i].type = SHARE_INFO_STRING; - switch (r->in.info.info502->type) { + switch (r->in.info->info502->type) { case 0x00: info[i].value = talloc_strdup(info, "DISK"); break; @@ -572,16 +562,16 @@ static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALL W_ERROR_HAVE_NO_MEMORY(info[i].value); i++; - if (r->in.info.info502->path && r->in.info.info502->path[0]) { + if (r->in.info->info502->path && r->in.info->info502->path[0]) { info[i].name = SHARE_PATH; info[i].type = SHARE_INFO_STRING; /* Windows will send a path in a form of C:\example\path */ - if (r->in.info.info502->path[1] == ':') { - info[i].value = talloc_strdup(info, &r->in.info.info502->path[2]); + if (r->in.info->info502->path[1] == ':') { + info[i].value = talloc_strdup(info, &r->in.info->info502->path[2]); } else { /* very strange let's try to set as is */ - info[i].value = talloc_strdup(info, r->in.info.info502->path); + info[i].value = talloc_strdup(info, r->in.info->info502->path); } W_ERROR_HAVE_NO_MEMORY(info[i].value); all_string_sub((char *)info[i].value, "\\", "/", 0); @@ -589,19 +579,19 @@ static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALL i++; } - if (r->in.info.info502->comment && r->in.info.info502->comment[0]) { + if (r->in.info->info502->comment && r->in.info->info502->comment[0]) { info[i].name = SHARE_COMMENT; info[i].type = SHARE_INFO_STRING; - info[i].value = talloc_strdup(info, r->in.info.info502->comment); + info[i].value = talloc_strdup(info, r->in.info->info502->comment); W_ERROR_HAVE_NO_MEMORY(info[i].value); i++; } - if (r->in.info.info502->password && r->in.info.info502->password[0]) { + if (r->in.info->info502->password && r->in.info->info502->password[0]) { info[i].name = SHARE_PASSWORD; info[i].type = SHARE_INFO_STRING; - info[i].value = talloc_strdup(info, r->in.info.info502->password); + info[i].value = talloc_strdup(info, r->in.info->info502->password); W_ERROR_HAVE_NO_MEMORY(info[i].value); i++; @@ -610,12 +600,12 @@ static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALL info[i].name = SHARE_MAX_CONNECTIONS; info[i].type = SHARE_INFO_INT; info[i].value = talloc(info, int); - *((int *)info[i].value) = r->in.info.info502->max_users; + *((int *)info[i].value) = r->in.info->info502->max_users; i++; /* TODO: security descriptor */ - nterr = share_create(sctx, r->in.info.info502->name, info, i); + nterr = share_create(sctx, r->in.info->info502->name, info, i); if (!NT_STATUS_IS_OK(nterr)) { return ntstatus_to_werror(nterr); } @@ -697,8 +687,7 @@ static WERROR dcesrv_srvsvc_fiel_ShareInfo(struct dcesrv_call_state *dce_call, T info->info502->path = dcesrv_common_get_share_path(mem_ctx, dce_ctx, scfg); W_ERROR_HAVE_NO_MEMORY(info->info502->path); info->info502->password = talloc_strdup(mem_ctx, share_string_option(scfg, SHARE_PASSWORD, NULL)); - info->info502->unknown = dcesrv_common_get_share_unknown(mem_ctx, dce_ctx, scfg); - info->info502->sd = dcesrv_common_get_security_descriptor(mem_ctx, dce_ctx, scfg); + info->info502->sd_buf.sd = dcesrv_common_get_security_descriptor(mem_ctx, dce_ctx, scfg); return WERR_OK; } @@ -727,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 */ @@ -745,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; @@ -758,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; } @@ -775,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; } @@ -783,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: @@ -799,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; } @@ -816,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; } @@ -824,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: @@ -842,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; } @@ -859,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; } @@ -867,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: @@ -885,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; } @@ -902,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; } @@ -910,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: @@ -928,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; } @@ -945,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; } @@ -953,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: @@ -975,7 +965,7 @@ static WERROR dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call, struct share_context *sctx = NULL; struct share_config *scfg = NULL; - ZERO_STRUCT(r->out); + ZERO_STRUCTP(r->out.info); /* TODO: - access check */ @@ -1008,7 +998,7 @@ static WERROR dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call, return status; } - r->out.info.info0 = info.info0; + r->out.info->info0 = info.info0; return WERR_OK; } case 1: @@ -1024,7 +1014,7 @@ static WERROR dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call, return status; } - r->out.info.info1 = info.info1; + r->out.info->info1 = info.info1; return WERR_OK; } case 2: @@ -1042,7 +1032,7 @@ static WERROR dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call, return status; } - r->out.info.info2 = info.info2; + r->out.info->info2 = info.info2; return WERR_OK; } case 501: @@ -1058,7 +1048,7 @@ static WERROR dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call, return status; } - r->out.info.info501 = info.info501; + r->out.info->info501 = info.info501; return WERR_OK; } case 502: @@ -1076,7 +1066,7 @@ static WERROR dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call, return status; } - r->out.info.info502 = info.info502; + r->out.info->info502 = info.info502; return WERR_OK; } case 1005: @@ -1092,7 +1082,7 @@ static WERROR dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call, return status; } - r->out.info.info1005 = info.info1005; + r->out.info->info1005 = info.info1005; return WERR_OK; } default: @@ -1248,7 +1238,7 @@ static WERROR dcesrv_srvsvc_NetShareSetInfo(struct dcesrv_call_state *dce_call, { status = dcesrv_srvsvc_fill_share_info(info, &count, r->in.share_name, r->in.level, - r->in.info.info0->name, + r->in.info->info0->name, NULL, NULL, NULL, @@ -1265,11 +1255,11 @@ static WERROR dcesrv_srvsvc_NetShareSetInfo(struct dcesrv_call_state *dce_call, { status = dcesrv_srvsvc_fill_share_info(info, &count, r->in.share_name, r->in.level, - r->in.info.info1->name, + r->in.info->info1->name, NULL, - r->in.info.info1->comment, + r->in.info->info1->comment, NULL, - r->in.info.info1->type, + r->in.info->info1->type, 0, 0, NULL); @@ -1282,12 +1272,12 @@ static WERROR dcesrv_srvsvc_NetShareSetInfo(struct dcesrv_call_state *dce_call, { status = dcesrv_srvsvc_fill_share_info(info, &count, r->in.share_name, r->in.level, - r->in.info.info2->name, - r->in.info.info2->path, - r->in.info.info2->comment, - r->in.info.info2->password, - r->in.info.info2->type, - r->in.info.info2->max_users, + r->in.info->info2->name, + r->in.info->info2->path, + r->in.info->info2->comment, + r->in.info->info2->password, + r->in.info->info2->type, + r->in.info->info2->max_users, 0, NULL); if (W_ERROR_EQUAL(status, WERR_OK)) { @@ -1299,13 +1289,13 @@ static WERROR dcesrv_srvsvc_NetShareSetInfo(struct dcesrv_call_state *dce_call, { status = dcesrv_srvsvc_fill_share_info(info, &count, r->in.share_name, r->in.level, - r->in.info.info501->name, + r->in.info->info501->name, NULL, - r->in.info.info501->comment, + r->in.info->info501->comment, NULL, - r->in.info.info501->type, + r->in.info->info501->type, 0, - r->in.info.info501->csc_policy, + r->in.info->info501->csc_policy, NULL); if (W_ERROR_EQUAL(status, WERR_OK)) { return status; @@ -1316,14 +1306,14 @@ static WERROR dcesrv_srvsvc_NetShareSetInfo(struct dcesrv_call_state *dce_call, { status = dcesrv_srvsvc_fill_share_info(info, &count, r->in.share_name, r->in.level, - r->in.info.info502->name, - r->in.info.info502->path, - r->in.info.info502->comment, - r->in.info.info502->password, - r->in.info.info502->type, - r->in.info.info502->max_users, + r->in.info->info502->name, + r->in.info->info502->path, + r->in.info->info502->comment, + r->in.info->info502->password, + r->in.info->info502->type, + r->in.info->info502->max_users, 0, - r->in.info.info502->sd); + r->in.info->info502->sd_buf.sd); if (W_ERROR_EQUAL(status, WERR_OK)) { return status; } @@ -1335,7 +1325,7 @@ static WERROR dcesrv_srvsvc_NetShareSetInfo(struct dcesrv_call_state *dce_call, r->in.share_name, r->in.level, NULL, NULL, - r->in.info.info1004->comment, + r->in.info->info1004->comment, NULL, 0, 0, @@ -1396,13 +1386,13 @@ static WERROR dcesrv_srvsvc_NetShareCheck(struct dcesrv_call_state *dce_call, TA const char **names; int count, i; - ZERO_STRUCT(r->out); + *r->out.type = 0; /* TODO: - access check */ if (strcmp("", r->in.device_name) == 0) { - r->out.type = STYPE_IPC; + *r->out.type = STYPE_IPC; return WERR_OK; } @@ -1441,17 +1431,17 @@ static WERROR dcesrv_srvsvc_NetShareCheck(struct dcesrv_call_state *dce_call, TA if (!type) continue; if (strcmp(type, "DISK") == 0) { - r->out.type = STYPE_DISKTREE; + *r->out.type = STYPE_DISKTREE; return WERR_OK; } if (strcmp(type, "IPC") == 0) { - r->out.type = STYPE_IPC; + *r->out.type = STYPE_IPC; return WERR_OK; } if (strcmp(type, "PRINTER") == 0) { - r->out.type = STYPE_PRINTQ; + *r->out.type = STYPE_PRINTQ; return WERR_OK; } } @@ -1469,7 +1459,7 @@ static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TA { struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx; - ZERO_STRUCT(r->out); + ZERO_STRUCTP(r->out.info); switch (r->in.level) { case 100: @@ -1483,7 +1473,7 @@ static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TA info100->server_name = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc); W_ERROR_HAVE_NO_MEMORY(info100->server_name); - r->out.info.info100 = info100; + r->out.info->info100 = info100; return WERR_OK; } case 101: @@ -1503,7 +1493,7 @@ static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TA info101->comment = talloc_strdup(mem_ctx, lp_serverstring(dce_ctx->lp_ctx)); W_ERROR_HAVE_NO_MEMORY(info101->comment); - r->out.info.info101 = info101; + r->out.info->info101 = info101; return WERR_OK; } case 102: @@ -1532,7 +1522,7 @@ static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TA info102->userpath = dcesrv_common_get_userpath(mem_ctx, dce_ctx); W_ERROR_HAVE_NO_MEMORY(info102->userpath); - r->out.info.info102 = info102; + r->out.info->info102 = info102; return WERR_OK; } default: @@ -1559,27 +1549,26 @@ static WERROR dcesrv_srvsvc_NetSrvSetInfo(struct dcesrv_call_state *dce_call, TA static WERROR dcesrv_srvsvc_NetDiskEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct srvsvc_NetDiskEnum *r) { - r->out.info.disks = NULL; - r->out.info.count = 0; - r->out.totalentries = 0; - r->out.resume_handle = NULL; + r->out.info->disks = NULL; + r->out.info->count = 0; + *r->out.totalentries = 0; switch (r->in.level) { case 0: { /* we can safely hardcode the reply and report we have only one disk (C:) */ /* for some reason Windows wants 2 entries with the second being empty */ - r->out.info.disks = talloc_array(mem_ctx, struct srvsvc_NetDiskInfo0, 2); - W_ERROR_HAVE_NO_MEMORY(r->out.info.disks); - r->out.info.count = 2; + r->out.info->disks = talloc_array(mem_ctx, struct srvsvc_NetDiskInfo0, 2); + W_ERROR_HAVE_NO_MEMORY(r->out.info->disks); + r->out.info->count = 2; - r->out.info.disks[0].disk = talloc_strdup(mem_ctx, "C:"); - W_ERROR_HAVE_NO_MEMORY(r->out.info.disks[0].disk); + r->out.info->disks[0].disk = talloc_strdup(mem_ctx, "C:"); + W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[0].disk); - r->out.info.disks[1].disk = talloc_strdup(mem_ctx, ""); - W_ERROR_HAVE_NO_MEMORY(r->out.info.disks[1].disk); + r->out.info->disks[1].disk = talloc_strdup(mem_ctx, ""); + W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[1].disk); - r->out.totalentries = 1; + *r->out.totalentries = 1; r->out.resume_handle = r->in.resume_handle; return WERR_OK; @@ -1618,48 +1607,50 @@ static WERROR dcesrv_srvsvc_NetTransportAdd(struct dcesrv_call_state *dce_call, static WERROR dcesrv_srvsvc_NetTransportEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct srvsvc_NetTransportEnum *r) { - r->out.level = r->in.level; - r->out.totalentries = 0; - r->out.resume_handle = NULL; + r->out.transports->level = r->in.transports->level; + *r->out.totalentries = 0; + if (r->out.resume_handle) { + *r->out.resume_handle = 0; + } - switch (r->in.level) { + switch (r->in.transports->level) { case 0: { - r->out.transports.ctr0 = talloc(mem_ctx, struct srvsvc_NetTransportCtr0); - W_ERROR_HAVE_NO_MEMORY(r->out.transports.ctr0); + r->out.transports->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetTransportCtr0); + W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr0); - r->out.transports.ctr0->count = 0; - r->out.transports.ctr0->array = NULL; + r->out.transports->ctr.ctr0->count = 0; + r->out.transports->ctr.ctr0->array = NULL; return WERR_NOT_SUPPORTED; } case 1: { - r->out.transports.ctr1 = talloc(mem_ctx, struct srvsvc_NetTransportCtr1); - W_ERROR_HAVE_NO_MEMORY(r->out.transports.ctr1); + r->out.transports->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetTransportCtr1); + W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr1); - r->out.transports.ctr1->count = 0; - r->out.transports.ctr1->array = NULL; + r->out.transports->ctr.ctr1->count = 0; + r->out.transports->ctr.ctr1->array = NULL; return WERR_NOT_SUPPORTED; } case 2: { - r->out.transports.ctr2 = talloc(mem_ctx, struct srvsvc_NetTransportCtr2); - W_ERROR_HAVE_NO_MEMORY(r->out.transports.ctr2); + r->out.transports->ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetTransportCtr2); + W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr2); - r->out.transports.ctr2->count = 0; - r->out.transports.ctr2->array = NULL; + r->out.transports->ctr.ctr2->count = 0; + r->out.transports->ctr.ctr2->array = NULL; return WERR_NOT_SUPPORTED; } case 3: { - r->out.transports.ctr3 = talloc(mem_ctx, struct srvsvc_NetTransportCtr3); - W_ERROR_HAVE_NO_MEMORY(r->out.transports.ctr3); + r->out.transports->ctr.ctr3 = talloc(mem_ctx, struct srvsvc_NetTransportCtr3); + W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr3); - r->out.transports.ctr3->count = 0; - r->out.transports.ctr3->array = NULL; + r->out.transports->ctr.ctr3->count = 0; + r->out.transports->ctr.ctr3->array = NULL; return WERR_NOT_SUPPORTED; } @@ -1689,31 +1680,34 @@ static WERROR dcesrv_srvsvc_NetRemoteTOD(struct dcesrv_call_state *dce_call, TAL struct timeval tval; time_t t; struct tm tm; + struct srvsvc_NetRemoteTODInfo *info; - r->out.info = talloc(mem_ctx, struct srvsvc_NetRemoteTODInfo); - W_ERROR_HAVE_NO_MEMORY(r->out.info); + info = talloc(mem_ctx, struct srvsvc_NetRemoteTODInfo); + W_ERROR_HAVE_NO_MEMORY(info); GetTimeOfDay(&tval); t = tval.tv_sec; gmtime_r(&t, &tm); - r->out.info->elapsed = t; + info->elapsed = t; /* TODO: fake the uptime: just return the milliseconds till 0:00:00 today */ - r->out.info->msecs = (tm.tm_hour*60*60*1000) - + (tm.tm_min*60*1000) - + (tm.tm_sec*1000) - + (tval.tv_usec/1000); - r->out.info->hours = tm.tm_hour; - r->out.info->mins = tm.tm_min; - r->out.info->secs = tm.tm_sec; - r->out.info->hunds = tval.tv_usec/10000; - r->out.info->timezone = get_time_zone(t)/60; - r->out.info->tinterval = 310; /* just return the same as windows */ - r->out.info->day = tm.tm_mday; - r->out.info->month = tm.tm_mon + 1; - r->out.info->year = tm.tm_year + 1900; - r->out.info->weekday = tm.tm_wday; + info->msecs = (tm.tm_hour*60*60*1000) + + (tm.tm_min*60*1000) + + (tm.tm_sec*1000) + + (tval.tv_usec/1000); + info->hours = tm.tm_hour; + info->mins = tm.tm_min; + info->secs = tm.tm_sec; + info->hunds = tval.tv_usec/10000; + info->timezone = get_time_zone(t)/60; + info->tinterval = 310; /* just return the same as windows */ + info->day = tm.tm_mday; + info->month = tm.tm_mon + 1; + info->year = tm.tm_year + 1900; + info->weekday = tm.tm_wday; + + *r->out.info = info; return WERR_OK; } @@ -1821,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 */ @@ -1839,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; @@ -1854,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; } @@ -1880,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: @@ -1905,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; } @@ -1931,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: @@ -1958,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; } @@ -1984,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: @@ -2011,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; } @@ -2037,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: @@ -2113,7 +2108,7 @@ static WERROR dcesrv_srvsvc_NetGetFileSecurity(struct dcesrv_call_state *dce_cal sd_buf->sd = io->query_secdesc.out.sd; - r->out.sd_buf = sd_buf; + *r->out.sd_buf = sd_buf; return WERR_OK; } @@ -2145,7 +2140,7 @@ static WERROR dcesrv_srvsvc_NetSetFileSecurity(struct dcesrv_call_state *dce_cal io->set_secdesc.level = RAW_FILEINFO_SEC_DESC; io->set_secdesc.in.file.path = r->in.file; io->set_secdesc.in.secinfo_flags = r->in.securityinformation; - io->set_secdesc.in.sd = r->in.sd_buf.sd; + io->set_secdesc.in.sd = r->in.sd_buf->sd; nt_status = ntvfs_setpathinfo(ntvfs_req, io); if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status); diff --git a/source4/torture/libnet/libnet_share.c b/source4/torture/libnet/libnet_share.c index 6bc5be40a6..e49461357a 100644 --- a/source4/torture/libnet/libnet_share.c +++ b/source4/torture/libnet/libnet_share.c @@ -102,11 +102,11 @@ static void test_displayshares(struct libnet_ListShares s) for (j = 0; j < ARRAY_SIZE(share_types); j++) { if (share_types[j].type == info->type) break; } - d_printf("\t[%d] %s\t%s\n\t %s\n\t [perms=0x%08x, max_usr=%d, cur_usr=%d, path=%s, pass=%s, unknown=0x%08x]\n", + d_printf("\t[%d] %s\t%s\n\t %s\n\t [perms=0x%08x, max_usr=%d, cur_usr=%d, path=%s, pass=%s]\n", i, info->name, share_types[j].desc, info->comment, info->permissions, info->max_users, info->current_users, info->path, - info->password, info->unknown); + info->password); } break; } @@ -170,6 +170,7 @@ static bool test_addshare(struct dcerpc_pipe *svc_pipe, TALLOC_CTX *mem_ctx, con { NTSTATUS status; struct srvsvc_NetShareAdd add; + union srvsvc_NetShareInfo info; struct srvsvc_NetShareInfo2 i; i.name = share; @@ -180,9 +181,11 @@ static bool test_addshare(struct dcerpc_pipe *svc_pipe, TALLOC_CTX *mem_ctx, con i.password = NULL; i.permissions = 0x0; + info.info2 = &i; + add.in.server_unc = host; add.in.level = 2; - add.in.info.info2 = &i; + add.in.info = &info; add.in.parm_error = NULL; status = dcerpc_srvsvc_NetShareAdd(svc_pipe, mem_ctx, &add); 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"); |