From b0fb34fd24f5d73cfc2d3aca09379d85b9fb57dd Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 15 Sep 2006 05:18:53 +0000 Subject: r18542: Some late nite work. Now we can add and remove a share from the "Computer Management" console (not yet modify!) usinf share backend = ldb (This used to be commit ae2f6d4a5a372a37b9783a02bb8e7f16588b21f0) --- source4/rpc_server/srvsvc/dcesrv_srvsvc.c | 75 ++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) (limited to 'source4/rpc_server/srvsvc') diff --git a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c index 2464da447a..68ab1498c2 100644 --- a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c +++ b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c @@ -452,10 +452,68 @@ static WERROR srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALLOC_CTX } case 502: { + NTSTATUS nterr; + struct share_info *info; + struct share_context *sctx; + + nterr = share_get_context(mem_ctx, &sctx); + if (!NT_STATUS_IS_OK(nterr)) { + return ntstatus_to_werror(nterr); + } + + info = talloc_zero(mem_ctx, struct share_info); + W_ERROR_HAVE_NO_MEMORY(info); + + info->name = talloc_strdup(info, r->in.info.info502->name); + W_ERROR_HAVE_NO_MEMORY(info->name); + switch (r->in.info.info502->type) { + case 0x00: + info->type = talloc_strdup(mem_ctx, "DISK"); + break; + case 0x01: + info->type = talloc_strdup(mem_ctx, "PRINTER"); + break; + case 0x03: + info->type = talloc_strdup(mem_ctx, "IPC"); + break; + default: + return WERR_INVALID_PARAM; + } + W_ERROR_HAVE_NO_MEMORY(info->type); + + /* Windows will send a path in a form of C:\example\path */ + if (r->in.info.info502->path[1] == ':') { + info->path = talloc_strdup(info, &r->in.info.info502->path[2]); + } else { + info->path = talloc_strdup(info, r->in.info.info502->path); + } + W_ERROR_HAVE_NO_MEMORY(info->path); + all_string_sub(info->path, "\\", "/", 0); + + if (r->in.info.info502->comment && r->in.info.info502->comment[0]) { + info->comment = talloc_strdup(info, r->in.info.info502->comment); + W_ERROR_HAVE_NO_MEMORY(info->comment); + } + + if (r->in.info.info502->password && r->in.info.info502->password[0]) { + info->password = talloc_strdup(info, r->in.info.info502->password); + W_ERROR_HAVE_NO_MEMORY(info->password); + } + + info->max_users = r->in.info.info502->max_users; + /* TODO: security descriptor */ + + + nterr = share_create(sctx, info); + if (!NT_STATUS_IS_OK(nterr)) { + return ntstatus_to_werror(nterr); + } + if (r->in.parm_error) { r->out.parm_error = r->in.parm_error; } - return WERR_NOT_SUPPORTED; + + return WERR_OK; } default: return WERR_UNKNOWN_LEVEL; @@ -1808,7 +1866,20 @@ static WERROR srvsvc_NETRSERVERTRANSPORTDELEX(struct dcesrv_call_state *dce_call static WERROR srvsvc_NetShareDel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct srvsvc_NetShareDel *r) { - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); + NTSTATUS nterr; + struct share_context *sctx; + + nterr = share_get_context(mem_ctx, &sctx); + if (!NT_STATUS_IS_OK(nterr)) { + return ntstatus_to_werror(nterr); + } + + nterr = share_remove(sctx, r->in.share_name); + if (!NT_STATUS_IS_OK(nterr)) { + return ntstatus_to_werror(nterr); + } + + return WERR_OK; } /* -- cgit