r14464: Don't include ndr_BASENAME.h files unless strictly required, instead
[garming/samba-autobuild/.git] / source4 / rpc_server / common / share_info.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    common share info functions
5
6    Copyright (C) Stefan (metze) Metzmacher 2004
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "librpc/gen_ndr/srvsvc.h"
25 #include "rpc_server/dcerpc_server.h"
26
27 /* 
28     Here are common server info functions used by some dcerpc server interfaces
29 */
30
31 /* This hardcoded value should go into a ldb database! */
32 uint32_t dcesrv_common_get_count_of_shares(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
33 {
34         /* what's about int -> uint32_t overflow */
35         return lp_numservices();
36 }
37
38 const char *dcesrv_common_get_share_name(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, int snum)
39 {
40         return talloc_strdup(mem_ctx, lp_servicename(snum));
41 }
42
43 const char *dcesrv_common_get_share_comment(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, int snum)
44 {
45         return talloc_strdup(mem_ctx, lp_comment(snum));
46 }
47
48 /* This hardcoded value should go into a ldb database! */
49 uint32_t dcesrv_common_get_share_permissions(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, int snum)
50 {
51         return 0;
52 }
53
54 /* This hardcoded value should go into a ldb database! */
55 uint32_t dcesrv_common_get_share_max_users(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, int snum)
56 {
57         return lp_max_connections(snum);
58 }
59
60 /* This hardcoded value should go into a ldb database! */
61 uint32_t dcesrv_common_get_share_current_users(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, int snum)
62 {
63         return 1;
64 }
65
66 /* This hardcoded value should go into a ldb database! */
67 enum srvsvc_ShareType dcesrv_common_get_share_type(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, int snum)
68 {
69         /* for disk share       0x00000000
70          * for print share      0x00000001
71          * for IPC$ share       0x00000003 
72          *
73          * administrative shares:
74          * ADMIN$, IPC$, C$, D$, E$ ...  are type |= 0x80000000
75          * this ones are hidden in NetShareEnum, but shown in NetShareEnumAll
76          */
77         enum srvsvc_ShareType share_type = 0;
78
79         if (!lp_browseable(snum)) {
80                 share_type |= STYPE_HIDDEN;
81         }
82
83         if (strcasecmp(lp_fstype(snum), "IPC") == 0) {
84                 share_type |= STYPE_IPC;
85                 return share_type;
86         }
87
88         if (lp_print_ok(snum)) {
89                 share_type |= STYPE_PRINTQ;
90                 return share_type;
91         }
92
93         share_type |= STYPE_DISKTREE;
94
95         return share_type;
96 }
97
98 /* This hardcoded value should go into a ldb database! */
99 const char *dcesrv_common_get_share_path(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, int snum)
100 {
101         if (strcasecmp(lp_fstype(snum), "IPC") == 0) {
102                 return talloc_strdup(mem_ctx, "");
103         }
104         return talloc_strdup(mem_ctx, "C:\\");
105 }
106
107 /* This hardcoded value should go into a ldb database! */
108 const char *dcesrv_common_get_share_password(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, int snum)
109 {
110         return NULL;
111 }
112
113 /* This hardcoded value should go into a ldb database! */
114 uint32_t dcesrv_common_get_share_csc_policy(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, int snum)
115 {
116         return 0;
117 }
118
119 /* This hardcoded value should go into a ldb database! */
120 uint32_t dcesrv_common_get_share_dfs_flags(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, int snum)
121 {
122         return 0;
123 }
124
125 /* This hardcoded value should go into a ldb database! */
126 uint32_t dcesrv_common_get_share_unknown(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, int snum)
127 {
128         return 0;
129 }
130
131 /* This hardcoded value should go into a ldb database! */
132 struct security_descriptor *dcesrv_common_get_security_descriptor(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, int snum)
133 {
134         return NULL;
135 }