Move S3 specific parameters to S3 conf file in make test.
[Samba.git] / source4 / rpc_server / common / server_info.c
bloba7384f117de15bc9f3d7ecc6690d0050a45809a0
1 /*
2 Unix SMB/CIFS implementation.
4 common server info functions
6 Copyright (C) Stefan (metze) Metzmacher 2004
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 3 of the License, or
11 (at your option) any later version.
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.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "librpc/gen_ndr/ndr_srvsvc.h"
24 #include "librpc/gen_ndr/svcctl.h"
25 #include "rpc_server/dcerpc_server.h"
26 #include "dsdb/samdb/samdb.h"
27 #include "auth/auth.h"
28 #include "param/param.h"
29 #include "rpc_server/common/common.h"
30 #include "rpc_server/common/proto.h"
32 /*
33 Here are common server info functions used by some dcerpc server interfaces
36 /* This hardcoded value should go into a ldb database! */
37 enum srvsvc_PlatformId dcesrv_common_get_platform_id(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
39 enum srvsvc_PlatformId id;
41 id = lp_parm_int(dce_ctx->lp_ctx, NULL, "server_info", "platform_id", PLATFORM_ID_NT);
43 return id;
46 const char *dcesrv_common_get_server_name(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, const char *server_unc)
48 const char *p = server_unc;
50 /* if there's no string return our NETBIOS name */
51 if (!p) {
52 return talloc_strdup(mem_ctx, lp_netbios_name(dce_ctx->lp_ctx));
55 /* if there're '\\\\' in front remove them otherwise just pass the string */
56 if (p[0] == '\\' && p[1] == '\\') {
57 p += 2;
60 return talloc_strdup(mem_ctx, p);
64 /* This hardcoded value should go into a ldb database! */
65 uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct tevent_context *event_ctx, struct dcesrv_context *dce_ctx)
67 int default_server_announce = 0;
68 default_server_announce |= SV_TYPE_WORKSTATION;
69 default_server_announce |= SV_TYPE_SERVER;
70 default_server_announce |= SV_TYPE_SERVER_UNIX;
72 switch (lp_announce_as(dce_ctx->lp_ctx)) {
73 case ANNOUNCE_AS_NT_SERVER:
74 default_server_announce |= SV_TYPE_SERVER_NT;
75 /* fall through... */
76 case ANNOUNCE_AS_NT_WORKSTATION:
77 default_server_announce |= SV_TYPE_NT;
78 break;
79 case ANNOUNCE_AS_WIN95:
80 default_server_announce |= SV_TYPE_WIN95_PLUS;
81 break;
82 case ANNOUNCE_AS_WFW:
83 default_server_announce |= SV_TYPE_WFW;
84 break;
85 default:
86 break;
89 switch (lp_server_role(dce_ctx->lp_ctx)) {
90 case ROLE_DOMAIN_MEMBER:
91 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
92 break;
93 case ROLE_DOMAIN_CONTROLLER:
95 struct ldb_context *samctx;
96 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
97 if (!tmp_ctx) {
98 break;
100 /* open main ldb */
101 samctx = samdb_connect(tmp_ctx, event_ctx, dce_ctx->lp_ctx, anonymous_session(tmp_ctx, event_ctx, dce_ctx->lp_ctx));
102 if (samctx == NULL) {
103 DEBUG(2,("Unable to open samdb in determining server announce flags\n"));
104 } else {
105 /* Determine if we are the pdc */
106 bool is_pdc = samdb_is_pdc(samctx);
107 if (is_pdc) {
108 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
109 } else {
110 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
113 /* Close it */
114 talloc_free(tmp_ctx);
115 break;
117 case ROLE_STANDALONE:
118 default:
119 break;
121 if (lp_time_server(dce_ctx->lp_ctx))
122 default_server_announce |= SV_TYPE_TIME_SOURCE;
124 if (lp_host_msdfs(dce_ctx->lp_ctx))
125 default_server_announce |= SV_TYPE_DFS_SERVER;
128 #if 0
130 /* TODO: announce us as print server when we are a print server */
131 bool is_print_server = false;
132 if (is_print_server) {
133 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
136 #endif
137 return default_server_announce;
140 /* This hardcoded value should go into a ldb database! */
141 const char *dcesrv_common_get_lan_root(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
143 return talloc_strdup(mem_ctx, "");
146 /* This hardcoded value should go into a ldb database! */
147 uint32_t dcesrv_common_get_users(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
149 return -1;
152 /* This hardcoded value should go into a ldb database! */
153 uint32_t dcesrv_common_get_disc(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
155 return 15;
158 /* This hardcoded value should go into a ldb database! */
159 uint32_t dcesrv_common_get_hidden(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
161 return 0;
164 /* This hardcoded value should go into a ldb database! */
165 uint32_t dcesrv_common_get_announce(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
167 return 240;
170 /* This hardcoded value should go into a ldb database! */
171 uint32_t dcesrv_common_get_anndelta(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
173 return 3000;
176 /* This hardcoded value should go into a ldb database! */
177 uint32_t dcesrv_common_get_licenses(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
179 return 0;
182 /* This hardcoded value should go into a ldb database! */
183 const char *dcesrv_common_get_userpath(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
185 return talloc_strdup(mem_ctx, "c:\\");
188 #define INVALID_SHARE_NAME_CHARS " \"*+,./:;<=>?[\\]|"
190 bool dcesrv_common_validate_share_name(TALLOC_CTX *mem_ctx, const char *share_name)
192 if (strpbrk(share_name, INVALID_SHARE_NAME_CHARS)) {
193 return false;
196 return true;