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 "system/passwd.h"
28 #include "../librpc/gen_ndr/srv_srvsvc.h"
29 #include "librpc/gen_ndr/messaging.h"
30 #include "../libcli/security/security.h"
31 #include "../librpc/gen_ndr/ndr_security.h"
34 #include "../lib/util/util_pw.h"
35 #include "smbd/smbd.h"
39 extern const struct generic_mapping file_generic_mapping;
42 #define DBGC_CLASS DBGC_RPC_SRV
44 #define MAX_SERVER_DISK_ENTRIES 15
46 /* Use for enumerating connections, pipes, & files */
48 struct file_enum_count {
51 struct srvsvc_NetFileCtr3 *ctr3;
54 struct sess_file_count {
60 /****************************************************************************
61 Count the entries belonging to a service in the connection db.
62 ****************************************************************************/
64 static int pipe_enum_fn( struct db_record *rec, void *p)
66 struct pipe_open_rec prec;
67 struct file_enum_count *fenum = (struct file_enum_count *)p;
68 struct srvsvc_NetFileInfo3 *f;
69 int i = fenum->ctr3->count;
70 char *fullpath = NULL;
73 if (rec->value.dsize != sizeof(struct pipe_open_rec))
76 memcpy(&prec, rec->value.dptr, sizeof(struct pipe_open_rec));
78 if ( !process_exists(prec.pid) ) {
82 username = uidtoname(prec.uid);
84 if ((fenum->username != NULL)
85 && !strequal(username, fenum->username)) {
89 fullpath = talloc_asprintf(fenum->ctx, "\\PIPE\\%s", prec.name );
94 f = TALLOC_REALLOC_ARRAY(fenum->ctx, fenum->ctr3->array,
95 struct srvsvc_NetFileInfo3, i+1);
97 DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
100 fenum->ctr3->array = f;
102 fenum->ctr3->array[i].fid =
103 (((uint32_t)(procid_to_pid(&prec.pid))<<16) | prec.pnum);
104 fenum->ctr3->array[i].permissions =
105 (FILE_READ_DATA|FILE_WRITE_DATA);
106 fenum->ctr3->array[i].num_locks = 0;
107 fenum->ctr3->array[i].path = fullpath;
108 fenum->ctr3->array[i].user = username;
110 fenum->ctr3->count++;
115 /*******************************************************************
116 ********************************************************************/
118 static WERROR net_enum_pipes(TALLOC_CTX *ctx,
119 const char *username,
120 struct srvsvc_NetFileCtr3 **ctr3,
123 struct file_enum_count fenum;
126 fenum.username = username;
129 if (connections_traverse(pipe_enum_fn, &fenum) == -1) {
130 DEBUG(0,("net_enum_pipes: traverse of connections.tdb "
140 /*******************************************************************
141 ********************************************************************/
143 static void enum_file_fn( const struct share_mode_entry *e,
144 const char *sharepath, const char *fname,
147 struct file_enum_count *fenum =
148 (struct file_enum_count *)private_data;
150 struct srvsvc_NetFileInfo3 *f;
151 int i = fenum->ctr3->count;
153 struct byte_range_lock *brl;
155 char *fullpath = NULL;
157 const char *username;
159 /* If the pid was not found delete the entry from connections.tdb */
161 if ( !process_exists(e->pid) ) {
165 username = uidtoname(e->uid);
167 if ((fenum->username != NULL)
168 && !strequal(username, fenum->username)) {
172 f = TALLOC_REALLOC_ARRAY(fenum->ctx, fenum->ctr3->array,
173 struct srvsvc_NetFileInfo3, i+1);
175 DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
178 fenum->ctr3->array = f;
180 /* need to count the number of locks on a file */
185 if ( (brl = brl_get_locks(talloc_tos(), &fsp)) != NULL ) {
186 num_locks = brl->num_locks;
190 if ( strcmp( fname, "." ) == 0 ) {
191 fullpath = talloc_asprintf(fenum->ctx, "C:%s", sharepath );
193 fullpath = talloc_asprintf(fenum->ctx, "C:%s/%s",
199 string_replace( fullpath, '/', '\\' );
201 /* mask out create (what ever that is) */
202 permissions = e->access_mask & (FILE_READ_DATA|FILE_WRITE_DATA);
204 /* now fill in the srvsvc_NetFileInfo3 struct */
206 fenum->ctr3->array[i].fid =
207 (((uint32_t)(procid_to_pid(&e->pid))<<16) | e->share_file_id);
208 fenum->ctr3->array[i].permissions = permissions;
209 fenum->ctr3->array[i].num_locks = num_locks;
210 fenum->ctr3->array[i].path = fullpath;
211 fenum->ctr3->array[i].user = username;
213 fenum->ctr3->count++;
216 /*******************************************************************
217 ********************************************************************/
219 static WERROR net_enum_files(TALLOC_CTX *ctx,
220 const char *username,
221 struct srvsvc_NetFileCtr3 **ctr3,
224 struct file_enum_count f_enum_cnt;
226 f_enum_cnt.ctx = ctx;
227 f_enum_cnt.username = username;
228 f_enum_cnt.ctr3 = *ctr3;
230 share_mode_forall( enum_file_fn, (void *)&f_enum_cnt );
232 *ctr3 = f_enum_cnt.ctr3;
237 /*******************************************************************
238 Utility function to get the 'type' of a share from an snum.
239 ********************************************************************/
240 static uint32 get_share_type(int snum)
242 /* work out the share type */
243 uint32 type = STYPE_DISKTREE;
245 if (lp_print_ok(snum))
247 if (strequal(lp_fstype(snum), "IPC"))
249 if (lp_administrative_share(snum))
250 type |= STYPE_HIDDEN;
255 /*******************************************************************
256 Fill in a share info level 0 structure.
257 ********************************************************************/
259 static void init_srv_share_info_0(struct pipes_struct *p,
260 struct srvsvc_NetShareInfo0 *r, int snum)
262 r->name = lp_servicename(snum);
265 /*******************************************************************
266 Fill in a share info level 1 structure.
267 ********************************************************************/
269 static void init_srv_share_info_1(struct pipes_struct *p,
270 struct srvsvc_NetShareInfo1 *r,
273 char *net_name = lp_servicename(snum);
274 char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum));
277 remark = talloc_sub_advanced(
278 p->mem_ctx, lp_servicename(snum),
279 get_current_username(), lp_pathname(snum),
280 p->session_info->utok.uid, get_current_username(),
285 r->type = get_share_type(snum);
286 r->comment = remark ? remark : "";
289 /*******************************************************************
290 Fill in a share info level 2 structure.
291 ********************************************************************/
293 static void init_srv_share_info_2(struct pipes_struct *p,
294 struct srvsvc_NetShareInfo2 *r,
299 int max_connections = lp_max_connections(snum);
300 uint32_t max_uses = max_connections!=0 ? max_connections : (uint32_t)-1;
301 char *net_name = lp_servicename(snum);
303 remark = talloc_strdup(p->mem_ctx, lp_comment(snum));
305 remark = talloc_sub_advanced(
306 p->mem_ctx, lp_servicename(snum),
307 get_current_username(), lp_pathname(snum),
308 p->session_info->utok.uid, get_current_username(),
311 path = talloc_asprintf(p->mem_ctx,
312 "C:%s", lp_pathname(snum));
316 * Change / to \\ so that win2k will see it as a valid path.
317 * This was added to enable use of browsing in win2k add
321 string_replace(path, '/', '\\');
325 r->type = get_share_type(snum);
326 r->comment = remark ? remark : "";
328 r->max_users = max_uses;
329 r->current_users = count_current_connections(net_name, false);
330 r->path = path ? path : "";
334 /*******************************************************************
335 Map any generic bits to file specific bits.
336 ********************************************************************/
338 static void map_generic_share_sd_bits(struct security_descriptor *psd)
341 struct security_acl *ps_dacl = NULL;
350 for (i = 0; i < ps_dacl->num_aces; i++) {
351 struct security_ace *psa = &ps_dacl->aces[i];
352 uint32 orig_mask = psa->access_mask;
354 se_map_generic(&psa->access_mask, &file_generic_mapping);
355 psa->access_mask |= orig_mask;
359 /*******************************************************************
360 Fill in a share info level 501 structure.
361 ********************************************************************/
363 static void init_srv_share_info_501(struct pipes_struct *p,
364 struct srvsvc_NetShareInfo501 *r, int snum)
366 const char *net_name = lp_servicename(snum);
367 char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum));
370 remark = talloc_sub_advanced(
371 p->mem_ctx, lp_servicename(snum),
372 get_current_username(), lp_pathname(snum),
373 p->session_info->utok.uid, get_current_username(),
378 r->type = get_share_type(snum);
379 r->comment = remark ? remark : "";
380 r->csc_policy = (lp_csc_policy(snum) << 4);
383 /*******************************************************************
384 Fill in a share info level 502 structure.
385 ********************************************************************/
387 static void init_srv_share_info_502(struct pipes_struct *p,
388 struct srvsvc_NetShareInfo502 *r, int snum)
390 const char *net_name = lp_servicename(snum);
392 struct security_descriptor *sd = NULL;
393 struct sec_desc_buf *sd_buf = NULL;
395 TALLOC_CTX *ctx = p->mem_ctx;
396 char *remark = talloc_strdup(ctx, lp_comment(snum));
399 remark = talloc_sub_advanced(
400 p->mem_ctx, lp_servicename(snum),
401 get_current_username(), lp_pathname(snum),
402 p->session_info->utok.uid, get_current_username(),
405 path = talloc_asprintf(ctx, "C:%s", lp_pathname(snum));
408 * Change / to \\ so that win2k will see it as a valid path. This was added to
409 * enable use of browsing in win2k add share dialog.
411 string_replace(path, '/', '\\');
414 sd = get_share_security(ctx, lp_servicename(snum), &sd_size);
416 sd_buf = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
419 r->type = get_share_type(snum);
420 r->comment = remark ? remark : "";
422 r->max_users = (uint32_t)-1;
423 r->current_users = 1; /* ??? */
424 r->path = path ? path : "";
429 /***************************************************************************
430 Fill in a share info level 1004 structure.
431 ***************************************************************************/
433 static void init_srv_share_info_1004(struct pipes_struct *p,
434 struct srvsvc_NetShareInfo1004 *r,
437 char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum));
440 remark = talloc_sub_advanced(
441 p->mem_ctx, lp_servicename(snum),
442 get_current_username(), lp_pathname(snum),
443 p->session_info->utok.uid, get_current_username(),
447 r->comment = remark ? remark : "";
450 /***************************************************************************
451 Fill in a share info level 1005 structure.
452 ***************************************************************************/
454 static void init_srv_share_info_1005(struct pipes_struct *p,
455 struct srvsvc_NetShareInfo1005 *r,
458 uint32_t dfs_flags = 0;
460 if (lp_host_msdfs() && lp_msdfs_root(snum)) {
461 dfs_flags |= SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT;
464 dfs_flags |= lp_csc_policy(snum) << SHARE_1005_CSC_POLICY_SHIFT;
466 r->dfs_flags = dfs_flags;
469 /***************************************************************************
470 Fill in a share info level 1006 structure.
471 ***************************************************************************/
473 static void init_srv_share_info_1006(struct pipes_struct *p,
474 struct srvsvc_NetShareInfo1006 *r,
477 r->max_users = (uint32_t)-1;
480 /***************************************************************************
481 Fill in a share info level 1007 structure.
482 ***************************************************************************/
484 static void init_srv_share_info_1007(struct pipes_struct *p,
485 struct srvsvc_NetShareInfo1007 *r,
489 r->alternate_directory_name = "";
492 /*******************************************************************
493 Fill in a share info level 1501 structure.
494 ********************************************************************/
496 static void init_srv_share_info_1501(struct pipes_struct *p,
497 struct sec_desc_buf *r,
500 struct security_descriptor *sd;
502 TALLOC_CTX *ctx = p->mem_ctx;
504 sd = get_share_security(ctx, lp_servicename(snum), &sd_size);
506 r = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
509 /*******************************************************************
510 True if it ends in '$'.
511 ********************************************************************/
513 static bool is_hidden_share(int snum)
515 const char *net_name = lp_servicename(snum);
517 return (net_name[strlen(net_name) - 1] == '$') ? True : False;
520 /*******************************************************************
521 Verify user is allowed to view share, access based enumeration
522 ********************************************************************/
523 static bool is_enumeration_allowed(struct pipes_struct *p,
526 if (!lp_access_based_share_enum(snum))
529 return share_access_check(p->session_info->security_token, lp_servicename(snum),
533 /*******************************************************************
534 Fill in a share info structure.
535 ********************************************************************/
537 static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
538 struct srvsvc_NetShareInfoCtr *info_ctr,
539 uint32_t *resume_handle_p,
540 uint32_t *total_entries,
544 int alloc_entries = 0;
545 int num_services = 0;
547 TALLOC_CTX *ctx = p->mem_ctx;
549 int valid_share_count = 0;
551 union srvsvc_NetShareCtr ctr;
552 uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
554 DEBUG(5,("init_srv_share_info_ctr\n"));
556 /* Ensure all the usershares are loaded. */
558 load_usershare_shares();
559 load_registry_shares();
560 num_services = lp_numservices();
563 allowed = TALLOC_ZERO_ARRAY(ctx, bool, num_services);
564 W_ERROR_HAVE_NO_MEMORY(allowed);
566 /* Count the number of entries. */
567 for (snum = 0; snum < num_services; snum++) {
568 if (lp_browseable(snum) && lp_snum_ok(snum) &&
569 is_enumeration_allowed(p, snum) &&
570 (all_shares || !is_hidden_share(snum)) ) {
571 DEBUG(10, ("counting service %s\n",
572 lp_servicename(snum) ? lp_servicename(snum) : "(null)"));
573 allowed[snum] = true;
576 DEBUG(10, ("NOT counting service %s\n",
577 lp_servicename(snum) ? lp_servicename(snum) : "(null)"));
581 if (!num_entries || (resume_handle >= num_entries)) {
585 /* Calculate alloc entries. */
586 alloc_entries = num_entries - resume_handle;
587 switch (info_ctr->level) {
589 ctr.ctr0 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr0);
590 W_ERROR_HAVE_NO_MEMORY(ctr.ctr0);
592 ctr.ctr0->count = alloc_entries;
593 ctr.ctr0->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo0, alloc_entries);
594 W_ERROR_HAVE_NO_MEMORY(ctr.ctr0->array);
596 for (snum = 0; snum < num_services; snum++) {
598 (resume_handle <= (i + valid_share_count++)) ) {
599 init_srv_share_info_0(p, &ctr.ctr0->array[i++], snum);
606 ctr.ctr1 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1);
607 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1);
609 ctr.ctr1->count = alloc_entries;
610 ctr.ctr1->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1, alloc_entries);
611 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1->array);
613 for (snum = 0; snum < num_services; snum++) {
615 (resume_handle <= (i + valid_share_count++)) ) {
616 init_srv_share_info_1(p, &ctr.ctr1->array[i++], snum);
623 ctr.ctr2 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr2);
624 W_ERROR_HAVE_NO_MEMORY(ctr.ctr2);
626 ctr.ctr2->count = alloc_entries;
627 ctr.ctr2->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo2, alloc_entries);
628 W_ERROR_HAVE_NO_MEMORY(ctr.ctr2->array);
630 for (snum = 0; snum < num_services; snum++) {
632 (resume_handle <= (i + valid_share_count++)) ) {
633 init_srv_share_info_2(p, &ctr.ctr2->array[i++], snum);
640 ctr.ctr501 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr501);
641 W_ERROR_HAVE_NO_MEMORY(ctr.ctr501);
643 ctr.ctr501->count = alloc_entries;
644 ctr.ctr501->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo501, alloc_entries);
645 W_ERROR_HAVE_NO_MEMORY(ctr.ctr501->array);
647 for (snum = 0; snum < num_services; snum++) {
649 (resume_handle <= (i + valid_share_count++)) ) {
650 init_srv_share_info_501(p, &ctr.ctr501->array[i++], snum);
657 ctr.ctr502 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr502);
658 W_ERROR_HAVE_NO_MEMORY(ctr.ctr502);
660 ctr.ctr502->count = alloc_entries;
661 ctr.ctr502->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo502, alloc_entries);
662 W_ERROR_HAVE_NO_MEMORY(ctr.ctr502->array);
664 for (snum = 0; snum < num_services; snum++) {
666 (resume_handle <= (i + valid_share_count++)) ) {
667 init_srv_share_info_502(p, &ctr.ctr502->array[i++], snum);
674 ctr.ctr1004 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1004);
675 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1004);
677 ctr.ctr1004->count = alloc_entries;
678 ctr.ctr1004->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1004, alloc_entries);
679 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1004->array);
681 for (snum = 0; snum < num_services; snum++) {
683 (resume_handle <= (i + valid_share_count++)) ) {
684 init_srv_share_info_1004(p, &ctr.ctr1004->array[i++], snum);
691 ctr.ctr1005 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1005);
692 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1005);
694 ctr.ctr1005->count = alloc_entries;
695 ctr.ctr1005->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1005, alloc_entries);
696 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1005->array);
698 for (snum = 0; snum < num_services; snum++) {
700 (resume_handle <= (i + valid_share_count++)) ) {
701 init_srv_share_info_1005(p, &ctr.ctr1005->array[i++], snum);
708 ctr.ctr1006 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1006);
709 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1006);
711 ctr.ctr1006->count = alloc_entries;
712 ctr.ctr1006->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1006, alloc_entries);
713 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1006->array);
715 for (snum = 0; snum < num_services; snum++) {
717 (resume_handle <= (i + valid_share_count++)) ) {
718 init_srv_share_info_1006(p, &ctr.ctr1006->array[i++], snum);
725 ctr.ctr1007 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1007);
726 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1007);
728 ctr.ctr1007->count = alloc_entries;
729 ctr.ctr1007->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1007, alloc_entries);
730 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1007->array);
732 for (snum = 0; snum < num_services; snum++) {
734 (resume_handle <= (i + valid_share_count++)) ) {
735 init_srv_share_info_1007(p, &ctr.ctr1007->array[i++], snum);
742 ctr.ctr1501 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1501);
743 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1501);
745 ctr.ctr1501->count = alloc_entries;
746 ctr.ctr1501->array = TALLOC_ZERO_ARRAY(ctx, struct sec_desc_buf, alloc_entries);
747 W_ERROR_HAVE_NO_MEMORY(ctr.ctr1501->array);
749 for (snum = 0; snum < num_services; snum++) {
751 (resume_handle <= (i + valid_share_count++)) ) {
752 init_srv_share_info_1501(p, &ctr.ctr1501->array[i++], snum);
759 DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n",
761 return WERR_UNKNOWN_LEVEL;
764 *total_entries = alloc_entries;
765 if (resume_handle_p) {
767 *resume_handle_p = (num_entries == 0) ? *resume_handle_p : 0;
769 *resume_handle_p = num_entries;
778 /*******************************************************************
779 fill in a sess info level 0 structure.
780 ********************************************************************/
782 static WERROR init_srv_sess_info_0(struct pipes_struct *p,
783 struct srvsvc_NetSessCtr0 *ctr0,
784 uint32_t *resume_handle_p,
785 uint32_t *total_entries)
787 struct sessionid *session_list;
788 uint32_t num_entries = 0;
789 uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
790 *total_entries = list_sessions(p->mem_ctx, &session_list);
792 DEBUG(5,("init_srv_sess_info_0\n"));
795 if (resume_handle_p) {
796 *resume_handle_p = 0;
801 for (; resume_handle < *total_entries; resume_handle++) {
803 ctr0->array = TALLOC_REALLOC_ARRAY(p->mem_ctx,
805 struct srvsvc_NetSessInfo0,
807 W_ERROR_HAVE_NO_MEMORY(ctr0->array);
809 ctr0->array[num_entries].client =
810 session_list[resume_handle].remote_machine;
815 ctr0->count = num_entries;
817 if (resume_handle_p) {
818 if (*resume_handle_p >= *total_entries) {
819 *resume_handle_p = 0;
821 *resume_handle_p = resume_handle;
828 /*******************************************************************
829 ********************************************************************/
831 static void sess_file_fn( const struct share_mode_entry *e,
832 const char *sharepath, const char *fname,
835 struct sess_file_count *sess = (struct sess_file_count *)data;
837 if ( procid_equal(&e->pid, &sess->pid) && (sess->uid == e->uid) ) {
844 /*******************************************************************
845 ********************************************************************/
847 static int net_count_files( uid_t uid, struct server_id pid )
849 struct sess_file_count s_file_cnt;
851 s_file_cnt.count = 0;
852 s_file_cnt.uid = uid;
853 s_file_cnt.pid = pid;
855 share_mode_forall( sess_file_fn, &s_file_cnt );
857 return s_file_cnt.count;
860 /*******************************************************************
861 fill in a sess info level 1 structure.
862 ********************************************************************/
864 static WERROR init_srv_sess_info_1(struct pipes_struct *p,
865 struct srvsvc_NetSessCtr1 *ctr1,
866 uint32_t *resume_handle_p,
867 uint32_t *total_entries)
869 struct sessionid *session_list;
870 uint32_t num_entries = 0;
871 time_t now = time(NULL);
872 uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
877 if (resume_handle_p) {
878 *resume_handle_p = 0;
883 *total_entries = list_sessions(p->mem_ctx, &session_list);
885 for (; resume_handle < *total_entries; resume_handle++) {
888 struct passwd *pw = sys_getpwnam(session_list[resume_handle].username);
892 DEBUG(10,("init_srv_sess_info_1: failed to find owner: %s\n",
893 session_list[resume_handle].username));
897 connect_time = (uint32_t)(now - session_list[resume_handle].connect_start);
898 num_files = net_count_files(pw->pw_uid, session_list[resume_handle].pid);
899 guest = strequal( session_list[resume_handle].username, lp_guestaccount() );
901 ctr1->array = TALLOC_REALLOC_ARRAY(p->mem_ctx,
903 struct srvsvc_NetSessInfo1,
905 W_ERROR_HAVE_NO_MEMORY(ctr1->array);
907 ctr1->array[num_entries].client = session_list[resume_handle].remote_machine;
908 ctr1->array[num_entries].user = session_list[resume_handle].username;
909 ctr1->array[num_entries].num_open = num_files;
910 ctr1->array[num_entries].time = connect_time;
911 ctr1->array[num_entries].idle_time = 0;
912 ctr1->array[num_entries].user_flags = guest;
917 ctr1->count = num_entries;
919 if (resume_handle_p) {
920 if (*resume_handle_p >= *total_entries) {
921 *resume_handle_p = 0;
923 *resume_handle_p = resume_handle;
930 /*******************************************************************
931 fill in a conn info level 0 structure.
932 ********************************************************************/
934 static WERROR init_srv_conn_info_0(struct srvsvc_NetConnCtr0 *ctr0,
935 uint32_t *resume_handle_p,
936 uint32_t *total_entries)
938 uint32_t num_entries = 0;
939 uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
941 DEBUG(5,("init_srv_conn_info_0\n"));
944 if (resume_handle_p) {
945 *resume_handle_p = 0;
954 for (; resume_handle < *total_entries; resume_handle++) {
956 ctr0->array = TALLOC_REALLOC_ARRAY(talloc_tos(),
958 struct srvsvc_NetConnInfo0,
964 ctr0->array[num_entries].conn_id = *total_entries;
966 /* move on to creating next connection */
970 ctr0->count = num_entries;
971 *total_entries = num_entries;
973 if (resume_handle_p) {
974 if (*resume_handle_p >= *total_entries) {
975 *resume_handle_p = 0;
977 *resume_handle_p = resume_handle;
984 /*******************************************************************
985 fill in a conn info level 1 structure.
986 ********************************************************************/
988 static WERROR init_srv_conn_info_1(struct srvsvc_NetConnCtr1 *ctr1,
989 uint32_t *resume_handle_p,
990 uint32_t *total_entries)
992 uint32_t num_entries = 0;
993 uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
995 DEBUG(5,("init_srv_conn_info_1\n"));
998 if (resume_handle_p) {
999 *resume_handle_p = 0;
1008 for (; resume_handle < *total_entries; resume_handle++) {
1010 ctr1->array = TALLOC_REALLOC_ARRAY(talloc_tos(),
1012 struct srvsvc_NetConnInfo1,
1018 ctr1->array[num_entries].conn_id = *total_entries;
1019 ctr1->array[num_entries].conn_type = 0x3;
1020 ctr1->array[num_entries].num_open = 1;
1021 ctr1->array[num_entries].num_users = 1;
1022 ctr1->array[num_entries].conn_time = 3;
1023 ctr1->array[num_entries].user = "dummy_user";
1024 ctr1->array[num_entries].share = "IPC$";
1026 /* move on to creating next connection */
1030 ctr1->count = num_entries;
1031 *total_entries = num_entries;
1033 if (resume_handle_p) {
1034 if (*resume_handle_p >= *total_entries) {
1035 *resume_handle_p = 0;
1037 *resume_handle_p = resume_handle;
1044 /*******************************************************************
1046 *******************************************************************/
1048 WERROR _srvsvc_NetFileEnum(struct pipes_struct *p,
1049 struct srvsvc_NetFileEnum *r)
1051 TALLOC_CTX *ctx = NULL;
1052 struct srvsvc_NetFileCtr3 *ctr3;
1053 uint32_t resume_hnd = 0;
1056 switch (r->in.info_ctr->level) {
1060 return WERR_UNKNOWN_LEVEL;
1063 if (!nt_token_check_sid(&global_sid_Builtin_Administrators,
1064 p->session_info->security_token)) {
1065 DEBUG(1, ("Enumerating files only allowed for "
1066 "administrators\n"));
1067 return WERR_ACCESS_DENIED;
1071 ctr3 = r->in.info_ctr->ctr.ctr3;
1073 werr = WERR_INVALID_PARAM;
1077 /* TODO -- Windows enumerates
1079 (c) open directories and files */
1081 werr = net_enum_files(ctx, r->in.user, &ctr3, resume_hnd);
1082 if (!W_ERROR_IS_OK(werr)) {
1086 werr = net_enum_pipes(ctx, r->in.user, &ctr3, resume_hnd);
1087 if (!W_ERROR_IS_OK(werr)) {
1091 *r->out.totalentries = ctr3->count;
1092 r->out.info_ctr->ctr.ctr3->array = ctr3->array;
1093 r->out.info_ctr->ctr.ctr3->count = ctr3->count;
1101 /*******************************************************************
1102 _srvsvc_NetSrvGetInfo
1103 ********************************************************************/
1105 WERROR _srvsvc_NetSrvGetInfo(struct pipes_struct *p,
1106 struct srvsvc_NetSrvGetInfo *r)
1108 WERROR status = WERR_OK;
1110 DEBUG(5,("_srvsvc_NetSrvGetInfo: %d\n", __LINE__));
1112 if (!pipe_access_check(p)) {
1113 DEBUG(3, ("access denied to _srvsvc_NetSrvGetInfo\n"));
1114 return WERR_ACCESS_DENIED;
1117 switch (r->in.level) {
1119 /* Technically level 102 should only be available to
1120 Administrators but there isn't anything super-secret
1121 here, as most of it is made up. */
1124 struct srvsvc_NetSrvInfo102 *info102;
1126 info102 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo102);
1131 info102->platform_id = PLATFORM_ID_NT;
1132 info102->server_name = global_myname();
1133 info102->version_major = lp_major_announce_version();
1134 info102->version_minor = lp_minor_announce_version();
1135 info102->server_type = lp_default_server_announce();
1136 info102->comment = string_truncate(lp_serverstring(),
1137 MAX_SERVER_STRING_LENGTH);
1138 info102->users = 0xffffffff;
1139 info102->disc = 0xf;
1140 info102->hidden = 0;
1141 info102->announce = 240;
1142 info102->anndelta = 3000;
1143 info102->licenses = 100000;
1144 info102->userpath = "C:\\";
1146 r->out.info->info102 = info102;
1150 struct srvsvc_NetSrvInfo101 *info101;
1152 info101 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo101);
1157 info101->platform_id = PLATFORM_ID_NT;
1158 info101->server_name = global_myname();
1159 info101->version_major = lp_major_announce_version();
1160 info101->version_minor = lp_minor_announce_version();
1161 info101->server_type = lp_default_server_announce();
1162 info101->comment = string_truncate(lp_serverstring(),
1163 MAX_SERVER_STRING_LENGTH);
1165 r->out.info->info101 = info101;
1169 struct srvsvc_NetSrvInfo100 *info100;
1171 info100 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo100);
1176 info100->platform_id = PLATFORM_ID_NT;
1177 info100->server_name = global_myname();
1179 r->out.info->info100 = info100;
1184 status = WERR_UNKNOWN_LEVEL;
1188 DEBUG(5,("_srvsvc_NetSrvGetInfo: %d\n", __LINE__));
1193 /*******************************************************************
1194 _srvsvc_NetSrvSetInfo
1195 ********************************************************************/
1197 WERROR _srvsvc_NetSrvSetInfo(struct pipes_struct *p,
1198 struct srvsvc_NetSrvSetInfo *r)
1200 WERROR status = WERR_OK;
1202 DEBUG(5,("_srvsvc_NetSrvSetInfo: %d\n", __LINE__));
1204 /* Set up the net server set info structure. */
1206 DEBUG(5,("_srvsvc_NetSrvSetInfo: %d\n", __LINE__));
1211 /*******************************************************************
1213 ********************************************************************/
1215 WERROR _srvsvc_NetConnEnum(struct pipes_struct *p,
1216 struct srvsvc_NetConnEnum *r)
1220 DEBUG(5,("_srvsvc_NetConnEnum: %d\n", __LINE__));
1222 if (!nt_token_check_sid(&global_sid_Builtin_Administrators,
1223 p->session_info->security_token)) {
1224 DEBUG(1, ("Enumerating connections only allowed for "
1225 "administrators\n"));
1226 return WERR_ACCESS_DENIED;
1229 switch (r->in.info_ctr->level) {
1231 werr = init_srv_conn_info_0(r->in.info_ctr->ctr.ctr0,
1232 r->in.resume_handle,
1233 r->out.totalentries);
1236 werr = init_srv_conn_info_1(r->in.info_ctr->ctr.ctr1,
1237 r->in.resume_handle,
1238 r->out.totalentries);
1241 return WERR_UNKNOWN_LEVEL;
1244 DEBUG(5,("_srvsvc_NetConnEnum: %d\n", __LINE__));
1249 /*******************************************************************
1251 ********************************************************************/
1253 WERROR _srvsvc_NetSessEnum(struct pipes_struct *p,
1254 struct srvsvc_NetSessEnum *r)
1258 DEBUG(5,("_srvsvc_NetSessEnum: %d\n", __LINE__));
1260 if (!nt_token_check_sid(&global_sid_Builtin_Administrators,
1261 p->session_info->security_token)) {
1262 DEBUG(1, ("Enumerating sessions only allowed for "
1263 "administrators\n"));
1264 return WERR_ACCESS_DENIED;
1267 switch (r->in.info_ctr->level) {
1269 werr = init_srv_sess_info_0(p,
1270 r->in.info_ctr->ctr.ctr0,
1271 r->in.resume_handle,
1272 r->out.totalentries);
1275 werr = init_srv_sess_info_1(p,
1276 r->in.info_ctr->ctr.ctr1,
1277 r->in.resume_handle,
1278 r->out.totalentries);
1281 return WERR_UNKNOWN_LEVEL;
1284 DEBUG(5,("_srvsvc_NetSessEnum: %d\n", __LINE__));
1289 /*******************************************************************
1291 ********************************************************************/
1293 WERROR _srvsvc_NetSessDel(struct pipes_struct *p,
1294 struct srvsvc_NetSessDel *r)
1296 struct sessionid *session_list;
1297 int num_sessions, snum;
1298 const char *username;
1299 const char *machine;
1300 bool not_root = False;
1303 username = r->in.user;
1304 machine = r->in.client;
1306 /* strip leading backslashes if any */
1307 if (machine && machine[0] == '\\' && machine[1] == '\\') {
1311 num_sessions = list_sessions(p->mem_ctx, &session_list);
1313 DEBUG(5,("_srvsvc_NetSessDel: %d\n", __LINE__));
1315 werr = WERR_ACCESS_DENIED;
1317 /* fail out now if you are not root or not a domain admin */
1319 if ((p->session_info->utok.uid != sec_initial_uid()) &&
1320 ( ! nt_token_check_domain_rid(p->session_info->security_token,
1321 DOMAIN_RID_ADMINS))) {
1326 for (snum = 0; snum < num_sessions; snum++) {
1328 if ((strequal(session_list[snum].username, username) || username[0] == '\0' ) &&
1329 strequal(session_list[snum].remote_machine, machine)) {
1333 if (p->session_info->utok.uid != sec_initial_uid()) {
1338 ntstat = messaging_send(p->msg_ctx,
1339 session_list[snum].pid,
1340 MSG_SHUTDOWN, &data_blob_null);
1342 if (NT_STATUS_IS_OK(ntstat))
1350 DEBUG(5,("_srvsvc_NetSessDel: %d\n", __LINE__));
1357 /*******************************************************************
1358 _srvsvc_NetShareEnumAll
1359 ********************************************************************/
1361 WERROR _srvsvc_NetShareEnumAll(struct pipes_struct *p,
1362 struct srvsvc_NetShareEnumAll *r)
1366 DEBUG(5,("_srvsvc_NetShareEnumAll: %d\n", __LINE__));
1368 if (!pipe_access_check(p)) {
1369 DEBUG(3, ("access denied to _srvsvc_NetShareEnumAll\n"));
1370 return WERR_ACCESS_DENIED;
1373 /* Create the list of shares for the response. */
1374 werr = init_srv_share_info_ctr(p,
1376 r->in.resume_handle,
1377 r->out.totalentries,
1380 DEBUG(5,("_srvsvc_NetShareEnumAll: %d\n", __LINE__));
1385 /*******************************************************************
1386 _srvsvc_NetShareEnum
1387 ********************************************************************/
1389 WERROR _srvsvc_NetShareEnum(struct pipes_struct *p,
1390 struct srvsvc_NetShareEnum *r)
1394 DEBUG(5,("_srvsvc_NetShareEnum: %d\n", __LINE__));
1396 if (!pipe_access_check(p)) {
1397 DEBUG(3, ("access denied to _srvsvc_NetShareEnum\n"));
1398 return WERR_ACCESS_DENIED;
1401 /* Create the list of shares for the response. */
1402 werr = init_srv_share_info_ctr(p,
1404 r->in.resume_handle,
1405 r->out.totalentries,
1408 DEBUG(5,("_srvsvc_NetShareEnum: %d\n", __LINE__));
1413 /*******************************************************************
1414 _srvsvc_NetShareGetInfo
1415 ********************************************************************/
1417 WERROR _srvsvc_NetShareGetInfo(struct pipes_struct *p,
1418 struct srvsvc_NetShareGetInfo *r)
1420 WERROR status = WERR_OK;
1421 char *share_name = NULL;
1423 union srvsvc_NetShareInfo *info = r->out.info;
1425 DEBUG(5,("_srvsvc_NetShareGetInfo: %d\n", __LINE__));
1427 if (!r->in.share_name) {
1428 return WERR_INVALID_NAME;
1431 snum = find_service(talloc_tos(), r->in.share_name, &share_name);
1436 return WERR_INVALID_NAME;
1439 switch (r->in.level) {
1441 info->info0 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo0);
1442 W_ERROR_HAVE_NO_MEMORY(info->info0);
1443 init_srv_share_info_0(p, info->info0, snum);
1446 info->info1 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1);
1447 W_ERROR_HAVE_NO_MEMORY(info->info1);
1448 init_srv_share_info_1(p, info->info1, snum);
1451 info->info2 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo2);
1452 W_ERROR_HAVE_NO_MEMORY(info->info2);
1453 init_srv_share_info_2(p, info->info2, snum);
1456 info->info501 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo501);
1457 W_ERROR_HAVE_NO_MEMORY(info->info501);
1458 init_srv_share_info_501(p, info->info501, snum);
1461 info->info502 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo502);
1462 W_ERROR_HAVE_NO_MEMORY(info->info502);
1463 init_srv_share_info_502(p, info->info502, snum);
1466 info->info1004 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1004);
1467 W_ERROR_HAVE_NO_MEMORY(info->info1004);
1468 init_srv_share_info_1004(p, info->info1004, snum);
1471 info->info1005 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1005);
1472 W_ERROR_HAVE_NO_MEMORY(info->info1005);
1473 init_srv_share_info_1005(p, info->info1005, snum);
1476 info->info1006 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1006);
1477 W_ERROR_HAVE_NO_MEMORY(info->info1006);
1478 init_srv_share_info_1006(p, info->info1006, snum);
1481 info->info1007 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1007);
1482 W_ERROR_HAVE_NO_MEMORY(info->info1007);
1483 init_srv_share_info_1007(p, info->info1007, snum);
1486 init_srv_share_info_1501(p, info->info1501, snum);
1489 DEBUG(5,("_srvsvc_NetShareGetInfo: unsupported switch value %d\n",
1491 status = WERR_UNKNOWN_LEVEL;
1495 DEBUG(5,("_srvsvc_NetShareGetInfo: %d\n", __LINE__));
1500 /*******************************************************************
1501 Check a given DOS pathname is valid for a share.
1502 ********************************************************************/
1504 char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname)
1508 if (!dos_pathname) {
1512 ptr = talloc_strdup(ctx, dos_pathname);
1516 /* Convert any '\' paths to '/' */
1518 ptr = unix_clean_name(ctx, ptr);
1523 /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */
1524 if (strlen(ptr) > 2 && ptr[1] == ':' && ptr[0] != '/')
1527 /* Only absolute paths allowed. */
1534 /*******************************************************************
1535 _srvsvc_NetShareSetInfo. Modify share details.
1536 ********************************************************************/
1538 WERROR _srvsvc_NetShareSetInfo(struct pipes_struct *p,
1539 struct srvsvc_NetShareSetInfo *r)
1541 char *command = NULL;
1542 char *share_name = NULL;
1543 char *comment = NULL;
1544 const char *pathname = NULL;
1549 struct security_descriptor *psd = NULL;
1550 bool is_disk_op = False;
1551 int max_connections = 0;
1552 TALLOC_CTX *ctx = p->mem_ctx;
1553 union srvsvc_NetShareInfo *info = r->in.info;
1555 DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__));
1557 if (!r->in.share_name) {
1558 return WERR_INVALID_NAME;
1561 if (r->out.parm_error) {
1562 *r->out.parm_error = 0;
1565 if ( strequal(r->in.share_name,"IPC$")
1566 || ( lp_enable_asu_support() && strequal(r->in.share_name,"ADMIN$") )
1567 || strequal(r->in.share_name,"global") )
1569 DEBUG(5,("_srvsvc_NetShareSetInfo: share %s cannot be "
1570 "modified by a remote user.\n",
1571 r->in.share_name ));
1572 return WERR_ACCESS_DENIED;
1575 snum = find_service(talloc_tos(), r->in.share_name, &share_name);
1580 /* Does this share exist ? */
1582 return WERR_NET_NAME_NOT_FOUND;
1584 /* No change to printer shares. */
1585 if (lp_print_ok(snum))
1586 return WERR_ACCESS_DENIED;
1588 is_disk_op = security_token_has_privilege(p->session_info->security_token, SEC_PRIV_DISK_OPERATOR);
1590 /* fail out now if you are not root and not a disk op */
1592 if ( p->session_info->utok.uid != sec_initial_uid() && !is_disk_op ) {
1593 DEBUG(2,("_srvsvc_NetShareSetInfo: uid %u doesn't have the "
1594 "SeDiskOperatorPrivilege privilege needed to modify "
1596 (unsigned int)p->session_info->utok.uid,
1598 return WERR_ACCESS_DENIED;
1601 switch (r->in.level) {
1603 pathname = talloc_strdup(ctx, lp_pathname(snum));
1604 comment = talloc_strdup(ctx, info->info1->comment);
1605 type = info->info1->type;
1609 comment = talloc_strdup(ctx, info->info2->comment);
1610 pathname = info->info2->path;
1611 type = info->info2->type;
1612 max_connections = (info->info2->max_users == (uint32_t)-1) ?
1613 0 : info->info2->max_users;
1617 /* not supported on set but here for completeness */
1619 comment = talloc_strdup(ctx, info->info501->comment);
1620 type = info->info501->type;
1625 comment = talloc_strdup(ctx, info->info502->comment);
1626 pathname = info->info502->path;
1627 type = info->info502->type;
1628 psd = info->info502->sd_buf.sd;
1629 map_generic_share_sd_bits(psd);
1632 pathname = talloc_strdup(ctx, lp_pathname(snum));
1633 comment = talloc_strdup(ctx, info->info1004->comment);
1634 type = STYPE_DISKTREE;
1637 /* XP re-sets the csc policy even if it wasn't changed by the
1638 user, so we must compare it to see if it's what is set in
1639 smb.conf, so that we can contine other ops like setting
1641 if (((info->info1005->dfs_flags &
1642 SHARE_1005_CSC_POLICY_MASK) >>
1643 SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum))
1646 DEBUG(3, ("_srvsvc_NetShareSetInfo: client is trying to change csc policy from the network; must be done with smb.conf\n"));
1647 return WERR_ACCESS_DENIED;
1651 return WERR_ACCESS_DENIED;
1653 pathname = talloc_strdup(ctx, lp_pathname(snum));
1654 comment = talloc_strdup(ctx, lp_comment(snum));
1655 psd = info->info1501->sd;
1656 map_generic_share_sd_bits(psd);
1657 type = STYPE_DISKTREE;
1660 DEBUG(5,("_srvsvc_NetShareSetInfo: unsupported switch value %d\n",
1662 return WERR_UNKNOWN_LEVEL;
1665 /* We can only modify disk shares. */
1666 if (type != STYPE_DISKTREE) {
1667 DEBUG(5,("_srvsvc_NetShareSetInfo: share %s is not a "
1670 return WERR_ACCESS_DENIED;
1673 if (comment == NULL) {
1677 /* Check if the pathname is valid. */
1678 if (!(path = valid_share_pathname(p->mem_ctx, pathname ))) {
1679 DEBUG(5,("_srvsvc_NetShareSetInfo: invalid pathname %s\n",
1681 return WERR_OBJECT_PATH_INVALID;
1684 /* Ensure share name, pathname and comment don't contain '"' characters. */
1685 string_replace(share_name, '"', ' ');
1686 string_replace(path, '"', ' ');
1687 string_replace(comment, '"', ' ');
1689 DEBUG(10,("_srvsvc_NetShareSetInfo: change share command = %s\n",
1690 lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" ));
1692 /* Only call modify function if something changed. */
1694 if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum))
1695 || (lp_max_connections(snum) != max_connections)) {
1696 if (!lp_change_share_cmd() || !*lp_change_share_cmd()) {
1697 DEBUG(10,("_srvsvc_NetShareSetInfo: No change share command\n"));
1698 return WERR_ACCESS_DENIED;
1701 command = talloc_asprintf(p->mem_ctx,
1702 "%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
1703 lp_change_share_cmd(),
1704 get_dyn_CONFIGFILE(),
1707 comment ? comment : "",
1713 DEBUG(10,("_srvsvc_NetShareSetInfo: Running [%s]\n", command ));
1715 /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
1720 if ( (ret = smbrun(command, NULL)) == 0 ) {
1721 /* Tell everyone we updated smb.conf. */
1722 message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED,
1729 /********* END SeDiskOperatorPrivilege BLOCK *********/
1731 DEBUG(3,("_srvsvc_NetShareSetInfo: Running [%s] returned (%d)\n",
1734 TALLOC_FREE(command);
1737 return WERR_ACCESS_DENIED;
1739 DEBUG(10,("_srvsvc_NetShareSetInfo: No change to share name (%s)\n",
1743 /* Replace SD if changed. */
1745 struct security_descriptor *old_sd;
1748 old_sd = get_share_security(p->mem_ctx, lp_servicename(snum), &sd_size);
1750 if (old_sd && !security_descriptor_equal(old_sd, psd)) {
1751 if (!set_share_security(share_name, psd))
1752 DEBUG(0,("_srvsvc_NetShareSetInfo: Failed to change security info in share %s.\n",
1757 DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__));
1762 /*******************************************************************
1763 _srvsvc_NetShareAdd.
1764 Call 'add_share_command "sharename" "pathname"
1765 "comment" "max connections = "
1766 ********************************************************************/
1768 WERROR _srvsvc_NetShareAdd(struct pipes_struct *p,
1769 struct srvsvc_NetShareAdd *r)
1771 char *command = NULL;
1772 char *share_name_in = NULL;
1773 char *share_name = NULL;
1774 char *comment = NULL;
1775 char *pathname = NULL;
1780 struct security_descriptor *psd = NULL;
1782 int max_connections = 0;
1783 TALLOC_CTX *ctx = p->mem_ctx;
1785 DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__));
1787 if (r->out.parm_error) {
1788 *r->out.parm_error = 0;
1791 is_disk_op = security_token_has_privilege(p->session_info->security_token, SEC_PRIV_DISK_OPERATOR);
1793 if (p->session_info->utok.uid != sec_initial_uid() && !is_disk_op )
1794 return WERR_ACCESS_DENIED;
1796 if (!lp_add_share_cmd() || !*lp_add_share_cmd()) {
1797 DEBUG(10,("_srvsvc_NetShareAdd: No add share command\n"));
1798 return WERR_ACCESS_DENIED;
1801 switch (r->in.level) {
1803 /* No path. Not enough info in a level 0 to do anything. */
1804 return WERR_ACCESS_DENIED;
1806 /* Not enough info in a level 1 to do anything. */
1807 return WERR_ACCESS_DENIED;
1809 share_name_in = talloc_strdup(ctx, r->in.info->info2->name);
1810 comment = talloc_strdup(ctx, r->in.info->info2->comment);
1811 pathname = talloc_strdup(ctx, r->in.info->info2->path);
1812 max_connections = (r->in.info->info2->max_users == (uint32_t)-1) ?
1813 0 : r->in.info->info2->max_users;
1814 type = r->in.info->info2->type;
1817 /* No path. Not enough info in a level 501 to do anything. */
1818 return WERR_ACCESS_DENIED;
1820 share_name_in = talloc_strdup(ctx, r->in.info->info502->name);
1821 comment = talloc_strdup(ctx, r->in.info->info502->comment);
1822 pathname = talloc_strdup(ctx, r->in.info->info502->path);
1823 max_connections = (r->in.info->info502->max_users == (uint32_t)-1) ?
1824 0 : r->in.info->info502->max_users;
1825 type = r->in.info->info502->type;
1826 psd = r->in.info->info502->sd_buf.sd;
1827 map_generic_share_sd_bits(psd);
1830 /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */
1836 return WERR_ACCESS_DENIED;
1838 /* DFS only level. */
1839 return WERR_ACCESS_DENIED;
1841 DEBUG(5,("_srvsvc_NetShareAdd: unsupported switch value %d\n",
1843 return WERR_UNKNOWN_LEVEL;
1846 /* check for invalid share names */
1848 if (!share_name_in || !validate_net_name(share_name_in,
1849 INVALID_SHARENAME_CHARS,
1850 strlen(share_name_in))) {
1851 DEBUG(5,("_srvsvc_NetShareAdd: Bad sharename \"%s\"\n",
1852 share_name_in ? share_name_in : ""));
1853 return WERR_INVALID_NAME;
1856 if (strequal(share_name_in,"IPC$") || strequal(share_name_in,"global")
1857 || (lp_enable_asu_support() &&
1858 strequal(share_name_in,"ADMIN$"))) {
1859 return WERR_ACCESS_DENIED;
1862 snum = find_service(ctx, share_name_in, &share_name);
1867 /* Share already exists. */
1869 return WERR_FILE_EXISTS;
1872 /* We can only add disk shares. */
1873 if (type != STYPE_DISKTREE) {
1874 return WERR_ACCESS_DENIED;
1877 /* Check if the pathname is valid. */
1878 if (!(path = valid_share_pathname(p->mem_ctx, pathname))) {
1879 return WERR_OBJECT_PATH_INVALID;
1882 /* Ensure share name, pathname and comment don't contain '"' characters. */
1883 string_replace(share_name_in, '"', ' ');
1884 string_replace(share_name, '"', ' ');
1885 string_replace(path, '"', ' ');
1887 string_replace(comment, '"', ' ');
1890 command = talloc_asprintf(ctx,
1891 "%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
1893 get_dyn_CONFIGFILE(),
1896 comment ? comment : "",
1902 DEBUG(10,("_srvsvc_NetShareAdd: Running [%s]\n", command ));
1904 /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
1909 /* FIXME: use libnetconf here - gd */
1911 if ( (ret = smbrun(command, NULL)) == 0 ) {
1912 /* Tell everyone we updated smb.conf. */
1913 message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0,
1920 /********* END SeDiskOperatorPrivilege BLOCK *********/
1922 DEBUG(3,("_srvsvc_NetShareAdd: Running [%s] returned (%d)\n",
1925 TALLOC_FREE(command);
1928 return WERR_ACCESS_DENIED;
1931 /* Note we use share_name here, not share_name_in as
1932 we need a canonicalized name for setting security. */
1933 if (!set_share_security(share_name, psd)) {
1934 DEBUG(0,("_srvsvc_NetShareAdd: Failed to add security info to share %s.\n",
1940 * We don't call reload_services() here, the message will
1941 * cause this to be done before the next packet is read
1942 * from the client. JRA.
1945 DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__));
1950 /*******************************************************************
1952 Call "delete share command" with the share name as
1954 ********************************************************************/
1956 WERROR _srvsvc_NetShareDel(struct pipes_struct *p,
1957 struct srvsvc_NetShareDel *r)
1959 char *command = NULL;
1960 char *share_name = NULL;
1964 struct share_params *params;
1965 TALLOC_CTX *ctx = p->mem_ctx;
1967 DEBUG(5,("_srvsvc_NetShareDel: %d\n", __LINE__));
1969 if (!r->in.share_name) {
1970 return WERR_NET_NAME_NOT_FOUND;
1973 if ( strequal(r->in.share_name,"IPC$")
1974 || ( lp_enable_asu_support() && strequal(r->in.share_name,"ADMIN$") )
1975 || strequal(r->in.share_name,"global") )
1977 return WERR_ACCESS_DENIED;
1980 snum = find_service(talloc_tos(), r->in.share_name, &share_name);
1986 return WERR_NO_SUCH_SHARE;
1989 if (!(params = get_share_params(p->mem_ctx, share_name))) {
1990 return WERR_NO_SUCH_SHARE;
1993 /* No change to printer shares. */
1994 if (lp_print_ok(snum))
1995 return WERR_ACCESS_DENIED;
1997 is_disk_op = security_token_has_privilege(p->session_info->security_token, SEC_PRIV_DISK_OPERATOR);
1999 if (p->session_info->utok.uid != sec_initial_uid() && !is_disk_op )
2000 return WERR_ACCESS_DENIED;
2002 if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) {
2003 DEBUG(10,("_srvsvc_NetShareDel: No delete share command\n"));
2004 return WERR_ACCESS_DENIED;
2007 command = talloc_asprintf(ctx,
2009 lp_delete_share_cmd(),
2010 get_dyn_CONFIGFILE(),
2011 lp_servicename(snum));
2016 DEBUG(10,("_srvsvc_NetShareDel: Running [%s]\n", command ));
2018 /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
2023 if ( (ret = smbrun(command, NULL)) == 0 ) {
2024 /* Tell everyone we updated smb.conf. */
2025 message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0,
2032 /********* END SeDiskOperatorPrivilege BLOCK *********/
2034 DEBUG(3,("_srvsvc_NetShareDel: Running [%s] returned (%d)\n", command, ret ));
2037 return WERR_ACCESS_DENIED;
2039 /* Delete the SD in the database. */
2040 delete_share_security(lp_servicename(params->service));
2042 lp_killservice(params->service);
2047 /*******************************************************************
2048 _srvsvc_NetShareDelSticky
2049 ********************************************************************/
2051 WERROR _srvsvc_NetShareDelSticky(struct pipes_struct *p,
2052 struct srvsvc_NetShareDelSticky *r)
2054 struct srvsvc_NetShareDel q;
2056 DEBUG(5,("_srvsvc_NetShareDelSticky: %d\n", __LINE__));
2058 q.in.server_unc = r->in.server_unc;
2059 q.in.share_name = r->in.share_name;
2060 q.in.reserved = r->in.reserved;
2062 return _srvsvc_NetShareDel(p, &q);
2065 /*******************************************************************
2066 _srvsvc_NetRemoteTOD
2067 ********************************************************************/
2069 WERROR _srvsvc_NetRemoteTOD(struct pipes_struct *p,
2070 struct srvsvc_NetRemoteTOD *r)
2072 struct srvsvc_NetRemoteTODInfo *tod;
2074 time_t unixdate = time(NULL);
2076 /* We do this call first as if we do it *after* the gmtime call
2077 it overwrites the pointed-to values. JRA */
2079 uint32 zone = get_time_zone(unixdate)/60;
2081 DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__));
2083 if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetRemoteTODInfo)) )
2088 DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__));
2090 t = gmtime(&unixdate);
2093 tod->elapsed = unixdate;
2095 tod->hours = t->tm_hour;
2096 tod->mins = t->tm_min;
2097 tod->secs = t->tm_sec;
2099 tod->timezone = zone;
2100 tod->tinterval = 10000;
2101 tod->day = t->tm_mday;
2102 tod->month = t->tm_mon + 1;
2103 tod->year = 1900+t->tm_year;
2104 tod->weekday = t->tm_wday;
2106 DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__));
2111 /***********************************************************************************
2112 _srvsvc_NetGetFileSecurity
2113 Win9x NT tools get security descriptor.
2114 ***********************************************************************************/
2116 WERROR _srvsvc_NetGetFileSecurity(struct pipes_struct *p,
2117 struct srvsvc_NetGetFileSecurity *r)
2119 struct smb_filename *smb_fname = NULL;
2120 struct security_descriptor *psd = NULL;
2122 char *servicename = NULL;
2126 connection_struct *conn = NULL;
2127 struct sec_desc_buf *sd_buf = NULL;
2128 files_struct *fsp = NULL;
2130 char *oldcwd = NULL;
2135 werr = WERR_NET_NAME_NOT_FOUND;
2138 snum = find_service(talloc_tos(), r->in.share, &servicename);
2144 DEBUG(10, ("Could not find service %s\n", servicename));
2145 werr = WERR_NET_NAME_NOT_FOUND;
2149 nt_status = create_conn_struct(talloc_tos(), &conn, snum,
2150 lp_pathname(snum), p->session_info,
2152 if (!NT_STATUS_IS_OK(nt_status)) {
2153 DEBUG(10, ("create_conn_struct failed: %s\n",
2154 nt_errstr(nt_status)));
2155 werr = ntstatus_to_werror(nt_status);
2159 nt_status = filename_convert(talloc_tos(),
2166 if (!NT_STATUS_IS_OK(nt_status)) {
2167 werr = ntstatus_to_werror(nt_status);
2171 nt_status = SMB_VFS_CREATE_FILE(
2174 0, /* root_dir_fid */
2175 smb_fname, /* fname */
2176 FILE_READ_ATTRIBUTES, /* access_mask */
2177 FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */
2178 FILE_OPEN, /* create_disposition*/
2179 0, /* create_options */
2180 0, /* file_attributes */
2181 INTERNAL_OPEN_ONLY, /* oplock_request */
2182 0, /* allocation_size */
2183 0, /* private_flags */
2189 if (!NT_STATUS_IS_OK(nt_status)) {
2190 DEBUG(3,("_srvsvc_NetGetFileSecurity: can't open %s\n",
2191 smb_fname_str_dbg(smb_fname)));
2192 werr = ntstatus_to_werror(nt_status);
2196 nt_status = SMB_VFS_FGET_NT_ACL(fsp,
2199 |SECINFO_DACL), &psd);
2201 if (!NT_STATUS_IS_OK(nt_status)) {
2202 DEBUG(3,("_srvsvc_NetGetFileSecurity: Unable to get NT ACL "
2203 "for file %s\n", smb_fname_str_dbg(smb_fname)));
2204 werr = ntstatus_to_werror(nt_status);
2208 sd_size = ndr_size_security_descriptor(psd, 0);
2210 sd_buf = TALLOC_ZERO_P(p->mem_ctx, struct sec_desc_buf);
2216 sd_buf->sd_size = sd_size;
2219 *r->out.sd_buf = sd_buf;
2221 psd->dacl->revision = NT4_ACL_REVISION;
2223 close_file(NULL, fsp, NORMAL_CLOSE);
2224 vfs_ChDir(conn, oldcwd);
2225 SMB_VFS_DISCONNECT(conn);
2233 close_file(NULL, fsp, NORMAL_CLOSE);
2237 vfs_ChDir(conn, oldcwd);
2241 SMB_VFS_DISCONNECT(conn);
2246 TALLOC_FREE(smb_fname);
2251 /***********************************************************************************
2252 _srvsvc_NetSetFileSecurity
2253 Win9x NT tools set security descriptor.
2254 ***********************************************************************************/
2256 WERROR _srvsvc_NetSetFileSecurity(struct pipes_struct *p,
2257 struct srvsvc_NetSetFileSecurity *r)
2259 struct smb_filename *smb_fname = NULL;
2260 char *servicename = NULL;
2261 files_struct *fsp = NULL;
2265 connection_struct *conn = NULL;
2267 char *oldcwd = NULL;
2268 struct security_descriptor *psd = NULL;
2269 uint32_t security_info_sent = 0;
2274 werr = WERR_NET_NAME_NOT_FOUND;
2278 snum = find_service(talloc_tos(), r->in.share, &servicename);
2285 DEBUG(10, ("Could not find service %s\n", servicename));
2286 werr = WERR_NET_NAME_NOT_FOUND;
2290 nt_status = create_conn_struct(talloc_tos(), &conn, snum,
2291 lp_pathname(snum), p->session_info,
2293 if (!NT_STATUS_IS_OK(nt_status)) {
2294 DEBUG(10, ("create_conn_struct failed: %s\n",
2295 nt_errstr(nt_status)));
2296 werr = ntstatus_to_werror(nt_status);
2300 nt_status = filename_convert(talloc_tos(),
2307 if (!NT_STATUS_IS_OK(nt_status)) {
2308 werr = ntstatus_to_werror(nt_status);
2312 nt_status = SMB_VFS_CREATE_FILE(
2315 0, /* root_dir_fid */
2316 smb_fname, /* fname */
2317 FILE_WRITE_ATTRIBUTES, /* access_mask */
2318 FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */
2319 FILE_OPEN, /* create_disposition*/
2320 0, /* create_options */
2321 0, /* file_attributes */
2322 INTERNAL_OPEN_ONLY, /* oplock_request */
2323 0, /* allocation_size */
2324 0, /* private_flags */
2330 if (!NT_STATUS_IS_OK(nt_status)) {
2331 DEBUG(3,("_srvsvc_NetSetFileSecurity: can't open %s\n",
2332 smb_fname_str_dbg(smb_fname)));
2333 werr = ntstatus_to_werror(nt_status);
2337 psd = r->in.sd_buf->sd;
2338 security_info_sent = r->in.securityinformation;
2340 if (psd->owner_sid==0) {
2341 security_info_sent &= ~SECINFO_OWNER;
2343 if (psd->group_sid==0) {
2344 security_info_sent &= ~SECINFO_GROUP;
2347 security_info_sent &= ~SECINFO_SACL;
2350 security_info_sent &= ~SECINFO_DACL;
2353 /* Convert all the generic bits. */
2354 security_acl_map_generic(psd->dacl, &file_generic_mapping);
2355 security_acl_map_generic(psd->sacl, &file_generic_mapping);
2357 nt_status = SMB_VFS_FSET_NT_ACL(fsp,
2361 if (!NT_STATUS_IS_OK(nt_status) ) {
2362 DEBUG(3,("_srvsvc_NetSetFileSecurity: Unable to set NT ACL "
2363 "on file %s\n", r->in.share));
2364 werr = WERR_ACCESS_DENIED;
2368 close_file(NULL, fsp, NORMAL_CLOSE);
2369 vfs_ChDir(conn, oldcwd);
2370 SMB_VFS_DISCONNECT(conn);
2378 close_file(NULL, fsp, NORMAL_CLOSE);
2382 vfs_ChDir(conn, oldcwd);
2386 SMB_VFS_DISCONNECT(conn);
2391 TALLOC_FREE(smb_fname);
2396 /***********************************************************************************
2397 It may be that we want to limit users to creating shares on certain areas of the UNIX file area.
2398 We could define areas by mapping Windows style disks to points on the UNIX directory hierarchy.
2399 These disks would the disks listed by this function.
2400 Users could then create shares relative to these disks. Watch out for moving these disks around.
2401 "Nigel Williams" <nigel@veritas.com>.
2402 ***********************************************************************************/
2404 static const char *server_disks[] = {"C:"};
2406 static uint32 get_server_disk_count(void)
2408 return sizeof(server_disks)/sizeof(server_disks[0]);
2411 static uint32 init_server_disk_enum(uint32 *resume)
2413 uint32 server_disk_count = get_server_disk_count();
2415 /*resume can be an offset into the list for now*/
2417 if(*resume & 0x80000000)
2420 if(*resume > server_disk_count)
2421 *resume = server_disk_count;
2423 return server_disk_count - *resume;
2426 static const char *next_server_disk_enum(uint32 *resume)
2430 if(init_server_disk_enum(resume) == 0)
2433 disk = server_disks[*resume];
2437 DEBUG(10, ("next_server_disk_enum: reporting disk %s. resume handle %d.\n", disk, *resume));
2442 /********************************************************************
2444 ********************************************************************/
2446 WERROR _srvsvc_NetDiskEnum(struct pipes_struct *p,
2447 struct srvsvc_NetDiskEnum *r)
2450 const char *disk_name;
2451 TALLOC_CTX *ctx = p->mem_ctx;
2453 uint32_t resume = r->in.resume_handle ? *r->in.resume_handle : 0;
2457 *r->out.totalentries = init_server_disk_enum(&resume);
2459 r->out.info->disks = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetDiskInfo0,
2460 MAX_SERVER_DISK_ENTRIES);
2461 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks);
2463 /*allow one struct srvsvc_NetDiskInfo0 for null terminator*/
2465 r->out.info->count = 0;
2467 for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(&resume)); i++) {
2469 r->out.info->count++;
2471 /*copy disk name into a unicode string*/
2473 r->out.info->disks[i].disk = talloc_strdup(ctx, disk_name);
2474 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[i].disk);
2477 /* add a terminating null string. Is this there if there is more data to come? */
2479 r->out.info->count++;
2481 r->out.info->disks[i].disk = talloc_strdup(ctx, "");
2482 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[i].disk);
2484 if (r->out.resume_handle) {
2485 *r->out.resume_handle = resume;
2491 /********************************************************************
2492 _srvsvc_NetNameValidate
2493 ********************************************************************/
2495 WERROR _srvsvc_NetNameValidate(struct pipes_struct *p,
2496 struct srvsvc_NetNameValidate *r)
2498 switch (r->in.name_type) {
2500 if (!validate_net_name(r->in.name, INVALID_SHARENAME_CHARS,
2501 strlen_m(r->in.name)))
2503 DEBUG(5,("_srvsvc_NetNameValidate: Bad sharename \"%s\"\n",
2505 return WERR_INVALID_NAME;
2510 return WERR_UNKNOWN_LEVEL;
2516 /*******************************************************************
2517 ********************************************************************/
2519 struct enum_file_close_state {
2520 struct srvsvc_NetFileClose *r;
2521 struct messaging_context *msg_ctx;
2524 static void enum_file_close_fn( const struct share_mode_entry *e,
2525 const char *sharepath, const char *fname,
2526 void *private_data )
2528 char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE];
2529 struct enum_file_close_state *state =
2530 (struct enum_file_close_state *)private_data;
2531 uint32_t fid = (((uint32_t)(procid_to_pid(&e->pid))<<16) | e->share_file_id);
2533 if (fid != state->r->in.fid) {
2534 return; /* Not this file. */
2537 if (!process_exists(e->pid) ) {
2541 /* Ok - send the close message. */
2542 DEBUG(10,("enum_file_close_fn: request to close file %s, %s\n",
2544 share_mode_str(talloc_tos(), 0, e) ));
2546 share_mode_entry_to_message(msg, e);
2548 state->r->out.result = ntstatus_to_werror(
2549 messaging_send_buf(state->msg_ctx,
2550 e->pid, MSG_SMB_CLOSE_FILE,
2552 MSG_SMB_SHARE_MODE_ENTRY_SIZE));
2555 /********************************************************************
2556 Close a file given a 32-bit file id.
2557 ********************************************************************/
2559 WERROR _srvsvc_NetFileClose(struct pipes_struct *p,
2560 struct srvsvc_NetFileClose *r)
2562 struct enum_file_close_state state;
2565 DEBUG(5,("_srvsvc_NetFileClose: %d\n", __LINE__));
2567 is_disk_op = security_token_has_privilege(p->session_info->security_token, SEC_PRIV_DISK_OPERATOR);
2569 if (p->session_info->utok.uid != sec_initial_uid() && !is_disk_op) {
2570 return WERR_ACCESS_DENIED;
2573 /* enum_file_close_fn sends the close message to
2574 * the relevent smbd process. */
2576 r->out.result = WERR_BADFILE;
2578 state.msg_ctx = p->msg_ctx;
2579 share_mode_forall(enum_file_close_fn, &state);
2580 return r->out.result;
2583 /********************************************************************
2584 ********************************************************************/
2586 WERROR _srvsvc_NetCharDevEnum(struct pipes_struct *p,
2587 struct srvsvc_NetCharDevEnum *r)
2589 p->rng_fault_state = True;
2590 return WERR_NOT_SUPPORTED;
2593 WERROR _srvsvc_NetCharDevGetInfo(struct pipes_struct *p,
2594 struct srvsvc_NetCharDevGetInfo *r)
2596 p->rng_fault_state = True;
2597 return WERR_NOT_SUPPORTED;
2600 WERROR _srvsvc_NetCharDevControl(struct pipes_struct *p,
2601 struct srvsvc_NetCharDevControl *r)
2603 p->rng_fault_state = True;
2604 return WERR_NOT_SUPPORTED;
2607 WERROR _srvsvc_NetCharDevQEnum(struct pipes_struct *p,
2608 struct srvsvc_NetCharDevQEnum *r)
2610 p->rng_fault_state = True;
2611 return WERR_NOT_SUPPORTED;
2614 WERROR _srvsvc_NetCharDevQGetInfo(struct pipes_struct *p,
2615 struct srvsvc_NetCharDevQGetInfo *r)
2617 p->rng_fault_state = True;
2618 return WERR_NOT_SUPPORTED;
2621 WERROR _srvsvc_NetCharDevQSetInfo(struct pipes_struct *p,
2622 struct srvsvc_NetCharDevQSetInfo *r)
2624 p->rng_fault_state = True;
2625 return WERR_NOT_SUPPORTED;
2628 WERROR _srvsvc_NetCharDevQPurge(struct pipes_struct *p,
2629 struct srvsvc_NetCharDevQPurge *r)
2631 p->rng_fault_state = True;
2632 return WERR_NOT_SUPPORTED;
2635 WERROR _srvsvc_NetCharDevQPurgeSelf(struct pipes_struct *p,
2636 struct srvsvc_NetCharDevQPurgeSelf *r)
2638 p->rng_fault_state = True;
2639 return WERR_NOT_SUPPORTED;
2642 WERROR _srvsvc_NetFileGetInfo(struct pipes_struct *p,
2643 struct srvsvc_NetFileGetInfo *r)
2645 p->rng_fault_state = True;
2646 return WERR_NOT_SUPPORTED;
2649 WERROR _srvsvc_NetShareCheck(struct pipes_struct *p,
2650 struct srvsvc_NetShareCheck *r)
2652 p->rng_fault_state = True;
2653 return WERR_NOT_SUPPORTED;
2656 WERROR _srvsvc_NetServerStatisticsGet(struct pipes_struct *p,
2657 struct srvsvc_NetServerStatisticsGet *r)
2659 p->rng_fault_state = True;
2660 return WERR_NOT_SUPPORTED;
2663 WERROR _srvsvc_NetTransportAdd(struct pipes_struct *p,
2664 struct srvsvc_NetTransportAdd *r)
2666 p->rng_fault_state = True;
2667 return WERR_NOT_SUPPORTED;
2670 WERROR _srvsvc_NetTransportEnum(struct pipes_struct *p,
2671 struct srvsvc_NetTransportEnum *r)
2673 p->rng_fault_state = True;
2674 return WERR_NOT_SUPPORTED;
2677 WERROR _srvsvc_NetTransportDel(struct pipes_struct *p,
2678 struct srvsvc_NetTransportDel *r)
2680 p->rng_fault_state = True;
2681 return WERR_NOT_SUPPORTED;
2684 WERROR _srvsvc_NetSetServiceBits(struct pipes_struct *p,
2685 struct srvsvc_NetSetServiceBits *r)
2687 p->rng_fault_state = True;
2688 return WERR_NOT_SUPPORTED;
2691 WERROR _srvsvc_NetPathType(struct pipes_struct *p,
2692 struct srvsvc_NetPathType *r)
2694 p->rng_fault_state = True;
2695 return WERR_NOT_SUPPORTED;
2698 WERROR _srvsvc_NetPathCanonicalize(struct pipes_struct *p,
2699 struct srvsvc_NetPathCanonicalize *r)
2701 p->rng_fault_state = True;
2702 return WERR_NOT_SUPPORTED;
2705 WERROR _srvsvc_NetPathCompare(struct pipes_struct *p,
2706 struct srvsvc_NetPathCompare *r)
2708 p->rng_fault_state = True;
2709 return WERR_NOT_SUPPORTED;
2712 WERROR _srvsvc_NETRPRNAMECANONICALIZE(struct pipes_struct *p,
2713 struct srvsvc_NETRPRNAMECANONICALIZE *r)
2715 p->rng_fault_state = True;
2716 return WERR_NOT_SUPPORTED;
2719 WERROR _srvsvc_NetPRNameCompare(struct pipes_struct *p,
2720 struct srvsvc_NetPRNameCompare *r)
2722 p->rng_fault_state = True;
2723 return WERR_NOT_SUPPORTED;
2726 WERROR _srvsvc_NetShareDelStart(struct pipes_struct *p,
2727 struct srvsvc_NetShareDelStart *r)
2729 p->rng_fault_state = True;
2730 return WERR_NOT_SUPPORTED;
2733 WERROR _srvsvc_NetShareDelCommit(struct pipes_struct *p,
2734 struct srvsvc_NetShareDelCommit *r)
2736 p->rng_fault_state = True;
2737 return WERR_NOT_SUPPORTED;
2740 WERROR _srvsvc_NetServerTransportAddEx(struct pipes_struct *p,
2741 struct srvsvc_NetServerTransportAddEx *r)
2743 p->rng_fault_state = True;
2744 return WERR_NOT_SUPPORTED;
2747 WERROR _srvsvc_NetServerSetServiceBitsEx(struct pipes_struct *p,
2748 struct srvsvc_NetServerSetServiceBitsEx *r)
2750 p->rng_fault_state = True;
2751 return WERR_NOT_SUPPORTED;
2754 WERROR _srvsvc_NETRDFSGETVERSION(struct pipes_struct *p,
2755 struct srvsvc_NETRDFSGETVERSION *r)
2757 p->rng_fault_state = True;
2758 return WERR_NOT_SUPPORTED;
2761 WERROR _srvsvc_NETRDFSCREATELOCALPARTITION(struct pipes_struct *p,
2762 struct srvsvc_NETRDFSCREATELOCALPARTITION *r)
2764 p->rng_fault_state = True;
2765 return WERR_NOT_SUPPORTED;
2768 WERROR _srvsvc_NETRDFSDELETELOCALPARTITION(struct pipes_struct *p,
2769 struct srvsvc_NETRDFSDELETELOCALPARTITION *r)
2771 p->rng_fault_state = True;
2772 return WERR_NOT_SUPPORTED;
2775 WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE(struct pipes_struct *p,
2776 struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *r)
2778 p->rng_fault_state = True;
2779 return WERR_NOT_SUPPORTED;
2782 WERROR _srvsvc_NETRDFSSETSERVERINFO(struct pipes_struct *p,
2783 struct srvsvc_NETRDFSSETSERVERINFO *r)
2785 p->rng_fault_state = True;
2786 return WERR_NOT_SUPPORTED;
2789 WERROR _srvsvc_NETRDFSCREATEEXITPOINT(struct pipes_struct *p,
2790 struct srvsvc_NETRDFSCREATEEXITPOINT *r)
2792 p->rng_fault_state = True;
2793 return WERR_NOT_SUPPORTED;
2796 WERROR _srvsvc_NETRDFSDELETEEXITPOINT(struct pipes_struct *p,
2797 struct srvsvc_NETRDFSDELETEEXITPOINT *r)
2799 p->rng_fault_state = True;
2800 return WERR_NOT_SUPPORTED;
2803 WERROR _srvsvc_NETRDFSMODIFYPREFIX(struct pipes_struct *p,
2804 struct srvsvc_NETRDFSMODIFYPREFIX *r)
2806 p->rng_fault_state = True;
2807 return WERR_NOT_SUPPORTED;
2810 WERROR _srvsvc_NETRDFSFIXLOCALVOLUME(struct pipes_struct *p,
2811 struct srvsvc_NETRDFSFIXLOCALVOLUME *r)
2813 p->rng_fault_state = True;
2814 return WERR_NOT_SUPPORTED;
2817 WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO(struct pipes_struct *p,
2818 struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r)
2820 p->rng_fault_state = True;
2821 return WERR_NOT_SUPPORTED;
2824 WERROR _srvsvc_NETRSERVERTRANSPORTDELEX(struct pipes_struct *p,
2825 struct srvsvc_NETRSERVERTRANSPORTDELEX *r)
2827 p->rng_fault_state = True;
2828 return WERR_NOT_SUPPORTED;