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/>.
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/proto.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_string(t, SID_BUILTIN_SERVER_OPERATORS)) { \
38 return WERR_ACCESS_DENIED; \
45 static WERROR
dcesrv_srvsvc_NetCharDevEnum(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
46 struct srvsvc_NetCharDevEnum
*r
)
48 r
->out
.level
= r
->in
.level
;
49 r
->out
.totalentries
= 0;
50 r
->out
.resume_handle
= NULL
;
52 switch (r
->in
.level
) {
54 r
->out
.ctr
.ctr0
= talloc(mem_ctx
, struct srvsvc_NetCharDevCtr0
);
55 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr0
);
57 r
->out
.ctr
.ctr0
->count
= 0;
58 r
->out
.ctr
.ctr0
->array
= NULL
;
60 return WERR_NOT_SUPPORTED
;
63 r
->out
.ctr
.ctr1
= talloc(mem_ctx
, struct srvsvc_NetCharDevCtr1
);
64 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr1
);
66 r
->out
.ctr
.ctr1
->count
= 0;
67 r
->out
.ctr
.ctr1
->array
= NULL
;
69 return WERR_NOT_SUPPORTED
;
72 return WERR_UNKNOWN_LEVEL
;
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
) {
90 return WERR_NOT_SUPPORTED
;
94 return WERR_NOT_SUPPORTED
;
97 return WERR_UNKNOWN_LEVEL
;
100 return WERR_UNKNOWN_LEVEL
;
105 srvsvc_NetCharDevControl
107 static WERROR
dcesrv_srvsvc_NetCharDevControl(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
108 struct srvsvc_NetCharDevControl
*r
)
110 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
115 srvsvc_NetCharDevQEnum
117 static WERROR
dcesrv_srvsvc_NetCharDevQEnum(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
118 struct srvsvc_NetCharDevQEnum
*r
)
120 r
->out
.level
= r
->in
.level
;
121 r
->out
.totalentries
= 0;
122 r
->out
.resume_handle
= NULL
;
124 switch (r
->in
.level
) {
127 r
->out
.ctr
.ctr0
= talloc(mem_ctx
, struct srvsvc_NetCharDevQCtr0
);
128 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr0
);
130 r
->out
.ctr
.ctr0
->count
= 0;
131 r
->out
.ctr
.ctr0
->array
= NULL
;
133 return WERR_NOT_SUPPORTED
;
137 r
->out
.ctr
.ctr1
= talloc(mem_ctx
, struct srvsvc_NetCharDevQCtr1
);
138 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr1
);
140 r
->out
.ctr
.ctr1
->count
= 0;
141 r
->out
.ctr
.ctr1
->array
= NULL
;
143 return WERR_NOT_SUPPORTED
;
146 return WERR_UNKNOWN_LEVEL
;
149 return WERR_UNKNOWN_LEVEL
;
154 srvsvc_NetCharDevQGetInfo
156 static WERROR
dcesrv_srvsvc_NetCharDevQGetInfo(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
157 struct srvsvc_NetCharDevQGetInfo
*r
)
159 ZERO_STRUCTP(r
->out
.info
);
161 switch (r
->in
.level
) {
164 return WERR_NOT_SUPPORTED
;
168 return WERR_NOT_SUPPORTED
;
171 return WERR_UNKNOWN_LEVEL
;
174 return WERR_UNKNOWN_LEVEL
;
179 srvsvc_NetCharDevQSetInfo
181 static WERROR
dcesrv_srvsvc_NetCharDevQSetInfo(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
182 struct srvsvc_NetCharDevQSetInfo
*r
)
184 switch (r
->in
.level
) {
187 if (r
->in
.parm_error
) {
188 r
->out
.parm_error
= r
->in
.parm_error
;
190 return WERR_NOT_SUPPORTED
;
194 if (r
->in
.parm_error
) {
195 r
->out
.parm_error
= r
->in
.parm_error
;
197 return WERR_NOT_SUPPORTED
;
200 return WERR_UNKNOWN_LEVEL
;
203 return WERR_UNKNOWN_LEVEL
;
208 srvsvc_NetCharDevQPurge
210 static WERROR
dcesrv_srvsvc_NetCharDevQPurge(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
211 struct srvsvc_NetCharDevQPurge
*r
)
213 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
218 srvsvc_NetCharDevQPurgeSelf
220 static WERROR
dcesrv_srvsvc_NetCharDevQPurgeSelf(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
221 struct srvsvc_NetCharDevQPurgeSelf
*r
)
223 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
230 static WERROR
dcesrv_srvsvc_NetConnEnum(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
231 struct srvsvc_NetConnEnum
*r
)
233 r
->out
.level
= r
->in
.level
;
234 r
->out
.totalentries
= 0;
235 r
->out
.resume_handle
= NULL
;
237 switch (r
->in
.level
) {
240 r
->out
.ctr
.ctr0
= talloc(mem_ctx
, struct srvsvc_NetConnCtr0
);
241 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr0
);
243 r
->out
.ctr
.ctr0
->count
= 0;
244 r
->out
.ctr
.ctr0
->array
= NULL
;
246 return WERR_NOT_SUPPORTED
;
250 r
->out
.ctr
.ctr1
= talloc(mem_ctx
, struct srvsvc_NetConnCtr1
);
251 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr1
);
253 r
->out
.ctr
.ctr1
->count
= 0;
254 r
->out
.ctr
.ctr1
->array
= NULL
;
256 return WERR_NOT_SUPPORTED
;
259 return WERR_UNKNOWN_LEVEL
;
262 return WERR_UNKNOWN_LEVEL
;
269 static WERROR
dcesrv_srvsvc_NetFileEnum(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
270 struct srvsvc_NetFileEnum
*r
)
272 r
->out
.level
= r
->in
.level
;
273 r
->out
.totalentries
= 0;
274 r
->out
.resume_handle
= NULL
;
276 switch (r
->in
.level
) {
279 r
->out
.ctr
.ctr2
= talloc(mem_ctx
, struct srvsvc_NetFileCtr2
);
280 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr2
);
282 r
->out
.ctr
.ctr2
->count
= 0;
283 r
->out
.ctr
.ctr2
->array
= NULL
;
285 return WERR_NOT_SUPPORTED
;
289 r
->out
.ctr
.ctr3
= talloc(mem_ctx
, struct srvsvc_NetFileCtr3
);
290 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr3
);
292 r
->out
.ctr
.ctr3
->count
= 0;
293 r
->out
.ctr
.ctr3
->array
= NULL
;
295 return WERR_NOT_SUPPORTED
;
298 return WERR_UNKNOWN_LEVEL
;
301 return WERR_UNKNOWN_LEVEL
;
306 srvsvc_NetFileGetInfo
308 static WERROR
dcesrv_srvsvc_NetFileGetInfo(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
309 struct srvsvc_NetFileGetInfo
*r
)
311 ZERO_STRUCTP(r
->out
.info
);
313 switch (r
->in
.level
) {
316 return WERR_NOT_SUPPORTED
;
320 return WERR_NOT_SUPPORTED
;
323 return WERR_UNKNOWN_LEVEL
;
326 return WERR_UNKNOWN_LEVEL
;
333 static WERROR
dcesrv_srvsvc_NetFileClose(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
334 struct srvsvc_NetFileClose
*r
)
336 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
343 static WERROR
dcesrv_srvsvc_NetSessEnum(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
344 struct srvsvc_NetSessEnum
*r
)
346 r
->out
.level
= r
->in
.level
;
347 r
->out
.totalentries
= 0;
348 r
->out
.resume_handle
= NULL
;
350 switch (r
->in
.level
) {
353 r
->out
.ctr
.ctr0
= talloc(mem_ctx
, struct srvsvc_NetSessCtr0
);
354 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr0
);
356 r
->out
.ctr
.ctr0
->count
= 0;
357 r
->out
.ctr
.ctr0
->array
= NULL
;
359 return WERR_NOT_SUPPORTED
;
363 r
->out
.ctr
.ctr1
= talloc(mem_ctx
, struct srvsvc_NetSessCtr1
);
364 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr1
);
366 r
->out
.ctr
.ctr1
->count
= 0;
367 r
->out
.ctr
.ctr1
->array
= NULL
;
369 return WERR_NOT_SUPPORTED
;
373 r
->out
.ctr
.ctr2
= talloc(mem_ctx
, struct srvsvc_NetSessCtr2
);
374 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr2
);
376 r
->out
.ctr
.ctr2
->count
= 0;
377 r
->out
.ctr
.ctr2
->array
= NULL
;
379 return WERR_NOT_SUPPORTED
;
383 r
->out
.ctr
.ctr10
= talloc(mem_ctx
, struct srvsvc_NetSessCtr10
);
384 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr10
);
386 r
->out
.ctr
.ctr2
->count
= 0;
387 r
->out
.ctr
.ctr2
->array
= NULL
;
389 return WERR_NOT_SUPPORTED
;
393 r
->out
.ctr
.ctr502
= talloc(mem_ctx
, struct srvsvc_NetSessCtr502
);
394 W_ERROR_HAVE_NO_MEMORY(r
->out
.ctr
.ctr502
);
396 r
->out
.ctr
.ctr2
->count
= 0;
397 r
->out
.ctr
.ctr2
->array
= NULL
;
399 return WERR_NOT_SUPPORTED
;
402 return WERR_UNKNOWN_LEVEL
;
405 return WERR_UNKNOWN_LEVEL
;
412 static WERROR
dcesrv_srvsvc_NetSessDel(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
413 struct srvsvc_NetSessDel
*r
)
415 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
422 static WERROR
dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
423 struct srvsvc_NetShareAdd
*r
)
425 switch (r
->in
.level
) {
428 if (r
->in
.parm_error
) {
429 r
->out
.parm_error
= r
->in
.parm_error
;
431 return WERR_NOT_SUPPORTED
;
435 if (r
->in
.parm_error
) {
436 r
->out
.parm_error
= r
->in
.parm_error
;
438 return WERR_NOT_SUPPORTED
;
443 struct share_info
*info
;
444 struct share_context
*sctx
;
448 nterr
= share_get_context_by_name(mem_ctx
, lp_share_backend(dce_call
->conn
->dce_ctx
->lp_ctx
), dce_call
->event_ctx
, dce_call
->conn
->dce_ctx
->lp_ctx
, &sctx
);
449 if (!NT_STATUS_IS_OK(nterr
)) {
450 return ntstatus_to_werror(nterr
);
453 /* there are no more than 8 options in struct srvsvc_NetShareInfo2 */
454 info
= talloc_array(mem_ctx
, struct share_info
, count
);
455 W_ERROR_HAVE_NO_MEMORY(info
);
459 info
[i
].name
= SHARE_TYPE
;
460 info
[i
].type
= SHARE_INFO_STRING
;
461 switch (r
->in
.info
->info2
->type
) {
463 info
[i
].value
= talloc_strdup(info
, "DISK");
466 info
[i
].value
= talloc_strdup(info
, "PRINTER");
469 info
[i
].value
= talloc_strdup(info
, "IPC");
472 return WERR_INVALID_PARAM
;
474 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
477 if (r
->in
.info
->info2
->path
&& r
->in
.info
->info2
->path
[0]) {
478 info
[i
].name
= SHARE_PATH
;
479 info
[i
].type
= SHARE_INFO_STRING
;
481 /* Windows will send a path in a form of C:\example\path */
482 if (r
->in
.info
->info2
->path
[1] == ':') {
483 info
[i
].value
= talloc_strdup(info
, &r
->in
.info
->info2
->path
[2]);
485 /* very strange let's try to set as is */
486 info
[i
].value
= talloc_strdup(info
, r
->in
.info
->info2
->path
);
488 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
489 all_string_sub((char *)info
[i
].value
, "\\", "/", 0);
494 if (r
->in
.info
->info2
->comment
&& r
->in
.info
->info2
->comment
[0]) {
495 info
[i
].name
= SHARE_COMMENT
;
496 info
[i
].type
= SHARE_INFO_STRING
;
497 info
[i
].value
= talloc_strdup(info
, r
->in
.info
->info2
->comment
);
498 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
503 if (r
->in
.info
->info2
->password
&& r
->in
.info
->info2
->password
[0]) {
504 info
[i
].name
= SHARE_PASSWORD
;
505 info
[i
].type
= SHARE_INFO_STRING
;
506 info
[i
].value
= talloc_strdup(info
, r
->in
.info
->info2
->password
);
507 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
512 info
[i
].name
= SHARE_MAX_CONNECTIONS
;
513 info
[i
].type
= SHARE_INFO_INT
;
514 info
[i
].value
= talloc(info
, int);
515 *((int *)info
[i
].value
) = r
->in
.info
->info2
->max_users
;
518 /* TODO: security descriptor */
520 nterr
= share_create(sctx
, r
->in
.info
->info2
->name
, info
, i
);
521 if (!NT_STATUS_IS_OK(nterr
)) {
522 return ntstatus_to_werror(nterr
);
525 if (r
->in
.parm_error
) {
526 r
->out
.parm_error
= r
->in
.parm_error
;
533 if (r
->in
.parm_error
) {
534 r
->out
.parm_error
= r
->in
.parm_error
;
536 return WERR_NOT_SUPPORTED
;
541 struct share_info
*info
;
542 struct share_context
*sctx
;
546 nterr
= share_get_context_by_name(mem_ctx
, lp_share_backend(dce_call
->conn
->dce_ctx
->lp_ctx
), dce_call
->event_ctx
, dce_call
->conn
->dce_ctx
->lp_ctx
, &sctx
);
547 if (!NT_STATUS_IS_OK(nterr
)) {
548 return ntstatus_to_werror(nterr
);
551 /* there are no more than 10 options in struct srvsvc_NetShareInfo502 */
552 info
= talloc_array(mem_ctx
, struct share_info
, count
);
553 W_ERROR_HAVE_NO_MEMORY(info
);
557 info
[i
].name
= SHARE_TYPE
;
558 info
[i
].type
= SHARE_INFO_STRING
;
559 switch (r
->in
.info
->info502
->type
) {
561 info
[i
].value
= talloc_strdup(info
, "DISK");
564 info
[i
].value
= talloc_strdup(info
, "PRINTER");
567 info
[i
].value
= talloc_strdup(info
, "IPC");
570 return WERR_INVALID_PARAM
;
572 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
575 if (r
->in
.info
->info502
->path
&& r
->in
.info
->info502
->path
[0]) {
576 info
[i
].name
= SHARE_PATH
;
577 info
[i
].type
= SHARE_INFO_STRING
;
579 /* Windows will send a path in a form of C:\example\path */
580 if (r
->in
.info
->info502
->path
[1] == ':') {
581 info
[i
].value
= talloc_strdup(info
, &r
->in
.info
->info502
->path
[2]);
583 /* very strange let's try to set as is */
584 info
[i
].value
= talloc_strdup(info
, r
->in
.info
->info502
->path
);
586 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
587 all_string_sub((char *)info
[i
].value
, "\\", "/", 0);
592 if (r
->in
.info
->info502
->comment
&& r
->in
.info
->info502
->comment
[0]) {
593 info
[i
].name
= SHARE_COMMENT
;
594 info
[i
].type
= SHARE_INFO_STRING
;
595 info
[i
].value
= talloc_strdup(info
, r
->in
.info
->info502
->comment
);
596 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
601 if (r
->in
.info
->info502
->password
&& r
->in
.info
->info502
->password
[0]) {
602 info
[i
].name
= SHARE_PASSWORD
;
603 info
[i
].type
= SHARE_INFO_STRING
;
604 info
[i
].value
= talloc_strdup(info
, r
->in
.info
->info502
->password
);
605 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
610 info
[i
].name
= SHARE_MAX_CONNECTIONS
;
611 info
[i
].type
= SHARE_INFO_INT
;
612 info
[i
].value
= talloc(info
, int);
613 *((int *)info
[i
].value
) = r
->in
.info
->info502
->max_users
;
616 /* TODO: security descriptor */
618 nterr
= share_create(sctx
, r
->in
.info
->info502
->name
, info
, i
);
619 if (!NT_STATUS_IS_OK(nterr
)) {
620 return ntstatus_to_werror(nterr
);
623 if (r
->in
.parm_error
) {
624 r
->out
.parm_error
= r
->in
.parm_error
;
630 return WERR_UNKNOWN_LEVEL
;
633 return WERR_UNKNOWN_LEVEL
;
636 static WERROR
dcesrv_srvsvc_fiel_ShareInfo(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
637 struct share_config
*scfg
, uint32_t level
,
638 union srvsvc_NetShareInfo
*info
)
640 struct dcesrv_context
*dce_ctx
= dce_call
->conn
->dce_ctx
;
645 info
->info0
->name
= talloc_strdup(mem_ctx
, scfg
->name
);
646 W_ERROR_HAVE_NO_MEMORY(info
->info0
->name
);
652 info
->info1
->name
= talloc_strdup(mem_ctx
, scfg
->name
);
653 W_ERROR_HAVE_NO_MEMORY(info
->info1
->name
);
654 info
->info1
->type
= dcesrv_common_get_share_type(mem_ctx
, dce_ctx
, scfg
);
655 info
->info1
->comment
= talloc_strdup(mem_ctx
, share_string_option(scfg
, SHARE_COMMENT
, ""));
656 W_ERROR_HAVE_NO_MEMORY(info
->info1
->comment
);
662 info
->info2
->name
= talloc_strdup(mem_ctx
, scfg
->name
);
663 W_ERROR_HAVE_NO_MEMORY(info
->info2
->name
);
664 info
->info2
->type
= dcesrv_common_get_share_type(mem_ctx
, dce_ctx
, scfg
);
665 info
->info2
->comment
= talloc_strdup(mem_ctx
, share_string_option(scfg
, SHARE_COMMENT
, ""));
666 W_ERROR_HAVE_NO_MEMORY(info
->info2
->comment
);
667 info
->info2
->permissions
= dcesrv_common_get_share_permissions(mem_ctx
, dce_ctx
, scfg
);
668 info
->info2
->max_users
= share_int_option(scfg
, SHARE_MAX_CONNECTIONS
, SHARE_MAX_CONNECTIONS_DEFAULT
);
669 info
->info2
->current_users
= dcesrv_common_get_share_current_users(mem_ctx
, dce_ctx
, scfg
);
670 info
->info2
->path
= dcesrv_common_get_share_path(mem_ctx
, dce_ctx
, scfg
);
671 W_ERROR_HAVE_NO_MEMORY(info
->info2
->path
);
672 info
->info2
->password
= talloc_strdup(mem_ctx
, share_string_option(scfg
, SHARE_PASSWORD
, NULL
));
678 info
->info501
->name
= talloc_strdup(mem_ctx
, scfg
->name
);
679 W_ERROR_HAVE_NO_MEMORY(info
->info501
->name
);
680 info
->info501
->type
= dcesrv_common_get_share_type(mem_ctx
, dce_ctx
, scfg
);
681 info
->info501
->comment
= talloc_strdup(mem_ctx
, share_string_option(scfg
, SHARE_COMMENT
, ""));
682 W_ERROR_HAVE_NO_MEMORY(info
->info501
->comment
);
683 info
->info501
->csc_policy
= share_int_option(scfg
, SHARE_CSC_POLICY
, SHARE_CSC_POLICY_DEFAULT
);
689 info
->info502
->name
= talloc_strdup(mem_ctx
, scfg
->name
);
690 W_ERROR_HAVE_NO_MEMORY(info
->info502
->name
);
691 info
->info502
->type
= dcesrv_common_get_share_type(mem_ctx
, dce_ctx
, scfg
);
692 info
->info502
->comment
= talloc_strdup(mem_ctx
, share_string_option(scfg
, SHARE_COMMENT
, ""));
693 W_ERROR_HAVE_NO_MEMORY(info
->info502
->comment
);
694 info
->info502
->permissions
= dcesrv_common_get_share_permissions(mem_ctx
, dce_ctx
, scfg
);
695 info
->info502
->max_users
= share_int_option(scfg
, SHARE_MAX_CONNECTIONS
, SHARE_MAX_CONNECTIONS_DEFAULT
);
696 info
->info502
->current_users
= dcesrv_common_get_share_current_users(mem_ctx
, dce_ctx
, scfg
);
697 info
->info502
->path
= dcesrv_common_get_share_path(mem_ctx
, dce_ctx
, scfg
);
698 W_ERROR_HAVE_NO_MEMORY(info
->info502
->path
);
699 info
->info502
->password
= talloc_strdup(mem_ctx
, share_string_option(scfg
, SHARE_PASSWORD
, NULL
));
700 info
->info502
->sd_buf
.sd
= dcesrv_common_get_security_descriptor(mem_ctx
, dce_ctx
, scfg
);
706 info
->info1005
->dfs_flags
= dcesrv_common_get_share_dfs_flags(mem_ctx
, dce_ctx
, scfg
);
711 return WERR_UNKNOWN_LEVEL
;
714 return WERR_UNKNOWN_LEVEL
;
718 srvsvc_NetShareEnumAll
720 static WERROR
dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
721 struct srvsvc_NetShareEnumAll
*r
)
726 struct share_context
*sctx
;
727 struct share_config
*scfg
;
729 r
->out
.level
= r
->in
.level
;
730 ZERO_STRUCT(r
->out
.ctr
);
731 r
->out
.totalentries
= 0;
732 r
->out
.resume_handle
= NULL
;
734 /* TODO: - paging of results
737 nterr
= share_get_context_by_name(mem_ctx
, lp_share_backend(dce_call
->conn
->dce_ctx
->lp_ctx
), dce_call
->event_ctx
, dce_call
->conn
->dce_ctx
->lp_ctx
, &sctx
);
738 if (!NT_STATUS_IS_OK(nterr
)) {
739 return ntstatus_to_werror(nterr
);
742 nterr
= share_list_all(mem_ctx
, sctx
, &numshares
, &snames
);
743 if (!NT_STATUS_IS_OK(nterr
)) {
744 return ntstatus_to_werror(nterr
);
747 switch (r
->in
.level
) {
751 struct srvsvc_NetShareCtr0
*ctr0
;
753 ctr0
= talloc(mem_ctx
, struct srvsvc_NetShareCtr0
);
754 W_ERROR_HAVE_NO_MEMORY(ctr0
);
756 ctr0
->count
= numshares
;
759 if (ctr0
->count
== 0) {
760 r
->out
.ctr
.ctr0
= ctr0
;
764 ctr0
->array
= talloc_array(mem_ctx
, struct srvsvc_NetShareInfo0
, ctr0
->count
);
765 W_ERROR_HAVE_NO_MEMORY(ctr0
->array
);
767 for (i
= 0; i
< ctr0
->count
; i
++) {
769 union srvsvc_NetShareInfo info
;
771 nterr
= share_get_config(mem_ctx
, sctx
, snames
[i
], &scfg
);
772 if (!NT_STATUS_IS_OK(nterr
)) {
773 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames
[i
]));
774 return WERR_GENERAL_FAILURE
;
776 info
.info0
= &ctr0
->array
[i
];
777 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
778 if (!W_ERROR_IS_OK(status
)) {
785 r
->out
.ctr
.ctr0
= ctr0
;
786 r
->out
.totalentries
= r
->out
.ctr
.ctr0
->count
;
792 struct srvsvc_NetShareCtr1
*ctr1
;
794 ctr1
= talloc(mem_ctx
, struct srvsvc_NetShareCtr1
);
795 W_ERROR_HAVE_NO_MEMORY(ctr1
);
797 ctr1
->count
= numshares
;
800 if (ctr1
->count
== 0) {
801 r
->out
.ctr
.ctr1
= ctr1
;
805 ctr1
->array
= talloc_array(mem_ctx
, struct srvsvc_NetShareInfo1
, ctr1
->count
);
806 W_ERROR_HAVE_NO_MEMORY(ctr1
->array
);
808 for (i
=0; i
< ctr1
->count
; i
++) {
810 union srvsvc_NetShareInfo info
;
812 nterr
= share_get_config(mem_ctx
, sctx
, snames
[i
], &scfg
);
813 if (!NT_STATUS_IS_OK(nterr
)) {
814 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames
[i
]));
815 return WERR_GENERAL_FAILURE
;
817 info
.info1
= &ctr1
->array
[i
];
818 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
819 if (!W_ERROR_IS_OK(status
)) {
826 r
->out
.ctr
.ctr1
= ctr1
;
827 r
->out
.totalentries
= r
->out
.ctr
.ctr1
->count
;
833 struct srvsvc_NetShareCtr2
*ctr2
;
835 SRVSVC_CHECK_ADMIN_ACCESS
;
837 ctr2
= talloc(mem_ctx
, struct srvsvc_NetShareCtr2
);
838 W_ERROR_HAVE_NO_MEMORY(ctr2
);
840 ctr2
->count
= numshares
;
843 if (ctr2
->count
== 0) {
844 r
->out
.ctr
.ctr2
= ctr2
;
848 ctr2
->array
= talloc_array(mem_ctx
, struct srvsvc_NetShareInfo2
, ctr2
->count
);
849 W_ERROR_HAVE_NO_MEMORY(ctr2
->array
);
851 for (i
=0; i
< ctr2
->count
; i
++) {
853 union srvsvc_NetShareInfo info
;
855 nterr
= share_get_config(mem_ctx
, sctx
, snames
[i
], &scfg
);
856 if (!NT_STATUS_IS_OK(nterr
)) {
857 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames
[i
]));
858 return WERR_GENERAL_FAILURE
;
860 info
.info2
= &ctr2
->array
[i
];
861 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
862 if (!W_ERROR_IS_OK(status
)) {
869 r
->out
.ctr
.ctr2
= ctr2
;
870 r
->out
.totalentries
= r
->out
.ctr
.ctr2
->count
;
876 struct srvsvc_NetShareCtr501
*ctr501
;
878 SRVSVC_CHECK_ADMIN_ACCESS
;
880 ctr501
= talloc(mem_ctx
, struct srvsvc_NetShareCtr501
);
881 W_ERROR_HAVE_NO_MEMORY(ctr501
);
883 ctr501
->count
= numshares
;
884 ctr501
->array
= NULL
;
886 if (ctr501
->count
== 0) {
887 r
->out
.ctr
.ctr501
= ctr501
;
891 ctr501
->array
= talloc_array(mem_ctx
, struct srvsvc_NetShareInfo501
, ctr501
->count
);
892 W_ERROR_HAVE_NO_MEMORY(ctr501
->array
);
894 for (i
=0; i
< ctr501
->count
; i
++) {
896 union srvsvc_NetShareInfo info
;
898 nterr
= share_get_config(mem_ctx
, sctx
, snames
[i
], &scfg
);
899 if (!NT_STATUS_IS_OK(nterr
)) {
900 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames
[i
]));
901 return WERR_GENERAL_FAILURE
;
903 info
.info501
= &ctr501
->array
[i
];
904 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
905 if (!W_ERROR_IS_OK(status
)) {
912 r
->out
.ctr
.ctr501
= ctr501
;
913 r
->out
.totalentries
= r
->out
.ctr
.ctr501
->count
;
919 struct srvsvc_NetShareCtr502
*ctr502
;
921 SRVSVC_CHECK_ADMIN_ACCESS
;
923 ctr502
= talloc(mem_ctx
, struct srvsvc_NetShareCtr502
);
924 W_ERROR_HAVE_NO_MEMORY(ctr502
);
926 ctr502
->count
= numshares
;
927 ctr502
->array
= NULL
;
929 if (ctr502
->count
== 0) {
930 r
->out
.ctr
.ctr502
= ctr502
;
934 ctr502
->array
= talloc_array(mem_ctx
, struct srvsvc_NetShareInfo502
, ctr502
->count
);
935 W_ERROR_HAVE_NO_MEMORY(ctr502
->array
);
937 for (i
=0; i
< ctr502
->count
; i
++) {
939 union srvsvc_NetShareInfo info
;
941 nterr
= share_get_config(mem_ctx
, sctx
, snames
[i
], &scfg
);
942 if (!NT_STATUS_IS_OK(nterr
)) {
943 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames
[i
]));
944 return WERR_GENERAL_FAILURE
;
946 info
.info502
= &ctr502
->array
[i
];
947 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
948 if (!W_ERROR_IS_OK(status
)) {
955 r
->out
.ctr
.ctr502
= ctr502
;
956 r
->out
.totalentries
= r
->out
.ctr
.ctr502
->count
;
960 return WERR_UNKNOWN_LEVEL
;
963 return WERR_UNKNOWN_LEVEL
;
968 srvsvc_NetShareGetInfo
970 static WERROR
dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
971 struct srvsvc_NetShareGetInfo
*r
)
974 struct share_context
*sctx
= NULL
;
975 struct share_config
*scfg
= NULL
;
977 ZERO_STRUCTP(r
->out
.info
);
979 /* TODO: - access check
982 if (strcmp("", r
->in
.share_name
) == 0) {
983 return WERR_INVALID_PARAM
;
986 nterr
= share_get_context_by_name(mem_ctx
, lp_share_backend(dce_call
->conn
->dce_ctx
->lp_ctx
), dce_call
->event_ctx
, dce_call
->conn
->dce_ctx
->lp_ctx
, &sctx
);
987 if (!NT_STATUS_IS_OK(nterr
)) {
988 return ntstatus_to_werror(nterr
);
991 nterr
= share_get_config(mem_ctx
, sctx
, r
->in
.share_name
, &scfg
);
992 if (!NT_STATUS_IS_OK(nterr
)) {
993 return ntstatus_to_werror(nterr
);
996 switch (r
->in
.level
) {
1000 union srvsvc_NetShareInfo info
;
1002 info
.info0
= talloc(mem_ctx
, struct srvsvc_NetShareInfo0
);
1003 W_ERROR_HAVE_NO_MEMORY(info
.info0
);
1005 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
1006 if (!W_ERROR_IS_OK(status
)) {
1010 r
->out
.info
->info0
= info
.info0
;
1016 union srvsvc_NetShareInfo info
;
1018 info
.info1
= talloc(mem_ctx
, struct srvsvc_NetShareInfo1
);
1019 W_ERROR_HAVE_NO_MEMORY(info
.info1
);
1021 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
1022 if (!W_ERROR_IS_OK(status
)) {
1026 r
->out
.info
->info1
= info
.info1
;
1032 union srvsvc_NetShareInfo info
;
1034 SRVSVC_CHECK_ADMIN_ACCESS
;
1036 info
.info2
= talloc(mem_ctx
, struct srvsvc_NetShareInfo2
);
1037 W_ERROR_HAVE_NO_MEMORY(info
.info2
);
1039 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
1040 if (!W_ERROR_IS_OK(status
)) {
1044 r
->out
.info
->info2
= info
.info2
;
1050 union srvsvc_NetShareInfo info
;
1052 info
.info501
= talloc(mem_ctx
, struct srvsvc_NetShareInfo501
);
1053 W_ERROR_HAVE_NO_MEMORY(info
.info501
);
1055 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
1056 if (!W_ERROR_IS_OK(status
)) {
1060 r
->out
.info
->info501
= info
.info501
;
1066 union srvsvc_NetShareInfo info
;
1068 SRVSVC_CHECK_ADMIN_ACCESS
;
1070 info
.info502
= talloc(mem_ctx
, struct srvsvc_NetShareInfo502
);
1071 W_ERROR_HAVE_NO_MEMORY(info
.info502
);
1073 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
1074 if (!W_ERROR_IS_OK(status
)) {
1078 r
->out
.info
->info502
= info
.info502
;
1084 union srvsvc_NetShareInfo info
;
1086 info
.info1005
= talloc(mem_ctx
, struct srvsvc_NetShareInfo1005
);
1087 W_ERROR_HAVE_NO_MEMORY(info
.info1005
);
1089 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
1090 if (!W_ERROR_IS_OK(status
)) {
1094 r
->out
.info
->info1005
= info
.info1005
;
1098 return WERR_UNKNOWN_LEVEL
;
1101 return WERR_UNKNOWN_LEVEL
;
1104 static WERROR
dcesrv_srvsvc_fill_share_info(struct share_info
*info
, int *count
,
1105 const char *share_name
, int level
,
1108 const char *comment
,
1109 const char *password
,
1110 enum srvsvc_ShareType type
,
1112 uint32_t csc_policy
,
1113 struct security_descriptor
*sd
)
1118 info
[i
].name
= SHARE_CSC_POLICY
;
1119 info
[i
].type
= SHARE_INFO_INT
;
1120 info
[i
].value
= talloc(info
, int);
1121 *((int *)info
[i
].value
) = csc_policy
;
1128 /* TODO: check if unknown is csc_policy */
1130 /* TODO: security descriptor */
1133 if (path
&& path
[0]) {
1134 info
[i
].name
= SHARE_PATH
;
1135 info
[i
].type
= SHARE_INFO_STRING
;
1137 /* Windows will send a path in a form of C:\example\path */
1138 if (path
[1] == ':') {
1139 info
[i
].value
= talloc_strdup(info
, &path
[2]);
1141 /* very strange let's try to set as is */
1142 info
[i
].value
= talloc_strdup(info
, path
);
1144 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
1145 all_string_sub((char *)info
[i
].value
, "\\", "/", 0);
1150 if (password
&& password
[0]) {
1151 info
[i
].name
= SHARE_PASSWORD
;
1152 info
[i
].type
= SHARE_INFO_STRING
;
1153 info
[i
].value
= talloc_strdup(info
, password
);
1154 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
1159 info
[i
].name
= SHARE_MAX_CONNECTIONS
;
1160 info
[i
].type
= SHARE_INFO_INT
;
1161 info
[i
].value
= talloc(info
, int);
1162 *((int *)info
[i
].value
) = max_users
;
1167 info
[i
].name
= SHARE_TYPE
;
1168 info
[i
].type
= SHARE_INFO_STRING
;
1171 info
[i
].value
= talloc_strdup(info
, "DISK");
1174 info
[i
].value
= talloc_strdup(info
, "PRINTER");
1177 info
[i
].value
= talloc_strdup(info
, "IPC");
1180 return WERR_INVALID_PARAM
;
1182 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
1187 info
[i
].name
= SHARE_COMMENT
;
1188 info
[i
].type
= SHARE_INFO_STRING
;
1189 info
[i
].value
= talloc_strdup(info
, comment
);
1190 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
1196 strcasecmp(share_name
, name
) != 0) {
1197 info
[i
].name
= SHARE_NAME
;
1198 info
[i
].type
= SHARE_INFO_STRING
;
1199 info
[i
].value
= talloc_strdup(info
, name
);
1200 W_ERROR_HAVE_NO_MEMORY(info
[i
].value
);
1207 return WERR_UNKNOWN_LEVEL
;
1216 srvsvc_NetShareSetInfo
1218 static WERROR
dcesrv_srvsvc_NetShareSetInfo(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1219 struct srvsvc_NetShareSetInfo
*r
)
1223 struct share_context
*sctx
= NULL
;
1224 struct share_info
*info
;
1227 /* TODO: - access check
1230 /* there are no more than 10 options in all struct srvsvc_NetShareInfoXXX */
1231 info
= talloc_array(mem_ctx
, struct share_info
, 10);
1232 W_ERROR_HAVE_NO_MEMORY(info
);
1234 ZERO_STRUCT(r
->out
);
1236 if (strcmp("", r
->in
.share_name
) == 0) {
1237 return WERR_INVALID_PARAM
;
1240 nterr
= share_get_context_by_name(mem_ctx
, lp_share_backend(dce_call
->conn
->dce_ctx
->lp_ctx
), dce_call
->event_ctx
, dce_call
->conn
->dce_ctx
->lp_ctx
, &sctx
);
1241 if (!NT_STATUS_IS_OK(nterr
)) {
1242 return ntstatus_to_werror(nterr
);
1245 switch (r
->in
.level
) {
1248 status
= dcesrv_srvsvc_fill_share_info(info
, &count
,
1249 r
->in
.share_name
, r
->in
.level
,
1250 r
->in
.info
->info0
->name
,
1258 if (W_ERROR_EQUAL(status
, WERR_OK
)) {
1265 status
= dcesrv_srvsvc_fill_share_info(info
, &count
,
1266 r
->in
.share_name
, r
->in
.level
,
1267 r
->in
.info
->info1
->name
,
1269 r
->in
.info
->info1
->comment
,
1271 r
->in
.info
->info1
->type
,
1275 if (W_ERROR_EQUAL(status
, WERR_OK
)) {
1282 status
= dcesrv_srvsvc_fill_share_info(info
, &count
,
1283 r
->in
.share_name
, r
->in
.level
,
1284 r
->in
.info
->info2
->name
,
1285 r
->in
.info
->info2
->path
,
1286 r
->in
.info
->info2
->comment
,
1287 r
->in
.info
->info2
->password
,
1288 r
->in
.info
->info2
->type
,
1289 r
->in
.info
->info2
->max_users
,
1292 if (W_ERROR_EQUAL(status
, WERR_OK
)) {
1299 status
= dcesrv_srvsvc_fill_share_info(info
, &count
,
1300 r
->in
.share_name
, r
->in
.level
,
1301 r
->in
.info
->info501
->name
,
1303 r
->in
.info
->info501
->comment
,
1305 r
->in
.info
->info501
->type
,
1307 r
->in
.info
->info501
->csc_policy
,
1309 if (W_ERROR_EQUAL(status
, WERR_OK
)) {
1316 status
= dcesrv_srvsvc_fill_share_info(info
, &count
,
1317 r
->in
.share_name
, r
->in
.level
,
1318 r
->in
.info
->info502
->name
,
1319 r
->in
.info
->info502
->path
,
1320 r
->in
.info
->info502
->comment
,
1321 r
->in
.info
->info502
->password
,
1322 r
->in
.info
->info502
->type
,
1323 r
->in
.info
->info502
->max_users
,
1325 r
->in
.info
->info502
->sd_buf
.sd
);
1326 if (W_ERROR_EQUAL(status
, WERR_OK
)) {
1333 status
= dcesrv_srvsvc_fill_share_info(info
, &count
,
1334 r
->in
.share_name
, r
->in
.level
,
1337 r
->in
.info
->info1004
->comment
,
1343 if (W_ERROR_EQUAL(status
, WERR_OK
)) {
1350 /* r->in.info.dfs_flags; */
1352 if (r
->in
.parm_error
) {
1353 r
->out
.parm_error
= r
->in
.parm_error
;
1359 return WERR_UNKNOWN_LEVEL
;
1362 nterr
= share_set(sctx
, r
->in
.share_name
, info
, count
);
1363 if (!NT_STATUS_IS_OK(nterr
)) {
1364 return ntstatus_to_werror(nterr
);
1367 if (r
->in
.parm_error
) {
1368 r
->out
.parm_error
= r
->in
.parm_error
;
1376 srvsvc_NetShareDelSticky
1378 static WERROR
dcesrv_srvsvc_NetShareDelSticky(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1379 struct srvsvc_NetShareDelSticky
*r
)
1381 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
1386 srvsvc_NetShareCheck
1388 static WERROR
dcesrv_srvsvc_NetShareCheck(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1389 struct srvsvc_NetShareCheck
*r
)
1392 struct share_context
*sctx
= NULL
;
1393 struct share_config
*scfg
= NULL
;
1400 /* TODO: - access check
1403 if (strcmp("", r
->in
.device_name
) == 0) {
1404 *r
->out
.type
= STYPE_IPC
;
1408 /* copy the path skipping C:\ */
1409 if (strncasecmp(r
->in
.device_name
, "C:", 2) == 0) {
1410 device
= talloc_strdup(mem_ctx
, &r
->in
.device_name
[2]);
1412 /* no chance we have a share that doesn't start with C:\ */
1413 return WERR_DEVICE_NOT_SHARED
;
1415 all_string_sub(device
, "\\", "/", 0);
1417 nterr
= share_get_context_by_name(mem_ctx
, lp_share_backend(dce_call
->conn
->dce_ctx
->lp_ctx
), dce_call
->event_ctx
, dce_call
->conn
->dce_ctx
->lp_ctx
, &sctx
);
1418 if (!NT_STATUS_IS_OK(nterr
)) {
1419 return ntstatus_to_werror(nterr
);
1422 nterr
= share_list_all(mem_ctx
, sctx
, &count
, &names
);
1423 if (!NT_STATUS_IS_OK(nterr
)) {
1424 return ntstatus_to_werror(nterr
);
1427 for (i
= 0; i
< count
; i
++) {
1431 nterr
= share_get_config(mem_ctx
, sctx
, names
[i
], &scfg
);
1432 if (!NT_STATUS_IS_OK(nterr
)) {
1433 return ntstatus_to_werror(nterr
);
1435 path
= share_string_option(scfg
, SHARE_PATH
, NULL
);
1436 if (!path
) continue;
1438 if (strcmp(device
, path
) == 0) {
1439 type
= share_string_option(scfg
, SHARE_TYPE
, NULL
);
1440 if (!type
) continue;
1442 if (strcmp(type
, "DISK") == 0) {
1443 *r
->out
.type
= STYPE_DISKTREE
;
1447 if (strcmp(type
, "IPC") == 0) {
1448 *r
->out
.type
= STYPE_IPC
;
1452 if (strcmp(type
, "PRINTER") == 0) {
1453 *r
->out
.type
= STYPE_PRINTQ
;
1459 return WERR_DEVICE_NOT_SHARED
;
1464 srvsvc_NetSrvGetInfo
1466 static WERROR
dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1467 struct srvsvc_NetSrvGetInfo
*r
)
1469 struct dcesrv_context
*dce_ctx
= dce_call
->conn
->dce_ctx
;
1471 ZERO_STRUCTP(r
->out
.info
);
1473 switch (r
->in
.level
) {
1476 struct srvsvc_NetSrvInfo100
*info100
;
1478 info100
= talloc(mem_ctx
, struct srvsvc_NetSrvInfo100
);
1479 W_ERROR_HAVE_NO_MEMORY(info100
);
1481 info100
->platform_id
= dcesrv_common_get_platform_id(mem_ctx
, dce_ctx
);
1482 info100
->server_name
= dcesrv_common_get_server_name(mem_ctx
, dce_ctx
, r
->in
.server_unc
);
1483 W_ERROR_HAVE_NO_MEMORY(info100
->server_name
);
1485 r
->out
.info
->info100
= info100
;
1490 struct srvsvc_NetSrvInfo101
*info101
;
1492 info101
= talloc(mem_ctx
, struct srvsvc_NetSrvInfo101
);
1493 W_ERROR_HAVE_NO_MEMORY(info101
);
1495 info101
->platform_id
= dcesrv_common_get_platform_id(mem_ctx
, dce_ctx
);
1496 info101
->server_name
= dcesrv_common_get_server_name(mem_ctx
, dce_ctx
, r
->in
.server_unc
);
1497 W_ERROR_HAVE_NO_MEMORY(info101
->server_name
);
1499 info101
->version_major
= dcesrv_common_get_version_major(mem_ctx
, dce_ctx
->lp_ctx
);
1500 info101
->version_minor
= dcesrv_common_get_version_minor(mem_ctx
, dce_ctx
->lp_ctx
);
1501 info101
->server_type
= dcesrv_common_get_server_type(mem_ctx
, dce_call
->event_ctx
, dce_ctx
);
1502 info101
->comment
= talloc_strdup(mem_ctx
, lp_serverstring(dce_ctx
->lp_ctx
));
1503 W_ERROR_HAVE_NO_MEMORY(info101
->comment
);
1505 r
->out
.info
->info101
= info101
;
1510 struct srvsvc_NetSrvInfo102
*info102
;
1512 info102
= talloc(mem_ctx
, struct srvsvc_NetSrvInfo102
);
1513 W_ERROR_HAVE_NO_MEMORY(info102
);
1515 info102
->platform_id
= dcesrv_common_get_platform_id(mem_ctx
, dce_ctx
);
1516 info102
->server_name
= dcesrv_common_get_server_name(mem_ctx
, dce_ctx
, r
->in
.server_unc
);
1517 W_ERROR_HAVE_NO_MEMORY(info102
->server_name
);
1519 info102
->version_major
= dcesrv_common_get_version_major(mem_ctx
, dce_ctx
->lp_ctx
);
1520 info102
->version_minor
= dcesrv_common_get_version_minor(mem_ctx
, dce_ctx
->lp_ctx
);
1521 info102
->server_type
= dcesrv_common_get_server_type(mem_ctx
, dce_call
->event_ctx
, dce_ctx
);
1522 info102
->comment
= talloc_strdup(mem_ctx
, lp_serverstring(dce_ctx
->lp_ctx
));
1523 W_ERROR_HAVE_NO_MEMORY(info102
->comment
);
1525 info102
->users
= dcesrv_common_get_users(mem_ctx
, dce_ctx
);
1526 info102
->disc
= dcesrv_common_get_disc(mem_ctx
, dce_ctx
);
1527 info102
->hidden
= dcesrv_common_get_hidden(mem_ctx
, dce_ctx
);
1528 info102
->announce
= dcesrv_common_get_announce(mem_ctx
, dce_ctx
);
1529 info102
->anndelta
= dcesrv_common_get_anndelta(mem_ctx
, dce_ctx
);
1530 info102
->licenses
= dcesrv_common_get_licenses(mem_ctx
, dce_ctx
);
1531 info102
->userpath
= dcesrv_common_get_userpath(mem_ctx
, dce_ctx
);
1532 W_ERROR_HAVE_NO_MEMORY(info102
->userpath
);
1534 r
->out
.info
->info102
= info102
;
1538 return WERR_UNKNOWN_LEVEL
;
1541 return WERR_UNKNOWN_LEVEL
;
1546 srvsvc_NetSrvSetInfo
1548 static WERROR
dcesrv_srvsvc_NetSrvSetInfo(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1549 struct srvsvc_NetSrvSetInfo
*r
)
1551 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
1558 static WERROR
dcesrv_srvsvc_NetDiskEnum(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1559 struct srvsvc_NetDiskEnum
*r
)
1561 r
->out
.info
.disks
= NULL
;
1562 r
->out
.info
.count
= 0;
1563 r
->out
.totalentries
= 0;
1564 r
->out
.resume_handle
= NULL
;
1566 switch (r
->in
.level
) {
1569 /* we can safely hardcode the reply and report we have only one disk (C:) */
1570 /* for some reason Windows wants 2 entries with the second being empty */
1571 r
->out
.info
.disks
= talloc_array(mem_ctx
, struct srvsvc_NetDiskInfo0
, 2);
1572 W_ERROR_HAVE_NO_MEMORY(r
->out
.info
.disks
);
1573 r
->out
.info
.count
= 2;
1575 r
->out
.info
.disks
[0].disk
= talloc_strdup(mem_ctx
, "C:");
1576 W_ERROR_HAVE_NO_MEMORY(r
->out
.info
.disks
[0].disk
);
1578 r
->out
.info
.disks
[1].disk
= talloc_strdup(mem_ctx
, "");
1579 W_ERROR_HAVE_NO_MEMORY(r
->out
.info
.disks
[1].disk
);
1581 r
->out
.totalentries
= 1;
1582 r
->out
.resume_handle
= r
->in
.resume_handle
;
1587 return WERR_UNKNOWN_LEVEL
;
1590 return WERR_UNKNOWN_LEVEL
;
1595 srvsvc_NetServerStatisticsGet
1597 static WERROR
dcesrv_srvsvc_NetServerStatisticsGet(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1598 struct srvsvc_NetServerStatisticsGet
*r
)
1600 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
1605 srvsvc_NetTransportAdd
1607 static WERROR
dcesrv_srvsvc_NetTransportAdd(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1608 struct srvsvc_NetTransportAdd
*r
)
1610 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
1615 srvsvc_NetTransportEnum
1617 static WERROR
dcesrv_srvsvc_NetTransportEnum(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1618 struct srvsvc_NetTransportEnum
*r
)
1620 r
->out
.transports
->level
= r
->in
.transports
->level
;
1621 *r
->out
.totalentries
= 0;
1622 if (r
->out
.resume_handle
) {
1623 *r
->out
.resume_handle
= 0;
1626 switch (r
->in
.transports
->level
) {
1629 r
->out
.transports
->ctr
.ctr0
= talloc(mem_ctx
, struct srvsvc_NetTransportCtr0
);
1630 W_ERROR_HAVE_NO_MEMORY(r
->out
.transports
->ctr
.ctr0
);
1632 r
->out
.transports
->ctr
.ctr0
->count
= 0;
1633 r
->out
.transports
->ctr
.ctr0
->array
= NULL
;
1635 return WERR_NOT_SUPPORTED
;
1639 r
->out
.transports
->ctr
.ctr1
= talloc(mem_ctx
, struct srvsvc_NetTransportCtr1
);
1640 W_ERROR_HAVE_NO_MEMORY(r
->out
.transports
->ctr
.ctr1
);
1642 r
->out
.transports
->ctr
.ctr1
->count
= 0;
1643 r
->out
.transports
->ctr
.ctr1
->array
= NULL
;
1645 return WERR_NOT_SUPPORTED
;
1649 r
->out
.transports
->ctr
.ctr2
= talloc(mem_ctx
, struct srvsvc_NetTransportCtr2
);
1650 W_ERROR_HAVE_NO_MEMORY(r
->out
.transports
->ctr
.ctr2
);
1652 r
->out
.transports
->ctr
.ctr2
->count
= 0;
1653 r
->out
.transports
->ctr
.ctr2
->array
= NULL
;
1655 return WERR_NOT_SUPPORTED
;
1659 r
->out
.transports
->ctr
.ctr3
= talloc(mem_ctx
, struct srvsvc_NetTransportCtr3
);
1660 W_ERROR_HAVE_NO_MEMORY(r
->out
.transports
->ctr
.ctr3
);
1662 r
->out
.transports
->ctr
.ctr3
->count
= 0;
1663 r
->out
.transports
->ctr
.ctr3
->array
= NULL
;
1665 return WERR_NOT_SUPPORTED
;
1668 return WERR_UNKNOWN_LEVEL
;
1671 return WERR_UNKNOWN_LEVEL
;
1675 srvsvc_NetTransportDel
1677 static WERROR
dcesrv_srvsvc_NetTransportDel(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1678 struct srvsvc_NetTransportDel
*r
)
1680 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
1687 static WERROR
dcesrv_srvsvc_NetRemoteTOD(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1688 struct srvsvc_NetRemoteTOD
*r
)
1690 struct timeval tval
;
1693 struct srvsvc_NetRemoteTODInfo
*info
;
1695 info
= talloc(mem_ctx
, struct srvsvc_NetRemoteTODInfo
);
1696 W_ERROR_HAVE_NO_MEMORY(info
);
1698 GetTimeOfDay(&tval
);
1704 /* TODO: fake the uptime: just return the milliseconds till 0:00:00 today */
1705 info
->msecs
= (tm
.tm_hour
*60*60*1000)
1706 + (tm
.tm_min
*60*1000)
1708 + (tval
.tv_usec
/1000);
1709 info
->hours
= tm
.tm_hour
;
1710 info
->mins
= tm
.tm_min
;
1711 info
->secs
= tm
.tm_sec
;
1712 info
->hunds
= tval
.tv_usec
/10000;
1713 info
->timezone
= get_time_zone(t
)/60;
1714 info
->tinterval
= 310; /* just return the same as windows */
1715 info
->day
= tm
.tm_mday
;
1716 info
->month
= tm
.tm_mon
+ 1;
1717 info
->year
= tm
.tm_year
+ 1900;
1718 info
->weekday
= tm
.tm_wday
;
1720 *r
->out
.info
= info
;
1728 static WERROR
dcesrv_srvsvc_NetPathType(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1729 struct srvsvc_NetPathType
*r
)
1731 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
1736 srvsvc_NetPathCanonicalize
1738 static WERROR
dcesrv_srvsvc_NetPathCanonicalize(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1739 struct srvsvc_NetPathCanonicalize
*r
)
1741 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
1746 srvsvc_NetPathCompare
1748 static WERROR
dcesrv_srvsvc_NetPathCompare(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1749 struct srvsvc_NetPathCompare
*r
)
1751 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
1756 srvsvc_NetNameValidate
1758 static WERROR
dcesrv_srvsvc_NetNameValidate(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1759 struct srvsvc_NetNameValidate
*r
)
1763 if ((r
->in
.flags
!= 0x0) && (r
->in
.flags
!= 0x80000000)) {
1764 return WERR_INVALID_NAME
;
1767 switch (r
->in
.name_type
) {
1776 return WERR_NOT_SUPPORTED
;
1778 case 9: /* validate share name */
1780 len
= strlen_m(r
->in
.name
);
1781 if ((r
->in
.flags
== 0x0) && (len
> 81)) {
1782 return WERR_INVALID_NAME
;
1784 if ((r
->in
.flags
== 0x80000000) && (len
> 13)) {
1785 return WERR_INVALID_NAME
;
1787 if (! dcesrv_common_validate_share_name(mem_ctx
, r
->in
.name
)) {
1788 return WERR_INVALID_NAME
;
1796 return WERR_NOT_SUPPORTED
;
1798 return WERR_INVALID_PARAM
;
1801 return WERR_INVALID_PARAM
;
1806 srvsvc_NetPRNameCompare
1808 static WERROR
dcesrv_srvsvc_NetPRNameCompare(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1809 struct srvsvc_NetPRNameCompare
*r
)
1811 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
1818 static WERROR
dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
1819 struct srvsvc_NetShareEnum
*r
)
1823 const char **snames
;
1824 struct share_context
*sctx
;
1825 struct share_config
*scfg
;
1826 struct dcesrv_context
*dce_ctx
= dce_call
->conn
->dce_ctx
;
1828 r
->out
.level
= r
->in
.level
;
1829 ZERO_STRUCT(r
->out
.ctr
);
1830 r
->out
.totalentries
= 0;
1831 r
->out
.resume_handle
= NULL
;
1833 /* TODO: - paging of results
1836 nterr
= share_get_context_by_name(mem_ctx
, lp_share_backend(dce_call
->conn
->dce_ctx
->lp_ctx
), dce_call
->event_ctx
, dce_call
->conn
->dce_ctx
->lp_ctx
, &sctx
);
1837 if (!NT_STATUS_IS_OK(nterr
)) {
1838 return ntstatus_to_werror(nterr
);
1841 nterr
= share_list_all(mem_ctx
, sctx
, &numshares
, &snames
);
1842 if (!NT_STATUS_IS_OK(nterr
)) {
1843 return ntstatus_to_werror(nterr
);
1846 switch (r
->in
.level
) {
1851 struct srvsvc_NetShareCtr0
*ctr0
;
1853 ctr0
= talloc(mem_ctx
, struct srvsvc_NetShareCtr0
);
1854 W_ERROR_HAVE_NO_MEMORY(ctr0
);
1857 ctr0
->count
= count
;
1860 if (ctr0
->count
== 0) {
1861 r
->out
.ctr
.ctr0
= ctr0
;
1865 ctr0
->array
= talloc_array(mem_ctx
, struct srvsvc_NetShareInfo0
, count
);
1866 W_ERROR_HAVE_NO_MEMORY(ctr0
->array
);
1868 for (i
=0; i
< count
; i
++) {
1870 union srvsvc_NetShareInfo info
;
1871 enum srvsvc_ShareType type
;
1873 nterr
= share_get_config(mem_ctx
, sctx
, snames
[i
], &scfg
);
1874 if (!NT_STATUS_IS_OK(nterr
)) {
1875 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames
[i
]));
1876 return WERR_GENERAL_FAILURE
;
1879 type
= dcesrv_common_get_share_type(mem_ctx
, dce_ctx
, scfg
);
1880 if (type
& STYPE_HIDDEN
) {
1886 info
.info0
= &ctr0
->array
[y
];
1887 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
1888 W_ERROR_NOT_OK_RETURN(status
);
1892 talloc_free(snames
);
1894 r
->out
.ctr
.ctr0
= ctr0
;
1895 r
->out
.totalentries
= r
->out
.ctr
.ctr0
->count
;
1902 struct srvsvc_NetShareCtr1
*ctr1
;
1904 ctr1
= talloc(mem_ctx
, struct srvsvc_NetShareCtr1
);
1905 W_ERROR_HAVE_NO_MEMORY(ctr1
);
1908 ctr1
->count
= count
;
1911 if (ctr1
->count
== 0) {
1912 r
->out
.ctr
.ctr1
= ctr1
;
1916 ctr1
->array
= talloc_array(mem_ctx
, struct srvsvc_NetShareInfo1
, count
);
1917 W_ERROR_HAVE_NO_MEMORY(ctr1
->array
);
1919 for (i
=0; i
< count
; i
++) {
1921 union srvsvc_NetShareInfo info
;
1922 enum srvsvc_ShareType type
;
1924 nterr
= share_get_config(mem_ctx
, sctx
, snames
[i
], &scfg
);
1925 if (!NT_STATUS_IS_OK(nterr
)) {
1926 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames
[i
]));
1927 return WERR_GENERAL_FAILURE
;
1930 type
= dcesrv_common_get_share_type(mem_ctx
, dce_ctx
, scfg
);
1931 if (type
& STYPE_HIDDEN
) {
1937 info
.info1
= &ctr1
->array
[y
];
1938 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
1939 W_ERROR_NOT_OK_RETURN(status
);
1943 talloc_free(snames
);
1945 r
->out
.ctr
.ctr1
= ctr1
;
1946 r
->out
.totalentries
= r
->out
.ctr
.ctr1
->count
;
1953 struct srvsvc_NetShareCtr2
*ctr2
;
1955 SRVSVC_CHECK_ADMIN_ACCESS
;
1957 ctr2
= talloc(mem_ctx
, struct srvsvc_NetShareCtr2
);
1958 W_ERROR_HAVE_NO_MEMORY(ctr2
);
1961 ctr2
->count
= count
;
1964 if (ctr2
->count
== 0) {
1965 r
->out
.ctr
.ctr2
= ctr2
;
1969 ctr2
->array
= talloc_array(mem_ctx
, struct srvsvc_NetShareInfo2
, count
);
1970 W_ERROR_HAVE_NO_MEMORY(ctr2
->array
);
1972 for (i
=0; i
< count
; i
++) {
1974 union srvsvc_NetShareInfo info
;
1975 enum srvsvc_ShareType type
;
1977 nterr
= share_get_config(mem_ctx
, sctx
, snames
[i
], &scfg
);
1978 if (!NT_STATUS_IS_OK(nterr
)) {
1979 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames
[i
]));
1980 return WERR_GENERAL_FAILURE
;
1983 type
= dcesrv_common_get_share_type(mem_ctx
, dce_ctx
, scfg
);
1984 if (type
& STYPE_HIDDEN
) {
1990 info
.info2
= &ctr2
->array
[y
];
1991 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
1992 W_ERROR_NOT_OK_RETURN(status
);
1996 talloc_free(snames
);
1998 r
->out
.ctr
.ctr2
= ctr2
;
1999 r
->out
.totalentries
= r
->out
.ctr
.ctr2
->count
;
2006 struct srvsvc_NetShareCtr502
*ctr502
;
2008 SRVSVC_CHECK_ADMIN_ACCESS
;
2010 ctr502
= talloc(mem_ctx
, struct srvsvc_NetShareCtr502
);
2011 W_ERROR_HAVE_NO_MEMORY(ctr502
);
2014 ctr502
->count
= count
;
2015 ctr502
->array
= NULL
;
2017 if (ctr502
->count
== 0) {
2018 r
->out
.ctr
.ctr502
= ctr502
;
2022 ctr502
->array
= talloc_array(mem_ctx
, struct srvsvc_NetShareInfo502
, count
);
2023 W_ERROR_HAVE_NO_MEMORY(ctr502
->array
);
2025 for (i
=0; i
< count
; i
++) {
2027 union srvsvc_NetShareInfo info
;
2028 enum srvsvc_ShareType type
;
2030 nterr
= share_get_config(mem_ctx
, sctx
, snames
[i
], &scfg
);
2031 if (!NT_STATUS_IS_OK(nterr
)) {
2032 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames
[i
]));
2033 return WERR_GENERAL_FAILURE
;
2036 type
= dcesrv_common_get_share_type(mem_ctx
, dce_ctx
, scfg
);
2037 if (type
& STYPE_HIDDEN
) {
2043 info
.info502
= &ctr502
->array
[y
];
2044 status
= dcesrv_srvsvc_fiel_ShareInfo(dce_call
, mem_ctx
, scfg
, r
->in
.level
, &info
);
2045 W_ERROR_NOT_OK_RETURN(status
);
2049 talloc_free(snames
);
2051 r
->out
.ctr
.ctr502
= ctr502
;
2052 r
->out
.totalentries
= r
->out
.ctr
.ctr502
->count
;
2056 return WERR_UNKNOWN_LEVEL
;
2059 return WERR_UNKNOWN_LEVEL
;
2064 srvsvc_NetShareDelStart
2066 static WERROR
dcesrv_srvsvc_NetShareDelStart(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2067 struct srvsvc_NetShareDelStart
*r
)
2069 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2074 srvsvc_NetShareDelCommit
2076 static WERROR
dcesrv_srvsvc_NetShareDelCommit(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2077 struct srvsvc_NetShareDelCommit
*r
)
2079 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2084 srvsvc_NetGetFileSecurity
2086 static WERROR
dcesrv_srvsvc_NetGetFileSecurity(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2087 struct srvsvc_NetGetFileSecurity
*r
)
2089 struct sec_desc_buf
*sd_buf
;
2090 struct ntvfs_context
*ntvfs_ctx
= NULL
;
2091 struct ntvfs_request
*ntvfs_req
;
2092 union smb_fileinfo
*io
;
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
,
2103 W_ERROR_HAVE_NO_MEMORY(ntvfs_req
);
2105 sd_buf
= talloc(mem_ctx
, struct sec_desc_buf
);
2106 W_ERROR_HAVE_NO_MEMORY(sd_buf
);
2108 io
= talloc(mem_ctx
, union smb_fileinfo
);
2109 W_ERROR_HAVE_NO_MEMORY(io
);
2111 io
->query_secdesc
.level
= RAW_FILEINFO_SEC_DESC
;
2112 io
->query_secdesc
.in
.file
.path
= r
->in
.file
;
2113 io
->query_secdesc
.in
.secinfo_flags
= r
->in
.securityinformation
;
2115 nt_status
= ntvfs_qpathinfo(ntvfs_req
, io
);
2116 if (!NT_STATUS_IS_OK(nt_status
)) return ntstatus_to_werror(nt_status
);
2118 sd_buf
->sd
= io
->query_secdesc
.out
.sd
;
2120 *r
->out
.sd_buf
= sd_buf
;
2126 srvsvc_NetSetFileSecurity
2128 static WERROR
dcesrv_srvsvc_NetSetFileSecurity(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2129 struct srvsvc_NetSetFileSecurity
*r
)
2131 struct ntvfs_context
*ntvfs_ctx
;
2132 struct ntvfs_request
*ntvfs_req
;
2133 union smb_setfileinfo
*io
;
2136 nt_status
= srvsvc_create_ntvfs_context(dce_call
, mem_ctx
, r
->in
.share
, &ntvfs_ctx
);
2137 if (!NT_STATUS_IS_OK(nt_status
)) return ntstatus_to_werror(nt_status
);
2139 ntvfs_req
= ntvfs_request_create(ntvfs_ctx
, mem_ctx
,
2140 dce_call
->conn
->auth_state
.session_info
,
2144 W_ERROR_HAVE_NO_MEMORY(ntvfs_req
);
2146 io
= talloc(mem_ctx
, union smb_setfileinfo
);
2147 W_ERROR_HAVE_NO_MEMORY(io
);
2149 io
->set_secdesc
.level
= RAW_FILEINFO_SEC_DESC
;
2150 io
->set_secdesc
.in
.file
.path
= r
->in
.file
;
2151 io
->set_secdesc
.in
.secinfo_flags
= r
->in
.securityinformation
;
2152 io
->set_secdesc
.in
.sd
= r
->in
.sd_buf
->sd
;
2154 nt_status
= ntvfs_setpathinfo(ntvfs_req
, io
);
2155 if (!NT_STATUS_IS_OK(nt_status
)) return ntstatus_to_werror(nt_status
);
2162 srvsvc_NetServerTransportAddEx
2164 static WERROR
dcesrv_srvsvc_NetServerTransportAddEx(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2165 struct srvsvc_NetServerTransportAddEx
*r
)
2167 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2172 srvsvc_NetServerSetServiceBitsEx
2174 static WERROR
dcesrv_srvsvc_NetServerSetServiceBitsEx(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2175 struct srvsvc_NetServerSetServiceBitsEx
*r
)
2177 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2182 srvsvc_NETRDFSGETVERSION
2184 static WERROR
dcesrv_srvsvc_NETRDFSGETVERSION(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2185 struct srvsvc_NETRDFSGETVERSION
*r
)
2187 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2192 srvsvc_NETRDFSCREATELOCALPARTITION
2194 static WERROR
dcesrv_srvsvc_NETRDFSCREATELOCALPARTITION(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2195 struct srvsvc_NETRDFSCREATELOCALPARTITION
*r
)
2197 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2202 srvsvc_NETRDFSDELETELOCALPARTITION
2204 static WERROR
dcesrv_srvsvc_NETRDFSDELETELOCALPARTITION(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2205 struct srvsvc_NETRDFSDELETELOCALPARTITION
*r
)
2207 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2212 srvsvc_NETRDFSSETLOCALVOLUMESTATE
2214 static WERROR
dcesrv_srvsvc_NETRDFSSETLOCALVOLUMESTATE(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2215 struct srvsvc_NETRDFSSETLOCALVOLUMESTATE
*r
)
2217 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2222 srvsvc_NETRDFSSETSERVERINFO
2224 static WERROR
dcesrv_srvsvc_NETRDFSSETSERVERINFO(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2225 struct srvsvc_NETRDFSSETSERVERINFO
*r
)
2227 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2232 srvsvc_NETRDFSCREATEEXITPOINT
2234 static WERROR
dcesrv_srvsvc_NETRDFSCREATEEXITPOINT(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2235 struct srvsvc_NETRDFSCREATEEXITPOINT
*r
)
2237 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2242 srvsvc_NETRDFSDELETEEXITPOINT
2244 static WERROR
dcesrv_srvsvc_NETRDFSDELETEEXITPOINT(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2245 struct srvsvc_NETRDFSDELETEEXITPOINT
*r
)
2247 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2252 srvsvc_NETRDFSMODIFYPREFIX
2254 static WERROR
dcesrv_srvsvc_NETRDFSMODIFYPREFIX(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2255 struct srvsvc_NETRDFSMODIFYPREFIX
*r
)
2257 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2262 srvsvc_NETRDFSFIXLOCALVOLUME
2264 static WERROR
dcesrv_srvsvc_NETRDFSFIXLOCALVOLUME(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2265 struct srvsvc_NETRDFSFIXLOCALVOLUME
*r
)
2267 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2272 srvsvc_NETRDFSMANAGERREPORTSITEINFO
2274 static WERROR
dcesrv_srvsvc_NETRDFSMANAGERREPORTSITEINFO(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2275 struct srvsvc_NETRDFSMANAGERREPORTSITEINFO
*r
)
2277 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2282 srvsvc_NETRSERVERTRANSPORTDELEX
2284 static WERROR
dcesrv_srvsvc_NETRSERVERTRANSPORTDELEX(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2285 struct srvsvc_NETRSERVERTRANSPORTDELEX
*r
)
2287 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2293 static WERROR
dcesrv_srvsvc_NetShareDel(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2294 struct srvsvc_NetShareDel
*r
)
2297 struct share_context
*sctx
;
2299 nterr
= share_get_context_by_name(mem_ctx
, lp_share_backend(dce_call
->conn
->dce_ctx
->lp_ctx
), dce_call
->event_ctx
, dce_call
->conn
->dce_ctx
->lp_ctx
, &sctx
);
2300 if (!NT_STATUS_IS_OK(nterr
)) {
2301 return ntstatus_to_werror(nterr
);
2304 nterr
= share_remove(sctx
, r
->in
.share_name
);
2305 if (!NT_STATUS_IS_OK(nterr
)) {
2306 return ntstatus_to_werror(nterr
);
2313 srvsvc_NetSetServiceBits
2315 static WERROR
dcesrv_srvsvc_NetSetServiceBits(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2316 struct srvsvc_NetSetServiceBits
*r
)
2318 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2322 srvsvc_NETRPRNAMECANONICALIZE
2324 static WERROR
dcesrv_srvsvc_NETRPRNAMECANONICALIZE(struct dcesrv_call_state
*dce_call
, TALLOC_CTX
*mem_ctx
,
2325 struct srvsvc_NETRPRNAMECANONICALIZE
*r
)
2327 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR
);
2330 /* include the generated boilerplate */
2331 #include "librpc/gen_ndr/ndr_srvsvc_s.c"