s3: smbd: vfs_fruit: Replace code in fruit_fget_nt_acl() with remove_virtual_nfs_aces().
[Samba.git] / source4 / rpc_server / srvsvc / dcesrv_srvsvc.c
bloba6bee0d8ca0b60027e45608b329a65d9679dd24e
1 /*
2 Unix SMB/CIFS implementation.
4 endpoint server for the srvsvc pipe
6 Copyright (C) Stefan (metze) Metzmacher 2004-2006
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "ntvfs/ntvfs.h"
24 #include "rpc_server/dcerpc_server.h"
25 #include "librpc/gen_ndr/ndr_srvsvc.h"
26 #include "rpc_server/common/common.h"
27 #include "rpc_server/common/share.h"
28 #include "auth/auth.h"
29 #include "libcli/security/security.h"
30 #include "system/time.h"
31 #include "rpc_server/srvsvc/proto.h"
32 #include "param/param.h"
34 #define SRVSVC_CHECK_ADMIN_ACCESS do { \
35 struct security_token *t = dce_call->conn->auth_state.session_info->security_token; \
36 if (!security_token_has_builtin_administrators(t) && \
37 !security_token_has_sid(t, &global_sid_Builtin_Server_Operators)) { \
38 return WERR_ACCESS_DENIED; \
39 } \
40 } while (0)
42 /*
43 srvsvc_NetCharDevEnum
45 static WERROR dcesrv_srvsvc_NetCharDevEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
46 struct srvsvc_NetCharDevEnum *r)
48 *r->out.totalentries = 0;
50 switch (r->in.info_ctr->level) {
51 case 0:
52 r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetCharDevCtr0);
53 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0);
55 r->out.info_ctr->ctr.ctr0->count = 0;
56 r->out.info_ctr->ctr.ctr0->array = NULL;
58 return WERR_NOT_SUPPORTED;
60 case 1:
61 r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetCharDevCtr1);
62 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1);
64 r->out.info_ctr->ctr.ctr1->count = 0;
65 r->out.info_ctr->ctr.ctr1->array = NULL;
67 return WERR_NOT_SUPPORTED;
69 default:
70 return WERR_INVALID_LEVEL;
75 /*
76 srvsvc_NetCharDevGetInfo
78 static WERROR dcesrv_srvsvc_NetCharDevGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
79 struct srvsvc_NetCharDevGetInfo *r)
81 ZERO_STRUCTP(r->out.info);
83 switch (r->in.level) {
84 case 0:
86 return WERR_NOT_SUPPORTED;
88 case 1:
90 return WERR_NOT_SUPPORTED;
92 default:
93 return WERR_INVALID_LEVEL;
98 /*
99 srvsvc_NetCharDevControl
101 static WERROR dcesrv_srvsvc_NetCharDevControl(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
102 struct srvsvc_NetCharDevControl *r)
104 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
109 srvsvc_NetCharDevQEnum
111 static WERROR dcesrv_srvsvc_NetCharDevQEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
112 struct srvsvc_NetCharDevQEnum *r)
114 *r->out.totalentries = 0;
116 switch (r->in.info_ctr->level) {
117 case 0:
119 r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetCharDevQCtr0);
120 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0);
122 r->out.info_ctr->ctr.ctr0->count = 0;
123 r->out.info_ctr->ctr.ctr0->array = NULL;
125 return WERR_NOT_SUPPORTED;
127 case 1:
129 r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetCharDevQCtr1);
130 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1);
132 r->out.info_ctr->ctr.ctr1->count = 0;
133 r->out.info_ctr->ctr.ctr1->array = NULL;
135 return WERR_NOT_SUPPORTED;
137 default:
138 return WERR_INVALID_LEVEL;
144 srvsvc_NetCharDevQGetInfo
146 static WERROR dcesrv_srvsvc_NetCharDevQGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
147 struct srvsvc_NetCharDevQGetInfo *r)
149 ZERO_STRUCTP(r->out.info);
151 switch (r->in.level) {
152 case 0:
154 return WERR_NOT_SUPPORTED;
156 case 1:
158 return WERR_NOT_SUPPORTED;
160 default:
161 return WERR_INVALID_LEVEL;
167 srvsvc_NetCharDevQSetInfo
169 static WERROR dcesrv_srvsvc_NetCharDevQSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
170 struct srvsvc_NetCharDevQSetInfo *r)
172 switch (r->in.level) {
173 case 0:
175 if (r->in.parm_error) {
176 r->out.parm_error = r->in.parm_error;
178 return WERR_NOT_SUPPORTED;
180 case 1:
182 if (r->in.parm_error) {
183 r->out.parm_error = r->in.parm_error;
185 return WERR_NOT_SUPPORTED;
187 default:
188 return WERR_INVALID_LEVEL;
194 srvsvc_NetCharDevQPurge
196 static WERROR dcesrv_srvsvc_NetCharDevQPurge(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
197 struct srvsvc_NetCharDevQPurge *r)
199 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
204 srvsvc_NetCharDevQPurgeSelf
206 static WERROR dcesrv_srvsvc_NetCharDevQPurgeSelf(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
207 struct srvsvc_NetCharDevQPurgeSelf *r)
209 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
214 srvsvc_NetConnEnum
216 static WERROR dcesrv_srvsvc_NetConnEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
217 struct srvsvc_NetConnEnum *r)
219 *r->out.totalentries = 0;
221 switch (r->in.info_ctr->level) {
222 case 0:
224 r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetConnCtr0);
225 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0);
227 r->out.info_ctr->ctr.ctr0->count = 0;
228 r->out.info_ctr->ctr.ctr0->array = NULL;
230 return WERR_NOT_SUPPORTED;
232 case 1:
234 r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetConnCtr1);
235 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1);
237 r->out.info_ctr->ctr.ctr1->count = 0;
238 r->out.info_ctr->ctr.ctr1->array = NULL;
240 return WERR_NOT_SUPPORTED;
242 default:
243 return WERR_INVALID_LEVEL;
249 srvsvc_NetFileEnum
251 static WERROR dcesrv_srvsvc_NetFileEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
252 struct srvsvc_NetFileEnum *r)
254 *r->out.totalentries = 0;
256 switch (r->in.info_ctr->level) {
257 case 2:
259 r->out.info_ctr->ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetFileCtr2);
260 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr2);
262 r->out.info_ctr->ctr.ctr2->count = 0;
263 r->out.info_ctr->ctr.ctr2->array = NULL;
265 return WERR_NOT_SUPPORTED;
267 case 3:
269 r->out.info_ctr->ctr.ctr3 = talloc(mem_ctx, struct srvsvc_NetFileCtr3);
270 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr3);
272 r->out.info_ctr->ctr.ctr3->count = 0;
273 r->out.info_ctr->ctr.ctr3->array = NULL;
275 return WERR_NOT_SUPPORTED;
277 default:
278 return WERR_INVALID_LEVEL;
284 srvsvc_NetFileGetInfo
286 static WERROR dcesrv_srvsvc_NetFileGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
287 struct srvsvc_NetFileGetInfo *r)
289 ZERO_STRUCTP(r->out.info);
291 switch (r->in.level) {
292 case 2:
294 return WERR_NOT_SUPPORTED;
296 case 3:
298 return WERR_NOT_SUPPORTED;
300 default:
301 return WERR_INVALID_LEVEL;
307 srvsvc_NetFileClose
309 static WERROR dcesrv_srvsvc_NetFileClose(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
310 struct srvsvc_NetFileClose *r)
312 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
317 srvsvc_NetSessEnum
319 static WERROR dcesrv_srvsvc_NetSessEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
320 struct srvsvc_NetSessEnum *r)
322 *r->out.totalentries = 0;
324 switch (r->in.info_ctr->level) {
325 case 0:
327 r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetSessCtr0);
328 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0);
330 r->out.info_ctr->ctr.ctr0->count = 0;
331 r->out.info_ctr->ctr.ctr0->array = NULL;
333 return WERR_NOT_SUPPORTED;
335 case 1:
337 r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetSessCtr1);
338 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1);
340 r->out.info_ctr->ctr.ctr1->count = 0;
341 r->out.info_ctr->ctr.ctr1->array = NULL;
343 return WERR_NOT_SUPPORTED;
345 case 2:
347 r->out.info_ctr->ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetSessCtr2);
348 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr2);
350 r->out.info_ctr->ctr.ctr2->count = 0;
351 r->out.info_ctr->ctr.ctr2->array = NULL;
353 return WERR_NOT_SUPPORTED;
355 case 10:
357 r->out.info_ctr->ctr.ctr10 = talloc(mem_ctx, struct srvsvc_NetSessCtr10);
358 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr10);
360 r->out.info_ctr->ctr.ctr10->count = 0;
361 r->out.info_ctr->ctr.ctr10->array = NULL;
363 return WERR_NOT_SUPPORTED;
365 case 502:
367 r->out.info_ctr->ctr.ctr502 = talloc(mem_ctx, struct srvsvc_NetSessCtr502);
368 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr502);
370 r->out.info_ctr->ctr.ctr502->count = 0;
371 r->out.info_ctr->ctr.ctr502->array = NULL;
373 return WERR_NOT_SUPPORTED;
375 default:
376 return WERR_INVALID_LEVEL;
382 srvsvc_NetSessDel
384 static WERROR dcesrv_srvsvc_NetSessDel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
385 struct srvsvc_NetSessDel *r)
387 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
392 srvsvc_NetShareAdd
394 static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
395 struct srvsvc_NetShareAdd *r)
397 switch (r->in.level) {
398 case 0:
400 if (r->in.parm_error) {
401 r->out.parm_error = r->in.parm_error;
403 return WERR_NOT_SUPPORTED;
405 case 1:
407 if (r->in.parm_error) {
408 r->out.parm_error = r->in.parm_error;
410 return WERR_NOT_SUPPORTED;
412 case 2:
414 NTSTATUS nterr;
415 struct share_info *info;
416 struct share_context *sctx;
417 unsigned int count = 8;
418 unsigned int i;
420 nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
421 if (!NT_STATUS_IS_OK(nterr)) {
422 return ntstatus_to_werror(nterr);
425 /* there are no more than 8 options in struct srvsvc_NetShareInfo2 */
426 info = talloc_array(mem_ctx, struct share_info, count);
427 W_ERROR_HAVE_NO_MEMORY(info);
429 i = 0;
431 info[i].name = SHARE_TYPE;
432 info[i].type = SHARE_INFO_STRING;
433 switch (r->in.info->info2->type) {
434 case STYPE_DISKTREE:
435 info[i].value = talloc_strdup(info, "DISK");
436 break;
437 case STYPE_PRINTQ:
438 info[i].value = talloc_strdup(info, "PRINTER");
439 break;
440 case STYPE_IPC:
441 info[i].value = talloc_strdup(info, "IPC");
442 break;
443 default:
444 return WERR_INVALID_PARAMETER;
446 W_ERROR_HAVE_NO_MEMORY(info[i].value);
447 i++;
449 if (r->in.info->info2->path && r->in.info->info2->path[0]) {
450 info[i].name = SHARE_PATH;
451 info[i].type = SHARE_INFO_STRING;
453 /* Windows will send a path in a form of C:\example\path */
454 if (r->in.info->info2->path[1] == ':') {
455 info[i].value = talloc_strdup(info, &r->in.info->info2->path[2]);
456 } else {
457 /* very strange let's try to set as is */
458 info[i].value = talloc_strdup(info, r->in.info->info2->path);
460 W_ERROR_HAVE_NO_MEMORY(info[i].value);
461 all_string_sub((char *)info[i].value, "\\", "/", 0);
463 i++;
466 if (r->in.info->info2->comment && r->in.info->info2->comment[0]) {
467 info[i].name = SHARE_COMMENT;
468 info[i].type = SHARE_INFO_STRING;
469 info[i].value = talloc_strdup(info, r->in.info->info2->comment);
470 W_ERROR_HAVE_NO_MEMORY(info[i].value);
472 i++;
475 if (r->in.info->info2->password && r->in.info->info2->password[0]) {
476 info[i].name = SHARE_PASSWORD;
477 info[i].type = SHARE_INFO_STRING;
478 info[i].value = talloc_strdup(info, r->in.info->info2->password);
479 W_ERROR_HAVE_NO_MEMORY(info[i].value);
481 i++;
484 info[i].name = SHARE_MAX_CONNECTIONS;
485 info[i].type = SHARE_INFO_INT;
486 info[i].value = talloc(info, int);
487 *((int *)info[i].value) = r->in.info->info2->max_users;
488 i++;
490 /* TODO: security descriptor */
492 nterr = share_create(sctx, r->in.info->info2->name, info, i);
493 if (!NT_STATUS_IS_OK(nterr)) {
494 return ntstatus_to_werror(nterr);
497 if (r->in.parm_error) {
498 r->out.parm_error = r->in.parm_error;
501 return WERR_OK;
503 case 501:
505 if (r->in.parm_error) {
506 r->out.parm_error = r->in.parm_error;
508 return WERR_NOT_SUPPORTED;
510 case 502:
512 NTSTATUS nterr;
513 struct share_info *info;
514 struct share_context *sctx;
515 unsigned int count = 10;
516 unsigned int i;
518 nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
519 if (!NT_STATUS_IS_OK(nterr)) {
520 return ntstatus_to_werror(nterr);
523 /* there are no more than 10 options in struct srvsvc_NetShareInfo502 */
524 info = talloc_array(mem_ctx, struct share_info, count);
525 W_ERROR_HAVE_NO_MEMORY(info);
527 i = 0;
529 info[i].name = SHARE_TYPE;
530 info[i].type = SHARE_INFO_STRING;
531 switch (r->in.info->info502->type) {
532 case 0x00:
533 info[i].value = talloc_strdup(info, "DISK");
534 break;
535 case 0x01:
536 info[i].value = talloc_strdup(info, "PRINTER");
537 break;
538 case 0x03:
539 info[i].value = talloc_strdup(info, "IPC");
540 break;
541 default:
542 return WERR_INVALID_PARAMETER;
544 W_ERROR_HAVE_NO_MEMORY(info[i].value);
545 i++;
547 if (r->in.info->info502->path && r->in.info->info502->path[0]) {
548 info[i].name = SHARE_PATH;
549 info[i].type = SHARE_INFO_STRING;
551 /* Windows will send a path in a form of C:\example\path */
552 if (r->in.info->info502->path[1] == ':') {
553 info[i].value = talloc_strdup(info, &r->in.info->info502->path[2]);
554 } else {
555 /* very strange let's try to set as is */
556 info[i].value = talloc_strdup(info, r->in.info->info502->path);
558 W_ERROR_HAVE_NO_MEMORY(info[i].value);
559 all_string_sub((char *)info[i].value, "\\", "/", 0);
561 i++;
564 if (r->in.info->info502->comment && r->in.info->info502->comment[0]) {
565 info[i].name = SHARE_COMMENT;
566 info[i].type = SHARE_INFO_STRING;
567 info[i].value = talloc_strdup(info, r->in.info->info502->comment);
568 W_ERROR_HAVE_NO_MEMORY(info[i].value);
570 i++;
573 if (r->in.info->info502->password && r->in.info->info502->password[0]) {
574 info[i].name = SHARE_PASSWORD;
575 info[i].type = SHARE_INFO_STRING;
576 info[i].value = talloc_strdup(info, r->in.info->info502->password);
577 W_ERROR_HAVE_NO_MEMORY(info[i].value);
579 i++;
582 info[i].name = SHARE_MAX_CONNECTIONS;
583 info[i].type = SHARE_INFO_INT;
584 info[i].value = talloc(info, int);
585 *((int *)info[i].value) = r->in.info->info502->max_users;
586 i++;
588 /* TODO: security descriptor */
590 nterr = share_create(sctx, r->in.info->info502->name, info, i);
591 if (!NT_STATUS_IS_OK(nterr)) {
592 return ntstatus_to_werror(nterr);
595 if (r->in.parm_error) {
596 r->out.parm_error = r->in.parm_error;
599 return WERR_OK;
601 default:
602 return WERR_INVALID_LEVEL;
606 static WERROR dcesrv_srvsvc_fiel_ShareInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
607 struct share_config *scfg, uint32_t level,
608 union srvsvc_NetShareInfo *info)
610 struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
612 switch (level) {
613 case 0:
615 info->info0->name = talloc_strdup(mem_ctx, scfg->name);
616 W_ERROR_HAVE_NO_MEMORY(info->info0->name);
618 return WERR_OK;
620 case 1:
622 info->info1->name = talloc_strdup(mem_ctx, scfg->name);
623 W_ERROR_HAVE_NO_MEMORY(info->info1->name);
624 info->info1->type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
625 info->info1->comment = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
626 W_ERROR_HAVE_NO_MEMORY(info->info1->comment);
628 return WERR_OK;
630 case 2:
632 info->info2->name = talloc_strdup(mem_ctx, scfg->name);
633 W_ERROR_HAVE_NO_MEMORY(info->info2->name);
634 info->info2->type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
635 info->info2->comment = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
636 W_ERROR_HAVE_NO_MEMORY(info->info2->comment);
637 info->info2->permissions = dcesrv_common_get_share_permissions(mem_ctx, dce_ctx, scfg);
638 info->info2->max_users = share_int_option(scfg, SHARE_MAX_CONNECTIONS, SHARE_MAX_CONNECTIONS_DEFAULT);
639 info->info2->current_users = dcesrv_common_get_share_current_users(mem_ctx, dce_ctx, scfg);
640 info->info2->path = dcesrv_common_get_share_path(mem_ctx, dce_ctx, scfg);
641 W_ERROR_HAVE_NO_MEMORY(info->info2->path);
642 info->info2->password = share_string_option(mem_ctx, scfg, SHARE_PASSWORD, NULL);
644 return WERR_OK;
646 case 501:
648 info->info501->name = talloc_strdup(mem_ctx, scfg->name);
649 W_ERROR_HAVE_NO_MEMORY(info->info501->name);
650 info->info501->type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
651 info->info501->comment = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
652 W_ERROR_HAVE_NO_MEMORY(info->info501->comment);
653 info->info501->csc_policy = share_int_option(scfg, SHARE_CSC_POLICY, SHARE_CSC_POLICY_DEFAULT);
655 return WERR_OK;
657 case 502:
659 info->info502->name = talloc_strdup(mem_ctx, scfg->name);
660 W_ERROR_HAVE_NO_MEMORY(info->info502->name);
661 info->info502->type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
662 info->info502->comment = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
663 W_ERROR_HAVE_NO_MEMORY(info->info502->comment);
664 info->info502->permissions = dcesrv_common_get_share_permissions(mem_ctx, dce_ctx, scfg);
665 info->info502->max_users = share_int_option(scfg, SHARE_MAX_CONNECTIONS, SHARE_MAX_CONNECTIONS_DEFAULT);
666 info->info502->current_users = dcesrv_common_get_share_current_users(mem_ctx, dce_ctx, scfg);
667 info->info502->path = dcesrv_common_get_share_path(mem_ctx, dce_ctx, scfg);
668 W_ERROR_HAVE_NO_MEMORY(info->info502->path);
669 info->info502->password = share_string_option(mem_ctx, scfg, SHARE_PASSWORD, NULL);
670 info->info502->sd_buf.sd = dcesrv_common_get_security_descriptor(mem_ctx, dce_ctx, scfg);
672 return WERR_OK;
674 case 1005:
676 info->info1005->dfs_flags = dcesrv_common_get_share_dfs_flags(mem_ctx, dce_ctx, scfg);
678 return WERR_OK;
680 default:
681 return WERR_INVALID_LEVEL;
686 srvsvc_NetShareEnumAll
688 static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
689 struct srvsvc_NetShareEnumAll *r)
691 NTSTATUS nterr;
692 int numshares = 0;
693 const char **snames;
694 struct share_context *sctx;
695 struct share_config *scfg;
697 *r->out.totalentries = 0;
699 /* TODO: - paging of results
702 nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
703 if (!NT_STATUS_IS_OK(nterr)) {
704 return ntstatus_to_werror(nterr);
707 nterr = share_list_all(mem_ctx, sctx, &numshares, &snames);
708 if (!NT_STATUS_IS_OK(nterr)) {
709 return ntstatus_to_werror(nterr);
712 switch (r->in.info_ctr->level) {
713 case 0:
715 unsigned int i;
716 struct srvsvc_NetShareCtr0 *ctr0;
718 ctr0 = talloc(mem_ctx, struct srvsvc_NetShareCtr0);
719 W_ERROR_HAVE_NO_MEMORY(ctr0);
721 ctr0->count = numshares;
722 ctr0->array = NULL;
724 if (ctr0->count == 0) {
725 r->out.info_ctr->ctr.ctr0 = ctr0;
726 return WERR_OK;
729 ctr0->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo0, ctr0->count);
730 W_ERROR_HAVE_NO_MEMORY(ctr0->array);
732 for (i = 0; i < ctr0->count; i++) {
733 WERROR status;
734 union srvsvc_NetShareInfo info;
736 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
737 if (!NT_STATUS_IS_OK(nterr)) {
738 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
739 return WERR_GEN_FAILURE;
741 info.info0 = &ctr0->array[i];
742 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
743 if (!W_ERROR_IS_OK(status)) {
744 return status;
746 talloc_free(scfg);
748 talloc_free(snames);
750 r->out.info_ctr->ctr.ctr0 = ctr0;
751 *r->out.totalentries = r->out.info_ctr->ctr.ctr0->count;
752 return WERR_OK;
754 case 1:
756 unsigned int i;
757 struct srvsvc_NetShareCtr1 *ctr1;
759 ctr1 = talloc(mem_ctx, struct srvsvc_NetShareCtr1);
760 W_ERROR_HAVE_NO_MEMORY(ctr1);
762 ctr1->count = numshares;
763 ctr1->array = NULL;
765 if (ctr1->count == 0) {
766 r->out.info_ctr->ctr.ctr1 = ctr1;
767 return WERR_OK;
770 ctr1->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo1, ctr1->count);
771 W_ERROR_HAVE_NO_MEMORY(ctr1->array);
773 for (i=0; i < ctr1->count; i++) {
774 WERROR status;
775 union srvsvc_NetShareInfo info;
777 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
778 if (!NT_STATUS_IS_OK(nterr)) {
779 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
780 return WERR_GEN_FAILURE;
782 info.info1 = &ctr1->array[i];
783 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
784 if (!W_ERROR_IS_OK(status)) {
785 return status;
787 talloc_free(scfg);
789 talloc_free(snames);
791 r->out.info_ctr->ctr.ctr1 = ctr1;
792 *r->out.totalentries = r->out.info_ctr->ctr.ctr1->count;
794 return WERR_OK;
796 case 2:
798 unsigned int i;
799 struct srvsvc_NetShareCtr2 *ctr2;
801 SRVSVC_CHECK_ADMIN_ACCESS;
803 ctr2 = talloc(mem_ctx, struct srvsvc_NetShareCtr2);
804 W_ERROR_HAVE_NO_MEMORY(ctr2);
806 ctr2->count = numshares;
807 ctr2->array = NULL;
809 if (ctr2->count == 0) {
810 r->out.info_ctr->ctr.ctr2 = ctr2;
811 return WERR_OK;
814 ctr2->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo2, ctr2->count);
815 W_ERROR_HAVE_NO_MEMORY(ctr2->array);
817 for (i=0; i < ctr2->count; i++) {
818 WERROR status;
819 union srvsvc_NetShareInfo info;
821 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
822 if (!NT_STATUS_IS_OK(nterr)) {
823 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
824 return WERR_GEN_FAILURE;
826 info.info2 = &ctr2->array[i];
827 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
828 if (!W_ERROR_IS_OK(status)) {
829 return status;
831 talloc_free(scfg);
833 talloc_free(snames);
835 r->out.info_ctr->ctr.ctr2 = ctr2;
836 *r->out.totalentries = r->out.info_ctr->ctr.ctr2->count;
838 return WERR_OK;
840 case 501:
842 unsigned int i;
843 struct srvsvc_NetShareCtr501 *ctr501;
845 SRVSVC_CHECK_ADMIN_ACCESS;
847 ctr501 = talloc(mem_ctx, struct srvsvc_NetShareCtr501);
848 W_ERROR_HAVE_NO_MEMORY(ctr501);
850 ctr501->count = numshares;
851 ctr501->array = NULL;
853 if (ctr501->count == 0) {
854 r->out.info_ctr->ctr.ctr501 = ctr501;
855 return WERR_OK;
858 ctr501->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo501, ctr501->count);
859 W_ERROR_HAVE_NO_MEMORY(ctr501->array);
861 for (i=0; i < ctr501->count; i++) {
862 WERROR status;
863 union srvsvc_NetShareInfo info;
865 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
866 if (!NT_STATUS_IS_OK(nterr)) {
867 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
868 return WERR_GEN_FAILURE;
870 info.info501 = &ctr501->array[i];
871 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
872 if (!W_ERROR_IS_OK(status)) {
873 return status;
875 talloc_free(scfg);
877 talloc_free(snames);
879 r->out.info_ctr->ctr.ctr501 = ctr501;
880 *r->out.totalentries = r->out.info_ctr->ctr.ctr501->count;
882 return WERR_OK;
884 case 502:
886 unsigned int i;
887 struct srvsvc_NetShareCtr502 *ctr502;
889 SRVSVC_CHECK_ADMIN_ACCESS;
891 ctr502 = talloc(mem_ctx, struct srvsvc_NetShareCtr502);
892 W_ERROR_HAVE_NO_MEMORY(ctr502);
894 ctr502->count = numshares;
895 ctr502->array = NULL;
897 if (ctr502->count == 0) {
898 r->out.info_ctr->ctr.ctr502 = ctr502;
899 return WERR_OK;
902 ctr502->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo502, ctr502->count);
903 W_ERROR_HAVE_NO_MEMORY(ctr502->array);
905 for (i=0; i < ctr502->count; i++) {
906 WERROR status;
907 union srvsvc_NetShareInfo info;
909 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
910 if (!NT_STATUS_IS_OK(nterr)) {
911 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
912 return WERR_GEN_FAILURE;
914 info.info502 = &ctr502->array[i];
915 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
916 if (!W_ERROR_IS_OK(status)) {
917 return status;
919 talloc_free(scfg);
921 talloc_free(snames);
923 r->out.info_ctr->ctr.ctr502 = ctr502;
924 *r->out.totalentries = r->out.info_ctr->ctr.ctr502->count;
926 return WERR_OK;
928 default:
929 return WERR_INVALID_LEVEL;
935 srvsvc_NetShareGetInfo
937 static WERROR dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
938 struct srvsvc_NetShareGetInfo *r)
940 NTSTATUS nterr;
941 struct share_context *sctx = NULL;
942 struct share_config *scfg = NULL;
944 ZERO_STRUCTP(r->out.info);
946 /* TODO: - access check
949 if (strcmp("", r->in.share_name) == 0) {
950 return WERR_INVALID_PARAMETER;
953 nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
954 if (!NT_STATUS_IS_OK(nterr)) {
955 return ntstatus_to_werror(nterr);
958 nterr = share_get_config(mem_ctx, sctx, r->in.share_name, &scfg);
959 if (!NT_STATUS_IS_OK(nterr)) {
960 return ntstatus_to_werror(nterr);
963 switch (r->in.level) {
964 case 0:
966 WERROR status;
967 union srvsvc_NetShareInfo info;
969 info.info0 = talloc(mem_ctx, struct srvsvc_NetShareInfo0);
970 W_ERROR_HAVE_NO_MEMORY(info.info0);
972 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
973 if (!W_ERROR_IS_OK(status)) {
974 return status;
977 r->out.info->info0 = info.info0;
978 return WERR_OK;
980 case 1:
982 WERROR status;
983 union srvsvc_NetShareInfo info;
985 info.info1 = talloc(mem_ctx, struct srvsvc_NetShareInfo1);
986 W_ERROR_HAVE_NO_MEMORY(info.info1);
988 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
989 if (!W_ERROR_IS_OK(status)) {
990 return status;
993 r->out.info->info1 = info.info1;
994 return WERR_OK;
996 case 2:
998 WERROR status;
999 union srvsvc_NetShareInfo info;
1001 SRVSVC_CHECK_ADMIN_ACCESS;
1003 info.info2 = talloc(mem_ctx, struct srvsvc_NetShareInfo2);
1004 W_ERROR_HAVE_NO_MEMORY(info.info2);
1006 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
1007 if (!W_ERROR_IS_OK(status)) {
1008 return status;
1011 r->out.info->info2 = info.info2;
1012 return WERR_OK;
1014 case 501:
1016 WERROR status;
1017 union srvsvc_NetShareInfo info;
1019 info.info501 = talloc(mem_ctx, struct srvsvc_NetShareInfo501);
1020 W_ERROR_HAVE_NO_MEMORY(info.info501);
1022 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
1023 if (!W_ERROR_IS_OK(status)) {
1024 return status;
1027 r->out.info->info501 = info.info501;
1028 return WERR_OK;
1030 case 502:
1032 WERROR status;
1033 union srvsvc_NetShareInfo info;
1035 SRVSVC_CHECK_ADMIN_ACCESS;
1037 info.info502 = talloc(mem_ctx, struct srvsvc_NetShareInfo502);
1038 W_ERROR_HAVE_NO_MEMORY(info.info502);
1040 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
1041 if (!W_ERROR_IS_OK(status)) {
1042 return status;
1045 r->out.info->info502 = info.info502;
1046 return WERR_OK;
1048 case 1005:
1050 WERROR status;
1051 union srvsvc_NetShareInfo info;
1053 info.info1005 = talloc(mem_ctx, struct srvsvc_NetShareInfo1005);
1054 W_ERROR_HAVE_NO_MEMORY(info.info1005);
1056 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
1057 if (!W_ERROR_IS_OK(status)) {
1058 return status;
1061 r->out.info->info1005 = info.info1005;
1062 return WERR_OK;
1064 default:
1065 return WERR_INVALID_LEVEL;
1069 static WERROR dcesrv_srvsvc_fill_share_info(struct share_info *info, int *count,
1070 const char *share_name, int level,
1071 const char *name,
1072 const char *path,
1073 const char *comment,
1074 const char *password,
1075 enum srvsvc_ShareType type,
1076 int32_t max_users,
1077 uint32_t csc_policy,
1078 struct security_descriptor *sd)
1080 unsigned int i = 0;
1082 if (level == 501) {
1083 info[i].name = SHARE_CSC_POLICY;
1084 info[i].type = SHARE_INFO_INT;
1085 info[i].value = talloc(info, int);
1086 *((int *)info[i].value) = csc_policy;
1087 i++;
1090 switch(level) {
1092 case 502:
1093 /* TODO: check if unknown is csc_policy */
1095 /* TODO: security descriptor */
1097 case 2:
1098 if (path && path[0]) {
1099 info[i].name = SHARE_PATH;
1100 info[i].type = SHARE_INFO_STRING;
1102 /* Windows will send a path in a form of C:\example\path */
1103 if (path[1] == ':') {
1104 info[i].value = talloc_strdup(info, &path[2]);
1105 } else {
1106 /* very strange let's try to set as is */
1107 info[i].value = talloc_strdup(info, path);
1109 W_ERROR_HAVE_NO_MEMORY(info[i].value);
1110 all_string_sub((char *)info[i].value, "\\", "/", 0);
1112 i++;
1115 if (password && password[0]) {
1116 info[i].name = SHARE_PASSWORD;
1117 info[i].type = SHARE_INFO_STRING;
1118 info[i].value = talloc_strdup(info, password);
1119 W_ERROR_HAVE_NO_MEMORY(info[i].value);
1121 i++;
1124 info[i].name = SHARE_MAX_CONNECTIONS;
1125 info[i].type = SHARE_INFO_INT;
1126 info[i].value = talloc(info, int);
1127 *((int *)info[i].value) = max_users;
1128 i++;
1130 FALL_THROUGH;
1131 case 501:
1132 case 1:
1133 info[i].name = SHARE_TYPE;
1134 info[i].type = SHARE_INFO_STRING;
1135 switch (type) {
1136 case 0x00:
1137 info[i].value = talloc_strdup(info, "DISK");
1138 break;
1139 case 0x01:
1140 info[i].value = talloc_strdup(info, "PRINTER");
1141 break;
1142 case 0x03:
1143 info[i].value = talloc_strdup(info, "IPC");
1144 break;
1145 default:
1146 return WERR_INVALID_PARAMETER;
1148 W_ERROR_HAVE_NO_MEMORY(info[i].value);
1149 i++;
1151 FALL_THROUGH;
1152 case 1004:
1153 if (comment) {
1154 info[i].name = SHARE_COMMENT;
1155 info[i].type = SHARE_INFO_STRING;
1156 info[i].value = talloc_strdup(info, comment);
1157 W_ERROR_HAVE_NO_MEMORY(info[i].value);
1159 i++;
1162 FALL_THROUGH;
1163 case 0:
1164 if (name &&
1165 strcasecmp(share_name, name) != 0) {
1166 info[i].name = SHARE_NAME;
1167 info[i].type = SHARE_INFO_STRING;
1168 info[i].value = talloc_strdup(info, name);
1169 W_ERROR_HAVE_NO_MEMORY(info[i].value);
1170 i++;
1173 break;
1175 default:
1176 return WERR_INVALID_LEVEL;
1179 *count = i;
1181 return WERR_OK;
1185 srvsvc_NetShareSetInfo
1187 static WERROR dcesrv_srvsvc_NetShareSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1188 struct srvsvc_NetShareSetInfo *r)
1190 NTSTATUS nterr;
1191 WERROR status;
1192 struct share_context *sctx = NULL;
1193 struct share_info *info;
1194 int count;
1196 /* TODO: - access check
1199 /* there are no more than 10 options in all struct srvsvc_NetShareInfoXXX */
1200 info = talloc_array(mem_ctx, struct share_info, 10);
1201 W_ERROR_HAVE_NO_MEMORY(info);
1203 if (strcmp("", r->in.share_name) == 0) {
1204 return WERR_INVALID_PARAMETER;
1207 nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
1208 if (!NT_STATUS_IS_OK(nterr)) {
1209 return ntstatus_to_werror(nterr);
1212 switch (r->in.level) {
1213 case 0:
1215 status = dcesrv_srvsvc_fill_share_info(info, &count,
1216 r->in.share_name, r->in.level,
1217 r->in.info->info0->name,
1218 NULL,
1219 NULL,
1220 NULL,
1224 NULL);
1225 if (!W_ERROR_EQUAL(status, WERR_OK)) {
1226 return status;
1228 break;
1230 case 1:
1232 status = dcesrv_srvsvc_fill_share_info(info, &count,
1233 r->in.share_name, r->in.level,
1234 r->in.info->info1->name,
1235 NULL,
1236 r->in.info->info1->comment,
1237 NULL,
1238 r->in.info->info1->type,
1241 NULL);
1242 if (!W_ERROR_EQUAL(status, WERR_OK)) {
1243 return status;
1245 break;
1247 case 2:
1249 status = dcesrv_srvsvc_fill_share_info(info, &count,
1250 r->in.share_name, r->in.level,
1251 r->in.info->info2->name,
1252 r->in.info->info2->path,
1253 r->in.info->info2->comment,
1254 r->in.info->info2->password,
1255 r->in.info->info2->type,
1256 r->in.info->info2->max_users,
1258 NULL);
1259 if (!W_ERROR_EQUAL(status, WERR_OK)) {
1260 return status;
1262 break;
1264 case 501:
1266 status = dcesrv_srvsvc_fill_share_info(info, &count,
1267 r->in.share_name, r->in.level,
1268 r->in.info->info501->name,
1269 NULL,
1270 r->in.info->info501->comment,
1271 NULL,
1272 r->in.info->info501->type,
1274 r->in.info->info501->csc_policy,
1275 NULL);
1276 if (!W_ERROR_EQUAL(status, WERR_OK)) {
1277 return status;
1279 break;
1281 case 502:
1283 status = dcesrv_srvsvc_fill_share_info(info, &count,
1284 r->in.share_name, r->in.level,
1285 r->in.info->info502->name,
1286 r->in.info->info502->path,
1287 r->in.info->info502->comment,
1288 r->in.info->info502->password,
1289 r->in.info->info502->type,
1290 r->in.info->info502->max_users,
1292 r->in.info->info502->sd_buf.sd);
1293 if (!W_ERROR_EQUAL(status, WERR_OK)) {
1294 return status;
1296 break;
1298 case 1004:
1300 status = dcesrv_srvsvc_fill_share_info(info, &count,
1301 r->in.share_name, r->in.level,
1302 NULL,
1303 NULL,
1304 r->in.info->info1004->comment,
1305 NULL,
1309 NULL);
1310 if (!W_ERROR_EQUAL(status, WERR_OK)) {
1311 return status;
1313 break;
1315 case 1005:
1317 /* r->in.info.dfs_flags; */
1319 if (r->in.parm_error) {
1320 r->out.parm_error = r->in.parm_error;
1323 return WERR_OK;
1325 default:
1326 return WERR_INVALID_LEVEL;
1329 nterr = share_set(sctx, r->in.share_name, info, count);
1330 if (!NT_STATUS_IS_OK(nterr)) {
1331 return ntstatus_to_werror(nterr);
1334 if (r->in.parm_error) {
1335 r->out.parm_error = r->in.parm_error;
1338 return WERR_OK;
1343 srvsvc_NetShareDelSticky
1345 static WERROR dcesrv_srvsvc_NetShareDelSticky(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1346 struct srvsvc_NetShareDelSticky *r)
1348 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1353 srvsvc_NetShareCheck
1355 static WERROR dcesrv_srvsvc_NetShareCheck(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1356 struct srvsvc_NetShareCheck *r)
1358 NTSTATUS nterr;
1359 struct share_context *sctx = NULL;
1360 struct share_config *scfg = NULL;
1361 char *device;
1362 const char **names;
1363 int count;
1364 int i;
1366 *r->out.type = 0;
1368 /* TODO: - access check
1371 if (strcmp("", r->in.device_name) == 0) {
1372 *r->out.type = STYPE_IPC;
1373 return WERR_OK;
1376 /* copy the path skipping C:\ */
1377 if (strncasecmp(r->in.device_name, "C:", 2) == 0) {
1378 device = talloc_strdup(mem_ctx, &r->in.device_name[2]);
1379 } else {
1380 /* no chance we have a share that doesn't start with C:\ */
1381 return WERR_NERR_DEVICENOTSHARED;
1383 all_string_sub(device, "\\", "/", 0);
1385 nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
1386 if (!NT_STATUS_IS_OK(nterr)) {
1387 return ntstatus_to_werror(nterr);
1390 nterr = share_list_all(mem_ctx, sctx, &count, &names);
1391 if (!NT_STATUS_IS_OK(nterr)) {
1392 return ntstatus_to_werror(nterr);
1395 for (i = 0; i < count; i++) {
1396 const char *path;
1397 const char *type;
1399 nterr = share_get_config(mem_ctx, sctx, names[i], &scfg);
1400 if (!NT_STATUS_IS_OK(nterr)) {
1401 return ntstatus_to_werror(nterr);
1403 path = share_string_option(mem_ctx, scfg, SHARE_PATH, NULL);
1404 if (!path) continue;
1406 if (strcmp(device, path) == 0) {
1407 type = share_string_option(mem_ctx, scfg, SHARE_TYPE, NULL);
1408 if (!type) continue;
1410 if (strcmp(type, "DISK") == 0) {
1411 *r->out.type = STYPE_DISKTREE;
1412 return WERR_OK;
1415 if (strcmp(type, "IPC") == 0) {
1416 *r->out.type = STYPE_IPC;
1417 return WERR_OK;
1420 if (strcmp(type, "PRINTER") == 0) {
1421 *r->out.type = STYPE_PRINTQ;
1422 return WERR_OK;
1427 return WERR_NERR_DEVICENOTSHARED;
1432 srvsvc_NetSrvGetInfo
1434 static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1435 struct srvsvc_NetSrvGetInfo *r)
1437 struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
1438 struct dcerpc_server_info *server_info = lpcfg_dcerpc_server_info(mem_ctx, dce_ctx->lp_ctx);
1440 ZERO_STRUCTP(r->out.info);
1442 switch (r->in.level) {
1443 case 100:
1445 struct srvsvc_NetSrvInfo100 *info100;
1447 info100 = talloc(mem_ctx, struct srvsvc_NetSrvInfo100);
1448 W_ERROR_HAVE_NO_MEMORY(info100);
1450 info100->platform_id = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
1451 info100->server_name = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
1452 W_ERROR_HAVE_NO_MEMORY(info100->server_name);
1454 r->out.info->info100 = info100;
1455 return WERR_OK;
1457 case 101:
1459 struct srvsvc_NetSrvInfo101 *info101;
1461 info101 = talloc(mem_ctx, struct srvsvc_NetSrvInfo101);
1462 W_ERROR_HAVE_NO_MEMORY(info101);
1464 info101->platform_id = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
1465 info101->server_name = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
1466 W_ERROR_HAVE_NO_MEMORY(info101->server_name);
1468 info101->version_major = server_info->version_major;
1469 info101->version_minor = server_info->version_minor;
1470 info101->server_type = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
1471 info101->comment = lpcfg_server_string(dce_ctx->lp_ctx, mem_ctx);
1472 W_ERROR_HAVE_NO_MEMORY(info101->comment);
1474 r->out.info->info101 = info101;
1475 return WERR_OK;
1477 case 102:
1479 struct srvsvc_NetSrvInfo102 *info102;
1481 info102 = talloc(mem_ctx, struct srvsvc_NetSrvInfo102);
1482 W_ERROR_HAVE_NO_MEMORY(info102);
1484 info102->platform_id = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
1485 info102->server_name = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
1486 W_ERROR_HAVE_NO_MEMORY(info102->server_name);
1488 info102->version_major = server_info->version_major;
1489 info102->version_minor = server_info->version_minor;
1490 info102->server_type = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
1491 info102->comment = lpcfg_server_string(dce_ctx->lp_ctx, mem_ctx);
1492 W_ERROR_HAVE_NO_MEMORY(info102->comment);
1494 info102->users = dcesrv_common_get_users(mem_ctx, dce_ctx);
1495 info102->disc = dcesrv_common_get_disc(mem_ctx, dce_ctx);
1496 info102->hidden = dcesrv_common_get_hidden(mem_ctx, dce_ctx);
1497 info102->announce = dcesrv_common_get_announce(mem_ctx, dce_ctx);
1498 info102->anndelta = dcesrv_common_get_anndelta(mem_ctx, dce_ctx);
1499 info102->licenses = dcesrv_common_get_licenses(mem_ctx, dce_ctx);
1500 info102->userpath = dcesrv_common_get_userpath(mem_ctx, dce_ctx);
1501 W_ERROR_HAVE_NO_MEMORY(info102->userpath);
1503 r->out.info->info102 = info102;
1504 return WERR_OK;
1506 default:
1507 return WERR_INVALID_LEVEL;
1513 srvsvc_NetSrvSetInfo
1515 static WERROR dcesrv_srvsvc_NetSrvSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1516 struct srvsvc_NetSrvSetInfo *r)
1518 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1523 srvsvc_NetDiskEnum
1525 static WERROR dcesrv_srvsvc_NetDiskEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1526 struct srvsvc_NetDiskEnum *r)
1528 r->out.info->disks = NULL;
1529 r->out.info->count = 0;
1530 *r->out.totalentries = 0;
1532 switch (r->in.level) {
1533 case 0:
1535 /* we can safely hardcode the reply and report we have only one disk (C:) */
1536 /* for some reason Windows wants 2 entries with the second being empty */
1537 r->out.info->disks = talloc_array(mem_ctx, struct srvsvc_NetDiskInfo0, 2);
1538 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks);
1539 r->out.info->count = 2;
1541 r->out.info->disks[0].disk = talloc_strdup(mem_ctx, "C:");
1542 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[0].disk);
1544 r->out.info->disks[1].disk = talloc_strdup(mem_ctx, "");
1545 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[1].disk);
1547 *r->out.totalentries = 1;
1548 r->out.resume_handle = r->in.resume_handle;
1550 return WERR_OK;
1552 default:
1553 return WERR_INVALID_LEVEL;
1559 srvsvc_NetServerStatisticsGet
1561 static WERROR dcesrv_srvsvc_NetServerStatisticsGet(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1562 struct srvsvc_NetServerStatisticsGet *r)
1564 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1569 srvsvc_NetTransportAdd
1571 static WERROR dcesrv_srvsvc_NetTransportAdd(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1572 struct srvsvc_NetTransportAdd *r)
1574 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1579 srvsvc_NetTransportEnum
1581 static WERROR dcesrv_srvsvc_NetTransportEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1582 struct srvsvc_NetTransportEnum *r)
1584 r->out.transports->level = r->in.transports->level;
1585 *r->out.totalentries = 0;
1586 if (r->out.resume_handle) {
1587 *r->out.resume_handle = 0;
1590 switch (r->in.transports->level) {
1591 case 0:
1593 r->out.transports->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetTransportCtr0);
1594 W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr0);
1596 r->out.transports->ctr.ctr0->count = 0;
1597 r->out.transports->ctr.ctr0->array = NULL;
1599 return WERR_NOT_SUPPORTED;
1601 case 1:
1603 r->out.transports->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetTransportCtr1);
1604 W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr1);
1606 r->out.transports->ctr.ctr1->count = 0;
1607 r->out.transports->ctr.ctr1->array = NULL;
1609 return WERR_NOT_SUPPORTED;
1611 case 2:
1613 r->out.transports->ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetTransportCtr2);
1614 W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr2);
1616 r->out.transports->ctr.ctr2->count = 0;
1617 r->out.transports->ctr.ctr2->array = NULL;
1619 return WERR_NOT_SUPPORTED;
1621 case 3:
1623 r->out.transports->ctr.ctr3 = talloc(mem_ctx, struct srvsvc_NetTransportCtr3);
1624 W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr3);
1626 r->out.transports->ctr.ctr3->count = 0;
1627 r->out.transports->ctr.ctr3->array = NULL;
1629 return WERR_NOT_SUPPORTED;
1631 default:
1632 return WERR_INVALID_LEVEL;
1637 srvsvc_NetTransportDel
1639 static WERROR dcesrv_srvsvc_NetTransportDel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1640 struct srvsvc_NetTransportDel *r)
1642 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1647 srvsvc_NetRemoteTOD
1649 static WERROR dcesrv_srvsvc_NetRemoteTOD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1650 struct srvsvc_NetRemoteTOD *r)
1652 struct timeval tval;
1653 time_t t;
1654 struct tm tm;
1655 struct srvsvc_NetRemoteTODInfo *info;
1657 info = talloc(mem_ctx, struct srvsvc_NetRemoteTODInfo);
1658 W_ERROR_HAVE_NO_MEMORY(info);
1660 GetTimeOfDay(&tval);
1661 t = tval.tv_sec;
1663 gmtime_r(&t, &tm);
1665 info->elapsed = t;
1666 /* TODO: fake the uptime: just return the milliseconds till 0:00:00 today */
1667 info->msecs = (tm.tm_hour*60*60*1000)
1668 + (tm.tm_min*60*1000)
1669 + (tm.tm_sec*1000)
1670 + (tval.tv_usec/1000);
1671 info->hours = tm.tm_hour;
1672 info->mins = tm.tm_min;
1673 info->secs = tm.tm_sec;
1674 info->hunds = tval.tv_usec/10000;
1675 info->timezone = get_time_zone(t)/60;
1676 info->tinterval = 310; /* just return the same as windows */
1677 info->day = tm.tm_mday;
1678 info->month = tm.tm_mon + 1;
1679 info->year = tm.tm_year + 1900;
1680 info->weekday = tm.tm_wday;
1682 *r->out.info = info;
1684 return WERR_OK;
1688 srvsvc_NetPathType
1690 static WERROR dcesrv_srvsvc_NetPathType(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1691 struct srvsvc_NetPathType *r)
1693 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1698 srvsvc_NetPathCanonicalize
1700 static WERROR dcesrv_srvsvc_NetPathCanonicalize(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1701 struct srvsvc_NetPathCanonicalize *r)
1703 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1708 srvsvc_NetPathCompare
1710 static WERROR dcesrv_srvsvc_NetPathCompare(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1711 struct srvsvc_NetPathCompare *r)
1713 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1718 srvsvc_NetNameValidate
1720 static WERROR dcesrv_srvsvc_NetNameValidate(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1721 struct srvsvc_NetNameValidate *r)
1723 int len;
1725 if ((r->in.flags != 0x0) && (r->in.flags != 0x80000000)) {
1726 return WERR_INVALID_NAME;
1729 switch (r->in.name_type) {
1730 case 1:
1731 case 2:
1732 case 3:
1733 case 4:
1734 case 5:
1735 case 6:
1736 case 7:
1737 case 8:
1738 return WERR_NOT_SUPPORTED;
1740 case 9: /* validate share name */
1742 len = strlen_m(r->in.name);
1743 if ((r->in.flags == 0x0) && (len > 81)) {
1744 return WERR_INVALID_NAME;
1746 if ((r->in.flags == 0x80000000) && (len > 13)) {
1747 return WERR_INVALID_NAME;
1749 if (! dcesrv_common_validate_share_name(mem_ctx, r->in.name)) {
1750 return WERR_INVALID_NAME;
1752 return WERR_OK;
1754 case 10:
1755 case 11:
1756 case 12:
1757 case 13:
1758 return WERR_NOT_SUPPORTED;
1759 default:
1760 return WERR_INVALID_PARAMETER;
1766 srvsvc_NetPRNameCompare
1768 static WERROR dcesrv_srvsvc_NetPRNameCompare(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1769 struct srvsvc_NetPRNameCompare *r)
1771 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1776 srvsvc_NetShareEnum
1778 static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1779 struct srvsvc_NetShareEnum *r)
1781 NTSTATUS nterr;
1782 int numshares = 0;
1783 const char **snames;
1784 struct share_context *sctx;
1785 struct share_config *scfg;
1786 struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
1788 *r->out.totalentries = 0;
1790 /* TODO: - paging of results
1793 nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
1794 if (!NT_STATUS_IS_OK(nterr)) {
1795 return ntstatus_to_werror(nterr);
1798 nterr = share_list_all(mem_ctx, sctx, &numshares, &snames);
1799 if (!NT_STATUS_IS_OK(nterr)) {
1800 return ntstatus_to_werror(nterr);
1803 switch (r->in.info_ctr->level) {
1804 case 0:
1806 unsigned int i, y = 0;
1807 unsigned int count;
1808 struct srvsvc_NetShareCtr0 *ctr0;
1810 ctr0 = talloc(mem_ctx, struct srvsvc_NetShareCtr0);
1811 W_ERROR_HAVE_NO_MEMORY(ctr0);
1813 count = numshares;
1814 ctr0->count = count;
1815 ctr0->array = NULL;
1817 if (ctr0->count == 0) {
1818 r->out.info_ctr->ctr.ctr0 = ctr0;
1819 return WERR_OK;
1822 ctr0->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo0, count);
1823 W_ERROR_HAVE_NO_MEMORY(ctr0->array);
1825 for (i=0; i < count; i++) {
1826 WERROR status;
1827 union srvsvc_NetShareInfo info;
1828 enum srvsvc_ShareType type;
1830 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
1831 if (!NT_STATUS_IS_OK(nterr)) {
1832 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
1833 return WERR_GEN_FAILURE;
1836 type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
1837 if (type & STYPE_HIDDEN) {
1838 ctr0->count--;
1839 talloc_free(scfg);
1840 continue;
1843 info.info0 = &ctr0->array[y];
1844 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
1845 W_ERROR_NOT_OK_RETURN(status);
1846 talloc_free(scfg);
1847 y++;
1849 talloc_free(snames);
1851 r->out.info_ctr->ctr.ctr0 = ctr0;
1852 *r->out.totalentries = r->out.info_ctr->ctr.ctr0->count;
1854 return WERR_OK;
1856 case 1:
1858 unsigned int i, y = 0;
1859 unsigned int count;
1860 struct srvsvc_NetShareCtr1 *ctr1;
1862 ctr1 = talloc(mem_ctx, struct srvsvc_NetShareCtr1);
1863 W_ERROR_HAVE_NO_MEMORY(ctr1);
1865 count = numshares;
1866 ctr1->count = count;
1867 ctr1->array = NULL;
1869 if (ctr1->count == 0) {
1870 r->out.info_ctr->ctr.ctr1 = ctr1;
1871 return WERR_OK;
1874 ctr1->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo1, count);
1875 W_ERROR_HAVE_NO_MEMORY(ctr1->array);
1877 for (i=0; i < count; i++) {
1878 WERROR status;
1879 union srvsvc_NetShareInfo info;
1880 enum srvsvc_ShareType type;
1882 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
1883 if (!NT_STATUS_IS_OK(nterr)) {
1884 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
1885 return WERR_GEN_FAILURE;
1888 type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
1889 if (type & STYPE_HIDDEN) {
1890 ctr1->count--;
1891 talloc_free(scfg);
1892 continue;
1895 info.info1 = &ctr1->array[y];
1896 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
1897 W_ERROR_NOT_OK_RETURN(status);
1898 talloc_free(scfg);
1899 y++;
1901 talloc_free(snames);
1903 r->out.info_ctr->ctr.ctr1 = ctr1;
1904 *r->out.totalentries = r->out.info_ctr->ctr.ctr1->count;
1906 return WERR_OK;
1908 case 2:
1910 unsigned int i, y = 0;
1911 unsigned int count;
1912 struct srvsvc_NetShareCtr2 *ctr2;
1914 SRVSVC_CHECK_ADMIN_ACCESS;
1916 ctr2 = talloc(mem_ctx, struct srvsvc_NetShareCtr2);
1917 W_ERROR_HAVE_NO_MEMORY(ctr2);
1919 count = numshares;
1920 ctr2->count = count;
1921 ctr2->array = NULL;
1923 if (ctr2->count == 0) {
1924 r->out.info_ctr->ctr.ctr2 = ctr2;
1925 return WERR_OK;
1928 ctr2->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo2, count);
1929 W_ERROR_HAVE_NO_MEMORY(ctr2->array);
1931 for (i=0; i < count; i++) {
1932 WERROR status;
1933 union srvsvc_NetShareInfo info;
1934 enum srvsvc_ShareType type;
1936 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
1937 if (!NT_STATUS_IS_OK(nterr)) {
1938 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
1939 return WERR_GEN_FAILURE;
1942 type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
1943 if (type & STYPE_HIDDEN) {
1944 ctr2->count--;
1945 talloc_free(scfg);
1946 continue;
1949 info.info2 = &ctr2->array[y];
1950 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
1951 W_ERROR_NOT_OK_RETURN(status);
1952 talloc_free(scfg);
1953 y++;
1955 talloc_free(snames);
1957 r->out.info_ctr->ctr.ctr2 = ctr2;
1958 *r->out.totalentries = r->out.info_ctr->ctr.ctr2->count;
1960 return WERR_OK;
1962 case 502:
1964 unsigned int i, y = 0;
1965 unsigned int count;
1966 struct srvsvc_NetShareCtr502 *ctr502;
1968 SRVSVC_CHECK_ADMIN_ACCESS;
1970 ctr502 = talloc(mem_ctx, struct srvsvc_NetShareCtr502);
1971 W_ERROR_HAVE_NO_MEMORY(ctr502);
1973 count = numshares;
1974 ctr502->count = count;
1975 ctr502->array = NULL;
1977 if (ctr502->count == 0) {
1978 r->out.info_ctr->ctr.ctr502 = ctr502;
1979 return WERR_OK;
1982 ctr502->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo502, count);
1983 W_ERROR_HAVE_NO_MEMORY(ctr502->array);
1985 for (i=0; i < count; i++) {
1986 WERROR status;
1987 union srvsvc_NetShareInfo info;
1988 enum srvsvc_ShareType type;
1990 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
1991 if (!NT_STATUS_IS_OK(nterr)) {
1992 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
1993 return WERR_GEN_FAILURE;
1996 type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
1997 if (type & STYPE_HIDDEN) {
1998 ctr502->count--;
1999 talloc_free(scfg);
2000 continue;
2003 info.info502 = &ctr502->array[y];
2004 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
2005 W_ERROR_NOT_OK_RETURN(status);
2006 talloc_free(scfg);
2007 y++;
2009 talloc_free(snames);
2011 r->out.info_ctr->ctr.ctr502 = ctr502;
2012 *r->out.totalentries = r->out.info_ctr->ctr.ctr502->count;
2014 return WERR_OK;
2016 default:
2017 return WERR_INVALID_LEVEL;
2023 srvsvc_NetShareDelStart
2025 static WERROR dcesrv_srvsvc_NetShareDelStart(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2026 struct srvsvc_NetShareDelStart *r)
2028 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2033 srvsvc_NetShareDelCommit
2035 static WERROR dcesrv_srvsvc_NetShareDelCommit(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2036 struct srvsvc_NetShareDelCommit *r)
2038 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2043 srvsvc_NetGetFileSecurity
2045 static WERROR dcesrv_srvsvc_NetGetFileSecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2046 struct srvsvc_NetGetFileSecurity *r)
2048 struct sec_desc_buf *sd_buf;
2049 struct ntvfs_context *ntvfs_ctx = NULL;
2050 struct ntvfs_request *ntvfs_req;
2051 union smb_fileinfo *io;
2052 NTSTATUS nt_status;
2054 nt_status = srvsvc_create_ntvfs_context(dce_call, mem_ctx, r->in.share, &ntvfs_ctx);
2055 if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status);
2057 ntvfs_req = ntvfs_request_create(ntvfs_ctx, mem_ctx,
2058 dce_call->conn->auth_state.session_info,
2060 dce_call->time,
2061 NULL, NULL, 0);
2062 W_ERROR_HAVE_NO_MEMORY(ntvfs_req);
2064 sd_buf = talloc(mem_ctx, struct sec_desc_buf);
2065 W_ERROR_HAVE_NO_MEMORY(sd_buf);
2067 io = talloc(mem_ctx, union smb_fileinfo);
2068 W_ERROR_HAVE_NO_MEMORY(io);
2070 io->query_secdesc.level = RAW_FILEINFO_SEC_DESC;
2071 io->query_secdesc.in.file.path = r->in.file;
2072 io->query_secdesc.in.secinfo_flags = r->in.securityinformation;
2074 nt_status = ntvfs_qpathinfo(ntvfs_req, io);
2075 if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status);
2077 sd_buf->sd = io->query_secdesc.out.sd;
2079 *r->out.sd_buf = sd_buf;
2080 return WERR_OK;
2085 srvsvc_NetSetFileSecurity
2087 static WERROR dcesrv_srvsvc_NetSetFileSecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2088 struct srvsvc_NetSetFileSecurity *r)
2090 struct ntvfs_context *ntvfs_ctx;
2091 struct ntvfs_request *ntvfs_req;
2092 union smb_setfileinfo *io;
2093 NTSTATUS nt_status;
2095 nt_status = srvsvc_create_ntvfs_context(dce_call, mem_ctx, r->in.share, &ntvfs_ctx);
2096 if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status);
2098 ntvfs_req = ntvfs_request_create(ntvfs_ctx, mem_ctx,
2099 dce_call->conn->auth_state.session_info,
2101 dce_call->time,
2102 NULL, NULL, 0);
2103 W_ERROR_HAVE_NO_MEMORY(ntvfs_req);
2105 io = talloc(mem_ctx, union smb_setfileinfo);
2106 W_ERROR_HAVE_NO_MEMORY(io);
2108 io->set_secdesc.level = RAW_SFILEINFO_SEC_DESC;
2109 io->set_secdesc.in.file.path = r->in.file;
2110 io->set_secdesc.in.secinfo_flags = r->in.securityinformation;
2111 io->set_secdesc.in.sd = r->in.sd_buf->sd;
2113 nt_status = ntvfs_setpathinfo(ntvfs_req, io);
2114 if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status);
2116 return WERR_OK;
2121 srvsvc_NetServerTransportAddEx
2123 static WERROR dcesrv_srvsvc_NetServerTransportAddEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2124 struct srvsvc_NetServerTransportAddEx *r)
2126 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2131 srvsvc_NetServerSetServiceBitsEx
2133 static WERROR dcesrv_srvsvc_NetServerSetServiceBitsEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2134 struct srvsvc_NetServerSetServiceBitsEx *r)
2136 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2141 srvsvc_NETRDFSGETVERSION
2143 static WERROR dcesrv_srvsvc_NETRDFSGETVERSION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2144 struct srvsvc_NETRDFSGETVERSION *r)
2146 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2151 srvsvc_NETRDFSCREATELOCALPARTITION
2153 static WERROR dcesrv_srvsvc_NETRDFSCREATELOCALPARTITION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2154 struct srvsvc_NETRDFSCREATELOCALPARTITION *r)
2156 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2161 srvsvc_NETRDFSDELETELOCALPARTITION
2163 static WERROR dcesrv_srvsvc_NETRDFSDELETELOCALPARTITION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2164 struct srvsvc_NETRDFSDELETELOCALPARTITION *r)
2166 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2171 srvsvc_NETRDFSSETLOCALVOLUMESTATE
2173 static WERROR dcesrv_srvsvc_NETRDFSSETLOCALVOLUMESTATE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2174 struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *r)
2176 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2181 srvsvc_NETRDFSSETSERVERINFO
2183 static WERROR dcesrv_srvsvc_NETRDFSSETSERVERINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2184 struct srvsvc_NETRDFSSETSERVERINFO *r)
2186 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2191 srvsvc_NETRDFSCREATEEXITPOINT
2193 static WERROR dcesrv_srvsvc_NETRDFSCREATEEXITPOINT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2194 struct srvsvc_NETRDFSCREATEEXITPOINT *r)
2196 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2201 srvsvc_NETRDFSDELETEEXITPOINT
2203 static WERROR dcesrv_srvsvc_NETRDFSDELETEEXITPOINT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2204 struct srvsvc_NETRDFSDELETEEXITPOINT *r)
2206 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2211 srvsvc_NETRDFSMODIFYPREFIX
2213 static WERROR dcesrv_srvsvc_NETRDFSMODIFYPREFIX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2214 struct srvsvc_NETRDFSMODIFYPREFIX *r)
2216 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2221 srvsvc_NETRDFSFIXLOCALVOLUME
2223 static WERROR dcesrv_srvsvc_NETRDFSFIXLOCALVOLUME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2224 struct srvsvc_NETRDFSFIXLOCALVOLUME *r)
2226 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2231 srvsvc_NETRDFSMANAGERREPORTSITEINFO
2233 static WERROR dcesrv_srvsvc_NETRDFSMANAGERREPORTSITEINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2234 struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r)
2236 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2241 srvsvc_NETRSERVERTRANSPORTDELEX
2243 static WERROR dcesrv_srvsvc_NETRSERVERTRANSPORTDELEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2244 struct srvsvc_NETRSERVERTRANSPORTDELEX *r)
2246 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2250 srvsvc_NetShareDel
2252 static WERROR dcesrv_srvsvc_NetShareDel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2253 struct srvsvc_NetShareDel *r)
2255 NTSTATUS nterr;
2256 struct share_context *sctx;
2258 nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
2259 if (!NT_STATUS_IS_OK(nterr)) {
2260 return ntstatus_to_werror(nterr);
2263 nterr = share_remove(sctx, r->in.share_name);
2264 if (!NT_STATUS_IS_OK(nterr)) {
2265 return ntstatus_to_werror(nterr);
2268 return WERR_OK;
2272 srvsvc_NetSetServiceBits
2274 static WERROR dcesrv_srvsvc_NetSetServiceBits(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2275 struct srvsvc_NetSetServiceBits *r)
2277 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2281 srvsvc_NETRPRNAMECANONICALIZE
2283 static WERROR dcesrv_srvsvc_NETRPRNAMECANONICALIZE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2284 struct srvsvc_NETRPRNAMECANONICALIZE *r)
2286 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2289 /* include the generated boilerplate */
2290 #include "librpc/gen_ndr/ndr_srvsvc_s.c"