2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-1997,
5 * Copyright (C) Jeremy Allison 2001.
6 * Copyright (C) Nigel Williams 2001.
7 * Copyright (C) Gerald (Jerry) Carter 2006.
8 * Copyright (C) Guenther Deschner 2008.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, see <http://www.gnu.org/licenses/>.
24 /* This is the implementation of the srvsvc pipe. */
28 extern const struct generic_mapping file_generic_mapping
;
31 #define DBGC_CLASS DBGC_RPC_SRV
33 #define MAX_SERVER_DISK_ENTRIES 15
35 /* Use for enumerating connections, pipes, & files */
37 struct file_enum_count
{
40 struct srvsvc_NetFileCtr3
*ctr3
;
43 struct sess_file_count
{
49 /****************************************************************************
50 Count the entries belonging to a service in the connection db.
51 ****************************************************************************/
53 static int pipe_enum_fn( struct db_record
*rec
, void *p
)
55 struct pipe_open_rec prec
;
56 struct file_enum_count
*fenum
= (struct file_enum_count
*)p
;
57 struct srvsvc_NetFileInfo3
*f
;
58 int i
= fenum
->ctr3
->count
;
59 char *fullpath
= NULL
;
62 if (rec
->value
.dsize
!= sizeof(struct pipe_open_rec
))
65 memcpy(&prec
, rec
->value
.dptr
, sizeof(struct pipe_open_rec
));
67 if ( !process_exists(prec
.pid
) ) {
71 username
= uidtoname(prec
.uid
);
73 if ((fenum
->username
!= NULL
)
74 && !strequal(username
, fenum
->username
)) {
78 fullpath
= talloc_asprintf(fenum
->ctx
, "\\PIPE\\%s", prec
.name
);
83 f
= TALLOC_REALLOC_ARRAY(fenum
->ctx
, fenum
->ctr3
->array
,
84 struct srvsvc_NetFileInfo3
, i
+1);
86 DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i
+1));
89 fenum
->ctr3
->array
= f
;
91 init_srvsvc_NetFileInfo3(&fenum
->ctr3
->array
[i
],
92 (((uint32_t)(procid_to_pid(&prec
.pid
))<<16) | prec
.pnum
),
93 (FILE_READ_DATA
|FILE_WRITE_DATA
),
103 /*******************************************************************
104 ********************************************************************/
106 static WERROR
net_enum_pipes(TALLOC_CTX
*ctx
,
107 const char *username
,
108 struct srvsvc_NetFileCtr3
**ctr3
,
111 struct file_enum_count fenum
;
114 fenum
.username
= username
;
117 if (connections_traverse(pipe_enum_fn
, &fenum
) == -1) {
118 DEBUG(0,("net_enum_pipes: traverse of connections.tdb "
128 /*******************************************************************
129 ********************************************************************/
131 static void enum_file_fn( const struct share_mode_entry
*e
,
132 const char *sharepath
, const char *fname
,
135 struct file_enum_count
*fenum
=
136 (struct file_enum_count
*)private_data
;
138 struct srvsvc_NetFileInfo3
*f
;
139 int i
= fenum
->ctr3
->count
;
141 struct byte_range_lock
*brl
;
143 char *fullpath
= NULL
;
145 const char *username
;
147 /* If the pid was not found delete the entry from connections.tdb */
149 if ( !process_exists(e
->pid
) ) {
153 username
= uidtoname(e
->uid
);
155 if ((fenum
->username
!= NULL
)
156 && !strequal(username
, fenum
->username
)) {
160 f
= TALLOC_REALLOC_ARRAY(fenum
->ctx
, fenum
->ctr3
->array
,
161 struct srvsvc_NetFileInfo3
, i
+1);
163 DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i
+1));
166 fenum
->ctr3
->array
= f
;
168 /* need to count the number of locks on a file */
173 if ( (brl
= brl_get_locks(talloc_tos(), &fsp
)) != NULL
) {
174 num_locks
= brl
->num_locks
;
178 if ( strcmp( fname
, "." ) == 0 ) {
179 fullpath
= talloc_asprintf(fenum
->ctx
, "C:%s", sharepath
);
181 fullpath
= talloc_asprintf(fenum
->ctx
, "C:%s/%s",
187 string_replace( fullpath
, '/', '\\' );
189 /* mask out create (what ever that is) */
190 permissions
= e
->access_mask
& (FILE_READ_DATA
|FILE_WRITE_DATA
);
192 /* now fill in the srvsvc_NetFileInfo3 struct */
193 init_srvsvc_NetFileInfo3(&fenum
->ctr3
->array
[i
],
194 (((uint32_t)(procid_to_pid(&e
->pid
))<<16) | e
->share_file_id
),
199 fenum
->ctr3
->count
++;
202 /*******************************************************************
203 ********************************************************************/
205 static WERROR
net_enum_files(TALLOC_CTX
*ctx
,
206 const char *username
,
207 struct srvsvc_NetFileCtr3
**ctr3
,
210 struct file_enum_count f_enum_cnt
;
212 f_enum_cnt
.ctx
= ctx
;
213 f_enum_cnt
.username
= username
;
214 f_enum_cnt
.ctr3
= *ctr3
;
216 share_mode_forall( enum_file_fn
, (void *)&f_enum_cnt
);
218 *ctr3
= f_enum_cnt
.ctr3
;
223 /*******************************************************************
224 Utility function to get the 'type' of a share from an snum.
225 ********************************************************************/
226 static uint32
get_share_type(int snum
)
228 /* work out the share type */
229 uint32 type
= STYPE_DISKTREE
;
231 if (lp_print_ok(snum
))
233 if (strequal(lp_fstype(snum
), "IPC"))
235 if (lp_administrative_share(snum
))
236 type
|= STYPE_HIDDEN
;
241 /*******************************************************************
242 Fill in a share info level 0 structure.
243 ********************************************************************/
245 static void init_srv_share_info_0(pipes_struct
*p
, struct srvsvc_NetShareInfo0
*r
, int snum
)
247 const char *net_name
= lp_servicename(snum
);
249 init_srvsvc_NetShareInfo0(r
, net_name
);
252 /*******************************************************************
253 Fill in a share info level 1 structure.
254 ********************************************************************/
256 static void init_srv_share_info_1(pipes_struct
*p
, struct srvsvc_NetShareInfo1
*r
, int snum
)
258 char *net_name
= lp_servicename(snum
);
259 char *remark
= talloc_strdup(p
->mem_ctx
, lp_comment(snum
));
262 remark
= talloc_sub_advanced(
263 p
->mem_ctx
, lp_servicename(snum
),
264 get_current_username(), lp_pathname(snum
),
265 p
->pipe_user
.ut
.uid
, get_current_username(),
269 init_srvsvc_NetShareInfo1(r
, net_name
,
270 get_share_type(snum
),
271 remark
? remark
: "");
274 /*******************************************************************
275 Fill in a share info level 2 structure.
276 ********************************************************************/
278 static void init_srv_share_info_2(pipes_struct
*p
, struct srvsvc_NetShareInfo2
*r
, int snum
)
282 int max_connections
= lp_max_connections(snum
);
283 uint32_t max_uses
= max_connections
!=0 ? max_connections
: (uint32_t)-1;
285 char *net_name
= lp_servicename(snum
);
287 remark
= talloc_strdup(p
->mem_ctx
, lp_comment(snum
));
289 remark
= talloc_sub_advanced(
290 p
->mem_ctx
, lp_servicename(snum
),
291 get_current_username(), lp_pathname(snum
),
292 p
->pipe_user
.ut
.uid
, get_current_username(),
295 path
= talloc_asprintf(p
->mem_ctx
,
296 "C:%s", lp_pathname(snum
));
300 * Change / to \\ so that win2k will see it as a valid path.
301 * This was added to enable use of browsing in win2k add
305 string_replace(path
, '/', '\\');
308 count
= count_current_connections(net_name
, false);
310 init_srvsvc_NetShareInfo2(r
, net_name
,
311 get_share_type(snum
),
312 remark
? remark
: "",
320 /*******************************************************************
321 Map any generic bits to file specific bits.
322 ********************************************************************/
324 static void map_generic_share_sd_bits(SEC_DESC
*psd
)
327 SEC_ACL
*ps_dacl
= NULL
;
336 for (i
= 0; i
< ps_dacl
->num_aces
; i
++) {
337 SEC_ACE
*psa
= &ps_dacl
->aces
[i
];
338 uint32 orig_mask
= psa
->access_mask
;
340 se_map_generic(&psa
->access_mask
, &file_generic_mapping
);
341 psa
->access_mask
|= orig_mask
;
345 /*******************************************************************
346 Fill in a share info level 501 structure.
347 ********************************************************************/
349 static void init_srv_share_info_501(pipes_struct
*p
, struct srvsvc_NetShareInfo501
*r
, int snum
)
351 const char *net_name
= lp_servicename(snum
);
352 char *remark
= talloc_strdup(p
->mem_ctx
, lp_comment(snum
));
355 remark
= talloc_sub_advanced(
356 p
->mem_ctx
, lp_servicename(snum
),
357 get_current_username(), lp_pathname(snum
),
358 p
->pipe_user
.ut
.uid
, get_current_username(),
362 init_srvsvc_NetShareInfo501(r
, net_name
,
363 get_share_type(snum
),
364 remark
? remark
: "",
365 (lp_csc_policy(snum
) << 4));
368 /*******************************************************************
369 Fill in a share info level 502 structure.
370 ********************************************************************/
372 static void init_srv_share_info_502(pipes_struct
*p
, struct srvsvc_NetShareInfo502
*r
, int snum
)
374 const char *net_name
= lp_servicename(snum
);
377 struct sec_desc_buf
*sd_buf
= NULL
;
379 TALLOC_CTX
*ctx
= p
->mem_ctx
;
380 char *remark
= talloc_strdup(ctx
, lp_comment(snum
));;
383 remark
= talloc_sub_advanced(
384 p
->mem_ctx
, lp_servicename(snum
),
385 get_current_username(), lp_pathname(snum
),
386 p
->pipe_user
.ut
.uid
, get_current_username(),
389 path
= talloc_asprintf(ctx
, "C:%s", lp_pathname(snum
));
392 * Change / to \\ so that win2k will see it as a valid path. This was added to
393 * enable use of browsing in win2k add share dialog.
395 string_replace(path
, '/', '\\');
398 sd
= get_share_security(ctx
, lp_servicename(snum
), &sd_size
);
400 sd_buf
= make_sec_desc_buf(p
->mem_ctx
, sd_size
, sd
);
402 init_srvsvc_NetShareInfo502(r
, net_name
,
403 get_share_type(snum
),
404 remark
? remark
: "",
413 /***************************************************************************
414 Fill in a share info level 1004 structure.
415 ***************************************************************************/
417 static void init_srv_share_info_1004(pipes_struct
*p
, struct srvsvc_NetShareInfo1004
*r
, int snum
)
419 char *remark
= talloc_strdup(p
->mem_ctx
, lp_comment(snum
));
422 remark
= talloc_sub_advanced(
423 p
->mem_ctx
, lp_servicename(snum
),
424 get_current_username(), lp_pathname(snum
),
425 p
->pipe_user
.ut
.uid
, get_current_username(),
429 init_srvsvc_NetShareInfo1004(r
, remark
? remark
: "");
432 /***************************************************************************
433 Fill in a share info level 1005 structure.
434 ***************************************************************************/
436 static void init_srv_share_info_1005(pipes_struct
*p
, struct srvsvc_NetShareInfo1005
*r
, int snum
)
438 uint32_t dfs_flags
= 0;
440 if (lp_host_msdfs() && lp_msdfs_root(snum
)) {
441 dfs_flags
|= SHARE_1005_IN_DFS
| SHARE_1005_DFS_ROOT
;
444 dfs_flags
|= lp_csc_policy(snum
) << SHARE_1005_CSC_POLICY_SHIFT
;
446 init_srvsvc_NetShareInfo1005(r
, dfs_flags
);
449 /***************************************************************************
450 Fill in a share info level 1006 structure.
451 ***************************************************************************/
453 static void init_srv_share_info_1006(pipes_struct
*p
, struct srvsvc_NetShareInfo1006
*r
, int snum
)
455 init_srvsvc_NetShareInfo1006(r
, (uint32_t)-1);
458 /***************************************************************************
459 Fill in a share info level 1007 structure.
460 ***************************************************************************/
462 static void init_srv_share_info_1007(pipes_struct
*p
, struct srvsvc_NetShareInfo1007
*r
, int snum
)
466 init_srvsvc_NetShareInfo1007(r
, flags
, "");
469 /*******************************************************************
470 Fill in a share info level 1501 structure.
471 ********************************************************************/
473 static void init_srv_share_info_1501(pipes_struct
*p
, struct sec_desc_buf
*r
, int snum
)
477 TALLOC_CTX
*ctx
= p
->mem_ctx
;
479 sd
= get_share_security(ctx
, lp_servicename(snum
), &sd_size
);
481 r
= make_sec_desc_buf(p
->mem_ctx
, sd_size
, sd
);
484 /*******************************************************************
485 True if it ends in '$'.
486 ********************************************************************/
488 static bool is_hidden_share(int snum
)
490 const char *net_name
= lp_servicename(snum
);
492 return (net_name
[strlen(net_name
) - 1] == '$') ? True
: False
;
495 /*******************************************************************
496 Fill in a share info structure.
497 ********************************************************************/
499 static WERROR
init_srv_share_info_ctr(pipes_struct
*p
,
500 struct srvsvc_NetShareInfoCtr
*info_ctr
,
501 uint32_t *resume_handle_p
,
502 uint32_t *total_entries
,
506 int alloc_entries
= 0;
507 int num_services
= 0;
509 TALLOC_CTX
*ctx
= p
->mem_ctx
;
511 int valid_share_count
= 0;
512 union srvsvc_NetShareCtr ctr
;
513 uint32_t resume_handle
= resume_handle_p
? *resume_handle_p
: 0;
515 DEBUG(5,("init_srv_share_info_ctr\n"));
517 /* Ensure all the usershares are loaded. */
519 load_usershare_shares();
520 load_registry_shares();
521 num_services
= lp_numservices();
524 /* Count the number of entries. */
525 for (snum
= 0; snum
< num_services
; snum
++) {
526 if (lp_browseable(snum
) && lp_snum_ok(snum
) && (all_shares
|| !is_hidden_share(snum
)) ) {
527 DEBUG(10, ("counting service %s\n", lp_servicename(snum
)));
530 DEBUG(10, ("NOT counting service %s\n", lp_servicename(snum
)));
534 if (!num_entries
|| (resume_handle
>= num_entries
)) {
538 /* Calculate alloc entries. */
539 alloc_entries
= num_entries
- resume_handle
;
540 switch (info_ctr
->level
) {
542 ctr
.ctr0
= TALLOC_ZERO_P(ctx
, struct srvsvc_NetShareCtr0
);
543 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr0
);
545 ctr
.ctr0
->count
= alloc_entries
;
546 ctr
.ctr0
->array
= TALLOC_ZERO_ARRAY(ctx
, struct srvsvc_NetShareInfo0
, alloc_entries
);
547 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr0
->array
);
549 for (snum
= 0; snum
< num_services
; snum
++) {
550 if (lp_browseable(snum
) && lp_snum_ok(snum
) && (all_shares
|| !is_hidden_share(snum
)) &&
551 (resume_handle
<= (i
+ valid_share_count
++)) ) {
552 init_srv_share_info_0(p
, &ctr
.ctr0
->array
[i
++], snum
);
559 ctr
.ctr1
= TALLOC_ZERO_P(ctx
, struct srvsvc_NetShareCtr1
);
560 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr1
);
562 ctr
.ctr1
->count
= alloc_entries
;
563 ctr
.ctr1
->array
= TALLOC_ZERO_ARRAY(ctx
, struct srvsvc_NetShareInfo1
, alloc_entries
);
564 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr1
->array
);
566 for (snum
= 0; snum
< num_services
; snum
++) {
567 if (lp_browseable(snum
) && lp_snum_ok(snum
) && (all_shares
|| !is_hidden_share(snum
)) &&
568 (resume_handle
<= (i
+ valid_share_count
++)) ) {
569 init_srv_share_info_1(p
, &ctr
.ctr1
->array
[i
++], snum
);
576 ctr
.ctr2
= TALLOC_ZERO_P(ctx
, struct srvsvc_NetShareCtr2
);
577 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr2
);
579 ctr
.ctr2
->count
= alloc_entries
;
580 ctr
.ctr2
->array
= TALLOC_ZERO_ARRAY(ctx
, struct srvsvc_NetShareInfo2
, alloc_entries
);
581 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr2
->array
);
583 for (snum
= 0; snum
< num_services
; snum
++) {
584 if (lp_browseable(snum
) && lp_snum_ok(snum
) && (all_shares
|| !is_hidden_share(snum
)) &&
585 (resume_handle
<= (i
+ valid_share_count
++)) ) {
586 init_srv_share_info_2(p
, &ctr
.ctr2
->array
[i
++], snum
);
593 ctr
.ctr501
= TALLOC_ZERO_P(ctx
, struct srvsvc_NetShareCtr501
);
594 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr501
);
596 ctr
.ctr501
->count
= alloc_entries
;
597 ctr
.ctr501
->array
= TALLOC_ZERO_ARRAY(ctx
, struct srvsvc_NetShareInfo501
, alloc_entries
);
598 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr501
->array
);
600 for (snum
= 0; snum
< num_services
; snum
++) {
601 if (lp_browseable(snum
) && lp_snum_ok(snum
) && (all_shares
|| !is_hidden_share(snum
)) &&
602 (resume_handle
<= (i
+ valid_share_count
++)) ) {
603 init_srv_share_info_501(p
, &ctr
.ctr501
->array
[i
++], snum
);
610 ctr
.ctr502
= TALLOC_ZERO_P(ctx
, struct srvsvc_NetShareCtr502
);
611 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr502
);
613 ctr
.ctr502
->count
= alloc_entries
;
614 ctr
.ctr502
->array
= TALLOC_ZERO_ARRAY(ctx
, struct srvsvc_NetShareInfo502
, alloc_entries
);
615 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr502
->array
);
617 for (snum
= 0; snum
< num_services
; snum
++) {
618 if (lp_browseable(snum
) && lp_snum_ok(snum
) && (all_shares
|| !is_hidden_share(snum
)) &&
619 (resume_handle
<= (i
+ valid_share_count
++)) ) {
620 init_srv_share_info_502(p
, &ctr
.ctr502
->array
[i
++], snum
);
627 ctr
.ctr1004
= TALLOC_ZERO_P(ctx
, struct srvsvc_NetShareCtr1004
);
628 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr1004
);
630 ctr
.ctr1004
->count
= alloc_entries
;
631 ctr
.ctr1004
->array
= TALLOC_ZERO_ARRAY(ctx
, struct srvsvc_NetShareInfo1004
, alloc_entries
);
632 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr1004
->array
);
634 for (snum
= 0; snum
< num_services
; snum
++) {
635 if (lp_browseable(snum
) && lp_snum_ok(snum
) && (all_shares
|| !is_hidden_share(snum
)) &&
636 (resume_handle
<= (i
+ valid_share_count
++)) ) {
637 init_srv_share_info_1004(p
, &ctr
.ctr1004
->array
[i
++], snum
);
644 ctr
.ctr1005
= TALLOC_ZERO_P(ctx
, struct srvsvc_NetShareCtr1005
);
645 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr1005
);
647 ctr
.ctr1005
->count
= alloc_entries
;
648 ctr
.ctr1005
->array
= TALLOC_ZERO_ARRAY(ctx
, struct srvsvc_NetShareInfo1005
, alloc_entries
);
649 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr1005
->array
);
651 for (snum
= 0; snum
< num_services
; snum
++) {
652 if (lp_browseable(snum
) && lp_snum_ok(snum
) && (all_shares
|| !is_hidden_share(snum
)) &&
653 (resume_handle
<= (i
+ valid_share_count
++)) ) {
654 init_srv_share_info_1005(p
, &ctr
.ctr1005
->array
[i
++], snum
);
661 ctr
.ctr1006
= TALLOC_ZERO_P(ctx
, struct srvsvc_NetShareCtr1006
);
662 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr1006
);
664 ctr
.ctr1006
->count
= alloc_entries
;
665 ctr
.ctr1006
->array
= TALLOC_ZERO_ARRAY(ctx
, struct srvsvc_NetShareInfo1006
, alloc_entries
);
666 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr1006
->array
);
668 for (snum
= 0; snum
< num_services
; snum
++) {
669 if (lp_browseable(snum
) && lp_snum_ok(snum
) && (all_shares
|| !is_hidden_share(snum
)) &&
670 (resume_handle
<= (i
+ valid_share_count
++)) ) {
671 init_srv_share_info_1006(p
, &ctr
.ctr1006
->array
[i
++], snum
);
678 ctr
.ctr1007
= TALLOC_ZERO_P(ctx
, struct srvsvc_NetShareCtr1007
);
679 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr1007
);
681 ctr
.ctr1007
->count
= alloc_entries
;
682 ctr
.ctr1007
->array
= TALLOC_ZERO_ARRAY(ctx
, struct srvsvc_NetShareInfo1007
, alloc_entries
);
683 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr1007
->array
);
685 for (snum
= 0; snum
< num_services
; snum
++) {
686 if (lp_browseable(snum
) && lp_snum_ok(snum
) && (all_shares
|| !is_hidden_share(snum
)) &&
687 (resume_handle
<= (i
+ valid_share_count
++)) ) {
688 init_srv_share_info_1007(p
, &ctr
.ctr1007
->array
[i
++], snum
);
695 ctr
.ctr1501
= TALLOC_ZERO_P(ctx
, struct srvsvc_NetShareCtr1501
);
696 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr1501
);
698 ctr
.ctr1501
->count
= alloc_entries
;
699 ctr
.ctr1501
->array
= TALLOC_ZERO_ARRAY(ctx
, struct sec_desc_buf
, alloc_entries
);
700 W_ERROR_HAVE_NO_MEMORY(ctr
.ctr1501
->array
);
702 for (snum
= 0; snum
< num_services
; snum
++) {
703 if (lp_browseable(snum
) && lp_snum_ok(snum
) && (all_shares
|| !is_hidden_share(snum
)) &&
704 (resume_handle
<= (i
+ valid_share_count
++)) ) {
705 init_srv_share_info_1501(p
, &ctr
.ctr1501
->array
[i
++], snum
);
712 DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n",
714 return WERR_UNKNOWN_LEVEL
;
717 *total_entries
= alloc_entries
;
718 if (resume_handle_p
) {
720 *resume_handle_p
= (num_entries
== 0) ? *resume_handle_p
: 0;
722 *resume_handle_p
= num_entries
;
731 /*******************************************************************
732 fill in a sess info level 0 structure.
733 ********************************************************************/
735 static WERROR
init_srv_sess_info_0(pipes_struct
*p
,
736 struct srvsvc_NetSessCtr0
*ctr0
,
737 uint32_t *resume_handle_p
,
738 uint32_t *total_entries
)
740 struct sessionid
*session_list
;
741 uint32_t num_entries
= 0;
742 uint32_t resume_handle
= resume_handle_p
? *resume_handle_p
: 0;
743 *total_entries
= list_sessions(p
->mem_ctx
, &session_list
);
745 DEBUG(5,("init_srv_sess_info_0\n"));
748 if (resume_handle_p
) {
749 *resume_handle_p
= 0;
754 for (; resume_handle
< *total_entries
; resume_handle
++) {
756 ctr0
->array
= TALLOC_REALLOC_ARRAY(p
->mem_ctx
,
758 struct srvsvc_NetSessInfo0
,
760 W_ERROR_HAVE_NO_MEMORY(ctr0
->array
);
762 init_srvsvc_NetSessInfo0(&ctr0
->array
[num_entries
],
763 session_list
[resume_handle
].remote_machine
);
767 ctr0
->count
= num_entries
;
769 if (resume_handle_p
) {
770 if (*resume_handle_p
>= *total_entries
) {
771 *resume_handle_p
= 0;
773 *resume_handle_p
= resume_handle
;
780 /*******************************************************************
781 ********************************************************************/
783 static void sess_file_fn( const struct share_mode_entry
*e
,
784 const char *sharepath
, const char *fname
,
787 struct sess_file_count
*sess
= (struct sess_file_count
*)data
;
789 if ( procid_equal(&e
->pid
, &sess
->pid
) && (sess
->uid
== e
->uid
) ) {
796 /*******************************************************************
797 ********************************************************************/
799 static int net_count_files( uid_t uid
, struct server_id pid
)
801 struct sess_file_count s_file_cnt
;
803 s_file_cnt
.count
= 0;
804 s_file_cnt
.uid
= uid
;
805 s_file_cnt
.pid
= pid
;
807 share_mode_forall( sess_file_fn
, &s_file_cnt
);
809 return s_file_cnt
.count
;
812 /*******************************************************************
813 fill in a sess info level 1 structure.
814 ********************************************************************/
816 static WERROR
init_srv_sess_info_1(pipes_struct
*p
,
817 struct srvsvc_NetSessCtr1
*ctr1
,
818 uint32_t *resume_handle_p
,
819 uint32_t *total_entries
)
821 struct sessionid
*session_list
;
822 uint32_t num_entries
= 0;
823 time_t now
= time(NULL
);
824 uint32_t resume_handle
= resume_handle_p
? *resume_handle_p
: 0;
829 if (resume_handle_p
) {
830 *resume_handle_p
= 0;
835 *total_entries
= list_sessions(p
->mem_ctx
, &session_list
);
837 for (; resume_handle
< *total_entries
; resume_handle
++) {
840 struct passwd
*pw
= sys_getpwnam(session_list
[resume_handle
].username
);
844 DEBUG(10,("init_srv_sess_info_1: failed to find owner: %s\n",
845 session_list
[resume_handle
].username
));
849 connect_time
= (uint32_t)(now
- session_list
[resume_handle
].connect_start
);
850 num_files
= net_count_files(pw
->pw_uid
, session_list
[resume_handle
].pid
);
851 guest
= strequal( session_list
[resume_handle
].username
, lp_guestaccount() );
853 ctr1
->array
= TALLOC_REALLOC_ARRAY(p
->mem_ctx
,
855 struct srvsvc_NetSessInfo1
,
857 W_ERROR_HAVE_NO_MEMORY(ctr1
->array
);
859 init_srvsvc_NetSessInfo1(&ctr1
->array
[num_entries
],
860 session_list
[resume_handle
].remote_machine
,
861 session_list
[resume_handle
].username
,
869 ctr1
->count
= num_entries
;
871 if (resume_handle_p
) {
872 if (*resume_handle_p
>= *total_entries
) {
873 *resume_handle_p
= 0;
875 *resume_handle_p
= resume_handle
;
882 /*******************************************************************
883 fill in a conn info level 0 structure.
884 ********************************************************************/
886 static WERROR
init_srv_conn_info_0(struct srvsvc_NetConnCtr0
*ctr0
,
887 uint32_t *resume_handle_p
,
888 uint32_t *total_entries
)
890 uint32_t num_entries
= 0;
891 uint32_t resume_handle
= resume_handle_p
? *resume_handle_p
: 0;
893 DEBUG(5,("init_srv_conn_info_0\n"));
896 if (resume_handle_p
) {
897 *resume_handle_p
= 0;
906 for (; resume_handle
< *total_entries
; resume_handle
++) {
908 ctr0
->array
= TALLOC_REALLOC_ARRAY(talloc_tos(),
910 struct srvsvc_NetConnInfo0
,
916 init_srvsvc_NetConnInfo0(&ctr0
->array
[num_entries
],
919 /* move on to creating next connection */
923 ctr0
->count
= num_entries
;
924 *total_entries
= num_entries
;
926 if (resume_handle_p
) {
927 if (*resume_handle_p
>= *total_entries
) {
928 *resume_handle_p
= 0;
930 *resume_handle_p
= resume_handle
;
937 /*******************************************************************
938 fill in a conn info level 1 structure.
939 ********************************************************************/
941 static WERROR
init_srv_conn_info_1(struct srvsvc_NetConnCtr1
*ctr1
,
942 uint32_t *resume_handle_p
,
943 uint32_t *total_entries
)
945 uint32_t num_entries
= 0;
946 uint32_t resume_handle
= resume_handle_p
? *resume_handle_p
: 0;
948 DEBUG(5,("init_srv_conn_info_1\n"));
951 if (resume_handle_p
) {
952 *resume_handle_p
= 0;
961 for (; resume_handle
< *total_entries
; resume_handle
++) {
963 ctr1
->array
= TALLOC_REALLOC_ARRAY(talloc_tos(),
965 struct srvsvc_NetConnInfo1
,
971 init_srvsvc_NetConnInfo1(&ctr1
->array
[num_entries
],
980 /* move on to creating next connection */
984 ctr1
->count
= num_entries
;
985 *total_entries
= num_entries
;
987 if (resume_handle_p
) {
988 if (*resume_handle_p
>= *total_entries
) {
989 *resume_handle_p
= 0;
991 *resume_handle_p
= resume_handle
;
998 /*******************************************************************
1000 *******************************************************************/
1002 WERROR
_srvsvc_NetFileEnum(pipes_struct
*p
,
1003 struct srvsvc_NetFileEnum
*r
)
1005 TALLOC_CTX
*ctx
= NULL
;
1006 struct srvsvc_NetFileCtr3
*ctr3
;
1007 uint32_t resume_hnd
= 0;
1010 switch (r
->in
.info_ctr
->level
) {
1014 return WERR_UNKNOWN_LEVEL
;
1018 ctr3
= r
->in
.info_ctr
->ctr
.ctr3
;
1020 werr
= WERR_INVALID_PARAM
;
1024 /* TODO -- Windows enumerates
1026 (c) open directories and files */
1028 werr
= net_enum_files(ctx
, r
->in
.user
, &ctr3
, resume_hnd
);
1029 if (!W_ERROR_IS_OK(werr
)) {
1033 werr
= net_enum_pipes(ctx
, r
->in
.user
, &ctr3
, resume_hnd
);
1034 if (!W_ERROR_IS_OK(werr
)) {
1038 *r
->out
.totalentries
= ctr3
->count
;
1039 r
->out
.info_ctr
->ctr
.ctr3
->array
= ctr3
->array
;
1040 r
->out
.info_ctr
->ctr
.ctr3
->count
= ctr3
->count
;
1048 /*******************************************************************
1049 _srvsvc_NetSrvGetInfo
1050 ********************************************************************/
1052 WERROR
_srvsvc_NetSrvGetInfo(pipes_struct
*p
,
1053 struct srvsvc_NetSrvGetInfo
*r
)
1055 WERROR status
= WERR_OK
;
1057 DEBUG(5,("_srvsvc_NetSrvGetInfo: %d\n", __LINE__
));
1059 if (!pipe_access_check(p
)) {
1060 DEBUG(3, ("access denied to _srvsvc_NetSrvGetInfo\n"));
1061 return WERR_ACCESS_DENIED
;
1064 switch (r
->in
.level
) {
1066 /* Technically level 102 should only be available to
1067 Administrators but there isn't anything super-secret
1068 here, as most of it is made up. */
1071 struct srvsvc_NetSrvInfo102
*info102
;
1073 info102
= TALLOC_P(p
->mem_ctx
, struct srvsvc_NetSrvInfo102
);
1078 init_srvsvc_NetSrvInfo102(info102
,
1081 lp_major_announce_version(),
1082 lp_minor_announce_version(),
1083 lp_default_server_announce(),
1084 string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH
),
1085 0xffffffff, /* users */
1089 3000, /* announce delta */
1090 100000, /* licenses */
1091 "c:\\"); /* user path */
1092 r
->out
.info
->info102
= info102
;
1096 struct srvsvc_NetSrvInfo101
*info101
;
1098 info101
= TALLOC_P(p
->mem_ctx
, struct srvsvc_NetSrvInfo101
);
1103 init_srvsvc_NetSrvInfo101(info101
,
1106 lp_major_announce_version(),
1107 lp_minor_announce_version(),
1108 lp_default_server_announce(),
1109 string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH
));
1110 r
->out
.info
->info101
= info101
;
1114 struct srvsvc_NetSrvInfo100
*info100
;
1116 info100
= TALLOC_P(p
->mem_ctx
, struct srvsvc_NetSrvInfo100
);
1121 init_srvsvc_NetSrvInfo100(info100
,
1124 r
->out
.info
->info100
= info100
;
1129 status
= WERR_UNKNOWN_LEVEL
;
1133 DEBUG(5,("_srvsvc_NetSrvGetInfo: %d\n", __LINE__
));
1138 /*******************************************************************
1139 _srvsvc_NetSrvSetInfo
1140 ********************************************************************/
1142 WERROR
_srvsvc_NetSrvSetInfo(pipes_struct
*p
,
1143 struct srvsvc_NetSrvSetInfo
*r
)
1145 WERROR status
= WERR_OK
;
1147 DEBUG(5,("_srvsvc_NetSrvSetInfo: %d\n", __LINE__
));
1149 /* Set up the net server set info structure. */
1151 DEBUG(5,("_srvsvc_NetSrvSetInfo: %d\n", __LINE__
));
1156 /*******************************************************************
1158 ********************************************************************/
1160 WERROR
_srvsvc_NetConnEnum(pipes_struct
*p
,
1161 struct srvsvc_NetConnEnum
*r
)
1165 DEBUG(5,("_srvsvc_NetConnEnum: %d\n", __LINE__
));
1167 switch (r
->in
.info_ctr
->level
) {
1169 werr
= init_srv_conn_info_0(r
->in
.info_ctr
->ctr
.ctr0
,
1170 r
->in
.resume_handle
,
1171 r
->out
.totalentries
);
1174 werr
= init_srv_conn_info_1(r
->in
.info_ctr
->ctr
.ctr1
,
1175 r
->in
.resume_handle
,
1176 r
->out
.totalentries
);
1179 return WERR_UNKNOWN_LEVEL
;
1182 DEBUG(5,("_srvsvc_NetConnEnum: %d\n", __LINE__
));
1187 /*******************************************************************
1189 ********************************************************************/
1191 WERROR
_srvsvc_NetSessEnum(pipes_struct
*p
,
1192 struct srvsvc_NetSessEnum
*r
)
1196 DEBUG(5,("_srvsvc_NetSessEnum: %d\n", __LINE__
));
1198 switch (r
->in
.info_ctr
->level
) {
1200 werr
= init_srv_sess_info_0(p
,
1201 r
->in
.info_ctr
->ctr
.ctr0
,
1202 r
->in
.resume_handle
,
1203 r
->out
.totalentries
);
1206 werr
= init_srv_sess_info_1(p
,
1207 r
->in
.info_ctr
->ctr
.ctr1
,
1208 r
->in
.resume_handle
,
1209 r
->out
.totalentries
);
1212 return WERR_UNKNOWN_LEVEL
;
1215 DEBUG(5,("_srvsvc_NetSessEnum: %d\n", __LINE__
));
1220 /*******************************************************************
1222 ********************************************************************/
1224 WERROR
_srvsvc_NetSessDel(pipes_struct
*p
,
1225 struct srvsvc_NetSessDel
*r
)
1227 struct sessionid
*session_list
;
1228 struct current_user user
;
1229 int num_sessions
, snum
;
1230 const char *username
;
1231 const char *machine
;
1232 bool not_root
= False
;
1235 username
= r
->in
.user
;
1236 machine
= r
->in
.client
;
1238 /* strip leading backslashes if any */
1239 if (machine
&& machine
[0] == '\\' && machine
[1] == '\\') {
1243 num_sessions
= list_sessions(p
->mem_ctx
, &session_list
);
1245 DEBUG(5,("_srvsvc_NetSessDel: %d\n", __LINE__
));
1247 werr
= WERR_ACCESS_DENIED
;
1249 get_current_user(&user
, p
);
1251 /* fail out now if you are not root or not a domain admin */
1253 if ((user
.ut
.uid
!= sec_initial_uid()) &&
1254 ( ! nt_token_check_domain_rid(p
->pipe_user
.nt_user_token
, DOMAIN_GROUP_RID_ADMINS
))) {
1259 for (snum
= 0; snum
< num_sessions
; snum
++) {
1261 if ((strequal(session_list
[snum
].username
, username
) || username
[0] == '\0' ) &&
1262 strequal(session_list
[snum
].remote_machine
, machine
)) {
1266 if (user
.ut
.uid
!= sec_initial_uid()) {
1271 ntstat
= messaging_send(smbd_messaging_context(),
1272 session_list
[snum
].pid
,
1273 MSG_SHUTDOWN
, &data_blob_null
);
1275 if (NT_STATUS_IS_OK(ntstat
))
1283 DEBUG(5,("_srvsvc_NetSessDel: %d\n", __LINE__
));
1290 /*******************************************************************
1291 _srvsvc_NetShareEnumAll
1292 ********************************************************************/
1294 WERROR
_srvsvc_NetShareEnumAll(pipes_struct
*p
,
1295 struct srvsvc_NetShareEnumAll
*r
)
1299 DEBUG(5,("_srvsvc_NetShareEnumAll: %d\n", __LINE__
));
1301 if (!pipe_access_check(p
)) {
1302 DEBUG(3, ("access denied to _srvsvc_NetShareEnumAll\n"));
1303 return WERR_ACCESS_DENIED
;
1306 /* Create the list of shares for the response. */
1307 werr
= init_srv_share_info_ctr(p
,
1309 r
->in
.resume_handle
,
1310 r
->out
.totalentries
,
1313 DEBUG(5,("_srvsvc_NetShareEnumAll: %d\n", __LINE__
));
1318 /*******************************************************************
1319 _srvsvc_NetShareEnum
1320 ********************************************************************/
1322 WERROR
_srvsvc_NetShareEnum(pipes_struct
*p
,
1323 struct srvsvc_NetShareEnum
*r
)
1327 DEBUG(5,("_srvsvc_NetShareEnum: %d\n", __LINE__
));
1329 if (!pipe_access_check(p
)) {
1330 DEBUG(3, ("access denied to _srvsvc_NetShareEnum\n"));
1331 return WERR_ACCESS_DENIED
;
1334 /* Create the list of shares for the response. */
1335 werr
= init_srv_share_info_ctr(p
,
1337 r
->in
.resume_handle
,
1338 r
->out
.totalentries
,
1341 DEBUG(5,("_srvsvc_NetShareEnum: %d\n", __LINE__
));
1346 /*******************************************************************
1347 _srvsvc_NetShareGetInfo
1348 ********************************************************************/
1350 WERROR
_srvsvc_NetShareGetInfo(pipes_struct
*p
,
1351 struct srvsvc_NetShareGetInfo
*r
)
1353 WERROR status
= WERR_OK
;
1356 union srvsvc_NetShareInfo
*info
= r
->out
.info
;
1358 DEBUG(5,("_srvsvc_NetShareGetInfo: %d\n", __LINE__
));
1360 fstrcpy(share_name
, r
->in
.share_name
);
1362 snum
= find_service(share_name
);
1364 return WERR_INVALID_NAME
;
1367 switch (r
->in
.level
) {
1369 info
->info0
= TALLOC_P(p
->mem_ctx
, struct srvsvc_NetShareInfo0
);
1370 W_ERROR_HAVE_NO_MEMORY(info
->info0
);
1371 init_srv_share_info_0(p
, info
->info0
, snum
);
1374 info
->info1
= TALLOC_P(p
->mem_ctx
, struct srvsvc_NetShareInfo1
);
1375 W_ERROR_HAVE_NO_MEMORY(info
->info1
);
1376 init_srv_share_info_1(p
, info
->info1
, snum
);
1379 info
->info2
= TALLOC_P(p
->mem_ctx
, struct srvsvc_NetShareInfo2
);
1380 W_ERROR_HAVE_NO_MEMORY(info
->info2
);
1381 init_srv_share_info_2(p
, info
->info2
, snum
);
1384 info
->info501
= TALLOC_P(p
->mem_ctx
, struct srvsvc_NetShareInfo501
);
1385 W_ERROR_HAVE_NO_MEMORY(info
->info501
);
1386 init_srv_share_info_501(p
, info
->info501
, snum
);
1389 info
->info502
= TALLOC_P(p
->mem_ctx
, struct srvsvc_NetShareInfo502
);
1390 W_ERROR_HAVE_NO_MEMORY(info
->info502
);
1391 init_srv_share_info_502(p
, info
->info502
, snum
);
1394 info
->info1004
= TALLOC_P(p
->mem_ctx
, struct srvsvc_NetShareInfo1004
);
1395 W_ERROR_HAVE_NO_MEMORY(info
->info1004
);
1396 init_srv_share_info_1004(p
, info
->info1004
, snum
);
1399 info
->info1005
= TALLOC_P(p
->mem_ctx
, struct srvsvc_NetShareInfo1005
);
1400 W_ERROR_HAVE_NO_MEMORY(info
->info1005
);
1401 init_srv_share_info_1005(p
, info
->info1005
, snum
);
1404 info
->info1006
= TALLOC_P(p
->mem_ctx
, struct srvsvc_NetShareInfo1006
);
1405 W_ERROR_HAVE_NO_MEMORY(info
->info1006
);
1406 init_srv_share_info_1006(p
, info
->info1006
, snum
);
1409 info
->info1007
= TALLOC_P(p
->mem_ctx
, struct srvsvc_NetShareInfo1007
);
1410 W_ERROR_HAVE_NO_MEMORY(info
->info1007
);
1411 init_srv_share_info_1007(p
, info
->info1007
, snum
);
1414 init_srv_share_info_1501(p
, info
->info1501
, snum
);
1417 DEBUG(5,("_srvsvc_NetShareGetInfo: unsupported switch value %d\n",
1419 status
= WERR_UNKNOWN_LEVEL
;
1423 DEBUG(5,("_srvsvc_NetShareGetInfo: %d\n", __LINE__
));
1428 /*******************************************************************
1429 Check a given DOS pathname is valid for a share.
1430 ********************************************************************/
1432 char *valid_share_pathname(TALLOC_CTX
*ctx
, const char *dos_pathname
)
1436 if (!dos_pathname
) {
1440 ptr
= talloc_strdup(ctx
, dos_pathname
);
1444 /* Convert any '\' paths to '/' */
1446 ptr
= unix_clean_name(ctx
, ptr
);
1451 /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */
1452 if (strlen(ptr
) > 2 && ptr
[1] == ':' && ptr
[0] != '/')
1455 /* Only absolute paths allowed. */
1462 /*******************************************************************
1463 _srvsvc_NetShareSetInfo. Modify share details.
1464 ********************************************************************/
1466 WERROR
_srvsvc_NetShareSetInfo(pipes_struct
*p
,
1467 struct srvsvc_NetShareSetInfo
*r
)
1469 struct current_user user
;
1470 char *command
= NULL
;
1471 char *share_name
= NULL
;
1472 char *comment
= NULL
;
1473 const char *pathname
= NULL
;
1478 SEC_DESC
*psd
= NULL
;
1479 SE_PRIV se_diskop
= SE_DISK_OPERATOR
;
1480 bool is_disk_op
= False
;
1481 int max_connections
= 0;
1482 TALLOC_CTX
*ctx
= p
->mem_ctx
;
1483 union srvsvc_NetShareInfo
*info
= r
->in
.info
;
1485 DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__
));
1487 share_name
= talloc_strdup(p
->mem_ctx
, r
->in
.share_name
);
1492 if (r
->out
.parm_error
) {
1493 *r
->out
.parm_error
= 0;
1496 if ( strequal(share_name
,"IPC$")
1497 || ( lp_enable_asu_support() && strequal(share_name
,"ADMIN$") )
1498 || strequal(share_name
,"global") )
1500 return WERR_ACCESS_DENIED
;
1503 snum
= find_service(share_name
);
1505 /* Does this share exist ? */
1507 return WERR_NET_NAME_NOT_FOUND
;
1509 /* No change to printer shares. */
1510 if (lp_print_ok(snum
))
1511 return WERR_ACCESS_DENIED
;
1513 get_current_user(&user
,p
);
1515 is_disk_op
= user_has_privileges( p
->pipe_user
.nt_user_token
, &se_diskop
);
1517 /* fail out now if you are not root and not a disk op */
1519 if ( user
.ut
.uid
!= sec_initial_uid() && !is_disk_op
)
1520 return WERR_ACCESS_DENIED
;
1522 switch (r
->in
.level
) {
1524 pathname
= talloc_strdup(ctx
, lp_pathname(snum
));
1525 comment
= talloc_strdup(ctx
, info
->info1
->comment
);
1526 type
= info
->info1
->type
;
1530 comment
= talloc_strdup(ctx
, info
->info2
->comment
);
1531 pathname
= info
->info2
->path
;
1532 type
= info
->info2
->type
;
1533 max_connections
= (info
->info2
->max_users
== (uint32_t)-1) ?
1534 0 : info
->info2
->max_users
;
1538 /* not supported on set but here for completeness */
1540 comment
= talloc_strdup(ctx
, info
->info501
->comment
);
1541 type
= info
->info501
->type
;
1546 comment
= talloc_strdup(ctx
, info
->info502
->comment
);
1547 pathname
= info
->info502
->path
;
1548 type
= info
->info502
->type
;
1549 psd
= info
->info502
->sd_buf
.sd
;
1550 map_generic_share_sd_bits(psd
);
1553 pathname
= talloc_strdup(ctx
, lp_pathname(snum
));
1554 comment
= talloc_strdup(ctx
, info
->info1004
->comment
);
1555 type
= STYPE_DISKTREE
;
1558 /* XP re-sets the csc policy even if it wasn't changed by the
1559 user, so we must compare it to see if it's what is set in
1560 smb.conf, so that we can contine other ops like setting
1562 if (((info
->info1005
->dfs_flags
&
1563 SHARE_1005_CSC_POLICY_MASK
) >>
1564 SHARE_1005_CSC_POLICY_SHIFT
) == lp_csc_policy(snum
))
1567 DEBUG(3, ("_srvsvc_NetShareSetInfo: client is trying to change csc policy from the network; must be done with smb.conf\n"));
1568 return WERR_ACCESS_DENIED
;
1572 return WERR_ACCESS_DENIED
;
1574 pathname
= talloc_strdup(ctx
, lp_pathname(snum
));
1575 comment
= talloc_strdup(ctx
, lp_comment(snum
));
1576 psd
= info
->info1501
->sd
;
1577 map_generic_share_sd_bits(psd
);
1578 type
= STYPE_DISKTREE
;
1581 DEBUG(5,("_srvsvc_NetShareSetInfo: unsupported switch value %d\n",
1583 return WERR_UNKNOWN_LEVEL
;
1586 /* We can only modify disk shares. */
1587 if (type
!= STYPE_DISKTREE
)
1588 return WERR_ACCESS_DENIED
;
1590 if (comment
== NULL
) {
1594 /* Check if the pathname is valid. */
1595 if (!(path
= valid_share_pathname(p
->mem_ctx
, pathname
)))
1596 return WERR_OBJECT_PATH_INVALID
;
1598 /* Ensure share name, pathname and comment don't contain '"' characters. */
1599 string_replace(share_name
, '"', ' ');
1600 string_replace(path
, '"', ' ');
1601 string_replace(comment
, '"', ' ');
1603 DEBUG(10,("_srvsvc_NetShareSetInfo: change share command = %s\n",
1604 lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" ));
1606 /* Only call modify function if something changed. */
1608 if (strcmp(path
, lp_pathname(snum
)) || strcmp(comment
, lp_comment(snum
))
1609 || (lp_max_connections(snum
) != max_connections
)) {
1610 if (!lp_change_share_cmd() || !*lp_change_share_cmd()) {
1611 DEBUG(10,("_srvsvc_NetShareSetInfo: No change share command\n"));
1612 return WERR_ACCESS_DENIED
;
1615 command
= talloc_asprintf(p
->mem_ctx
,
1616 "%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
1617 lp_change_share_cmd(),
1618 get_dyn_CONFIGFILE(),
1621 comment
? comment
: "",
1627 DEBUG(10,("_srvsvc_NetShareSetInfo: Running [%s]\n", command
));
1629 /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
1634 if ( (ret
= smbrun(command
, NULL
)) == 0 ) {
1635 /* Tell everyone we updated smb.conf. */
1636 message_send_all(smbd_messaging_context(),
1637 MSG_SMB_CONF_UPDATED
, NULL
, 0,
1644 /********* END SeDiskOperatorPrivilege BLOCK *********/
1646 DEBUG(3,("_srvsvc_NetShareSetInfo: Running [%s] returned (%d)\n",
1649 TALLOC_FREE(command
);
1652 return WERR_ACCESS_DENIED
;
1654 DEBUG(10,("_srvsvc_NetShareSetInfo: No change to share name (%s)\n",
1658 /* Replace SD if changed. */
1663 old_sd
= get_share_security(p
->mem_ctx
, lp_servicename(snum
), &sd_size
);
1665 if (old_sd
&& !sec_desc_equal(old_sd
, psd
)) {
1666 if (!set_share_security(share_name
, psd
))
1667 DEBUG(0,("_srvsvc_NetShareSetInfo: Failed to change security info in share %s.\n",
1672 DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__
));
1677 /*******************************************************************
1678 _srvsvc_NetShareAdd.
1679 Call 'add_share_command "sharename" "pathname"
1680 "comment" "max connections = "
1681 ********************************************************************/
1683 WERROR
_srvsvc_NetShareAdd(pipes_struct
*p
,
1684 struct srvsvc_NetShareAdd
*r
)
1686 struct current_user user
;
1687 char *command
= NULL
;
1688 char *share_name
= NULL
;
1689 char *comment
= NULL
;
1690 char *pathname
= NULL
;
1695 SEC_DESC
*psd
= NULL
;
1696 SE_PRIV se_diskop
= SE_DISK_OPERATOR
;
1698 int max_connections
= 0;
1699 TALLOC_CTX
*ctx
= p
->mem_ctx
;
1701 DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__
));
1703 if (r
->out
.parm_error
) {
1704 *r
->out
.parm_error
= 0;
1707 get_current_user(&user
,p
);
1709 is_disk_op
= user_has_privileges( p
->pipe_user
.nt_user_token
, &se_diskop
);
1711 if (user
.ut
.uid
!= sec_initial_uid() && !is_disk_op
)
1712 return WERR_ACCESS_DENIED
;
1714 if (!lp_add_share_cmd() || !*lp_add_share_cmd()) {
1715 DEBUG(10,("_srvsvc_NetShareAdd: No add share command\n"));
1716 return WERR_ACCESS_DENIED
;
1719 switch (r
->in
.level
) {
1721 /* No path. Not enough info in a level 0 to do anything. */
1722 return WERR_ACCESS_DENIED
;
1724 /* Not enough info in a level 1 to do anything. */
1725 return WERR_ACCESS_DENIED
;
1727 share_name
= talloc_strdup(ctx
, r
->in
.info
->info2
->name
);
1728 comment
= talloc_strdup(ctx
, r
->in
.info
->info2
->comment
);
1729 pathname
= talloc_strdup(ctx
, r
->in
.info
->info2
->path
);
1730 max_connections
= (r
->in
.info
->info2
->max_users
== (uint32_t)-1) ?
1731 0 : r
->in
.info
->info2
->max_users
;
1732 type
= r
->in
.info
->info2
->type
;
1735 /* No path. Not enough info in a level 501 to do anything. */
1736 return WERR_ACCESS_DENIED
;
1738 share_name
= talloc_strdup(ctx
, r
->in
.info
->info502
->name
);
1739 comment
= talloc_strdup(ctx
, r
->in
.info
->info502
->comment
);
1740 pathname
= talloc_strdup(ctx
, r
->in
.info
->info502
->path
);
1741 max_connections
= (r
->in
.info
->info502
->max_users
== (uint32_t)-1) ?
1742 0 : r
->in
.info
->info502
->max_users
;
1743 type
= r
->in
.info
->info502
->type
;
1744 psd
= r
->in
.info
->info502
->sd_buf
.sd
;
1745 map_generic_share_sd_bits(psd
);
1748 /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */
1754 return WERR_ACCESS_DENIED
;
1756 /* DFS only level. */
1757 return WERR_ACCESS_DENIED
;
1759 DEBUG(5,("_srvsvc_NetShareAdd: unsupported switch value %d\n",
1761 return WERR_UNKNOWN_LEVEL
;
1764 /* check for invalid share names */
1766 if (!share_name
|| !validate_net_name(share_name
,
1767 INVALID_SHARENAME_CHARS
,
1768 strlen(share_name
))) {
1769 DEBUG(5,("_srvsvc_NetShareAdd: Bad sharename \"%s\"\n",
1770 share_name
? share_name
: ""));
1771 return WERR_INVALID_NAME
;
1774 if (strequal(share_name
,"IPC$") || strequal(share_name
,"global")
1775 || (lp_enable_asu_support() &&
1776 strequal(share_name
,"ADMIN$"))) {
1777 return WERR_ACCESS_DENIED
;
1780 snum
= find_service(share_name
);
1782 /* Share already exists. */
1784 return WERR_ALREADY_EXISTS
;
1787 /* We can only add disk shares. */
1788 if (type
!= STYPE_DISKTREE
) {
1789 return WERR_ACCESS_DENIED
;
1792 /* Check if the pathname is valid. */
1793 if (!(path
= valid_share_pathname(p
->mem_ctx
, pathname
))) {
1794 return WERR_OBJECT_PATH_INVALID
;
1797 /* Ensure share name, pathname and comment don't contain '"' characters. */
1798 string_replace(share_name
, '"', ' ');
1799 string_replace(path
, '"', ' ');
1801 string_replace(comment
, '"', ' ');
1804 command
= talloc_asprintf(ctx
,
1805 "%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
1807 get_dyn_CONFIGFILE(),
1810 comment
? comment
: "",
1816 DEBUG(10,("_srvsvc_NetShareAdd: Running [%s]\n", command
));
1818 /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
1823 /* FIXME: use libnetconf here - gd */
1825 if ( (ret
= smbrun(command
, NULL
)) == 0 ) {
1826 /* Tell everyone we updated smb.conf. */
1827 message_send_all(smbd_messaging_context(),
1828 MSG_SMB_CONF_UPDATED
, NULL
, 0, NULL
);
1834 /********* END SeDiskOperatorPrivilege BLOCK *********/
1836 DEBUG(3,("_srvsvc_NetShareAdd: Running [%s] returned (%d)\n",
1839 TALLOC_FREE(command
);
1842 return WERR_ACCESS_DENIED
;
1845 if (!set_share_security(share_name
, psd
)) {
1846 DEBUG(0,("_srvsvc_NetShareAdd: Failed to add security info to share %s.\n",
1852 * We don't call reload_services() here, the message will
1853 * cause this to be done before the next packet is read
1854 * from the client. JRA.
1857 DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__
));
1862 /*******************************************************************
1864 Call "delete share command" with the share name as
1866 ********************************************************************/
1868 WERROR
_srvsvc_NetShareDel(pipes_struct
*p
,
1869 struct srvsvc_NetShareDel
*r
)
1871 struct current_user user
;
1872 char *command
= NULL
;
1873 char *share_name
= NULL
;
1876 SE_PRIV se_diskop
= SE_DISK_OPERATOR
;
1878 struct share_params
*params
;
1879 TALLOC_CTX
*ctx
= p
->mem_ctx
;
1881 DEBUG(5,("_srvsvc_NetShareDel: %d\n", __LINE__
));
1883 share_name
= talloc_strdup(p
->mem_ctx
, r
->in
.share_name
);
1885 return WERR_NET_NAME_NOT_FOUND
;
1887 if ( strequal(share_name
,"IPC$")
1888 || ( lp_enable_asu_support() && strequal(share_name
,"ADMIN$") )
1889 || strequal(share_name
,"global") )
1891 return WERR_ACCESS_DENIED
;
1894 if (!(params
= get_share_params(p
->mem_ctx
, share_name
))) {
1895 return WERR_NO_SUCH_SHARE
;
1898 snum
= find_service(share_name
);
1900 /* No change to printer shares. */
1901 if (lp_print_ok(snum
))
1902 return WERR_ACCESS_DENIED
;
1904 get_current_user(&user
,p
);
1906 is_disk_op
= user_has_privileges( p
->pipe_user
.nt_user_token
, &se_diskop
);
1908 if (user
.ut
.uid
!= sec_initial_uid() && !is_disk_op
)
1909 return WERR_ACCESS_DENIED
;
1911 if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) {
1912 DEBUG(10,("_srvsvc_NetShareDel: No delete share command\n"));
1913 return WERR_ACCESS_DENIED
;
1916 command
= talloc_asprintf(ctx
,
1918 lp_delete_share_cmd(),
1919 get_dyn_CONFIGFILE(),
1920 lp_servicename(snum
));
1925 DEBUG(10,("_srvsvc_NetShareDel: Running [%s]\n", command
));
1927 /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
1932 if ( (ret
= smbrun(command
, NULL
)) == 0 ) {
1933 /* Tell everyone we updated smb.conf. */
1934 message_send_all(smbd_messaging_context(),
1935 MSG_SMB_CONF_UPDATED
, NULL
, 0, NULL
);
1941 /********* END SeDiskOperatorPrivilege BLOCK *********/
1943 DEBUG(3,("_srvsvc_NetShareDel: Running [%s] returned (%d)\n", command
, ret
));
1946 return WERR_ACCESS_DENIED
;
1948 /* Delete the SD in the database. */
1949 delete_share_security(lp_servicename(params
->service
));
1951 lp_killservice(params
->service
);
1956 /*******************************************************************
1957 _srvsvc_NetShareDelSticky
1958 ********************************************************************/
1960 WERROR
_srvsvc_NetShareDelSticky(pipes_struct
*p
,
1961 struct srvsvc_NetShareDelSticky
*r
)
1963 struct srvsvc_NetShareDel q
;
1965 DEBUG(5,("_srvsvc_NetShareDelSticky: %d\n", __LINE__
));
1967 q
.in
.server_unc
= r
->in
.server_unc
;
1968 q
.in
.share_name
= r
->in
.share_name
;
1969 q
.in
.reserved
= r
->in
.reserved
;
1971 return _srvsvc_NetShareDel(p
, &q
);
1974 /*******************************************************************
1975 _srvsvc_NetRemoteTOD
1976 ********************************************************************/
1978 WERROR
_srvsvc_NetRemoteTOD(pipes_struct
*p
,
1979 struct srvsvc_NetRemoteTOD
*r
)
1981 struct srvsvc_NetRemoteTODInfo
*tod
;
1983 time_t unixdate
= time(NULL
);
1985 /* We do this call first as if we do it *after* the gmtime call
1986 it overwrites the pointed-to values. JRA */
1988 uint32 zone
= get_time_zone(unixdate
)/60;
1990 DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__
));
1992 if ( !(tod
= TALLOC_ZERO_P(p
->mem_ctx
, struct srvsvc_NetRemoteTODInfo
)) )
1997 DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__
));
1999 t
= gmtime(&unixdate
);
2002 init_srvsvc_NetRemoteTODInfo(tod
,
2016 DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__
));
2021 /***********************************************************************************
2022 _srvsvc_NetGetFileSecurity
2023 Win9x NT tools get security descriptor.
2024 ***********************************************************************************/
2026 WERROR
_srvsvc_NetGetFileSecurity(pipes_struct
*p
,
2027 struct srvsvc_NetGetFileSecurity
*r
)
2029 SEC_DESC
*psd
= NULL
;
2031 fstring servicename
;
2035 connection_struct
*conn
= NULL
;
2036 struct sec_desc_buf
*sd_buf
= NULL
;
2037 files_struct
*fsp
= NULL
;
2039 char *oldcwd
= NULL
;
2043 fstrcpy(servicename
, r
->in
.share
);
2045 snum
= find_service(servicename
);
2047 DEBUG(10, ("Could not find service %s\n", servicename
));
2048 werr
= WERR_NET_NAME_NOT_FOUND
;
2052 nt_status
= create_conn_struct(talloc_tos(), &conn
, snum
,
2053 lp_pathname(snum
), &oldcwd
);
2054 if (!NT_STATUS_IS_OK(nt_status
)) {
2055 DEBUG(10, ("create_conn_struct failed: %s\n",
2056 nt_errstr(nt_status
)));
2057 werr
= ntstatus_to_werror(nt_status
);
2061 conn
->server_info
= p
->server_info
;
2063 nt_status
= create_file(
2066 0, /* root_dir_fid */
2067 r
->in
.file
, /* fname */
2068 FILE_READ_ATTRIBUTES
, /* access_mask */
2069 FILE_SHARE_READ
|FILE_SHARE_WRITE
, /* share_access */
2070 FILE_OPEN
, /* create_disposition*/
2071 0, /* create_options */
2072 0, /* file_attributes */
2073 INTERNAL_OPEN_ONLY
, /* oplock_request */
2074 0, /* allocation_size */
2081 if (!NT_STATUS_IS_OK(nt_status
)) {
2082 DEBUG(3,("_srvsvc_NetGetFileSecurity: can't open %s\n",
2084 werr
= ntstatus_to_werror(nt_status
);
2088 nt_status
= SMB_VFS_FGET_NT_ACL(fsp
,
2089 (OWNER_SECURITY_INFORMATION
2090 |GROUP_SECURITY_INFORMATION
2091 |DACL_SECURITY_INFORMATION
), &psd
);
2093 if (!NT_STATUS_IS_OK(nt_status
)) {
2094 DEBUG(3,("_srvsvc_NetGetFileSecurity: Unable to get NT ACL "
2095 "for file %s\n", r
->in
.file
));
2096 werr
= ntstatus_to_werror(nt_status
);
2100 sd_size
= ndr_size_security_descriptor(psd
, 0);
2102 sd_buf
= TALLOC_ZERO_P(p
->mem_ctx
, struct sec_desc_buf
);
2108 sd_buf
->sd_size
= sd_size
;
2111 *r
->out
.sd_buf
= sd_buf
;
2113 psd
->dacl
->revision
= NT4_ACL_REVISION
;
2115 close_file(fsp
, NORMAL_CLOSE
);
2116 vfs_ChDir(conn
, oldcwd
);
2117 conn_free_internal(conn
);
2123 close_file(fsp
, NORMAL_CLOSE
);
2127 vfs_ChDir(conn
, oldcwd
);
2131 conn_free_internal(conn
);
2137 /***********************************************************************************
2138 _srvsvc_NetSetFileSecurity
2139 Win9x NT tools set security descriptor.
2140 ***********************************************************************************/
2142 WERROR
_srvsvc_NetSetFileSecurity(pipes_struct
*p
,
2143 struct srvsvc_NetSetFileSecurity
*r
)
2145 fstring servicename
;
2146 files_struct
*fsp
= NULL
;
2150 connection_struct
*conn
= NULL
;
2152 char *oldcwd
= NULL
;
2153 struct security_descriptor
*psd
= NULL
;
2154 uint32_t security_info_sent
= 0;
2158 fstrcpy(servicename
, r
->in
.share
);
2160 snum
= find_service(servicename
);
2162 DEBUG(10, ("Could not find service %s\n", servicename
));
2163 werr
= WERR_NET_NAME_NOT_FOUND
;
2167 nt_status
= create_conn_struct(talloc_tos(), &conn
, snum
,
2168 lp_pathname(snum
), &oldcwd
);
2169 if (!NT_STATUS_IS_OK(nt_status
)) {
2170 DEBUG(10, ("create_conn_struct failed: %s\n",
2171 nt_errstr(nt_status
)));
2172 werr
= ntstatus_to_werror(nt_status
);
2176 conn
->server_info
= p
->server_info
;
2178 nt_status
= create_file(
2181 0, /* root_dir_fid */
2182 r
->in
.file
, /* fname */
2183 FILE_WRITE_ATTRIBUTES
, /* access_mask */
2184 FILE_SHARE_READ
|FILE_SHARE_WRITE
, /* share_access */
2185 FILE_OPEN
, /* create_disposition*/
2186 0, /* create_options */
2187 0, /* file_attributes */
2188 INTERNAL_OPEN_ONLY
, /* oplock_request */
2189 0, /* allocation_size */
2196 if (!NT_STATUS_IS_OK(nt_status
)) {
2197 DEBUG(3,("_srvsvc_NetSetFileSecurity: can't open %s\n",
2199 werr
= ntstatus_to_werror(nt_status
);
2203 psd
= r
->in
.sd_buf
->sd
;
2204 security_info_sent
= r
->in
.securityinformation
;
2206 if (psd
->owner_sid
==0) {
2207 security_info_sent
&= ~OWNER_SECURITY_INFORMATION
;
2209 if (psd
->group_sid
==0) {
2210 security_info_sent
&= ~GROUP_SECURITY_INFORMATION
;
2213 security_info_sent
&= ~SACL_SECURITY_INFORMATION
;
2216 security_info_sent
&= ~DACL_SECURITY_INFORMATION
;
2219 /* Convert all the generic bits. */
2220 security_acl_map_generic(psd
->dacl
, &file_generic_mapping
);
2221 security_acl_map_generic(psd
->sacl
, &file_generic_mapping
);
2223 nt_status
= SMB_VFS_FSET_NT_ACL(fsp
,
2227 if (!NT_STATUS_IS_OK(nt_status
) ) {
2228 DEBUG(3,("_srvsvc_NetSetFileSecurity: Unable to set NT ACL "
2229 "on file %s\n", r
->in
.share
));
2230 werr
= WERR_ACCESS_DENIED
;
2234 close_file(fsp
, NORMAL_CLOSE
);
2235 vfs_ChDir(conn
, oldcwd
);
2236 conn_free_internal(conn
);
2242 close_file(fsp
, NORMAL_CLOSE
);
2246 vfs_ChDir(conn
, oldcwd
);
2250 conn_free_internal(conn
);
2256 /***********************************************************************************
2257 It may be that we want to limit users to creating shares on certain areas of the UNIX file area.
2258 We could define areas by mapping Windows style disks to points on the UNIX directory hierarchy.
2259 These disks would the disks listed by this function.
2260 Users could then create shares relative to these disks. Watch out for moving these disks around.
2261 "Nigel Williams" <nigel@veritas.com>.
2262 ***********************************************************************************/
2264 static const char *server_disks
[] = {"C:"};
2266 static uint32
get_server_disk_count(void)
2268 return sizeof(server_disks
)/sizeof(server_disks
[0]);
2271 static uint32
init_server_disk_enum(uint32
*resume
)
2273 uint32 server_disk_count
= get_server_disk_count();
2275 /*resume can be an offset into the list for now*/
2277 if(*resume
& 0x80000000)
2280 if(*resume
> server_disk_count
)
2281 *resume
= server_disk_count
;
2283 return server_disk_count
- *resume
;
2286 static const char *next_server_disk_enum(uint32
*resume
)
2290 if(init_server_disk_enum(resume
) == 0)
2293 disk
= server_disks
[*resume
];
2297 DEBUG(10, ("next_server_disk_enum: reporting disk %s. resume handle %d.\n", disk
, *resume
));
2302 /********************************************************************
2304 ********************************************************************/
2306 WERROR
_srvsvc_NetDiskEnum(pipes_struct
*p
,
2307 struct srvsvc_NetDiskEnum
*r
)
2310 const char *disk_name
;
2311 TALLOC_CTX
*ctx
= p
->mem_ctx
;
2313 uint32_t resume
= r
->in
.resume_handle
? *r
->in
.resume_handle
: 0;
2317 *r
->out
.totalentries
= init_server_disk_enum(&resume
);
2319 r
->out
.info
->disks
= TALLOC_ZERO_ARRAY(ctx
, struct srvsvc_NetDiskInfo0
,
2320 MAX_SERVER_DISK_ENTRIES
);
2321 W_ERROR_HAVE_NO_MEMORY(r
->out
.info
->disks
);
2323 /*allow one struct srvsvc_NetDiskInfo0 for null terminator*/
2325 r
->out
.info
->count
= 0;
2327 for(i
= 0; i
< MAX_SERVER_DISK_ENTRIES
-1 && (disk_name
= next_server_disk_enum(&resume
)); i
++) {
2329 r
->out
.info
->count
++;
2331 /*copy disk name into a unicode string*/
2333 r
->out
.info
->disks
[i
].disk
= talloc_strdup(ctx
, disk_name
);
2334 W_ERROR_HAVE_NO_MEMORY(r
->out
.info
->disks
[i
].disk
);
2337 /* add a terminating null string. Is this there if there is more data to come? */
2339 r
->out
.info
->count
++;
2341 r
->out
.info
->disks
[i
].disk
= talloc_strdup(ctx
, "");
2342 W_ERROR_HAVE_NO_MEMORY(r
->out
.info
->disks
[i
].disk
);
2344 if (r
->out
.resume_handle
) {
2345 *r
->out
.resume_handle
= resume
;
2351 /********************************************************************
2352 _srvsvc_NetNameValidate
2353 ********************************************************************/
2355 WERROR
_srvsvc_NetNameValidate(pipes_struct
*p
,
2356 struct srvsvc_NetNameValidate
*r
)
2358 switch (r
->in
.name_type
) {
2360 if (!validate_net_name(r
->in
.name
, INVALID_SHARENAME_CHARS
,
2361 strlen_m(r
->in
.name
)))
2363 DEBUG(5,("_srvsvc_NetNameValidate: Bad sharename \"%s\"\n",
2365 return WERR_INVALID_NAME
;
2370 return WERR_UNKNOWN_LEVEL
;
2376 /*******************************************************************
2377 ********************************************************************/
2379 static void enum_file_close_fn( const struct share_mode_entry
*e
,
2380 const char *sharepath
, const char *fname
,
2381 void *private_data
)
2383 char msg
[MSG_SMB_SHARE_MODE_ENTRY_SIZE
];
2384 struct srvsvc_NetFileClose
*r
=
2385 (struct srvsvc_NetFileClose
*)private_data
;
2386 uint32_t fid
= (((uint32_t)(procid_to_pid(&e
->pid
))<<16) | e
->share_file_id
);
2388 if (fid
!= r
->in
.fid
) {
2389 return; /* Not this file. */
2392 if (!process_exists(e
->pid
) ) {
2396 /* Ok - send the close message. */
2397 DEBUG(10,("enum_file_close_fn: request to close file %s, %s\n",
2399 share_mode_str(talloc_tos(), 0, e
) ));
2401 share_mode_entry_to_message(msg
, e
);
2403 r
->out
.result
= ntstatus_to_werror(
2404 messaging_send_buf(smbd_messaging_context(),
2405 e
->pid
, MSG_SMB_CLOSE_FILE
,
2407 MSG_SMB_SHARE_MODE_ENTRY_SIZE
));
2410 /********************************************************************
2411 Close a file given a 32-bit file id.
2412 ********************************************************************/
2414 WERROR
_srvsvc_NetFileClose(pipes_struct
*p
, struct srvsvc_NetFileClose
*r
)
2416 struct current_user user
;
2417 SE_PRIV se_diskop
= SE_DISK_OPERATOR
;
2420 DEBUG(5,("_srvsvc_NetFileClose: %d\n", __LINE__
));
2422 get_current_user(&user
,p
);
2424 is_disk_op
= user_has_privileges( p
->pipe_user
.nt_user_token
, &se_diskop
);
2426 if (user
.ut
.uid
!= sec_initial_uid() && !is_disk_op
) {
2427 return WERR_ACCESS_DENIED
;
2430 /* enum_file_close_fn sends the close message to
2431 * the relevent smbd process. */
2433 r
->out
.result
= WERR_BADFILE
;
2434 share_mode_forall( enum_file_close_fn
, (void *)r
);
2435 return r
->out
.result
;
2438 /********************************************************************
2439 ********************************************************************/
2441 WERROR
_srvsvc_NetCharDevEnum(pipes_struct
*p
, struct srvsvc_NetCharDevEnum
*r
)
2443 p
->rng_fault_state
= True
;
2444 return WERR_NOT_SUPPORTED
;
2447 WERROR
_srvsvc_NetCharDevGetInfo(pipes_struct
*p
, struct srvsvc_NetCharDevGetInfo
*r
)
2449 p
->rng_fault_state
= True
;
2450 return WERR_NOT_SUPPORTED
;
2453 WERROR
_srvsvc_NetCharDevControl(pipes_struct
*p
, struct srvsvc_NetCharDevControl
*r
)
2455 p
->rng_fault_state
= True
;
2456 return WERR_NOT_SUPPORTED
;
2459 WERROR
_srvsvc_NetCharDevQEnum(pipes_struct
*p
, struct srvsvc_NetCharDevQEnum
*r
)
2461 p
->rng_fault_state
= True
;
2462 return WERR_NOT_SUPPORTED
;
2465 WERROR
_srvsvc_NetCharDevQGetInfo(pipes_struct
*p
, struct srvsvc_NetCharDevQGetInfo
*r
)
2467 p
->rng_fault_state
= True
;
2468 return WERR_NOT_SUPPORTED
;
2471 WERROR
_srvsvc_NetCharDevQSetInfo(pipes_struct
*p
, struct srvsvc_NetCharDevQSetInfo
*r
)
2473 p
->rng_fault_state
= True
;
2474 return WERR_NOT_SUPPORTED
;
2477 WERROR
_srvsvc_NetCharDevQPurge(pipes_struct
*p
, struct srvsvc_NetCharDevQPurge
*r
)
2479 p
->rng_fault_state
= True
;
2480 return WERR_NOT_SUPPORTED
;
2483 WERROR
_srvsvc_NetCharDevQPurgeSelf(pipes_struct
*p
, struct srvsvc_NetCharDevQPurgeSelf
*r
)
2485 p
->rng_fault_state
= True
;
2486 return WERR_NOT_SUPPORTED
;
2489 WERROR
_srvsvc_NetFileGetInfo(pipes_struct
*p
, struct srvsvc_NetFileGetInfo
*r
)
2491 p
->rng_fault_state
= True
;
2492 return WERR_NOT_SUPPORTED
;
2495 WERROR
_srvsvc_NetShareCheck(pipes_struct
*p
, struct srvsvc_NetShareCheck
*r
)
2497 p
->rng_fault_state
= True
;
2498 return WERR_NOT_SUPPORTED
;
2501 WERROR
_srvsvc_NetServerStatisticsGet(pipes_struct
*p
, struct srvsvc_NetServerStatisticsGet
*r
)
2503 p
->rng_fault_state
= True
;
2504 return WERR_NOT_SUPPORTED
;
2507 WERROR
_srvsvc_NetTransportAdd(pipes_struct
*p
, struct srvsvc_NetTransportAdd
*r
)
2509 p
->rng_fault_state
= True
;
2510 return WERR_NOT_SUPPORTED
;
2513 WERROR
_srvsvc_NetTransportEnum(pipes_struct
*p
, struct srvsvc_NetTransportEnum
*r
)
2515 p
->rng_fault_state
= True
;
2516 return WERR_NOT_SUPPORTED
;
2519 WERROR
_srvsvc_NetTransportDel(pipes_struct
*p
, struct srvsvc_NetTransportDel
*r
)
2521 p
->rng_fault_state
= True
;
2522 return WERR_NOT_SUPPORTED
;
2525 WERROR
_srvsvc_NetSetServiceBits(pipes_struct
*p
, struct srvsvc_NetSetServiceBits
*r
)
2527 p
->rng_fault_state
= True
;
2528 return WERR_NOT_SUPPORTED
;
2531 WERROR
_srvsvc_NetPathType(pipes_struct
*p
, struct srvsvc_NetPathType
*r
)
2533 p
->rng_fault_state
= True
;
2534 return WERR_NOT_SUPPORTED
;
2537 WERROR
_srvsvc_NetPathCanonicalize(pipes_struct
*p
, struct srvsvc_NetPathCanonicalize
*r
)
2539 p
->rng_fault_state
= True
;
2540 return WERR_NOT_SUPPORTED
;
2543 WERROR
_srvsvc_NetPathCompare(pipes_struct
*p
, struct srvsvc_NetPathCompare
*r
)
2545 p
->rng_fault_state
= True
;
2546 return WERR_NOT_SUPPORTED
;
2549 WERROR
_srvsvc_NETRPRNAMECANONICALIZE(pipes_struct
*p
, struct srvsvc_NETRPRNAMECANONICALIZE
*r
)
2551 p
->rng_fault_state
= True
;
2552 return WERR_NOT_SUPPORTED
;
2555 WERROR
_srvsvc_NetPRNameCompare(pipes_struct
*p
, struct srvsvc_NetPRNameCompare
*r
)
2557 p
->rng_fault_state
= True
;
2558 return WERR_NOT_SUPPORTED
;
2561 WERROR
_srvsvc_NetShareDelStart(pipes_struct
*p
, struct srvsvc_NetShareDelStart
*r
)
2563 p
->rng_fault_state
= True
;
2564 return WERR_NOT_SUPPORTED
;
2567 WERROR
_srvsvc_NetShareDelCommit(pipes_struct
*p
, struct srvsvc_NetShareDelCommit
*r
)
2569 p
->rng_fault_state
= True
;
2570 return WERR_NOT_SUPPORTED
;
2573 WERROR
_srvsvc_NetServerTransportAddEx(pipes_struct
*p
, struct srvsvc_NetServerTransportAddEx
*r
)
2575 p
->rng_fault_state
= True
;
2576 return WERR_NOT_SUPPORTED
;
2579 WERROR
_srvsvc_NetServerSetServiceBitsEx(pipes_struct
*p
, struct srvsvc_NetServerSetServiceBitsEx
*r
)
2581 p
->rng_fault_state
= True
;
2582 return WERR_NOT_SUPPORTED
;
2585 WERROR
_srvsvc_NETRDFSGETVERSION(pipes_struct
*p
, struct srvsvc_NETRDFSGETVERSION
*r
)
2587 p
->rng_fault_state
= True
;
2588 return WERR_NOT_SUPPORTED
;
2591 WERROR
_srvsvc_NETRDFSCREATELOCALPARTITION(pipes_struct
*p
, struct srvsvc_NETRDFSCREATELOCALPARTITION
*r
)
2593 p
->rng_fault_state
= True
;
2594 return WERR_NOT_SUPPORTED
;
2597 WERROR
_srvsvc_NETRDFSDELETELOCALPARTITION(pipes_struct
*p
, struct srvsvc_NETRDFSDELETELOCALPARTITION
*r
)
2599 p
->rng_fault_state
= True
;
2600 return WERR_NOT_SUPPORTED
;
2603 WERROR
_srvsvc_NETRDFSSETLOCALVOLUMESTATE(pipes_struct
*p
, struct srvsvc_NETRDFSSETLOCALVOLUMESTATE
*r
)
2605 p
->rng_fault_state
= True
;
2606 return WERR_NOT_SUPPORTED
;
2609 WERROR
_srvsvc_NETRDFSSETSERVERINFO(pipes_struct
*p
, struct srvsvc_NETRDFSSETSERVERINFO
*r
)
2611 p
->rng_fault_state
= True
;
2612 return WERR_NOT_SUPPORTED
;
2615 WERROR
_srvsvc_NETRDFSCREATEEXITPOINT(pipes_struct
*p
, struct srvsvc_NETRDFSCREATEEXITPOINT
*r
)
2617 p
->rng_fault_state
= True
;
2618 return WERR_NOT_SUPPORTED
;
2621 WERROR
_srvsvc_NETRDFSDELETEEXITPOINT(pipes_struct
*p
, struct srvsvc_NETRDFSDELETEEXITPOINT
*r
)
2623 p
->rng_fault_state
= True
;
2624 return WERR_NOT_SUPPORTED
;
2627 WERROR
_srvsvc_NETRDFSMODIFYPREFIX(pipes_struct
*p
, struct srvsvc_NETRDFSMODIFYPREFIX
*r
)
2629 p
->rng_fault_state
= True
;
2630 return WERR_NOT_SUPPORTED
;
2633 WERROR
_srvsvc_NETRDFSFIXLOCALVOLUME(pipes_struct
*p
, struct srvsvc_NETRDFSFIXLOCALVOLUME
*r
)
2635 p
->rng_fault_state
= True
;
2636 return WERR_NOT_SUPPORTED
;
2639 WERROR
_srvsvc_NETRDFSMANAGERREPORTSITEINFO(pipes_struct
*p
, struct srvsvc_NETRDFSMANAGERREPORTSITEINFO
*r
)
2641 p
->rng_fault_state
= True
;
2642 return WERR_NOT_SUPPORTED
;
2645 WERROR
_srvsvc_NETRSERVERTRANSPORTDELEX(pipes_struct
*p
, struct srvsvc_NETRSERVERTRANSPORTDELEX
*r
)
2647 p
->rng_fault_state
= True
;
2648 return WERR_NOT_SUPPORTED
;