12f5c90e8dfcc0a9ecad4a0f201e1ecb4570ce7d
[jra/samba/.git] / source4 / rpc_server / common / server_info.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    common server 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/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 _PUBLIC_ enum srvsvc_PlatformId dcesrv_common_get_platform_id(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
33 {
34         enum srvsvc_PlatformId id;
35
36         id = lp_parm_int(-1, "server_info", "platform_id", PLATFORM_ID_NT);
37
38         return id;
39 }
40
41 _PUBLIC_ const char *dcesrv_common_get_server_name(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, const char *server_unc)
42 {
43         const char *p = server_unc;
44
45         /* if there's no string return our NETBIOS name */
46         if (!p) {
47                 return talloc_strdup(mem_ctx, lp_netbios_name());
48         }
49
50         /* if there're '\\\\' in front remove them otherwise just pass the string */
51         if (p[0] == '\\' && p[1] == '\\') {
52                 p += 2;
53         }
54
55         return talloc_strdup(mem_ctx, p);
56 }
57
58 const char *dcesrv_common_get_domain_name(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
59 {
60         return talloc_strdup(mem_ctx, lp_workgroup());
61 }
62
63 /* This hardcoded value should go into a ldb database! */
64 _PUBLIC_ uint32_t dcesrv_common_get_version_major(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
65 {
66         return lp_parm_int(-1, "server_info", "version_major", 5);
67 }
68
69 /* This hardcoded value should go into a ldb database! */
70 _PUBLIC_ uint32_t dcesrv_common_get_version_minor(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
71 {
72         return lp_parm_int(-1, "server_info", "version_minor", 2);
73 }
74
75 /* This hardcoded value should go into a ldb database! */
76 _PUBLIC_ uint32_t dcesrv_common_get_version_build(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
77 {
78         return lp_parm_int(-1, "server_info", "version_build", 3790);
79 }
80
81 /* This hardcoded value should go into a ldb database! */
82 _PUBLIC_ uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
83 {
84         return lp_default_server_announce();
85 }
86
87 /* This hardcoded value should go into a ldb database! */
88 _PUBLIC_ const char *dcesrv_common_get_lan_root(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
89 {
90         return talloc_strdup(mem_ctx, "");
91 }
92
93 /* This hardcoded value should go into a ldb database! */
94 _PUBLIC_ uint32_t dcesrv_common_get_users(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
95 {
96         return -1;
97 }
98
99 /* This hardcoded value should go into a ldb database! */
100 _PUBLIC_ uint32_t dcesrv_common_get_disc(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
101 {
102         return 15;
103 }
104
105 /* This hardcoded value should go into a ldb database! */
106 _PUBLIC_ uint32_t dcesrv_common_get_hidden(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
107 {
108         return 0;
109 }
110
111 /* This hardcoded value should go into a ldb database! */
112 _PUBLIC_ uint32_t dcesrv_common_get_announce(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
113 {
114         return 240;
115 }
116
117 /* This hardcoded value should go into a ldb database! */
118 _PUBLIC_ uint32_t dcesrv_common_get_anndelta(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
119 {
120         return 3000;
121 }
122
123 /* This hardcoded value should go into a ldb database! */
124 _PUBLIC_ uint32_t dcesrv_common_get_licenses(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
125 {
126         return 0;
127 }
128
129 /* This hardcoded value should go into a ldb database! */
130 _PUBLIC_ const char *dcesrv_common_get_userpath(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
131 {
132         return talloc_strdup(mem_ctx, "c:\\");
133 }
134
135 #define INVALID_SHARE_NAME_CHARS " \"*+,./:;<=>?[\\]|"
136
137 _PUBLIC_ bool dcesrv_common_validate_share_name(TALLOC_CTX *mem_ctx, const char *share_name)
138 {
139         if (strpbrk(share_name, INVALID_SHARE_NAME_CHARS)) {
140                 return False;
141         }
142
143         return True;
144 }