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. */
27 #include "../librpc/gen_ndr/srv_srvsvc.h"
28 #include "librpc/gen_ndr/messaging.h"
29 #include "../libcli/security/security.h"
30 #include "../librpc/gen_ndr/ndr_security.h"
34 extern const struct generic_mapping file_generic_mapping;
37 #define DBGC_CLASS DBGC_RPC_SRV
39 #define MAX_SERVER_DISK_ENTRIES 15
41 /* Use for enumerating connections, pipes, & files */
43 struct file_enum_count {
46 struct srvsvc_NetFileCtr3 *ctr3;
49 struct sess_file_count {
55 /****************************************************************************
56 Count the entries belonging to a service in the connection db.
57 ****************************************************************************/
59 static int pipe_enum_fn( struct db_record *rec, void *p)
61 struct pipe_open_rec prec;
62 struct file_enum_count *fenum = (struct file_enum_count *)p;
63 struct srvsvc_NetFileInfo3 *f;
64 int i = fenum->ctr3->count;
65 char *fullpath = NULL;
68 if (rec->value.dsize != sizeof(struct pipe_open_rec))
71 memcpy(&prec, rec->value.dptr, sizeof(struct pipe_open_rec));
73 if ( !process_exists(prec.pid) ) {
77 username = uidtoname(prec.uid);
79 if ((fenum->username != NULL)
80 && !strequal(username, fenum->username)) {
84 fullpath = talloc_asprintf(fenum->ctx, "\\PIPE\\%s", prec.name );
89 f = TALLOC_REALLOC_ARRAY(fenum->ctx, fenum->ctr3->array,
90 struct srvsvc_NetFileInfo3, i+1);
92 DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
95 fenum->ctr3->array = f;
97 fenum->ctr3->array[i].fid =
98 (((uint32_t)(procid_to_pid(&prec.pid))<<16) | prec.pnum);
99 fenum->ctr3->array[i].permissions =
100 (FILE_READ_DATA|FILE_WRITE_DATA);
101 fenum->ctr3->array[i].num_locks = 0;
102 fenum->ctr3->array[i].path = fullpath;
103 fenum->ctr3->array[i].user = username;
105 fenum->ctr3->count++;
110 /*******************************************************************
111 ********************************************************************/
113 static WERROR net_enum_pipes(TALLOC_CTX *ctx,
114 const char *username,
115 struct srvsvc_NetFileCtr3 **ctr3,
118 struct file_enum_count fenum;
121 fenum.username = username;
124 if (connections_traverse(pipe_enum_fn, &fenum) == -1) {
125 DEBUG(0,("net_enum_pipes: traverse of connections.tdb "
135 /*******************************************************************
136 ********************************************************************/
138 static void enum_file_fn( const struct share_mode_entry *e,
139 const char *sharepath, const char *fname,
142 struct file_enum_count *fenum =
143 (struct file_enum_count *)private_data;
145 struct srvsvc_NetFileInfo3 *f;
146 int i = fenum->ctr3->count;
148 struct byte_range_lock *brl;
150 char *fullpath = NULL;
152 const char *username;
154 /* If the pid was not found delete the entry from connections.tdb */
156 if ( !process_exists(e->pid) ) {
160 username = uidtoname(e->uid);
162 if ((fenum->username != NULL)
163 && !strequal(username, fenum->username)) {
167 f = TALLOC_REALLOC_ARRAY(fenum->ctx, fenum->ctr3->array,
168 struct srvsvc_NetFileInfo3, i+1);
170 DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
173 fenum->ctr3->array = f;
175 /* need to count the number of locks on a file */
180 if ( (brl = brl_get_locks(talloc_tos(), &fsp)) != NULL ) {
181 num_locks = brl->num_locks;
185 if ( strcmp( fname, "." ) == 0 ) {
186 fullpath = talloc_asprintf(fenum->ctx, "C:%s", sharepath );
188 fullpath = talloc_asprintf(fenum->ctx, "C:%s/%s",
194 string_replace( fullpath, '/', '\\' );
196 /* mask out create (what ever that is) */
197 permissions = e->access_mask & (FILE_READ_DATA|FILE_WRITE_DATA);
199 /* now fill in the srvsvc_NetFileInfo3 struct */
201 fenum->ctr3->array[i].fid =
202 (((uint32_t)(procid_to_pid(&e->pid))<<16) | e->share_file_id);
203 fenum->ctr3->array[i].permissions = permissions;
204 fenum->ctr3->array[i].num_locks = num_locks;
205 fenum->ctr3->array[i].path = fullpath;
206 fenum->ctr3->array[i].user = username;
208 fenum->ctr3->count++;
211 /*******************************************************************
212 ********************************************************************/
214 static WERROR net_enum_files(TALLOC_CTX *ctx,
215 const char *username,
216 struct srvsvc_NetFileCtr3 **ctr3,
219 struct file_enum_count f_enum_cnt;
221 f_enum_cnt.ctx = ctx;
222 f_enum_cnt.username = username;
223 f_enum_cnt.ctr3 = *ctr3;
225 share_mode_forall( enum_file_fn, (void *)&f_enum_cnt );
227 *ctr3 = f_enum_cnt.ctr3;
232 /*******************************************************************
233 Utility function to get the 'type' of a share from an snum.
234 ********************************************************************/
235 static uint32 get_share_type(int snum)
237 /* work out the share type */
238 uint32 type = STYPE_DISKTREE;
240 if (lp_print_ok(snum))
242 if (strequal(lp_fstype(snum), "IPC"))
244 if (lp_administrative_share(snum))
245 type |= STYPE_HIDDEN;
250 /*******************************************************************
251 Fill in a share info level 0 structure.
252 ********************************************************************/
254 static void init_srv_share_info_0(struct pipes_struct *p,
255 struct srvsvc_NetShareInfo0 *r, int snum)
257 r->name = lp_servicename(snum);
260 /*******************************************************************
261 Fill in a share info level 1 structure.
262 ********************************************************************/
264 static void init_srv_share_info_1(struct pipes_struct *p,
265 struct srvsvc_NetShareInfo1 *r,
268 char *net_name = lp_servicename(snum);
269 char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum));
272 remark = talloc_sub_advanced(
273 p->mem_ctx, lp_servicename(snum),
274 get_current_username(), lp_pathname(snum),
275 p->session_info->utok.uid, get_current_username(),
280 r->type = get_share_type(snum);
281 r->comment = remark ? remark : "";
284 /*******************************************************************
285 Fill in a share info level 2 structure.
286 ********************************************************************/
288 static void init_srv_share_info_2(struct pipes_struct *p,
289 struct srvsvc_NetShareInfo2 *r,
294 int max_connections = lp_max_connections(snum);
295 uint32_t max_uses = max_connections!=0 ? max_connections : (uint32_t)-1;
296 char *net_name = lp_servicename(snum);
298 remark = talloc_strdup(p->mem_ctx, lp_comment(snum));
300 remark = talloc_sub_advanced(
301 p->mem_ctx, lp_servicename(snum),
302 get_current_username(), lp_pathname(snum),
303 p->session_info->utok.uid, get_current_username(),
306 path = talloc_asprintf(p->mem_ctx,
307 "C:%s", lp_pathname(snum));
311 * Change / to \\ so that win2k will see it as a valid path.
312 * This was added to enable use of browsing in win2k add
316 string_replace(path, '/', '\\');
320 r->type = get_share_type(snum);
321 r->comment = remark ? remark : "";
323 r->max_users = max_uses;
324 r->current_users = count_current_connections(net_name, false);
325 r->path = path ? path : "";
329 /*******************************************************************
330 Map any generic bits to file specific bits.
331 ********************************************************************/
333 static void map_generic_share_sd_bits(struct security_descriptor *psd)
336 struct security_acl *ps_dacl = NULL;
345 for (i = 0; i < ps_dacl->num_aces; i++) {
346 struct security_ace *psa = &ps_dacl->aces[i];
347 uint32 orig_mask = psa->access_mask;
349 se_map_generic(&psa->access_mask, &file_generic_mapping);
350 psa->access_mask |= orig_mask;
354 /*******************************************************************
355 Fill in a share info level 501 structure.
356 ********************************************************************/
358 static void init_srv_share_info_501(struct pipes_struct *p,
359 struct srvsvc_NetShareInfo501 *r, int snum)
361 const char *net_name = lp_servicename(snum);
362 char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum));
365 remark = talloc_sub_advanced(
366 p->mem_ctx, lp_servicename(snum),
367 get_current_username(), lp_pathname(snum),
368 p->session_info->utok.uid, get_current_username(),
373 r->type = get_share_type(snum);
374 r->comment = remark ? remark : "";
375 r->csc_policy = (lp_csc_policy(snum) << 4);
378 /*******************************************************************
379 Fill in a share info level 502 structure.
380 ********************************************************************/
382 static void init_srv_share_info_502(struct pipes_struct *p,
383 struct srvsvc_NetShareInfo502 *r, int snum)
385 const char *net_name = lp_servicename(snum);
387 struct security_descriptor *sd = NULL;
388 struct sec_desc_buf *sd_buf = NULL;
390 TALLOC_CTX *ctx = p->mem_ctx;
391 char *remark = talloc_strdup(ctx, lp_comment(snum));
394 remark = talloc_sub_advanced(
395 p->mem_ctx, lp_servicename(snum),
396 get_current_username(), lp_pathname(snum),
397 p->session_info->utok.uid, get_current_username(),
400 path = talloc_asprintf(ctx, "C:%s", lp_pathname(snum));
403 * Change / to \\ so that win2k will see it as a valid path. This was added to
404 * enable use of browsing in win2k add share dialog.
406 string_replace(path, '/', '\\');
409 sd = get_share_security(ctx, lp_servicename(snum), &sd_size);
411 sd_buf = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
414 r->type = get_share_type(snum);
415 r->comment = remark ? remark : "";
417 r->max_users = (uint32_t)-1;
418 r->current_users = 1; /* ??? */
419 r->path = path ? path : "";
424 /***************************************************************************
425 Fill in a share info level 1004 structure.
426 ***************************************************************************/
428 static void init_srv_share_info_1004(struct pipes_struct *p,
429 struct srvsvc_NetShareInfo1004 *r,
432 char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum));
435 remark = talloc_sub_advanced(
436 p->mem_ctx, lp_servicename(snum),
437 get_current_username(), lp_pathname(snum),
438 p->session_info->utok.uid, get_current_username(),
442 r->comment = remark ? remark : "";
445 /***************************************************************************
446 Fill in a share info level 1005 structure.
447 ***************************************************************************/
449 static void init_srv_share_info_1005(struct pipes_struct *p,
450 struct srvsvc_NetShareInfo1005 *r,
453 uint32_t dfs_flags = 0;
455 if (lp_host_msdfs() && lp_msdfs_root(snum)) {
456 dfs_flags |= SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT;
459 dfs_flags |= lp_csc_policy(snum) << SHARE_1005_CSC_POLICY_SHIFT;
461 r->dfs_flags = dfs_flags;
464 /***************************************************************************
465 Fill in a share info level 1006 structure.
466 ***************************************************************************/
468 static void init_srv_share_info_1006(struct pipes_struct *p,
469 struct srvsvc_NetShareInfo1006 *r,
472 r->max_users = (uint32_t)-1;
475 /***************************************************************************
476 Fill in a share info level 1007 structure.
477 ***************************************************************************/
479 static void init_srv_share_info_1007(struct pipes_struct *p,
480 struct srvsvc_NetShareInfo1007 *r,
484 r->alternate_directory_name = "";
487 /*******************************************************************
488 Fill in a share info level 1501 structure.
489 ********************************************************************/
491 static void init_srv_share_info_1501(struct pipes_struct *p,
492 struct sec_desc_buf *r,
495 struct security_descriptor *sd;
497 TALLOC_CTX *ctx = p->mem_ctx;
499 sd = get_share_security(ctx, lp_servicename(snum), &sd_size);
501 r = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
504 /*******************************************************************
505 True if it ends in '$'.
506 ********************************************************************/
508 static bool is_hidden_share(int snum)
510 const char *net_name = lp_servicename(snum);
512 return (net_name[strlen(net_name) - 1] == '$') ? True : False;
515 /*******************************************************************
516 Verify user is allowed to view share, access based enumeration
517 ********************************************************************/
518 static bool is_enumeration_allowed(struct pipes_struct *p,
521 if (!lp_access_based_share_enum(snum))
524 return share_access_check(p->session_info->security_token, lp_servicename(snum),
528 /*******************************************************************
529 Fill in a share info structure.
530 ********************************************************************/
532 static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
533 struct srvsvc_NetShareInfoCtr *info_ctr,
534 uint32_t *resume_handle_p,
535 uint32_t *total_entries,
539 int alloc_entries = 0;
540 int num_services = 0;
542 TALLOC_CTX *ctx = p->mem_ctx;
544 int valid_share_count = 0;
546 union srvsvc_NetShareCtr ctr;
547 uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
549 DEBUG(5,("init_srv_share_info_ctr\n"));
551 /* Ensure all the usershares are loaded. */
553 load_usershare_shares();
554 load_registry_shares();
555 num_services = lp_numservices();
558 allowed = TALLOC_ZERO_ARRAY(ctx, bool, num_services);
559 W_ERROR_HAVE_NO_MEMORY(allowed);
561 /* Count the number of entries. */
562 for (snum = 0; snum < num_services; snum++) {
563 if (lp_browseable(snum) && lp_snum_ok(snum) &&
564 is_enumeration_allowed(p, snum) &&
565 (all_shares || !is_hidden_share(snum)) ) {
566 DEBUG(10, ("counting service %s\n",
567 lp_servicename(snum) ? lp_servicename(snum) : "(null)"));
568 allowed[snum] = true;
571 DEBUG(10, ("NOT counting service %s\n",
572 lp_servicename(snum) ? lp_servicename(snum) : "(null)"));
576 if (!num_entries || (resume_handle >= num_entries)) {
580 /* Calculate alloc entries. */
581 alloc_entries = num_entries - resume_handle;
582 switch (info_ctr->level) {
584 ctr.ctr0 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr0);
585 W_ERROR_HAVE_NO_MEMORY(ctr.ctr0);
587 ctr.ctr0->count = alloc_entries;
588 ctr.ctr0->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo0, alloc_entries);
589 W_ERROR_HAVE_NO_MEMORY(ctr.ctr0->array);
591 for (snum = 0; snum < num_services; snum++) {
593 (resume_handle <= (i + valid_share_count++)) ) {
594 init_srv_share_info_0(p, &ctr.ctr0->array[i++], snum);
601 ctr.ctr1 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1);
602 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1);
604 ctr.ctr1->count = alloc_entries;
605 ctr.ctr1->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1, alloc_entries);
606 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1->array);
608 for (snum = 0; snum < num_services; snum++) {
610 (resume_handle <= (i + valid_share_count++)) ) {
611 init_srv_share_info_1(p, &ctr.ctr1->array[i++], snum);
618 ctr.ctr2 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr2);
619 W_ERROR_HAVE_NO_MEMORY(ctr.ctr2);
621 ctr.ctr2->count = alloc_entries;
622 ctr.ctr2->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo2, alloc_entries);
623 W_ERROR_HAVE_NO_MEMORY(ctr.ctr2->array);
625 for (snum = 0; snum < num_services; snum++) {
627 (resume_handle <= (i + valid_share_count++)) ) {
628 init_srv_share_info_2(p, &ctr.ctr2->array[i++], snum);
635 ctr.ctr501 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr501);
636 W_ERROR_HAVE_NO_MEMORY(ctr.ctr501);
638 ctr.ctr501->count = alloc_entries;
639 ctr.ctr501->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo501, alloc_entries);
640 W_ERROR_HAVE_NO_MEMORY(ctr.ctr501->array);
642 for (snum = 0; snum < num_services; snum++) {
644 (resume_handle <= (i + valid_share_count++)) ) {
645 init_srv_share_info_501(p, &ctr.ctr501->array[i++], snum);
652 ctr.ctr502 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr502);
653 W_ERROR_HAVE_NO_MEMORY(ctr.ctr502);
655 ctr.ctr502->count = alloc_entries;
656 ctr.ctr502->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo502, alloc_entries);
657 W_ERROR_HAVE_NO_MEMORY(ctr.ctr502->array);
659 for (snum = 0; snum < num_services; snum++) {
661 (resume_handle <= (i + valid_share_count++)) ) {
662 init_srv_share_info_502(p, &ctr.ctr502->array[i++], snum);
669 ctr.ctr1004 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1004);
670 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1004);
672 ctr.ctr1004->count = alloc_entries;
673 ctr.ctr1004->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1004, alloc_entries);
674 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1004->array);
676 for (snum = 0; snum < num_services; snum++) {
678 (resume_handle <= (i + valid_share_count++)) ) {
679 init_srv_share_info_1004(p, &ctr.ctr1004->array[i++], snum);
686 ctr.ctr1005 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1005);
687 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1005);
689 ctr.ctr1005->count = alloc_entries;
690 ctr.ctr1005->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1005, alloc_entries);
691 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1005->array);
693 for (snum = 0; snum < num_services; snum++) {
695 (resume_handle <= (i + valid_share_count++)) ) {
696 init_srv_share_info_1005(p, &ctr.ctr1005->array[i++], snum);
703 ctr.ctr1006 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1006);
704 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1006);
706 ctr.ctr1006->count = alloc_entries;
707 ctr.ctr1006->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1006, alloc_entries);
708 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1006->array);
710 for (snum = 0; snum < num_services; snum++) {
712 (resume_handle <= (i + valid_share_count++)) ) {
713 init_srv_share_info_1006(p, &ctr.ctr1006->array[i++], snum);
720 ctr.ctr1007 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1007);
721 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1007);
723 ctr.ctr1007->count = alloc_entries;
724 ctr.ctr1007->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1007, alloc_entries);
725 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1007->array);
727 for (snum = 0; snum < num_services; snum++) {
729 (resume_handle <= (i + valid_share_count++)) ) {
730 init_srv_share_info_1007(p, &ctr.ctr1007->array[i++], snum);
737 ctr.ctr1501 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1501);
738 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1501);
740 ctr.ctr1501->count = alloc_entries;
741 ctr.ctr1501->array = TALLOC_ZERO_ARRAY(ctx, struct sec_desc_buf, alloc_entries);
742 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1501->array);
744 for (snum = 0; snum < num_services; snum++) {
746 (resume_handle <= (i + valid_share_count++)) ) {
747 init_srv_share_info_1501(p, &ctr.ctr1501->array[i++], snum);
754 DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n",
756 return WERR_UNKNOWN_LEVEL;
759 *total_entries = alloc_entries;
760 if (resume_handle_p) {
762 *resume_handle_p = (num_entries == 0) ? *resume_handle_p : 0;
764 *resume_handle_p = num_entries;
773 /*******************************************************************
774 fill in a sess info level 0 structure.
775 ********************************************************************/
777 static WERROR init_srv_sess_info_0(struct pipes_struct *p,
778 struct srvsvc_NetSessCtr0 *ctr0,
779 uint32_t *resume_handle_p,
780 uint32_t *total_entries)
782 struct sessionid *session_list;
783 uint32_t num_entries = 0;
784 uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
785 *total_entries = list_sessions(p->mem_ctx, &session_list);
787 DEBUG(5,("init_srv_sess_info_0\n"));
790 if (resume_handle_p) {
791 *resume_handle_p = 0;
796 for (; resume_handle < *total_entries; resume_handle++) {
798 ctr0->array = TALLOC_REALLOC_ARRAY(p->mem_ctx,
800 struct srvsvc_NetSessInfo0,
802 W_ERROR_HAVE_NO_MEMORY(ctr0->array);
804 ctr0->array[num_entries].client =
805 session_list[resume_handle].remote_machine;
810 ctr0->count = num_entries;
812 if (resume_handle_p) {
813 if (*resume_handle_p >= *total_entries) {
814 *resume_handle_p = 0;
816 *resume_handle_p = resume_handle;
823 /*******************************************************************
824 ********************************************************************/
826 static void sess_file_fn( const struct share_mode_entry *e,
827 const char *sharepath, const char *fname,
830 struct sess_file_count *sess = (struct sess_file_count *)data;
832 if ( procid_equal(&e->pid, &sess->pid) && (sess->uid == e->uid) ) {
839 /*******************************************************************
840 ********************************************************************/
842 static int net_count_files( uid_t uid, struct server_id pid )
844 struct sess_file_count s_file_cnt;
846 s_file_cnt.count = 0;
847 s_file_cnt.uid = uid;
848 s_file_cnt.pid = pid;
850 share_mode_forall( sess_file_fn, &s_file_cnt );
852 return s_file_cnt.count;
855 /*******************************************************************
856 fill in a sess info level 1 structure.
857 ********************************************************************/
859 static WERROR init_srv_sess_info_1(struct pipes_struct *p,
860 struct srvsvc_NetSessCtr1 *ctr1,
861 uint32_t *resume_handle_p,
862 uint32_t *total_entries)
864 struct sessionid *session_list;
865 uint32_t num_entries = 0;
866 time_t now = time(NULL);
867 uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
872 if (resume_handle_p) {
873 *resume_handle_p = 0;
878 *total_entries = list_sessions(p->mem_ctx, &session_list);
880 for (; resume_handle < *total_entries; resume_handle++) {
883 struct passwd *pw = sys_getpwnam(session_list[resume_handle].username);
887 DEBUG(10,("init_srv_sess_info_1: failed to find owner: %s\n",
888 session_list[resume_handle].username));
892 connect_time = (uint32_t)(now - session_list[resume_handle].connect_start);
893 num_files = net_count_files(pw->pw_uid, session_list[resume_handle].pid);
894 guest = strequal( session_list[resume_handle].username, lp_guestaccount() );
896 ctr1->array = TALLOC_REALLOC_ARRAY(p->mem_ctx,
898 struct srvsvc_NetSessInfo1,
900 W_ERROR_HAVE_NO_MEMORY(ctr1->array);
902 ctr1->array[num_entries].client = session_list[resume_handle].remote_machine;
903 ctr1->array[num_entries].user = session_list[resume_handle].username;
904 ctr1->array[num_entries].num_open = num_files;
905 ctr1->array[num_entries].time = connect_time;
906 ctr1->array[num_entries].idle_time = 0;
907 ctr1->array[num_entries].user_flags = guest;
912 ctr1->count = num_entries;
914 if (resume_handle_p) {
915 if (*resume_handle_p >= *total_entries) {
916 *resume_handle_p = 0;
918 *resume_handle_p = resume_handle;
925 /*******************************************************************
926 fill in a conn info level 0 structure.
927 ********************************************************************/
929 static WERROR init_srv_conn_info_0(struct srvsvc_NetConnCtr0 *ctr0,
930 uint32_t *resume_handle_p,
931 uint32_t *total_entries)
933 uint32_t num_entries = 0;
934 uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
936 DEBUG(5,("init_srv_conn_info_0\n"));
939 if (resume_handle_p) {
940 *resume_handle_p = 0;
949 for (; resume_handle < *total_entries; resume_handle++) {
951 ctr0->array = TALLOC_REALLOC_ARRAY(talloc_tos(),
953 struct srvsvc_NetConnInfo0,
959 ctr0->array[num_entries].conn_id = *total_entries;
961 /* move on to creating next connection */
965 ctr0->count = num_entries;
966 *total_entries = num_entries;
968 if (resume_handle_p) {
969 if (*resume_handle_p >= *total_entries) {
970 *resume_handle_p = 0;
972 *resume_handle_p = resume_handle;
979 /*******************************************************************
980 fill in a conn info level 1 structure.
981 ********************************************************************/
983 static WERROR init_srv_conn_info_1(struct srvsvc_NetConnCtr1 *ctr1,
984 uint32_t *resume_handle_p,
985 uint32_t *total_entries)
987 uint32_t num_entries = 0;
988 uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
990 DEBUG(5,("init_srv_conn_info_1\n"));
993 if (resume_handle_p) {
994 *resume_handle_p = 0;
1003 for (; resume_handle < *total_entries; resume_handle++) {
1005 ctr1->array = TALLOC_REALLOC_ARRAY(talloc_tos(),
1007 struct srvsvc_NetConnInfo1,
1013 ctr1->array[num_entries].conn_id = *total_entries;
1014 ctr1->array[num_entries].conn_type = 0x3;
1015 ctr1->array[num_entries].num_open = 1;
1016 ctr1->array[num_entries].num_users = 1;
1017 ctr1->array[num_entries].conn_time = 3;
1018 ctr1->array[num_entries].user = "dummy_user";
1019 ctr1->array[num_entries].share = "IPC$";
1021 /* move on to creating next connection */
1025 ctr1->count = num_entries;
1026 *total_entries = num_entries;
1028 if (resume_handle_p) {
1029 if (*resume_handle_p >= *total_entries) {
1030 *resume_handle_p = 0;
1032 *resume_handle_p = resume_handle;
1039 /*******************************************************************
1041 *******************************************************************/
1043 WERROR _srvsvc_NetFileEnum(struct pipes_struct *p,
1044 struct srvsvc_NetFileEnum *r)
1046 TALLOC_CTX *ctx = NULL;
1047 struct srvsvc_NetFileCtr3 *ctr3;
1048 uint32_t resume_hnd = 0;
1051 switch (r->in.info_ctr->level) {
1055 return WERR_UNKNOWN_LEVEL;
1058 if (!nt_token_check_sid(&global_sid_Builtin_Administrators,
1059 p->session_info->security_token)) {
1060 DEBUG(1, ("Enumerating files only allowed for "
1061 "administrators\n"));
1062 return WERR_ACCESS_DENIED;
1066 ctr3 = r->in.info_ctr->ctr.ctr3;
1068 werr = WERR_INVALID_PARAM;
1072 /* TODO -- Windows enumerates
1074 (c) open directories and files */
1076 werr = net_enum_files(ctx, r->in.user, &ctr3, resume_hnd);
1077 if (!W_ERROR_IS_OK(werr)) {
1081 werr = net_enum_pipes(ctx, r->in.user, &ctr3, resume_hnd);
1082 if (!W_ERROR_IS_OK(werr)) {
1086 *r->out.totalentries = ctr3->count;
1087 r->out.info_ctr->ctr.ctr3->array = ctr3->array;
1088 r->out.info_ctr->ctr.ctr3->count = ctr3->count;
1096 /*******************************************************************
1097 _srvsvc_NetSrvGetInfo
1098 ********************************************************************/
1100 WERROR _srvsvc_NetSrvGetInfo(struct pipes_struct *p,
1101 struct srvsvc_NetSrvGetInfo *r)
1103 WERROR status = WERR_OK;
1105 DEBUG(5,("_srvsvc_NetSrvGetInfo: %d\n", __LINE__));
1107 if (!pipe_access_check(p)) {
1108 DEBUG(3, ("access denied to _srvsvc_NetSrvGetInfo\n"));
1109 return WERR_ACCESS_DENIED;
1112 switch (r->in.level) {
1114 /* Technically level 102 should only be available to
1115 Administrators but there isn't anything super-secret
1116 here, as most of it is made up. */
1119 struct srvsvc_NetSrvInfo102 *info102;
1121 info102 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo102);
1126 info102->platform_id = PLATFORM_ID_NT;
1127 info102->server_name = global_myname();
1128 info102->version_major = lp_major_announce_version();
1129 info102->version_minor = lp_minor_announce_version();
1130 info102->server_type = lp_default_server_announce();
1131 info102->comment = string_truncate(lp_serverstring(),
1132 MAX_SERVER_STRING_LENGTH);
1133 info102->users = 0xffffffff;
1134 info102->disc = 0xf;
1135 info102->hidden = 0;
1136 info102->announce = 240;
1137 info102->anndelta = 3000;
1138 info102->licenses = 100000;
1139 info102->userpath = "C:\\";
1141 r->out.info->info102 = info102;
1145 struct srvsvc_NetSrvInfo101 *info101;
1147 info101 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo101);
1152 info101->platform_id = PLATFORM_ID_NT;
1153 info101->server_name = global_myname();
1154 info101->version_major = lp_major_announce_version();
1155 info101->version_minor = lp_minor_announce_version();
1156 info101->server_type = lp_default_server_announce();
1157 info101->comment = string_truncate(lp_serverstring(),
1158 MAX_SERVER_STRING_LENGTH);
1160 r->out.info->info101 = info101;
1164 struct srvsvc_NetSrvInfo100 *info100;
1166 info100 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo100);
1171 info100->platform_id = PLATFORM_ID_NT;
1172 info100->server_name = global_myname();
1174 r->out.info->info100 = info100;
1179 status = WERR_UNKNOWN_LEVEL;
1183 DEBUG(5,("_srvsvc_NetSrvGetInfo: %d\n", __LINE__));
1188 /*******************************************************************
1189 _srvsvc_NetSrvSetInfo
1190 ********************************************************************/
1192 WERROR _srvsvc_NetSrvSetInfo(struct pipes_struct *p,
1193 struct srvsvc_NetSrvSetInfo *r)
1195 WERROR status = WERR_OK;
1197 DEBUG(5,("_srvsvc_NetSrvSetInfo: %d\n", __LINE__));
1199 /* Set up the net server set info structure. */
1201 DEBUG(5,("_srvsvc_NetSrvSetInfo: %d\n", __LINE__));
1206 /*******************************************************************
1208 ********************************************************************/
1210 WERROR _srvsvc_NetConnEnum(struct pipes_struct *p,
1211 struct srvsvc_NetConnEnum *r)
1215 DEBUG(5,("_srvsvc_NetConnEnum: %d\n", __LINE__));
1217 if (!nt_token_check_sid(&global_sid_Builtin_Administrators,
1218 p->session_info->security_token)) {
1219 DEBUG(1, ("Enumerating connections only allowed for "
1220 "administrators\n"));
1221 return WERR_ACCESS_DENIED;
1224 switch (r->in.info_ctr->level) {
1226 werr = init_srv_conn_info_0(r->in.info_ctr->ctr.ctr0,
1227 r->in.resume_handle,
1228 r->out.totalentries);
1231 werr = init_srv_conn_info_1(r->in.info_ctr->ctr.ctr1,
1232 r->in.resume_handle,
1233 r->out.totalentries);
1236 return WERR_UNKNOWN_LEVEL;
1239 DEBUG(5,("_srvsvc_NetConnEnum: %d\n", __LINE__));
1244 /*******************************************************************
1246 ********************************************************************/
1248 WERROR _srvsvc_NetSessEnum(struct pipes_struct *p,
1249 struct srvsvc_NetSessEnum *r)
1253 DEBUG(5,("_srvsvc_NetSessEnum: %d\n", __LINE__));
1255 if (!nt_token_check_sid(&global_sid_Builtin_Administrators,
1256 p->session_info->security_token)) {
1257 DEBUG(1, ("Enumerating sessions only allowed for "
1258 "administrators\n"));
1259 return WERR_ACCESS_DENIED;
1262 switch (r->in.info_ctr->level) {
1264 werr = init_srv_sess_info_0(p,
1265 r->in.info_ctr->ctr.ctr0,
1266 r->in.resume_handle,
1267 r->out.totalentries);
1270 werr = init_srv_sess_info_1(p,
1271 r->in.info_ctr->ctr.ctr1,
1272 r->in.resume_handle,
1273 r->out.totalentries);
1276 return WERR_UNKNOWN_LEVEL;
1279 DEBUG(5,("_srvsvc_NetSessEnum: %d\n", __LINE__));
1284 /*******************************************************************
1286 ********************************************************************/
1288 WERROR _srvsvc_NetSessDel(struct pipes_struct *p,
1289 struct srvsvc_NetSessDel *r)
1291 struct sessionid *session_list;
1292 int num_sessions, snum;
1293 const char *username;
1294 const char *machine;
1295 bool not_root = False;
1298 username = r->in.user;
1299 machine = r->in.client;
1301 /* strip leading backslashes if any */
1302 if (machine && machine[0] == '\\' && machine[1] == '\\') {
1306 num_sessions = list_sessions(p->mem_ctx, &session_list);
1308 DEBUG(5,("_srvsvc_NetSessDel: %d\n", __LINE__));
1310 werr = WERR_ACCESS_DENIED;
1312 /* fail out now if you are not root or not a domain admin */
1314 if ((p->session_info->utok.uid != sec_initial_uid()) &&
1315 ( ! nt_token_check_domain_rid(p->session_info->security_token,
1316 DOMAIN_RID_ADMINS))) {
1321 for (snum = 0; snum < num_sessions; snum++) {
1323 if ((strequal(session_list[snum].username, username) || username[0] == '\0' ) &&
1324 strequal(session_list[snum].remote_machine, machine)) {
1328 if (p->session_info->utok.uid != sec_initial_uid()) {
1333 ntstat = messaging_send(p->msg_ctx,
1334 session_list[snum].pid,
1335 MSG_SHUTDOWN, &data_blob_null);
1337 if (NT_STATUS_IS_OK(ntstat))
1345 DEBUG(5,("_srvsvc_NetSessDel: %d\n", __LINE__));
1352 /*******************************************************************
1353 _srvsvc_NetShareEnumAll
1354 ********************************************************************/
1356 WERROR _srvsvc_NetShareEnumAll(struct pipes_struct *p,
1357 struct srvsvc_NetShareEnumAll *r)
1361 DEBUG(5,("_srvsvc_NetShareEnumAll: %d\n", __LINE__));
1363 if (!pipe_access_check(p)) {
1364 DEBUG(3, ("access denied to _srvsvc_NetShareEnumAll\n"));
1365 return WERR_ACCESS_DENIED;
1368 /* Create the list of shares for the response. */
1369 werr = init_srv_share_info_ctr(p,
1371 r->in.resume_handle,
1372 r->out.totalentries,
1375 DEBUG(5,("_srvsvc_NetShareEnumAll: %d\n", __LINE__));
1380 /*******************************************************************
1381 _srvsvc_NetShareEnum
1382 ********************************************************************/
1384 WERROR _srvsvc_NetShareEnum(struct pipes_struct *p,
1385 struct srvsvc_NetShareEnum *r)
1389 DEBUG(5,("_srvsvc_NetShareEnum: %d\n", __LINE__));
1391 if (!pipe_access_check(p)) {
1392 DEBUG(3, ("access denied to _srvsvc_NetShareEnum\n"));
1393 return WERR_ACCESS_DENIED;
1396 /* Create the list of shares for the response. */
1397 werr = init_srv_share_info_ctr(p,
1399 r->in.resume_handle,
1400 r->out.totalentries,
1403 DEBUG(5,("_srvsvc_NetShareEnum: %d\n", __LINE__));
1408 /*******************************************************************
1409 _srvsvc_NetShareGetInfo
1410 ********************************************************************/
1412 WERROR _srvsvc_NetShareGetInfo(struct pipes_struct *p,
1413 struct srvsvc_NetShareGetInfo *r)
1415 WERROR status = WERR_OK;
1416 char *share_name = NULL;
1418 union srvsvc_NetShareInfo *info = r->out.info;
1420 DEBUG(5,("_srvsvc_NetShareGetInfo: %d\n", __LINE__));
1422 if (!r->in.share_name) {
1423 return WERR_INVALID_NAME;
1426 snum = find_service(talloc_tos(), r->in.share_name, &share_name);
1431 return WERR_INVALID_NAME;
1434 switch (r->in.level) {
1436 info->info0 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo0);
1437 W_ERROR_HAVE_NO_MEMORY(info->info0);
1438 init_srv_share_info_0(p, info->info0, snum);
1441 info->info1 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1);
1442 W_ERROR_HAVE_NO_MEMORY(info->info1);
1443 init_srv_share_info_1(p, info->info1, snum);
1446 info->info2 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo2);
1447 W_ERROR_HAVE_NO_MEMORY(info->info2);
1448 init_srv_share_info_2(p, info->info2, snum);
1451 info->info501 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo501);
1452 W_ERROR_HAVE_NO_MEMORY(info->info501);
1453 init_srv_share_info_501(p, info->info501, snum);
1456 info->info502 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo502);
1457 W_ERROR_HAVE_NO_MEMORY(info->info502);
1458 init_srv_share_info_502(p, info->info502, snum);
1461 info->info1004 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1004);
1462 W_ERROR_HAVE_NO_MEMORY(info->info1004);
1463 init_srv_share_info_1004(p, info->info1004, snum);
1466 info->info1005 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1005);
1467 W_ERROR_HAVE_NO_MEMORY(info->info1005);
1468 init_srv_share_info_1005(p, info->info1005, snum);
1471 info->info1006 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1006);
1472 W_ERROR_HAVE_NO_MEMORY(info->info1006);
1473 init_srv_share_info_1006(p, info->info1006, snum);
1476 info->info1007 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1007);
1477 W_ERROR_HAVE_NO_MEMORY(info->info1007);
1478 init_srv_share_info_1007(p, info->info1007, snum);
1481 init_srv_share_info_1501(p, info->info1501, snum);
1484 DEBUG(5,("_srvsvc_NetShareGetInfo: unsupported switch value %d\n",
1486 status = WERR_UNKNOWN_LEVEL;
1490 DEBUG(5,("_srvsvc_NetShareGetInfo: %d\n", __LINE__));
1495 /*******************************************************************
1496 Check a given DOS pathname is valid for a share.
1497 ********************************************************************/
1499 char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname)
1503 if (!dos_pathname) {
1507 ptr = talloc_strdup(ctx, dos_pathname);
1511 /* Convert any '\' paths to '/' */
1513 ptr = unix_clean_name(ctx, ptr);
1518 /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */
1519 if (strlen(ptr) > 2 && ptr[1] == ':' && ptr[0] != '/')
1522 /* Only absolute paths allowed. */
1529 /*******************************************************************
1530 _srvsvc_NetShareSetInfo. Modify share details.
1531 ********************************************************************/
1533 WERROR _srvsvc_NetShareSetInfo(struct pipes_struct *p,
1534 struct srvsvc_NetShareSetInfo *r)
1536 char *command = NULL;
1537 char *share_name = NULL;
1538 char *comment = NULL;
1539 const char *pathname = NULL;
1544 struct security_descriptor *psd = NULL;
1545 bool is_disk_op = False;
1546 int max_connections = 0;
1547 TALLOC_CTX *ctx = p->mem_ctx;
1548 union srvsvc_NetShareInfo *info = r->in.info;
1550 DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__));
1552 if (!r->in.share_name) {
1553 return WERR_INVALID_NAME;
1556 if (r->out.parm_error) {
1557 *r->out.parm_error = 0;
1560 if ( strequal(r->in.share_name,"IPC$")
1561 || ( lp_enable_asu_support() && strequal(r->in.share_name,"ADMIN$") )
1562 || strequal(r->in.share_name,"global") )
1564 DEBUG(5,("_srvsvc_NetShareSetInfo: share %s cannot be "
1565 "modified by a remote user.\n",
1566 r->in.share_name ));
1567 return WERR_ACCESS_DENIED;
1570 snum = find_service(talloc_tos(), r->in.share_name, &share_name);
1575 /* Does this share exist ? */
1577 return WERR_NET_NAME_NOT_FOUND;
1579 /* No change to printer shares. */
1580 if (lp_print_ok(snum))
1581 return WERR_ACCESS_DENIED;
1583 is_disk_op = security_token_has_privilege(p->session_info->security_token, SEC_PRIV_DISK_OPERATOR);
1585 /* fail out now if you are not root and not a disk op */
1587 if ( p->session_info->utok.uid != sec_initial_uid() && !is_disk_op ) {
1588 DEBUG(2,("_srvsvc_NetShareSetInfo: uid %u doesn't have the "
1589 "SeDiskOperatorPrivilege privilege needed to modify "
1591 (unsigned int)p->session_info->utok.uid,
1593 return WERR_ACCESS_DENIED;
1596 switch (r->in.level) {
1598 pathname = talloc_strdup(ctx, lp_pathname(snum));
1599 comment = talloc_strdup(ctx, info->info1->comment);
1600 type = info->info1->type;
1604 comment = talloc_strdup(ctx, info->info2->comment);
1605 pathname = info->info2->path;
1606 type = info->info2->type;
1607 max_connections = (info->info2->max_users == (uint32_t)-1) ?
1608 0 : info->info2->max_users;
1612 /* not supported on set but here for completeness */
1614 comment = talloc_strdup(ctx, info->info501->comment);
1615 type = info->info501->type;
1620 comment = talloc_strdup(ctx, info->info502->comment);
1621 pathname = info->info502->path;
1622 type = info->info502->type;
1623 psd = info->info502->sd_buf.sd;
1624 map_generic_share_sd_bits(psd);
1627 pathname = talloc_strdup(ctx, lp_pathname(snum));
1628 comment = talloc_strdup(ctx, info->info1004->comment);
1629 type = STYPE_DISKTREE;
1632 /* XP re-sets the csc policy even if it wasn't changed by the
1633 user, so we must compare it to see if it's what is set in
1634 smb.conf, so that we can contine other ops like setting
1636 if (((info->info1005->dfs_flags &
1637 SHARE_1005_CSC_POLICY_MASK) >>
1638 SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum))
1641 DEBUG(3, ("_srvsvc_NetShareSetInfo: client is trying to change csc policy from the network; must be done with smb.conf\n"));
1642 return WERR_ACCESS_DENIED;
1646 return WERR_ACCESS_DENIED;
1648 pathname = talloc_strdup(ctx, lp_pathname(snum));
1649 comment = talloc_strdup(ctx, lp_comment(snum));
1650 psd = info->info1501->sd;
1651 map_generic_share_sd_bits(psd);
1652 type = STYPE_DISKTREE;
1655 DEBUG(5,("_srvsvc_NetShareSetInfo: unsupported switch value %d\n",
1657 return WERR_UNKNOWN_LEVEL;
1660 /* We can only modify disk shares. */
1661 if (type != STYPE_DISKTREE) {
1662 DEBUG(5,("_srvsvc_NetShareSetInfo: share %s is not a "
1665 return WERR_ACCESS_DENIED;
1668 if (comment == NULL) {
1672 /* Check if the pathname is valid. */
1673 if (!(path = valid_share_pathname(p->mem_ctx, pathname ))) {
1674 DEBUG(5,("_srvsvc_NetShareSetInfo: invalid pathname %s\n",
1676 return WERR_OBJECT_PATH_INVALID;
1679 /* Ensure share name, pathname and comment don't contain '"' characters. */
1680 string_replace(share_name, '"', ' ');
1681 string_replace(path, '"', ' ');
1682 string_replace(comment, '"', ' ');
1684 DEBUG(10,("_srvsvc_NetShareSetInfo: change share command = %s\n",
1685 lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" ));
1687 /* Only call modify function if something changed. */
1689 if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum))
1690 || (lp_max_connections(snum) != max_connections)) {
1691 if (!lp_change_share_cmd() || !*lp_change_share_cmd()) {
1692 DEBUG(10,("_srvsvc_NetShareSetInfo: No change share command\n"));
1693 return WERR_ACCESS_DENIED;
1696 command = talloc_asprintf(p->mem_ctx,
1697 "%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
1698 lp_change_share_cmd(),
1699 get_dyn_CONFIGFILE(),
1702 comment ? comment : "",
1708 DEBUG(10,("_srvsvc_NetShareSetInfo: Running [%s]\n", command ));
1710 /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
1715 if ( (ret = smbrun(command, NULL)) == 0 ) {
1716 /* Tell everyone we updated smb.conf. */
1717 message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED,
1724 /********* END SeDiskOperatorPrivilege BLOCK *********/
1726 DEBUG(3,("_srvsvc_NetShareSetInfo: Running [%s] returned (%d)\n",
1729 TALLOC_FREE(command);
1732 return WERR_ACCESS_DENIED;
1734 DEBUG(10,("_srvsvc_NetShareSetInfo: No change to share name (%s)\n",
1738 /* Replace SD if changed. */
1740 struct security_descriptor *old_sd;
1743 old_sd = get_share_security(p->mem_ctx, lp_servicename(snum), &sd_size);
1745 if (old_sd && !security_descriptor_equal(old_sd, psd)) {
1746 if (!set_share_security(share_name, psd))
1747 DEBUG(0,("_srvsvc_NetShareSetInfo: Failed to change security info in share %s.\n",
1752 DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__));
1757 /*******************************************************************
1758 _srvsvc_NetShareAdd.
1759 Call 'add_share_command "sharename" "pathname"
1760 "comment" "max connections = "
1761 ********************************************************************/
1763 WERROR _srvsvc_NetShareAdd(struct pipes_struct *p,
1764 struct srvsvc_NetShareAdd *r)
1766 char *command = NULL;
1767 char *share_name_in = NULL;
1768 char *share_name = NULL;
1769 char *comment = NULL;
1770 char *pathname = NULL;
1775 struct security_descriptor *psd = NULL;
1777 int max_connections = 0;
1778 TALLOC_CTX *ctx = p->mem_ctx;
1780 DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__));
1782 if (r->out.parm_error) {
1783 *r->out.parm_error = 0;
1786 is_disk_op = security_token_has_privilege(p->session_info->security_token, SEC_PRIV_DISK_OPERATOR);
1788 if (p->session_info->utok.uid != sec_initial_uid() && !is_disk_op )
1789 return WERR_ACCESS_DENIED;
1791 if (!lp_add_share_cmd() || !*lp_add_share_cmd()) {
1792 DEBUG(10,("_srvsvc_NetShareAdd: No add share command\n"));
1793 return WERR_ACCESS_DENIED;
1796 switch (r->in.level) {
1798 /* No path. Not enough info in a level 0 to do anything. */
1799 return WERR_ACCESS_DENIED;
1801 /* Not enough info in a level 1 to do anything. */
1802 return WERR_ACCESS_DENIED;
1804 share_name_in = talloc_strdup(ctx, r->in.info->info2->name);
1805 comment = talloc_strdup(ctx, r->in.info->info2->comment);
1806 pathname = talloc_strdup(ctx, r->in.info->info2->path);
1807 max_connections = (r->in.info->info2->max_users == (uint32_t)-1) ?
1808 0 : r->in.info->info2->max_users;
1809 type = r->in.info->info2->type;
1812 /* No path. Not enough info in a level 501 to do anything. */
1813 return WERR_ACCESS_DENIED;
1815 share_name_in = talloc_strdup(ctx, r->in.info->info502->name);
1816 comment = talloc_strdup(ctx, r->in.info->info502->comment);
1817 pathname = talloc_strdup(ctx, r->in.info->info502->path);
1818 max_connections = (r->in.info->info502->max_users == (uint32_t)-1) ?
1819 0 : r->in.info->info502->max_users;
1820 type = r->in.info->info502->type;
1821 psd = r->in.info->info502->sd_buf.sd;
1822 map_generic_share_sd_bits(psd);
1825 /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */
1831 return WERR_ACCESS_DENIED;
1833 /* DFS only level. */
1834 return WERR_ACCESS_DENIED;
1836 DEBUG(5,("_srvsvc_NetShareAdd: unsupported switch value %d\n",
1838 return WERR_UNKNOWN_LEVEL;
1841 /* check for invalid share names */
1843 if (!share_name_in || !validate_net_name(share_name_in,
1844 INVALID_SHARENAME_CHARS,
1845 strlen(share_name_in))) {
1846 DEBUG(5,("_srvsvc_NetShareAdd: Bad sharename \"%s\"\n",
1847 share_name_in ? share_name_in : ""));
1848 return WERR_INVALID_NAME;
1851 if (strequal(share_name_in,"IPC$") || strequal(share_name_in,"global")
1852 || (lp_enable_asu_support() &&
1853 strequal(share_name_in,"ADMIN$"))) {
1854 return WERR_ACCESS_DENIED;
1857 snum = find_service(ctx, share_name_in, &share_name);
1862 /* Share already exists. */
1864 return WERR_FILE_EXISTS;
1867 /* We can only add disk shares. */
1868 if (type != STYPE_DISKTREE) {
1869 return WERR_ACCESS_DENIED;
1872 /* Check if the pathname is valid. */
1873 if (!(path = valid_share_pathname(p->mem_ctx, pathname))) {
1874 return WERR_OBJECT_PATH_INVALID;
1877 /* Ensure share name, pathname and comment don't contain '"' characters. */
1878 string_replace(share_name_in, '"', ' ');
1879 string_replace(share_name, '"', ' ');
1880 string_replace(path, '"', ' ');
1882 string_replace(comment, '"', ' ');
1885 command = talloc_asprintf(ctx,
1886 "%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
1888 get_dyn_CONFIGFILE(),
1891 comment ? comment : "",
1897 DEBUG(10,("_srvsvc_NetShareAdd: Running [%s]\n", command ));
1899 /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
1904 /* FIXME: use libnetconf here - gd */
1906 if ( (ret = smbrun(command, NULL)) == 0 ) {
1907 /* Tell everyone we updated smb.conf. */
1908 message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0,
1915 /********* END SeDiskOperatorPrivilege BLOCK *********/
1917 DEBUG(3,("_srvsvc_NetShareAdd: Running [%s] returned (%d)\n",
1920 TALLOC_FREE(command);
1923 return WERR_ACCESS_DENIED;
1926 /* Note we use share_name here, not share_name_in as
1927 we need a canonicalized name for setting security. */
1928 if (!set_share_security(share_name, psd)) {
1929 DEBUG(0,("_srvsvc_NetShareAdd: Failed to add security info to share %s.\n",
1935 * We don't call reload_services() here, the message will
1936 * cause this to be done before the next packet is read
1937 * from the client. JRA.
1940 DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__));
1945 /*******************************************************************
1947 Call "delete share command" with the share name as
1949 ********************************************************************/
1951 WERROR _srvsvc_NetShareDel(struct pipes_struct *p,
1952 struct srvsvc_NetShareDel *r)
1954 char *command = NULL;
1955 char *share_name = NULL;
1959 struct share_params *params;
1960 TALLOC_CTX *ctx = p->mem_ctx;
1962 DEBUG(5,("_srvsvc_NetShareDel: %d\n", __LINE__));
1964 if (!r->in.share_name) {
1965 return WERR_NET_NAME_NOT_FOUND;
1968 if ( strequal(r->in.share_name,"IPC$")
1969 || ( lp_enable_asu_support() && strequal(r->in.share_name,"ADMIN$") )
1970 || strequal(r->in.share_name,"global") )
1972 return WERR_ACCESS_DENIED;
1975 snum = find_service(talloc_tos(), r->in.share_name, &share_name);
1981 return WERR_NO_SUCH_SHARE;
1984 if (!(params = get_share_params(p->mem_ctx, share_name))) {
1985 return WERR_NO_SUCH_SHARE;
1988 /* No change to printer shares. */
1989 if (lp_print_ok(snum))
1990 return WERR_ACCESS_DENIED;
1992 is_disk_op = security_token_has_privilege(p->session_info->security_token, SEC_PRIV_DISK_OPERATOR);
1994 if (p->session_info->utok.uid != sec_initial_uid() && !is_disk_op )
1995 return WERR_ACCESS_DENIED;
1997 if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) {
1998 DEBUG(10,("_srvsvc_NetShareDel: No delete share command\n"));
1999 return WERR_ACCESS_DENIED;
2002 command = talloc_asprintf(ctx,
2004 lp_delete_share_cmd(),
2005 get_dyn_CONFIGFILE(),
2006 lp_servicename(snum));
2011 DEBUG(10,("_srvsvc_NetShareDel: Running [%s]\n", command ));
2013 /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
2018 if ( (ret = smbrun(command, NULL)) == 0 ) {
2019 /* Tell everyone we updated smb.conf. */
2020 message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0,
2027 /********* END SeDiskOperatorPrivilege BLOCK *********/
2029 DEBUG(3,("_srvsvc_NetShareDel: Running [%s] returned (%d)\n", command, ret ));
2032 return WERR_ACCESS_DENIED;
2034 /* Delete the SD in the database. */
2035 delete_share_security(lp_servicename(params->service));
2037 lp_killservice(params->service);
2042 /*******************************************************************
2043 _srvsvc_NetShareDelSticky
2044 ********************************************************************/
2046 WERROR _srvsvc_NetShareDelSticky(struct pipes_struct *p,
2047 struct srvsvc_NetShareDelSticky *r)
2049 struct srvsvc_NetShareDel q;
2051 DEBUG(5,("_srvsvc_NetShareDelSticky: %d\n", __LINE__));
2053 q.in.server_unc = r->in.server_unc;
2054 q.in.share_name = r->in.share_name;
2055 q.in.reserved = r->in.reserved;
2057 return _srvsvc_NetShareDel(p, &q);
2060 /*******************************************************************
2061 _srvsvc_NetRemoteTOD
2062 ********************************************************************/
2064 WERROR _srvsvc_NetRemoteTOD(struct pipes_struct *p,
2065 struct srvsvc_NetRemoteTOD *r)
2067 struct srvsvc_NetRemoteTODInfo *tod;
2069 time_t unixdate = time(NULL);
2071 /* We do this call first as if we do it *after* the gmtime call
2072 it overwrites the pointed-to values. JRA */
2074 uint32 zone = get_time_zone(unixdate)/60;
2076 DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__));
2078 if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetRemoteTODInfo)) )
2083 DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__));
2085 t = gmtime(&unixdate);
2088 tod->elapsed = unixdate;
2090 tod->hours = t->tm_hour;
2091 tod->mins = t->tm_min;
2092 tod->secs = t->tm_sec;
2094 tod->timezone = zone;
2095 tod->tinterval = 10000;
2096 tod->day = t->tm_mday;
2097 tod->month = t->tm_mon + 1;
2098 tod->year = 1900+t->tm_year;
2099 tod->weekday = t->tm_wday;
2101 DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__));
2106 /***********************************************************************************
2107 _srvsvc_NetGetFileSecurity
2108 Win9x NT tools get security descriptor.
2109 ***********************************************************************************/
2111 WERROR _srvsvc_NetGetFileSecurity(struct pipes_struct *p,
2112 struct srvsvc_NetGetFileSecurity *r)
2114 struct smb_filename *smb_fname = NULL;
2115 struct security_descriptor *psd = NULL;
2117 char *servicename = NULL;
2121 connection_struct *conn = NULL;
2122 struct sec_desc_buf *sd_buf = NULL;
2123 files_struct *fsp = NULL;
2125 char *oldcwd = NULL;
2130 werr = WERR_NET_NAME_NOT_FOUND;
2133 snum = find_service(talloc_tos(), r->in.share, &servicename);
2139 DEBUG(10, ("Could not find service %s\n", servicename));
2140 werr = WERR_NET_NAME_NOT_FOUND;
2144 nt_status = create_conn_struct(talloc_tos(), &conn, snum,
2145 lp_pathname(snum), p->session_info,
2147 if (!NT_STATUS_IS_OK(nt_status)) {
2148 DEBUG(10, ("create_conn_struct failed: %s\n",
2149 nt_errstr(nt_status)));
2150 werr = ntstatus_to_werror(nt_status);
2154 nt_status = filename_convert(talloc_tos(),
2161 if (!NT_STATUS_IS_OK(nt_status)) {
2162 werr = ntstatus_to_werror(nt_status);
2166 nt_status = SMB_VFS_CREATE_FILE(
2169 0, /* root_dir_fid */
2170 smb_fname, /* fname */
2171 FILE_READ_ATTRIBUTES, /* access_mask */
2172 FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */
2173 FILE_OPEN, /* create_disposition*/
2174 0, /* create_options */
2175 0, /* file_attributes */
2176 INTERNAL_OPEN_ONLY, /* oplock_request */
2177 0, /* allocation_size */
2178 0, /* private_flags */
2184 if (!NT_STATUS_IS_OK(nt_status)) {
2185 DEBUG(3,("_srvsvc_NetGetFileSecurity: can't open %s\n",
2186 smb_fname_str_dbg(smb_fname)));
2187 werr = ntstatus_to_werror(nt_status);
2191 nt_status = SMB_VFS_FGET_NT_ACL(fsp,
2194 |SECINFO_DACL), &psd);
2196 if (!NT_STATUS_IS_OK(nt_status)) {
2197 DEBUG(3,("_srvsvc_NetGetFileSecurity: Unable to get NT ACL "
2198 "for file %s\n", smb_fname_str_dbg(smb_fname)));
2199 werr = ntstatus_to_werror(nt_status);
2203 sd_size = ndr_size_security_descriptor(psd, 0);
2205 sd_buf = TALLOC_ZERO_P(p->mem_ctx, struct sec_desc_buf);
2211 sd_buf->sd_size = sd_size;
2214 *r->out.sd_buf = sd_buf;
2216 psd->dacl->revision = NT4_ACL_REVISION;
2218 close_file(NULL, fsp, NORMAL_CLOSE);
2219 vfs_ChDir(conn, oldcwd);
2220 SMB_VFS_DISCONNECT(conn);
2228 close_file(NULL, fsp, NORMAL_CLOSE);
2232 vfs_ChDir(conn, oldcwd);
2236 SMB_VFS_DISCONNECT(conn);
2241 TALLOC_FREE(smb_fname);
2246 /***********************************************************************************
2247 _srvsvc_NetSetFileSecurity
2248 Win9x NT tools set security descriptor.
2249 ***********************************************************************************/
2251 WERROR _srvsvc_NetSetFileSecurity(struct pipes_struct *p,
2252 struct srvsvc_NetSetFileSecurity *r)
2254 struct smb_filename *smb_fname = NULL;
2255 char *servicename = NULL;
2256 files_struct *fsp = NULL;
2260 connection_struct *conn = NULL;
2262 char *oldcwd = NULL;
2263 struct security_descriptor *psd = NULL;
2264 uint32_t security_info_sent = 0;
2269 werr = WERR_NET_NAME_NOT_FOUND;
2273 snum = find_service(talloc_tos(), r->in.share, &servicename);
2280 DEBUG(10, ("Could not find service %s\n", servicename));
2281 werr = WERR_NET_NAME_NOT_FOUND;
2285 nt_status = create_conn_struct(talloc_tos(), &conn, snum,
2286 lp_pathname(snum), p->session_info,
2288 if (!NT_STATUS_IS_OK(nt_status)) {
2289 DEBUG(10, ("create_conn_struct failed: %s\n",
2290 nt_errstr(nt_status)));
2291 werr = ntstatus_to_werror(nt_status);
2295 nt_status = filename_convert(talloc_tos(),
2302 if (!NT_STATUS_IS_OK(nt_status)) {
2303 werr = ntstatus_to_werror(nt_status);
2307 nt_status = SMB_VFS_CREATE_FILE(
2310 0, /* root_dir_fid */
2311 smb_fname, /* fname */
2312 FILE_WRITE_ATTRIBUTES, /* access_mask */
2313 FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */
2314 FILE_OPEN, /* create_disposition*/
2315 0, /* create_options */
2316 0, /* file_attributes */
2317 INTERNAL_OPEN_ONLY, /* oplock_request */
2318 0, /* allocation_size */
2319 0, /* private_flags */
2325 if (!NT_STATUS_IS_OK(nt_status)) {
2326 DEBUG(3,("_srvsvc_NetSetFileSecurity: can't open %s\n",
2327 smb_fname_str_dbg(smb_fname)));
2328 werr = ntstatus_to_werror(nt_status);
2332 psd = r->in.sd_buf->sd;
2333 security_info_sent = r->in.securityinformation;
2335 if (psd->owner_sid==0) {
2336 security_info_sent &= ~SECINFO_OWNER;
2338 if (psd->group_sid==0) {
2339 security_info_sent &= ~SECINFO_GROUP;
2342 security_info_sent &= ~SECINFO_SACL;
2345 security_info_sent &= ~SECINFO_DACL;
2348 /* Convert all the generic bits. */
2349 security_acl_map_generic(psd->dacl, &file_generic_mapping);
2350 security_acl_map_generic(psd->sacl, &file_generic_mapping);
2352 nt_status = SMB_VFS_FSET_NT_ACL(fsp,
2356 if (!NT_STATUS_IS_OK(nt_status) ) {
2357 DEBUG(3,("_srvsvc_NetSetFileSecurity: Unable to set NT ACL "
2358 "on file %s\n", r->in.share));
2359 werr = WERR_ACCESS_DENIED;
2363 close_file(NULL, fsp, NORMAL_CLOSE);
2364 vfs_ChDir(conn, oldcwd);
2365 SMB_VFS_DISCONNECT(conn);
2373 close_file(NULL, fsp, NORMAL_CLOSE);
2377 vfs_ChDir(conn, oldcwd);
2381 SMB_VFS_DISCONNECT(conn);
2386 TALLOC_FREE(smb_fname);
2391 /***********************************************************************************
2392 It may be that we want to limit users to creating shares on certain areas of the UNIX file area.
2393 We could define areas by mapping Windows style disks to points on the UNIX directory hierarchy.
2394 These disks would the disks listed by this function.
2395 Users could then create shares relative to these disks. Watch out for moving these disks around.
2396 "Nigel Williams" <nigel@veritas.com>.
2397 ***********************************************************************************/
2399 static const char *server_disks[] = {"C:"};
2401 static uint32 get_server_disk_count(void)
2403 return sizeof(server_disks)/sizeof(server_disks[0]);
2406 static uint32 init_server_disk_enum(uint32 *resume)
2408 uint32 server_disk_count = get_server_disk_count();
2410 /*resume can be an offset into the list for now*/
2412 if(*resume & 0x80000000)
2415 if(*resume > server_disk_count)
2416 *resume = server_disk_count;
2418 return server_disk_count - *resume;
2421 static const char *next_server_disk_enum(uint32 *resume)
2425 if(init_server_disk_enum(resume) == 0)
2428 disk = server_disks[*resume];
2432 DEBUG(10, ("next_server_disk_enum: reporting disk %s. resume handle %d.\n", disk, *resume));
2437 /********************************************************************
2439 ********************************************************************/
2441 WERROR _srvsvc_NetDiskEnum(struct pipes_struct *p,
2442 struct srvsvc_NetDiskEnum *r)
2445 const char *disk_name;
2446 TALLOC_CTX *ctx = p->mem_ctx;
2448 uint32_t resume = r->in.resume_handle ? *r->in.resume_handle : 0;
2452 *r->out.totalentries = init_server_disk_enum(&resume);
2454 r->out.info->disks = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetDiskInfo0,
2455 MAX_SERVER_DISK_ENTRIES);
2456 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks);
2458 /*allow one struct srvsvc_NetDiskInfo0 for null terminator*/
2460 r->out.info->count = 0;
2462 for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(&resume)); i++) {
2464 r->out.info->count++;
2466 /*copy disk name into a unicode string*/
2468 r->out.info->disks[i].disk = talloc_strdup(ctx, disk_name);
2469 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[i].disk);
2472 /* add a terminating null string. Is this there if there is more data to come? */
2474 r->out.info->count++;
2476 r->out.info->disks[i].disk = talloc_strdup(ctx, "");
2477 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[i].disk);
2479 if (r->out.resume_handle) {
2480 *r->out.resume_handle = resume;
2486 /********************************************************************
2487 _srvsvc_NetNameValidate
2488 ********************************************************************/
2490 WERROR _srvsvc_NetNameValidate(struct pipes_struct *p,
2491 struct srvsvc_NetNameValidate *r)
2493 switch (r->in.name_type) {
2495 if (!validate_net_name(r->in.name, INVALID_SHARENAME_CHARS,
2496 strlen_m(r->in.name)))
2498 DEBUG(5,("_srvsvc_NetNameValidate: Bad sharename \"%s\"\n",
2500 return WERR_INVALID_NAME;
2505 return WERR_UNKNOWN_LEVEL;
2511 /*******************************************************************
2512 ********************************************************************/
2514 struct enum_file_close_state {
2515 struct srvsvc_NetFileClose *r;
2516 struct messaging_context *msg_ctx;
2519 static void enum_file_close_fn( const struct share_mode_entry *e,
2520 const char *sharepath, const char *fname,
2521 void *private_data )
2523 char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE];
2524 struct enum_file_close_state *state =
2525 (struct enum_file_close_state *)private_data;
2526 uint32_t fid = (((uint32_t)(procid_to_pid(&e->pid))<<16) | e->share_file_id);
2528 if (fid != state->r->in.fid) {
2529 return; /* Not this file. */
2532 if (!process_exists(e->pid) ) {
2536 /* Ok - send the close message. */
2537 DEBUG(10,("enum_file_close_fn: request to close file %s, %s\n",
2539 share_mode_str(talloc_tos(), 0, e) ));
2541 share_mode_entry_to_message(msg, e);
2543 state->r->out.result = ntstatus_to_werror(
2544 messaging_send_buf(state->msg_ctx,
2545 e->pid, MSG_SMB_CLOSE_FILE,
2547 MSG_SMB_SHARE_MODE_ENTRY_SIZE));
2550 /********************************************************************
2551 Close a file given a 32-bit file id.
2552 ********************************************************************/
2554 WERROR _srvsvc_NetFileClose(struct pipes_struct *p,
2555 struct srvsvc_NetFileClose *r)
2557 struct enum_file_close_state state;
2560 DEBUG(5,("_srvsvc_NetFileClose: %d\n", __LINE__));
2562 is_disk_op = security_token_has_privilege(p->session_info->security_token, SEC_PRIV_DISK_OPERATOR);
2564 if (p->session_info->utok.uid != sec_initial_uid() && !is_disk_op) {
2565 return WERR_ACCESS_DENIED;
2568 /* enum_file_close_fn sends the close message to
2569 * the relevent smbd process. */
2571 r->out.result = WERR_BADFILE;
2573 state.msg_ctx = p->msg_ctx;
2574 share_mode_forall(enum_file_close_fn, &state);
2575 return r->out.result;
2578 /********************************************************************
2579 ********************************************************************/
2581 WERROR _srvsvc_NetCharDevEnum(struct pipes_struct *p,
2582 struct srvsvc_NetCharDevEnum *r)
2584 p->rng_fault_state = True;
2585 return WERR_NOT_SUPPORTED;
2588 WERROR _srvsvc_NetCharDevGetInfo(struct pipes_struct *p,
2589 struct srvsvc_NetCharDevGetInfo *r)
2591 p->rng_fault_state = True;
2592 return WERR_NOT_SUPPORTED;
2595 WERROR _srvsvc_NetCharDevControl(struct pipes_struct *p,
2596 struct srvsvc_NetCharDevControl *r)
2598 p->rng_fault_state = True;
2599 return WERR_NOT_SUPPORTED;
2602 WERROR _srvsvc_NetCharDevQEnum(struct pipes_struct *p,
2603 struct srvsvc_NetCharDevQEnum *r)
2605 p->rng_fault_state = True;
2606 return WERR_NOT_SUPPORTED;
2609 WERROR _srvsvc_NetCharDevQGetInfo(struct pipes_struct *p,
2610 struct srvsvc_NetCharDevQGetInfo *r)
2612 p->rng_fault_state = True;
2613 return WERR_NOT_SUPPORTED;
2616 WERROR _srvsvc_NetCharDevQSetInfo(struct pipes_struct *p,
2617 struct srvsvc_NetCharDevQSetInfo *r)
2619 p->rng_fault_state = True;
2620 return WERR_NOT_SUPPORTED;
2623 WERROR _srvsvc_NetCharDevQPurge(struct pipes_struct *p,
2624 struct srvsvc_NetCharDevQPurge *r)
2626 p->rng_fault_state = True;
2627 return WERR_NOT_SUPPORTED;
2630 WERROR _srvsvc_NetCharDevQPurgeSelf(struct pipes_struct *p,
2631 struct srvsvc_NetCharDevQPurgeSelf *r)
2633 p->rng_fault_state = True;
2634 return WERR_NOT_SUPPORTED;
2637 WERROR _srvsvc_NetFileGetInfo(struct pipes_struct *p,
2638 struct srvsvc_NetFileGetInfo *r)
2640 p->rng_fault_state = True;
2641 return WERR_NOT_SUPPORTED;
2644 WERROR _srvsvc_NetShareCheck(struct pipes_struct *p,
2645 struct srvsvc_NetShareCheck *r)
2647 p->rng_fault_state = True;
2648 return WERR_NOT_SUPPORTED;
2651 WERROR _srvsvc_NetServerStatisticsGet(struct pipes_struct *p,
2652 struct srvsvc_NetServerStatisticsGet *r)
2654 p->rng_fault_state = True;
2655 return WERR_NOT_SUPPORTED;
2658 WERROR _srvsvc_NetTransportAdd(struct pipes_struct *p,
2659 struct srvsvc_NetTransportAdd *r)
2661 p->rng_fault_state = True;
2662 return WERR_NOT_SUPPORTED;
2665 WERROR _srvsvc_NetTransportEnum(struct pipes_struct *p,
2666 struct srvsvc_NetTransportEnum *r)
2668 p->rng_fault_state = True;
2669 return WERR_NOT_SUPPORTED;
2672 WERROR _srvsvc_NetTransportDel(struct pipes_struct *p,
2673 struct srvsvc_NetTransportDel *r)
2675 p->rng_fault_state = True;
2676 return WERR_NOT_SUPPORTED;
2679 WERROR _srvsvc_NetSetServiceBits(struct pipes_struct *p,
2680 struct srvsvc_NetSetServiceBits *r)
2682 p->rng_fault_state = True;
2683 return WERR_NOT_SUPPORTED;
2686 WERROR _srvsvc_NetPathType(struct pipes_struct *p,
2687 struct srvsvc_NetPathType *r)
2689 p->rng_fault_state = True;
2690 return WERR_NOT_SUPPORTED;
2693 WERROR _srvsvc_NetPathCanonicalize(struct pipes_struct *p,
2694 struct srvsvc_NetPathCanonicalize *r)
2696 p->rng_fault_state = True;
2697 return WERR_NOT_SUPPORTED;
2700 WERROR _srvsvc_NetPathCompare(struct pipes_struct *p,
2701 struct srvsvc_NetPathCompare *r)
2703 p->rng_fault_state = True;
2704 return WERR_NOT_SUPPORTED;
2707 WERROR _srvsvc_NETRPRNAMECANONICALIZE(struct pipes_struct *p,
2708 struct srvsvc_NETRPRNAMECANONICALIZE *r)
2710 p->rng_fault_state = True;
2711 return WERR_NOT_SUPPORTED;
2714 WERROR _srvsvc_NetPRNameCompare(struct pipes_struct *p,
2715 struct srvsvc_NetPRNameCompare *r)
2717 p->rng_fault_state = True;
2718 return WERR_NOT_SUPPORTED;
2721 WERROR _srvsvc_NetShareDelStart(struct pipes_struct *p,
2722 struct srvsvc_NetShareDelStart *r)
2724 p->rng_fault_state = True;
2725 return WERR_NOT_SUPPORTED;
2728 WERROR _srvsvc_NetShareDelCommit(struct pipes_struct *p,
2729 struct srvsvc_NetShareDelCommit *r)
2731 p->rng_fault_state = True;
2732 return WERR_NOT_SUPPORTED;
2735 WERROR _srvsvc_NetServerTransportAddEx(struct pipes_struct *p,
2736 struct srvsvc_NetServerTransportAddEx *r)
2738 p->rng_fault_state = True;
2739 return WERR_NOT_SUPPORTED;
2742 WERROR _srvsvc_NetServerSetServiceBitsEx(struct pipes_struct *p,
2743 struct srvsvc_NetServerSetServiceBitsEx *r)
2745 p->rng_fault_state = True;
2746 return WERR_NOT_SUPPORTED;
2749 WERROR _srvsvc_NETRDFSGETVERSION(struct pipes_struct *p,
2750 struct srvsvc_NETRDFSGETVERSION *r)
2752 p->rng_fault_state = True;
2753 return WERR_NOT_SUPPORTED;
2756 WERROR _srvsvc_NETRDFSCREATELOCALPARTITION(struct pipes_struct *p,
2757 struct srvsvc_NETRDFSCREATELOCALPARTITION *r)
2759 p->rng_fault_state = True;
2760 return WERR_NOT_SUPPORTED;
2763 WERROR _srvsvc_NETRDFSDELETELOCALPARTITION(struct pipes_struct *p,
2764 struct srvsvc_NETRDFSDELETELOCALPARTITION *r)
2766 p->rng_fault_state = True;
2767 return WERR_NOT_SUPPORTED;
2770 WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE(struct pipes_struct *p,
2771 struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *r)
2773 p->rng_fault_state = True;
2774 return WERR_NOT_SUPPORTED;
2777 WERROR _srvsvc_NETRDFSSETSERVERINFO(struct pipes_struct *p,
2778 struct srvsvc_NETRDFSSETSERVERINFO *r)
2780 p->rng_fault_state = True;
2781 return WERR_NOT_SUPPORTED;
2784 WERROR _srvsvc_NETRDFSCREATEEXITPOINT(struct pipes_struct *p,
2785 struct srvsvc_NETRDFSCREATEEXITPOINT *r)
2787 p->rng_fault_state = True;
2788 return WERR_NOT_SUPPORTED;
2791 WERROR _srvsvc_NETRDFSDELETEEXITPOINT(struct pipes_struct *p,
2792 struct srvsvc_NETRDFSDELETEEXITPOINT *r)
2794 p->rng_fault_state = True;
2795 return WERR_NOT_SUPPORTED;
2798 WERROR _srvsvc_NETRDFSMODIFYPREFIX(struct pipes_struct *p,
2799 struct srvsvc_NETRDFSMODIFYPREFIX *r)
2801 p->rng_fault_state = True;
2802 return WERR_NOT_SUPPORTED;
2805 WERROR _srvsvc_NETRDFSFIXLOCALVOLUME(struct pipes_struct *p,
2806 struct srvsvc_NETRDFSFIXLOCALVOLUME *r)
2808 p->rng_fault_state = True;
2809 return WERR_NOT_SUPPORTED;
2812 WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO(struct pipes_struct *p,
2813 struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r)
2815 p->rng_fault_state = True;
2816 return WERR_NOT_SUPPORTED;
2819 WERROR _srvsvc_NETRSERVERTRANSPORTDELEX(struct pipes_struct *p,
2820 struct srvsvc_NETRSERVERTRANSPORTDELEX *r)
2822 p->rng_fault_state = True;
2823 return WERR_NOT_SUPPORTED;