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 "../lib/util/dlinklist.h"
62 #include "lib/param/param.h"
63 #include "lib/param/loadparm.h"
64 #include "auth/gensec/gensec.h"
66 #include "lib/util/bitmap.h"
67 #include "libcli/smb/smb_constants.h"
68 #include "lib/param/loadparm_server_role.h"
70 #define standard_sub_basic talloc_strdup
72 static bool do_parameter(const char *, const char *, void *);
73 static bool defaults_saved = false;
75 #define LOADPARM_EXTRA_GLOBALS \
76 struct parmlist_entry *param_opt; \
91 #include "param_global.h"
93 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
96 /* prototypes for the special type handlers */
97 static bool handle_include(struct loadparm_context *lp_ctx, int unused,
98 const char *pszParmValue, char **ptr);
99 static bool handle_realm(struct loadparm_context *lp_ctx, int unused,
100 const char *pszParmValue, char **ptr);
101 static bool handle_copy(struct loadparm_context *lp_ctx, int unused,
102 const char *pszParmValue, char **ptr);
103 static bool handle_debuglevel(struct loadparm_context *lp_ctx, int unused,
104 const char *pszParmValue, char **ptr);
105 static bool handle_logfile(struct loadparm_context *lp_ctx, int unused,
106 const char *pszParmValue, char **ptr);
108 static const struct enum_list enum_protocol[] = {
109 {PROTOCOL_SMB2_02, "SMB2"},
110 {PROTOCOL_SMB2_02, "SMB2_02"},
111 {PROTOCOL_NT1, "NT1"},
112 {PROTOCOL_LANMAN2, "LANMAN2"},
113 {PROTOCOL_LANMAN1, "LANMAN1"},
114 {PROTOCOL_CORE, "CORE"},
115 {PROTOCOL_COREPLUS, "COREPLUS"},
116 {PROTOCOL_COREPLUS, "CORE+"},
120 static const struct enum_list enum_security[] = {
122 {SEC_SHARE, "SHARE"},
124 {SEC_DOMAIN, "DOMAIN"},
129 static const struct enum_list enum_bool_auto[] = {
140 /* Client-side offline caching policy types */
142 static const struct enum_list enum_csc_policy[] = {
143 {CSC_POLICY_MANUAL, "manual"},
144 {CSC_POLICY_DOCUMENTS, "documents"},
145 {CSC_POLICY_PROGRAMS, "programs"},
146 {CSC_POLICY_DISABLE, "disable"},
150 /* SMB signing types. */
151 static const struct enum_list enum_smb_signing_vals[] = {
152 {SMB_SIGNING_DEFAULT, "default"},
153 {SMB_SIGNING_OFF, "No"},
154 {SMB_SIGNING_OFF, "False"},
155 {SMB_SIGNING_OFF, "0"},
156 {SMB_SIGNING_OFF, "Off"},
157 {SMB_SIGNING_OFF, "disabled"},
158 {SMB_SIGNING_IF_REQUIRED, "if_required"},
159 {SMB_SIGNING_IF_REQUIRED, "Yes"},
160 {SMB_SIGNING_IF_REQUIRED, "True"},
161 {SMB_SIGNING_IF_REQUIRED, "1"},
162 {SMB_SIGNING_IF_REQUIRED, "On"},
163 {SMB_SIGNING_IF_REQUIRED, "enabled"},
164 {SMB_SIGNING_IF_REQUIRED, "auto"},
165 {SMB_SIGNING_REQUIRED, "required"},
166 {SMB_SIGNING_REQUIRED, "mandatory"},
167 {SMB_SIGNING_REQUIRED, "force"},
168 {SMB_SIGNING_REQUIRED, "forced"},
169 {SMB_SIGNING_REQUIRED, "enforced"},
173 /* Server role options */
174 static const struct enum_list enum_server_role[] = {
176 {ROLE_STANDALONE, "standalone"},
177 {ROLE_DOMAIN_MEMBER, "member server"},
178 {ROLE_DOMAIN_MEMBER, "member"},
179 /* note that currently
180 ROLE_DOMAIN_CONTROLLER == ROLE_DOMAIN_BDC */
181 {ROLE_DOMAIN_CONTROLLER, "domain controller"},
182 {ROLE_DOMAIN_BDC, "backup domain controller"},
183 {ROLE_DOMAIN_BDC, "bdc"},
184 {ROLE_DOMAIN_BDC, "dc"},
185 {ROLE_DOMAIN_PDC, "primary domain controller"},
186 {ROLE_DOMAIN_PDC, "pdc"},
190 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
191 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
193 static struct parm_struct parm_table[] = {
195 .label = "server role",
198 .offset = GLOBAL_VAR(server_role),
200 .enum_list = enum_server_role
203 .label = "domain logons",
206 .offset = GLOBAL_VAR(domain_logons),
208 .enum_list = enum_bool_auto
211 .label = "domain master",
214 .offset = GLOBAL_VAR(domain_master),
216 .enum_list = enum_bool_auto
219 .label = "dos charset",
222 .offset = GLOBAL_VAR(dos_charset),
227 .label = "unix charset",
230 .offset = GLOBAL_VAR(unix_charset),
235 .label = "ncalrpc dir",
238 .offset = GLOBAL_VAR(ncalrpc_dir),
246 .offset = LOCAL_VAR(comment),
254 .offset = LOCAL_VAR(szPath),
259 .label = "directory",
262 .offset = LOCAL_VAR(szPath),
267 .label = "workgroup",
270 .offset = GLOBAL_VAR(szWorkgroup),
278 .offset = GLOBAL_VAR(szRealm),
279 .special = handle_realm,
283 .label = "netbios name",
286 .offset = GLOBAL_VAR(szNetbiosName),
291 .label = "netbios aliases",
294 .offset = GLOBAL_VAR(szNetbiosAliases),
299 .label = "netbios scope",
302 .offset = GLOBAL_VAR(szNetbiosScope),
307 .label = "server string",
310 .offset = GLOBAL_VAR(szServerString),
315 .label = "interfaces",
318 .offset = GLOBAL_VAR(szInterfaces),
323 .label = "bind interfaces only",
326 .offset = GLOBAL_VAR(bBindInterfacesOnly),
331 .label = "ntvfs handler",
334 .offset = LOCAL_VAR(ntvfs_handler),
339 .label = "ntptr providor",
342 .offset = GLOBAL_VAR(ntptr_providor),
347 .label = "passdb backend",
350 .offset = GLOBAL_VAR(passdb_backend),
355 .label = "dcerpc endpoint servers",
358 .offset = GLOBAL_VAR(dcerpc_ep_servers),
363 .label = "server services",
366 .offset = GLOBAL_VAR(server_services),
375 .offset = GLOBAL_VAR(security),
377 .enum_list = enum_security
380 .label = "encrypt passwords",
383 .offset = GLOBAL_VAR(bEncryptPasswords),
388 .label = "null passwords",
391 .offset = GLOBAL_VAR(bNullPasswords),
396 .label = "obey pam restrictions",
399 .offset = GLOBAL_VAR(bObeyPamRestrictions),
404 .label = "password server",
407 .offset = GLOBAL_VAR(szPasswordServers),
412 .label = "private dir",
415 .offset = GLOBAL_VAR(szPrivateDir),
420 .label = "passwd chat",
423 .offset = GLOBAL_VAR(szPasswdChat),
428 .label = "password level",
431 .offset = GLOBAL_VAR(pwordlevel),
436 .label = "lanman auth",
439 .offset = GLOBAL_VAR(bLanmanAuth),
444 .label = "ntlm auth",
447 .offset = GLOBAL_VAR(bNTLMAuth),
452 .label = "client NTLMv2 auth",
455 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
460 .label = "client lanman auth",
463 .offset = GLOBAL_VAR(bClientLanManAuth),
468 .label = "client plaintext auth",
471 .offset = GLOBAL_VAR(bClientPlaintextAuth),
476 .label = "client use spnego principal",
479 .offset = GLOBAL_VAR(client_use_spnego_principal),
485 .label = "read only",
488 .offset = LOCAL_VAR(bRead_only),
494 .label = "create mask",
497 .offset = LOCAL_VAR(iCreate_mask),
502 .label = "force create mode",
505 .offset = LOCAL_VAR(iCreate_force_mode),
510 .label = "directory mask",
513 .offset = LOCAL_VAR(iDir_mask),
518 .label = "force directory mode",
521 .offset = LOCAL_VAR(iDir_force_mode),
527 .label = "hosts allow",
530 .offset = LOCAL_VAR(szHostsallow),
535 .label = "hosts deny",
538 .offset = LOCAL_VAR(szHostsdeny),
544 .label = "log level",
547 .offset = GLOBAL_VAR(loglevel),
548 .special = handle_debuglevel,
552 .label = "debuglevel",
555 .offset = GLOBAL_VAR(loglevel),
556 .special = handle_debuglevel,
563 .offset = GLOBAL_VAR(logfile),
564 .special = handle_logfile,
569 .label = "smb ports",
572 .offset = GLOBAL_VAR(smb_ports),
580 .offset = GLOBAL_VAR(nbt_port),
585 .label = "dgram port",
588 .offset = GLOBAL_VAR(dgram_port),
593 .label = "cldap port",
596 .offset = GLOBAL_VAR(cldap_port),
601 .label = "krb5 port",
604 .offset = GLOBAL_VAR(krb5_port),
609 .label = "kpasswd port",
612 .offset = GLOBAL_VAR(kpasswd_port),
620 .offset = GLOBAL_VAR(web_port),
625 .label = "tls enabled",
628 .offset = GLOBAL_VAR(tls_enabled),
633 .label = "tls keyfile",
636 .offset = GLOBAL_VAR(tls_keyfile),
641 .label = "tls certfile",
644 .offset = GLOBAL_VAR(tls_certfile),
649 .label = "tls cafile",
652 .offset = GLOBAL_VAR(tls_cafile),
657 .label = "tls crlfile",
660 .offset = GLOBAL_VAR(tls_crlfile),
665 .label = "tls dh params file",
668 .offset = GLOBAL_VAR(tls_dhpfile),
673 .label = "large readwrite",
676 .offset = GLOBAL_VAR(bLargeReadwrite),
681 .label = "server max protocol",
684 .offset = GLOBAL_VAR(srv_maxprotocol),
686 .enum_list = enum_protocol
689 .label = "server min protocol",
692 .offset = GLOBAL_VAR(srv_minprotocol),
694 .enum_list = enum_protocol
697 .label = "client max protocol",
700 .offset = GLOBAL_VAR(cli_maxprotocol),
702 .enum_list = enum_protocol
705 .label = "client min protocol",
708 .offset = GLOBAL_VAR(cli_minprotocol),
710 .enum_list = enum_protocol
716 .offset = GLOBAL_VAR(bUnicode),
724 .offset = GLOBAL_VAR(bReadRaw),
729 .label = "write raw",
732 .offset = GLOBAL_VAR(bWriteRaw),
737 .label = "disable netbios",
740 .offset = GLOBAL_VAR(bDisableNetbios),
746 .label = "nt status support",
749 .offset = GLOBAL_VAR(bNTStatusSupport),
758 .offset = GLOBAL_VAR(max_mux),
766 .offset = GLOBAL_VAR(max_xmit),
772 .label = "name resolve order",
775 .offset = GLOBAL_VAR(szNameResolveOrder),
780 .label = "max wins ttl",
783 .offset = GLOBAL_VAR(max_wins_ttl),
788 .label = "min wins ttl",
791 .offset = GLOBAL_VAR(min_wins_ttl),
796 .label = "time server",
799 .offset = GLOBAL_VAR(bTimeServer),
804 .label = "unix extensions",
807 .offset = GLOBAL_VAR(bUnixExtensions),
812 .label = "use spnego",
815 .offset = GLOBAL_VAR(bUseSpnego),
820 .label = "server signing",
823 .offset = GLOBAL_VAR(server_signing),
825 .enum_list = enum_smb_signing_vals
828 .label = "client signing",
831 .offset = GLOBAL_VAR(client_signing),
833 .enum_list = enum_smb_signing_vals
836 .label = "rpc big endian",
839 .offset = GLOBAL_VAR(bRpcBigEndian),
845 .label = "max connections",
848 .offset = LOCAL_VAR(iMaxConnections),
853 .label = "paranoid server security",
856 .offset = GLOBAL_VAR(paranoid_server_security),
861 .label = "socket options",
864 .offset = GLOBAL_VAR(socket_options),
870 .label = "strict sync",
873 .offset = LOCAL_VAR(bStrictSync),
881 .offset = GLOBAL_VAR(bUseMmap),
884 .flags = FLAG_ADVANCED,
887 .label = "case insensitive filesystem",
890 .offset = LOCAL_VAR(bCIFileSystem),
896 .label = "max print jobs",
899 .offset = LOCAL_VAR(iMaxPrintJobs),
904 .label = "printable",
907 .offset = LOCAL_VAR(bPrint_ok),
915 .offset = LOCAL_VAR(bPrint_ok),
921 .label = "printer name",
924 .offset = LOCAL_VAR(szPrintername),
932 .offset = LOCAL_VAR(szPrintername),
938 .label = "map system",
941 .offset = LOCAL_VAR(bMap_system),
946 .label = "map hidden",
949 .offset = LOCAL_VAR(bMap_hidden),
954 .label = "map archive",
957 .offset = LOCAL_VAR(bMap_archive),
963 .label = "preferred master",
966 .offset = GLOBAL_VAR(bPreferredMaster),
968 .enum_list = enum_bool_auto
971 .label = "prefered master",
974 .offset = GLOBAL_VAR(bPreferredMaster),
976 .enum_list = enum_bool_auto
979 .label = "local master",
982 .offset = GLOBAL_VAR(bLocalMaster),
987 .label = "browseable",
990 .offset = LOCAL_VAR(bBrowseable),
995 .label = "browsable",
998 .offset = LOCAL_VAR(bBrowseable),
1004 .label = "wins server",
1006 .p_class = P_GLOBAL,
1007 .offset = GLOBAL_VAR(szWINSservers),
1012 .label = "wins support",
1014 .p_class = P_GLOBAL,
1015 .offset = GLOBAL_VAR(bWINSsupport),
1020 .label = "dns proxy",
1022 .p_class = P_GLOBAL,
1023 .offset = GLOBAL_VAR(bWINSdnsProxy),
1028 .label = "wins hook",
1030 .p_class = P_GLOBAL,
1031 .offset = GLOBAL_VAR(szWINSHook),
1037 .label = "csc policy",
1040 .offset = LOCAL_VAR(iCSCPolicy),
1042 .enum_list = enum_csc_policy
1046 .label = "strict locking",
1049 .offset = LOCAL_VAR(iStrictLocking),
1057 .offset = LOCAL_VAR(bOpLocks),
1063 .label = "share backend",
1065 .p_class = P_GLOBAL,
1066 .offset = GLOBAL_VAR(szShareBackend),
1073 .p_class = P_GLOBAL,
1074 .offset = GLOBAL_VAR(szAutoServices),
1079 .label = "auto services",
1081 .p_class = P_GLOBAL,
1082 .offset = GLOBAL_VAR(szAutoServices),
1087 .label = "lock dir",
1089 .p_class = P_GLOBAL,
1090 .offset = GLOBAL_VAR(szLockDir),
1095 .label = "lock directory",
1097 .p_class = P_GLOBAL,
1098 .offset = GLOBAL_VAR(szLockDir),
1103 .label = "state directory",
1105 .p_class = P_GLOBAL,
1106 .offset = GLOBAL_VAR(szStateDir),
1111 .label = "cache directory",
1113 .p_class = P_GLOBAL,
1114 .offset = GLOBAL_VAR(szCacheDir),
1119 .label = "pid directory",
1121 .p_class = P_GLOBAL,
1122 .offset = GLOBAL_VAR(szPidDir),
1128 .label = "socket address",
1130 .p_class = P_GLOBAL,
1131 .offset = GLOBAL_VAR(szSocketAddress),
1139 .offset = LOCAL_VAR(szCopy),
1140 .special = handle_copy,
1147 .offset = LOCAL_VAR(szInclude),
1148 .special = handle_include,
1153 .label = "available",
1156 .offset = LOCAL_VAR(bAvailable),
1164 .offset = LOCAL_VAR(volume),
1172 .offset = LOCAL_VAR(fstype),
1178 .label = "panic action",
1180 .p_class = P_GLOBAL,
1181 .offset = GLOBAL_VAR(panic_action),
1187 .label = "msdfs root",
1190 .offset = LOCAL_VAR(bMSDfsRoot),
1195 .label = "host msdfs",
1197 .p_class = P_GLOBAL,
1198 .offset = GLOBAL_VAR(bHostMSDfs),
1203 .label = "winbind separator",
1205 .p_class = P_GLOBAL,
1206 .offset = GLOBAL_VAR(szWinbindSeparator),
1211 .label = "winbindd socket directory",
1213 .p_class = P_GLOBAL,
1214 .offset = GLOBAL_VAR(szWinbinddSocketDirectory),
1219 .label = "winbindd privileged socket directory",
1221 .p_class = P_GLOBAL,
1222 .offset = GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory),
1227 .label = "winbind sealed pipes",
1229 .p_class = P_GLOBAL,
1230 .offset = GLOBAL_VAR(bWinbindSealedPipes),
1235 .label = "template shell",
1237 .p_class = P_GLOBAL,
1238 .offset = GLOBAL_VAR(szTemplateShell),
1243 .label = "template homedir",
1245 .p_class = P_GLOBAL,
1246 .offset = GLOBAL_VAR(szTemplateHomedir),
1251 .label = "idmap trusted only",
1253 .p_class = P_GLOBAL,
1254 .offset = GLOBAL_VAR(bIdmapTrustedOnly),
1260 .label = "ntp signd socket directory",
1262 .p_class = P_GLOBAL,
1263 .offset = GLOBAL_VAR(szNTPSignDSocketDirectory),
1268 .label = "rndc command",
1270 .p_class = P_GLOBAL,
1271 .offset = GLOBAL_VAR(szRNDCCommand),
1276 .label = "dns update command",
1278 .p_class = P_GLOBAL,
1279 .offset = GLOBAL_VAR(szDNSUpdateCommand),
1284 .label = "spn update command",
1286 .p_class = P_GLOBAL,
1287 .offset = GLOBAL_VAR(szSPNUpdateCommand),
1292 .label = "nsupdate command",
1294 .p_class = P_GLOBAL,
1295 .offset = GLOBAL_VAR(szNSUpdateCommand),
1300 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
1304 /* local variables */
1305 struct loadparm_context {
1306 const char *szConfigFile;
1307 struct loadparm_global *globals;
1308 struct loadparm_service **services;
1309 struct loadparm_service *sDefault;
1310 struct smb_iconv_handle *iconv_handle;
1312 struct loadparm_service *currentService;
1313 bool bInGlobalSection;
1315 struct file_lists *next;
1320 unsigned int flags[NUMPARAMETERS];
1323 bool global; /* Is this the global context, which may set
1324 * global variables such as debug level etc? */
1325 const struct loadparm_s3_context *s3_fns;
1329 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx)
1331 if (lp_ctx->s3_fns) {
1332 return lp_ctx->s3_fns->get_default_loadparm_service();
1334 return lp_ctx->sDefault;
1338 * Convenience routine to grab string parameters into temporary memory
1339 * and run standard_sub_basic on them.
1341 * The buffers can be written to by
1342 * callers without affecting the source string.
1345 static const char *lp_string(const char *s)
1347 #if 0 /* until REWRITE done to make thread-safe */
1348 size_t len = s ? strlen(s) : 0;
1352 /* The follow debug is useful for tracking down memory problems
1353 especially if you have an inner loop that is calling a lp_*()
1354 function that returns a string. Perhaps this debug should be
1355 present all the time? */
1358 DEBUG(10, ("lp_string(%s)\n", s));
1361 #if 0 /* until REWRITE done to make thread-safe */
1363 lp_talloc = talloc_init("lp_talloc");
1365 ret = talloc_array(lp_talloc, char, len + 100); /* leave room for substitution */
1373 strlcpy(ret, s, len);
1375 if (trim_string(ret, "\"", "\"")) {
1376 if (strchr(ret,'"') != NULL)
1377 strlcpy(ret, s, len);
1380 standard_sub_basic(ret,len+100);
1387 In this section all the functions that are used to access the
1388 parameters from the rest of the program are defined
1392 * the creation of separate lpcfg_*() and lp_*() functions is to allow
1393 * for code compatibility between existing Samba4 and Samba3 code.
1396 /* this global context supports the lp_*() function varients */
1397 static struct loadparm_context *global_loadparm_context;
1399 #define lpcfg_default_service global_loadparm_context->sDefault
1400 #define lpcfg_global_service(i) global_loadparm_context->services[i]
1402 #define FN_GLOBAL_STRING(fn_name,var_name) \
1403 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
1404 if (lp_ctx == NULL) return NULL; \
1405 if (lp_ctx->s3_fns) { \
1406 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1407 return lp_ctx->s3_fns->fn_name(); \
1409 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
1412 #define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
1413 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
1414 if (lp_ctx == NULL) return NULL; \
1415 if (lp_ctx->s3_fns) { \
1416 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1417 return lp_ctx->s3_fns->fn_name(); \
1419 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
1422 #define FN_GLOBAL_LIST(fn_name,var_name) \
1423 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
1424 if (lp_ctx == NULL) return NULL; \
1425 if (lp_ctx->s3_fns) { \
1426 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1427 return lp_ctx->s3_fns->fn_name(); \
1429 return lp_ctx->globals->var_name; \
1432 #define FN_GLOBAL_BOOL(fn_name,var_name) \
1433 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
1434 if (lp_ctx == NULL) return false; \
1435 if (lp_ctx->s3_fns) { \
1436 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1437 return lp_ctx->s3_fns->fn_name(); \
1439 return lp_ctx->globals->var_name; \
1442 #define FN_GLOBAL_INTEGER(fn_name,var_name) \
1443 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
1444 if (lp_ctx->s3_fns) { \
1445 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1446 return lp_ctx->s3_fns->fn_name(); \
1448 return lp_ctx->globals->var_name; \
1451 /* Local parameters don't need the ->s3_fns because the struct
1452 * loadparm_service is shared and lpcfg_service() checks the ->s3_fns
1454 #define FN_LOCAL_STRING(fn_name,val) \
1455 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, \
1456 struct loadparm_service *sDefault) { \
1457 return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val))); \
1460 #define FN_LOCAL_CONST_STRING(fn_name,val) FN_LOCAL_STRING(fn_name, val)
1462 #define FN_LOCAL_LIST(fn_name,val) \
1463 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, \
1464 struct loadparm_service *sDefault) {\
1465 return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val); \
1468 #define FN_LOCAL_PARM_BOOL(fn_name, val) FN_LOCAL_BOOL(fn_name, val)
1470 #define FN_LOCAL_BOOL(fn_name,val) \
1471 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, \
1472 struct loadparm_service *sDefault) { \
1473 return((service != NULL)? service->val : sDefault->val); \
1476 #define FN_LOCAL_INTEGER(fn_name,val) \
1477 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, \
1478 struct loadparm_service *sDefault) { \
1479 return((service != NULL)? service->val : sDefault->val); \
1482 #define FN_LOCAL_PARM_INTEGER(fn_name, val) FN_LOCAL_INTEGER(fn_name, val)
1484 #define FN_LOCAL_PARM_CHAR(fn_name, val) FN_LOCAL_CHAR(fn_name, val)
1486 #define FN_LOCAL_CHAR(fn_name,val) \
1487 _PUBLIC_ char lpcfg_ ## fn_name(struct loadparm_service *service, \
1488 struct loadparm_service *sDefault) { \
1489 return((service != NULL)? service->val : sDefault->val); \
1492 #include "lib/param/param_functions.c"
1494 FN_GLOBAL_LIST(smb_ports, smb_ports)
1495 FN_GLOBAL_INTEGER(nbt_port, nbt_port)
1496 FN_GLOBAL_INTEGER(dgram_port, dgram_port)
1497 FN_GLOBAL_INTEGER(cldap_port, cldap_port)
1498 FN_GLOBAL_INTEGER(krb5_port, krb5_port)
1499 FN_GLOBAL_INTEGER(kpasswd_port, kpasswd_port)
1500 FN_GLOBAL_INTEGER(web_port, web_port)
1501 FN_GLOBAL_BOOL(tls_enabled, tls_enabled)
1502 FN_GLOBAL_STRING(logfile, logfile)
1503 FN_GLOBAL_STRING(share_backend, szShareBackend)
1504 FN_GLOBAL_CONST_STRING(winbind_separator, szWinbindSeparator)
1505 FN_GLOBAL_CONST_STRING(winbindd_socket_directory, szWinbinddSocketDirectory)
1506 FN_GLOBAL_CONST_STRING(winbindd_privileged_socket_directory, szWinbinddPrivilegedSocketDirectory)
1507 FN_GLOBAL_CONST_STRING(template_shell, szTemplateShell)
1508 FN_GLOBAL_CONST_STRING(template_homedir, szTemplateHomedir)
1509 FN_GLOBAL_BOOL(winbind_sealed_pipes, bWinbindSealedPipes)
1510 FN_GLOBAL_BOOL(idmap_trusted_only, bIdmapTrustedOnly)
1511 FN_GLOBAL_STRING(private_dir, szPrivateDir)
1512 FN_GLOBAL_STRING(serverstring, szServerString)
1513 FN_GLOBAL_STRING(lockdir, szLockDir)
1514 FN_GLOBAL_STRING(statedir, szStateDir)
1515 FN_GLOBAL_STRING(cachedir, szCacheDir)
1516 FN_GLOBAL_STRING(ncalrpc_dir, ncalrpc_dir)
1517 FN_GLOBAL_STRING(dos_charset, dos_charset)
1518 FN_GLOBAL_STRING(unix_charset, unix_charset)
1519 FN_GLOBAL_STRING(piddir, szPidDir)
1520 FN_GLOBAL_LIST(rndc_command, szRNDCCommand)
1521 FN_GLOBAL_LIST(dns_update_command, szDNSUpdateCommand)
1522 FN_GLOBAL_LIST(spn_update_command, szSPNUpdateCommand)
1523 FN_GLOBAL_LIST(nsupdate_command, szNSUpdateCommand)
1524 FN_GLOBAL_LIST(dcerpc_endpoint_servers, dcerpc_ep_servers)
1525 FN_GLOBAL_LIST(server_services, server_services)
1526 FN_GLOBAL_STRING(ntptr_providor, ntptr_providor)
1527 FN_GLOBAL_STRING(passdb_backend, passdb_backend)
1528 FN_GLOBAL_STRING(auto_services, szAutoServices)
1529 FN_GLOBAL_STRING(passwd_chat, szPasswdChat)
1530 FN_GLOBAL_LIST(passwordserver, szPasswordServers)
1531 FN_GLOBAL_LIST(name_resolve_order, szNameResolveOrder)
1532 FN_GLOBAL_STRING(realm, szRealm_upper)
1533 FN_GLOBAL_STRING(dnsdomain, szRealm_lower)
1534 FN_GLOBAL_STRING(socket_options, socket_options)
1535 FN_GLOBAL_STRING(workgroup, szWorkgroup)
1536 FN_GLOBAL_STRING(netbios_name, szNetbiosName)
1537 FN_GLOBAL_STRING(netbios_scope, szNetbiosScope)
1538 FN_GLOBAL_LIST(wins_server_list, szWINSservers)
1539 FN_GLOBAL_LIST(interfaces, szInterfaces)
1540 FN_GLOBAL_STRING(socket_address, szSocketAddress)
1541 FN_GLOBAL_LIST(netbios_aliases, szNetbiosAliases)
1542 FN_GLOBAL_BOOL(disable_netbios, bDisableNetbios)
1543 FN_GLOBAL_BOOL(we_are_a_wins_server, bWINSsupport)
1544 FN_GLOBAL_BOOL(wins_dns_proxy, bWINSdnsProxy)
1545 FN_GLOBAL_STRING(wins_hook, szWINSHook)
1546 FN_GLOBAL_BOOL(local_master, bLocalMaster)
1547 FN_GLOBAL_BOOL(readraw, bReadRaw)
1548 FN_GLOBAL_BOOL(large_readwrite, bLargeReadwrite)
1549 FN_GLOBAL_BOOL(writeraw, bWriteRaw)
1550 FN_GLOBAL_BOOL(null_passwords, bNullPasswords)
1551 FN_GLOBAL_BOOL(obey_pam_restrictions, bObeyPamRestrictions)
1552 FN_GLOBAL_BOOL(encrypted_passwords, bEncryptPasswords)
1553 FN_GLOBAL_BOOL(time_server, bTimeServer)
1554 FN_GLOBAL_BOOL(bind_interfaces_only, bBindInterfacesOnly)
1555 FN_GLOBAL_BOOL(unicode, bUnicode)
1556 FN_GLOBAL_BOOL(nt_status_support, bNTStatusSupport)
1557 FN_GLOBAL_BOOL(lanman_auth, bLanmanAuth)
1558 FN_GLOBAL_BOOL(ntlm_auth, bNTLMAuth)
1559 FN_GLOBAL_BOOL(client_plaintext_auth, bClientPlaintextAuth)
1560 FN_GLOBAL_BOOL(client_lanman_auth, bClientLanManAuth)
1561 FN_GLOBAL_BOOL(client_ntlmv2_auth, bClientNTLMv2Auth)
1562 FN_GLOBAL_BOOL(client_use_spnego_principal, client_use_spnego_principal)
1563 FN_GLOBAL_BOOL(host_msdfs, bHostMSDfs)
1564 FN_GLOBAL_BOOL(unix_extensions, bUnixExtensions)
1565 FN_GLOBAL_BOOL(use_spnego, bUseSpnego)
1566 FN_GLOBAL_BOOL(use_mmap, bUseMmap)
1567 FN_GLOBAL_BOOL(rpc_big_endian, bRpcBigEndian)
1568 FN_GLOBAL_INTEGER(max_wins_ttl, max_wins_ttl)
1569 FN_GLOBAL_INTEGER(min_wins_ttl, min_wins_ttl)
1570 FN_GLOBAL_INTEGER(maxmux, max_mux)
1571 FN_GLOBAL_INTEGER(max_xmit, max_xmit)
1572 FN_GLOBAL_INTEGER(passwordlevel, pwordlevel)
1573 FN_GLOBAL_INTEGER(srv_maxprotocol, srv_maxprotocol)
1574 FN_GLOBAL_INTEGER(srv_minprotocol, srv_minprotocol)
1575 FN_GLOBAL_INTEGER(cli_maxprotocol, cli_maxprotocol)
1576 FN_GLOBAL_INTEGER(cli_minprotocol, cli_minprotocol)
1577 FN_GLOBAL_BOOL(paranoid_server_security, paranoid_server_security)
1579 FN_GLOBAL_INTEGER(server_signing, server_signing)
1580 FN_GLOBAL_INTEGER(client_signing, client_signing)
1582 FN_GLOBAL_CONST_STRING(ntp_signd_socket_directory, szNTPSignDSocketDirectory)
1584 /* local prototypes */
1585 static int map_parameter(const char *pszParmName);
1586 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
1587 const char *pszServiceName);
1588 static void copy_service(struct loadparm_service *pserviceDest,
1589 struct loadparm_service *pserviceSource,
1590 struct bitmap *pcopymapDest);
1591 static bool lpcfg_service_ok(struct loadparm_service *service);
1592 static bool do_section(const char *pszSectionName, void *);
1593 static void init_copymap(struct loadparm_service *pservice);
1595 /* This is a helper function for parametrical options support. */
1596 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
1597 /* Actual parametrical functions are quite simple */
1598 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
1599 struct loadparm_service *service,
1600 const char *type, const char *option)
1602 char *vfskey_tmp = NULL;
1603 char *vfskey = NULL;
1604 struct parmlist_entry *data;
1609 if (lp_ctx->s3_fns) {
1610 return lp_ctx->s3_fns->get_parametric(service, type, option);
1613 data = (service == NULL ? lp_ctx->globals->param_opt : service->param_opt);
1615 vfskey_tmp = talloc_asprintf(NULL, "%s:%s", type, option);
1616 if (vfskey_tmp == NULL) return NULL;
1617 vfskey = strlower_talloc(NULL, vfskey_tmp);
1618 talloc_free(vfskey_tmp);
1621 if (strcmp(data->key, vfskey) == 0) {
1622 talloc_free(vfskey);
1628 if (service != NULL) {
1629 /* Try to fetch the same option but from globals */
1630 /* but only if we are not already working with globals */
1631 for (data = lp_ctx->globals->param_opt; data;
1632 data = data->next) {
1633 if (strcmp(data->key, vfskey) == 0) {
1634 talloc_free(vfskey);
1640 talloc_free(vfskey);
1647 * convenience routine to return int parameters.
1649 static int lp_int(const char *s)
1653 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
1657 return strtol(s, NULL, 0);
1661 * convenience routine to return unsigned long parameters.
1663 static int lp_ulong(const char *s)
1667 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
1671 return strtoul(s, NULL, 0);
1675 * convenience routine to return unsigned long parameters.
1677 static double lp_double(const char *s)
1681 DEBUG(0,("lp_double(%s): is called with NULL!\n",s));
1685 return strtod(s, NULL);
1689 * convenience routine to return boolean parameters.
1691 static bool lp_bool(const char *s)
1696 DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
1700 if (!set_boolean(s, &ret)) {
1701 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
1710 * Return parametric option from a given service. Type is a part of option before ':'
1711 * Parametric option has following syntax: 'Type: option = value'
1712 * Returned value is allocated in 'lp_talloc' context
1715 const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
1716 struct loadparm_service *service, const char *type,
1719 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1722 return lp_string(value);
1728 * Return parametric option from a given service. Type is a part of option before ':'
1729 * Parametric option has following syntax: 'Type: option = value'
1730 * Returned value is allocated in 'lp_talloc' context
1733 const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
1734 struct loadparm_context *lp_ctx,
1735 struct loadparm_service *service,
1737 const char *option, const char *separator)
1739 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1742 return (const char **)str_list_make(mem_ctx, value, separator);
1748 * Return parametric option from a given service. Type is a part of option before ':'
1749 * Parametric option has following syntax: 'Type: option = value'
1752 int lpcfg_parm_int(struct loadparm_context *lp_ctx,
1753 struct loadparm_service *service, const char *type,
1754 const char *option, int default_v)
1756 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1759 return lp_int(value);
1765 * Return parametric option from a given service. Type is a part of
1766 * option before ':'.
1767 * Parametric option has following syntax: 'Type: option = value'.
1770 int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
1771 struct loadparm_service *service, const char *type,
1772 const char *option, int default_v)
1776 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1778 if (value && conv_str_size_error(value, &bval)) {
1779 if (bval <= INT_MAX) {
1788 * Return parametric option from a given service.
1789 * Type is a part of option before ':'
1790 * Parametric option has following syntax: 'Type: option = value'
1792 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
1793 struct loadparm_service *service, const char *type,
1794 const char *option, unsigned long default_v)
1796 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1799 return lp_ulong(value);
1805 double lpcfg_parm_double(struct loadparm_context *lp_ctx,
1806 struct loadparm_service *service, const char *type,
1807 const char *option, double default_v)
1809 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1812 return lp_double(value);
1818 * Return parametric option from a given service. Type is a part of option before ':'
1819 * Parametric option has following syntax: 'Type: option = value'
1822 bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
1823 struct loadparm_service *service, const char *type,
1824 const char *option, bool default_v)
1826 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1829 return lp_bool(value);
1836 * Initialise a service to the defaults.
1839 static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx, struct loadparm_service *sDefault)
1841 struct loadparm_service *pservice =
1842 talloc_zero(mem_ctx, struct loadparm_service);
1843 copy_service(pservice, sDefault, NULL);
1848 * Set a string value, deallocating any existing space, and allocing the space
1851 static bool lpcfg_string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
1858 *dest = talloc_strdup(mem_ctx, src);
1859 if ((*dest) == NULL) {
1860 DEBUG(0,("Out of memory in string_set\n"));
1868 * Set a string value, deallocating any existing space, and allocing the space
1871 static bool lpcfg_string_set_upper(TALLOC_CTX *mem_ctx, char **dest, const char *src)
1878 *dest = strupper_talloc(mem_ctx, src);
1879 if ((*dest) == NULL) {
1880 DEBUG(0,("Out of memory in string_set_upper\n"));
1890 * Add a new service to the services array initialising it with the given
1894 struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
1895 const struct loadparm_service *pservice,
1899 struct loadparm_service tservice;
1900 int num_to_alloc = lp_ctx->iNumServices + 1;
1901 struct parmlist_entry *data, *pdata;
1903 if (pservice == NULL) {
1904 pservice = lp_ctx->sDefault;
1907 tservice = *pservice;
1909 /* it might already exist */
1911 struct loadparm_service *service = getservicebyname(lp_ctx,
1913 if (service != NULL) {
1914 /* Clean all parametric options for service */
1915 /* They will be added during parsing again */
1916 data = service->param_opt;
1922 service->param_opt = NULL;
1927 /* find an invalid one */
1928 for (i = 0; i < lp_ctx->iNumServices; i++)
1929 if (lp_ctx->services[i] == NULL)
1932 /* if not, then create one */
1933 if (i == lp_ctx->iNumServices) {
1934 struct loadparm_service **tsp;
1936 tsp = talloc_realloc(lp_ctx, lp_ctx->services, struct loadparm_service *, num_to_alloc);
1939 DEBUG(0,("lpcfg_add_service: failed to enlarge services!\n"));
1942 lp_ctx->services = tsp;
1943 lp_ctx->services[lp_ctx->iNumServices] = NULL;
1946 lp_ctx->iNumServices++;
1949 lp_ctx->services[i] = init_service(lp_ctx->services, lp_ctx->sDefault);
1950 if (lp_ctx->services[i] == NULL) {
1951 DEBUG(0,("lpcfg_add_service: out of memory!\n"));
1954 copy_service(lp_ctx->services[i], &tservice, NULL);
1956 lpcfg_string_set(lp_ctx->services[i], &lp_ctx->services[i]->szService, name);
1957 return lp_ctx->services[i];
1961 * Add a new home service, with the specified home directory, defaults coming
1962 * from service ifrom.
1965 bool lpcfg_add_home(struct loadparm_context *lp_ctx,
1966 const char *pszHomename,
1967 struct loadparm_service *default_service,
1968 const char *user, const char *pszHomedir)
1970 struct loadparm_service *service;
1972 service = lpcfg_add_service(lp_ctx, default_service, pszHomename);
1974 if (service == NULL)
1977 if (!(*(default_service->szPath))
1978 || strequal(default_service->szPath, lp_ctx->sDefault->szPath)) {
1979 service->szPath = talloc_strdup(service, pszHomedir);
1981 service->szPath = string_sub_talloc(service, lpcfg_pathname(default_service, lp_ctx->sDefault), "%H", pszHomedir);
1984 if (!(*(service->comment))) {
1985 service->comment = talloc_asprintf(service, "Home directory of %s", user);
1987 service->bAvailable = default_service->bAvailable;
1988 service->bBrowseable = default_service->bBrowseable;
1990 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
1991 pszHomename, user, service->szPath));
1997 * Add a new printer service, with defaults coming from service iFrom.
2000 bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
2001 const char *pszPrintername,
2002 struct loadparm_service *default_service)
2004 const char *comment = "From Printcap";
2005 struct loadparm_service *service;
2006 service = lpcfg_add_service(lp_ctx, default_service, pszPrintername);
2008 if (service == NULL)
2011 /* note that we do NOT default the availability flag to True - */
2012 /* we take it from the default service passed. This allows all */
2013 /* dynamic printers to be disabled by disabling the [printers] */
2014 /* entry (if/when the 'available' keyword is implemented!). */
2016 /* the printer name is set to the service name. */
2017 lpcfg_string_set(service, &service->szPrintername, pszPrintername);
2018 lpcfg_string_set(service, &service->comment, comment);
2019 service->bBrowseable = default_service->bBrowseable;
2020 /* Printers cannot be read_only. */
2021 service->bRead_only = false;
2022 /* Printer services must be printable. */
2023 service->bPrint_ok = true;
2025 DEBUG(3, ("adding printer service %s\n", pszPrintername));
2031 * Map a parameter's string representation to something we can use.
2032 * Returns False if the parameter string is not recognised, else TRUE.
2035 static int map_parameter(const char *pszParmName)
2039 if (*pszParmName == '-')
2042 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
2043 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
2046 /* Warn only if it isn't parametric option */
2047 if (strchr(pszParmName, ':') == NULL)
2048 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
2049 /* We do return 'fail' for parametric options as well because they are
2050 stored in different storage
2057 return the parameter structure for a parameter
2059 struct parm_struct *lpcfg_parm_struct(struct loadparm_context *lp_ctx, const char *name)
2063 if (lp_ctx->s3_fns) {
2064 return lp_ctx->s3_fns->get_parm_struct(name);
2067 parmnum = map_parameter(name);
2068 if (parmnum == -1) return NULL;
2069 return &parm_table[parmnum];
2073 return the parameter pointer for a parameter
2075 void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
2076 struct loadparm_service *service, struct parm_struct *parm)
2078 if (lp_ctx->s3_fns) {
2079 return lp_ctx->s3_fns->get_parm_ptr(service, parm);
2082 if (service == NULL) {
2083 if (parm->p_class == P_LOCAL)
2084 return ((char *)lp_ctx->sDefault)+parm->offset;
2085 else if (parm->p_class == P_GLOBAL)
2086 return ((char *)lp_ctx->globals)+parm->offset;
2089 return ((char *)service) + parm->offset;
2094 return the parameter pointer for a parameter
2096 bool lpcfg_parm_is_cmdline(struct loadparm_context *lp_ctx, const char *name)
2100 if (lp_ctx->s3_fns) {
2101 struct parm_struct *parm = lp_ctx->s3_fns->get_parm_struct(name);
2103 return parm->flags & FLAG_CMDLINE;
2108 parmnum = map_parameter(name);
2109 if (parmnum == -1) return false;
2111 return lp_ctx->flags[parmnum] & FLAG_CMDLINE;
2115 * Find a service by name. Otherwise works like get_service.
2118 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
2119 const char *pszServiceName)
2123 if (lp_ctx->s3_fns) {
2124 return lp_ctx->s3_fns->get_service(pszServiceName);
2127 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--)
2128 if (lp_ctx->services[iService] != NULL &&
2129 strwicmp(lp_ctx->services[iService]->szService, pszServiceName) == 0) {
2130 return lp_ctx->services[iService];
2137 * Copy a service structure to another.
2138 * If pcopymapDest is NULL then copy all fields
2141 static void copy_service(struct loadparm_service *pserviceDest,
2142 struct loadparm_service *pserviceSource,
2143 struct bitmap *pcopymapDest)
2146 bool bcopyall = (pcopymapDest == NULL);
2147 struct parmlist_entry *data, *pdata, *paramo;
2150 for (i = 0; parm_table[i].label; i++)
2151 if (parm_table[i].p_class == P_LOCAL &&
2152 (bcopyall || bitmap_query(pcopymapDest, i))) {
2154 ((char *)pserviceSource) + parm_table[i].offset;
2156 ((char *)pserviceDest) + parm_table[i].offset;
2158 switch (parm_table[i].type) {
2160 *(bool *)dest_ptr = *(bool *)src_ptr;
2166 *(int *)dest_ptr = *(int *)src_ptr;
2170 lpcfg_string_set(pserviceDest,
2176 lpcfg_string_set_upper(pserviceDest,
2181 *(const char ***)dest_ptr = (const char **)str_list_copy(pserviceDest,
2182 *(const char ***)src_ptr);
2190 init_copymap(pserviceDest);
2191 if (pserviceSource->copymap)
2192 bitmap_copy(pserviceDest->copymap,
2193 pserviceSource->copymap);
2196 data = pserviceSource->param_opt;
2199 pdata = pserviceDest->param_opt;
2200 /* Traverse destination */
2202 /* If we already have same option, override it */
2203 if (strcmp(pdata->key, data->key) == 0) {
2204 talloc_free(pdata->value);
2205 pdata->value = talloc_reference(pdata,
2210 pdata = pdata->next;
2213 paramo = talloc_zero(pserviceDest, struct parmlist_entry);
2216 paramo->key = talloc_reference(paramo, data->key);
2217 paramo->value = talloc_reference(paramo, data->value);
2218 DLIST_ADD(pserviceDest->param_opt, paramo);
2225 * Check a service for consistency. Return False if the service is in any way
2226 * incomplete or faulty, else True.
2228 static bool lpcfg_service_ok(struct loadparm_service *service)
2233 if (service->szService[0] == '\0') {
2234 DEBUG(0, ("The following message indicates an internal error:\n"));
2235 DEBUG(0, ("No service name in service entry.\n"));
2239 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
2240 /* I can't see why you'd want a non-printable printer service... */
2241 if (strwicmp(service->szService, PRINTERS_NAME) == 0) {
2242 if (!service->bPrint_ok) {
2243 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
2244 service->szService));
2245 service->bPrint_ok = true;
2247 /* [printers] service must also be non-browsable. */
2248 if (service->bBrowseable)
2249 service->bBrowseable = false;
2252 /* If a service is flagged unavailable, log the fact at level 0. */
2253 if (!service->bAvailable)
2254 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
2255 service->szService));
2261 /*******************************************************************
2262 Keep a linked list of all config files so we know when one has changed
2263 it's date and needs to be reloaded.
2264 ********************************************************************/
2266 static void add_to_file_list(struct loadparm_context *lp_ctx,
2267 const char *fname, const char *subfname)
2269 struct file_lists *f = lp_ctx->file_lists;
2272 if (f->name && !strcmp(f->name, fname))
2278 f = talloc(lp_ctx, struct file_lists);
2281 f->next = lp_ctx->file_lists;
2282 f->name = talloc_strdup(f, fname);
2287 f->subfname = talloc_strdup(f, subfname);
2292 lp_ctx->file_lists = f;
2293 f->modtime = file_modtime(subfname);
2295 time_t t = file_modtime(subfname);
2301 /*******************************************************************
2302 Check if a config file has changed date.
2303 ********************************************************************/
2304 bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx)
2306 struct file_lists *f;
2307 DEBUG(6, ("lp_file_list_changed()\n"));
2309 for (f = lp_ctx->file_lists; f != NULL; f = f->next) {
2313 n2 = standard_sub_basic(lp_ctx, f->name);
2315 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
2316 f->name, n2, ctime(&f->modtime)));
2318 mod_time = file_modtime(n2);
2320 if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
2321 DEBUGADD(6, ("file %s modified: %s\n", n2,
2323 f->modtime = mod_time;
2324 talloc_free(f->subfname);
2325 f->subfname = talloc_strdup(f, n2);
2332 /***************************************************************************
2333 Handle the "realm" parameter
2334 ***************************************************************************/
2336 static bool handle_realm(struct loadparm_context *lp_ctx, int unused,
2337 const char *pszParmValue, char **ptr)
2339 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
2341 talloc_free(lp_ctx->globals->szRealm_upper);
2342 talloc_free(lp_ctx->globals->szRealm_lower);
2344 lp_ctx->globals->szRealm_upper = strupper_talloc(lp_ctx, pszParmValue);
2345 lp_ctx->globals->szRealm_lower = strlower_talloc(lp_ctx, pszParmValue);
2350 /***************************************************************************
2351 Handle the include operation.
2352 ***************************************************************************/
2354 static bool handle_include(struct loadparm_context *lp_ctx, int unused,
2355 const char *pszParmValue, char **ptr)
2357 char *fname = standard_sub_basic(lp_ctx, pszParmValue);
2359 add_to_file_list(lp_ctx, pszParmValue, fname);
2361 lpcfg_string_set(lp_ctx, ptr, fname);
2363 if (file_exist(fname))
2364 return pm_process(fname, do_section, do_parameter, lp_ctx);
2366 DEBUG(2, ("Can't find include file %s\n", fname));
2371 /***************************************************************************
2372 Handle the interpretation of the copy parameter.
2373 ***************************************************************************/
2375 static bool handle_copy(struct loadparm_context *lp_ctx, int unused,
2376 const char *pszParmValue, char **ptr)
2379 struct loadparm_service *serviceTemp;
2381 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
2385 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
2387 if ((serviceTemp = getservicebyname(lp_ctx, pszParmValue)) != NULL) {
2388 if (serviceTemp == lp_ctx->currentService) {
2389 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
2391 copy_service(lp_ctx->currentService,
2393 lp_ctx->currentService->copymap);
2397 DEBUG(0, ("Unable to copy service - source not found: %s\n",
2405 static bool handle_debuglevel(struct loadparm_context *lp_ctx, int unused,
2406 const char *pszParmValue, char **ptr)
2409 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
2410 if (lp_ctx->global) {
2411 return debug_parse_levels(pszParmValue);
2416 static bool handle_logfile(struct loadparm_context *lp_ctx, int unused,
2417 const char *pszParmValue, char **ptr)
2419 debug_set_logfile(pszParmValue);
2420 if (lp_ctx->global) {
2421 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
2426 /***************************************************************************
2427 Initialise a copymap.
2428 ***************************************************************************/
2430 static void init_copymap(struct loadparm_service *pservice)
2434 TALLOC_FREE(pservice->copymap);
2436 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
2437 if (!pservice->copymap)
2439 ("Couldn't allocate copymap!! (size %d)\n",
2440 (int)NUMPARAMETERS));
2442 for (i = 0; i < NUMPARAMETERS; i++)
2443 bitmap_set(pservice->copymap, i);
2447 * Process a parametric option
2449 static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
2450 struct loadparm_service *service,
2451 const char *pszParmName,
2452 const char *pszParmValue, int flags)
2454 struct parmlist_entry *paramo, *data;
2456 TALLOC_CTX *mem_ctx;
2458 while (isspace((unsigned char)*pszParmName)) {
2462 name = strlower_talloc(lp_ctx, pszParmName);
2463 if (!name) return false;
2465 if (service == NULL) {
2466 data = lp_ctx->globals->param_opt;
2467 mem_ctx = lp_ctx->globals;
2469 data = service->param_opt;
2473 /* Traverse destination */
2474 for (paramo=data; paramo; paramo=paramo->next) {
2475 /* If we already have the option set, override it unless
2476 it was a command line option and the new one isn't */
2477 if (strcmp(paramo->key, name) == 0) {
2478 if ((paramo->priority & FLAG_CMDLINE) &&
2479 !(flags & FLAG_CMDLINE)) {
2484 talloc_free(paramo->value);
2485 paramo->value = talloc_strdup(paramo, pszParmValue);
2486 paramo->priority = flags;
2492 paramo = talloc_zero(mem_ctx, struct parmlist_entry);
2495 paramo->key = talloc_strdup(paramo, name);
2496 paramo->value = talloc_strdup(paramo, pszParmValue);
2497 paramo->priority = flags;
2498 if (service == NULL) {
2499 DLIST_ADD(lp_ctx->globals->param_opt, paramo);
2501 DLIST_ADD(service->param_opt, paramo);
2509 static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
2510 const char *pszParmName, const char *pszParmValue,
2511 struct loadparm_context *lp_ctx, bool on_globals)
2514 /* if it is a special case then go ahead */
2515 if (parm_table[parmnum].special) {
2517 ret = parm_table[parmnum].special(lp_ctx, -1, pszParmValue,
2522 goto mark_non_default;
2525 /* now switch on the type of variable it is */
2526 switch (parm_table[parmnum].type)
2530 if (!set_boolean(pszParmValue, &b)) {
2531 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
2534 *(bool *)parm_ptr = b;
2540 if (!set_boolean(pszParmValue, &b)) {
2541 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
2544 *(bool *)parm_ptr = !b;
2549 *(int *)parm_ptr = atoi(pszParmValue);
2553 *(char *)parm_ptr = *pszParmValue;
2557 *(int *)parm_ptr = strtol(pszParmValue, NULL, 8);
2563 if (conv_str_size_error(pszParmValue, &val)) {
2564 if (val <= INT_MAX) {
2565 *(int *)parm_ptr = (int)val;
2570 DEBUG(0,("lp_do_parameter(%s): value is not "
2571 "a valid size specifier!\n", pszParmValue));
2576 *(const char ***)parm_ptr = (const char **)str_list_make(mem_ctx,
2577 pszParmValue, NULL);
2581 char **new_list = str_list_make(mem_ctx,
2582 pszParmValue, NULL);
2583 for (i=0; new_list[i]; i++) {
2584 if (new_list[i][0] == '+' && new_list[i][1] &&
2585 (!str_list_check(*(const char ***)parm_ptr,
2586 &new_list[i][1]))) {
2587 *(const char ***)parm_ptr = str_list_add(*(const char ***)parm_ptr,
2589 } else if (new_list[i][0] == '-' && new_list[i][1]) {
2590 #if 0 /* This is commented out because we sometimes parse the list
2591 * twice, and so we can't assert on this */
2592 if (!str_list_check(*(const char ***)parm_ptr,
2594 DEBUG(0, ("Unsupported value for: %s = %s, %s is not in the original list [%s]\n",
2595 pszParmName, pszParmValue, new_list[i],
2596 str_list_join_shell(mem_ctx, *(const char ***)parm_ptr, ' ')));
2601 str_list_remove(*(const char ***)parm_ptr,
2605 DEBUG(0, ("Unsupported list syntax for: %s = %s\n",
2606 pszParmName, pszParmValue));
2609 *(const char ***)parm_ptr = (const char **) new_list;
2616 lpcfg_string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
2620 lpcfg_string_set_upper(mem_ctx, (char **)parm_ptr, pszParmValue);
2624 for (i = 0; parm_table[parmnum].enum_list[i].name; i++) {
2627 parm_table[parmnum].enum_list[i].name)) {
2629 parm_table[parmnum].
2634 if (!parm_table[parmnum].enum_list[i].name) {
2635 DEBUG(0,("Unknown enumerated value '%s' for '%s'\n",
2636 pszParmValue, pszParmName));
2643 if (on_globals && (lp_ctx->flags[parmnum] & FLAG_DEFAULT)) {
2644 lp_ctx->flags[parmnum] &= ~FLAG_DEFAULT;
2645 /* we have to also unset FLAG_DEFAULT on aliases */
2646 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
2647 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
2649 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
2650 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
2657 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
2658 const char *pszParmName, const char *pszParmValue)
2660 int parmnum = map_parameter(pszParmName);
2664 if (strchr(pszParmName, ':')) {
2665 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName, pszParmValue, 0);
2667 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
2671 /* if the flag has been set on the command line, then don't allow override,
2672 but don't report an error */
2673 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
2677 parm_ptr = lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[parmnum]);
2679 return set_variable(lp_ctx->globals, parmnum, parm_ptr,
2680 pszParmName, pszParmValue, lp_ctx, true);
2683 bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
2684 struct loadparm_service *service,
2685 const char *pszParmName, const char *pszParmValue)
2689 int parmnum = map_parameter(pszParmName);
2692 if (strchr(pszParmName, ':')) {
2693 return lp_do_parameter_parametric(lp_ctx, service, pszParmName, pszParmValue, 0);
2695 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
2699 /* if the flag has been set on the command line, then don't allow override,
2700 but don't report an error */
2701 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
2705 if (parm_table[parmnum].p_class == P_GLOBAL) {
2707 ("Global parameter %s found in service section!\n",
2711 parm_ptr = ((char *)service) + parm_table[parmnum].offset;
2713 if (!service->copymap)
2714 init_copymap(service);
2716 /* this handles the aliases - set the copymap for other
2717 * entries with the same data pointer */
2718 for (i = 0; parm_table[i].label; i++)
2719 if (parm_table[i].offset == parm_table[parmnum].offset &&
2720 parm_table[i].p_class == parm_table[parmnum].p_class)
2721 bitmap_clear(service->copymap, i);
2723 return set_variable(service, parmnum, parm_ptr, pszParmName,
2724 pszParmValue, lp_ctx, false);
2728 * Process a parameter.
2731 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
2734 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
2736 if (lp_ctx->bInGlobalSection)
2737 return lpcfg_do_global_parameter(lp_ctx, pszParmName,
2740 return lpcfg_do_service_parameter(lp_ctx, lp_ctx->currentService,
2741 pszParmName, pszParmValue);
2745 variable argument do parameter
2747 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx, const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
2748 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
2749 const char *pszParmName, const char *fmt, ...)
2756 s = talloc_vasprintf(NULL, fmt, ap);
2758 ret = lpcfg_do_global_parameter(lp_ctx, pszParmName, s);
2765 set a parameter from the commandline - this is called from command line parameter
2766 parsing code. It sets the parameter then marks the parameter as unable to be modified
2767 by smb.conf processing
2769 bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
2770 const char *pszParmValue)
2775 if (lp_ctx->s3_fns) {
2776 return lp_ctx->s3_fns->set_cmdline(pszParmName, pszParmValue);
2779 parmnum = map_parameter(pszParmName);
2781 while (isspace((unsigned char)*pszParmValue)) pszParmValue++;
2784 if (parmnum < 0 && strchr(pszParmName, ':')) {
2785 /* set a parametric option */
2786 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
2787 pszParmValue, FLAG_CMDLINE);
2791 DEBUG(0,("Unknown option '%s'\n", pszParmName));
2795 /* reset the CMDLINE flag in case this has been called before */
2796 lp_ctx->flags[parmnum] &= ~FLAG_CMDLINE;
2798 if (!lpcfg_do_global_parameter(lp_ctx, pszParmName, pszParmValue)) {
2802 lp_ctx->flags[parmnum] |= FLAG_CMDLINE;
2804 /* we have to also set FLAG_CMDLINE on aliases */
2805 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
2806 lp_ctx->flags[i] |= FLAG_CMDLINE;
2808 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
2809 lp_ctx->flags[i] |= FLAG_CMDLINE;
2816 set a option from the commandline in 'a=b' format. Use to support --option
2818 bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option)
2823 s = talloc_strdup(NULL, option);
2836 ret = lpcfg_set_cmdline(lp_ctx, s, p+1);
2842 #define BOOLSTR(b) ((b) ? "Yes" : "No")
2845 * Print a parameter of the specified type.
2848 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
2850 /* For the seperation of lists values that we print below */
2851 const char *list_sep = ", ";
2856 for (i = 0; p->enum_list[i].name; i++) {
2857 if (*(int *)ptr == p->enum_list[i].value) {
2859 p->enum_list[i].name);
2866 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
2870 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
2875 fprintf(f, "%d", *(int *)ptr);
2879 fprintf(f, "%c", *(char *)ptr);
2883 int val = *(int *)ptr;
2887 fprintf(f, "0%o", val);
2896 if ((char ***)ptr && *(char ***)ptr) {
2897 char **list = *(char ***)ptr;
2898 for (; *list; list++) {
2899 /* surround strings with whitespace in double quotes */
2900 if (*(list+1) == NULL) {
2901 /* last item, no extra separator */
2904 if ( strchr_m( *list, ' ' ) ) {
2905 fprintf(f, "\"%s\"%s", *list, list_sep);
2907 fprintf(f, "%s%s", *list, list_sep);
2915 if (*(char **)ptr) {
2916 fprintf(f, "%s", *(char **)ptr);
2925 * Check if two parameters are equal.
2928 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
2933 return (*((bool *)ptr1) == *((bool *)ptr2));
2939 return (*((int *)ptr1) == *((int *)ptr2));
2942 return (*((char *)ptr1) == *((char *)ptr2));
2946 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
2951 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
2956 return (p1 == p2 || strequal(p1, p2));
2965 * Process a new section (service).
2967 * At this stage all sections are services.
2968 * Later we'll have special sections that permit server parameters to be set.
2969 * Returns True on success, False on failure.
2972 static bool do_section(const char *pszSectionName, void *userdata)
2974 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
2976 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
2977 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
2980 /* if we've just struck a global section, note the fact. */
2981 lp_ctx->bInGlobalSection = isglobal;
2983 /* check for multiple global sections */
2984 if (lp_ctx->bInGlobalSection) {
2985 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
2989 /* if we have a current service, tidy it up before moving on */
2992 if (lp_ctx->currentService != NULL)
2993 bRetval = lpcfg_service_ok(lp_ctx->currentService);
2995 /* if all is still well, move to the next record in the services array */
2997 /* We put this here to avoid an odd message order if messages are */
2998 /* issued by the post-processing of a previous section. */
2999 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
3001 if ((lp_ctx->currentService = lpcfg_add_service(lp_ctx, lp_ctx->sDefault,
3004 DEBUG(0, ("Failed to add a new service\n"));
3014 * Determine if a particular base parameter is currently set to the default value.
3017 static bool is_default(struct loadparm_service *sDefault, int i)
3019 void *def_ptr = ((char *)sDefault) + parm_table[i].offset;
3020 if (!defaults_saved)
3022 switch (parm_table[i].type) {
3025 return str_list_equal((const char **)parm_table[i].def.lvalue,
3026 (const char **)def_ptr);
3029 return strequal(parm_table[i].def.svalue,
3033 return parm_table[i].def.bvalue ==
3040 return parm_table[i].def.ivalue ==
3047 *Display the contents of the global structure.
3050 static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
3054 struct parmlist_entry *data;
3056 fprintf(f, "# Global parameters\n[global]\n");
3058 for (i = 0; parm_table[i].label; i++)
3059 if (parm_table[i].p_class == P_GLOBAL &&
3060 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
3061 if (!show_defaults && (lp_ctx->flags[i] & FLAG_DEFAULT))
3063 fprintf(f, "\t%s = ", parm_table[i].label);
3064 print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f);
3067 if (lp_ctx->globals->param_opt != NULL) {
3068 for (data = lp_ctx->globals->param_opt; data;
3069 data = data->next) {
3070 if (!show_defaults && (data->priority & FLAG_DEFAULT)) {
3073 fprintf(f, "\t%s = %s\n", data->key, data->value);
3080 * Display the contents of a single services record.
3083 static void dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f,
3084 unsigned int *flags)
3087 struct parmlist_entry *data;
3089 if (pService != sDefault)
3090 fprintf(f, "\n[%s]\n", pService->szService);
3092 for (i = 0; parm_table[i].label; i++) {
3093 if (parm_table[i].p_class == P_LOCAL &&
3094 (*parm_table[i].label != '-') &&
3095 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
3097 if (pService == sDefault) {
3098 if (flags && (flags[i] & FLAG_DEFAULT)) {
3101 if (defaults_saved) {
3102 if (is_default(sDefault, i)) {
3107 if (equal_parameter(parm_table[i].type,
3108 ((char *)pService) +
3109 parm_table[i].offset,
3110 ((char *)sDefault) +
3111 parm_table[i].offset))
3115 fprintf(f, "\t%s = ", parm_table[i].label);
3116 print_parameter(&parm_table[i],
3117 ((char *)pService) + parm_table[i].offset, f);
3121 if (pService->param_opt != NULL) {
3122 for (data = pService->param_opt; data; data = data->next) {
3123 fprintf(f, "\t%s = %s\n", data->key, data->value);
3128 bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
3129 struct loadparm_service *service,
3130 const char *parm_name, FILE * f)
3132 struct parm_struct *parm;
3135 parm = lpcfg_parm_struct(lp_ctx, parm_name);
3140 ptr = lpcfg_parm_ptr(lp_ctx, service,parm);
3142 print_parameter(parm, ptr, f);
3148 * Return info about the next parameter in a service.
3149 * snum==-1 gives the globals.
3150 * Return NULL when out of parameters.
3154 struct parm_struct *lpcfg_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
3158 /* do the globals */
3159 for (; parm_table[*i].label; (*i)++) {
3160 if ((*parm_table[*i].label == '-'))
3164 && (parm_table[*i].offset ==
3165 parm_table[(*i) - 1].offset)
3166 && (parm_table[*i].p_class ==
3167 parm_table[(*i) - 1].p_class))
3170 return &parm_table[(*i)++];
3173 struct loadparm_service *pService = lp_ctx->services[snum];
3175 for (; parm_table[*i].label; (*i)++) {
3176 if (parm_table[*i].p_class == P_LOCAL &&
3177 (*parm_table[*i].label != '-') &&
3179 (parm_table[*i].offset !=
3180 parm_table[(*i) - 1].offset)))
3182 if (allparameters ||
3183 !equal_parameter(parm_table[*i].type,
3184 ((char *)pService) +
3185 parm_table[*i].offset,
3186 ((char *)lp_ctx->sDefault) +
3187 parm_table[*i].offset))
3189 return &parm_table[(*i)++];
3200 * Auto-load some home services.
3202 static void lpcfg_add_auto_services(struct loadparm_context *lp_ctx,
3210 * Unload unused services.
3213 void lpcfg_killunused(struct loadparm_context *lp_ctx,
3214 struct smbsrv_connection *smb,
3215 bool (*snumused) (struct smbsrv_connection *, int))
3218 for (i = 0; i < lp_ctx->iNumServices; i++) {
3219 if (lp_ctx->services[i] == NULL)
3222 if (!snumused || !snumused(smb, i)) {
3223 talloc_free(lp_ctx->services[i]);
3224 lp_ctx->services[i] = NULL;
3230 static int lpcfg_destructor(struct loadparm_context *lp_ctx)
3232 struct parmlist_entry *data;
3234 if (lp_ctx->refuse_free) {
3235 /* someone is trying to free the
3236 global_loadparm_context.
3237 We can't allow that. */
3241 if (lp_ctx->globals->param_opt != NULL) {
3242 struct parmlist_entry *next;
3243 for (data = lp_ctx->globals->param_opt; data; data=next) {
3245 if (data->priority & FLAG_CMDLINE) continue;
3246 DLIST_REMOVE(lp_ctx->globals->param_opt, data);
3255 * Initialise the global parameter structure.
3257 * Note that most callers should use loadparm_init_global() instead
3259 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
3263 struct loadparm_context *lp_ctx;
3264 struct parmlist_entry *parm;
3267 lp_ctx = talloc_zero(mem_ctx, struct loadparm_context);
3271 talloc_set_destructor(lp_ctx, lpcfg_destructor);
3272 lp_ctx->bInGlobalSection = true;
3273 lp_ctx->globals = talloc_zero(lp_ctx, struct loadparm_global);
3274 lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service);
3276 lp_ctx->sDefault->iMaxPrintJobs = 1000;
3277 lp_ctx->sDefault->bAvailable = true;
3278 lp_ctx->sDefault->bBrowseable = true;
3279 lp_ctx->sDefault->bRead_only = true;
3280 lp_ctx->sDefault->bMap_archive = true;
3281 lp_ctx->sDefault->iStrictLocking = true;
3282 lp_ctx->sDefault->bOpLocks = true;
3283 lp_ctx->sDefault->iCreate_mask = 0744;
3284 lp_ctx->sDefault->iCreate_force_mode = 0000;
3285 lp_ctx->sDefault->iDir_mask = 0755;
3286 lp_ctx->sDefault->iDir_force_mode = 0000;
3288 DEBUG(3, ("Initialising global parameters\n"));
3290 for (i = 0; parm_table[i].label; i++) {
3291 if ((parm_table[i].type == P_STRING ||
3292 parm_table[i].type == P_USTRING) &&
3293 !(lp_ctx->flags[i] & FLAG_CMDLINE)) {
3295 if (parm_table[i].p_class == P_LOCAL) {
3296 r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset);
3298 r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset);
3300 *r = talloc_strdup(lp_ctx, "");
3304 logfile = talloc_asprintf(lp_ctx, "%s/log.samba", dyn_LOGFILEBASE);
3305 lpcfg_do_global_parameter(lp_ctx, "log file", logfile);
3306 talloc_free(logfile);
3308 lpcfg_do_global_parameter(lp_ctx, "log level", "0");
3310 lpcfg_do_global_parameter(lp_ctx, "share backend", "classic");
3312 lpcfg_do_global_parameter(lp_ctx, "server role", "auto");
3313 lpcfg_do_global_parameter(lp_ctx, "domain logons", "No");
3314 lpcfg_do_global_parameter(lp_ctx, "domain master", "Auto");
3316 /* options that can be set on the command line must be initialised via
3317 the slower lpcfg_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
3319 lpcfg_do_global_parameter(lp_ctx, "socket options", "TCP_NODELAY");
3321 lpcfg_do_global_parameter(lp_ctx, "workgroup", DEFAULT_WORKGROUP);
3322 myname = get_myname(lp_ctx);
3323 lpcfg_do_global_parameter(lp_ctx, "netbios name", myname);
3324 talloc_free(myname);
3325 lpcfg_do_global_parameter(lp_ctx, "name resolve order", "wins host bcast");
3327 lpcfg_do_global_parameter(lp_ctx, "fstype", "NTFS");
3329 lpcfg_do_global_parameter(lp_ctx, "ntvfs handler", "unixuid default");
3330 lpcfg_do_global_parameter(lp_ctx, "max connections", "-1");
3332 lpcfg_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup unixinfo browser eventlog6 backupkey dnsserver");
3333 lpcfg_do_global_parameter(lp_ctx, "server services", "smb rpc nbt wrepl ldap cldap kdc drepl winbind ntp_signd kcc dnsupdate");
3334 lpcfg_do_global_parameter(lp_ctx, "ntptr providor", "simple_ldb");
3335 /* the winbind method for domain controllers is for both RODC
3336 auth forwarding and for trusted domains */
3337 lpcfg_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR);
3338 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
3340 /* This hive should be dynamically generated by Samba using
3341 data from the sam, but for the moment leave it in a tdb to
3342 keep regedt32 from popping up an annoying dialog. */
3343 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_USERS", "hku.ldb");
3345 /* using UTF8 by default allows us to support all chars */
3346 lpcfg_do_global_parameter(lp_ctx, "unix charset", "UTF8");
3348 /* Use codepage 850 as a default for the dos character set */
3349 lpcfg_do_global_parameter(lp_ctx, "dos charset", "CP850");
3352 * Allow the default PASSWD_CHAT to be overridden in local.h.
3354 lpcfg_do_global_parameter(lp_ctx, "passwd chat", DEFAULT_PASSWD_CHAT);
3356 lpcfg_do_global_parameter(lp_ctx, "pid directory", dyn_PIDDIR);
3357 lpcfg_do_global_parameter(lp_ctx, "lock dir", dyn_LOCKDIR);
3358 lpcfg_do_global_parameter(lp_ctx, "state directory", dyn_STATEDIR);
3359 lpcfg_do_global_parameter(lp_ctx, "cache directory", dyn_CACHEDIR);
3360 lpcfg_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
3362 lpcfg_do_global_parameter(lp_ctx, "socket address", "");
3363 lpcfg_do_global_parameter_var(lp_ctx, "server string",
3364 "Samba %s", SAMBA_VERSION_STRING);
3366 lpcfg_do_global_parameter(lp_ctx, "password server", "*");
3368 lpcfg_do_global_parameter(lp_ctx, "max mux", "50");
3369 lpcfg_do_global_parameter(lp_ctx, "max xmit", "12288");
3370 lpcfg_do_global_parameter(lp_ctx, "password level", "0");
3371 lpcfg_do_global_parameter(lp_ctx, "LargeReadwrite", "True");
3372 lpcfg_do_global_parameter(lp_ctx, "server min protocol", "CORE");
3373 lpcfg_do_global_parameter(lp_ctx, "server max protocol", "NT1");
3374 lpcfg_do_global_parameter(lp_ctx, "client min protocol", "CORE");
3375 lpcfg_do_global_parameter(lp_ctx, "client max protocol", "NT1");
3376 lpcfg_do_global_parameter(lp_ctx, "security", "AUTO");
3377 lpcfg_do_global_parameter(lp_ctx, "paranoid server security", "True");
3378 lpcfg_do_global_parameter(lp_ctx, "EncryptPasswords", "True");
3379 lpcfg_do_global_parameter(lp_ctx, "ReadRaw", "True");
3380 lpcfg_do_global_parameter(lp_ctx, "WriteRaw", "True");
3381 lpcfg_do_global_parameter(lp_ctx, "NullPasswords", "False");
3382 lpcfg_do_global_parameter(lp_ctx, "ObeyPamRestrictions", "False");
3384 lpcfg_do_global_parameter(lp_ctx, "TimeServer", "False");
3385 lpcfg_do_global_parameter(lp_ctx, "BindInterfacesOnly", "False");
3386 lpcfg_do_global_parameter(lp_ctx, "Unicode", "True");
3387 lpcfg_do_global_parameter(lp_ctx, "ClientLanManAuth", "False");
3388 lpcfg_do_global_parameter(lp_ctx, "ClientNTLMv2Auth", "True");
3389 lpcfg_do_global_parameter(lp_ctx, "LanmanAuth", "False");
3390 lpcfg_do_global_parameter(lp_ctx, "NTLMAuth", "True");
3391 lpcfg_do_global_parameter(lp_ctx, "client use spnego principal", "False");
3393 lpcfg_do_global_parameter(lp_ctx, "UnixExtensions", "False");
3395 lpcfg_do_global_parameter(lp_ctx, "PreferredMaster", "Auto");
3396 lpcfg_do_global_parameter(lp_ctx, "LocalMaster", "True");
3398 lpcfg_do_global_parameter(lp_ctx, "wins support", "False");
3399 lpcfg_do_global_parameter(lp_ctx, "dns proxy", "True");
3401 lpcfg_do_global_parameter(lp_ctx, "winbind separator", "\\");
3402 lpcfg_do_global_parameter(lp_ctx, "winbind sealed pipes", "True");
3403 lpcfg_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
3404 #if _SAMBA_BUILD_ >= 4
3405 lpcfg_do_global_parameter(lp_ctx, "winbindd privileged socket directory", dyn_WINBINDD_PRIVILEGED_SOCKET_DIR);
3406 lpcfg_do_global_parameter(lp_ctx, "ntp signd socket directory", dyn_NTP_SIGND_SOCKET_DIR);
3407 lpcfg_do_global_parameter_var(lp_ctx, "dns update command", "%s/samba_dnsupdate", dyn_SCRIPTSBINDIR);
3408 lpcfg_do_global_parameter_var(lp_ctx, "spn update command", "%s/samba_spnupdate", dyn_SCRIPTSBINDIR);
3410 lpcfg_do_global_parameter(lp_ctx, "template shell", "/bin/false");
3411 lpcfg_do_global_parameter(lp_ctx, "template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%");
3412 lpcfg_do_global_parameter(lp_ctx, "idmap trusted only", "False");
3414 lpcfg_do_global_parameter(lp_ctx, "client signing", "default");
3415 lpcfg_do_global_parameter(lp_ctx, "server signing", "default");
3417 lpcfg_do_global_parameter(lp_ctx, "use spnego", "True");
3419 lpcfg_do_global_parameter(lp_ctx, "use mmap", "True");
3421 lpcfg_do_global_parameter(lp_ctx, "smb ports", "445 139");
3422 lpcfg_do_global_parameter(lp_ctx, "nbt port", "137");
3423 lpcfg_do_global_parameter(lp_ctx, "dgram port", "138");
3424 lpcfg_do_global_parameter(lp_ctx, "cldap port", "389");
3425 lpcfg_do_global_parameter(lp_ctx, "krb5 port", "88");
3426 lpcfg_do_global_parameter(lp_ctx, "kpasswd port", "464");
3427 lpcfg_do_global_parameter(lp_ctx, "web port", "901");
3429 lpcfg_do_global_parameter(lp_ctx, "nt status support", "True");
3431 lpcfg_do_global_parameter(lp_ctx, "max wins ttl", "518400"); /* 6 days */
3432 lpcfg_do_global_parameter(lp_ctx, "min wins ttl", "10");
3434 lpcfg_do_global_parameter(lp_ctx, "tls enabled", "True");
3435 lpcfg_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem");
3436 lpcfg_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
3437 lpcfg_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
3438 lpcfg_do_global_parameter(lp_ctx, "prefork children:smb", "4");
3440 lpcfg_do_global_parameter(lp_ctx, "rndc command", "/usr/sbin/rndc");
3441 lpcfg_do_global_parameter(lp_ctx, "nsupdate command", "/usr/bin/nsupdate -g");
3443 for (i = 0; parm_table[i].label; i++) {
3444 if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
3445 lp_ctx->flags[i] |= FLAG_DEFAULT;
3449 for (parm=lp_ctx->globals->param_opt; parm; parm=parm->next) {
3450 if (!(parm->priority & FLAG_CMDLINE)) {
3451 parm->priority |= FLAG_DEFAULT;
3459 * Initialise the global parameter structure.
3461 struct loadparm_context *loadparm_init_global(bool load_default)
3463 if (global_loadparm_context == NULL) {
3464 global_loadparm_context = loadparm_init(NULL);
3466 if (global_loadparm_context == NULL) {
3469 global_loadparm_context->global = true;
3470 if (load_default && !global_loadparm_context->loaded) {
3471 lpcfg_load_default(global_loadparm_context);
3473 global_loadparm_context->refuse_free = true;
3474 return global_loadparm_context;
3478 * Initialise the global parameter structure.
3480 struct loadparm_context *loadparm_init_s3(TALLOC_CTX *mem_ctx,
3481 const struct loadparm_s3_context *s3_fns)
3483 struct loadparm_context *loadparm_context = talloc_zero(mem_ctx, struct loadparm_context);
3484 if (!loadparm_context) {
3487 loadparm_context->s3_fns = s3_fns;
3488 return loadparm_context;
3491 const char *lpcfg_configfile(struct loadparm_context *lp_ctx)
3493 return lp_ctx->szConfigFile;
3496 const char *lp_default_path(void)
3498 if (getenv("SMB_CONF_PATH"))
3499 return getenv("SMB_CONF_PATH");
3501 return dyn_CONFIGFILE;
3505 * Update the internal state of a loadparm context after settings
3508 static bool lpcfg_update(struct loadparm_context *lp_ctx)
3510 struct debug_settings settings;
3511 lpcfg_add_auto_services(lp_ctx, lpcfg_auto_services(lp_ctx));
3513 if (!lp_ctx->globals->szWINSservers && lp_ctx->globals->bWINSsupport) {
3514 lpcfg_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
3517 if (!lp_ctx->global) {
3521 panic_action = lp_ctx->globals->panic_action;
3523 reload_charcnv(lp_ctx);
3525 ZERO_STRUCT(settings);
3526 /* Add any more debug-related smb.conf parameters created in
3528 settings.timestamp_logs = true;
3529 debug_set_settings(&settings);
3531 /* FIXME: This is a bit of a hack, but we can't use a global, since
3532 * not everything that uses lp also uses the socket library */
3533 if (lpcfg_parm_bool(lp_ctx, NULL, "socket", "testnonblock", false)) {
3534 setenv("SOCKET_TESTNONBLOCK", "1", 1);
3536 unsetenv("SOCKET_TESTNONBLOCK");
3542 bool lpcfg_load_default(struct loadparm_context *lp_ctx)
3546 path = lp_default_path();
3548 if (!file_exist(path)) {
3549 /* We allow the default smb.conf file to not exist,
3550 * basically the equivalent of an empty file. */
3551 return lpcfg_update(lp_ctx);
3554 return lpcfg_load(lp_ctx, path);
3558 * Load the services array from the services file.
3560 * Return True on success, False on failure.
3562 bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename)
3567 filename = talloc_strdup(lp_ctx, filename);
3569 lp_ctx->szConfigFile = filename;
3571 if (lp_ctx->s3_fns) {
3572 return lp_ctx->s3_fns->load(filename);
3575 lp_ctx->bInGlobalSection = true;
3576 n2 = standard_sub_basic(lp_ctx, lp_ctx->szConfigFile);
3577 DEBUG(2, ("lpcfg_load: refreshing parameters from %s\n", n2));
3579 add_to_file_list(lp_ctx, lp_ctx->szConfigFile, n2);
3581 /* We get sections first, so have to start 'behind' to make up */
3582 lp_ctx->currentService = NULL;
3583 bRetval = pm_process(n2, do_section, do_parameter, lp_ctx);
3585 /* finish up the last section */
3586 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
3588 if (lp_ctx->currentService != NULL)
3589 bRetval = lpcfg_service_ok(lp_ctx->currentService);
3591 bRetval = bRetval && lpcfg_update(lp_ctx);
3593 /* we do this unconditionally, so that it happens even
3594 for a missing smb.conf */
3595 reload_charcnv(lp_ctx);
3597 if (bRetval == true) {
3598 /* set this up so that any child python tasks will
3599 find the right smb.conf */
3600 setenv("SMB_CONF_PATH", filename, 1);
3602 /* set the context used by the lp_*() function
3604 global_loadparm_context = lp_ctx;
3605 lp_ctx->loaded = true;
3612 * Return the max number of services.
3615 int lpcfg_numservices(struct loadparm_context *lp_ctx)
3617 if (lp_ctx->s3_fns) {
3618 return lp_ctx->s3_fns->get_numservices();
3621 return lp_ctx->iNumServices;
3625 * Display the contents of the services array in human-readable form.
3628 void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
3633 if (lp_ctx->s3_fns) {
3634 lp_ctx->s3_fns->dump(f, show_defaults, maxtoprint);
3638 defaults_saved = !show_defaults;
3640 dump_globals(lp_ctx, f, show_defaults);
3642 dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f, lp_ctx->flags);
3644 for (iService = 0; iService < maxtoprint; iService++)
3645 lpcfg_dump_one(f, show_defaults, lp_ctx->services[iService], lp_ctx->sDefault);
3649 * Display the contents of one service in human-readable form.
3651 void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault)
3653 if (service != NULL) {
3654 if (service->szService[0] == '\0')
3656 dump_a_service(service, sDefault, f, NULL);
3660 struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
3663 if (lp_ctx->s3_fns) {
3664 return lp_ctx->s3_fns->get_servicebynum(snum);
3667 return lp_ctx->services[snum];
3670 struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
3671 const char *service_name)
3676 if (lp_ctx->s3_fns) {
3677 return lp_ctx->s3_fns->get_service(service_name);
3680 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
3681 if (lp_ctx->services[iService] &&
3682 lp_ctx->services[iService]->szService) {
3684 * The substitution here is used to support %U is
3687 serviceName = standard_sub_basic(
3688 lp_ctx->services[iService],
3689 lp_ctx->services[iService]->szService);
3690 if (strequal(serviceName, service_name)) {
3691 talloc_free(serviceName);
3692 return lp_ctx->services[iService];
3694 talloc_free(serviceName);
3698 DEBUG(7,("lpcfg_servicenumber: couldn't find %s\n", service_name));
3702 const char *lpcfg_servicename(const struct loadparm_service *service)
3704 return lp_string((const char *)service->szService);
3708 * A useful volume label function.
3710 const char *lpcfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault)
3713 ret = lp_string((const char *)((service != NULL && service->volume != NULL) ?
3714 service->volume : sDefault->volume));
3716 return lpcfg_servicename(service);
3721 * If we are PDC then prefer us as DMB
3723 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault)
3726 ret = lp_string((const char *)((service != NULL && service->szPrintername != NULL) ?
3727 service->szPrintername : sDefault->szPrintername));
3728 if (ret == NULL || (ret != NULL && *ret == '\0'))
3729 ret = lpcfg_servicename(service);
3736 * Return the max print jobs per queue.
3738 int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault)
3740 int maxjobs = (service != NULL) ? service->iMaxPrintJobs : sDefault->iMaxPrintJobs;
3741 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
3742 maxjobs = PRINT_MAX_JOBID - 1;
3747 struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx)
3749 if (lp_ctx == NULL) {
3750 return get_iconv_handle();
3752 return lp_ctx->iconv_handle;
3755 _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
3757 struct smb_iconv_handle *old_ic = lp_ctx->iconv_handle;
3758 if (!lp_ctx->global) {
3762 if (old_ic == NULL) {
3763 old_ic = global_iconv_handle;
3765 lp_ctx->iconv_handle = smb_iconv_handle_reinit_lp(lp_ctx, lp_ctx, old_ic);
3766 global_iconv_handle = lp_ctx->iconv_handle;
3769 _PUBLIC_ char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3771 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_keyfile);
3774 _PUBLIC_ char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3776 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_certfile);
3779 _PUBLIC_ char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3781 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_cafile);
3784 _PUBLIC_ char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3786 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_crlfile);
3789 _PUBLIC_ char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3791 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_dhpfile);
3794 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3796 struct gensec_settings *settings = talloc(mem_ctx, struct gensec_settings);
3797 if (settings == NULL)
3799 SMB_ASSERT(lp_ctx != NULL);
3800 settings->lp_ctx = talloc_reference(settings, lp_ctx);
3801 settings->target_hostname = lpcfg_parm_string(lp_ctx, NULL, "gensec", "target_hostname");
3805 int lpcfg_server_role(struct loadparm_context *lp_ctx)
3807 if (lp_ctx->s3_fns) {
3808 return lp_ctx->s3_fns->server_role();
3811 return lp_find_server_role(lp_ctx->globals->server_role,
3812 lp_ctx->globals->security,
3813 lp_ctx->globals->domain_logons,
3814 (lp_ctx->globals->domain_master == true) ||
3815 (lp_ctx->globals->domain_master == Auto));