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
14 Copyright (C) Andrew Bartlett 2011-2012
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 3 of the License, or
19 (at your option) any later version.
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program. If not, see <http://www.gnu.org/licenses/>.
33 * This module provides suitable callback functions for the params
34 * module. It builds the internal table of service details which is
35 * then used by the rest of the server.
39 * 1) add it to the global or service structure definition
40 * 2) add it to the parm_table
41 * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
42 * 4) If it's a global then initialise it in init_globals. If a local
43 * (ie. service) parameter then initialise it in the sDefault structure
47 * The configuration file is processed sequentially for speed. It is NOT
48 * accessed randomly as happens in 'real' Windows. For this reason, there
49 * is a fair bit of sequence-dependent code here - ie., code which assumes
50 * that certain things happen before others. In particular, the code which
51 * happens at the boundary between sections is delicately poised, so be
58 #include "dynconfig/dynconfig.h"
59 #include "system/time.h"
60 #include "system/locale.h"
61 #include "system/network.h" /* needed for TCP_NODELAY */
62 #include "../lib/util/dlinklist.h"
63 #include "lib/param/param.h"
64 #include "lib/param/loadparm.h"
65 #include "auth/gensec/gensec.h"
66 #include "lib/param/s3_param.h"
67 #include "lib/util/bitmap.h"
68 #include "libcli/smb/smb_constants.h"
69 #include "source4/dns_server/dns_update.h"
71 #define standard_sub_basic talloc_strdup
73 static bool do_parameter(const char *, const char *, void *);
74 static bool defaults_saved = false;
76 #define LOADPARM_EXTRA_GLOBALS \
77 struct parmlist_entry *param_opt; \
80 int iPreferredMaster; \
81 char *szLdapMachineSuffix; \
82 char *szLdapUserSuffix; \
83 char *szLdapIdmapSuffix; \
84 char *szLdapGroupSuffix; \
85 char *szUsershareTemplateShare; \
88 int winbindMaxDomainConnections; \
97 #include "lib/param/param_global.h"
99 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
101 /* we don't need a special handler for "dos charset" and "unix charset" */
102 #define handle_dos_charset NULL
103 #define handle_charset NULL
105 /* these are parameter handlers which are not needed in the
108 #define handle_netbios_aliases NULL
109 #define handle_debug_list NULL
110 #define handle_printing NULL
111 #define handle_ldap_debug_level NULL
112 #define handle_idmap_backend NULL
113 #define handle_idmap_uid NULL
114 #define handle_idmap_gid NULL
120 /* prototypes for the special type handlers */
121 static bool handle_include(struct loadparm_context *lp_ctx, int unused,
122 const char *pszParmValue, char **ptr);
123 static bool handle_realm(struct loadparm_context *lp_ctx, int unused,
124 const char *pszParmValue, char **ptr);
125 static bool handle_copy(struct loadparm_context *lp_ctx, int unused,
126 const char *pszParmValue, char **ptr);
127 static bool handle_debuglevel(struct loadparm_context *lp_ctx, int unused,
128 const char *pszParmValue, char **ptr);
129 static bool handle_logfile(struct loadparm_context *lp_ctx, int unused,
130 const char *pszParmValue, char **ptr);
132 #include "lib/param/param_table.c"
134 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
135 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
137 static struct parm_struct parm_table[] = {
139 .label = "server role",
142 .offset = GLOBAL_VAR(server_role),
144 .enum_list = enum_server_role
147 .label = "dos charset",
150 .offset = GLOBAL_VAR(dos_charset),
155 .label = "unix charset",
158 .offset = GLOBAL_VAR(unix_charset),
166 .offset = LOCAL_VAR(comment),
169 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
175 .offset = LOCAL_VAR(szPath),
178 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
181 .label = "directory",
184 .offset = LOCAL_VAR(szPath),
190 .label = "workgroup",
193 .offset = GLOBAL_VAR(szWorkgroup),
196 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
202 .offset = GLOBAL_VAR(szRealm),
203 .special = handle_realm,
205 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
208 .label = "netbios name",
211 .offset = GLOBAL_VAR(szNetbiosName),
214 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
217 .label = "netbios aliases",
220 .offset = GLOBAL_VAR(szNetbiosAliases),
225 .label = "netbios scope",
228 .offset = GLOBAL_VAR(szNetbiosScope),
231 .flags = FLAG_ADVANCED,
234 .label = "server string",
237 .offset = GLOBAL_VAR(szServerString),
240 .flags = FLAG_BASIC | FLAG_ADVANCED,
243 .label = "interfaces",
246 .offset = GLOBAL_VAR(szInterfaces),
249 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
252 .label = "bind interfaces only",
255 .offset = GLOBAL_VAR(bBindInterfacesOnly),
258 .flags = FLAG_ADVANCED | FLAG_WIZARD,
261 .label = "passdb backend",
264 .offset = GLOBAL_VAR(passdb_backend),
273 .offset = GLOBAL_VAR(security),
275 .enum_list = enum_security
278 .label = "encrypt passwords",
281 .offset = GLOBAL_VAR(bEncryptPasswords),
286 .label = "null passwords",
289 .offset = GLOBAL_VAR(bNullPasswords),
292 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
295 .label = "obey pam restrictions",
298 .offset = GLOBAL_VAR(bObeyPamRestrictions),
301 .flags = FLAG_ADVANCED,
304 .label = "password server",
307 .offset = GLOBAL_VAR(szPasswordServer),
312 .label = "private dir",
315 .offset = GLOBAL_VAR(szPrivateDir),
320 .label = "passwd chat",
323 .offset = GLOBAL_VAR(szPasswdChat),
328 .label = "password level",
331 .offset = GLOBAL_VAR(pwordlevel),
336 .label = "lanman auth",
339 .offset = GLOBAL_VAR(bLanmanAuth),
342 .flags = FLAG_ADVANCED,
345 .label = "ntlm auth",
348 .offset = GLOBAL_VAR(bNTLMAuth),
351 .flags = FLAG_ADVANCED,
354 .label = "client NTLMv2 auth",
357 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
360 .flags = FLAG_ADVANCED,
363 .label = "client lanman auth",
366 .offset = GLOBAL_VAR(bClientLanManAuth),
369 .flags = FLAG_ADVANCED,
372 .label = "client plaintext auth",
375 .offset = GLOBAL_VAR(bClientPlaintextAuth),
378 .flags = FLAG_ADVANCED,
381 .label = "client use spnego principal",
384 .offset = GLOBAL_VAR(client_use_spnego_principal),
390 .label = "read only",
393 .offset = LOCAL_VAR(bRead_only),
399 .label = "create mask",
402 .offset = LOCAL_VAR(iCreate_mask),
407 .label = "force create mode",
410 .offset = LOCAL_VAR(iCreate_force_mode),
415 .label = "directory mask",
418 .offset = LOCAL_VAR(iDir_mask),
423 .label = "force directory mode",
426 .offset = LOCAL_VAR(iDir_force_mode),
432 .label = "hosts allow",
435 .offset = LOCAL_VAR(szHostsallow),
440 .label = "hosts deny",
443 .offset = LOCAL_VAR(szHostsdeny),
449 .label = "log level",
452 .offset = GLOBAL_VAR(loglevel),
453 .special = handle_debuglevel,
457 .label = "debuglevel",
460 .offset = GLOBAL_VAR(loglevel),
461 .special = handle_debuglevel,
468 .offset = GLOBAL_VAR(logfile),
469 .special = handle_logfile,
471 .flags = FLAG_ADVANCED,
475 .label = "smb ports",
478 .offset = GLOBAL_VAR(smb_ports),
486 .offset = GLOBAL_VAR(nbt_port),
491 .label = "dgram port",
494 .offset = GLOBAL_VAR(dgram_port),
499 .label = "cldap port",
502 .offset = GLOBAL_VAR(cldap_port),
507 .label = "krb5 port",
510 .offset = GLOBAL_VAR(krb5_port),
515 .label = "kpasswd port",
518 .offset = GLOBAL_VAR(kpasswd_port),
526 .offset = GLOBAL_VAR(web_port),
531 .label = "large readwrite",
534 .offset = GLOBAL_VAR(bLargeReadwrite),
537 .flags = FLAG_ADVANCED,
540 .label = "server max protocol",
543 .offset = GLOBAL_VAR(srv_maxprotocol),
545 .enum_list = enum_protocol,
546 .flags = FLAG_ADVANCED,
549 .label = "max protocol",
552 .offset = GLOBAL_VAR(srv_maxprotocol),
554 .enum_list = enum_protocol,
555 .flags = FLAG_ADVANCED,
561 .offset = GLOBAL_VAR(srv_maxprotocol),
563 .enum_list = enum_protocol,
564 .flags = FLAG_ADVANCED,
567 .label = "server min protocol",
570 .offset = GLOBAL_VAR(srv_minprotocol),
572 .enum_list = enum_protocol,
573 .flags = FLAG_ADVANCED,
576 .label = "min protocol",
579 .offset = GLOBAL_VAR(srv_minprotocol),
581 .enum_list = enum_protocol,
582 .flags = FLAG_ADVANCED,
585 .label = "client max protocol",
588 .offset = GLOBAL_VAR(cli_maxprotocol),
590 .enum_list = enum_protocol
593 .label = "client min protocol",
596 .offset = GLOBAL_VAR(cli_minprotocol),
598 .enum_list = enum_protocol
604 .offset = GLOBAL_VAR(bUnicode),
612 .offset = GLOBAL_VAR(bReadRaw),
617 .label = "write raw",
620 .offset = GLOBAL_VAR(bWriteRaw),
625 .label = "disable netbios",
628 .offset = GLOBAL_VAR(bDisableNetbios),
634 .label = "nt status support",
637 .offset = GLOBAL_VAR(bNTStatusSupport),
646 .offset = GLOBAL_VAR(max_mux),
649 .flags = FLAG_ADVANCED,
655 .offset = GLOBAL_VAR(max_xmit),
658 .flags = FLAG_ADVANCED,
662 .label = "name resolve order",
665 .offset = GLOBAL_VAR(szNameResolveOrder),
670 .label = "max wins ttl",
673 .offset = GLOBAL_VAR(max_wins_ttl),
676 .flags = FLAG_ADVANCED,
679 .label = "min wins ttl",
682 .offset = GLOBAL_VAR(min_wins_ttl),
685 .flags = FLAG_ADVANCED,
688 .label = "time server",
691 .offset = GLOBAL_VAR(bTimeServer),
694 .flags = FLAG_ADVANCED,
697 .label = "unix extensions",
700 .offset = GLOBAL_VAR(bUnixExtensions),
703 .flags = FLAG_ADVANCED,
706 .label = "use spnego",
709 .offset = GLOBAL_VAR(bUseSpnego),
714 .label = "server signing",
717 .offset = GLOBAL_VAR(server_signing),
719 .enum_list = enum_smb_signing_vals,
720 .flags = FLAG_ADVANCED,
723 .label = "client signing",
726 .offset = GLOBAL_VAR(client_signing),
728 .enum_list = enum_smb_signing_vals
731 .label = "rpc big endian",
734 .offset = GLOBAL_VAR(bRpcBigEndian),
740 .label = "max connections",
743 .offset = LOCAL_VAR(iMaxConnections),
746 .flags = FLAG_ADVANCED | FLAG_SHARE,
749 .label = "paranoid server security",
752 .offset = GLOBAL_VAR(paranoid_server_security),
757 .label = "socket options",
760 .offset = GLOBAL_VAR(socket_options),
766 .label = "strict sync",
769 .offset = LOCAL_VAR(bStrictSync),
777 .offset = GLOBAL_VAR(bUseMmap),
780 .flags = FLAG_ADVANCED,
784 .label = "max print jobs",
787 .offset = LOCAL_VAR(iMaxPrintJobs),
792 .label = "printable",
795 .offset = LOCAL_VAR(bPrint_ok),
803 .offset = LOCAL_VAR(bPrint_ok),
809 .label = "printer name",
812 .offset = LOCAL_VAR(szPrintername),
815 .flags = FLAG_ADVANCED | FLAG_PRINT,
821 .offset = LOCAL_VAR(szPrintername),
827 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
830 .label = "mangling method",
833 .offset = GLOBAL_VAR(szManglingMethod),
836 .flags = FLAG_ADVANCED,
839 .label = "mangle prefix",
842 .offset = GLOBAL_VAR(mangle_prefix),
845 .flags = FLAG_ADVANCED,
849 .label = "default case",
852 .offset = LOCAL_VAR(iDefaultCase),
854 .enum_list = enum_case,
855 .flags = FLAG_ADVANCED | FLAG_SHARE,
858 .label = "case sensitive",
861 .offset = LOCAL_VAR(iCaseSensitive),
863 .enum_list = enum_bool_auto,
864 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
867 .label = "casesignames",
870 .offset = LOCAL_VAR(iCaseSensitive),
872 .enum_list = enum_bool_auto,
873 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
876 .label = "preserve case",
879 .offset = LOCAL_VAR(bCasePreserve),
882 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
885 .label = "short preserve case",
888 .offset = LOCAL_VAR(bShortCasePreserve),
891 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
894 .label = "mangling char",
897 .offset = LOCAL_VAR(magic_char),
900 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
903 .label = "hide dot files",
906 .offset = LOCAL_VAR(bHideDotFiles),
909 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
912 .label = "hide special files",
915 .offset = LOCAL_VAR(bHideSpecialFiles),
918 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
921 .label = "hide unreadable",
924 .offset = LOCAL_VAR(bHideUnReadable),
927 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
930 .label = "hide unwriteable files",
933 .offset = LOCAL_VAR(bHideUnWriteableFiles),
936 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
939 .label = "delete veto files",
942 .offset = LOCAL_VAR(bDeleteVetoFiles),
945 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
948 .label = "veto files",
951 .offset = LOCAL_VAR(szVetoFiles),
954 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
957 .label = "hide files",
960 .offset = LOCAL_VAR(szHideFiles),
963 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
966 .label = "veto oplock files",
969 .offset = LOCAL_VAR(szVetoOplockFiles),
972 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
975 .label = "map archive",
978 .offset = LOCAL_VAR(bMap_archive),
981 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
984 .label = "map hidden",
987 .offset = LOCAL_VAR(bMap_hidden),
990 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
993 .label = "map system",
996 .offset = LOCAL_VAR(bMap_system),
999 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1002 .label = "map readonly",
1005 .offset = LOCAL_VAR(iMap_readonly),
1007 .enum_list = enum_map_readonly,
1008 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1011 .label = "mangled names",
1014 .offset = LOCAL_VAR(bMangledNames),
1017 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1020 .label = "max stat cache size",
1022 .p_class = P_GLOBAL,
1023 .offset = GLOBAL_VAR(iMaxStatCacheSize),
1026 .flags = FLAG_ADVANCED,
1029 .label = "stat cache",
1031 .p_class = P_GLOBAL,
1032 .offset = GLOBAL_VAR(bStatCache),
1035 .flags = FLAG_ADVANCED,
1038 .label = "store dos attributes",
1041 .offset = LOCAL_VAR(bStoreDosAttributes),
1044 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1047 .label = "dmapi support",
1050 .offset = LOCAL_VAR(bDmapiSupport),
1053 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1057 {N_("Domain Options"), P_SEP, P_SEPARATOR},
1060 .label = "machine password timeout",
1062 .p_class = P_GLOBAL,
1063 .offset = GLOBAL_VAR(machine_password_timeout),
1066 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1069 {N_("Logon Options"), P_SEP, P_SEPARATOR},
1072 .label = "add user script",
1074 .p_class = P_GLOBAL,
1075 .offset = GLOBAL_VAR(szAddUserScript),
1078 .flags = FLAG_ADVANCED,
1081 .label = "rename user script",
1083 .p_class = P_GLOBAL,
1084 .offset = GLOBAL_VAR(szRenameUserScript),
1087 .flags = FLAG_ADVANCED,
1090 .label = "delete user script",
1092 .p_class = P_GLOBAL,
1093 .offset = GLOBAL_VAR(szDelUserScript),
1096 .flags = FLAG_ADVANCED,
1099 .label = "add group script",
1101 .p_class = P_GLOBAL,
1102 .offset = GLOBAL_VAR(szAddGroupScript),
1105 .flags = FLAG_ADVANCED,
1108 .label = "delete group script",
1110 .p_class = P_GLOBAL,
1111 .offset = GLOBAL_VAR(szDelGroupScript),
1114 .flags = FLAG_ADVANCED,
1117 .label = "add user to group script",
1119 .p_class = P_GLOBAL,
1120 .offset = GLOBAL_VAR(szAddUserToGroupScript),
1123 .flags = FLAG_ADVANCED,
1126 .label = "delete user from group script",
1128 .p_class = P_GLOBAL,
1129 .offset = GLOBAL_VAR(szDelUserFromGroupScript),
1132 .flags = FLAG_ADVANCED,
1135 .label = "set primary group script",
1137 .p_class = P_GLOBAL,
1138 .offset = GLOBAL_VAR(szSetPrimaryGroupScript),
1141 .flags = FLAG_ADVANCED,
1144 .label = "add machine script",
1146 .p_class = P_GLOBAL,
1147 .offset = GLOBAL_VAR(szAddMachineScript),
1150 .flags = FLAG_ADVANCED,
1153 .label = "shutdown script",
1155 .p_class = P_GLOBAL,
1156 .offset = GLOBAL_VAR(szShutdownScript),
1159 .flags = FLAG_ADVANCED,
1162 .label = "abort shutdown script",
1164 .p_class = P_GLOBAL,
1165 .offset = GLOBAL_VAR(szAbortShutdownScript),
1168 .flags = FLAG_ADVANCED,
1171 .label = "username map script",
1173 .p_class = P_GLOBAL,
1174 .offset = GLOBAL_VAR(szUsernameMapScript),
1177 .flags = FLAG_ADVANCED,
1180 .label = "username map cache time",
1182 .p_class = P_GLOBAL,
1183 .offset = GLOBAL_VAR(iUsernameMapCacheTime),
1186 .flags = FLAG_ADVANCED,
1189 .label = "logon script",
1191 .p_class = P_GLOBAL,
1192 .offset = GLOBAL_VAR(szLogonScript),
1195 .flags = FLAG_ADVANCED,
1198 .label = "logon path",
1200 .p_class = P_GLOBAL,
1201 .offset = GLOBAL_VAR(szLogonPath),
1204 .flags = FLAG_ADVANCED,
1207 .label = "logon drive",
1209 .p_class = P_GLOBAL,
1210 .offset = GLOBAL_VAR(szLogonDrive),
1213 .flags = FLAG_ADVANCED,
1216 .label = "logon home",
1218 .p_class = P_GLOBAL,
1219 .offset = GLOBAL_VAR(szLogonHome),
1222 .flags = FLAG_ADVANCED,
1225 .label = "domain logons",
1227 .p_class = P_GLOBAL,
1228 .offset = GLOBAL_VAR(bDomainLogons),
1231 .flags = FLAG_ADVANCED,
1235 .label = "init logon delayed hosts",
1237 .p_class = P_GLOBAL,
1238 .offset = GLOBAL_VAR(szInitLogonDelayedHosts),
1241 .flags = FLAG_ADVANCED,
1245 .label = "init logon delay",
1247 .p_class = P_GLOBAL,
1248 .offset = GLOBAL_VAR(InitLogonDelay),
1251 .flags = FLAG_ADVANCED,
1255 {N_("Browse Options"), P_SEP, P_SEPARATOR},
1258 .label = "os level",
1260 .p_class = P_GLOBAL,
1261 .offset = GLOBAL_VAR(os_level),
1264 .flags = FLAG_BASIC | FLAG_ADVANCED,
1267 .label = "lm announce",
1269 .p_class = P_GLOBAL,
1270 .offset = GLOBAL_VAR(lm_announce),
1272 .enum_list = enum_bool_auto,
1273 .flags = FLAG_ADVANCED,
1276 .label = "lm interval",
1278 .p_class = P_GLOBAL,
1279 .offset = GLOBAL_VAR(lm_interval),
1282 .flags = FLAG_ADVANCED,
1285 .label = "preferred master",
1287 .p_class = P_GLOBAL,
1288 .offset = GLOBAL_VAR(iPreferredMaster),
1290 .enum_list = enum_bool_auto,
1291 .flags = FLAG_BASIC | FLAG_ADVANCED,
1294 .label = "prefered master",
1296 .p_class = P_GLOBAL,
1297 .offset = GLOBAL_VAR(iPreferredMaster),
1299 .enum_list = enum_bool_auto,
1303 .label = "local master",
1305 .p_class = P_GLOBAL,
1306 .offset = GLOBAL_VAR(bLocalMaster),
1309 .flags = FLAG_BASIC | FLAG_ADVANCED,
1312 .label = "domain master",
1314 .p_class = P_GLOBAL,
1315 .offset = GLOBAL_VAR(domain_master),
1317 .enum_list = enum_bool_auto,
1318 .flags = FLAG_BASIC | FLAG_ADVANCED,
1321 .label = "browse list",
1323 .p_class = P_GLOBAL,
1324 .offset = GLOBAL_VAR(bBrowseList),
1327 .flags = FLAG_ADVANCED,
1330 .label = "browseable",
1333 .offset = LOCAL_VAR(bBrowseable),
1336 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1339 .label = "browsable",
1342 .offset = LOCAL_VAR(bBrowseable),
1348 .label = "access based share enum",
1351 .offset = LOCAL_VAR(bAccessBasedShareEnum),
1354 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
1357 .label = "enhanced browsing",
1359 .p_class = P_GLOBAL,
1360 .offset = GLOBAL_VAR(enhanced_browsing),
1363 .flags = FLAG_ADVANCED,
1366 {N_("WINS Options"), P_SEP, P_SEPARATOR},
1369 .label = "dns proxy",
1371 .p_class = P_GLOBAL,
1372 .offset = GLOBAL_VAR(bWINSdnsProxy),
1375 .flags = FLAG_ADVANCED,
1378 .label = "wins proxy",
1380 .p_class = P_GLOBAL,
1381 .offset = GLOBAL_VAR(bWINSproxy),
1384 .flags = FLAG_ADVANCED,
1387 .label = "wins server",
1389 .p_class = P_GLOBAL,
1390 .offset = GLOBAL_VAR(szWINSservers),
1393 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1396 .label = "wins support",
1398 .p_class = P_GLOBAL,
1399 .offset = GLOBAL_VAR(bWINSsupport),
1402 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1405 .label = "wins hook",
1407 .p_class = P_GLOBAL,
1408 .offset = GLOBAL_VAR(szWINSHook),
1411 .flags = FLAG_ADVANCED,
1414 {N_("Locking Options"), P_SEP, P_SEPARATOR},
1417 .label = "blocking locks",
1420 .offset = LOCAL_VAR(bBlockingLocks),
1423 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1426 .label = "csc policy",
1429 .offset = LOCAL_VAR(iCSCPolicy),
1431 .enum_list = enum_csc_policy,
1432 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1435 .label = "fake oplocks",
1438 .offset = LOCAL_VAR(bFakeOplocks),
1441 .flags = FLAG_ADVANCED | FLAG_SHARE,
1444 .label = "kernel oplocks",
1447 .offset = LOCAL_VAR(bKernelOplocks),
1450 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1456 .offset = LOCAL_VAR(bLocking),
1459 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1462 .label = "lock spin time",
1464 .p_class = P_GLOBAL,
1465 .offset = GLOBAL_VAR(iLockSpinTime),
1468 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1474 .offset = LOCAL_VAR(bOpLocks),
1477 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1480 .label = "level2 oplocks",
1483 .offset = LOCAL_VAR(bLevel2OpLocks),
1486 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1489 .label = "oplock break wait time",
1491 .p_class = P_GLOBAL,
1492 .offset = GLOBAL_VAR(oplock_break_wait_time),
1495 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1498 .label = "oplock contention limit",
1501 .offset = LOCAL_VAR(iOplockContentionLimit),
1504 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1507 .label = "posix locking",
1510 .offset = LOCAL_VAR(bPosixLocking),
1513 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1516 .label = "strict locking",
1519 .offset = LOCAL_VAR(iStrictLocking),
1521 .enum_list = enum_bool_auto,
1522 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1525 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
1528 .label = "ldap admin dn",
1530 .p_class = P_GLOBAL,
1531 .offset = GLOBAL_VAR(szLdapAdminDn),
1534 .flags = FLAG_ADVANCED,
1537 .label = "ldap delete dn",
1539 .p_class = P_GLOBAL,
1540 .offset = GLOBAL_VAR(ldap_delete_dn),
1543 .flags = FLAG_ADVANCED,
1546 .label = "ldap group suffix",
1548 .p_class = P_GLOBAL,
1549 .offset = GLOBAL_VAR(szLdapGroupSuffix),
1552 .flags = FLAG_ADVANCED,
1555 .label = "ldap idmap suffix",
1557 .p_class = P_GLOBAL,
1558 .offset = GLOBAL_VAR(szLdapIdmapSuffix),
1561 .flags = FLAG_ADVANCED,
1564 .label = "ldap machine suffix",
1566 .p_class = P_GLOBAL,
1567 .offset = GLOBAL_VAR(szLdapMachineSuffix),
1570 .flags = FLAG_ADVANCED,
1573 .label = "ldap passwd sync",
1575 .p_class = P_GLOBAL,
1576 .offset = GLOBAL_VAR(ldap_passwd_sync),
1578 .enum_list = enum_ldap_passwd_sync,
1579 .flags = FLAG_ADVANCED,
1582 .label = "ldap password sync",
1584 .p_class = P_GLOBAL,
1585 .offset = GLOBAL_VAR(ldap_passwd_sync),
1587 .enum_list = enum_ldap_passwd_sync,
1591 .label = "ldap replication sleep",
1593 .p_class = P_GLOBAL,
1594 .offset = GLOBAL_VAR(ldap_replication_sleep),
1597 .flags = FLAG_ADVANCED,
1600 .label = "ldap suffix",
1602 .p_class = P_GLOBAL,
1603 .offset = GLOBAL_VAR(szLdapSuffix),
1606 .flags = FLAG_ADVANCED,
1609 .label = "ldap ssl",
1611 .p_class = P_GLOBAL,
1612 .offset = GLOBAL_VAR(ldap_ssl),
1614 .enum_list = enum_ldap_ssl,
1615 .flags = FLAG_ADVANCED,
1618 .label = "ldap ssl ads",
1620 .p_class = P_GLOBAL,
1621 .offset = GLOBAL_VAR(ldap_ssl_ads),
1624 .flags = FLAG_ADVANCED,
1627 .label = "ldap deref",
1629 .p_class = P_GLOBAL,
1630 .offset = GLOBAL_VAR(ldap_deref),
1632 .enum_list = enum_ldap_deref,
1633 .flags = FLAG_ADVANCED,
1636 .label = "ldap follow referral",
1638 .p_class = P_GLOBAL,
1639 .offset = GLOBAL_VAR(ldap_follow_referral),
1641 .enum_list = enum_bool_auto,
1642 .flags = FLAG_ADVANCED,
1645 .label = "ldap timeout",
1647 .p_class = P_GLOBAL,
1648 .offset = GLOBAL_VAR(ldap_timeout),
1651 .flags = FLAG_ADVANCED,
1654 .label = "ldap connection timeout",
1656 .p_class = P_GLOBAL,
1657 .offset = GLOBAL_VAR(ldap_connection_timeout),
1660 .flags = FLAG_ADVANCED,
1663 .label = "ldap page size",
1665 .p_class = P_GLOBAL,
1666 .offset = GLOBAL_VAR(ldap_page_size),
1669 .flags = FLAG_ADVANCED,
1672 .label = "ldap user suffix",
1674 .p_class = P_GLOBAL,
1675 .offset = GLOBAL_VAR(szLdapUserSuffix),
1678 .flags = FLAG_ADVANCED,
1681 .label = "ldap debug level",
1683 .p_class = P_GLOBAL,
1684 .offset = GLOBAL_VAR(ldap_debug_level),
1685 .special = handle_ldap_debug_level,
1687 .flags = FLAG_ADVANCED,
1690 .label = "ldap debug threshold",
1692 .p_class = P_GLOBAL,
1693 .offset = GLOBAL_VAR(ldap_debug_threshold),
1696 .flags = FLAG_ADVANCED,
1699 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
1702 .label = "eventlog list",
1704 .p_class = P_GLOBAL,
1705 .offset = GLOBAL_VAR(szEventLogs),
1708 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1711 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
1714 .label = "add share command",
1716 .p_class = P_GLOBAL,
1717 .offset = GLOBAL_VAR(szAddShareCommand),
1720 .flags = FLAG_ADVANCED,
1723 .label = "change share command",
1725 .p_class = P_GLOBAL,
1726 .offset = GLOBAL_VAR(szChangeShareCommand),
1729 .flags = FLAG_ADVANCED,
1732 .label = "delete share command",
1734 .p_class = P_GLOBAL,
1735 .offset = GLOBAL_VAR(szDeleteShareCommand),
1738 .flags = FLAG_ADVANCED,
1741 .label = "config file",
1743 .p_class = P_GLOBAL,
1744 .offset = GLOBAL_VAR(szConfigFile),
1747 .flags = FLAG_HIDE|FLAG_META,
1752 .p_class = P_GLOBAL,
1753 .offset = GLOBAL_VAR(szAutoServices),
1756 .flags = FLAG_ADVANCED,
1759 .label = "auto services",
1761 .p_class = P_GLOBAL,
1762 .offset = GLOBAL_VAR(szAutoServices),
1765 .flags = FLAG_ADVANCED,
1768 .label = "lock directory",
1770 .p_class = P_GLOBAL,
1771 .offset = GLOBAL_VAR(szLockDir),
1774 .flags = FLAG_ADVANCED,
1777 .label = "lock dir",
1779 .p_class = P_GLOBAL,
1780 .offset = GLOBAL_VAR(szLockDir),
1786 .label = "state directory",
1788 .p_class = P_GLOBAL,
1789 .offset = GLOBAL_VAR(szStateDir),
1792 .flags = FLAG_ADVANCED,
1795 .label = "cache directory",
1797 .p_class = P_GLOBAL,
1798 .offset = GLOBAL_VAR(szCacheDir),
1801 .flags = FLAG_ADVANCED,
1804 .label = "pid directory",
1806 .p_class = P_GLOBAL,
1807 .offset = GLOBAL_VAR(szPidDir),
1810 .flags = FLAG_ADVANCED,
1813 .label = "ntp signd socket directory",
1815 .p_class = P_GLOBAL,
1816 .offset = GLOBAL_VAR(szNTPSignDSocketDirectory),
1819 .flags = FLAG_ADVANCED,
1824 .label = "utmp directory",
1826 .p_class = P_GLOBAL,
1827 .offset = GLOBAL_VAR(szUtmpDir),
1830 .flags = FLAG_ADVANCED,
1833 .label = "wtmp directory",
1835 .p_class = P_GLOBAL,
1836 .offset = GLOBAL_VAR(szWtmpDir),
1839 .flags = FLAG_ADVANCED,
1844 .p_class = P_GLOBAL,
1845 .offset = GLOBAL_VAR(bUtmp),
1848 .flags = FLAG_ADVANCED,
1852 .label = "default service",
1854 .p_class = P_GLOBAL,
1855 .offset = GLOBAL_VAR(szDefaultService),
1858 .flags = FLAG_ADVANCED,
1863 .p_class = P_GLOBAL,
1864 .offset = GLOBAL_VAR(szDefaultService),
1867 .flags = FLAG_ADVANCED,
1870 .label = "message command",
1872 .p_class = P_GLOBAL,
1873 .offset = GLOBAL_VAR(szMsgCommand),
1876 .flags = FLAG_ADVANCED,
1879 .label = "dfree cache time",
1882 .offset = LOCAL_VAR(iDfreeCacheTime),
1885 .flags = FLAG_ADVANCED,
1888 .label = "dfree command",
1891 .offset = LOCAL_VAR(szDfree),
1894 .flags = FLAG_ADVANCED,
1897 .label = "get quota command",
1899 .p_class = P_GLOBAL,
1900 .offset = GLOBAL_VAR(szGetQuota),
1903 .flags = FLAG_ADVANCED,
1906 .label = "set quota command",
1908 .p_class = P_GLOBAL,
1909 .offset = GLOBAL_VAR(szSetQuota),
1912 .flags = FLAG_ADVANCED,
1915 .label = "remote announce",
1917 .p_class = P_GLOBAL,
1918 .offset = GLOBAL_VAR(szRemoteAnnounce),
1921 .flags = FLAG_ADVANCED,
1924 .label = "remote browse sync",
1926 .p_class = P_GLOBAL,
1927 .offset = GLOBAL_VAR(szRemoteBrowseSync),
1930 .flags = FLAG_ADVANCED,
1933 .label = "socket address",
1935 .p_class = P_GLOBAL,
1936 .offset = GLOBAL_VAR(szSocketAddress),
1939 .flags = FLAG_ADVANCED,
1942 .label = "nmbd bind explicit broadcast",
1944 .p_class = P_GLOBAL,
1945 .offset = GLOBAL_VAR(bNmbdBindExplicitBroadcast),
1948 .flags = FLAG_ADVANCED,
1951 .label = "homedir map",
1953 .p_class = P_GLOBAL,
1954 .offset = GLOBAL_VAR(szNISHomeMapName),
1957 .flags = FLAG_ADVANCED,
1960 .label = "afs username map",
1962 .p_class = P_GLOBAL,
1963 .offset = GLOBAL_VAR(szAfsUsernameMap),
1966 .flags = FLAG_ADVANCED,
1969 .label = "afs token lifetime",
1971 .p_class = P_GLOBAL,
1972 .offset = GLOBAL_VAR(iAfsTokenLifetime),
1975 .flags = FLAG_ADVANCED,
1978 .label = "log nt token command",
1980 .p_class = P_GLOBAL,
1981 .offset = GLOBAL_VAR(szLogNtTokenCommand),
1984 .flags = FLAG_ADVANCED,
1987 .label = "NIS homedir",
1989 .p_class = P_GLOBAL,
1990 .offset = GLOBAL_VAR(bNISHomeMap),
1993 .flags = FLAG_ADVANCED,
1999 .offset = LOCAL_VAR(valid),
2008 .offset = LOCAL_VAR(szCopy),
2009 .special = handle_copy,
2017 .offset = LOCAL_VAR(szInclude),
2018 .special = handle_include,
2020 .flags = FLAG_HIDE|FLAG_META,
2026 .offset = LOCAL_VAR(szPreExec),
2029 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
2035 .offset = LOCAL_VAR(szPreExec),
2038 .flags = FLAG_ADVANCED,
2041 .label = "preexec close",
2044 .offset = LOCAL_VAR(bPreexecClose),
2047 .flags = FLAG_ADVANCED | FLAG_SHARE,
2050 .label = "postexec",
2053 .offset = LOCAL_VAR(szPostExec),
2056 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
2059 .label = "root preexec",
2062 .offset = LOCAL_VAR(szRootPreExec),
2065 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
2068 .label = "root preexec close",
2071 .offset = LOCAL_VAR(bRootpreexecClose),
2074 .flags = FLAG_ADVANCED | FLAG_SHARE,
2077 .label = "root postexec",
2080 .offset = LOCAL_VAR(szRootPostExec),
2083 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
2086 .label = "available",
2089 .offset = LOCAL_VAR(bAvailable),
2092 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
2095 .label = "registry shares",
2097 .p_class = P_GLOBAL,
2098 .offset = GLOBAL_VAR(bRegistryShares),
2101 .flags = FLAG_ADVANCED,
2104 .label = "usershare allow guests",
2106 .p_class = P_GLOBAL,
2107 .offset = GLOBAL_VAR(bUsershareAllowGuests),
2110 .flags = FLAG_ADVANCED,
2113 .label = "usershare max shares",
2115 .p_class = P_GLOBAL,
2116 .offset = GLOBAL_VAR(iUsershareMaxShares),
2119 .flags = FLAG_ADVANCED,
2122 .label = "usershare owner only",
2124 .p_class = P_GLOBAL,
2125 .offset = GLOBAL_VAR(bUsershareOwnerOnly),
2128 .flags = FLAG_ADVANCED,
2131 .label = "usershare path",
2133 .p_class = P_GLOBAL,
2134 .offset = GLOBAL_VAR(szUsersharePath),
2137 .flags = FLAG_ADVANCED,
2140 .label = "usershare prefix allow list",
2142 .p_class = P_GLOBAL,
2143 .offset = GLOBAL_VAR(szUsersharePrefixAllowList),
2146 .flags = FLAG_ADVANCED,
2149 .label = "usershare prefix deny list",
2151 .p_class = P_GLOBAL,
2152 .offset = GLOBAL_VAR(szUsersharePrefixDenyList),
2155 .flags = FLAG_ADVANCED,
2158 .label = "usershare template share",
2160 .p_class = P_GLOBAL,
2161 .offset = GLOBAL_VAR(szUsershareTemplateShare),
2164 .flags = FLAG_ADVANCED,
2170 .offset = LOCAL_VAR(volume),
2173 .flags = FLAG_ADVANCED | FLAG_SHARE,
2179 .offset = LOCAL_VAR(fstype),
2182 .flags = FLAG_ADVANCED | FLAG_SHARE,
2185 .label = "set directory",
2188 .offset = LOCAL_VAR(bNo_set_dir),
2191 .flags = FLAG_ADVANCED | FLAG_SHARE,
2194 .label = "allow insecure wide links",
2196 .p_class = P_GLOBAL,
2197 .offset = GLOBAL_VAR(bAllowInsecureWidelinks),
2200 .flags = FLAG_ADVANCED,
2203 .label = "wide links",
2206 .offset = LOCAL_VAR(bWidelinks),
2209 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2212 .label = "follow symlinks",
2215 .offset = LOCAL_VAR(bSymlinks),
2218 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2221 .label = "dont descend",
2224 .offset = LOCAL_VAR(szDontdescend),
2227 .flags = FLAG_ADVANCED | FLAG_SHARE,
2230 .label = "magic script",
2233 .offset = LOCAL_VAR(szMagicScript),
2236 .flags = FLAG_ADVANCED | FLAG_SHARE,
2239 .label = "magic output",
2242 .offset = LOCAL_VAR(szMagicOutput),
2245 .flags = FLAG_ADVANCED | FLAG_SHARE,
2248 .label = "delete readonly",
2251 .offset = LOCAL_VAR(bDeleteReadonly),
2254 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2257 .label = "dos filemode",
2260 .offset = LOCAL_VAR(bDosFilemode),
2263 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2266 .label = "dos filetimes",
2269 .offset = LOCAL_VAR(bDosFiletimes),
2272 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2275 .label = "dos filetime resolution",
2278 .offset = LOCAL_VAR(bDosFiletimeResolution),
2281 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2284 .label = "fake directory create times",
2287 .offset = LOCAL_VAR(bFakeDirCreateTimes),
2290 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2293 .label = "async smb echo handler",
2295 .p_class = P_GLOBAL,
2296 .offset = GLOBAL_VAR(bAsyncSMBEchoHandler),
2299 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2302 .label = "panic action",
2304 .p_class = P_GLOBAL,
2305 .offset = GLOBAL_VAR(szPanicAction),
2308 .flags = FLAG_ADVANCED,
2311 .label = "perfcount module",
2313 .p_class = P_GLOBAL,
2314 .offset = GLOBAL_VAR(szSMBPerfcountModule),
2317 .flags = FLAG_ADVANCED,
2320 {N_("VFS module options"), P_SEP, P_SEPARATOR},
2323 .label = "vfs objects",
2326 .offset = LOCAL_VAR(szVfsObjects),
2329 .flags = FLAG_ADVANCED | FLAG_SHARE,
2332 .label = "vfs object",
2335 .offset = LOCAL_VAR(szVfsObjects),
2342 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
2345 .label = "msdfs root",
2348 .offset = LOCAL_VAR(bMSDfsRoot),
2351 .flags = FLAG_ADVANCED | FLAG_SHARE,
2354 .label = "msdfs proxy",
2357 .offset = LOCAL_VAR(szMSDfsProxy),
2360 .flags = FLAG_ADVANCED | FLAG_SHARE,
2363 .label = "host msdfs",
2365 .p_class = P_GLOBAL,
2366 .offset = GLOBAL_VAR(bHostMSDfs),
2369 .flags = FLAG_ADVANCED,
2372 {N_("Winbind options"), P_SEP, P_SEPARATOR},
2375 .label = "passdb expand explicit",
2377 .p_class = P_GLOBAL,
2378 .offset = GLOBAL_VAR(bPassdbExpandExplicit),
2381 .flags = FLAG_ADVANCED,
2384 .label = "idmap backend",
2386 .p_class = P_GLOBAL,
2387 .offset = GLOBAL_VAR(szIdmapBackend),
2388 .special = handle_idmap_backend,
2390 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
2393 .label = "idmap cache time",
2395 .p_class = P_GLOBAL,
2396 .offset = GLOBAL_VAR(iIdmapCacheTime),
2399 .flags = FLAG_ADVANCED,
2402 .label = "idmap negative cache time",
2404 .p_class = P_GLOBAL,
2405 .offset = GLOBAL_VAR(iIdmapNegativeCacheTime),
2408 .flags = FLAG_ADVANCED,
2411 .label = "idmap uid",
2413 .p_class = P_GLOBAL,
2414 .offset = GLOBAL_VAR(szIdmapUID),
2415 .special = handle_idmap_uid,
2417 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
2420 .label = "winbind uid",
2422 .p_class = P_GLOBAL,
2423 .offset = GLOBAL_VAR(szIdmapUID),
2424 .special = handle_idmap_uid,
2429 .label = "idmap gid",
2431 .p_class = P_GLOBAL,
2432 .offset = GLOBAL_VAR(szIdmapGID),
2433 .special = handle_idmap_gid,
2435 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
2438 .label = "winbind gid",
2440 .p_class = P_GLOBAL,
2441 .offset = GLOBAL_VAR(szIdmapGID),
2442 .special = handle_idmap_gid,
2447 .label = "template homedir",
2449 .p_class = P_GLOBAL,
2450 .offset = GLOBAL_VAR(szTemplateHomedir),
2453 .flags = FLAG_ADVANCED,
2456 .label = "template shell",
2458 .p_class = P_GLOBAL,
2459 .offset = GLOBAL_VAR(szTemplateShell),
2462 .flags = FLAG_ADVANCED,
2465 .label = "winbind separator",
2467 .p_class = P_GLOBAL,
2468 .offset = GLOBAL_VAR(szWinbindSeparator),
2471 .flags = FLAG_ADVANCED,
2474 .label = "winbind cache time",
2476 .p_class = P_GLOBAL,
2477 .offset = GLOBAL_VAR(winbind_cache_time),
2480 .flags = FLAG_ADVANCED,
2483 .label = "winbind reconnect delay",
2485 .p_class = P_GLOBAL,
2486 .offset = GLOBAL_VAR(winbind_reconnect_delay),
2489 .flags = FLAG_ADVANCED,
2492 .label = "winbind max clients",
2494 .p_class = P_GLOBAL,
2495 .offset = GLOBAL_VAR(winbind_max_clients),
2498 .flags = FLAG_ADVANCED,
2501 .label = "winbind enum users",
2503 .p_class = P_GLOBAL,
2504 .offset = GLOBAL_VAR(bWinbindEnumUsers),
2507 .flags = FLAG_ADVANCED,
2510 .label = "winbind enum groups",
2512 .p_class = P_GLOBAL,
2513 .offset = GLOBAL_VAR(bWinbindEnumGroups),
2516 .flags = FLAG_ADVANCED,
2519 .label = "winbind use default domain",
2521 .p_class = P_GLOBAL,
2522 .offset = GLOBAL_VAR(bWinbindUseDefaultDomain),
2525 .flags = FLAG_ADVANCED,
2528 .label = "winbind trusted domains only",
2530 .p_class = P_GLOBAL,
2531 .offset = GLOBAL_VAR(bWinbindTrustedDomainsOnly),
2534 .flags = FLAG_ADVANCED,
2537 .label = "winbind nested groups",
2539 .p_class = P_GLOBAL,
2540 .offset = GLOBAL_VAR(bWinbindNestedGroups),
2543 .flags = FLAG_ADVANCED,
2546 .label = "winbind expand groups",
2548 .p_class = P_GLOBAL,
2549 .offset = GLOBAL_VAR(winbind_expand_groups),
2552 .flags = FLAG_ADVANCED,
2555 .label = "winbind nss info",
2557 .p_class = P_GLOBAL,
2558 .offset = GLOBAL_VAR(szWinbindNssInfo),
2561 .flags = FLAG_ADVANCED,
2564 .label = "winbind refresh tickets",
2566 .p_class = P_GLOBAL,
2567 .offset = GLOBAL_VAR(bWinbindRefreshTickets),
2570 .flags = FLAG_ADVANCED,
2573 .label = "winbind offline logon",
2575 .p_class = P_GLOBAL,
2576 .offset = GLOBAL_VAR(bWinbindOfflineLogon),
2579 .flags = FLAG_ADVANCED,
2582 .label = "winbind normalize names",
2584 .p_class = P_GLOBAL,
2585 .offset = GLOBAL_VAR(bWinbindNormalizeNames),
2588 .flags = FLAG_ADVANCED,
2591 .label = "winbind rpc only",
2593 .p_class = P_GLOBAL,
2594 .offset = GLOBAL_VAR(bWinbindRpcOnly),
2597 .flags = FLAG_ADVANCED,
2600 .label = "create krb5 conf",
2602 .p_class = P_GLOBAL,
2603 .offset = GLOBAL_VAR(bCreateKrb5Conf),
2606 .flags = FLAG_ADVANCED,
2609 .label = "ncalrpc dir",
2611 .p_class = P_GLOBAL,
2612 .offset = GLOBAL_VAR(ncalrpc_dir),
2615 .flags = FLAG_ADVANCED,
2618 .label = "winbind max domain connections",
2620 .p_class = P_GLOBAL,
2621 .offset = GLOBAL_VAR(winbindMaxDomainConnections),
2624 .flags = FLAG_ADVANCED,
2627 .label = "winbindd socket directory",
2629 .p_class = P_GLOBAL,
2630 .offset = GLOBAL_VAR(szWinbinddSocketDirectory),
2633 .flags = FLAG_ADVANCED,
2636 .label = "winbindd privileged socket directory",
2638 .p_class = P_GLOBAL,
2639 .offset = GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory),
2642 .flags = FLAG_ADVANCED,
2645 .label = "winbind sealed pipes",
2647 .p_class = P_GLOBAL,
2648 .offset = GLOBAL_VAR(bWinbindSealedPipes),
2651 .flags = FLAG_ADVANCED,
2654 {N_("DNS options"), P_SEP, P_SEPARATOR},
2656 .label = "allow dns updates",
2658 .p_class = P_GLOBAL,
2659 .offset = GLOBAL_VAR(allow_dns_updates),
2661 .enum_list = enum_dns_update_settings,
2662 .flags = FLAG_ADVANCED,
2665 .label = "dns forwarder",
2667 .p_class = P_GLOBAL,
2668 .offset = GLOBAL_VAR(dns_forwarder),
2671 .flags = FLAG_ADVANCED,
2674 .label = "dns recursive queries",
2676 .p_class = P_GLOBAL,
2677 .offset = GLOBAL_VAR(dns_recursive_queries),
2682 .label = "dns update command",
2684 .p_class = P_GLOBAL,
2685 .offset = GLOBAL_VAR(szDNSUpdateCommand),
2688 .flags = FLAG_ADVANCED,
2691 .label = "nsupdate command",
2693 .p_class = P_GLOBAL,
2694 .offset = GLOBAL_VAR(szNSUpdateCommand),
2697 .flags = FLAG_ADVANCED,
2700 .label = "rndc command",
2702 .p_class = P_GLOBAL,
2703 .offset = GLOBAL_VAR(szRNDCCommand),
2706 .flags = FLAG_ADVANCED,
2709 .label = "multicast dns register",
2711 .p_class = P_GLOBAL,
2712 .offset = GLOBAL_VAR(bMulticastDnsRegister),
2715 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2718 {N_("AD DC options"), P_SEP, P_SEPARATOR},
2721 .label = "samba kcc command",
2723 .p_class = P_GLOBAL,
2724 .offset = GLOBAL_VAR(szSambaKCCCommand),
2727 .flags = FLAG_ADVANCED,
2730 .label = "server services",
2732 .p_class = P_GLOBAL,
2733 .offset = GLOBAL_VAR(server_services),
2738 .label = "dcerpc endpoint servers",
2740 .p_class = P_GLOBAL,
2741 .offset = GLOBAL_VAR(dcerpc_ep_servers),
2746 .label = "spn update command",
2748 .p_class = P_GLOBAL,
2749 .offset = GLOBAL_VAR(szSPNUpdateCommand),
2752 .flags = FLAG_ADVANCED,
2755 .label = "share backend",
2757 .p_class = P_GLOBAL,
2758 .offset = GLOBAL_VAR(szShareBackend),
2763 .label = "ntvfs handler",
2766 .offset = LOCAL_VAR(ntvfs_handler),
2771 {N_("TLS options"), P_SEP, P_SEPARATOR},
2774 .label = "tls enabled",
2776 .p_class = P_GLOBAL,
2777 .offset = GLOBAL_VAR(tls_enabled),
2782 .label = "tls keyfile",
2784 .p_class = P_GLOBAL,
2785 .offset = GLOBAL_VAR(tls_keyfile),
2790 .label = "tls certfile",
2792 .p_class = P_GLOBAL,
2793 .offset = GLOBAL_VAR(tls_certfile),
2798 .label = "tls cafile",
2800 .p_class = P_GLOBAL,
2801 .offset = GLOBAL_VAR(tls_cafile),
2806 .label = "tls crlfile",
2808 .p_class = P_GLOBAL,
2809 .offset = GLOBAL_VAR(tls_crlfile),
2814 .label = "tls dh params file",
2816 .p_class = P_GLOBAL,
2817 .offset = GLOBAL_VAR(tls_dhpfile),
2822 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
2826 /* local variables */
2827 struct loadparm_context {
2828 const char *szConfigFile;
2829 struct loadparm_global *globals;
2830 struct loadparm_service **services;
2831 struct loadparm_service *sDefault;
2832 struct smb_iconv_handle *iconv_handle;
2834 struct loadparm_service *currentService;
2835 bool bInGlobalSection;
2837 struct file_lists *next;
2842 unsigned int flags[NUMPARAMETERS];
2845 bool global; /* Is this the global context, which may set
2846 * global variables such as debug level etc? */
2847 const struct loadparm_s3_helpers *s3_fns;
2851 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx)
2853 if (lp_ctx->s3_fns) {
2854 return lp_ctx->s3_fns->get_default_loadparm_service();
2856 return lp_ctx->sDefault;
2860 * Convenience routine to grab string parameters into temporary memory
2861 * and run standard_sub_basic on them.
2863 * The buffers can be written to by
2864 * callers without affecting the source string.
2867 static const char *lp_string(const char *s)
2869 #if 0 /* until REWRITE done to make thread-safe */
2870 size_t len = s ? strlen(s) : 0;
2874 /* The follow debug is useful for tracking down memory problems
2875 especially if you have an inner loop that is calling a lp_*()
2876 function that returns a string. Perhaps this debug should be
2877 present all the time? */
2880 DEBUG(10, ("lp_string(%s)\n", s));
2883 #if 0 /* until REWRITE done to make thread-safe */
2885 lp_talloc = talloc_init("lp_talloc");
2887 ret = talloc_array(lp_talloc, char, len + 100); /* leave room for substitution */
2895 strlcpy(ret, s, len);
2897 if (trim_string(ret, "\"", "\"")) {
2898 if (strchr(ret,'"') != NULL)
2899 strlcpy(ret, s, len);
2902 standard_sub_basic(ret,len+100);
2909 In this section all the functions that are used to access the
2910 parameters from the rest of the program are defined
2914 * the creation of separate lpcfg_*() and lp_*() functions is to allow
2915 * for code compatibility between existing Samba4 and Samba3 code.
2918 /* this global context supports the lp_*() function varients */
2919 static struct loadparm_context *global_loadparm_context;
2921 #define lpcfg_default_service global_loadparm_context->sDefault
2922 #define lpcfg_global_service(i) global_loadparm_context->services[i]
2924 #define FN_GLOBAL_STRING(fn_name,var_name) \
2925 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
2926 if (lp_ctx == NULL) return NULL; \
2927 if (lp_ctx->s3_fns) { \
2928 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
2929 return lp_ctx->s3_fns->fn_name(); \
2931 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
2934 #define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
2935 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
2936 if (lp_ctx == NULL) return NULL; \
2937 if (lp_ctx->s3_fns) { \
2938 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
2939 return lp_ctx->s3_fns->fn_name(); \
2941 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
2944 #define FN_GLOBAL_LIST(fn_name,var_name) \
2945 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
2946 if (lp_ctx == NULL) return NULL; \
2947 if (lp_ctx->s3_fns) { \
2948 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
2949 return lp_ctx->s3_fns->fn_name(); \
2951 return lp_ctx->globals->var_name; \
2954 #define FN_GLOBAL_BOOL(fn_name,var_name) \
2955 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
2956 if (lp_ctx == NULL) return false; \
2957 if (lp_ctx->s3_fns) { \
2958 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
2959 return lp_ctx->s3_fns->fn_name(); \
2961 return lp_ctx->globals->var_name; \
2964 #define FN_GLOBAL_INTEGER(fn_name,var_name) \
2965 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
2966 if (lp_ctx->s3_fns) { \
2967 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
2968 return lp_ctx->s3_fns->fn_name(); \
2970 return lp_ctx->globals->var_name; \
2973 /* Local parameters don't need the ->s3_fns because the struct
2974 * loadparm_service is shared and lpcfg_service() checks the ->s3_fns
2976 #define FN_LOCAL_STRING(fn_name,val) \
2977 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, \
2978 struct loadparm_service *sDefault) { \
2979 return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val))); \
2982 #define FN_LOCAL_CONST_STRING(fn_name,val) FN_LOCAL_STRING(fn_name, val)
2984 #define FN_LOCAL_LIST(fn_name,val) \
2985 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, \
2986 struct loadparm_service *sDefault) {\
2987 return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val); \
2990 #define FN_LOCAL_PARM_BOOL(fn_name, val) FN_LOCAL_BOOL(fn_name, val)
2992 #define FN_LOCAL_BOOL(fn_name,val) \
2993 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, \
2994 struct loadparm_service *sDefault) { \
2995 return((service != NULL)? service->val : sDefault->val); \
2998 #define FN_LOCAL_INTEGER(fn_name,val) \
2999 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, \
3000 struct loadparm_service *sDefault) { \
3001 return((service != NULL)? service->val : sDefault->val); \
3004 #define FN_LOCAL_PARM_INTEGER(fn_name, val) FN_LOCAL_INTEGER(fn_name, val)
3006 #define FN_LOCAL_PARM_CHAR(fn_name, val) FN_LOCAL_CHAR(fn_name, val)
3008 #define FN_LOCAL_CHAR(fn_name,val) \
3009 _PUBLIC_ char lpcfg_ ## fn_name(struct loadparm_service *service, \
3010 struct loadparm_service *sDefault) { \
3011 return((service != NULL)? service->val : sDefault->val); \
3014 #include "lib/param/param_functions.c"
3016 /* These functions remain only in lib/param for now */
3017 FN_GLOBAL_BOOL(readraw, bReadRaw)
3018 FN_GLOBAL_BOOL(writeraw, bWriteRaw)
3019 FN_GLOBAL_STRING(cachedir, szCacheDir)
3020 FN_GLOBAL_STRING(socket_address, szSocketAddress)
3021 FN_GLOBAL_STRING(statedir, szStateDir)
3023 /* local prototypes */
3024 static int map_parameter(const char *pszParmName);
3025 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
3026 const char *pszServiceName);
3027 static void copy_service(struct loadparm_service *pserviceDest,
3028 struct loadparm_service *pserviceSource,
3029 struct bitmap *pcopymapDest);
3030 static bool lpcfg_service_ok(struct loadparm_service *service);
3031 static bool do_section(const char *pszSectionName, void *);
3032 static void init_copymap(struct loadparm_service *pservice);
3034 /* This is a helper function for parametrical options support. */
3035 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
3036 /* Actual parametrical functions are quite simple */
3037 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
3038 struct loadparm_service *service,
3039 const char *type, const char *option)
3041 char *vfskey_tmp = NULL;
3042 char *vfskey = NULL;
3043 struct parmlist_entry *data;
3048 if (lp_ctx->s3_fns) {
3049 return lp_ctx->s3_fns->get_parametric(service, type, option);
3052 data = (service == NULL ? lp_ctx->globals->param_opt : service->param_opt);
3054 vfskey_tmp = talloc_asprintf(NULL, "%s:%s", type, option);
3055 if (vfskey_tmp == NULL) return NULL;
3056 vfskey = strlower_talloc(NULL, vfskey_tmp);
3057 talloc_free(vfskey_tmp);
3060 if (strcmp(data->key, vfskey) == 0) {
3061 talloc_free(vfskey);
3067 if (service != NULL) {
3068 /* Try to fetch the same option but from globals */
3069 /* but only if we are not already working with globals */
3070 for (data = lp_ctx->globals->param_opt; data;
3071 data = data->next) {
3072 if (strcmp(data->key, vfskey) == 0) {
3073 talloc_free(vfskey);
3079 talloc_free(vfskey);
3086 * convenience routine to return int parameters.
3088 static int lp_int(const char *s)
3092 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
3096 return strtol(s, NULL, 0);
3100 * convenience routine to return unsigned long parameters.
3102 static unsigned long lp_ulong(const char *s)
3106 DEBUG(0,("lp_ulong(%s): is called with NULL!\n",s));
3110 return strtoul(s, NULL, 0);
3114 * convenience routine to return unsigned long parameters.
3116 static long lp_long(const char *s)
3120 DEBUG(0,("lp_long(%s): is called with NULL!\n",s));
3124 return strtol(s, NULL, 0);
3128 * convenience routine to return unsigned long parameters.
3130 static double lp_double(const char *s)
3134 DEBUG(0,("lp_double(%s): is called with NULL!\n",s));
3138 return strtod(s, NULL);
3142 * convenience routine to return boolean parameters.
3144 static bool lp_bool(const char *s)
3149 DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
3153 if (!set_boolean(s, &ret)) {
3154 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
3163 * Return parametric option from a given service. Type is a part of option before ':'
3164 * Parametric option has following syntax: 'Type: option = value'
3165 * Returned value is allocated in 'lp_talloc' context
3168 const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
3169 struct loadparm_service *service, const char *type,
3172 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
3175 return lp_string(value);
3181 * Return parametric option from a given service. Type is a part of option before ':'
3182 * Parametric option has following syntax: 'Type: option = value'
3183 * Returned value is allocated in 'lp_talloc' context
3186 const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
3187 struct loadparm_context *lp_ctx,
3188 struct loadparm_service *service,
3190 const char *option, const char *separator)
3192 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
3195 return (const char **)str_list_make(mem_ctx, value, separator);
3201 * Return parametric option from a given service. Type is a part of option before ':'
3202 * Parametric option has following syntax: 'Type: option = value'
3205 int lpcfg_parm_int(struct loadparm_context *lp_ctx,
3206 struct loadparm_service *service, const char *type,
3207 const char *option, int default_v)
3209 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
3212 return lp_int(value);
3218 * Return parametric option from a given service. Type is a part of
3219 * option before ':'.
3220 * Parametric option has following syntax: 'Type: option = value'.
3223 int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
3224 struct loadparm_service *service, const char *type,
3225 const char *option, int default_v)
3229 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
3231 if (value && conv_str_size_error(value, &bval)) {
3232 if (bval <= INT_MAX) {
3241 * Return parametric option from a given service.
3242 * Type is a part of option before ':'
3243 * Parametric option has following syntax: 'Type: option = value'
3245 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
3246 struct loadparm_service *service, const char *type,
3247 const char *option, unsigned long default_v)
3249 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
3252 return lp_ulong(value);
3257 long lpcfg_parm_long(struct loadparm_context *lp_ctx,
3258 struct loadparm_service *service, const char *type,
3259 const char *option, long default_v)
3261 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
3264 return lp_long(value);
3269 double lpcfg_parm_double(struct loadparm_context *lp_ctx,
3270 struct loadparm_service *service, const char *type,
3271 const char *option, double default_v)
3273 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
3276 return lp_double(value);
3282 * Return parametric option from a given service. Type is a part of option before ':'
3283 * Parametric option has following syntax: 'Type: option = value'
3286 bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
3287 struct loadparm_service *service, const char *type,
3288 const char *option, bool default_v)
3290 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
3293 return lp_bool(value);
3300 * Initialise a service to the defaults.
3303 static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx, struct loadparm_service *sDefault)
3305 struct loadparm_service *pservice =
3306 talloc_zero(mem_ctx, struct loadparm_service);
3307 copy_service(pservice, sDefault, NULL);
3312 * Set a string value, deallocating any existing space, and allocing the space
3315 static bool lpcfg_string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
3322 *dest = talloc_strdup(mem_ctx, src);
3323 if ((*dest) == NULL) {
3324 DEBUG(0,("Out of memory in string_set\n"));
3332 * Set a string value, deallocating any existing space, and allocing the space
3335 static bool lpcfg_string_set_upper(TALLOC_CTX *mem_ctx, char **dest, const char *src)
3342 *dest = strupper_talloc(mem_ctx, src);
3343 if ((*dest) == NULL) {
3344 DEBUG(0,("Out of memory in string_set_upper\n"));
3354 * Add a new service to the services array initialising it with the given
3358 struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
3359 const struct loadparm_service *pservice,
3363 struct loadparm_service tservice;
3364 int num_to_alloc = lp_ctx->iNumServices + 1;
3365 struct parmlist_entry *data, *pdata;
3367 if (pservice == NULL) {
3368 pservice = lp_ctx->sDefault;
3371 tservice = *pservice;
3373 /* it might already exist */
3375 struct loadparm_service *service = getservicebyname(lp_ctx,
3377 if (service != NULL) {
3378 /* Clean all parametric options for service */
3379 /* They will be added during parsing again */
3380 data = service->param_opt;
3386 service->param_opt = NULL;
3391 /* find an invalid one */
3392 for (i = 0; i < lp_ctx->iNumServices; i++)
3393 if (lp_ctx->services[i] == NULL)
3396 /* if not, then create one */
3397 if (i == lp_ctx->iNumServices) {
3398 struct loadparm_service **tsp;
3400 tsp = talloc_realloc(lp_ctx, lp_ctx->services, struct loadparm_service *, num_to_alloc);
3403 DEBUG(0,("lpcfg_add_service: failed to enlarge services!\n"));
3406 lp_ctx->services = tsp;
3407 lp_ctx->services[lp_ctx->iNumServices] = NULL;
3410 lp_ctx->iNumServices++;
3413 lp_ctx->services[i] = init_service(lp_ctx->services, lp_ctx->sDefault);
3414 if (lp_ctx->services[i] == NULL) {
3415 DEBUG(0,("lpcfg_add_service: out of memory!\n"));
3418 copy_service(lp_ctx->services[i], &tservice, NULL);
3420 lpcfg_string_set(lp_ctx->services[i], &lp_ctx->services[i]->szService, name);
3421 return lp_ctx->services[i];
3425 * Add a new home service, with the specified home directory, defaults coming
3426 * from service ifrom.
3429 bool lpcfg_add_home(struct loadparm_context *lp_ctx,
3430 const char *pszHomename,
3431 struct loadparm_service *default_service,
3432 const char *user, const char *pszHomedir)
3434 struct loadparm_service *service;
3436 service = lpcfg_add_service(lp_ctx, default_service, pszHomename);
3438 if (service == NULL)
3441 if (!(*(default_service->szPath))
3442 || strequal(default_service->szPath, lp_ctx->sDefault->szPath)) {
3443 service->szPath = talloc_strdup(service, pszHomedir);
3445 service->szPath = string_sub_talloc(service, lpcfg_pathname(default_service, lp_ctx->sDefault), "%H", pszHomedir);
3448 if (!(*(service->comment))) {
3449 service->comment = talloc_asprintf(service, "Home directory of %s", user);
3451 service->bAvailable = default_service->bAvailable;
3452 service->bBrowseable = default_service->bBrowseable;
3454 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
3455 pszHomename, user, service->szPath));
3461 * Add a new printer service, with defaults coming from service iFrom.
3464 bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
3465 const char *pszPrintername,
3466 struct loadparm_service *default_service)
3468 const char *comment = "From Printcap";
3469 struct loadparm_service *service;
3470 service = lpcfg_add_service(lp_ctx, default_service, pszPrintername);
3472 if (service == NULL)
3475 /* note that we do NOT default the availability flag to True - */
3476 /* we take it from the default service passed. This allows all */
3477 /* dynamic printers to be disabled by disabling the [printers] */
3478 /* entry (if/when the 'available' keyword is implemented!). */
3480 /* the printer name is set to the service name. */
3481 lpcfg_string_set(service, &service->szPrintername, pszPrintername);
3482 lpcfg_string_set(service, &service->comment, comment);
3483 service->bBrowseable = default_service->bBrowseable;
3484 /* Printers cannot be read_only. */
3485 service->bRead_only = false;
3486 /* Printer services must be printable. */
3487 service->bPrint_ok = true;
3489 DEBUG(3, ("adding printer service %s\n", pszPrintername));
3495 * Map a parameter's string representation to something we can use.
3496 * Returns False if the parameter string is not recognised, else TRUE.
3499 static int map_parameter(const char *pszParmName)
3503 if (*pszParmName == '-')
3506 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
3507 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
3510 /* Warn only if it isn't parametric option */
3511 if (strchr(pszParmName, ':') == NULL)
3512 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
3513 /* We do return 'fail' for parametric options as well because they are
3514 stored in different storage
3521 return the parameter structure for a parameter
3523 struct parm_struct *lpcfg_parm_struct(struct loadparm_context *lp_ctx, const char *name)
3527 if (lp_ctx->s3_fns) {
3528 return lp_ctx->s3_fns->get_parm_struct(name);
3531 parmnum = map_parameter(name);
3532 if (parmnum == -1) return NULL;
3533 return &parm_table[parmnum];
3537 return the parameter pointer for a parameter
3539 void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
3540 struct loadparm_service *service, struct parm_struct *parm)
3542 if (lp_ctx->s3_fns) {
3543 return lp_ctx->s3_fns->get_parm_ptr(service, parm);
3546 if (service == NULL) {
3547 if (parm->p_class == P_LOCAL)
3548 return ((char *)lp_ctx->sDefault)+parm->offset;
3549 else if (parm->p_class == P_GLOBAL)
3550 return ((char *)lp_ctx->globals)+parm->offset;
3553 return ((char *)service) + parm->offset;
3558 return the parameter pointer for a parameter
3560 bool lpcfg_parm_is_cmdline(struct loadparm_context *lp_ctx, const char *name)
3564 if (lp_ctx->s3_fns) {
3565 struct parm_struct *parm = lp_ctx->s3_fns->get_parm_struct(name);
3567 return parm->flags & FLAG_CMDLINE;
3572 parmnum = map_parameter(name);
3573 if (parmnum == -1) return false;
3575 return lp_ctx->flags[parmnum] & FLAG_CMDLINE;
3579 * Find a service by name. Otherwise works like get_service.
3582 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
3583 const char *pszServiceName)
3587 if (lp_ctx->s3_fns) {
3588 return lp_ctx->s3_fns->get_service(pszServiceName);
3591 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--)
3592 if (lp_ctx->services[iService] != NULL &&
3593 strwicmp(lp_ctx->services[iService]->szService, pszServiceName) == 0) {
3594 return lp_ctx->services[iService];
3601 * Copy a service structure to another.
3602 * If pcopymapDest is NULL then copy all fields
3605 static void copy_service(struct loadparm_service *pserviceDest,
3606 struct loadparm_service *pserviceSource,
3607 struct bitmap *pcopymapDest)
3610 bool bcopyall = (pcopymapDest == NULL);
3611 struct parmlist_entry *data, *pdata, *paramo;
3614 for (i = 0; parm_table[i].label; i++)
3615 if (parm_table[i].p_class == P_LOCAL &&
3616 (bcopyall || bitmap_query(pcopymapDest, i))) {
3618 ((char *)pserviceSource) + parm_table[i].offset;
3620 ((char *)pserviceDest) + parm_table[i].offset;
3622 switch (parm_table[i].type) {
3624 *(bool *)dest_ptr = *(bool *)src_ptr;
3631 *(int *)dest_ptr = *(int *)src_ptr;
3635 lpcfg_string_set(pserviceDest,
3641 lpcfg_string_set_upper(pserviceDest,
3646 *(const char ***)dest_ptr = (const char **)str_list_copy(pserviceDest,
3647 *(const char ***)src_ptr);
3655 init_copymap(pserviceDest);
3656 if (pserviceSource->copymap)
3657 bitmap_copy(pserviceDest->copymap,
3658 pserviceSource->copymap);
3661 data = pserviceSource->param_opt;
3664 pdata = pserviceDest->param_opt;
3665 /* Traverse destination */
3667 /* If we already have same option, override it */
3668 if (strcmp(pdata->key, data->key) == 0) {
3669 talloc_free(pdata->value);
3670 pdata->value = talloc_strdup(pdata,
3675 pdata = pdata->next;
3678 paramo = talloc_zero(pserviceDest, struct parmlist_entry);
3681 paramo->key = talloc_strdup(paramo, data->key);
3682 paramo->value = talloc_strdup(paramo, data->value);
3683 DLIST_ADD(pserviceDest->param_opt, paramo);
3690 * Check a service for consistency. Return False if the service is in any way
3691 * incomplete or faulty, else True.
3693 static bool lpcfg_service_ok(struct loadparm_service *service)
3698 if (service->szService[0] == '\0') {
3699 DEBUG(0, ("The following message indicates an internal error:\n"));
3700 DEBUG(0, ("No service name in service entry.\n"));
3704 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
3705 /* I can't see why you'd want a non-printable printer service... */
3706 if (strwicmp(service->szService, PRINTERS_NAME) == 0) {
3707 if (!service->bPrint_ok) {
3708 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
3709 service->szService));
3710 service->bPrint_ok = true;
3712 /* [printers] service must also be non-browsable. */
3713 if (service->bBrowseable)
3714 service->bBrowseable = false;
3717 /* If a service is flagged unavailable, log the fact at level 0. */
3718 if (!service->bAvailable)
3719 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
3720 service->szService));
3726 /*******************************************************************
3727 Keep a linked list of all config files so we know when one has changed
3728 it's date and needs to be reloaded.
3729 ********************************************************************/
3731 static void add_to_file_list(struct loadparm_context *lp_ctx,
3732 const char *fname, const char *subfname)
3734 struct file_lists *f = lp_ctx->file_lists;
3737 if (f->name && !strcmp(f->name, fname))
3743 f = talloc(lp_ctx, struct file_lists);
3746 f->next = lp_ctx->file_lists;
3747 f->name = talloc_strdup(f, fname);
3752 f->subfname = talloc_strdup(f, subfname);
3757 lp_ctx->file_lists = f;
3758 f->modtime = file_modtime(subfname);
3760 time_t t = file_modtime(subfname);
3766 /*******************************************************************
3767 Check if a config file has changed date.
3768 ********************************************************************/
3769 bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx)
3771 struct file_lists *f;
3772 DEBUG(6, ("lp_file_list_changed()\n"));
3774 for (f = lp_ctx->file_lists; f != NULL; f = f->next) {
3778 n2 = standard_sub_basic(lp_ctx, f->name);
3780 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
3781 f->name, n2, ctime(&f->modtime)));
3783 mod_time = file_modtime(n2);
3785 if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
3786 DEBUGADD(6, ("file %s modified: %s\n", n2,
3788 f->modtime = mod_time;
3789 talloc_free(f->subfname);
3790 f->subfname = talloc_strdup(f, n2);
3797 /***************************************************************************
3798 Handle the "realm" parameter
3799 ***************************************************************************/
3801 static bool handle_realm(struct loadparm_context *lp_ctx, int unused,
3802 const char *pszParmValue, char **ptr)
3804 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
3806 talloc_free(lp_ctx->globals->szRealm_upper);
3807 talloc_free(lp_ctx->globals->szRealm_lower);
3809 lp_ctx->globals->szRealm_upper = strupper_talloc(lp_ctx, pszParmValue);
3810 lp_ctx->globals->szRealm_lower = strlower_talloc(lp_ctx, pszParmValue);
3815 /***************************************************************************
3816 Handle the include operation.
3817 ***************************************************************************/
3819 static bool handle_include(struct loadparm_context *lp_ctx, int unused,
3820 const char *pszParmValue, char **ptr)
3822 char *fname = standard_sub_basic(lp_ctx, pszParmValue);
3824 add_to_file_list(lp_ctx, pszParmValue, fname);
3826 lpcfg_string_set(lp_ctx, ptr, fname);
3828 if (file_exist(fname))
3829 return pm_process(fname, do_section, do_parameter, lp_ctx);
3831 DEBUG(2, ("Can't find include file %s\n", fname));
3836 /***************************************************************************
3837 Handle the interpretation of the copy parameter.
3838 ***************************************************************************/
3840 static bool handle_copy(struct loadparm_context *lp_ctx, int unused,
3841 const char *pszParmValue, char **ptr)
3844 struct loadparm_service *serviceTemp;
3846 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
3850 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
3852 if ((serviceTemp = getservicebyname(lp_ctx, pszParmValue)) != NULL) {
3853 if (serviceTemp == lp_ctx->currentService) {
3854 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
3856 copy_service(lp_ctx->currentService,
3858 lp_ctx->currentService->copymap);
3862 DEBUG(0, ("Unable to copy service - source not found: %s\n",
3870 static bool handle_debuglevel(struct loadparm_context *lp_ctx, int unused,
3871 const char *pszParmValue, char **ptr)
3874 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
3875 if (lp_ctx->global) {
3876 return debug_parse_levels(pszParmValue);
3881 static bool handle_logfile(struct loadparm_context *lp_ctx, int unused,
3882 const char *pszParmValue, char **ptr)
3884 debug_set_logfile(pszParmValue);
3885 if (lp_ctx->global) {
3886 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
3891 /***************************************************************************
3892 Initialise a copymap.
3893 ***************************************************************************/
3895 static void init_copymap(struct loadparm_service *pservice)
3899 TALLOC_FREE(pservice->copymap);
3901 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
3902 if (!pservice->copymap)
3904 ("Couldn't allocate copymap!! (size %d)\n",
3905 (int)NUMPARAMETERS));
3907 for (i = 0; i < NUMPARAMETERS; i++)
3908 bitmap_set(pservice->copymap, i);
3912 * Process a parametric option
3914 static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
3915 struct loadparm_service *service,
3916 const char *pszParmName,
3917 const char *pszParmValue, int flags)
3919 struct parmlist_entry *paramo, *data;
3921 TALLOC_CTX *mem_ctx;
3923 while (isspace((unsigned char)*pszParmName)) {
3927 name = strlower_talloc(lp_ctx, pszParmName);
3928 if (!name) return false;
3930 if (service == NULL) {
3931 data = lp_ctx->globals->param_opt;
3932 mem_ctx = lp_ctx->globals;
3934 data = service->param_opt;
3938 /* Traverse destination */
3939 for (paramo=data; paramo; paramo=paramo->next) {
3940 /* If we already have the option set, override it unless
3941 it was a command line option and the new one isn't */
3942 if (strcmp(paramo->key, name) == 0) {
3943 if ((paramo->priority & FLAG_CMDLINE) &&
3944 !(flags & FLAG_CMDLINE)) {
3949 talloc_free(paramo->value);
3950 paramo->value = talloc_strdup(paramo, pszParmValue);
3951 paramo->priority = flags;
3957 paramo = talloc_zero(mem_ctx, struct parmlist_entry);
3960 paramo->key = talloc_strdup(paramo, name);
3961 paramo->value = talloc_strdup(paramo, pszParmValue);
3962 paramo->priority = flags;
3963 if (service == NULL) {
3964 DLIST_ADD(lp_ctx->globals->param_opt, paramo);
3966 DLIST_ADD(service->param_opt, paramo);
3974 static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
3975 const char *pszParmName, const char *pszParmValue,
3976 struct loadparm_context *lp_ctx, bool on_globals)
3979 /* if it is a special case then go ahead */
3980 if (parm_table[parmnum].special) {
3982 ret = parm_table[parmnum].special(lp_ctx, -1, pszParmValue,
3987 goto mark_non_default;
3990 /* now switch on the type of variable it is */
3991 switch (parm_table[parmnum].type)
3995 if (!set_boolean(pszParmValue, &b)) {
3996 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
3999 *(bool *)parm_ptr = b;
4005 if (!set_boolean(pszParmValue, &b)) {
4006 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
4009 *(bool *)parm_ptr = !b;
4014 *(int *)parm_ptr = atoi(pszParmValue);
4018 *(char *)parm_ptr = *pszParmValue;
4022 *(int *)parm_ptr = strtol(pszParmValue, NULL, 8);
4028 if (conv_str_size_error(pszParmValue, &val)) {
4029 if (val <= INT_MAX) {
4030 *(int *)parm_ptr = (int)val;
4035 DEBUG(0,("lp_do_parameter(%s): value is not "
4036 "a valid size specifier!\n", pszParmValue));
4041 *(const char ***)parm_ptr = (const char **)str_list_make(mem_ctx,
4042 pszParmValue, NULL);
4046 char **new_list = str_list_make(mem_ctx,
4047 pszParmValue, NULL);
4048 for (i=0; new_list[i]; i++) {
4049 if (new_list[i][0] == '+' && new_list[i][1]) {
4050 if (!str_list_check(*(const char ***)parm_ptr,
4052 *(const char ***)parm_ptr = str_list_add(*(const char ***)parm_ptr,
4055 } else if (new_list[i][0] == '-' && new_list[i][1]) {
4056 str_list_remove(*(const char ***)parm_ptr,
4060 DEBUG(0, ("Unsupported list syntax for: %s = %s\n",
4061 pszParmName, pszParmValue));
4064 *(const char ***)parm_ptr = (const char **) new_list;
4071 lpcfg_string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
4075 lpcfg_string_set_upper(mem_ctx, (char **)parm_ptr, pszParmValue);
4079 for (i = 0; parm_table[parmnum].enum_list[i].name; i++) {
4082 parm_table[parmnum].enum_list[i].name)) {
4084 parm_table[parmnum].
4089 if (!parm_table[parmnum].enum_list[i].name) {
4090 DEBUG(0,("Unknown enumerated value '%s' for '%s'\n",
4091 pszParmValue, pszParmName));
4101 if (on_globals && (lp_ctx->flags[parmnum] & FLAG_DEFAULT)) {
4102 lp_ctx->flags[parmnum] &= ~FLAG_DEFAULT;
4103 /* we have to also unset FLAG_DEFAULT on aliases */
4104 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
4105 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
4107 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
4108 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
4115 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
4116 const char *pszParmName, const char *pszParmValue)
4118 int parmnum = map_parameter(pszParmName);
4122 if (strchr(pszParmName, ':')) {
4123 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName, pszParmValue, 0);
4125 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
4129 /* if the flag has been set on the command line, then don't allow override,
4130 but don't report an error */
4131 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
4135 parm_ptr = lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[parmnum]);
4137 return set_variable(lp_ctx->globals, parmnum, parm_ptr,
4138 pszParmName, pszParmValue, lp_ctx, true);
4141 bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
4142 struct loadparm_service *service,
4143 const char *pszParmName, const char *pszParmValue)
4147 int parmnum = map_parameter(pszParmName);
4150 if (strchr(pszParmName, ':')) {
4151 return lp_do_parameter_parametric(lp_ctx, service, pszParmName, pszParmValue, 0);
4153 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
4157 /* if the flag has been set on the command line, then don't allow override,
4158 but don't report an error */
4159 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
4163 if (parm_table[parmnum].p_class == P_GLOBAL) {
4165 ("Global parameter %s found in service section!\n",
4169 parm_ptr = ((char *)service) + parm_table[parmnum].offset;
4171 if (!service->copymap)
4172 init_copymap(service);
4174 /* this handles the aliases - set the copymap for other
4175 * entries with the same data pointer */
4176 for (i = 0; parm_table[i].label; i++)
4177 if (parm_table[i].offset == parm_table[parmnum].offset &&
4178 parm_table[i].p_class == parm_table[parmnum].p_class)
4179 bitmap_clear(service->copymap, i);
4181 return set_variable(service, parmnum, parm_ptr, pszParmName,
4182 pszParmValue, lp_ctx, false);
4186 * Process a parameter.
4189 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
4192 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
4194 if (lp_ctx->bInGlobalSection)
4195 return lpcfg_do_global_parameter(lp_ctx, pszParmName,
4198 return lpcfg_do_service_parameter(lp_ctx, lp_ctx->currentService,
4199 pszParmName, pszParmValue);
4203 variable argument do parameter
4205 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx, const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
4206 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
4207 const char *pszParmName, const char *fmt, ...)
4214 s = talloc_vasprintf(NULL, fmt, ap);
4216 ret = lpcfg_do_global_parameter(lp_ctx, pszParmName, s);
4223 set a parameter from the commandline - this is called from command line parameter
4224 parsing code. It sets the parameter then marks the parameter as unable to be modified
4225 by smb.conf processing
4227 bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
4228 const char *pszParmValue)
4233 if (lp_ctx->s3_fns) {
4234 return lp_ctx->s3_fns->set_cmdline(pszParmName, pszParmValue);
4237 parmnum = map_parameter(pszParmName);
4239 while (isspace((unsigned char)*pszParmValue)) pszParmValue++;
4242 if (parmnum < 0 && strchr(pszParmName, ':')) {
4243 /* set a parametric option */
4244 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
4245 pszParmValue, FLAG_CMDLINE);
4249 DEBUG(0,("Unknown option '%s'\n", pszParmName));
4253 /* reset the CMDLINE flag in case this has been called before */
4254 lp_ctx->flags[parmnum] &= ~FLAG_CMDLINE;
4256 if (!lpcfg_do_global_parameter(lp_ctx, pszParmName, pszParmValue)) {
4260 lp_ctx->flags[parmnum] |= FLAG_CMDLINE;
4262 /* we have to also set FLAG_CMDLINE on aliases */
4263 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
4264 lp_ctx->flags[i] |= FLAG_CMDLINE;
4266 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
4267 lp_ctx->flags[i] |= FLAG_CMDLINE;
4274 set a option from the commandline in 'a=b' format. Use to support --option
4276 bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option)
4281 s = talloc_strdup(NULL, option);
4294 ret = lpcfg_set_cmdline(lp_ctx, s, p+1);
4300 #define BOOLSTR(b) ((b) ? "Yes" : "No")
4303 * Print a parameter of the specified type.
4306 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
4308 /* For the seperation of lists values that we print below */
4309 const char *list_sep = ", ";
4314 for (i = 0; p->enum_list[i].name; i++) {
4315 if (*(int *)ptr == p->enum_list[i].value) {
4317 p->enum_list[i].name);
4324 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
4328 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
4333 fprintf(f, "%d", *(int *)ptr);
4337 fprintf(f, "%c", *(char *)ptr);
4341 int val = *(int *)ptr;
4345 fprintf(f, "0%o", val);
4354 if ((char ***)ptr && *(char ***)ptr) {
4355 char **list = *(char ***)ptr;
4356 for (; *list; list++) {
4357 /* surround strings with whitespace in double quotes */
4358 if (*(list+1) == NULL) {
4359 /* last item, no extra separator */
4362 if ( strchr_m( *list, ' ' ) ) {
4363 fprintf(f, "\"%s\"%s", *list, list_sep);
4365 fprintf(f, "%s%s", *list, list_sep);
4373 if (*(char **)ptr) {
4374 fprintf(f, "%s", *(char **)ptr);
4383 * Check if two parameters are equal.
4386 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
4391 return (*((bool *)ptr1) == *((bool *)ptr2));
4397 return (*((int *)ptr1) == *((int *)ptr2));
4400 return (*((char *)ptr1) == *((char *)ptr2));
4404 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
4409 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
4414 return (p1 == p2 || strequal(p1, p2));
4423 * Process a new section (service).
4425 * At this stage all sections are services.
4426 * Later we'll have special sections that permit server parameters to be set.
4427 * Returns True on success, False on failure.
4430 static bool do_section(const char *pszSectionName, void *userdata)
4432 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
4434 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
4435 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
4438 /* if we've just struck a global section, note the fact. */
4439 lp_ctx->bInGlobalSection = isglobal;
4441 /* check for multiple global sections */
4442 if (lp_ctx->bInGlobalSection) {
4443 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
4447 /* if we have a current service, tidy it up before moving on */
4450 if (lp_ctx->currentService != NULL)
4451 bRetval = lpcfg_service_ok(lp_ctx->currentService);
4453 /* if all is still well, move to the next record in the services array */
4455 /* We put this here to avoid an odd message order if messages are */
4456 /* issued by the post-processing of a previous section. */
4457 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
4459 if ((lp_ctx->currentService = lpcfg_add_service(lp_ctx, lp_ctx->sDefault,
4462 DEBUG(0, ("Failed to add a new service\n"));
4472 * Determine if a particular base parameter is currently set to the default value.
4475 static bool is_default(struct loadparm_service *sDefault, int i)
4477 void *def_ptr = ((char *)sDefault) + parm_table[i].offset;
4478 if (!defaults_saved)
4480 switch (parm_table[i].type) {
4483 return str_list_equal((const char **)parm_table[i].def.lvalue,
4484 (const char **)def_ptr);
4487 return strequal(parm_table[i].def.svalue,
4491 return parm_table[i].def.bvalue ==
4498 return parm_table[i].def.ivalue ==
4507 *Display the contents of the global structure.
4510 static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
4514 struct parmlist_entry *data;
4516 fprintf(f, "# Global parameters\n[global]\n");
4518 for (i = 0; parm_table[i].label; i++)
4519 if (parm_table[i].p_class == P_GLOBAL &&
4520 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
4521 if (!show_defaults && (lp_ctx->flags[i] & FLAG_DEFAULT))
4523 fprintf(f, "\t%s = ", parm_table[i].label);
4524 print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f);
4527 if (lp_ctx->globals->param_opt != NULL) {
4528 for (data = lp_ctx->globals->param_opt; data;
4529 data = data->next) {
4530 if (!show_defaults && (data->priority & FLAG_DEFAULT)) {
4533 fprintf(f, "\t%s = %s\n", data->key, data->value);
4540 * Display the contents of a single services record.
4543 static void dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f,
4544 unsigned int *flags)
4547 struct parmlist_entry *data;
4549 if (pService != sDefault)
4550 fprintf(f, "\n[%s]\n", pService->szService);
4552 for (i = 0; parm_table[i].label; i++) {
4553 if (parm_table[i].p_class == P_LOCAL &&
4554 (*parm_table[i].label != '-') &&
4555 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
4557 if (pService == sDefault) {
4558 if (flags && (flags[i] & FLAG_DEFAULT)) {
4561 if (defaults_saved) {
4562 if (is_default(sDefault, i)) {
4567 if (equal_parameter(parm_table[i].type,
4568 ((char *)pService) +
4569 parm_table[i].offset,
4570 ((char *)sDefault) +
4571 parm_table[i].offset))
4575 fprintf(f, "\t%s = ", parm_table[i].label);
4576 print_parameter(&parm_table[i],
4577 ((char *)pService) + parm_table[i].offset, f);
4581 if (pService->param_opt != NULL) {
4582 for (data = pService->param_opt; data; data = data->next) {
4583 fprintf(f, "\t%s = %s\n", data->key, data->value);
4588 bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
4589 struct loadparm_service *service,
4590 const char *parm_name, FILE * f)
4592 struct parm_struct *parm;
4595 parm = lpcfg_parm_struct(lp_ctx, parm_name);
4600 ptr = lpcfg_parm_ptr(lp_ctx, service,parm);
4602 print_parameter(parm, ptr, f);
4608 * Return info about the next parameter in a service.
4609 * snum==-1 gives the globals.
4610 * Return NULL when out of parameters.
4614 struct parm_struct *lpcfg_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
4618 /* do the globals */
4619 for (; parm_table[*i].label; (*i)++) {
4620 if ((*parm_table[*i].label == '-'))
4624 && (parm_table[*i].offset ==
4625 parm_table[(*i) - 1].offset)
4626 && (parm_table[*i].p_class ==
4627 parm_table[(*i) - 1].p_class))
4630 return &parm_table[(*i)++];
4633 struct loadparm_service *pService = lp_ctx->services[snum];
4635 for (; parm_table[*i].label; (*i)++) {
4636 if (parm_table[*i].p_class == P_LOCAL &&
4637 (*parm_table[*i].label != '-') &&
4639 (parm_table[*i].offset !=
4640 parm_table[(*i) - 1].offset)))
4642 if (allparameters ||
4643 !equal_parameter(parm_table[*i].type,
4644 ((char *)pService) +
4645 parm_table[*i].offset,
4646 ((char *)lp_ctx->sDefault) +
4647 parm_table[*i].offset))
4649 return &parm_table[(*i)++];
4660 * Auto-load some home services.
4662 static void lpcfg_add_auto_services(struct loadparm_context *lp_ctx,
4670 * Unload unused services.
4673 void lpcfg_killunused(struct loadparm_context *lp_ctx,
4674 struct smbsrv_connection *smb,
4675 bool (*snumused) (struct smbsrv_connection *, int))
4678 for (i = 0; i < lp_ctx->iNumServices; i++) {
4679 if (lp_ctx->services[i] == NULL)
4682 if (!snumused || !snumused(smb, i)) {
4683 talloc_free(lp_ctx->services[i]);
4684 lp_ctx->services[i] = NULL;
4690 static int lpcfg_destructor(struct loadparm_context *lp_ctx)
4692 struct parmlist_entry *data;
4694 if (lp_ctx->refuse_free) {
4695 /* someone is trying to free the
4696 global_loadparm_context.
4697 We can't allow that. */
4701 if (lp_ctx->globals->param_opt != NULL) {
4702 struct parmlist_entry *next;
4703 for (data = lp_ctx->globals->param_opt; data; data=next) {
4705 if (data->priority & FLAG_CMDLINE) continue;
4706 DLIST_REMOVE(lp_ctx->globals->param_opt, data);
4715 * Initialise the global parameter structure.
4717 * Note that most callers should use loadparm_init_global() instead
4719 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
4723 struct loadparm_context *lp_ctx;
4724 struct parmlist_entry *parm;
4727 lp_ctx = talloc_zero(mem_ctx, struct loadparm_context);
4731 talloc_set_destructor(lp_ctx, lpcfg_destructor);
4732 lp_ctx->bInGlobalSection = true;
4733 lp_ctx->globals = talloc_zero(lp_ctx, struct loadparm_global);
4734 lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service);
4736 lp_ctx->sDefault->iMaxPrintJobs = 1000;
4737 lp_ctx->sDefault->bAvailable = true;
4738 lp_ctx->sDefault->bBrowseable = true;
4739 lp_ctx->sDefault->bRead_only = true;
4740 lp_ctx->sDefault->bMap_archive = true;
4741 lp_ctx->sDefault->iStrictLocking = true;
4742 lp_ctx->sDefault->bOpLocks = true;
4743 lp_ctx->sDefault->iCreate_mask = 0744;
4744 lp_ctx->sDefault->iCreate_force_mode = 0000;
4745 lp_ctx->sDefault->iDir_mask = 0755;
4746 lp_ctx->sDefault->iDir_force_mode = 0000;
4748 DEBUG(3, ("Initialising global parameters\n"));
4750 for (i = 0; parm_table[i].label; i++) {
4751 if ((parm_table[i].type == P_STRING ||
4752 parm_table[i].type == P_USTRING) &&
4753 !(lp_ctx->flags[i] & FLAG_CMDLINE)) {
4755 if (parm_table[i].p_class == P_LOCAL) {
4756 r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset);
4758 r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset);
4760 *r = talloc_strdup(lp_ctx, "");
4764 logfile = talloc_asprintf(lp_ctx, "%s/log.samba", dyn_LOGFILEBASE);
4765 lpcfg_do_global_parameter(lp_ctx, "log file", logfile);
4766 talloc_free(logfile);
4768 lpcfg_do_global_parameter(lp_ctx, "log level", "0");
4770 lpcfg_do_global_parameter(lp_ctx, "share backend", "classic");
4772 lpcfg_do_global_parameter(lp_ctx, "server role", "auto");
4773 lpcfg_do_global_parameter(lp_ctx, "domain logons", "No");
4774 lpcfg_do_global_parameter(lp_ctx, "domain master", "Auto");
4776 /* options that can be set on the command line must be initialised via
4777 the slower lpcfg_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
4779 lpcfg_do_global_parameter(lp_ctx, "socket options", "TCP_NODELAY");
4781 lpcfg_do_global_parameter(lp_ctx, "workgroup", DEFAULT_WORKGROUP);
4782 myname = get_myname(lp_ctx);
4783 lpcfg_do_global_parameter(lp_ctx, "netbios name", myname);
4784 talloc_free(myname);
4785 lpcfg_do_global_parameter(lp_ctx, "name resolve order", "wins host bcast");
4787 lpcfg_do_global_parameter(lp_ctx, "fstype", "NTFS");
4789 lpcfg_do_global_parameter(lp_ctx, "ntvfs handler", "unixuid default");
4790 lpcfg_do_global_parameter(lp_ctx, "max connections", "-1");
4792 lpcfg_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi dssetup unixinfo browser eventlog6 backupkey dnsserver");
4793 lpcfg_do_global_parameter(lp_ctx, "server services", "s3fs rpc nbt wrepl ldap cldap kdc drepl winbind ntp_signd kcc dnsupdate");
4794 /* the winbind method for domain controllers is for both RODC
4795 auth forwarding and for trusted domains */
4796 lpcfg_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR);
4797 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
4799 /* This hive should be dynamically generated by Samba using
4800 data from the sam, but for the moment leave it in a tdb to
4801 keep regedt32 from popping up an annoying dialog. */
4802 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_USERS", "hku.ldb");
4804 /* using UTF8 by default allows us to support all chars */
4805 lpcfg_do_global_parameter(lp_ctx, "unix charset", "UTF8");
4807 /* Use codepage 850 as a default for the dos character set */
4808 lpcfg_do_global_parameter(lp_ctx, "dos charset", "CP850");
4811 * Allow the default PASSWD_CHAT to be overridden in local.h.
4813 lpcfg_do_global_parameter(lp_ctx, "passwd chat", DEFAULT_PASSWD_CHAT);
4815 lpcfg_do_global_parameter(lp_ctx, "pid directory", dyn_PIDDIR);
4816 lpcfg_do_global_parameter(lp_ctx, "lock dir", dyn_LOCKDIR);
4817 lpcfg_do_global_parameter(lp_ctx, "state directory", dyn_STATEDIR);
4818 lpcfg_do_global_parameter(lp_ctx, "cache directory", dyn_CACHEDIR);
4819 lpcfg_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
4821 lpcfg_do_global_parameter(lp_ctx, "socket address", "");
4822 lpcfg_do_global_parameter_var(lp_ctx, "server string",
4823 "Samba %s", SAMBA_VERSION_STRING);
4825 lpcfg_do_global_parameter(lp_ctx, "password server", "*");
4827 lpcfg_do_global_parameter(lp_ctx, "max mux", "50");
4828 lpcfg_do_global_parameter(lp_ctx, "max xmit", "12288");
4829 lpcfg_do_global_parameter(lp_ctx, "host msdfs", "true");
4831 lpcfg_do_global_parameter(lp_ctx, "password level", "0");
4832 lpcfg_do_global_parameter(lp_ctx, "LargeReadwrite", "True");
4833 lpcfg_do_global_parameter(lp_ctx, "server min protocol", "CORE");
4834 lpcfg_do_global_parameter(lp_ctx, "server max protocol", "NT1");
4835 lpcfg_do_global_parameter(lp_ctx, "client min protocol", "CORE");
4836 lpcfg_do_global_parameter(lp_ctx, "client max protocol", "NT1");
4837 lpcfg_do_global_parameter(lp_ctx, "security", "AUTO");
4838 lpcfg_do_global_parameter(lp_ctx, "paranoid server security", "True");
4839 lpcfg_do_global_parameter(lp_ctx, "EncryptPasswords", "True");
4840 lpcfg_do_global_parameter(lp_ctx, "ReadRaw", "True");
4841 lpcfg_do_global_parameter(lp_ctx, "WriteRaw", "True");
4842 lpcfg_do_global_parameter(lp_ctx, "NullPasswords", "False");
4843 lpcfg_do_global_parameter(lp_ctx, "ObeyPamRestrictions", "False");
4845 lpcfg_do_global_parameter(lp_ctx, "TimeServer", "False");
4846 lpcfg_do_global_parameter(lp_ctx, "BindInterfacesOnly", "False");
4847 lpcfg_do_global_parameter(lp_ctx, "Unicode", "True");
4848 lpcfg_do_global_parameter(lp_ctx, "ClientLanManAuth", "False");
4849 lpcfg_do_global_parameter(lp_ctx, "ClientNTLMv2Auth", "True");
4850 lpcfg_do_global_parameter(lp_ctx, "LanmanAuth", "False");
4851 lpcfg_do_global_parameter(lp_ctx, "NTLMAuth", "True");
4852 lpcfg_do_global_parameter(lp_ctx, "client use spnego principal", "False");
4854 lpcfg_do_global_parameter(lp_ctx, "UnixExtensions", "False");
4856 lpcfg_do_global_parameter(lp_ctx, "PreferredMaster", "Auto");
4857 lpcfg_do_global_parameter(lp_ctx, "LocalMaster", "True");
4859 lpcfg_do_global_parameter(lp_ctx, "wins support", "False");
4860 lpcfg_do_global_parameter(lp_ctx, "dns proxy", "True");
4862 lpcfg_do_global_parameter(lp_ctx, "winbind separator", "\\");
4863 lpcfg_do_global_parameter(lp_ctx, "winbind sealed pipes", "True");
4864 lpcfg_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
4865 #if _SAMBA_BUILD_ >= 4
4866 lpcfg_do_global_parameter(lp_ctx, "winbindd privileged socket directory", dyn_WINBINDD_PRIVILEGED_SOCKET_DIR);
4867 lpcfg_do_global_parameter(lp_ctx, "ntp signd socket directory", dyn_NTP_SIGND_SOCKET_DIR);
4868 lpcfg_do_global_parameter_var(lp_ctx, "dns update command", "%s/samba_dnsupdate", dyn_SCRIPTSBINDIR);
4869 lpcfg_do_global_parameter_var(lp_ctx, "spn update command", "%s/samba_spnupdate", dyn_SCRIPTSBINDIR);
4870 lpcfg_do_global_parameter_var(lp_ctx, "samba kcc command",
4871 "%s/samba_kcc", dyn_SCRIPTSBINDIR);
4873 lpcfg_do_global_parameter(lp_ctx, "template shell", "/bin/false");
4874 lpcfg_do_global_parameter(lp_ctx, "template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%");
4876 lpcfg_do_global_parameter(lp_ctx, "client signing", "default");
4877 lpcfg_do_global_parameter(lp_ctx, "server signing", "default");
4879 lpcfg_do_global_parameter(lp_ctx, "use spnego", "True");
4881 lpcfg_do_global_parameter(lp_ctx, "use mmap", "True");
4883 lpcfg_do_global_parameter(lp_ctx, "smb ports", "445 139");
4884 lpcfg_do_global_parameter(lp_ctx, "nbt port", "137");
4885 lpcfg_do_global_parameter(lp_ctx, "dgram port", "138");
4886 lpcfg_do_global_parameter(lp_ctx, "cldap port", "389");
4887 lpcfg_do_global_parameter(lp_ctx, "krb5 port", "88");
4888 lpcfg_do_global_parameter(lp_ctx, "kpasswd port", "464");
4889 lpcfg_do_global_parameter(lp_ctx, "web port", "901");
4891 lpcfg_do_global_parameter(lp_ctx, "nt status support", "True");
4893 lpcfg_do_global_parameter(lp_ctx, "max wins ttl", "518400"); /* 6 days */
4894 lpcfg_do_global_parameter(lp_ctx, "min wins ttl", "10");
4896 lpcfg_do_global_parameter(lp_ctx, "tls enabled", "True");
4897 lpcfg_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem");
4898 lpcfg_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
4899 lpcfg_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
4900 lpcfg_do_global_parameter(lp_ctx, "prefork children:smb", "4");
4902 lpcfg_do_global_parameter(lp_ctx, "rndc command", "/usr/sbin/rndc");
4903 lpcfg_do_global_parameter(lp_ctx, "nsupdate command", "/usr/bin/nsupdate -g");
4905 lpcfg_do_global_parameter(lp_ctx, "allow dns updates", "False");
4906 lpcfg_do_global_parameter(lp_ctx, "dns recursive queries", "False");
4907 lpcfg_do_global_parameter(lp_ctx, "dns forwarder", "");
4909 for (i = 0; parm_table[i].label; i++) {
4910 if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
4911 lp_ctx->flags[i] |= FLAG_DEFAULT;
4915 for (parm=lp_ctx->globals->param_opt; parm; parm=parm->next) {
4916 if (!(parm->priority & FLAG_CMDLINE)) {
4917 parm->priority |= FLAG_DEFAULT;
4925 * Initialise the global parameter structure.
4927 struct loadparm_context *loadparm_init_global(bool load_default)
4929 if (global_loadparm_context == NULL) {
4930 global_loadparm_context = loadparm_init(NULL);
4932 if (global_loadparm_context == NULL) {
4935 global_loadparm_context->global = true;
4936 if (load_default && !global_loadparm_context->loaded) {
4937 lpcfg_load_default(global_loadparm_context);
4939 global_loadparm_context->refuse_free = true;
4940 return global_loadparm_context;
4944 * Initialise the global parameter structure.
4946 struct loadparm_context *loadparm_init_s3(TALLOC_CTX *mem_ctx,
4947 const struct loadparm_s3_helpers *s3_fns)
4949 struct loadparm_context *loadparm_context = talloc_zero(mem_ctx, struct loadparm_context);
4950 if (!loadparm_context) {
4953 loadparm_context->s3_fns = s3_fns;
4954 return loadparm_context;
4957 const char *lpcfg_configfile(struct loadparm_context *lp_ctx)
4959 return lp_ctx->szConfigFile;
4962 const char *lp_default_path(void)
4964 if (getenv("SMB_CONF_PATH"))
4965 return getenv("SMB_CONF_PATH");
4967 return dyn_CONFIGFILE;
4971 * Update the internal state of a loadparm context after settings
4974 static bool lpcfg_update(struct loadparm_context *lp_ctx)
4976 struct debug_settings settings;
4977 lpcfg_add_auto_services(lp_ctx, lpcfg_auto_services(lp_ctx));
4979 if (!lp_ctx->globals->szWINSservers && lp_ctx->globals->bWINSsupport) {
4980 lpcfg_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
4983 if (!lp_ctx->global) {
4987 panic_action = lp_ctx->globals->panic_action;
4989 reload_charcnv(lp_ctx);
4991 ZERO_STRUCT(settings);
4992 /* Add any more debug-related smb.conf parameters created in
4994 settings.timestamp_logs = true;
4995 debug_set_settings(&settings);
4997 /* FIXME: This is a bit of a hack, but we can't use a global, since
4998 * not everything that uses lp also uses the socket library */
4999 if (lpcfg_parm_bool(lp_ctx, NULL, "socket", "testnonblock", false)) {
5000 setenv("SOCKET_TESTNONBLOCK", "1", 1);
5002 unsetenv("SOCKET_TESTNONBLOCK");
5008 bool lpcfg_load_default(struct loadparm_context *lp_ctx)
5012 path = lp_default_path();
5014 if (!file_exist(path)) {
5015 /* We allow the default smb.conf file to not exist,
5016 * basically the equivalent of an empty file. */
5017 return lpcfg_update(lp_ctx);
5020 return lpcfg_load(lp_ctx, path);
5024 * Load the services array from the services file.
5026 * Return True on success, False on failure.
5028 bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename)
5033 filename = talloc_strdup(lp_ctx, filename);
5035 lp_ctx->szConfigFile = filename;
5037 if (lp_ctx->s3_fns) {
5038 return lp_ctx->s3_fns->load(filename);
5041 lp_ctx->bInGlobalSection = true;
5042 n2 = standard_sub_basic(lp_ctx, lp_ctx->szConfigFile);
5043 DEBUG(2, ("lpcfg_load: refreshing parameters from %s\n", n2));
5045 add_to_file_list(lp_ctx, lp_ctx->szConfigFile, n2);
5047 /* We get sections first, so have to start 'behind' to make up */
5048 lp_ctx->currentService = NULL;
5049 bRetval = pm_process(n2, do_section, do_parameter, lp_ctx);
5051 /* finish up the last section */
5052 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
5054 if (lp_ctx->currentService != NULL)
5055 bRetval = lpcfg_service_ok(lp_ctx->currentService);
5057 bRetval = bRetval && lpcfg_update(lp_ctx);
5059 /* we do this unconditionally, so that it happens even
5060 for a missing smb.conf */
5061 reload_charcnv(lp_ctx);
5063 if (bRetval == true) {
5064 /* set this up so that any child python tasks will
5065 find the right smb.conf */
5066 setenv("SMB_CONF_PATH", filename, 1);
5068 /* set the context used by the lp_*() function
5070 global_loadparm_context = lp_ctx;
5071 lp_ctx->loaded = true;
5078 * Return the max number of services.
5081 int lpcfg_numservices(struct loadparm_context *lp_ctx)
5083 if (lp_ctx->s3_fns) {
5084 return lp_ctx->s3_fns->get_numservices();
5087 return lp_ctx->iNumServices;
5091 * Display the contents of the services array in human-readable form.
5094 void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
5099 if (lp_ctx->s3_fns) {
5100 lp_ctx->s3_fns->dump(f, show_defaults, maxtoprint);
5104 defaults_saved = !show_defaults;
5106 dump_globals(lp_ctx, f, show_defaults);
5108 dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f, lp_ctx->flags);
5110 for (iService = 0; iService < maxtoprint; iService++)
5111 lpcfg_dump_one(f, show_defaults, lp_ctx->services[iService], lp_ctx->sDefault);
5115 * Display the contents of one service in human-readable form.
5117 void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault)
5119 if (service != NULL) {
5120 if (service->szService[0] == '\0')
5122 dump_a_service(service, sDefault, f, NULL);
5126 struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
5129 if (lp_ctx->s3_fns) {
5130 return lp_ctx->s3_fns->get_servicebynum(snum);
5133 return lp_ctx->services[snum];
5136 struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
5137 const char *service_name)
5142 if (lp_ctx->s3_fns) {
5143 return lp_ctx->s3_fns->get_service(service_name);
5146 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
5147 if (lp_ctx->services[iService] &&
5148 lp_ctx->services[iService]->szService) {
5150 * The substitution here is used to support %U is
5153 serviceName = standard_sub_basic(
5154 lp_ctx->services[iService],
5155 lp_ctx->services[iService]->szService);
5156 if (strequal(serviceName, service_name)) {
5157 talloc_free(serviceName);
5158 return lp_ctx->services[iService];
5160 talloc_free(serviceName);
5164 DEBUG(7,("lpcfg_servicenumber: couldn't find %s\n", service_name));
5168 const char *lpcfg_servicename(const struct loadparm_service *service)
5170 return lp_string((const char *)service->szService);
5174 * A useful volume label function.
5176 const char *lpcfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault)
5179 ret = lp_string((const char *)((service != NULL && service->volume != NULL) ?
5180 service->volume : sDefault->volume));
5182 return lpcfg_servicename(service);
5187 * If we are PDC then prefer us as DMB
5189 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault)
5192 ret = lp_string((const char *)((service != NULL && service->szPrintername != NULL) ?
5193 service->szPrintername : sDefault->szPrintername));
5194 if (ret == NULL || (ret != NULL && *ret == '\0'))
5195 ret = lpcfg_servicename(service);
5202 * Return the max print jobs per queue.
5204 int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault)
5206 int maxjobs = (service != NULL) ? service->iMaxPrintJobs : sDefault->iMaxPrintJobs;
5207 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
5208 maxjobs = PRINT_MAX_JOBID - 1;
5213 struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx)
5215 if (lp_ctx == NULL) {
5216 return get_iconv_handle();
5218 return lp_ctx->iconv_handle;
5221 _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
5223 struct smb_iconv_handle *old_ic = lp_ctx->iconv_handle;
5224 if (!lp_ctx->global) {
5228 if (old_ic == NULL) {
5229 old_ic = global_iconv_handle;
5231 lp_ctx->iconv_handle = smb_iconv_handle_reinit_lp(lp_ctx, lp_ctx, old_ic);
5232 global_iconv_handle = lp_ctx->iconv_handle;
5235 _PUBLIC_ char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
5237 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_keyfile);
5240 _PUBLIC_ char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
5242 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_certfile);
5245 _PUBLIC_ char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
5247 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_cafile);
5250 _PUBLIC_ char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
5252 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_crlfile);
5255 _PUBLIC_ char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
5257 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_dhpfile);
5260 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
5262 struct gensec_settings *settings = talloc_zero(mem_ctx, struct gensec_settings);
5263 if (settings == NULL)
5265 SMB_ASSERT(lp_ctx != NULL);
5266 settings->lp_ctx = talloc_reference(settings, lp_ctx);
5267 settings->target_hostname = lpcfg_parm_string(lp_ctx, NULL, "gensec", "target_hostname");
5271 int lpcfg_server_role(struct loadparm_context *lp_ctx)
5273 int domain_master = lpcfg__domain_master(lp_ctx);
5275 return lp_find_server_role(lpcfg__server_role(lp_ctx),
5276 lpcfg__security(lp_ctx),
5277 lpcfg__domain_logons(lp_ctx),
5278 (domain_master == true) ||
5279 (domain_master == Auto));
5282 int lpcfg_security(struct loadparm_context *lp_ctx)
5284 return lp_find_security(lpcfg__server_role(lp_ctx),
5285 lpcfg__security(lp_ctx));