VERSION: Disable GIT_SNAPSHOT for the 4.16.2 release.
[Samba.git] / source4 / rpc_server / srvsvc / dcesrv_srvsvc.c
blobd7a22626b53915a2570d14ceda0df2263b668dfa
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 #undef strcasecmp
35 #undef strncasecmp
37 #define SRVSVC_CHECK_ADMIN_ACCESS do { \
38 struct auth_session_info *si = dcesrv_call_session_info(dce_call); \
39 struct security_token *t = si->security_token; \
40 if (!security_token_has_builtin_administrators(t) && \
41 !security_token_has_sid(t, &global_sid_Builtin_Server_Operators)) { \
42 return WERR_ACCESS_DENIED; \
43 } \
44 } while (0)
46 /*
47 srvsvc_NetCharDevEnum
49 static WERROR dcesrv_srvsvc_NetCharDevEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
50 struct srvsvc_NetCharDevEnum *r)
52 *r->out.totalentries = 0;
54 switch (r->in.info_ctr->level) {
55 case 0:
56 r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetCharDevCtr0);
57 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0);
59 r->out.info_ctr->ctr.ctr0->count = 0;
60 r->out.info_ctr->ctr.ctr0->array = NULL;
62 return WERR_NOT_SUPPORTED;
64 case 1:
65 r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetCharDevCtr1);
66 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1);
68 r->out.info_ctr->ctr.ctr1->count = 0;
69 r->out.info_ctr->ctr.ctr1->array = NULL;
71 return WERR_NOT_SUPPORTED;
73 default:
74 return WERR_INVALID_LEVEL;
79 /*
80 srvsvc_NetCharDevGetInfo
82 static WERROR dcesrv_srvsvc_NetCharDevGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
83 struct srvsvc_NetCharDevGetInfo *r)
85 ZERO_STRUCTP(r->out.info);
87 switch (r->in.level) {
88 case 0:
90 return WERR_NOT_SUPPORTED;
92 case 1:
94 return WERR_NOT_SUPPORTED;
96 default:
97 return WERR_INVALID_LEVEL;
103 srvsvc_NetCharDevControl
105 static WERROR dcesrv_srvsvc_NetCharDevControl(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
106 struct srvsvc_NetCharDevControl *r)
108 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
113 srvsvc_NetCharDevQEnum
115 static WERROR dcesrv_srvsvc_NetCharDevQEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
116 struct srvsvc_NetCharDevQEnum *r)
118 *r->out.totalentries = 0;
120 switch (r->in.info_ctr->level) {
121 case 0:
123 r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetCharDevQCtr0);
124 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0);
126 r->out.info_ctr->ctr.ctr0->count = 0;
127 r->out.info_ctr->ctr.ctr0->array = NULL;
129 return WERR_NOT_SUPPORTED;
131 case 1:
133 r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetCharDevQCtr1);
134 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1);
136 r->out.info_ctr->ctr.ctr1->count = 0;
137 r->out.info_ctr->ctr.ctr1->array = NULL;
139 return WERR_NOT_SUPPORTED;
141 default:
142 return WERR_INVALID_LEVEL;
148 srvsvc_NetCharDevQGetInfo
150 static WERROR dcesrv_srvsvc_NetCharDevQGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
151 struct srvsvc_NetCharDevQGetInfo *r)
153 ZERO_STRUCTP(r->out.info);
155 switch (r->in.level) {
156 case 0:
158 return WERR_NOT_SUPPORTED;
160 case 1:
162 return WERR_NOT_SUPPORTED;
164 default:
165 return WERR_INVALID_LEVEL;
171 srvsvc_NetCharDevQSetInfo
173 static WERROR dcesrv_srvsvc_NetCharDevQSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
174 struct srvsvc_NetCharDevQSetInfo *r)
176 switch (r->in.level) {
177 case 0:
179 if (r->in.parm_error) {
180 r->out.parm_error = r->in.parm_error;
182 return WERR_NOT_SUPPORTED;
184 case 1:
186 if (r->in.parm_error) {
187 r->out.parm_error = r->in.parm_error;
189 return WERR_NOT_SUPPORTED;
191 default:
192 return WERR_INVALID_LEVEL;
198 srvsvc_NetCharDevQPurge
200 static WERROR dcesrv_srvsvc_NetCharDevQPurge(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
201 struct srvsvc_NetCharDevQPurge *r)
203 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
208 srvsvc_NetCharDevQPurgeSelf
210 static WERROR dcesrv_srvsvc_NetCharDevQPurgeSelf(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
211 struct srvsvc_NetCharDevQPurgeSelf *r)
213 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
218 srvsvc_NetConnEnum
220 static WERROR dcesrv_srvsvc_NetConnEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
221 struct srvsvc_NetConnEnum *r)
223 *r->out.totalentries = 0;
225 switch (r->in.info_ctr->level) {
226 case 0:
228 r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetConnCtr0);
229 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0);
231 r->out.info_ctr->ctr.ctr0->count = 0;
232 r->out.info_ctr->ctr.ctr0->array = NULL;
234 return WERR_NOT_SUPPORTED;
236 case 1:
238 r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetConnCtr1);
239 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1);
241 r->out.info_ctr->ctr.ctr1->count = 0;
242 r->out.info_ctr->ctr.ctr1->array = NULL;
244 return WERR_NOT_SUPPORTED;
246 default:
247 return WERR_INVALID_LEVEL;
253 srvsvc_NetFileEnum
255 static WERROR dcesrv_srvsvc_NetFileEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
256 struct srvsvc_NetFileEnum *r)
258 *r->out.totalentries = 0;
260 switch (r->in.info_ctr->level) {
261 case 2:
263 r->out.info_ctr->ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetFileCtr2);
264 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr2);
266 r->out.info_ctr->ctr.ctr2->count = 0;
267 r->out.info_ctr->ctr.ctr2->array = NULL;
269 return WERR_NOT_SUPPORTED;
271 case 3:
273 r->out.info_ctr->ctr.ctr3 = talloc(mem_ctx, struct srvsvc_NetFileCtr3);
274 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr3);
276 r->out.info_ctr->ctr.ctr3->count = 0;
277 r->out.info_ctr->ctr.ctr3->array = NULL;
279 return WERR_NOT_SUPPORTED;
281 default:
282 return WERR_INVALID_LEVEL;
288 srvsvc_NetFileGetInfo
290 static WERROR dcesrv_srvsvc_NetFileGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
291 struct srvsvc_NetFileGetInfo *r)
293 ZERO_STRUCTP(r->out.info);
295 switch (r->in.level) {
296 case 2:
298 return WERR_NOT_SUPPORTED;
300 case 3:
302 return WERR_NOT_SUPPORTED;
304 default:
305 return WERR_INVALID_LEVEL;
311 srvsvc_NetFileClose
313 static WERROR dcesrv_srvsvc_NetFileClose(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
314 struct srvsvc_NetFileClose *r)
316 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
321 srvsvc_NetSessEnum
323 static WERROR dcesrv_srvsvc_NetSessEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
324 struct srvsvc_NetSessEnum *r)
326 *r->out.totalentries = 0;
328 switch (r->in.info_ctr->level) {
329 case 0:
331 r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetSessCtr0);
332 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0);
334 r->out.info_ctr->ctr.ctr0->count = 0;
335 r->out.info_ctr->ctr.ctr0->array = NULL;
337 return WERR_NOT_SUPPORTED;
339 case 1:
341 r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetSessCtr1);
342 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1);
344 r->out.info_ctr->ctr.ctr1->count = 0;
345 r->out.info_ctr->ctr.ctr1->array = NULL;
347 return WERR_NOT_SUPPORTED;
349 case 2:
351 r->out.info_ctr->ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetSessCtr2);
352 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr2);
354 r->out.info_ctr->ctr.ctr2->count = 0;
355 r->out.info_ctr->ctr.ctr2->array = NULL;
357 return WERR_NOT_SUPPORTED;
359 case 10:
361 r->out.info_ctr->ctr.ctr10 = talloc(mem_ctx, struct srvsvc_NetSessCtr10);
362 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr10);
364 r->out.info_ctr->ctr.ctr10->count = 0;
365 r->out.info_ctr->ctr.ctr10->array = NULL;
367 return WERR_NOT_SUPPORTED;
369 case 502:
371 r->out.info_ctr->ctr.ctr502 = talloc(mem_ctx, struct srvsvc_NetSessCtr502);
372 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr502);
374 r->out.info_ctr->ctr.ctr502->count = 0;
375 r->out.info_ctr->ctr.ctr502->array = NULL;
377 return WERR_NOT_SUPPORTED;
379 default:
380 return WERR_INVALID_LEVEL;
386 srvsvc_NetSessDel
388 static WERROR dcesrv_srvsvc_NetSessDel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
389 struct srvsvc_NetSessDel *r)
391 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
396 srvsvc_NetShareAdd
398 static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
399 struct srvsvc_NetShareAdd *r)
401 switch (r->in.level) {
402 case 0:
404 if (r->in.parm_error) {
405 r->out.parm_error = r->in.parm_error;
407 return WERR_NOT_SUPPORTED;
409 case 1:
411 if (r->in.parm_error) {
412 r->out.parm_error = r->in.parm_error;
414 return WERR_NOT_SUPPORTED;
416 case 2:
418 NTSTATUS nterr;
419 struct share_info *info;
420 struct share_context *sctx;
421 unsigned int count = 8;
422 unsigned int i;
424 nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
425 if (!NT_STATUS_IS_OK(nterr)) {
426 return ntstatus_to_werror(nterr);
429 /* there are no more than 8 options in struct srvsvc_NetShareInfo2 */
430 info = talloc_array(mem_ctx, struct share_info, count);
431 W_ERROR_HAVE_NO_MEMORY(info);
433 i = 0;
435 info[i].name = SHARE_TYPE;
436 info[i].type = SHARE_INFO_STRING;
437 switch (r->in.info->info2->type) {
438 case STYPE_DISKTREE:
439 info[i].value = talloc_strdup(info, "DISK");
440 break;
441 case STYPE_PRINTQ:
442 info[i].value = talloc_strdup(info, "PRINTER");
443 break;
444 case STYPE_IPC:
445 info[i].value = talloc_strdup(info, "IPC");
446 break;
447 default:
448 return WERR_INVALID_PARAMETER;
450 W_ERROR_HAVE_NO_MEMORY(info[i].value);
451 i++;
453 if (r->in.info->info2->path && r->in.info->info2->path[0]) {
454 info[i].name = SHARE_PATH;
455 info[i].type = SHARE_INFO_STRING;
457 /* Windows will send a path in a form of C:\example\path */
458 if (r->in.info->info2->path[1] == ':') {
459 info[i].value = talloc_strdup(info, &r->in.info->info2->path[2]);
460 } else {
461 /* very strange let's try to set as is */
462 info[i].value = talloc_strdup(info, r->in.info->info2->path);
464 W_ERROR_HAVE_NO_MEMORY(info[i].value);
465 all_string_sub((char *)info[i].value, "\\", "/", 0);
467 i++;
470 if (r->in.info->info2->comment && r->in.info->info2->comment[0]) {
471 info[i].name = SHARE_COMMENT;
472 info[i].type = SHARE_INFO_STRING;
473 info[i].value = talloc_strdup(info, r->in.info->info2->comment);
474 W_ERROR_HAVE_NO_MEMORY(info[i].value);
476 i++;
479 if (r->in.info->info2->password && r->in.info->info2->password[0]) {
480 info[i].name = SHARE_PASSWORD;
481 info[i].type = SHARE_INFO_STRING;
482 info[i].value = talloc_strdup(info, r->in.info->info2->password);
483 W_ERROR_HAVE_NO_MEMORY(info[i].value);
485 i++;
488 info[i].name = SHARE_MAX_CONNECTIONS;
489 info[i].type = SHARE_INFO_INT;
490 info[i].value = talloc(info, int);
491 *((int *)info[i].value) = r->in.info->info2->max_users;
492 i++;
494 /* TODO: security descriptor */
496 nterr = share_create(sctx, r->in.info->info2->name, info, i);
497 if (!NT_STATUS_IS_OK(nterr)) {
498 return ntstatus_to_werror(nterr);
501 if (r->in.parm_error) {
502 r->out.parm_error = r->in.parm_error;
505 return WERR_OK;
507 case 501:
509 if (r->in.parm_error) {
510 r->out.parm_error = r->in.parm_error;
512 return WERR_NOT_SUPPORTED;
514 case 502:
516 NTSTATUS nterr;
517 struct share_info *info;
518 struct share_context *sctx;
519 unsigned int count = 10;
520 unsigned int i;
522 nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
523 if (!NT_STATUS_IS_OK(nterr)) {
524 return ntstatus_to_werror(nterr);
527 /* there are no more than 10 options in struct srvsvc_NetShareInfo502 */
528 info = talloc_array(mem_ctx, struct share_info, count);
529 W_ERROR_HAVE_NO_MEMORY(info);
531 i = 0;
533 info[i].name = SHARE_TYPE;
534 info[i].type = SHARE_INFO_STRING;
535 switch (r->in.info->info502->type) {
536 case 0x00:
537 info[i].value = talloc_strdup(info, "DISK");
538 break;
539 case 0x01:
540 info[i].value = talloc_strdup(info, "PRINTER");
541 break;
542 case 0x03:
543 info[i].value = talloc_strdup(info, "IPC");
544 break;
545 default:
546 return WERR_INVALID_PARAMETER;
548 W_ERROR_HAVE_NO_MEMORY(info[i].value);
549 i++;
551 if (r->in.info->info502->path && r->in.info->info502->path[0]) {
552 info[i].name = SHARE_PATH;
553 info[i].type = SHARE_INFO_STRING;
555 /* Windows will send a path in a form of C:\example\path */
556 if (r->in.info->info502->path[1] == ':') {
557 info[i].value = talloc_strdup(info, &r->in.info->info502->path[2]);
558 } else {
559 /* very strange let's try to set as is */
560 info[i].value = talloc_strdup(info, r->in.info->info502->path);
562 W_ERROR_HAVE_NO_MEMORY(info[i].value);
563 all_string_sub((char *)info[i].value, "\\", "/", 0);
565 i++;
568 if (r->in.info->info502->comment && r->in.info->info502->comment[0]) {
569 info[i].name = SHARE_COMMENT;
570 info[i].type = SHARE_INFO_STRING;
571 info[i].value = talloc_strdup(info, r->in.info->info502->comment);
572 W_ERROR_HAVE_NO_MEMORY(info[i].value);
574 i++;
577 if (r->in.info->info502->password && r->in.info->info502->password[0]) {
578 info[i].name = SHARE_PASSWORD;
579 info[i].type = SHARE_INFO_STRING;
580 info[i].value = talloc_strdup(info, r->in.info->info502->password);
581 W_ERROR_HAVE_NO_MEMORY(info[i].value);
583 i++;
586 info[i].name = SHARE_MAX_CONNECTIONS;
587 info[i].type = SHARE_INFO_INT;
588 info[i].value = talloc(info, int);
589 *((int *)info[i].value) = r->in.info->info502->max_users;
590 i++;
592 /* TODO: security descriptor */
594 nterr = share_create(sctx, r->in.info->info502->name, info, i);
595 if (!NT_STATUS_IS_OK(nterr)) {
596 return ntstatus_to_werror(nterr);
599 if (r->in.parm_error) {
600 r->out.parm_error = r->in.parm_error;
603 return WERR_OK;
605 default:
606 return WERR_INVALID_LEVEL;
610 static WERROR dcesrv_srvsvc_fiel_ShareInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
611 struct share_config *scfg, uint32_t level,
612 union srvsvc_NetShareInfo *info)
614 struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
616 switch (level) {
617 case 0:
619 info->info0->name = talloc_strdup(mem_ctx, scfg->name);
620 W_ERROR_HAVE_NO_MEMORY(info->info0->name);
622 return WERR_OK;
624 case 1:
626 info->info1->name = talloc_strdup(mem_ctx, scfg->name);
627 W_ERROR_HAVE_NO_MEMORY(info->info1->name);
628 info->info1->type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
629 info->info1->comment = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
630 W_ERROR_HAVE_NO_MEMORY(info->info1->comment);
632 return WERR_OK;
634 case 2:
636 info->info2->name = talloc_strdup(mem_ctx, scfg->name);
637 W_ERROR_HAVE_NO_MEMORY(info->info2->name);
638 info->info2->type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
639 info->info2->comment = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
640 W_ERROR_HAVE_NO_MEMORY(info->info2->comment);
641 info->info2->permissions = dcesrv_common_get_share_permissions(mem_ctx, dce_ctx, scfg);
642 info->info2->max_users = share_int_option(scfg, SHARE_MAX_CONNECTIONS, SHARE_MAX_CONNECTIONS_DEFAULT);
643 info->info2->current_users = dcesrv_common_get_share_current_users(mem_ctx, dce_ctx, scfg);
644 info->info2->path = dcesrv_common_get_share_path(mem_ctx, dce_ctx, scfg);
645 W_ERROR_HAVE_NO_MEMORY(info->info2->path);
646 info->info2->password = share_string_option(mem_ctx, scfg, SHARE_PASSWORD, NULL);
648 return WERR_OK;
650 case 501:
652 info->info501->name = talloc_strdup(mem_ctx, scfg->name);
653 W_ERROR_HAVE_NO_MEMORY(info->info501->name);
654 info->info501->type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
655 info->info501->comment = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
656 W_ERROR_HAVE_NO_MEMORY(info->info501->comment);
657 info->info501->csc_policy = share_int_option(scfg, SHARE_CSC_POLICY, SHARE_CSC_POLICY_DEFAULT);
659 return WERR_OK;
661 case 502:
663 info->info502->name = talloc_strdup(mem_ctx, scfg->name);
664 W_ERROR_HAVE_NO_MEMORY(info->info502->name);
665 info->info502->type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
666 info->info502->comment = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
667 W_ERROR_HAVE_NO_MEMORY(info->info502->comment);
668 info->info502->permissions = dcesrv_common_get_share_permissions(mem_ctx, dce_ctx, scfg);
669 info->info502->max_users = share_int_option(scfg, SHARE_MAX_CONNECTIONS, SHARE_MAX_CONNECTIONS_DEFAULT);
670 info->info502->current_users = dcesrv_common_get_share_current_users(mem_ctx, dce_ctx, scfg);
671 info->info502->path = dcesrv_common_get_share_path(mem_ctx, dce_ctx, scfg);
672 W_ERROR_HAVE_NO_MEMORY(info->info502->path);
673 info->info502->password = share_string_option(mem_ctx, scfg, SHARE_PASSWORD, NULL);
674 info->info502->sd_buf.sd = dcesrv_common_get_security_descriptor(mem_ctx, dce_ctx, scfg);
676 return WERR_OK;
678 case 1005:
680 info->info1005->dfs_flags = dcesrv_common_get_share_dfs_flags(mem_ctx, dce_ctx, scfg);
682 return WERR_OK;
684 default:
685 return WERR_INVALID_LEVEL;
690 srvsvc_NetShareEnumAll
692 static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
693 struct srvsvc_NetShareEnumAll *r)
695 NTSTATUS nterr;
696 int numshares = 0;
697 const char **snames;
698 struct share_context *sctx;
699 struct share_config *scfg;
701 *r->out.totalentries = 0;
703 /* TODO: - paging of results
706 nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
707 if (!NT_STATUS_IS_OK(nterr)) {
708 return ntstatus_to_werror(nterr);
711 nterr = share_list_all(mem_ctx, sctx, &numshares, &snames);
712 if (!NT_STATUS_IS_OK(nterr)) {
713 return ntstatus_to_werror(nterr);
716 switch (r->in.info_ctr->level) {
717 case 0:
719 unsigned int i;
720 struct srvsvc_NetShareCtr0 *ctr0;
722 ctr0 = talloc(mem_ctx, struct srvsvc_NetShareCtr0);
723 W_ERROR_HAVE_NO_MEMORY(ctr0);
725 ctr0->count = numshares;
726 ctr0->array = NULL;
728 if (ctr0->count == 0) {
729 r->out.info_ctr->ctr.ctr0 = ctr0;
730 return WERR_OK;
733 ctr0->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo0, ctr0->count);
734 W_ERROR_HAVE_NO_MEMORY(ctr0->array);
736 for (i = 0; i < ctr0->count; i++) {
737 WERROR status;
738 union srvsvc_NetShareInfo info;
740 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
741 if (!NT_STATUS_IS_OK(nterr)) {
742 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
743 return WERR_GEN_FAILURE;
745 info.info0 = &ctr0->array[i];
746 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
747 if (!W_ERROR_IS_OK(status)) {
748 return status;
750 talloc_free(scfg);
752 talloc_free(snames);
754 r->out.info_ctr->ctr.ctr0 = ctr0;
755 *r->out.totalentries = r->out.info_ctr->ctr.ctr0->count;
756 return WERR_OK;
758 case 1:
760 unsigned int i;
761 struct srvsvc_NetShareCtr1 *ctr1;
763 ctr1 = talloc(mem_ctx, struct srvsvc_NetShareCtr1);
764 W_ERROR_HAVE_NO_MEMORY(ctr1);
766 ctr1->count = numshares;
767 ctr1->array = NULL;
769 if (ctr1->count == 0) {
770 r->out.info_ctr->ctr.ctr1 = ctr1;
771 return WERR_OK;
774 ctr1->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo1, ctr1->count);
775 W_ERROR_HAVE_NO_MEMORY(ctr1->array);
777 for (i=0; i < ctr1->count; i++) {
778 WERROR status;
779 union srvsvc_NetShareInfo info;
781 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
782 if (!NT_STATUS_IS_OK(nterr)) {
783 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
784 return WERR_GEN_FAILURE;
786 info.info1 = &ctr1->array[i];
787 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
788 if (!W_ERROR_IS_OK(status)) {
789 return status;
791 talloc_free(scfg);
793 talloc_free(snames);
795 r->out.info_ctr->ctr.ctr1 = ctr1;
796 *r->out.totalentries = r->out.info_ctr->ctr.ctr1->count;
798 return WERR_OK;
800 case 2:
802 unsigned int i;
803 struct srvsvc_NetShareCtr2 *ctr2;
805 SRVSVC_CHECK_ADMIN_ACCESS;
807 ctr2 = talloc(mem_ctx, struct srvsvc_NetShareCtr2);
808 W_ERROR_HAVE_NO_MEMORY(ctr2);
810 ctr2->count = numshares;
811 ctr2->array = NULL;
813 if (ctr2->count == 0) {
814 r->out.info_ctr->ctr.ctr2 = ctr2;
815 return WERR_OK;
818 ctr2->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo2, ctr2->count);
819 W_ERROR_HAVE_NO_MEMORY(ctr2->array);
821 for (i=0; i < ctr2->count; i++) {
822 WERROR status;
823 union srvsvc_NetShareInfo info;
825 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
826 if (!NT_STATUS_IS_OK(nterr)) {
827 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
828 return WERR_GEN_FAILURE;
830 info.info2 = &ctr2->array[i];
831 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
832 if (!W_ERROR_IS_OK(status)) {
833 return status;
835 talloc_free(scfg);
837 talloc_free(snames);
839 r->out.info_ctr->ctr.ctr2 = ctr2;
840 *r->out.totalentries = r->out.info_ctr->ctr.ctr2->count;
842 return WERR_OK;
844 case 501:
846 unsigned int i;
847 struct srvsvc_NetShareCtr501 *ctr501;
849 SRVSVC_CHECK_ADMIN_ACCESS;
851 ctr501 = talloc(mem_ctx, struct srvsvc_NetShareCtr501);
852 W_ERROR_HAVE_NO_MEMORY(ctr501);
854 ctr501->count = numshares;
855 ctr501->array = NULL;
857 if (ctr501->count == 0) {
858 r->out.info_ctr->ctr.ctr501 = ctr501;
859 return WERR_OK;
862 ctr501->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo501, ctr501->count);
863 W_ERROR_HAVE_NO_MEMORY(ctr501->array);
865 for (i=0; i < ctr501->count; i++) {
866 WERROR status;
867 union srvsvc_NetShareInfo info;
869 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
870 if (!NT_STATUS_IS_OK(nterr)) {
871 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
872 return WERR_GEN_FAILURE;
874 info.info501 = &ctr501->array[i];
875 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
876 if (!W_ERROR_IS_OK(status)) {
877 return status;
879 talloc_free(scfg);
881 talloc_free(snames);
883 r->out.info_ctr->ctr.ctr501 = ctr501;
884 *r->out.totalentries = r->out.info_ctr->ctr.ctr501->count;
886 return WERR_OK;
888 case 502:
890 unsigned int i;
891 struct srvsvc_NetShareCtr502 *ctr502;
893 SRVSVC_CHECK_ADMIN_ACCESS;
895 ctr502 = talloc(mem_ctx, struct srvsvc_NetShareCtr502);
896 W_ERROR_HAVE_NO_MEMORY(ctr502);
898 ctr502->count = numshares;
899 ctr502->array = NULL;
901 if (ctr502->count == 0) {
902 r->out.info_ctr->ctr.ctr502 = ctr502;
903 return WERR_OK;
906 ctr502->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo502, ctr502->count);
907 W_ERROR_HAVE_NO_MEMORY(ctr502->array);
909 for (i=0; i < ctr502->count; i++) {
910 WERROR status;
911 union srvsvc_NetShareInfo info;
913 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
914 if (!NT_STATUS_IS_OK(nterr)) {
915 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
916 return WERR_GEN_FAILURE;
918 info.info502 = &ctr502->array[i];
919 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
920 if (!W_ERROR_IS_OK(status)) {
921 return status;
923 talloc_free(scfg);
925 talloc_free(snames);
927 r->out.info_ctr->ctr.ctr502 = ctr502;
928 *r->out.totalentries = r->out.info_ctr->ctr.ctr502->count;
930 return WERR_OK;
932 default:
933 return WERR_INVALID_LEVEL;
939 srvsvc_NetShareGetInfo
941 static WERROR dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
942 struct srvsvc_NetShareGetInfo *r)
944 NTSTATUS nterr;
945 struct share_context *sctx = NULL;
946 struct share_config *scfg = NULL;
948 ZERO_STRUCTP(r->out.info);
950 /* TODO: - access check
953 if (strcmp("", r->in.share_name) == 0) {
954 return WERR_INVALID_PARAMETER;
957 nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
958 if (!NT_STATUS_IS_OK(nterr)) {
959 return ntstatus_to_werror(nterr);
962 nterr = share_get_config(mem_ctx, sctx, r->in.share_name, &scfg);
963 if (!NT_STATUS_IS_OK(nterr)) {
964 return ntstatus_to_werror(nterr);
967 switch (r->in.level) {
968 case 0:
970 WERROR status;
971 union srvsvc_NetShareInfo info;
973 info.info0 = talloc(mem_ctx, struct srvsvc_NetShareInfo0);
974 W_ERROR_HAVE_NO_MEMORY(info.info0);
976 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
977 if (!W_ERROR_IS_OK(status)) {
978 return status;
981 r->out.info->info0 = info.info0;
982 return WERR_OK;
984 case 1:
986 WERROR status;
987 union srvsvc_NetShareInfo info;
989 info.info1 = talloc(mem_ctx, struct srvsvc_NetShareInfo1);
990 W_ERROR_HAVE_NO_MEMORY(info.info1);
992 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
993 if (!W_ERROR_IS_OK(status)) {
994 return status;
997 r->out.info->info1 = info.info1;
998 return WERR_OK;
1000 case 2:
1002 WERROR status;
1003 union srvsvc_NetShareInfo info;
1005 SRVSVC_CHECK_ADMIN_ACCESS;
1007 info.info2 = talloc(mem_ctx, struct srvsvc_NetShareInfo2);
1008 W_ERROR_HAVE_NO_MEMORY(info.info2);
1010 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
1011 if (!W_ERROR_IS_OK(status)) {
1012 return status;
1015 r->out.info->info2 = info.info2;
1016 return WERR_OK;
1018 case 501:
1020 WERROR status;
1021 union srvsvc_NetShareInfo info;
1023 info.info501 = talloc(mem_ctx, struct srvsvc_NetShareInfo501);
1024 W_ERROR_HAVE_NO_MEMORY(info.info501);
1026 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
1027 if (!W_ERROR_IS_OK(status)) {
1028 return status;
1031 r->out.info->info501 = info.info501;
1032 return WERR_OK;
1034 case 502:
1036 WERROR status;
1037 union srvsvc_NetShareInfo info;
1039 SRVSVC_CHECK_ADMIN_ACCESS;
1041 info.info502 = talloc(mem_ctx, struct srvsvc_NetShareInfo502);
1042 W_ERROR_HAVE_NO_MEMORY(info.info502);
1044 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
1045 if (!W_ERROR_IS_OK(status)) {
1046 return status;
1049 r->out.info->info502 = info.info502;
1050 return WERR_OK;
1052 case 1005:
1054 WERROR status;
1055 union srvsvc_NetShareInfo info;
1057 info.info1005 = talloc(mem_ctx, struct srvsvc_NetShareInfo1005);
1058 W_ERROR_HAVE_NO_MEMORY(info.info1005);
1060 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
1061 if (!W_ERROR_IS_OK(status)) {
1062 return status;
1065 r->out.info->info1005 = info.info1005;
1066 return WERR_OK;
1068 default:
1069 return WERR_INVALID_LEVEL;
1073 static WERROR dcesrv_srvsvc_fill_share_info(struct share_info *info, int *count,
1074 const char *share_name, int level,
1075 const char *name,
1076 const char *path,
1077 const char *comment,
1078 const char *password,
1079 enum srvsvc_ShareType type,
1080 int32_t max_users,
1081 uint32_t csc_policy,
1082 struct security_descriptor *sd)
1084 unsigned int i = 0;
1086 if (level == 501) {
1087 info[i].name = SHARE_CSC_POLICY;
1088 info[i].type = SHARE_INFO_INT;
1089 info[i].value = talloc(info, int);
1090 *((int *)info[i].value) = csc_policy;
1091 i++;
1094 switch(level) {
1096 case 502:
1097 /* TODO: check if unknown is csc_policy */
1099 /* TODO: security descriptor */
1101 case 2:
1102 if (path && path[0]) {
1103 info[i].name = SHARE_PATH;
1104 info[i].type = SHARE_INFO_STRING;
1106 /* Windows will send a path in a form of C:\example\path */
1107 if (path[1] == ':') {
1108 info[i].value = talloc_strdup(info, &path[2]);
1109 } else {
1110 /* very strange let's try to set as is */
1111 info[i].value = talloc_strdup(info, path);
1113 W_ERROR_HAVE_NO_MEMORY(info[i].value);
1114 all_string_sub((char *)info[i].value, "\\", "/", 0);
1116 i++;
1119 if (password && password[0]) {
1120 info[i].name = SHARE_PASSWORD;
1121 info[i].type = SHARE_INFO_STRING;
1122 info[i].value = talloc_strdup(info, password);
1123 W_ERROR_HAVE_NO_MEMORY(info[i].value);
1125 i++;
1128 info[i].name = SHARE_MAX_CONNECTIONS;
1129 info[i].type = SHARE_INFO_INT;
1130 info[i].value = talloc(info, int);
1131 *((int *)info[i].value) = max_users;
1132 i++;
1134 FALL_THROUGH;
1135 case 501:
1136 case 1:
1137 info[i].name = SHARE_TYPE;
1138 info[i].type = SHARE_INFO_STRING;
1139 switch (type) {
1140 case 0x00:
1141 info[i].value = talloc_strdup(info, "DISK");
1142 break;
1143 case 0x01:
1144 info[i].value = talloc_strdup(info, "PRINTER");
1145 break;
1146 case 0x03:
1147 info[i].value = talloc_strdup(info, "IPC");
1148 break;
1149 default:
1150 return WERR_INVALID_PARAMETER;
1152 W_ERROR_HAVE_NO_MEMORY(info[i].value);
1153 i++;
1155 FALL_THROUGH;
1156 case 1004:
1157 if (comment) {
1158 info[i].name = SHARE_COMMENT;
1159 info[i].type = SHARE_INFO_STRING;
1160 info[i].value = talloc_strdup(info, comment);
1161 W_ERROR_HAVE_NO_MEMORY(info[i].value);
1163 i++;
1166 FALL_THROUGH;
1167 case 0:
1168 if (name &&
1169 strcasecmp(share_name, name) != 0) {
1170 info[i].name = SHARE_NAME;
1171 info[i].type = SHARE_INFO_STRING;
1172 info[i].value = talloc_strdup(info, name);
1173 W_ERROR_HAVE_NO_MEMORY(info[i].value);
1174 i++;
1177 break;
1179 default:
1180 return WERR_INVALID_LEVEL;
1183 *count = i;
1185 return WERR_OK;
1189 srvsvc_NetShareSetInfo
1191 static WERROR dcesrv_srvsvc_NetShareSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1192 struct srvsvc_NetShareSetInfo *r)
1194 NTSTATUS nterr;
1195 WERROR status;
1196 struct share_context *sctx = NULL;
1197 struct share_info *info;
1198 int count;
1200 /* TODO: - access check
1203 /* there are no more than 10 options in all struct srvsvc_NetShareInfoXXX */
1204 info = talloc_array(mem_ctx, struct share_info, 10);
1205 W_ERROR_HAVE_NO_MEMORY(info);
1207 if (strcmp("", r->in.share_name) == 0) {
1208 return WERR_INVALID_PARAMETER;
1211 nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
1212 if (!NT_STATUS_IS_OK(nterr)) {
1213 return ntstatus_to_werror(nterr);
1216 switch (r->in.level) {
1217 case 0:
1219 status = dcesrv_srvsvc_fill_share_info(info, &count,
1220 r->in.share_name, r->in.level,
1221 r->in.info->info0->name,
1222 NULL,
1223 NULL,
1224 NULL,
1228 NULL);
1229 if (!W_ERROR_EQUAL(status, WERR_OK)) {
1230 return status;
1232 break;
1234 case 1:
1236 status = dcesrv_srvsvc_fill_share_info(info, &count,
1237 r->in.share_name, r->in.level,
1238 r->in.info->info1->name,
1239 NULL,
1240 r->in.info->info1->comment,
1241 NULL,
1242 r->in.info->info1->type,
1245 NULL);
1246 if (!W_ERROR_EQUAL(status, WERR_OK)) {
1247 return status;
1249 break;
1251 case 2:
1253 status = dcesrv_srvsvc_fill_share_info(info, &count,
1254 r->in.share_name, r->in.level,
1255 r->in.info->info2->name,
1256 r->in.info->info2->path,
1257 r->in.info->info2->comment,
1258 r->in.info->info2->password,
1259 r->in.info->info2->type,
1260 r->in.info->info2->max_users,
1262 NULL);
1263 if (!W_ERROR_EQUAL(status, WERR_OK)) {
1264 return status;
1266 break;
1268 case 501:
1270 status = dcesrv_srvsvc_fill_share_info(info, &count,
1271 r->in.share_name, r->in.level,
1272 r->in.info->info501->name,
1273 NULL,
1274 r->in.info->info501->comment,
1275 NULL,
1276 r->in.info->info501->type,
1278 r->in.info->info501->csc_policy,
1279 NULL);
1280 if (!W_ERROR_EQUAL(status, WERR_OK)) {
1281 return status;
1283 break;
1285 case 502:
1287 status = dcesrv_srvsvc_fill_share_info(info, &count,
1288 r->in.share_name, r->in.level,
1289 r->in.info->info502->name,
1290 r->in.info->info502->path,
1291 r->in.info->info502->comment,
1292 r->in.info->info502->password,
1293 r->in.info->info502->type,
1294 r->in.info->info502->max_users,
1296 r->in.info->info502->sd_buf.sd);
1297 if (!W_ERROR_EQUAL(status, WERR_OK)) {
1298 return status;
1300 break;
1302 case 1004:
1304 status = dcesrv_srvsvc_fill_share_info(info, &count,
1305 r->in.share_name, r->in.level,
1306 NULL,
1307 NULL,
1308 r->in.info->info1004->comment,
1309 NULL,
1313 NULL);
1314 if (!W_ERROR_EQUAL(status, WERR_OK)) {
1315 return status;
1317 break;
1319 case 1005:
1321 /* r->in.info.dfs_flags; */
1323 if (r->in.parm_error) {
1324 r->out.parm_error = r->in.parm_error;
1327 return WERR_OK;
1329 default:
1330 return WERR_INVALID_LEVEL;
1333 nterr = share_set(sctx, r->in.share_name, info, count);
1334 if (!NT_STATUS_IS_OK(nterr)) {
1335 return ntstatus_to_werror(nterr);
1338 if (r->in.parm_error) {
1339 r->out.parm_error = r->in.parm_error;
1342 return WERR_OK;
1347 srvsvc_NetShareDelSticky
1349 static WERROR dcesrv_srvsvc_NetShareDelSticky(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1350 struct srvsvc_NetShareDelSticky *r)
1352 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1357 srvsvc_NetShareCheck
1359 static WERROR dcesrv_srvsvc_NetShareCheck(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1360 struct srvsvc_NetShareCheck *r)
1362 NTSTATUS nterr;
1363 struct share_context *sctx = NULL;
1364 struct share_config *scfg = NULL;
1365 char *device;
1366 const char **names;
1367 int count;
1368 int i;
1370 *r->out.type = 0;
1372 /* TODO: - access check
1375 if (strcmp("", r->in.device_name) == 0) {
1376 *r->out.type = STYPE_IPC;
1377 return WERR_OK;
1380 /* copy the path skipping C:\ */
1381 if (strncasecmp(r->in.device_name, "C:", 2) == 0) {
1382 device = talloc_strdup(mem_ctx, &r->in.device_name[2]);
1383 } else {
1384 /* no chance we have a share that doesn't start with C:\ */
1385 return WERR_NERR_DEVICENOTSHARED;
1387 all_string_sub(device, "\\", "/", 0);
1389 nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
1390 if (!NT_STATUS_IS_OK(nterr)) {
1391 return ntstatus_to_werror(nterr);
1394 nterr = share_list_all(mem_ctx, sctx, &count, &names);
1395 if (!NT_STATUS_IS_OK(nterr)) {
1396 return ntstatus_to_werror(nterr);
1399 for (i = 0; i < count; i++) {
1400 const char *path;
1401 const char *type;
1403 nterr = share_get_config(mem_ctx, sctx, names[i], &scfg);
1404 if (!NT_STATUS_IS_OK(nterr)) {
1405 return ntstatus_to_werror(nterr);
1407 path = share_string_option(mem_ctx, scfg, SHARE_PATH, NULL);
1408 if (!path) continue;
1410 if (strcmp(device, path) == 0) {
1411 type = share_string_option(mem_ctx, scfg, SHARE_TYPE, NULL);
1412 if (!type) continue;
1414 if (strcmp(type, "DISK") == 0) {
1415 *r->out.type = STYPE_DISKTREE;
1416 return WERR_OK;
1419 if (strcmp(type, "IPC") == 0) {
1420 *r->out.type = STYPE_IPC;
1421 return WERR_OK;
1424 if (strcmp(type, "PRINTER") == 0) {
1425 *r->out.type = STYPE_PRINTQ;
1426 return WERR_OK;
1431 return WERR_NERR_DEVICENOTSHARED;
1436 srvsvc_NetSrvGetInfo
1438 static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1439 struct srvsvc_NetSrvGetInfo *r)
1441 struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
1442 struct dcerpc_server_info *server_info = lpcfg_dcerpc_server_info(mem_ctx, dce_ctx->lp_ctx);
1443 const struct loadparm_substitution *lp_sub =
1444 lpcfg_noop_substitution();
1446 ZERO_STRUCTP(r->out.info);
1448 switch (r->in.level) {
1449 case 100:
1451 struct srvsvc_NetSrvInfo100 *info100;
1453 info100 = talloc(mem_ctx, struct srvsvc_NetSrvInfo100);
1454 W_ERROR_HAVE_NO_MEMORY(info100);
1456 info100->platform_id = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
1457 info100->server_name = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
1458 W_ERROR_HAVE_NO_MEMORY(info100->server_name);
1460 r->out.info->info100 = info100;
1461 return WERR_OK;
1463 case 101:
1465 struct srvsvc_NetSrvInfo101 *info101;
1467 info101 = talloc(mem_ctx, struct srvsvc_NetSrvInfo101);
1468 W_ERROR_HAVE_NO_MEMORY(info101);
1470 info101->platform_id = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
1471 info101->server_name = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
1472 W_ERROR_HAVE_NO_MEMORY(info101->server_name);
1474 info101->version_major = server_info->version_major;
1475 info101->version_minor = server_info->version_minor;
1476 info101->server_type = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
1477 info101->comment = lpcfg_server_string(dce_ctx->lp_ctx, lp_sub, mem_ctx);
1478 W_ERROR_HAVE_NO_MEMORY(info101->comment);
1480 r->out.info->info101 = info101;
1481 return WERR_OK;
1483 case 102:
1485 struct srvsvc_NetSrvInfo102 *info102;
1487 info102 = talloc(mem_ctx, struct srvsvc_NetSrvInfo102);
1488 W_ERROR_HAVE_NO_MEMORY(info102);
1490 info102->platform_id = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
1491 info102->server_name = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
1492 W_ERROR_HAVE_NO_MEMORY(info102->server_name);
1494 info102->version_major = server_info->version_major;
1495 info102->version_minor = server_info->version_minor;
1496 info102->server_type = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
1497 info102->comment = lpcfg_server_string(dce_ctx->lp_ctx, lp_sub, mem_ctx);
1498 W_ERROR_HAVE_NO_MEMORY(info102->comment);
1500 info102->users = dcesrv_common_get_users(mem_ctx, dce_ctx);
1501 info102->disc = dcesrv_common_get_disc(mem_ctx, dce_ctx);
1502 info102->hidden = dcesrv_common_get_hidden(mem_ctx, dce_ctx);
1503 info102->announce = dcesrv_common_get_announce(mem_ctx, dce_ctx);
1504 info102->anndelta = dcesrv_common_get_anndelta(mem_ctx, dce_ctx);
1505 info102->licenses = dcesrv_common_get_licenses(mem_ctx, dce_ctx);
1506 info102->userpath = dcesrv_common_get_userpath(mem_ctx, dce_ctx);
1507 W_ERROR_HAVE_NO_MEMORY(info102->userpath);
1509 r->out.info->info102 = info102;
1510 return WERR_OK;
1512 default:
1513 return WERR_INVALID_LEVEL;
1519 srvsvc_NetSrvSetInfo
1521 static WERROR dcesrv_srvsvc_NetSrvSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1522 struct srvsvc_NetSrvSetInfo *r)
1524 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1529 srvsvc_NetDiskEnum
1531 static WERROR dcesrv_srvsvc_NetDiskEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1532 struct srvsvc_NetDiskEnum *r)
1534 r->out.info->disks = NULL;
1535 r->out.info->count = 0;
1536 *r->out.totalentries = 0;
1538 switch (r->in.level) {
1539 case 0:
1541 /* we can safely hardcode the reply and report we have only one disk (C:) */
1542 /* for some reason Windows wants 2 entries with the second being empty */
1543 r->out.info->disks = talloc_array(mem_ctx, struct srvsvc_NetDiskInfo0, 2);
1544 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks);
1545 r->out.info->count = 2;
1547 r->out.info->disks[0].disk = talloc_strdup(mem_ctx, "C:");
1548 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[0].disk);
1550 r->out.info->disks[1].disk = talloc_strdup(mem_ctx, "");
1551 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[1].disk);
1553 *r->out.totalentries = 1;
1554 r->out.resume_handle = r->in.resume_handle;
1556 return WERR_OK;
1558 default:
1559 return WERR_INVALID_LEVEL;
1565 srvsvc_NetServerStatisticsGet
1567 static WERROR dcesrv_srvsvc_NetServerStatisticsGet(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1568 struct srvsvc_NetServerStatisticsGet *r)
1570 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1575 srvsvc_NetTransportAdd
1577 static WERROR dcesrv_srvsvc_NetTransportAdd(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1578 struct srvsvc_NetTransportAdd *r)
1580 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1585 srvsvc_NetTransportEnum
1587 static WERROR dcesrv_srvsvc_NetTransportEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1588 struct srvsvc_NetTransportEnum *r)
1590 r->out.transports->level = r->in.transports->level;
1591 *r->out.totalentries = 0;
1592 if (r->out.resume_handle) {
1593 *r->out.resume_handle = 0;
1596 switch (r->in.transports->level) {
1597 case 0:
1599 r->out.transports->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetTransportCtr0);
1600 W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr0);
1602 r->out.transports->ctr.ctr0->count = 0;
1603 r->out.transports->ctr.ctr0->array = NULL;
1605 return WERR_NOT_SUPPORTED;
1607 case 1:
1609 r->out.transports->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetTransportCtr1);
1610 W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr1);
1612 r->out.transports->ctr.ctr1->count = 0;
1613 r->out.transports->ctr.ctr1->array = NULL;
1615 return WERR_NOT_SUPPORTED;
1617 case 2:
1619 r->out.transports->ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetTransportCtr2);
1620 W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr2);
1622 r->out.transports->ctr.ctr2->count = 0;
1623 r->out.transports->ctr.ctr2->array = NULL;
1625 return WERR_NOT_SUPPORTED;
1627 case 3:
1629 r->out.transports->ctr.ctr3 = talloc(mem_ctx, struct srvsvc_NetTransportCtr3);
1630 W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr3);
1632 r->out.transports->ctr.ctr3->count = 0;
1633 r->out.transports->ctr.ctr3->array = NULL;
1635 return WERR_NOT_SUPPORTED;
1637 default:
1638 return WERR_INVALID_LEVEL;
1643 srvsvc_NetTransportDel
1645 static WERROR dcesrv_srvsvc_NetTransportDel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1646 struct srvsvc_NetTransportDel *r)
1648 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1653 srvsvc_NetRemoteTOD
1655 static WERROR dcesrv_srvsvc_NetRemoteTOD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1656 struct srvsvc_NetRemoteTOD *r)
1658 struct timeval tval;
1659 time_t t;
1660 struct tm tm;
1661 struct srvsvc_NetRemoteTODInfo *info;
1663 info = talloc(mem_ctx, struct srvsvc_NetRemoteTODInfo);
1664 W_ERROR_HAVE_NO_MEMORY(info);
1666 GetTimeOfDay(&tval);
1667 t = tval.tv_sec;
1669 gmtime_r(&t, &tm);
1671 info->elapsed = t;
1672 /* TODO: fake the uptime: just return the milliseconds till 0:00:00 today */
1673 info->msecs = (tm.tm_hour*60*60*1000)
1674 + (tm.tm_min*60*1000)
1675 + (tm.tm_sec*1000)
1676 + (tval.tv_usec/1000);
1677 info->hours = tm.tm_hour;
1678 info->mins = tm.tm_min;
1679 info->secs = tm.tm_sec;
1680 info->hunds = tval.tv_usec/10000;
1681 info->timezone = get_time_zone(t)/60;
1682 info->tinterval = 310; /* just return the same as windows */
1683 info->day = tm.tm_mday;
1684 info->month = tm.tm_mon + 1;
1685 info->year = tm.tm_year + 1900;
1686 info->weekday = tm.tm_wday;
1688 *r->out.info = info;
1690 return WERR_OK;
1694 srvsvc_NetPathType
1696 static WERROR dcesrv_srvsvc_NetPathType(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1697 struct srvsvc_NetPathType *r)
1699 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1704 srvsvc_NetPathCanonicalize
1706 static WERROR dcesrv_srvsvc_NetPathCanonicalize(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1707 struct srvsvc_NetPathCanonicalize *r)
1709 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1714 srvsvc_NetPathCompare
1716 static WERROR dcesrv_srvsvc_NetPathCompare(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1717 struct srvsvc_NetPathCompare *r)
1719 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1724 srvsvc_NetNameValidate
1726 static WERROR dcesrv_srvsvc_NetNameValidate(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1727 struct srvsvc_NetNameValidate *r)
1729 int len;
1731 if ((r->in.flags != 0x0) && (r->in.flags != 0x80000000)) {
1732 return WERR_INVALID_NAME;
1735 switch (r->in.name_type) {
1736 case 1:
1737 case 2:
1738 case 3:
1739 case 4:
1740 case 5:
1741 case 6:
1742 case 7:
1743 case 8:
1744 return WERR_NOT_SUPPORTED;
1746 case 9: /* validate share name */
1748 len = strlen_m(r->in.name);
1749 if ((r->in.flags == 0x0) && (len > 81)) {
1750 return WERR_INVALID_NAME;
1752 if ((r->in.flags == 0x80000000) && (len > 13)) {
1753 return WERR_INVALID_NAME;
1755 if (! dcesrv_common_validate_share_name(mem_ctx, r->in.name)) {
1756 return WERR_INVALID_NAME;
1758 return WERR_OK;
1760 case 10:
1761 case 11:
1762 case 12:
1763 case 13:
1764 return WERR_NOT_SUPPORTED;
1765 default:
1766 return WERR_INVALID_PARAMETER;
1772 srvsvc_NetPRNameCompare
1774 static WERROR dcesrv_srvsvc_NetPRNameCompare(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1775 struct srvsvc_NetPRNameCompare *r)
1777 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1782 srvsvc_NetShareEnum
1784 static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1785 struct srvsvc_NetShareEnum *r)
1787 NTSTATUS nterr;
1788 int numshares = 0;
1789 const char **snames;
1790 struct share_context *sctx;
1791 struct share_config *scfg;
1792 struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
1794 *r->out.totalentries = 0;
1796 /* TODO: - paging of results
1799 nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
1800 if (!NT_STATUS_IS_OK(nterr)) {
1801 return ntstatus_to_werror(nterr);
1804 nterr = share_list_all(mem_ctx, sctx, &numshares, &snames);
1805 if (!NT_STATUS_IS_OK(nterr)) {
1806 return ntstatus_to_werror(nterr);
1809 switch (r->in.info_ctr->level) {
1810 case 0:
1812 unsigned int i, y = 0;
1813 unsigned int count;
1814 struct srvsvc_NetShareCtr0 *ctr0;
1816 ctr0 = talloc(mem_ctx, struct srvsvc_NetShareCtr0);
1817 W_ERROR_HAVE_NO_MEMORY(ctr0);
1819 count = numshares;
1820 ctr0->count = count;
1821 ctr0->array = NULL;
1823 if (ctr0->count == 0) {
1824 r->out.info_ctr->ctr.ctr0 = ctr0;
1825 return WERR_OK;
1828 ctr0->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo0, count);
1829 W_ERROR_HAVE_NO_MEMORY(ctr0->array);
1831 for (i=0; i < count; i++) {
1832 WERROR status;
1833 union srvsvc_NetShareInfo info;
1834 enum srvsvc_ShareType type;
1836 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
1837 if (!NT_STATUS_IS_OK(nterr)) {
1838 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
1839 return WERR_GEN_FAILURE;
1842 type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
1843 if (type & STYPE_HIDDEN) {
1844 ctr0->count--;
1845 talloc_free(scfg);
1846 continue;
1849 info.info0 = &ctr0->array[y];
1850 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
1851 W_ERROR_NOT_OK_RETURN(status);
1852 talloc_free(scfg);
1853 y++;
1855 talloc_free(snames);
1857 r->out.info_ctr->ctr.ctr0 = ctr0;
1858 *r->out.totalentries = r->out.info_ctr->ctr.ctr0->count;
1860 return WERR_OK;
1862 case 1:
1864 unsigned int i, y = 0;
1865 unsigned int count;
1866 struct srvsvc_NetShareCtr1 *ctr1;
1868 ctr1 = talloc(mem_ctx, struct srvsvc_NetShareCtr1);
1869 W_ERROR_HAVE_NO_MEMORY(ctr1);
1871 count = numshares;
1872 ctr1->count = count;
1873 ctr1->array = NULL;
1875 if (ctr1->count == 0) {
1876 r->out.info_ctr->ctr.ctr1 = ctr1;
1877 return WERR_OK;
1880 ctr1->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo1, count);
1881 W_ERROR_HAVE_NO_MEMORY(ctr1->array);
1883 for (i=0; i < count; i++) {
1884 WERROR status;
1885 union srvsvc_NetShareInfo info;
1886 enum srvsvc_ShareType type;
1888 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
1889 if (!NT_STATUS_IS_OK(nterr)) {
1890 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
1891 return WERR_GEN_FAILURE;
1894 type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
1895 if (type & STYPE_HIDDEN) {
1896 ctr1->count--;
1897 talloc_free(scfg);
1898 continue;
1901 info.info1 = &ctr1->array[y];
1902 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
1903 W_ERROR_NOT_OK_RETURN(status);
1904 talloc_free(scfg);
1905 y++;
1907 talloc_free(snames);
1909 r->out.info_ctr->ctr.ctr1 = ctr1;
1910 *r->out.totalentries = r->out.info_ctr->ctr.ctr1->count;
1912 return WERR_OK;
1914 case 2:
1916 unsigned int i, y = 0;
1917 unsigned int count;
1918 struct srvsvc_NetShareCtr2 *ctr2;
1920 SRVSVC_CHECK_ADMIN_ACCESS;
1922 ctr2 = talloc(mem_ctx, struct srvsvc_NetShareCtr2);
1923 W_ERROR_HAVE_NO_MEMORY(ctr2);
1925 count = numshares;
1926 ctr2->count = count;
1927 ctr2->array = NULL;
1929 if (ctr2->count == 0) {
1930 r->out.info_ctr->ctr.ctr2 = ctr2;
1931 return WERR_OK;
1934 ctr2->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo2, count);
1935 W_ERROR_HAVE_NO_MEMORY(ctr2->array);
1937 for (i=0; i < count; i++) {
1938 WERROR status;
1939 union srvsvc_NetShareInfo info;
1940 enum srvsvc_ShareType type;
1942 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
1943 if (!NT_STATUS_IS_OK(nterr)) {
1944 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
1945 return WERR_GEN_FAILURE;
1948 type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
1949 if (type & STYPE_HIDDEN) {
1950 ctr2->count--;
1951 talloc_free(scfg);
1952 continue;
1955 info.info2 = &ctr2->array[y];
1956 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
1957 W_ERROR_NOT_OK_RETURN(status);
1958 talloc_free(scfg);
1959 y++;
1961 talloc_free(snames);
1963 r->out.info_ctr->ctr.ctr2 = ctr2;
1964 *r->out.totalentries = r->out.info_ctr->ctr.ctr2->count;
1966 return WERR_OK;
1968 case 502:
1970 unsigned int i, y = 0;
1971 unsigned int count;
1972 struct srvsvc_NetShareCtr502 *ctr502;
1974 SRVSVC_CHECK_ADMIN_ACCESS;
1976 ctr502 = talloc(mem_ctx, struct srvsvc_NetShareCtr502);
1977 W_ERROR_HAVE_NO_MEMORY(ctr502);
1979 count = numshares;
1980 ctr502->count = count;
1981 ctr502->array = NULL;
1983 if (ctr502->count == 0) {
1984 r->out.info_ctr->ctr.ctr502 = ctr502;
1985 return WERR_OK;
1988 ctr502->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo502, count);
1989 W_ERROR_HAVE_NO_MEMORY(ctr502->array);
1991 for (i=0; i < count; i++) {
1992 WERROR status;
1993 union srvsvc_NetShareInfo info;
1994 enum srvsvc_ShareType type;
1996 nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
1997 if (!NT_STATUS_IS_OK(nterr)) {
1998 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
1999 return WERR_GEN_FAILURE;
2002 type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
2003 if (type & STYPE_HIDDEN) {
2004 ctr502->count--;
2005 talloc_free(scfg);
2006 continue;
2009 info.info502 = &ctr502->array[y];
2010 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
2011 W_ERROR_NOT_OK_RETURN(status);
2012 talloc_free(scfg);
2013 y++;
2015 talloc_free(snames);
2017 r->out.info_ctr->ctr.ctr502 = ctr502;
2018 *r->out.totalentries = r->out.info_ctr->ctr.ctr502->count;
2020 return WERR_OK;
2022 default:
2023 return WERR_INVALID_LEVEL;
2029 srvsvc_NetShareDelStart
2031 static WERROR dcesrv_srvsvc_NetShareDelStart(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2032 struct srvsvc_NetShareDelStart *r)
2034 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2039 srvsvc_NetShareDelCommit
2041 static WERROR dcesrv_srvsvc_NetShareDelCommit(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2042 struct srvsvc_NetShareDelCommit *r)
2044 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2049 srvsvc_NetGetFileSecurity
2051 static WERROR dcesrv_srvsvc_NetGetFileSecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2052 struct srvsvc_NetGetFileSecurity *r)
2054 struct auth_session_info *session_info =
2055 dcesrv_call_session_info(dce_call);
2056 struct sec_desc_buf *sd_buf;
2057 struct ntvfs_context *ntvfs_ctx = NULL;
2058 struct ntvfs_request *ntvfs_req;
2059 union smb_fileinfo *io;
2060 NTSTATUS nt_status;
2062 nt_status = srvsvc_create_ntvfs_context(dce_call, mem_ctx, r->in.share, &ntvfs_ctx);
2063 if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status);
2065 ntvfs_req = ntvfs_request_create(ntvfs_ctx, mem_ctx,
2066 session_info,
2068 dce_call->time,
2069 NULL, NULL, 0);
2070 W_ERROR_HAVE_NO_MEMORY(ntvfs_req);
2072 sd_buf = talloc(mem_ctx, struct sec_desc_buf);
2073 W_ERROR_HAVE_NO_MEMORY(sd_buf);
2075 io = talloc(mem_ctx, union smb_fileinfo);
2076 W_ERROR_HAVE_NO_MEMORY(io);
2078 io->query_secdesc.level = RAW_FILEINFO_SEC_DESC;
2079 io->query_secdesc.in.file.path = r->in.file;
2080 io->query_secdesc.in.secinfo_flags = r->in.securityinformation;
2082 nt_status = ntvfs_qpathinfo(ntvfs_req, io);
2083 if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status);
2085 sd_buf->sd = io->query_secdesc.out.sd;
2087 *r->out.sd_buf = sd_buf;
2088 return WERR_OK;
2093 srvsvc_NetSetFileSecurity
2095 static WERROR dcesrv_srvsvc_NetSetFileSecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2096 struct srvsvc_NetSetFileSecurity *r)
2098 struct auth_session_info *session_info =
2099 dcesrv_call_session_info(dce_call);
2100 struct ntvfs_context *ntvfs_ctx;
2101 struct ntvfs_request *ntvfs_req;
2102 union smb_setfileinfo *io;
2103 NTSTATUS nt_status;
2105 nt_status = srvsvc_create_ntvfs_context(dce_call, mem_ctx, r->in.share, &ntvfs_ctx);
2106 if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status);
2108 ntvfs_req = ntvfs_request_create(ntvfs_ctx, mem_ctx,
2109 session_info,
2111 dce_call->time,
2112 NULL, NULL, 0);
2113 W_ERROR_HAVE_NO_MEMORY(ntvfs_req);
2115 io = talloc(mem_ctx, union smb_setfileinfo);
2116 W_ERROR_HAVE_NO_MEMORY(io);
2118 io->set_secdesc.level = RAW_SFILEINFO_SEC_DESC;
2119 io->set_secdesc.in.file.path = r->in.file;
2120 io->set_secdesc.in.secinfo_flags = r->in.securityinformation;
2121 io->set_secdesc.in.sd = r->in.sd_buf->sd;
2123 nt_status = ntvfs_setpathinfo(ntvfs_req, io);
2124 if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status);
2126 return WERR_OK;
2131 srvsvc_NetServerTransportAddEx
2133 static WERROR dcesrv_srvsvc_NetServerTransportAddEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2134 struct srvsvc_NetServerTransportAddEx *r)
2136 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2141 srvsvc_NetServerSetServiceBitsEx
2143 static WERROR dcesrv_srvsvc_NetServerSetServiceBitsEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2144 struct srvsvc_NetServerSetServiceBitsEx *r)
2146 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2151 srvsvc_NETRDFSGETVERSION
2153 static WERROR dcesrv_srvsvc_NETRDFSGETVERSION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2154 struct srvsvc_NETRDFSGETVERSION *r)
2156 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2161 srvsvc_NETRDFSCREATELOCALPARTITION
2163 static WERROR dcesrv_srvsvc_NETRDFSCREATELOCALPARTITION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2164 struct srvsvc_NETRDFSCREATELOCALPARTITION *r)
2166 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2171 srvsvc_NETRDFSDELETELOCALPARTITION
2173 static WERROR dcesrv_srvsvc_NETRDFSDELETELOCALPARTITION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2174 struct srvsvc_NETRDFSDELETELOCALPARTITION *r)
2176 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2181 srvsvc_NETRDFSSETLOCALVOLUMESTATE
2183 static WERROR dcesrv_srvsvc_NETRDFSSETLOCALVOLUMESTATE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2184 struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *r)
2186 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2191 srvsvc_NETRDFSSETSERVERINFO
2193 static WERROR dcesrv_srvsvc_NETRDFSSETSERVERINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2194 struct srvsvc_NETRDFSSETSERVERINFO *r)
2196 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2201 srvsvc_NETRDFSCREATEEXITPOINT
2203 static WERROR dcesrv_srvsvc_NETRDFSCREATEEXITPOINT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2204 struct srvsvc_NETRDFSCREATEEXITPOINT *r)
2206 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2211 srvsvc_NETRDFSDELETEEXITPOINT
2213 static WERROR dcesrv_srvsvc_NETRDFSDELETEEXITPOINT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2214 struct srvsvc_NETRDFSDELETEEXITPOINT *r)
2216 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2221 srvsvc_NETRDFSMODIFYPREFIX
2223 static WERROR dcesrv_srvsvc_NETRDFSMODIFYPREFIX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2224 struct srvsvc_NETRDFSMODIFYPREFIX *r)
2226 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2231 srvsvc_NETRDFSFIXLOCALVOLUME
2233 static WERROR dcesrv_srvsvc_NETRDFSFIXLOCALVOLUME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2234 struct srvsvc_NETRDFSFIXLOCALVOLUME *r)
2236 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2241 srvsvc_NETRDFSMANAGERREPORTSITEINFO
2243 static WERROR dcesrv_srvsvc_NETRDFSMANAGERREPORTSITEINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2244 struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r)
2246 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2251 srvsvc_NETRSERVERTRANSPORTDELEX
2253 static WERROR dcesrv_srvsvc_NETRSERVERTRANSPORTDELEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2254 struct srvsvc_NETRSERVERTRANSPORTDELEX *r)
2256 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2260 srvsvc_NetShareDel
2262 static WERROR dcesrv_srvsvc_NetShareDel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2263 struct srvsvc_NetShareDel *r)
2265 NTSTATUS nterr;
2266 struct share_context *sctx;
2268 nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
2269 if (!NT_STATUS_IS_OK(nterr)) {
2270 return ntstatus_to_werror(nterr);
2273 nterr = share_remove(sctx, r->in.share_name);
2274 if (!NT_STATUS_IS_OK(nterr)) {
2275 return ntstatus_to_werror(nterr);
2278 return WERR_OK;
2282 srvsvc_NetSetServiceBits
2284 static WERROR dcesrv_srvsvc_NetSetServiceBits(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2285 struct srvsvc_NetSetServiceBits *r)
2287 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2291 srvsvc_NETRPRNAMECANONICALIZE
2293 static WERROR dcesrv_srvsvc_NETRPRNAMECANONICALIZE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
2294 struct srvsvc_NETRPRNAMECANONICALIZE *r)
2296 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
2299 /* include the generated boilerplate */
2300 #include "librpc/gen_ndr/ndr_srvsvc_s.c"