2 Unix SMB/CIFS implementation.
3 Parameter loading functions
4 Copyright (C) Karl Auer 1993-1998
6 Largely re-written by Andrew Tridgell, September 1994
8 Copyright (C) Simo Sorce 2001
9 Copyright (C) Alexander Bokovoy 2002
10 Copyright (C) Stefan (metze) Metzmacher 2002
11 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
12 Copyright (C) James Myers 2003 <myersjj@samba.org>
13 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 3 of the License, or
18 (at your option) any later version.
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program. If not, see <http://www.gnu.org/licenses/>.
32 * This module provides suitable callback functions for the params
33 * module. It builds the internal table of service details which is
34 * then used by the rest of the server.
38 * 1) add it to the global or service structure definition
39 * 2) add it to the parm_table
40 * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
41 * 4) If it's a global then initialise it in init_globals. If a local
42 * (ie. service) parameter then initialise it in the sDefault structure
46 * The configuration file is processed sequentially for speed. It is NOT
47 * accessed randomly as happens in 'real' Windows. For this reason, there
48 * is a fair bit of sequence-dependent code here - ie., code which assumes
49 * that certain things happen before others. In particular, the code which
50 * happens at the boundary between sections is delicately poised, so be
57 #include "dynconfig/dynconfig.h"
58 #include "system/time.h"
59 #include "system/locale.h"
60 #include "system/network.h" /* needed for TCP_NODELAY */
61 #include "smb_server/smb_server.h"
62 #include "libcli/raw/signing.h"
63 #include "../lib/util/dlinklist.h"
64 #include "../lib/util/parmlist.h"
65 #include "param/param.h"
66 #include "param/loadparm.h"
67 #include "libcli/raw/libcliraw.h"
68 #include "rpc_server/common/common.h"
69 #include "lib/socket/socket.h"
70 #include "auth/gensec/gensec.h"
73 #define standard_sub_basic talloc_strdup
75 static bool do_parameter(const char *, const char *, void *);
76 static bool defaults_saved = false;
78 #define LOADPARM_EXTRA_GLOBALS \
79 struct parmlist_entry *param_opt; \
88 int bPreferredMaster; \
89 char *szAnnounceVersion; /* This is initialised in init_globals */
90 #define LOADPARM_EXTRA_LOCALS \
91 struct parmlist_entry *param_opt; \
95 char *szPrintername; \
100 char dummy[3]; /* for alignment */
102 #include "param_global.h"
103 #include "param_local.h"
105 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
108 /* prototypes for the special type handlers */
109 static bool handle_include(struct loadparm_context *lp_ctx,
110 const char *pszParmValue, char **ptr);
111 static bool handle_realm(struct loadparm_context *lp_ctx,
112 const char *pszParmValue, char **ptr);
113 static bool handle_copy(struct loadparm_context *lp_ctx,
114 const char *pszParmValue, char **ptr);
115 static bool handle_debuglevel(struct loadparm_context *lp_ctx,
116 const char *pszParmValue, char **ptr);
117 static bool handle_logfile(struct loadparm_context *lp_ctx,
118 const char *pszParmValue, char **ptr);
120 static const struct enum_list enum_protocol[] = {
121 {PROTOCOL_SMB2, "SMB2"},
122 {PROTOCOL_NT1, "NT1"},
123 {PROTOCOL_LANMAN2, "LANMAN2"},
124 {PROTOCOL_LANMAN1, "LANMAN1"},
125 {PROTOCOL_CORE, "CORE"},
126 {PROTOCOL_COREPLUS, "COREPLUS"},
127 {PROTOCOL_COREPLUS, "CORE+"},
131 static const struct enum_list enum_security[] = {
132 {SEC_SHARE, "SHARE"},
138 static const struct enum_list enum_bool_auto[] = {
149 /* Client-side offline caching policy types */
152 CSC_POLICY_DOCUMENTS=1,
153 CSC_POLICY_PROGRAMS=2,
157 static const struct enum_list enum_csc_policy[] = {
158 {CSC_POLICY_MANUAL, "manual"},
159 {CSC_POLICY_DOCUMENTS, "documents"},
160 {CSC_POLICY_PROGRAMS, "programs"},
161 {CSC_POLICY_DISABLE, "disable"},
165 /* SMB signing types. */
166 static const struct enum_list enum_smb_signing_vals[] = {
167 {SMB_SIGNING_OFF, "No"},
168 {SMB_SIGNING_OFF, "False"},
169 {SMB_SIGNING_OFF, "0"},
170 {SMB_SIGNING_OFF, "Off"},
171 {SMB_SIGNING_OFF, "disabled"},
172 {SMB_SIGNING_SUPPORTED, "Yes"},
173 {SMB_SIGNING_SUPPORTED, "True"},
174 {SMB_SIGNING_SUPPORTED, "1"},
175 {SMB_SIGNING_SUPPORTED, "On"},
176 {SMB_SIGNING_SUPPORTED, "enabled"},
177 {SMB_SIGNING_REQUIRED, "required"},
178 {SMB_SIGNING_REQUIRED, "mandatory"},
179 {SMB_SIGNING_REQUIRED, "force"},
180 {SMB_SIGNING_REQUIRED, "forced"},
181 {SMB_SIGNING_REQUIRED, "enforced"},
182 {SMB_SIGNING_AUTO, "auto"},
186 static const struct enum_list enum_server_role[] = {
187 {ROLE_STANDALONE, "standalone"},
188 {ROLE_DOMAIN_MEMBER, "member server"},
189 {ROLE_DOMAIN_MEMBER, "member"},
190 {ROLE_DOMAIN_CONTROLLER, "domain controller"},
191 {ROLE_DOMAIN_CONTROLLER, "dc"},
195 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
196 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
198 static struct parm_struct parm_table[] = {
199 {"server role", P_ENUM, P_GLOBAL, GLOBAL_VAR(server_role), NULL, enum_server_role},
200 {"dos charset", P_STRING, P_GLOBAL, GLOBAL_VAR(dos_charset), NULL, NULL},
201 {"unix charset", P_STRING, P_GLOBAL, GLOBAL_VAR(unix_charset), NULL, NULL},
202 {"ncalrpc dir", P_STRING, P_GLOBAL, GLOBAL_VAR(ncalrpc_dir), NULL, NULL},
203 {"comment", P_STRING, P_LOCAL, LOCAL_VAR(comment), NULL, NULL},
204 {"path", P_STRING, P_LOCAL, LOCAL_VAR(szPath), NULL, NULL},
205 {"directory", P_STRING, P_LOCAL, LOCAL_VAR(szPath), NULL, NULL},
206 {"workgroup", P_USTRING, P_GLOBAL, GLOBAL_VAR(szWorkgroup), NULL, NULL},
207 {"realm", P_STRING, P_GLOBAL, GLOBAL_VAR(szRealm), handle_realm, NULL},
208 {"netbios name", P_USTRING, P_GLOBAL, GLOBAL_VAR(szNetbiosName), NULL, NULL},
209 {"netbios aliases", P_LIST, P_GLOBAL, GLOBAL_VAR(szNetbiosAliases), NULL, NULL},
210 {"netbios scope", P_USTRING, P_GLOBAL, GLOBAL_VAR(szNetbiosScope), NULL, NULL},
211 {"server string", P_STRING, P_GLOBAL, GLOBAL_VAR(szServerString), NULL, NULL},
212 {"interfaces", P_LIST, P_GLOBAL, GLOBAL_VAR(szInterfaces), NULL, NULL},
213 {"bind interfaces only", P_BOOL, P_GLOBAL, GLOBAL_VAR(bBindInterfacesOnly), NULL, NULL},
214 {"ntvfs handler", P_LIST, P_LOCAL, LOCAL_VAR(ntvfs_handler), NULL, NULL},
215 {"ntptr providor", P_STRING, P_GLOBAL, GLOBAL_VAR(ntptr_providor), NULL, NULL},
216 {"dcerpc endpoint servers", P_LIST, P_GLOBAL, GLOBAL_VAR(dcerpc_ep_servers), NULL, NULL},
217 {"server services", P_LIST, P_GLOBAL, GLOBAL_VAR(server_services), NULL, NULL},
219 {"security", P_ENUM, P_GLOBAL, GLOBAL_VAR(security), NULL, enum_security},
220 {"encrypt passwords", P_BOOL, P_GLOBAL, GLOBAL_VAR(bEncryptPasswords), NULL, NULL},
221 {"null passwords", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNullPasswords), NULL, NULL},
222 {"obey pam restrictions", P_BOOL, P_GLOBAL, GLOBAL_VAR(bObeyPamRestrictions), NULL, NULL},
223 {"password server", P_LIST, P_GLOBAL, GLOBAL_VAR(szPasswordServers), NULL, NULL},
224 {"spoolss database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSPOOLSS_URL), NULL, NULL},
225 {"wins config database", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINS_CONFIG_URL), NULL, NULL},
226 {"wins database", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINS_URL), NULL, NULL},
227 {"private dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szPrivateDir), NULL, NULL},
228 {"passwd chat", P_STRING, P_GLOBAL, GLOBAL_VAR(szPasswdChat), NULL, NULL},
229 {"password level", P_INTEGER, P_GLOBAL, GLOBAL_VAR(pwordlevel), NULL, NULL},
230 {"lanman auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLanmanAuth), NULL, NULL},
231 {"ntlm auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNTLMAuth), NULL, NULL},
232 {"client NTLMv2 auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientNTLMv2Auth), NULL, NULL},
233 {"client lanman auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientLanManAuth), NULL, NULL},
234 {"client plaintext auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientPlaintextAuth), NULL, NULL},
235 {"client use spnego principal", P_BOOL, P_GLOBAL, GLOBAL_VAR(client_use_spnego_principal), NULL, NULL},
237 {"read only", P_BOOL, P_LOCAL, LOCAL_VAR(bRead_only), NULL, NULL},
239 {"create mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_mask), NULL, NULL},
240 {"force create mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_force_mode), NULL, NULL},
241 {"directory mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_mask), NULL, NULL},
242 {"force directory mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_force_mode), NULL, NULL},
244 {"hosts allow", P_LIST, P_LOCAL, LOCAL_VAR(szHostsallow), NULL, NULL},
245 {"hosts deny", P_LIST, P_LOCAL, LOCAL_VAR(szHostsdeny), NULL, NULL},
247 {"log level", P_STRING, P_GLOBAL, GLOBAL_VAR(loglevel), handle_debuglevel, NULL},
248 {"debuglevel", P_STRING, P_GLOBAL, GLOBAL_VAR(loglevel), handle_debuglevel, NULL},
249 {"log file", P_STRING, P_GLOBAL, GLOBAL_VAR(logfile), handle_logfile, NULL},
251 {"smb ports", P_LIST, P_GLOBAL, GLOBAL_VAR(smb_ports), NULL, NULL},
252 {"nbt port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(nbt_port), NULL, NULL},
253 {"dgram port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(dgram_port), NULL, NULL},
254 {"cldap port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(cldap_port), NULL, NULL},
255 {"krb5 port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(krb5_port), NULL, NULL},
256 {"kpasswd port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(kpasswd_port), NULL, NULL},
257 {"web port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(web_port), NULL, NULL},
258 {"tls enabled", P_BOOL, P_GLOBAL, GLOBAL_VAR(tls_enabled), NULL, NULL},
259 {"tls keyfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_keyfile), NULL, NULL},
260 {"tls certfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_certfile), NULL, NULL},
261 {"tls cafile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_cafile), NULL, NULL},
262 {"tls crlfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_crlfile), NULL, NULL},
263 {"tls dh params file", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_dhpfile), NULL, NULL},
264 {"large readwrite", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLargeReadwrite), NULL, NULL},
265 {"server max protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(srv_maxprotocol), NULL, enum_protocol},
266 {"server min protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(srv_minprotocol), NULL, enum_protocol},
267 {"client max protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(cli_maxprotocol), NULL, enum_protocol},
268 {"client min protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(cli_minprotocol), NULL, enum_protocol},
269 {"unicode", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUnicode), NULL, NULL},
270 {"read raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bReadRaw), NULL, NULL},
271 {"write raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWriteRaw), NULL, NULL},
272 {"disable netbios", P_BOOL, P_GLOBAL, GLOBAL_VAR(bDisableNetbios), NULL, NULL},
274 {"nt status support", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNTStatusSupport), NULL, NULL},
276 {"announce version", P_STRING, P_GLOBAL, GLOBAL_VAR(szAnnounceVersion), NULL, NULL},
277 {"max mux", P_INTEGER, P_GLOBAL, GLOBAL_VAR(max_mux), NULL, NULL},
278 {"max xmit", P_BYTES, P_GLOBAL, GLOBAL_VAR(max_xmit), NULL, NULL},
280 {"name resolve order", P_LIST, P_GLOBAL, GLOBAL_VAR(szNameResolveOrder), NULL, NULL},
281 {"max wins ttl", P_INTEGER, P_GLOBAL, GLOBAL_VAR(max_wins_ttl), NULL, NULL},
282 {"min wins ttl", P_INTEGER, P_GLOBAL, GLOBAL_VAR(min_wins_ttl), NULL, NULL},
283 {"time server", P_BOOL, P_GLOBAL, GLOBAL_VAR(bTimeServer), NULL, NULL},
284 {"unix extensions", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUnixExtensions), NULL, NULL},
285 {"use spnego", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUseSpnego), NULL, NULL},
286 {"server signing", P_ENUM, P_GLOBAL, GLOBAL_VAR(server_signing), NULL, enum_smb_signing_vals},
287 {"client signing", P_ENUM, P_GLOBAL, GLOBAL_VAR(client_signing), NULL, enum_smb_signing_vals},
288 {"rpc big endian", P_BOOL, P_GLOBAL, GLOBAL_VAR(bRpcBigEndian), NULL, NULL},
290 {"max connections", P_INTEGER, P_LOCAL, LOCAL_VAR(iMaxConnections), NULL, NULL},
291 {"paranoid server security", P_BOOL, P_GLOBAL, GLOBAL_VAR(paranoid_server_security), NULL, NULL},
292 {"socket options", P_STRING, P_GLOBAL, GLOBAL_VAR(socket_options), NULL, NULL},
294 {"strict sync", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictSync), NULL, NULL},
295 {"case insensitive filesystem", P_BOOL, P_LOCAL, LOCAL_VAR(bCIFileSystem), NULL, NULL},
297 {"max print jobs", P_INTEGER, P_LOCAL, LOCAL_VAR(iMaxPrintJobs), NULL, NULL},
298 {"printable", P_BOOL, P_LOCAL, LOCAL_VAR(bPrint_ok), NULL, NULL},
299 {"print ok", P_BOOL, P_LOCAL, LOCAL_VAR(bPrint_ok), NULL, NULL},
301 {"printer name", P_STRING, P_LOCAL, LOCAL_VAR(szPrintername), NULL, NULL},
302 {"printer", P_STRING, P_LOCAL, LOCAL_VAR(szPrintername), NULL, NULL},
304 {"map system", P_BOOL, P_LOCAL, LOCAL_VAR(bMap_system), NULL, NULL},
305 {"map hidden", P_BOOL, P_LOCAL, LOCAL_VAR(bMap_hidden), NULL, NULL},
306 {"map archive", P_BOOL, P_LOCAL, LOCAL_VAR(bMap_archive), NULL, NULL},
308 {"preferred master", P_ENUM, P_GLOBAL, GLOBAL_VAR(bPreferredMaster), NULL, enum_bool_auto},
309 {"prefered master", P_ENUM, P_GLOBAL, GLOBAL_VAR(bPreferredMaster), NULL, enum_bool_auto},
310 {"local master", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLocalMaster), NULL, NULL},
311 {"browseable", P_BOOL, P_LOCAL, LOCAL_VAR(bBrowseable), NULL, NULL},
312 {"browsable", P_BOOL, P_LOCAL, LOCAL_VAR(bBrowseable), NULL, NULL},
314 {"wins server", P_LIST, P_GLOBAL, GLOBAL_VAR(szWINSservers), NULL, NULL},
315 {"wins support", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWINSsupport), NULL, NULL},
316 {"dns proxy", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWINSdnsProxy), NULL, NULL},
317 {"wins hook", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINSHook), NULL, NULL},
319 {"csc policy", P_ENUM, P_LOCAL, LOCAL_VAR(iCSCPolicy), NULL, enum_csc_policy},
321 {"strict locking", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictLocking), NULL, NULL},
322 {"oplocks", P_BOOL, P_LOCAL, LOCAL_VAR(bOplocks), NULL, NULL},
324 {"share backend", P_STRING, P_GLOBAL, GLOBAL_VAR(szShareBackend), NULL, NULL},
325 {"preload", P_STRING, P_GLOBAL, GLOBAL_VAR(szAutoServices), NULL, NULL},
326 {"auto services", P_STRING, P_GLOBAL, GLOBAL_VAR(szAutoServices), NULL, NULL},
327 {"lock dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szLockDir), NULL, NULL},
328 {"lock directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szLockDir), NULL, NULL},
329 {"pid directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szPidDir), NULL, NULL},
331 {"socket address", P_STRING, P_GLOBAL, GLOBAL_VAR(szSocketAddress), NULL, NULL},
332 {"copy", P_STRING, P_LOCAL, LOCAL_VAR(szCopy), handle_copy, NULL},
333 {"include", P_STRING, P_LOCAL, LOCAL_VAR(szInclude), handle_include, NULL},
335 {"available", P_BOOL, P_LOCAL, LOCAL_VAR(bAvailable), NULL, NULL},
336 {"volume", P_STRING, P_LOCAL, LOCAL_VAR(volume), NULL, NULL },
337 {"fstype", P_STRING, P_LOCAL, LOCAL_VAR(fstype), NULL, NULL},
339 {"panic action", P_STRING, P_GLOBAL, GLOBAL_VAR(panic_action), NULL, NULL},
341 {"msdfs root", P_BOOL, P_LOCAL, LOCAL_VAR(bMSDfsRoot), NULL, NULL},
342 {"host msdfs", P_BOOL, P_GLOBAL, GLOBAL_VAR(bHostMSDfs), NULL, NULL},
343 {"winbind separator", P_STRING, P_GLOBAL, GLOBAL_VAR(szWinbindSeparator), NULL, NULL },
344 {"winbindd socket directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szWinbinddSocketDirectory), NULL, NULL },
345 {"winbindd privileged socket directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory), NULL, NULL },
346 {"winbind sealed pipes", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWinbindSealedPipes), NULL, NULL },
347 {"template shell", P_STRING, P_GLOBAL, GLOBAL_VAR(szTemplateShell), NULL, NULL },
348 {"template homedir", P_STRING, P_GLOBAL, GLOBAL_VAR(szTemplateHomedir), NULL, NULL },
349 {"idmap trusted only", P_BOOL, P_GLOBAL, GLOBAL_VAR(bIdmapTrustedOnly), NULL, NULL},
351 {"ntp signd socket directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szNTPSignDSocketDirectory), NULL, NULL },
352 {"rndc command", P_CMDLIST, P_GLOBAL, GLOBAL_VAR(szRNDCCommand), NULL, NULL },
353 {"dns update command", P_CMDLIST, P_GLOBAL, GLOBAL_VAR(szDNSUpdateCommand), NULL, NULL },
354 {"spn update command", P_CMDLIST, P_GLOBAL, GLOBAL_VAR(szSPNUpdateCommand), NULL, NULL },
355 {"nsupdate command", P_CMDLIST, P_GLOBAL, GLOBAL_VAR(szNSUpdateCommand), NULL, NULL },
357 {NULL, P_BOOL, P_NONE, 0, NULL, NULL}
361 /* local variables */
362 struct loadparm_context {
363 const char *szConfigFile;
364 struct loadparm_global *globals;
365 struct loadparm_service **services;
366 struct loadparm_service *sDefault;
367 struct smb_iconv_handle *iconv_handle;
369 struct loadparm_service *currentService;
370 bool bInGlobalSection;
372 struct file_lists *next;
377 unsigned int flags[NUMPARAMETERS];
380 bool global; /* Is this the global context, which may set
381 * global variables such as debug level etc? */
382 const struct loadparm_s3_context *s3_fns;
386 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx)
388 return lp_ctx->sDefault;
392 return the parameter table
394 struct parm_struct *lpcfg_parm_table(void)
400 * Convenience routine to grab string parameters into temporary memory
401 * and run standard_sub_basic on them.
403 * The buffers can be written to by
404 * callers without affecting the source string.
407 static const char *lp_string(const char *s)
409 #if 0 /* until REWRITE done to make thread-safe */
410 size_t len = s ? strlen(s) : 0;
414 /* The follow debug is useful for tracking down memory problems
415 especially if you have an inner loop that is calling a lp_*()
416 function that returns a string. Perhaps this debug should be
417 present all the time? */
420 DEBUG(10, ("lp_string(%s)\n", s));
423 #if 0 /* until REWRITE done to make thread-safe */
425 lp_talloc = talloc_init("lp_talloc");
427 ret = talloc_array(lp_talloc, char, len + 100); /* leave room for substitution */
435 strlcpy(ret, s, len);
437 if (trim_string(ret, "\"", "\"")) {
438 if (strchr(ret,'"') != NULL)
439 strlcpy(ret, s, len);
442 standard_sub_basic(ret,len+100);
449 In this section all the functions that are used to access the
450 parameters from the rest of the program are defined
454 * the creation of separate lpcfg_*() and lp_*() functions is to allow
455 * for code compatibility between existing Samba4 and Samba3 code.
458 /* this global context supports the lp_*() function varients */
459 static struct loadparm_context *global_loadparm_context;
461 #define lpcfg_default_service global_loadparm_context->sDefault
462 #define lpcfg_global_service(i) global_loadparm_context->services[i]
464 #define FN_GLOBAL_STRING(fn_name,var_name) \
465 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
466 if (lp_ctx == NULL) return NULL; \
467 if (lp_ctx->s3_fns) { \
468 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
469 return lp_ctx->s3_fns->fn_name(); \
471 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
474 #define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
475 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
476 if (lp_ctx == NULL) return NULL; \
477 if (lp_ctx->s3_fns) { \
478 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
479 return lp_ctx->s3_fns->fn_name(); \
481 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
484 #define FN_GLOBAL_LIST(fn_name,var_name) \
485 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
486 if (lp_ctx == NULL) return NULL; \
487 if (lp_ctx->s3_fns) { \
488 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
489 return lp_ctx->s3_fns->fn_name(); \
491 return lp_ctx->globals->var_name; \
494 #define FN_GLOBAL_BOOL(fn_name,var_name) \
495 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
496 if (lp_ctx == NULL) return false; \
497 if (lp_ctx->s3_fns) { \
498 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
499 return lp_ctx->s3_fns->fn_name(); \
501 return lp_ctx->globals->var_name; \
504 #define FN_GLOBAL_INTEGER(fn_name,var_name) \
505 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
506 if (lp_ctx->s3_fns) { \
507 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
508 return lp_ctx->s3_fns->fn_name(); \
510 return lp_ctx->globals->var_name; \
513 #define FN_LOCAL_STRING(fn_name,val) \
514 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, \
515 struct loadparm_service *sDefault) { \
516 return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val))); \
519 #define FN_LOCAL_LIST(fn_name,val) \
520 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, \
521 struct loadparm_service *sDefault) {\
522 return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val); \
525 #define FN_LOCAL_BOOL(fn_name,val) \
526 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, \
527 struct loadparm_service *sDefault) { \
528 return((service != NULL)? service->val : sDefault->val); \
531 #define FN_LOCAL_INTEGER(fn_name,val) \
532 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, \
533 struct loadparm_service *sDefault) { \
534 return((service != NULL)? service->val : sDefault->val); \
537 FN_GLOBAL_INTEGER(server_role, server_role)
538 FN_GLOBAL_LIST(smb_ports, smb_ports)
539 FN_GLOBAL_INTEGER(nbt_port, nbt_port)
540 FN_GLOBAL_INTEGER(dgram_port, dgram_port)
541 FN_GLOBAL_INTEGER(cldap_port, cldap_port)
542 FN_GLOBAL_INTEGER(krb5_port, krb5_port)
543 FN_GLOBAL_INTEGER(kpasswd_port, kpasswd_port)
544 FN_GLOBAL_INTEGER(web_port, web_port)
545 FN_GLOBAL_BOOL(tls_enabled, tls_enabled)
546 FN_GLOBAL_STRING(logfile, logfile)
547 FN_GLOBAL_STRING(share_backend, szShareBackend)
548 FN_GLOBAL_STRING(spoolss_url, szSPOOLSS_URL)
549 FN_GLOBAL_STRING(wins_config_url, szWINS_CONFIG_URL)
550 FN_GLOBAL_STRING(wins_url, szWINS_URL)
551 FN_GLOBAL_CONST_STRING(winbind_separator, szWinbindSeparator)
552 FN_GLOBAL_CONST_STRING(winbindd_socket_directory, szWinbinddSocketDirectory)
553 FN_GLOBAL_CONST_STRING(winbindd_privileged_socket_directory, szWinbinddPrivilegedSocketDirectory)
554 FN_GLOBAL_CONST_STRING(template_shell, szTemplateShell)
555 FN_GLOBAL_CONST_STRING(template_homedir, szTemplateHomedir)
556 FN_GLOBAL_BOOL(winbind_sealed_pipes, bWinbindSealedPipes)
557 FN_GLOBAL_BOOL(idmap_trusted_only, bIdmapTrustedOnly)
558 FN_GLOBAL_STRING(private_dir, szPrivateDir)
559 FN_GLOBAL_STRING(serverstring, szServerString)
560 FN_GLOBAL_STRING(lockdir, szLockDir)
561 FN_GLOBAL_STRING(ncalrpc_dir, ncalrpc_dir)
562 FN_GLOBAL_STRING(dos_charset, dos_charset)
563 FN_GLOBAL_STRING(unix_charset, unix_charset)
564 FN_GLOBAL_STRING(piddir, szPidDir)
565 FN_GLOBAL_LIST(rndc_command, szRNDCCommand)
566 FN_GLOBAL_LIST(dns_update_command, szDNSUpdateCommand)
567 FN_GLOBAL_LIST(spn_update_command, szSPNUpdateCommand)
568 FN_GLOBAL_LIST(nsupdate_command, szNSUpdateCommand)
569 FN_GLOBAL_LIST(dcerpc_endpoint_servers, dcerpc_ep_servers)
570 FN_GLOBAL_LIST(server_services, server_services)
571 FN_GLOBAL_STRING(ntptr_providor, ntptr_providor)
572 FN_GLOBAL_STRING(auto_services, szAutoServices)
573 FN_GLOBAL_STRING(passwd_chat, szPasswdChat)
574 FN_GLOBAL_LIST(passwordserver, szPasswordServers)
575 FN_GLOBAL_LIST(name_resolve_order, szNameResolveOrder)
576 FN_GLOBAL_STRING(realm, szRealm_upper)
577 FN_GLOBAL_STRING(dnsdomain, szRealm_lower)
578 FN_GLOBAL_STRING(socket_options, socket_options)
579 FN_GLOBAL_STRING(workgroup, szWorkgroup)
580 FN_GLOBAL_STRING(netbios_name, szNetbiosName)
581 FN_GLOBAL_STRING(netbios_scope, szNetbiosScope)
582 FN_GLOBAL_LIST(wins_server_list, szWINSservers)
583 FN_GLOBAL_LIST(interfaces, szInterfaces)
584 FN_GLOBAL_STRING(socket_address, szSocketAddress)
585 FN_GLOBAL_LIST(netbios_aliases, szNetbiosAliases)
586 FN_GLOBAL_BOOL(disable_netbios, bDisableNetbios)
587 FN_GLOBAL_BOOL(wins_support, bWINSsupport)
588 FN_GLOBAL_BOOL(wins_dns_proxy, bWINSdnsProxy)
589 FN_GLOBAL_STRING(wins_hook, szWINSHook)
590 FN_GLOBAL_BOOL(local_master, bLocalMaster)
591 FN_GLOBAL_BOOL(readraw, bReadRaw)
592 FN_GLOBAL_BOOL(large_readwrite, bLargeReadwrite)
593 FN_GLOBAL_BOOL(writeraw, bWriteRaw)
594 FN_GLOBAL_BOOL(null_passwords, bNullPasswords)
595 FN_GLOBAL_BOOL(obey_pam_restrictions, bObeyPamRestrictions)
596 FN_GLOBAL_BOOL(encrypted_passwords, bEncryptPasswords)
597 FN_GLOBAL_BOOL(time_server, bTimeServer)
598 FN_GLOBAL_BOOL(bind_interfaces_only, bBindInterfacesOnly)
599 FN_GLOBAL_BOOL(unicode, bUnicode)
600 FN_GLOBAL_BOOL(nt_status_support, bNTStatusSupport)
601 FN_GLOBAL_BOOL(lanman_auth, bLanmanAuth)
602 FN_GLOBAL_BOOL(ntlm_auth, bNTLMAuth)
603 FN_GLOBAL_BOOL(client_plaintext_auth, bClientPlaintextAuth)
604 FN_GLOBAL_BOOL(client_lanman_auth, bClientLanManAuth)
605 FN_GLOBAL_BOOL(client_ntlmv2_auth, bClientNTLMv2Auth)
606 FN_GLOBAL_BOOL(client_use_spnego_principal, client_use_spnego_principal)
607 FN_GLOBAL_BOOL(host_msdfs, bHostMSDfs)
608 FN_GLOBAL_BOOL(unix_extensions, bUnixExtensions)
609 FN_GLOBAL_BOOL(use_spnego, bUseSpnego)
610 FN_GLOBAL_BOOL(rpc_big_endian, bRpcBigEndian)
611 FN_GLOBAL_INTEGER(max_wins_ttl, max_wins_ttl)
612 FN_GLOBAL_INTEGER(min_wins_ttl, min_wins_ttl)
613 FN_GLOBAL_INTEGER(maxmux, max_mux)
614 FN_GLOBAL_INTEGER(max_xmit, max_xmit)
615 FN_GLOBAL_INTEGER(passwordlevel, pwordlevel)
616 FN_GLOBAL_INTEGER(srv_maxprotocol, srv_maxprotocol)
617 FN_GLOBAL_INTEGER(srv_minprotocol, srv_minprotocol)
618 FN_GLOBAL_INTEGER(cli_maxprotocol, cli_maxprotocol)
619 FN_GLOBAL_INTEGER(cli_minprotocol, cli_minprotocol)
620 FN_GLOBAL_INTEGER(security, security)
621 FN_GLOBAL_BOOL(paranoid_server_security, paranoid_server_security)
623 FN_LOCAL_STRING(pathname, szPath)
624 FN_LOCAL_LIST(hostsallow, szHostsallow)
625 FN_LOCAL_LIST(hostsdeny, szHostsdeny)
626 FN_LOCAL_STRING(comment, comment)
627 FN_LOCAL_STRING(fstype, fstype)
628 FN_LOCAL_LIST(ntvfs_handler, ntvfs_handler)
629 FN_LOCAL_BOOL(msdfs_root, bMSDfsRoot)
630 FN_LOCAL_BOOL(browseable, bBrowseable)
631 FN_LOCAL_BOOL(readonly, bRead_only)
632 FN_LOCAL_BOOL(print_ok, bPrint_ok)
633 FN_LOCAL_BOOL(map_hidden, bMap_hidden)
634 FN_LOCAL_BOOL(map_archive, bMap_archive)
635 FN_LOCAL_BOOL(strict_locking, bStrictLocking)
636 FN_LOCAL_BOOL(oplocks, bOplocks)
637 FN_LOCAL_BOOL(strict_sync, bStrictSync)
638 FN_LOCAL_BOOL(ci_filesystem, bCIFileSystem)
639 FN_LOCAL_BOOL(map_system, bMap_system)
640 FN_LOCAL_INTEGER(max_connections, iMaxConnections)
641 FN_LOCAL_INTEGER(csc_policy, iCSCPolicy)
642 FN_LOCAL_INTEGER(create_mask, iCreate_mask)
643 FN_LOCAL_INTEGER(force_create_mode, iCreate_force_mode)
644 FN_LOCAL_INTEGER(dir_mask, iDir_mask)
645 FN_LOCAL_INTEGER(force_dir_mode, iDir_force_mode)
646 FN_GLOBAL_INTEGER(server_signing, server_signing)
647 FN_GLOBAL_INTEGER(client_signing, client_signing)
649 FN_GLOBAL_CONST_STRING(ntp_signd_socket_directory, szNTPSignDSocketDirectory)
651 /* local prototypes */
652 static int map_parameter(const char *pszParmName);
653 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
654 const char *pszServiceName);
655 static void copy_service(struct loadparm_service *pserviceDest,
656 struct loadparm_service *pserviceSource,
658 static bool service_ok(struct loadparm_service *service);
659 static bool do_section(const char *pszSectionName, void *);
660 static void init_copymap(struct loadparm_service *pservice);
662 /* This is a helper function for parametrical options support. */
663 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
664 /* Actual parametrical functions are quite simple */
665 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
666 struct loadparm_service *service,
667 const char *type, const char *option)
669 char *vfskey_tmp = NULL;
671 struct parmlist_entry *data;
676 if (lp_ctx->s3_fns) {
677 SMB_ASSERT(service == NULL);
678 return lp_ctx->s3_fns->get_parametric(type, option);
681 data = (service == NULL ? lp_ctx->globals->param_opt : service->param_opt);
683 vfskey_tmp = talloc_asprintf(NULL, "%s:%s", type, option);
684 if (vfskey_tmp == NULL) return NULL;
685 vfskey = strlower_talloc(NULL, vfskey_tmp);
686 talloc_free(vfskey_tmp);
689 if (strcmp(data->key, vfskey) == 0) {
696 if (service != NULL) {
697 /* Try to fetch the same option but from globals */
698 /* but only if we are not already working with globals */
699 for (data = lp_ctx->globals->param_opt; data;
701 if (strcmp(data->key, vfskey) == 0) {
715 * convenience routine to return int parameters.
717 static int lp_int(const char *s)
721 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
725 return strtol(s, NULL, 0);
729 * convenience routine to return unsigned long parameters.
731 static int lp_ulong(const char *s)
735 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
739 return strtoul(s, NULL, 0);
743 * convenience routine to return unsigned long parameters.
745 static double lp_double(const char *s)
749 DEBUG(0,("lp_double(%s): is called with NULL!\n",s));
753 return strtod(s, NULL);
757 * convenience routine to return boolean parameters.
759 static bool lp_bool(const char *s)
764 DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
768 if (!set_boolean(s, &ret)) {
769 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
778 * Return parametric option from a given service. Type is a part of option before ':'
779 * Parametric option has following syntax: 'Type: option = value'
780 * Returned value is allocated in 'lp_talloc' context
783 const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
784 struct loadparm_service *service, const char *type,
787 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
790 return lp_string(value);
796 * Return parametric option from a given service. Type is a part of option before ':'
797 * Parametric option has following syntax: 'Type: option = value'
798 * Returned value is allocated in 'lp_talloc' context
801 const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
802 struct loadparm_context *lp_ctx,
803 struct loadparm_service *service,
805 const char *option, const char *separator)
807 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
810 return (const char **)str_list_make(mem_ctx, value, separator);
816 * Return parametric option from a given service. Type is a part of option before ':'
817 * Parametric option has following syntax: 'Type: option = value'
820 int lpcfg_parm_int(struct loadparm_context *lp_ctx,
821 struct loadparm_service *service, const char *type,
822 const char *option, int default_v)
824 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
827 return lp_int(value);
833 * Return parametric option from a given service. Type is a part of
835 * Parametric option has following syntax: 'Type: option = value'.
838 int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
839 struct loadparm_service *service, const char *type,
840 const char *option, int default_v)
844 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
846 if (value && conv_str_size_error(value, &bval)) {
847 if (bval <= INT_MAX) {
856 * Return parametric option from a given service.
857 * Type is a part of option before ':'
858 * Parametric option has following syntax: 'Type: option = value'
860 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
861 struct loadparm_service *service, const char *type,
862 const char *option, unsigned long default_v)
864 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
867 return lp_ulong(value);
873 double lpcfg_parm_double(struct loadparm_context *lp_ctx,
874 struct loadparm_service *service, const char *type,
875 const char *option, double default_v)
877 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
880 return lp_double(value);
886 * Return parametric option from a given service. Type is a part of option before ':'
887 * Parametric option has following syntax: 'Type: option = value'
890 bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
891 struct loadparm_service *service, const char *type,
892 const char *option, bool default_v)
894 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
897 return lp_bool(value);
904 * Initialise a service to the defaults.
907 static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx, struct loadparm_service *sDefault)
909 struct loadparm_service *pservice =
910 talloc_zero(mem_ctx, struct loadparm_service);
911 copy_service(pservice, sDefault, NULL);
916 * Set a string value, deallocating any existing space, and allocing the space
919 static bool string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
926 *dest = talloc_strdup(mem_ctx, src);
927 if ((*dest) == NULL) {
928 DEBUG(0,("Out of memory in string_set\n"));
936 * Set a string value, deallocating any existing space, and allocing the space
939 static bool string_set_upper(TALLOC_CTX *mem_ctx, char **dest, const char *src)
946 *dest = strupper_talloc(mem_ctx, src);
947 if ((*dest) == NULL) {
948 DEBUG(0,("Out of memory in string_set_upper\n"));
958 * Add a new service to the services array initialising it with the given
962 struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
963 const struct loadparm_service *pservice,
967 struct loadparm_service tservice;
968 int num_to_alloc = lp_ctx->iNumServices + 1;
969 struct parmlist_entry *data, *pdata;
971 if (pservice == NULL) {
972 pservice = lp_ctx->sDefault;
975 tservice = *pservice;
977 /* it might already exist */
979 struct loadparm_service *service = getservicebyname(lp_ctx,
981 if (service != NULL) {
982 /* Clean all parametric options for service */
983 /* They will be added during parsing again */
984 data = service->param_opt;
990 service->param_opt = NULL;
995 /* find an invalid one */
996 for (i = 0; i < lp_ctx->iNumServices; i++)
997 if (lp_ctx->services[i] == NULL)
1000 /* if not, then create one */
1001 if (i == lp_ctx->iNumServices) {
1002 struct loadparm_service **tsp;
1004 tsp = talloc_realloc(lp_ctx, lp_ctx->services, struct loadparm_service *, num_to_alloc);
1007 DEBUG(0,("lpcfg_add_service: failed to enlarge services!\n"));
1010 lp_ctx->services = tsp;
1011 lp_ctx->services[lp_ctx->iNumServices] = NULL;
1014 lp_ctx->iNumServices++;
1017 lp_ctx->services[i] = init_service(lp_ctx->services, lp_ctx->sDefault);
1018 if (lp_ctx->services[i] == NULL) {
1019 DEBUG(0,("lpcfg_add_service: out of memory!\n"));
1022 copy_service(lp_ctx->services[i], &tservice, NULL);
1024 string_set(lp_ctx->services[i], &lp_ctx->services[i]->szService, name);
1025 return lp_ctx->services[i];
1029 * Add a new home service, with the specified home directory, defaults coming
1030 * from service ifrom.
1033 bool lpcfg_add_home(struct loadparm_context *lp_ctx,
1034 const char *pszHomename,
1035 struct loadparm_service *default_service,
1036 const char *user, const char *pszHomedir)
1038 struct loadparm_service *service;
1040 service = lpcfg_add_service(lp_ctx, default_service, pszHomename);
1042 if (service == NULL)
1045 if (!(*(default_service->szPath))
1046 || strequal(default_service->szPath, lp_ctx->sDefault->szPath)) {
1047 service->szPath = talloc_strdup(service, pszHomedir);
1049 service->szPath = string_sub_talloc(service, lpcfg_pathname(default_service, lp_ctx->sDefault), "%H", pszHomedir);
1052 if (!(*(service->comment))) {
1053 service->comment = talloc_asprintf(service, "Home directory of %s", user);
1055 service->bAvailable = default_service->bAvailable;
1056 service->bBrowseable = default_service->bBrowseable;
1058 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
1059 pszHomename, user, service->szPath));
1065 * Add a new printer service, with defaults coming from service iFrom.
1068 bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
1069 const char *pszPrintername,
1070 struct loadparm_service *default_service)
1072 const char *comment = "From Printcap";
1073 struct loadparm_service *service;
1074 service = lpcfg_add_service(lp_ctx, default_service, pszPrintername);
1076 if (service == NULL)
1079 /* note that we do NOT default the availability flag to True - */
1080 /* we take it from the default service passed. This allows all */
1081 /* dynamic printers to be disabled by disabling the [printers] */
1082 /* entry (if/when the 'available' keyword is implemented!). */
1084 /* the printer name is set to the service name. */
1085 string_set(service, &service->szPrintername, pszPrintername);
1086 string_set(service, &service->comment, comment);
1087 service->bBrowseable = default_service->bBrowseable;
1088 /* Printers cannot be read_only. */
1089 service->bRead_only = false;
1090 /* Printer services must be printable. */
1091 service->bPrint_ok = true;
1093 DEBUG(3, ("adding printer service %s\n", pszPrintername));
1099 * Map a parameter's string representation to something we can use.
1100 * Returns False if the parameter string is not recognised, else TRUE.
1103 static int map_parameter(const char *pszParmName)
1107 if (*pszParmName == '-')
1110 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
1111 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
1114 /* Warn only if it isn't parametric option */
1115 if (strchr(pszParmName, ':') == NULL)
1116 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
1117 /* We do return 'fail' for parametric options as well because they are
1118 stored in different storage
1125 return the parameter structure for a parameter
1127 struct parm_struct *lpcfg_parm_struct(const char *name)
1129 int parmnum = map_parameter(name);
1130 if (parmnum == -1) return NULL;
1131 return &parm_table[parmnum];
1135 return the parameter pointer for a parameter
1137 void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
1138 struct loadparm_service *service, struct parm_struct *parm)
1140 if (service == NULL) {
1141 if (parm->pclass == P_LOCAL)
1142 return ((char *)lp_ctx->sDefault)+parm->offset;
1143 else if (parm->pclass == P_GLOBAL)
1144 return ((char *)lp_ctx->globals)+parm->offset;
1147 return ((char *)service) + parm->offset;
1152 * Find a service by name. Otherwise works like get_service.
1155 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
1156 const char *pszServiceName)
1160 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--)
1161 if (lp_ctx->services[iService] != NULL &&
1162 strwicmp(lp_ctx->services[iService]->szService, pszServiceName) == 0) {
1163 return lp_ctx->services[iService];
1170 * Copy a service structure to another.
1171 * If pcopymapDest is NULL then copy all fields
1174 static void copy_service(struct loadparm_service *pserviceDest,
1175 struct loadparm_service *pserviceSource,
1179 bool bcopyall = (pcopymapDest == NULL);
1180 struct parmlist_entry *data, *pdata, *paramo;
1183 for (i = 0; parm_table[i].label; i++)
1184 if (parm_table[i].offset != -1 && parm_table[i].pclass == P_LOCAL &&
1185 (bcopyall || pcopymapDest[i])) {
1187 ((char *)pserviceSource) + parm_table[i].offset;
1189 ((char *)pserviceDest) + parm_table[i].offset;
1191 switch (parm_table[i].type) {
1193 *(int *)dest_ptr = *(int *)src_ptr;
1199 *(int *)dest_ptr = *(int *)src_ptr;
1203 string_set(pserviceDest,
1209 string_set_upper(pserviceDest,
1214 *(const char ***)dest_ptr = (const char **)str_list_copy(pserviceDest,
1215 *(const char ***)src_ptr);
1223 init_copymap(pserviceDest);
1224 if (pserviceSource->copymap)
1225 memcpy((void *)pserviceDest->copymap,
1226 (void *)pserviceSource->copymap,
1227 sizeof(int) * NUMPARAMETERS);
1230 data = pserviceSource->param_opt;
1233 pdata = pserviceDest->param_opt;
1234 /* Traverse destination */
1236 /* If we already have same option, override it */
1237 if (strcmp(pdata->key, data->key) == 0) {
1238 talloc_free(pdata->value);
1239 pdata->value = talloc_reference(pdata,
1244 pdata = pdata->next;
1247 paramo = talloc_zero(pserviceDest, struct parmlist_entry);
1250 paramo->key = talloc_reference(paramo, data->key);
1251 paramo->value = talloc_reference(paramo, data->value);
1252 DLIST_ADD(pserviceDest->param_opt, paramo);
1259 * Check a service for consistency. Return False if the service is in any way
1260 * incomplete or faulty, else True.
1262 static bool service_ok(struct loadparm_service *service)
1267 if (service->szService[0] == '\0') {
1268 DEBUG(0, ("The following message indicates an internal error:\n"));
1269 DEBUG(0, ("No service name in service entry.\n"));
1273 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
1274 /* I can't see why you'd want a non-printable printer service... */
1275 if (strwicmp(service->szService, PRINTERS_NAME) == 0) {
1276 if (!service->bPrint_ok) {
1277 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
1278 service->szService));
1279 service->bPrint_ok = true;
1281 /* [printers] service must also be non-browsable. */
1282 if (service->bBrowseable)
1283 service->bBrowseable = false;
1286 /* If a service is flagged unavailable, log the fact at level 0. */
1287 if (!service->bAvailable)
1288 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
1289 service->szService));
1295 /*******************************************************************
1296 Keep a linked list of all config files so we know when one has changed
1297 it's date and needs to be reloaded.
1298 ********************************************************************/
1300 static void add_to_file_list(struct loadparm_context *lp_ctx,
1301 const char *fname, const char *subfname)
1303 struct file_lists *f = lp_ctx->file_lists;
1306 if (f->name && !strcmp(f->name, fname))
1312 f = talloc(lp_ctx, struct file_lists);
1315 f->next = lp_ctx->file_lists;
1316 f->name = talloc_strdup(f, fname);
1321 f->subfname = talloc_strdup(f, subfname);
1326 lp_ctx->file_lists = f;
1327 f->modtime = file_modtime(subfname);
1329 time_t t = file_modtime(subfname);
1335 /*******************************************************************
1336 Check if a config file has changed date.
1337 ********************************************************************/
1338 bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx)
1340 struct file_lists *f;
1341 DEBUG(6, ("lp_file_list_changed()\n"));
1343 for (f = lp_ctx->file_lists; f != NULL; f = f->next) {
1347 n2 = standard_sub_basic(lp_ctx, f->name);
1349 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
1350 f->name, n2, ctime(&f->modtime)));
1352 mod_time = file_modtime(n2);
1354 if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
1355 DEBUGADD(6, ("file %s modified: %s\n", n2,
1357 f->modtime = mod_time;
1358 talloc_free(f->subfname);
1359 f->subfname = talloc_strdup(f, n2);
1366 /***************************************************************************
1367 Handle the "realm" parameter
1368 ***************************************************************************/
1370 static bool handle_realm(struct loadparm_context *lp_ctx,
1371 const char *pszParmValue, char **ptr)
1373 string_set(lp_ctx, ptr, pszParmValue);
1375 talloc_free(lp_ctx->globals->szRealm_upper);
1376 talloc_free(lp_ctx->globals->szRealm_lower);
1378 lp_ctx->globals->szRealm_upper = strupper_talloc(lp_ctx, pszParmValue);
1379 lp_ctx->globals->szRealm_lower = strlower_talloc(lp_ctx, pszParmValue);
1384 /***************************************************************************
1385 Handle the include operation.
1386 ***************************************************************************/
1388 static bool handle_include(struct loadparm_context *lp_ctx,
1389 const char *pszParmValue, char **ptr)
1391 char *fname = standard_sub_basic(lp_ctx, pszParmValue);
1393 add_to_file_list(lp_ctx, pszParmValue, fname);
1395 string_set(lp_ctx, ptr, fname);
1397 if (file_exist(fname))
1398 return pm_process(fname, do_section, do_parameter, lp_ctx);
1400 DEBUG(2, ("Can't find include file %s\n", fname));
1405 /***************************************************************************
1406 Handle the interpretation of the copy parameter.
1407 ***************************************************************************/
1409 static bool handle_copy(struct loadparm_context *lp_ctx,
1410 const char *pszParmValue, char **ptr)
1413 struct loadparm_service *serviceTemp;
1415 string_set(lp_ctx, ptr, pszParmValue);
1419 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
1421 if ((serviceTemp = getservicebyname(lp_ctx, pszParmValue)) != NULL) {
1422 if (serviceTemp == lp_ctx->currentService) {
1423 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
1425 copy_service(lp_ctx->currentService,
1427 lp_ctx->currentService->copymap);
1431 DEBUG(0, ("Unable to copy service - source not found: %s\n",
1439 static bool handle_debuglevel(struct loadparm_context *lp_ctx,
1440 const char *pszParmValue, char **ptr)
1443 string_set(lp_ctx, ptr, pszParmValue);
1444 if (lp_ctx->global) {
1445 return debug_parse_levels(pszParmValue);
1450 static bool handle_logfile(struct loadparm_context *lp_ctx,
1451 const char *pszParmValue, char **ptr)
1453 debug_set_logfile(pszParmValue);
1454 if (lp_ctx->global) {
1455 string_set(lp_ctx, ptr, pszParmValue);
1460 /***************************************************************************
1461 Initialise a copymap.
1462 ***************************************************************************/
1464 static void init_copymap(struct loadparm_service *pservice)
1467 talloc_free(pservice->copymap);
1468 pservice->copymap = talloc_array(pservice, int, NUMPARAMETERS);
1469 if (pservice->copymap == NULL) {
1471 ("Couldn't allocate copymap!! (size %d)\n",
1472 (int)NUMPARAMETERS));
1475 for (i = 0; i < NUMPARAMETERS; i++)
1476 pservice->copymap[i] = true;
1480 * Process a parametric option
1482 static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
1483 struct loadparm_service *service,
1484 const char *pszParmName,
1485 const char *pszParmValue, int flags)
1487 struct parmlist_entry *paramo, *data;
1489 TALLOC_CTX *mem_ctx;
1491 while (isspace((unsigned char)*pszParmName)) {
1495 name = strlower_talloc(lp_ctx, pszParmName);
1496 if (!name) return false;
1498 if (service == NULL) {
1499 data = lp_ctx->globals->param_opt;
1500 mem_ctx = lp_ctx->globals;
1502 data = service->param_opt;
1506 /* Traverse destination */
1507 for (paramo=data; paramo; paramo=paramo->next) {
1508 /* If we already have the option set, override it unless
1509 it was a command line option and the new one isn't */
1510 if (strcmp(paramo->key, name) == 0) {
1511 if ((paramo->priority & FLAG_CMDLINE) &&
1512 !(flags & FLAG_CMDLINE)) {
1517 talloc_free(paramo->value);
1518 paramo->value = talloc_strdup(paramo, pszParmValue);
1519 paramo->priority = flags;
1525 paramo = talloc_zero(mem_ctx, struct parmlist_entry);
1528 paramo->key = talloc_strdup(paramo, name);
1529 paramo->value = talloc_strdup(paramo, pszParmValue);
1530 paramo->priority = flags;
1531 if (service == NULL) {
1532 DLIST_ADD(lp_ctx->globals->param_opt, paramo);
1534 DLIST_ADD(service->param_opt, paramo);
1542 static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
1543 const char *pszParmName, const char *pszParmValue,
1544 struct loadparm_context *lp_ctx, bool on_globals)
1547 /* if it is a special case then go ahead */
1548 if (parm_table[parmnum].special) {
1550 ret = parm_table[parmnum].special(lp_ctx, pszParmValue,
1555 goto mark_non_default;
1558 /* now switch on the type of variable it is */
1559 switch (parm_table[parmnum].type)
1563 if (!set_boolean(pszParmValue, &b)) {
1564 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
1567 *(int *)parm_ptr = b;
1572 *(int *)parm_ptr = atoi(pszParmValue);
1576 *(int *)parm_ptr = strtol(pszParmValue, NULL, 8);
1582 if (conv_str_size_error(pszParmValue, &val)) {
1583 if (val <= INT_MAX) {
1584 *(int *)parm_ptr = (int)val;
1589 DEBUG(0,("lp_do_parameter(%s): value is not "
1590 "a valid size specifier!\n", pszParmValue));
1595 *(const char ***)parm_ptr = (const char **)str_list_make(mem_ctx,
1596 pszParmValue, NULL);
1600 char **new_list = str_list_make(mem_ctx,
1601 pszParmValue, NULL);
1602 for (i=0; new_list[i]; i++) {
1603 if (new_list[i][0] == '+' && new_list[i][1] &&
1604 (!str_list_check(*(const char ***)parm_ptr,
1605 &new_list[i][1]))) {
1606 *(const char ***)parm_ptr = str_list_add(*(const char ***)parm_ptr,
1608 } else if (new_list[i][0] == '-' && new_list[i][1]) {
1609 #if 0 /* This is commented out because we sometimes parse the list
1610 * twice, and so we can't assert on this */
1611 if (!str_list_check(*(const char ***)parm_ptr,
1613 DEBUG(0, ("Unsupported value for: %s = %s, %s is not in the original list [%s]\n",
1614 pszParmName, pszParmValue, new_list[i],
1615 str_list_join_shell(mem_ctx, *(const char ***)parm_ptr, ' ')));
1620 str_list_remove(*(const char ***)parm_ptr,
1624 DEBUG(0, ("Unsupported list syntax for: %s = %s\n",
1625 pszParmName, pszParmValue));
1628 *(const char ***)parm_ptr = (const char **) new_list;
1635 string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
1639 string_set_upper(mem_ctx, (char **)parm_ptr, pszParmValue);
1643 for (i = 0; parm_table[parmnum].enum_list[i].name; i++) {
1646 parm_table[parmnum].enum_list[i].name)) {
1648 parm_table[parmnum].
1653 if (!parm_table[parmnum].enum_list[i].name) {
1654 DEBUG(0,("Unknown enumerated value '%s' for '%s'\n",
1655 pszParmValue, pszParmName));
1662 if (on_globals && (lp_ctx->flags[parmnum] & FLAG_DEFAULT)) {
1663 lp_ctx->flags[parmnum] &= ~FLAG_DEFAULT;
1664 /* we have to also unset FLAG_DEFAULT on aliases */
1665 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
1666 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
1668 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
1669 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
1676 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
1677 const char *pszParmName, const char *pszParmValue)
1679 int parmnum = map_parameter(pszParmName);
1683 if (strchr(pszParmName, ':')) {
1684 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName, pszParmValue, 0);
1686 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
1690 /* if the flag has been set on the command line, then don't allow override,
1691 but don't report an error */
1692 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
1696 parm_ptr = lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[parmnum]);
1698 return set_variable(lp_ctx->globals, parmnum, parm_ptr,
1699 pszParmName, pszParmValue, lp_ctx, true);
1702 bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
1703 struct loadparm_service *service,
1704 const char *pszParmName, const char *pszParmValue)
1708 int parmnum = map_parameter(pszParmName);
1711 if (strchr(pszParmName, ':')) {
1712 return lp_do_parameter_parametric(lp_ctx, service, pszParmName, pszParmValue, 0);
1714 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
1718 /* if the flag has been set on the command line, then don't allow override,
1719 but don't report an error */
1720 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
1724 if (parm_table[parmnum].pclass == P_GLOBAL) {
1726 ("Global parameter %s found in service section!\n",
1730 parm_ptr = ((char *)service) + parm_table[parmnum].offset;
1732 if (!service->copymap)
1733 init_copymap(service);
1735 /* this handles the aliases - set the copymap for other
1736 * entries with the same data pointer */
1737 for (i = 0; parm_table[i].label; i++)
1738 if (parm_table[i].offset == parm_table[parmnum].offset &&
1739 parm_table[i].pclass == parm_table[parmnum].pclass)
1740 service->copymap[i] = false;
1742 return set_variable(service, parmnum, parm_ptr, pszParmName,
1743 pszParmValue, lp_ctx, false);
1747 * Process a parameter.
1750 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
1753 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
1755 if (lp_ctx->bInGlobalSection)
1756 return lpcfg_do_global_parameter(lp_ctx, pszParmName,
1759 return lpcfg_do_service_parameter(lp_ctx, lp_ctx->currentService,
1760 pszParmName, pszParmValue);
1764 variable argument do parameter
1766 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx, const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
1767 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
1768 const char *pszParmName, const char *fmt, ...)
1775 s = talloc_vasprintf(NULL, fmt, ap);
1777 ret = lpcfg_do_global_parameter(lp_ctx, pszParmName, s);
1784 set a parameter from the commandline - this is called from command line parameter
1785 parsing code. It sets the parameter then marks the parameter as unable to be modified
1786 by smb.conf processing
1788 bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
1789 const char *pszParmValue)
1791 int parmnum = map_parameter(pszParmName);
1794 while (isspace((unsigned char)*pszParmValue)) pszParmValue++;
1797 if (parmnum < 0 && strchr(pszParmName, ':')) {
1798 /* set a parametric option */
1799 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
1800 pszParmValue, FLAG_CMDLINE);
1804 DEBUG(0,("Unknown option '%s'\n", pszParmName));
1808 /* reset the CMDLINE flag in case this has been called before */
1809 lp_ctx->flags[parmnum] &= ~FLAG_CMDLINE;
1811 if (!lpcfg_do_global_parameter(lp_ctx, pszParmName, pszParmValue)) {
1815 lp_ctx->flags[parmnum] |= FLAG_CMDLINE;
1817 /* we have to also set FLAG_CMDLINE on aliases */
1818 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
1819 lp_ctx->flags[i] |= FLAG_CMDLINE;
1821 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
1822 lp_ctx->flags[i] |= FLAG_CMDLINE;
1829 set a option from the commandline in 'a=b' format. Use to support --option
1831 bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option)
1849 ret = lpcfg_set_cmdline(lp_ctx, s, p+1);
1855 #define BOOLSTR(b) ((b) ? "Yes" : "No")
1858 * Print a parameter of the specified type.
1861 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
1864 const char *list_sep = ", "; /* For the seperation of lists values that we print below */
1868 for (i = 0; p->enum_list[i].name; i++) {
1869 if (*(int *)ptr == p->enum_list[i].value) {
1871 p->enum_list[i].name);
1878 fprintf(f, "%s", BOOLSTR((bool)*(int *)ptr));
1883 fprintf(f, "%d", *(int *)ptr);
1887 fprintf(f, "0%o", *(int *)ptr);
1894 if ((char ***)ptr && *(char ***)ptr) {
1895 char **list = *(char ***)ptr;
1897 for (; *list; list++) {
1898 if (*(list+1) == NULL) {
1899 /* last item, print no extra seperator after */
1902 fprintf(f, "%s%s", *list, list_sep);
1909 if (*(char **)ptr) {
1910 fprintf(f, "%s", *(char **)ptr);
1917 * Check if two parameters are equal.
1920 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
1924 return (*((int *)ptr1) == *((int *)ptr2));
1930 return (*((int *)ptr1) == *((int *)ptr2));
1934 return str_list_equal((const char **)(*(char ***)ptr1),
1935 (const char **)(*(char ***)ptr2));
1940 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
1945 return (p1 == p2 || strequal(p1, p2));
1952 * Process a new section (service).
1954 * At this stage all sections are services.
1955 * Later we'll have special sections that permit server parameters to be set.
1956 * Returns True on success, False on failure.
1959 static bool do_section(const char *pszSectionName, void *userdata)
1961 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
1963 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
1964 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
1967 /* if we've just struck a global section, note the fact. */
1968 lp_ctx->bInGlobalSection = isglobal;
1970 /* check for multiple global sections */
1971 if (lp_ctx->bInGlobalSection) {
1972 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
1976 /* if we have a current service, tidy it up before moving on */
1979 if (lp_ctx->currentService != NULL)
1980 bRetval = service_ok(lp_ctx->currentService);
1982 /* if all is still well, move to the next record in the services array */
1984 /* We put this here to avoid an odd message order if messages are */
1985 /* issued by the post-processing of a previous section. */
1986 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
1988 if ((lp_ctx->currentService = lpcfg_add_service(lp_ctx, lp_ctx->sDefault,
1991 DEBUG(0, ("Failed to add a new service\n"));
2001 * Determine if a particular base parameter is currently set to the default value.
2004 static bool is_default(struct loadparm_service *sDefault, int i)
2006 void *def_ptr = ((char *)sDefault) + parm_table[i].offset;
2007 if (!defaults_saved)
2009 switch (parm_table[i].type) {
2012 return str_list_equal((const char **)parm_table[i].def.lvalue,
2013 (const char **)def_ptr);
2016 return strequal(parm_table[i].def.svalue,
2019 return parm_table[i].def.bvalue ==
2025 return parm_table[i].def.ivalue ==
2032 *Display the contents of the global structure.
2035 static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
2039 struct parmlist_entry *data;
2041 fprintf(f, "# Global parameters\n[global]\n");
2043 for (i = 0; parm_table[i].label; i++)
2044 if (parm_table[i].pclass == P_GLOBAL &&
2045 parm_table[i].offset != -1 &&
2046 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
2047 if (!show_defaults && (lp_ctx->flags[i] & FLAG_DEFAULT))
2049 fprintf(f, "\t%s = ", parm_table[i].label);
2050 print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f);
2053 if (lp_ctx->globals->param_opt != NULL) {
2054 for (data = lp_ctx->globals->param_opt; data;
2055 data = data->next) {
2056 if (!show_defaults && (data->priority & FLAG_DEFAULT)) {
2059 fprintf(f, "\t%s = %s\n", data->key, data->value);
2066 * Display the contents of a single services record.
2069 static void dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f,
2070 unsigned int *flags)
2073 struct parmlist_entry *data;
2075 if (pService != sDefault)
2076 fprintf(f, "\n[%s]\n", pService->szService);
2078 for (i = 0; parm_table[i].label; i++) {
2079 if (parm_table[i].pclass == P_LOCAL &&
2080 parm_table[i].offset != -1 &&
2081 (*parm_table[i].label != '-') &&
2082 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
2084 if (pService == sDefault) {
2085 if (flags && (flags[i] & FLAG_DEFAULT)) {
2088 if (defaults_saved) {
2089 if (is_default(sDefault, i)) {
2094 if (equal_parameter(parm_table[i].type,
2095 ((char *)pService) +
2096 parm_table[i].offset,
2097 ((char *)sDefault) +
2098 parm_table[i].offset))
2102 fprintf(f, "\t%s = ", parm_table[i].label);
2103 print_parameter(&parm_table[i],
2104 ((char *)pService) + parm_table[i].offset, f);
2108 if (pService->param_opt != NULL) {
2109 for (data = pService->param_opt; data; data = data->next) {
2110 fprintf(f, "\t%s = %s\n", data->key, data->value);
2115 bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
2116 struct loadparm_service *service,
2117 const char *parm_name, FILE * f)
2119 struct parm_struct *parm;
2122 parm = lpcfg_parm_struct(parm_name);
2127 ptr = lpcfg_parm_ptr(lp_ctx, service,parm);
2129 print_parameter(parm, ptr, f);
2135 * Return info about the next parameter in a service.
2136 * snum==-1 gives the globals.
2137 * Return NULL when out of parameters.
2141 struct parm_struct *lpcfg_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
2145 /* do the globals */
2146 for (; parm_table[*i].label; (*i)++) {
2147 if (parm_table[*i].offset == -1
2148 || (*parm_table[*i].label == '-'))
2152 && (parm_table[*i].offset ==
2153 parm_table[(*i) - 1].offset))
2156 return &parm_table[(*i)++];
2159 struct loadparm_service *pService = lp_ctx->services[snum];
2161 for (; parm_table[*i].label; (*i)++) {
2162 if (parm_table[*i].pclass == P_LOCAL &&
2163 parm_table[*i].offset != -1 &&
2164 (*parm_table[*i].label != '-') &&
2166 (parm_table[*i].offset !=
2167 parm_table[(*i) - 1].offset)))
2169 if (allparameters ||
2170 !equal_parameter(parm_table[*i].type,
2171 ((char *)pService) +
2172 parm_table[*i].offset,
2173 ((char *)lp_ctx->sDefault) +
2174 parm_table[*i].offset))
2176 return &parm_table[(*i)++];
2187 * Auto-load some home services.
2189 static void lpcfg_add_auto_services(struct loadparm_context *lp_ctx,
2197 * Unload unused services.
2200 void lpcfg_killunused(struct loadparm_context *lp_ctx,
2201 struct smbsrv_connection *smb,
2202 bool (*snumused) (struct smbsrv_connection *, int))
2205 for (i = 0; i < lp_ctx->iNumServices; i++) {
2206 if (lp_ctx->services[i] == NULL)
2209 if (!snumused || !snumused(smb, i)) {
2210 talloc_free(lp_ctx->services[i]);
2211 lp_ctx->services[i] = NULL;
2217 static int lpcfg_destructor(struct loadparm_context *lp_ctx)
2219 struct parmlist_entry *data;
2221 if (lp_ctx->refuse_free) {
2222 /* someone is trying to free the
2223 global_loadparm_context.
2224 We can't allow that. */
2228 if (lp_ctx->globals->param_opt != NULL) {
2229 struct parmlist_entry *next;
2230 for (data = lp_ctx->globals->param_opt; data; data=next) {
2232 if (data->priority & FLAG_CMDLINE) continue;
2233 DLIST_REMOVE(lp_ctx->globals->param_opt, data);
2242 * Initialise the global parameter structure.
2244 * Note that most callers should use loadparm_init_global() instead
2246 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
2250 struct loadparm_context *lp_ctx;
2251 struct parmlist_entry *parm;
2254 lp_ctx = talloc_zero(mem_ctx, struct loadparm_context);
2258 talloc_set_destructor(lp_ctx, lpcfg_destructor);
2259 lp_ctx->bInGlobalSection = true;
2260 lp_ctx->globals = talloc_zero(lp_ctx, struct loadparm_global);
2261 lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service);
2263 lp_ctx->sDefault->iMaxPrintJobs = 1000;
2264 lp_ctx->sDefault->bAvailable = true;
2265 lp_ctx->sDefault->bBrowseable = true;
2266 lp_ctx->sDefault->bRead_only = true;
2267 lp_ctx->sDefault->bMap_archive = true;
2268 lp_ctx->sDefault->bStrictLocking = true;
2269 lp_ctx->sDefault->bOplocks = true;
2270 lp_ctx->sDefault->iCreate_mask = 0744;
2271 lp_ctx->sDefault->iCreate_force_mode = 0000;
2272 lp_ctx->sDefault->iDir_mask = 0755;
2273 lp_ctx->sDefault->iDir_force_mode = 0000;
2275 DEBUG(3, ("Initialising global parameters\n"));
2277 for (i = 0; parm_table[i].label; i++) {
2278 if ((parm_table[i].type == P_STRING ||
2279 parm_table[i].type == P_USTRING) &&
2280 parm_table[i].offset != -1 &&
2281 !(lp_ctx->flags[i] & FLAG_CMDLINE)) {
2283 if (parm_table[i].pclass == P_LOCAL) {
2284 r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset);
2286 r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset);
2288 *r = talloc_strdup(lp_ctx, "");
2292 logfile = talloc_asprintf(lp_ctx, "%s/log.samba", dyn_LOGFILEBASE);
2293 lpcfg_do_global_parameter(lp_ctx, "log file", logfile);
2294 talloc_free(logfile);
2296 lpcfg_do_global_parameter(lp_ctx, "log level", "0");
2298 lpcfg_do_global_parameter(lp_ctx, "share backend", "classic");
2300 lpcfg_do_global_parameter(lp_ctx, "share backend", "classic");
2302 lpcfg_do_global_parameter(lp_ctx, "server role", "standalone");
2304 /* options that can be set on the command line must be initialised via
2305 the slower lpcfg_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
2307 lpcfg_do_global_parameter(lp_ctx, "socket options", "TCP_NODELAY");
2309 lpcfg_do_global_parameter(lp_ctx, "workgroup", DEFAULT_WORKGROUP);
2310 myname = get_myname(lp_ctx);
2311 lpcfg_do_global_parameter(lp_ctx, "netbios name", myname);
2312 talloc_free(myname);
2313 lpcfg_do_global_parameter(lp_ctx, "name resolve order", "wins host bcast");
2315 lpcfg_do_global_parameter(lp_ctx, "fstype", "NTFS");
2317 lpcfg_do_global_parameter(lp_ctx, "ntvfs handler", "unixuid default");
2318 lpcfg_do_global_parameter(lp_ctx, "max connections", "-1");
2320 lpcfg_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup unixinfo browser eventlog6 backupkey");
2321 lpcfg_do_global_parameter(lp_ctx, "server services", "smb rpc nbt wrepl ldap cldap kdc drepl winbind ntp_signd kcc dnsupdate web");
2322 lpcfg_do_global_parameter(lp_ctx, "ntptr providor", "simple_ldb");
2323 /* the winbind method for domain controllers is for both RODC
2324 auth forwarding and for trusted domains */
2325 lpcfg_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR);
2326 lpcfg_do_global_parameter(lp_ctx, "spoolss database", "spoolss.ldb");
2327 lpcfg_do_global_parameter(lp_ctx, "wins config database", "wins_config.ldb");
2328 lpcfg_do_global_parameter(lp_ctx, "wins database", "wins.ldb");
2329 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
2331 /* This hive should be dynamically generated by Samba using
2332 data from the sam, but for the moment leave it in a tdb to
2333 keep regedt32 from popping up an annoying dialog. */
2334 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_USERS", "hku.ldb");
2336 /* using UTF8 by default allows us to support all chars */
2337 lpcfg_do_global_parameter(lp_ctx, "unix charset", "UTF8");
2339 /* Use codepage 850 as a default for the dos character set */
2340 lpcfg_do_global_parameter(lp_ctx, "dos charset", "CP850");
2343 * Allow the default PASSWD_CHAT to be overridden in local.h.
2345 lpcfg_do_global_parameter(lp_ctx, "passwd chat", DEFAULT_PASSWD_CHAT);
2347 lpcfg_do_global_parameter(lp_ctx, "pid directory", dyn_PIDDIR);
2348 lpcfg_do_global_parameter(lp_ctx, "lock dir", dyn_LOCKDIR);
2349 lpcfg_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
2351 lpcfg_do_global_parameter(lp_ctx, "socket address", "");
2352 lpcfg_do_global_parameter_var(lp_ctx, "server string",
2353 "Samba %s", SAMBA_VERSION_STRING);
2355 lpcfg_do_global_parameter_var(lp_ctx, "announce version", "%d.%d",
2356 DEFAULT_MAJOR_VERSION,
2357 DEFAULT_MINOR_VERSION);
2359 lpcfg_do_global_parameter(lp_ctx, "password server", "*");
2361 lpcfg_do_global_parameter(lp_ctx, "max mux", "50");
2362 lpcfg_do_global_parameter(lp_ctx, "max xmit", "12288");
2363 lpcfg_do_global_parameter(lp_ctx, "password level", "0");
2364 lpcfg_do_global_parameter(lp_ctx, "LargeReadwrite", "True");
2365 lpcfg_do_global_parameter(lp_ctx, "server min protocol", "CORE");
2366 lpcfg_do_global_parameter(lp_ctx, "server max protocol", "NT1");
2367 lpcfg_do_global_parameter(lp_ctx, "client min protocol", "CORE");
2368 lpcfg_do_global_parameter(lp_ctx, "client max protocol", "NT1");
2369 lpcfg_do_global_parameter(lp_ctx, "security", "USER");
2370 lpcfg_do_global_parameter(lp_ctx, "paranoid server security", "True");
2371 lpcfg_do_global_parameter(lp_ctx, "EncryptPasswords", "True");
2372 lpcfg_do_global_parameter(lp_ctx, "ReadRaw", "True");
2373 lpcfg_do_global_parameter(lp_ctx, "WriteRaw", "True");
2374 lpcfg_do_global_parameter(lp_ctx, "NullPasswords", "False");
2375 lpcfg_do_global_parameter(lp_ctx, "ObeyPamRestrictions", "False");
2376 lpcfg_do_global_parameter(lp_ctx, "announce as", "NT SERVER");
2378 lpcfg_do_global_parameter(lp_ctx, "TimeServer", "False");
2379 lpcfg_do_global_parameter(lp_ctx, "BindInterfacesOnly", "False");
2380 lpcfg_do_global_parameter(lp_ctx, "Unicode", "True");
2381 lpcfg_do_global_parameter(lp_ctx, "ClientLanManAuth", "False");
2382 lpcfg_do_global_parameter(lp_ctx, "ClientNTLMv2Auth", "True");
2383 lpcfg_do_global_parameter(lp_ctx, "LanmanAuth", "False");
2384 lpcfg_do_global_parameter(lp_ctx, "NTLMAuth", "True");
2385 lpcfg_do_global_parameter(lp_ctx, "client use spnego principal", "False");
2387 lpcfg_do_global_parameter(lp_ctx, "UnixExtensions", "False");
2389 lpcfg_do_global_parameter(lp_ctx, "PreferredMaster", "Auto");
2390 lpcfg_do_global_parameter(lp_ctx, "LocalMaster", "True");
2392 lpcfg_do_global_parameter(lp_ctx, "wins support", "False");
2393 lpcfg_do_global_parameter(lp_ctx, "dns proxy", "True");
2395 lpcfg_do_global_parameter(lp_ctx, "winbind separator", "\\");
2396 lpcfg_do_global_parameter(lp_ctx, "winbind sealed pipes", "True");
2397 lpcfg_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
2398 lpcfg_do_global_parameter(lp_ctx, "winbindd privileged socket directory", dyn_WINBINDD_PRIVILEGED_SOCKET_DIR);
2399 lpcfg_do_global_parameter(lp_ctx, "template shell", "/bin/false");
2400 lpcfg_do_global_parameter(lp_ctx, "template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%");
2401 lpcfg_do_global_parameter(lp_ctx, "idmap trusted only", "False");
2403 lpcfg_do_global_parameter(lp_ctx, "client signing", "Yes");
2404 lpcfg_do_global_parameter(lp_ctx, "server signing", "auto");
2406 lpcfg_do_global_parameter(lp_ctx, "use spnego", "True");
2408 lpcfg_do_global_parameter(lp_ctx, "smb ports", "445 139");
2409 lpcfg_do_global_parameter(lp_ctx, "nbt port", "137");
2410 lpcfg_do_global_parameter(lp_ctx, "dgram port", "138");
2411 lpcfg_do_global_parameter(lp_ctx, "cldap port", "389");
2412 lpcfg_do_global_parameter(lp_ctx, "krb5 port", "88");
2413 lpcfg_do_global_parameter(lp_ctx, "kpasswd port", "464");
2414 lpcfg_do_global_parameter(lp_ctx, "web port", "901");
2416 lpcfg_do_global_parameter(lp_ctx, "nt status support", "True");
2418 lpcfg_do_global_parameter(lp_ctx, "max wins ttl", "518400"); /* 6 days */
2419 lpcfg_do_global_parameter(lp_ctx, "min wins ttl", "10");
2421 lpcfg_do_global_parameter(lp_ctx, "tls enabled", "True");
2422 lpcfg_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem");
2423 lpcfg_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
2424 lpcfg_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
2425 lpcfg_do_global_parameter(lp_ctx, "prefork children:smb", "4");
2427 lpcfg_do_global_parameter(lp_ctx, "ntp signd socket directory", dyn_NTP_SIGND_SOCKET_DIR);
2428 lpcfg_do_global_parameter(lp_ctx, "rndc command", "/usr/sbin/rndc");
2429 lpcfg_do_global_parameter_var(lp_ctx, "dns update command", "%s/samba_dnsupdate", dyn_SCRIPTSBINDIR);
2430 lpcfg_do_global_parameter_var(lp_ctx, "spn update command", "%s/samba_spnupdate", dyn_SCRIPTSBINDIR);
2431 lpcfg_do_global_parameter(lp_ctx, "nsupdate command", "/usr/bin/nsupdate -g");
2433 for (i = 0; parm_table[i].label; i++) {
2434 if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
2435 lp_ctx->flags[i] |= FLAG_DEFAULT;
2439 for (parm=lp_ctx->globals->param_opt; parm; parm=parm->next) {
2440 if (!(parm->priority & FLAG_CMDLINE)) {
2441 parm->priority |= FLAG_DEFAULT;
2449 * Initialise the global parameter structure.
2451 struct loadparm_context *loadparm_init_global(bool load_default)
2453 if (global_loadparm_context == NULL) {
2454 global_loadparm_context = loadparm_init(NULL);
2456 if (global_loadparm_context == NULL) {
2459 global_loadparm_context->global = true;
2460 if (load_default && !global_loadparm_context->loaded) {
2461 lpcfg_load_default(global_loadparm_context);
2463 global_loadparm_context->refuse_free = true;
2464 return global_loadparm_context;
2468 * Initialise the global parameter structure.
2470 struct loadparm_context *loadparm_init_s3(TALLOC_CTX *mem_ctx,
2471 const struct loadparm_s3_context *s3_fns)
2473 struct loadparm_context *loadparm_context = loadparm_init(mem_ctx);
2474 if (!loadparm_context) {
2477 loadparm_context->s3_fns = s3_fns;
2478 return loadparm_context;
2481 const char *lpcfg_configfile(struct loadparm_context *lp_ctx)
2483 return lp_ctx->szConfigFile;
2486 const char *lp_default_path(void)
2488 if (getenv("SMB_CONF_PATH"))
2489 return getenv("SMB_CONF_PATH");
2491 return dyn_CONFIGFILE;
2495 * Update the internal state of a loadparm context after settings
2498 static bool lpcfg_update(struct loadparm_context *lp_ctx)
2500 struct debug_settings settings;
2501 lpcfg_add_auto_services(lp_ctx, lpcfg_auto_services(lp_ctx));
2503 if (!lp_ctx->globals->szWINSservers && lp_ctx->globals->bWINSsupport) {
2504 lpcfg_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
2507 if (!lp_ctx->global) {
2511 panic_action = lp_ctx->globals->panic_action;
2513 reload_charcnv(lp_ctx);
2515 ZERO_STRUCT(settings);
2516 /* Add any more debug-related smb.conf parameters created in
2518 settings.timestamp_logs = true;
2519 debug_set_settings(&settings);
2521 /* FIXME: This is a bit of a hack, but we can't use a global, since
2522 * not everything that uses lp also uses the socket library */
2523 if (lpcfg_parm_bool(lp_ctx, NULL, "socket", "testnonblock", false)) {
2524 setenv("SOCKET_TESTNONBLOCK", "1", 1);
2526 unsetenv("SOCKET_TESTNONBLOCK");
2532 bool lpcfg_load_default(struct loadparm_context *lp_ctx)
2536 path = lp_default_path();
2538 if (!file_exist(path)) {
2539 /* We allow the default smb.conf file to not exist,
2540 * basically the equivalent of an empty file. */
2541 return lpcfg_update(lp_ctx);
2544 return lpcfg_load(lp_ctx, path);
2548 * Load the services array from the services file.
2550 * Return True on success, False on failure.
2552 bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename)
2557 filename = talloc_strdup(lp_ctx, filename);
2559 lp_ctx->szConfigFile = filename;
2561 lp_ctx->bInGlobalSection = true;
2562 n2 = standard_sub_basic(lp_ctx, lp_ctx->szConfigFile);
2563 DEBUG(2, ("lpcfg_load: refreshing parameters from %s\n", n2));
2565 add_to_file_list(lp_ctx, lp_ctx->szConfigFile, n2);
2567 /* We get sections first, so have to start 'behind' to make up */
2568 lp_ctx->currentService = NULL;
2569 bRetval = pm_process(n2, do_section, do_parameter, lp_ctx);
2571 /* finish up the last section */
2572 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
2574 if (lp_ctx->currentService != NULL)
2575 bRetval = service_ok(lp_ctx->currentService);
2577 bRetval = bRetval && lpcfg_update(lp_ctx);
2579 /* we do this unconditionally, so that it happens even
2580 for a missing smb.conf */
2581 reload_charcnv(lp_ctx);
2583 if (bRetval == true) {
2584 /* set this up so that any child python tasks will
2585 find the right smb.conf */
2586 setenv("SMB_CONF_PATH", filename, 1);
2588 /* set the context used by the lp_*() function
2590 global_loadparm_context = lp_ctx;
2591 lp_ctx->loaded = true;
2598 * Return the max number of services.
2601 int lpcfg_numservices(struct loadparm_context *lp_ctx)
2603 return lp_ctx->iNumServices;
2607 * Display the contents of the services array in human-readable form.
2610 void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
2615 defaults_saved = !show_defaults;
2617 dump_globals(lp_ctx, f, show_defaults);
2619 dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f, lp_ctx->flags);
2621 for (iService = 0; iService < maxtoprint; iService++)
2622 lpcfg_dump_one(f, show_defaults, lp_ctx->services[iService], lp_ctx->sDefault);
2626 * Display the contents of one service in human-readable form.
2628 void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault)
2630 if (service != NULL) {
2631 if (service->szService[0] == '\0')
2633 dump_a_service(service, sDefault, f, NULL);
2637 struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
2640 return lp_ctx->services[snum];
2643 struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
2644 const char *service_name)
2649 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
2650 if (lp_ctx->services[iService] &&
2651 lp_ctx->services[iService]->szService) {
2653 * The substitution here is used to support %U is
2656 serviceName = standard_sub_basic(
2657 lp_ctx->services[iService],
2658 lp_ctx->services[iService]->szService);
2659 if (strequal(serviceName, service_name)) {
2660 talloc_free(serviceName);
2661 return lp_ctx->services[iService];
2663 talloc_free(serviceName);
2667 DEBUG(7,("lpcfg_servicenumber: couldn't find %s\n", service_name));
2671 const char *lpcfg_servicename(const struct loadparm_service *service)
2673 return lp_string((const char *)service->szService);
2677 * A useful volume label function.
2679 const char *lpcfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault)
2682 ret = lp_string((const char *)((service != NULL && service->volume != NULL) ?
2683 service->volume : sDefault->volume));
2685 return lpcfg_servicename(service);
2690 * If we are PDC then prefer us as DMB
2692 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault)
2695 ret = lp_string((const char *)((service != NULL && service->szPrintername != NULL) ?
2696 service->szPrintername : sDefault->szPrintername));
2697 if (ret == NULL || (ret != NULL && *ret == '\0'))
2698 ret = lpcfg_servicename(service);
2705 * Return the max print jobs per queue.
2707 int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault)
2709 int maxjobs = (service != NULL) ? service->iMaxPrintJobs : sDefault->iMaxPrintJobs;
2710 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
2711 maxjobs = PRINT_MAX_JOBID - 1;
2716 struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx)
2718 if (lp_ctx == NULL) {
2719 return get_iconv_handle();
2721 return lp_ctx->iconv_handle;
2724 _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
2726 struct smb_iconv_handle *old_ic = lp_ctx->iconv_handle;
2727 if (!lp_ctx->global) {
2731 if (old_ic == NULL) {
2732 old_ic = global_iconv_handle;
2734 lp_ctx->iconv_handle = smb_iconv_handle_reinit_lp(lp_ctx, lp_ctx, old_ic);
2735 global_iconv_handle = lp_ctx->iconv_handle;
2738 void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
2739 struct smbcli_options *options)
2741 options->max_xmit = lpcfg_max_xmit(lp_ctx);
2742 options->max_mux = lpcfg_maxmux(lp_ctx);
2743 options->use_spnego = lpcfg_nt_status_support(lp_ctx) && lpcfg_use_spnego(lp_ctx);
2744 options->signing = lpcfg_client_signing(lp_ctx);
2745 options->request_timeout = SMB_REQUEST_TIMEOUT;
2746 options->ntstatus_support = lpcfg_nt_status_support(lp_ctx);
2747 options->max_protocol = lpcfg_cli_maxprotocol(lp_ctx);
2748 options->unicode = lpcfg_unicode(lp_ctx);
2749 options->use_oplocks = true;
2750 options->use_level2_oplocks = true;
2753 void lpcfg_smbcli_session_options(struct loadparm_context *lp_ctx,
2754 struct smbcli_session_options *options)
2756 options->lanman_auth = lpcfg_client_lanman_auth(lp_ctx);
2757 options->ntlmv2_auth = lpcfg_client_ntlmv2_auth(lp_ctx);
2758 options->plaintext_auth = lpcfg_client_plaintext_auth(lp_ctx);
2761 _PUBLIC_ char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
2763 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_keyfile);
2766 _PUBLIC_ char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
2768 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_certfile);
2771 _PUBLIC_ char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
2773 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_cafile);
2776 _PUBLIC_ char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
2778 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_crlfile);
2781 _PUBLIC_ char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
2783 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_dhpfile);
2786 _PUBLIC_ struct dcerpc_server_info *lpcfg_dcerpc_server_info(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
2788 struct dcerpc_server_info *ret = talloc_zero(mem_ctx, struct dcerpc_server_info);
2790 ret->domain_name = talloc_reference(mem_ctx, lpcfg_workgroup(lp_ctx));
2791 ret->version_major = lpcfg_parm_int(lp_ctx, NULL, "server_info", "version_major", 5);
2792 ret->version_minor = lpcfg_parm_int(lp_ctx, NULL, "server_info", "version_minor", 2);
2793 ret->version_build = lpcfg_parm_int(lp_ctx, NULL, "server_info", "version_build", 3790);
2798 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
2800 struct gensec_settings *settings = talloc(mem_ctx, struct gensec_settings);
2801 if (settings == NULL)
2803 SMB_ASSERT(lp_ctx != NULL);
2804 settings->lp_ctx = talloc_reference(settings, lp_ctx);
2805 settings->target_hostname = lpcfg_parm_string(lp_ctx, NULL, "gensec", "target_hostname");