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 char *szPrintcapname; \
82 int iPreferredMaster; \
83 char *szLdapMachineSuffix; \
84 char *szLdapUserSuffix; \
85 char *szLdapIdmapSuffix; \
86 char *szLdapGroupSuffix; \
87 char *szUsershareTemplateShare; \
90 int winbindMaxDomainConnections; \
99 #include "lib/param/param_global.h"
101 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
103 /* we don't need a special handler for "dos charset" and "unix charset" */
104 #define handle_dos_charset NULL
105 #define handle_charset NULL
107 /* these are parameter handlers which are not needed in the
110 #define handle_netbios_aliases NULL
111 #define handle_debug_list NULL
112 #define handle_printing NULL
113 #define handle_ldap_debug_level NULL
114 #define handle_idmap_backend NULL
115 #define handle_idmap_uid NULL
116 #define handle_idmap_gid NULL
122 /* prototypes for the special type handlers */
123 static bool handle_include(struct loadparm_context
*lp_ctx
, int unused
,
124 const char *pszParmValue
, char **ptr
);
125 static bool handle_realm(struct loadparm_context
*lp_ctx
, int unused
,
126 const char *pszParmValue
, char **ptr
);
127 static bool handle_copy(struct loadparm_context
*lp_ctx
, int unused
,
128 const char *pszParmValue
, char **ptr
);
129 static bool handle_debuglevel(struct loadparm_context
*lp_ctx
, int unused
,
130 const char *pszParmValue
, char **ptr
);
131 static bool handle_logfile(struct loadparm_context
*lp_ctx
, int unused
,
132 const char *pszParmValue
, char **ptr
);
134 #include "lib/param/param_table.c"
136 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
137 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
139 static struct parm_struct parm_table
[] = {
141 .label
= "server role",
144 .offset
= GLOBAL_VAR(server_role
),
146 .enum_list
= enum_server_role
149 .label
= "dos charset",
152 .offset
= GLOBAL_VAR(dos_charset
),
157 .label
= "unix charset",
160 .offset
= GLOBAL_VAR(unix_charset
),
168 .offset
= LOCAL_VAR(comment
),
171 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
177 .offset
= LOCAL_VAR(szPath
),
180 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
183 .label
= "directory",
186 .offset
= LOCAL_VAR(szPath
),
192 .label
= "workgroup",
195 .offset
= GLOBAL_VAR(szWorkgroup
),
198 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
204 .offset
= GLOBAL_VAR(szRealm
),
205 .special
= handle_realm
,
207 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
210 .label
= "netbios name",
213 .offset
= GLOBAL_VAR(szNetbiosName
),
216 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
219 .label
= "netbios aliases",
222 .offset
= GLOBAL_VAR(szNetbiosAliases
),
227 .label
= "netbios scope",
230 .offset
= GLOBAL_VAR(szNetbiosScope
),
233 .flags
= FLAG_ADVANCED
,
236 .label
= "server string",
239 .offset
= GLOBAL_VAR(szServerString
),
242 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
245 .label
= "interfaces",
248 .offset
= GLOBAL_VAR(szInterfaces
),
251 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
254 .label
= "bind interfaces only",
257 .offset
= GLOBAL_VAR(bBindInterfacesOnly
),
260 .flags
= FLAG_ADVANCED
| FLAG_WIZARD
,
263 .label
= "passdb backend",
266 .offset
= GLOBAL_VAR(passdb_backend
),
275 .offset
= GLOBAL_VAR(security
),
277 .enum_list
= enum_security
280 .label
= "encrypt passwords",
283 .offset
= GLOBAL_VAR(bEncryptPasswords
),
288 .label
= "null passwords",
291 .offset
= GLOBAL_VAR(bNullPasswords
),
294 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
297 .label
= "obey pam restrictions",
300 .offset
= GLOBAL_VAR(bObeyPamRestrictions
),
303 .flags
= FLAG_ADVANCED
,
306 .label
= "password server",
309 .offset
= GLOBAL_VAR(szPasswordServer
),
314 .label
= "private dir",
317 .offset
= GLOBAL_VAR(szPrivateDir
),
322 .label
= "passwd chat",
325 .offset
= GLOBAL_VAR(szPasswdChat
),
330 .label
= "password level",
333 .offset
= GLOBAL_VAR(pwordlevel
),
338 .label
= "lanman auth",
341 .offset
= GLOBAL_VAR(bLanmanAuth
),
344 .flags
= FLAG_ADVANCED
,
347 .label
= "ntlm auth",
350 .offset
= GLOBAL_VAR(bNTLMAuth
),
353 .flags
= FLAG_ADVANCED
,
356 .label
= "client NTLMv2 auth",
359 .offset
= GLOBAL_VAR(bClientNTLMv2Auth
),
362 .flags
= FLAG_ADVANCED
,
365 .label
= "client lanman auth",
368 .offset
= GLOBAL_VAR(bClientLanManAuth
),
371 .flags
= FLAG_ADVANCED
,
374 .label
= "client plaintext auth",
377 .offset
= GLOBAL_VAR(bClientPlaintextAuth
),
380 .flags
= FLAG_ADVANCED
,
383 .label
= "client use spnego principal",
386 .offset
= GLOBAL_VAR(client_use_spnego_principal
),
392 .label
= "read only",
395 .offset
= LOCAL_VAR(bRead_only
),
401 .label
= "create mask",
404 .offset
= LOCAL_VAR(iCreate_mask
),
409 .label
= "force create mode",
412 .offset
= LOCAL_VAR(iCreate_force_mode
),
417 .label
= "directory mask",
420 .offset
= LOCAL_VAR(iDir_mask
),
425 .label
= "force directory mode",
428 .offset
= LOCAL_VAR(iDir_force_mode
),
434 .label
= "hosts allow",
437 .offset
= LOCAL_VAR(szHostsallow
),
442 .label
= "hosts deny",
445 .offset
= LOCAL_VAR(szHostsdeny
),
451 .label
= "log level",
454 .offset
= GLOBAL_VAR(loglevel
),
455 .special
= handle_debuglevel
,
459 .label
= "debuglevel",
462 .offset
= GLOBAL_VAR(loglevel
),
463 .special
= handle_debuglevel
,
470 .offset
= GLOBAL_VAR(logfile
),
471 .special
= handle_logfile
,
473 .flags
= FLAG_ADVANCED
,
477 .label
= "smb ports",
480 .offset
= GLOBAL_VAR(smb_ports
),
488 .offset
= GLOBAL_VAR(nbt_port
),
493 .label
= "dgram port",
496 .offset
= GLOBAL_VAR(dgram_port
),
501 .label
= "cldap port",
504 .offset
= GLOBAL_VAR(cldap_port
),
509 .label
= "krb5 port",
512 .offset
= GLOBAL_VAR(krb5_port
),
517 .label
= "kpasswd port",
520 .offset
= GLOBAL_VAR(kpasswd_port
),
528 .offset
= GLOBAL_VAR(web_port
),
533 .label
= "large readwrite",
536 .offset
= GLOBAL_VAR(bLargeReadwrite
),
539 .flags
= FLAG_ADVANCED
,
542 .label
= "server max protocol",
545 .offset
= GLOBAL_VAR(srv_maxprotocol
),
547 .enum_list
= enum_protocol
,
548 .flags
= FLAG_ADVANCED
,
551 .label
= "max protocol",
554 .offset
= GLOBAL_VAR(srv_maxprotocol
),
556 .enum_list
= enum_protocol
,
557 .flags
= FLAG_ADVANCED
,
563 .offset
= GLOBAL_VAR(srv_maxprotocol
),
565 .enum_list
= enum_protocol
,
566 .flags
= FLAG_ADVANCED
,
569 .label
= "server min protocol",
572 .offset
= GLOBAL_VAR(srv_minprotocol
),
574 .enum_list
= enum_protocol
,
575 .flags
= FLAG_ADVANCED
,
578 .label
= "min protocol",
581 .offset
= GLOBAL_VAR(srv_minprotocol
),
583 .enum_list
= enum_protocol
,
584 .flags
= FLAG_ADVANCED
,
587 .label
= "client max protocol",
590 .offset
= GLOBAL_VAR(cli_maxprotocol
),
592 .enum_list
= enum_protocol
595 .label
= "client min protocol",
598 .offset
= GLOBAL_VAR(cli_minprotocol
),
600 .enum_list
= enum_protocol
606 .offset
= GLOBAL_VAR(bUnicode
),
614 .offset
= GLOBAL_VAR(bReadRaw
),
619 .label
= "write raw",
622 .offset
= GLOBAL_VAR(bWriteRaw
),
627 .label
= "disable netbios",
630 .offset
= GLOBAL_VAR(bDisableNetbios
),
636 .label
= "nt status support",
639 .offset
= GLOBAL_VAR(bNTStatusSupport
),
648 .offset
= GLOBAL_VAR(max_mux
),
651 .flags
= FLAG_ADVANCED
,
657 .offset
= GLOBAL_VAR(max_xmit
),
660 .flags
= FLAG_ADVANCED
,
664 .label
= "name resolve order",
667 .offset
= GLOBAL_VAR(szNameResolveOrder
),
672 .label
= "max wins ttl",
675 .offset
= GLOBAL_VAR(max_wins_ttl
),
678 .flags
= FLAG_ADVANCED
,
681 .label
= "min wins ttl",
684 .offset
= GLOBAL_VAR(min_wins_ttl
),
687 .flags
= FLAG_ADVANCED
,
690 .label
= "time server",
693 .offset
= GLOBAL_VAR(bTimeServer
),
696 .flags
= FLAG_ADVANCED
,
699 .label
= "unix extensions",
702 .offset
= GLOBAL_VAR(bUnixExtensions
),
705 .flags
= FLAG_ADVANCED
,
708 .label
= "use spnego",
711 .offset
= GLOBAL_VAR(bUseSpnego
),
716 .label
= "server signing",
719 .offset
= GLOBAL_VAR(server_signing
),
721 .enum_list
= enum_smb_signing_vals
,
722 .flags
= FLAG_ADVANCED
,
725 .label
= "client signing",
728 .offset
= GLOBAL_VAR(client_signing
),
730 .enum_list
= enum_smb_signing_vals
733 .label
= "rpc big endian",
736 .offset
= GLOBAL_VAR(bRpcBigEndian
),
742 .label
= "max connections",
745 .offset
= LOCAL_VAR(iMaxConnections
),
748 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
751 .label
= "paranoid server security",
754 .offset
= GLOBAL_VAR(paranoid_server_security
),
759 .label
= "socket options",
762 .offset
= GLOBAL_VAR(socket_options
),
768 .label
= "strict sync",
771 .offset
= LOCAL_VAR(bStrictSync
),
779 .offset
= GLOBAL_VAR(bUseMmap
),
782 .flags
= FLAG_ADVANCED
,
785 {N_("Printing Options"), P_SEP
, P_SEPARATOR
},
788 .label
= "max reported print jobs",
791 .offset
= LOCAL_VAR(iMaxReportedPrintJobs
),
794 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
797 .label
= "max print jobs",
800 .offset
= LOCAL_VAR(iMaxPrintJobs
),
803 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
806 .label
= "load printers",
809 .offset
= GLOBAL_VAR(bLoadPrinters
),
812 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
815 .label
= "printcap cache time",
818 .offset
= GLOBAL_VAR(PrintcapCacheTime
),
821 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
824 .label
= "printcap name",
827 .offset
= GLOBAL_VAR(szPrintcapname
),
830 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
836 .offset
= GLOBAL_VAR(szPrintcapname
),
842 .label
= "printable",
845 .offset
= LOCAL_VAR(bPrint_ok
),
848 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
851 .label
= "print notify backchannel",
854 .offset
= LOCAL_VAR(bPrintNotifyBackchannel
),
857 .flags
= FLAG_ADVANCED
,
863 .offset
= LOCAL_VAR(bPrint_ok
),
872 .offset
= LOCAL_VAR(iPrinting
),
873 .special
= handle_printing
,
874 .enum_list
= enum_printing
,
875 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
878 .label
= "cups options",
881 .offset
= LOCAL_VAR(szCupsOptions
),
884 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
887 .label
= "cups server",
890 .offset
= GLOBAL_VAR(szCupsServer
),
893 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
896 .label
= "cups encrypt",
899 .offset
= GLOBAL_VAR(CupsEncrypt
),
901 .enum_list
= enum_bool_auto
,
902 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
906 .label
= "cups connection timeout",
909 .offset
= GLOBAL_VAR(cups_connection_timeout
),
912 .flags
= FLAG_ADVANCED
,
915 .label
= "iprint server",
918 .offset
= GLOBAL_VAR(szIPrintServer
),
921 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
924 .label
= "print command",
927 .offset
= LOCAL_VAR(szPrintcommand
),
930 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
933 .label
= "disable spoolss",
936 .offset
= GLOBAL_VAR(bDisableSpoolss
),
939 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
942 .label
= "enable spoolss",
945 .offset
= GLOBAL_VAR(bDisableSpoolss
),
951 .label
= "lpq command",
954 .offset
= LOCAL_VAR(szLpqcommand
),
957 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
960 .label
= "lprm command",
963 .offset
= LOCAL_VAR(szLprmcommand
),
966 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
969 .label
= "lppause command",
972 .offset
= LOCAL_VAR(szLppausecommand
),
975 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
978 .label
= "lpresume command",
981 .offset
= LOCAL_VAR(szLpresumecommand
),
984 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
987 .label
= "queuepause command",
990 .offset
= LOCAL_VAR(szQueuepausecommand
),
993 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
996 .label
= "queueresume command",
999 .offset
= LOCAL_VAR(szQueueresumecommand
),
1002 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
1005 .label
= "addport command",
1007 .p_class
= P_GLOBAL
,
1008 .offset
= GLOBAL_VAR(szAddPortCommand
),
1011 .flags
= FLAG_ADVANCED
,
1014 .label
= "enumports command",
1016 .p_class
= P_GLOBAL
,
1017 .offset
= GLOBAL_VAR(szEnumPortsCommand
),
1020 .flags
= FLAG_ADVANCED
,
1023 .label
= "addprinter command",
1025 .p_class
= P_GLOBAL
,
1026 .offset
= GLOBAL_VAR(szAddPrinterCommand
),
1029 .flags
= FLAG_ADVANCED
,
1032 .label
= "deleteprinter command",
1034 .p_class
= P_GLOBAL
,
1035 .offset
= GLOBAL_VAR(szDeletePrinterCommand
),
1038 .flags
= FLAG_ADVANCED
,
1041 .label
= "show add printer wizard",
1043 .p_class
= P_GLOBAL
,
1044 .offset
= GLOBAL_VAR(bMsAddPrinterWizard
),
1047 .flags
= FLAG_ADVANCED
,
1050 .label
= "os2 driver map",
1052 .p_class
= P_GLOBAL
,
1053 .offset
= GLOBAL_VAR(szOs2DriverMap
),
1056 .flags
= FLAG_ADVANCED
,
1060 .label
= "printer name",
1063 .offset
= LOCAL_VAR(szPrintername
),
1066 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
1072 .offset
= LOCAL_VAR(szPrintername
),
1078 .label
= "use client driver",
1081 .offset
= LOCAL_VAR(bUseClientDriver
),
1084 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
1087 .label
= "default devmode",
1090 .offset
= LOCAL_VAR(bDefaultDevmode
),
1093 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
1096 .label
= "force printername",
1099 .offset
= LOCAL_VAR(bForcePrintername
),
1102 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
1105 .label
= "printjob username",
1108 .offset
= LOCAL_VAR(szPrintjobUsername
),
1111 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
1114 {N_("Filename Handling"), P_SEP
, P_SEPARATOR
},
1117 .label
= "mangling method",
1119 .p_class
= P_GLOBAL
,
1120 .offset
= GLOBAL_VAR(szManglingMethod
),
1123 .flags
= FLAG_ADVANCED
,
1126 .label
= "mangle prefix",
1128 .p_class
= P_GLOBAL
,
1129 .offset
= GLOBAL_VAR(mangle_prefix
),
1132 .flags
= FLAG_ADVANCED
,
1136 .label
= "default case",
1139 .offset
= LOCAL_VAR(iDefaultCase
),
1141 .enum_list
= enum_case
,
1142 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1145 .label
= "case sensitive",
1148 .offset
= LOCAL_VAR(iCaseSensitive
),
1150 .enum_list
= enum_bool_auto
,
1151 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1154 .label
= "casesignames",
1157 .offset
= LOCAL_VAR(iCaseSensitive
),
1159 .enum_list
= enum_bool_auto
,
1160 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
| FLAG_HIDE
,
1163 .label
= "preserve case",
1166 .offset
= LOCAL_VAR(bCasePreserve
),
1169 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1172 .label
= "short preserve case",
1175 .offset
= LOCAL_VAR(bShortCasePreserve
),
1178 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1181 .label
= "mangling char",
1184 .offset
= LOCAL_VAR(magic_char
),
1187 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1190 .label
= "hide dot files",
1193 .offset
= LOCAL_VAR(bHideDotFiles
),
1196 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1199 .label
= "hide special files",
1202 .offset
= LOCAL_VAR(bHideSpecialFiles
),
1205 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1208 .label
= "hide unreadable",
1211 .offset
= LOCAL_VAR(bHideUnReadable
),
1214 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1217 .label
= "hide unwriteable files",
1220 .offset
= LOCAL_VAR(bHideUnWriteableFiles
),
1223 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1226 .label
= "delete veto files",
1229 .offset
= LOCAL_VAR(bDeleteVetoFiles
),
1232 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1235 .label
= "veto files",
1238 .offset
= LOCAL_VAR(szVetoFiles
),
1241 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1244 .label
= "hide files",
1247 .offset
= LOCAL_VAR(szHideFiles
),
1250 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1253 .label
= "veto oplock files",
1256 .offset
= LOCAL_VAR(szVetoOplockFiles
),
1259 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1262 .label
= "map archive",
1265 .offset
= LOCAL_VAR(bMap_archive
),
1268 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1271 .label
= "map hidden",
1274 .offset
= LOCAL_VAR(bMap_hidden
),
1277 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1280 .label
= "map system",
1283 .offset
= LOCAL_VAR(bMap_system
),
1286 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1289 .label
= "map readonly",
1292 .offset
= LOCAL_VAR(iMap_readonly
),
1294 .enum_list
= enum_map_readonly
,
1295 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1298 .label
= "mangled names",
1301 .offset
= LOCAL_VAR(bMangledNames
),
1304 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1307 .label
= "max stat cache size",
1309 .p_class
= P_GLOBAL
,
1310 .offset
= GLOBAL_VAR(iMaxStatCacheSize
),
1313 .flags
= FLAG_ADVANCED
,
1316 .label
= "stat cache",
1318 .p_class
= P_GLOBAL
,
1319 .offset
= GLOBAL_VAR(bStatCache
),
1322 .flags
= FLAG_ADVANCED
,
1325 .label
= "store dos attributes",
1328 .offset
= LOCAL_VAR(bStoreDosAttributes
),
1331 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1334 .label
= "dmapi support",
1337 .offset
= LOCAL_VAR(bDmapiSupport
),
1340 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1344 {N_("Domain Options"), P_SEP
, P_SEPARATOR
},
1347 .label
= "machine password timeout",
1349 .p_class
= P_GLOBAL
,
1350 .offset
= GLOBAL_VAR(machine_password_timeout
),
1353 .flags
= FLAG_ADVANCED
| FLAG_WIZARD
,
1356 {N_("Logon Options"), P_SEP
, P_SEPARATOR
},
1359 .label
= "add user script",
1361 .p_class
= P_GLOBAL
,
1362 .offset
= GLOBAL_VAR(szAddUserScript
),
1365 .flags
= FLAG_ADVANCED
,
1368 .label
= "rename user script",
1370 .p_class
= P_GLOBAL
,
1371 .offset
= GLOBAL_VAR(szRenameUserScript
),
1374 .flags
= FLAG_ADVANCED
,
1377 .label
= "delete user script",
1379 .p_class
= P_GLOBAL
,
1380 .offset
= GLOBAL_VAR(szDelUserScript
),
1383 .flags
= FLAG_ADVANCED
,
1386 .label
= "add group script",
1388 .p_class
= P_GLOBAL
,
1389 .offset
= GLOBAL_VAR(szAddGroupScript
),
1392 .flags
= FLAG_ADVANCED
,
1395 .label
= "delete group script",
1397 .p_class
= P_GLOBAL
,
1398 .offset
= GLOBAL_VAR(szDelGroupScript
),
1401 .flags
= FLAG_ADVANCED
,
1404 .label
= "add user to group script",
1406 .p_class
= P_GLOBAL
,
1407 .offset
= GLOBAL_VAR(szAddUserToGroupScript
),
1410 .flags
= FLAG_ADVANCED
,
1413 .label
= "delete user from group script",
1415 .p_class
= P_GLOBAL
,
1416 .offset
= GLOBAL_VAR(szDelUserFromGroupScript
),
1419 .flags
= FLAG_ADVANCED
,
1422 .label
= "set primary group script",
1424 .p_class
= P_GLOBAL
,
1425 .offset
= GLOBAL_VAR(szSetPrimaryGroupScript
),
1428 .flags
= FLAG_ADVANCED
,
1431 .label
= "add machine script",
1433 .p_class
= P_GLOBAL
,
1434 .offset
= GLOBAL_VAR(szAddMachineScript
),
1437 .flags
= FLAG_ADVANCED
,
1440 .label
= "shutdown script",
1442 .p_class
= P_GLOBAL
,
1443 .offset
= GLOBAL_VAR(szShutdownScript
),
1446 .flags
= FLAG_ADVANCED
,
1449 .label
= "abort shutdown script",
1451 .p_class
= P_GLOBAL
,
1452 .offset
= GLOBAL_VAR(szAbortShutdownScript
),
1455 .flags
= FLAG_ADVANCED
,
1458 .label
= "username map script",
1460 .p_class
= P_GLOBAL
,
1461 .offset
= GLOBAL_VAR(szUsernameMapScript
),
1464 .flags
= FLAG_ADVANCED
,
1467 .label
= "username map cache time",
1469 .p_class
= P_GLOBAL
,
1470 .offset
= GLOBAL_VAR(iUsernameMapCacheTime
),
1473 .flags
= FLAG_ADVANCED
,
1476 .label
= "logon script",
1478 .p_class
= P_GLOBAL
,
1479 .offset
= GLOBAL_VAR(szLogonScript
),
1482 .flags
= FLAG_ADVANCED
,
1485 .label
= "logon path",
1487 .p_class
= P_GLOBAL
,
1488 .offset
= GLOBAL_VAR(szLogonPath
),
1491 .flags
= FLAG_ADVANCED
,
1494 .label
= "logon drive",
1496 .p_class
= P_GLOBAL
,
1497 .offset
= GLOBAL_VAR(szLogonDrive
),
1500 .flags
= FLAG_ADVANCED
,
1503 .label
= "logon home",
1505 .p_class
= P_GLOBAL
,
1506 .offset
= GLOBAL_VAR(szLogonHome
),
1509 .flags
= FLAG_ADVANCED
,
1512 .label
= "domain logons",
1514 .p_class
= P_GLOBAL
,
1515 .offset
= GLOBAL_VAR(bDomainLogons
),
1518 .flags
= FLAG_ADVANCED
,
1522 .label
= "init logon delayed hosts",
1524 .p_class
= P_GLOBAL
,
1525 .offset
= GLOBAL_VAR(szInitLogonDelayedHosts
),
1528 .flags
= FLAG_ADVANCED
,
1532 .label
= "init logon delay",
1534 .p_class
= P_GLOBAL
,
1535 .offset
= GLOBAL_VAR(InitLogonDelay
),
1538 .flags
= FLAG_ADVANCED
,
1542 {N_("Browse Options"), P_SEP
, P_SEPARATOR
},
1545 .label
= "os level",
1547 .p_class
= P_GLOBAL
,
1548 .offset
= GLOBAL_VAR(os_level
),
1551 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
1554 .label
= "lm announce",
1556 .p_class
= P_GLOBAL
,
1557 .offset
= GLOBAL_VAR(lm_announce
),
1559 .enum_list
= enum_bool_auto
,
1560 .flags
= FLAG_ADVANCED
,
1563 .label
= "lm interval",
1565 .p_class
= P_GLOBAL
,
1566 .offset
= GLOBAL_VAR(lm_interval
),
1569 .flags
= FLAG_ADVANCED
,
1572 .label
= "preferred master",
1574 .p_class
= P_GLOBAL
,
1575 .offset
= GLOBAL_VAR(iPreferredMaster
),
1577 .enum_list
= enum_bool_auto
,
1578 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
1581 .label
= "prefered master",
1583 .p_class
= P_GLOBAL
,
1584 .offset
= GLOBAL_VAR(iPreferredMaster
),
1586 .enum_list
= enum_bool_auto
,
1590 .label
= "local master",
1592 .p_class
= P_GLOBAL
,
1593 .offset
= GLOBAL_VAR(bLocalMaster
),
1596 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
1599 .label
= "domain master",
1601 .p_class
= P_GLOBAL
,
1602 .offset
= GLOBAL_VAR(domain_master
),
1604 .enum_list
= enum_bool_auto
,
1605 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
1608 .label
= "browse list",
1610 .p_class
= P_GLOBAL
,
1611 .offset
= GLOBAL_VAR(bBrowseList
),
1614 .flags
= FLAG_ADVANCED
,
1617 .label
= "browseable",
1620 .offset
= LOCAL_VAR(bBrowseable
),
1623 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
1626 .label
= "browsable",
1629 .offset
= LOCAL_VAR(bBrowseable
),
1635 .label
= "access based share enum",
1638 .offset
= LOCAL_VAR(bAccessBasedShareEnum
),
1641 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
1644 .label
= "enhanced browsing",
1646 .p_class
= P_GLOBAL
,
1647 .offset
= GLOBAL_VAR(enhanced_browsing
),
1650 .flags
= FLAG_ADVANCED
,
1653 {N_("WINS Options"), P_SEP
, P_SEPARATOR
},
1656 .label
= "dns proxy",
1658 .p_class
= P_GLOBAL
,
1659 .offset
= GLOBAL_VAR(bWINSdnsProxy
),
1662 .flags
= FLAG_ADVANCED
,
1665 .label
= "wins proxy",
1667 .p_class
= P_GLOBAL
,
1668 .offset
= GLOBAL_VAR(bWINSproxy
),
1671 .flags
= FLAG_ADVANCED
,
1674 .label
= "wins server",
1676 .p_class
= P_GLOBAL
,
1677 .offset
= GLOBAL_VAR(szWINSservers
),
1680 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
1683 .label
= "wins support",
1685 .p_class
= P_GLOBAL
,
1686 .offset
= GLOBAL_VAR(bWINSsupport
),
1689 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
1692 .label
= "wins hook",
1694 .p_class
= P_GLOBAL
,
1695 .offset
= GLOBAL_VAR(szWINSHook
),
1698 .flags
= FLAG_ADVANCED
,
1701 {N_("Locking Options"), P_SEP
, P_SEPARATOR
},
1704 .label
= "blocking locks",
1707 .offset
= LOCAL_VAR(bBlockingLocks
),
1710 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1713 .label
= "csc policy",
1716 .offset
= LOCAL_VAR(iCSCPolicy
),
1718 .enum_list
= enum_csc_policy
,
1719 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1722 .label
= "fake oplocks",
1725 .offset
= LOCAL_VAR(bFakeOplocks
),
1728 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1731 .label
= "kernel oplocks",
1734 .offset
= LOCAL_VAR(bKernelOplocks
),
1737 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1743 .offset
= LOCAL_VAR(bLocking
),
1746 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1749 .label
= "lock spin time",
1751 .p_class
= P_GLOBAL
,
1752 .offset
= GLOBAL_VAR(iLockSpinTime
),
1755 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
1761 .offset
= LOCAL_VAR(bOpLocks
),
1764 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1767 .label
= "level2 oplocks",
1770 .offset
= LOCAL_VAR(bLevel2OpLocks
),
1773 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1776 .label
= "oplock break wait time",
1778 .p_class
= P_GLOBAL
,
1779 .offset
= GLOBAL_VAR(oplock_break_wait_time
),
1782 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
1785 .label
= "oplock contention limit",
1788 .offset
= LOCAL_VAR(iOplockContentionLimit
),
1791 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1794 .label
= "posix locking",
1797 .offset
= LOCAL_VAR(bPosixLocking
),
1800 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1803 .label
= "strict locking",
1806 .offset
= LOCAL_VAR(iStrictLocking
),
1808 .enum_list
= enum_bool_auto
,
1809 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1812 {N_("Ldap Options"), P_SEP
, P_SEPARATOR
},
1815 .label
= "ldap admin dn",
1817 .p_class
= P_GLOBAL
,
1818 .offset
= GLOBAL_VAR(szLdapAdminDn
),
1821 .flags
= FLAG_ADVANCED
,
1824 .label
= "ldap delete dn",
1826 .p_class
= P_GLOBAL
,
1827 .offset
= GLOBAL_VAR(ldap_delete_dn
),
1830 .flags
= FLAG_ADVANCED
,
1833 .label
= "ldap group suffix",
1835 .p_class
= P_GLOBAL
,
1836 .offset
= GLOBAL_VAR(szLdapGroupSuffix
),
1839 .flags
= FLAG_ADVANCED
,
1842 .label
= "ldap idmap suffix",
1844 .p_class
= P_GLOBAL
,
1845 .offset
= GLOBAL_VAR(szLdapIdmapSuffix
),
1848 .flags
= FLAG_ADVANCED
,
1851 .label
= "ldap machine suffix",
1853 .p_class
= P_GLOBAL
,
1854 .offset
= GLOBAL_VAR(szLdapMachineSuffix
),
1857 .flags
= FLAG_ADVANCED
,
1860 .label
= "ldap passwd sync",
1862 .p_class
= P_GLOBAL
,
1863 .offset
= GLOBAL_VAR(ldap_passwd_sync
),
1865 .enum_list
= enum_ldap_passwd_sync
,
1866 .flags
= FLAG_ADVANCED
,
1869 .label
= "ldap password sync",
1871 .p_class
= P_GLOBAL
,
1872 .offset
= GLOBAL_VAR(ldap_passwd_sync
),
1874 .enum_list
= enum_ldap_passwd_sync
,
1878 .label
= "ldap replication sleep",
1880 .p_class
= P_GLOBAL
,
1881 .offset
= GLOBAL_VAR(ldap_replication_sleep
),
1884 .flags
= FLAG_ADVANCED
,
1887 .label
= "ldap suffix",
1889 .p_class
= P_GLOBAL
,
1890 .offset
= GLOBAL_VAR(szLdapSuffix
),
1893 .flags
= FLAG_ADVANCED
,
1896 .label
= "ldap ssl",
1898 .p_class
= P_GLOBAL
,
1899 .offset
= GLOBAL_VAR(ldap_ssl
),
1901 .enum_list
= enum_ldap_ssl
,
1902 .flags
= FLAG_ADVANCED
,
1905 .label
= "ldap ssl ads",
1907 .p_class
= P_GLOBAL
,
1908 .offset
= GLOBAL_VAR(ldap_ssl_ads
),
1911 .flags
= FLAG_ADVANCED
,
1914 .label
= "ldap deref",
1916 .p_class
= P_GLOBAL
,
1917 .offset
= GLOBAL_VAR(ldap_deref
),
1919 .enum_list
= enum_ldap_deref
,
1920 .flags
= FLAG_ADVANCED
,
1923 .label
= "ldap follow referral",
1925 .p_class
= P_GLOBAL
,
1926 .offset
= GLOBAL_VAR(ldap_follow_referral
),
1928 .enum_list
= enum_bool_auto
,
1929 .flags
= FLAG_ADVANCED
,
1932 .label
= "ldap timeout",
1934 .p_class
= P_GLOBAL
,
1935 .offset
= GLOBAL_VAR(ldap_timeout
),
1938 .flags
= FLAG_ADVANCED
,
1941 .label
= "ldap connection timeout",
1943 .p_class
= P_GLOBAL
,
1944 .offset
= GLOBAL_VAR(ldap_connection_timeout
),
1947 .flags
= FLAG_ADVANCED
,
1950 .label
= "ldap page size",
1952 .p_class
= P_GLOBAL
,
1953 .offset
= GLOBAL_VAR(ldap_page_size
),
1956 .flags
= FLAG_ADVANCED
,
1959 .label
= "ldap user suffix",
1961 .p_class
= P_GLOBAL
,
1962 .offset
= GLOBAL_VAR(szLdapUserSuffix
),
1965 .flags
= FLAG_ADVANCED
,
1968 .label
= "ldap debug level",
1970 .p_class
= P_GLOBAL
,
1971 .offset
= GLOBAL_VAR(ldap_debug_level
),
1972 .special
= handle_ldap_debug_level
,
1974 .flags
= FLAG_ADVANCED
,
1977 .label
= "ldap debug threshold",
1979 .p_class
= P_GLOBAL
,
1980 .offset
= GLOBAL_VAR(ldap_debug_threshold
),
1983 .flags
= FLAG_ADVANCED
,
1986 {N_("EventLog Options"), P_SEP
, P_SEPARATOR
},
1989 .label
= "eventlog list",
1991 .p_class
= P_GLOBAL
,
1992 .offset
= GLOBAL_VAR(szEventLogs
),
1995 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1998 {N_("Miscellaneous Options"), P_SEP
, P_SEPARATOR
},
2001 .label
= "add share command",
2003 .p_class
= P_GLOBAL
,
2004 .offset
= GLOBAL_VAR(szAddShareCommand
),
2007 .flags
= FLAG_ADVANCED
,
2010 .label
= "change share command",
2012 .p_class
= P_GLOBAL
,
2013 .offset
= GLOBAL_VAR(szChangeShareCommand
),
2016 .flags
= FLAG_ADVANCED
,
2019 .label
= "delete share command",
2021 .p_class
= P_GLOBAL
,
2022 .offset
= GLOBAL_VAR(szDeleteShareCommand
),
2025 .flags
= FLAG_ADVANCED
,
2028 .label
= "config file",
2030 .p_class
= P_GLOBAL
,
2031 .offset
= GLOBAL_VAR(szConfigFile
),
2034 .flags
= FLAG_HIDE
|FLAG_META
,
2039 .p_class
= P_GLOBAL
,
2040 .offset
= GLOBAL_VAR(szAutoServices
),
2043 .flags
= FLAG_ADVANCED
,
2046 .label
= "auto services",
2048 .p_class
= P_GLOBAL
,
2049 .offset
= GLOBAL_VAR(szAutoServices
),
2052 .flags
= FLAG_ADVANCED
,
2055 .label
= "lock directory",
2057 .p_class
= P_GLOBAL
,
2058 .offset
= GLOBAL_VAR(szLockDir
),
2061 .flags
= FLAG_ADVANCED
,
2064 .label
= "lock dir",
2066 .p_class
= P_GLOBAL
,
2067 .offset
= GLOBAL_VAR(szLockDir
),
2073 .label
= "state directory",
2075 .p_class
= P_GLOBAL
,
2076 .offset
= GLOBAL_VAR(szStateDir
),
2079 .flags
= FLAG_ADVANCED
,
2082 .label
= "cache directory",
2084 .p_class
= P_GLOBAL
,
2085 .offset
= GLOBAL_VAR(szCacheDir
),
2088 .flags
= FLAG_ADVANCED
,
2091 .label
= "pid directory",
2093 .p_class
= P_GLOBAL
,
2094 .offset
= GLOBAL_VAR(szPidDir
),
2097 .flags
= FLAG_ADVANCED
,
2100 .label
= "ntp signd socket directory",
2102 .p_class
= P_GLOBAL
,
2103 .offset
= GLOBAL_VAR(szNTPSignDSocketDirectory
),
2106 .flags
= FLAG_ADVANCED
,
2111 .label
= "utmp directory",
2113 .p_class
= P_GLOBAL
,
2114 .offset
= GLOBAL_VAR(szUtmpDir
),
2117 .flags
= FLAG_ADVANCED
,
2120 .label
= "wtmp directory",
2122 .p_class
= P_GLOBAL
,
2123 .offset
= GLOBAL_VAR(szWtmpDir
),
2126 .flags
= FLAG_ADVANCED
,
2131 .p_class
= P_GLOBAL
,
2132 .offset
= GLOBAL_VAR(bUtmp
),
2135 .flags
= FLAG_ADVANCED
,
2139 .label
= "default service",
2141 .p_class
= P_GLOBAL
,
2142 .offset
= GLOBAL_VAR(szDefaultService
),
2145 .flags
= FLAG_ADVANCED
,
2150 .p_class
= P_GLOBAL
,
2151 .offset
= GLOBAL_VAR(szDefaultService
),
2154 .flags
= FLAG_ADVANCED
,
2157 .label
= "message command",
2159 .p_class
= P_GLOBAL
,
2160 .offset
= GLOBAL_VAR(szMsgCommand
),
2163 .flags
= FLAG_ADVANCED
,
2166 .label
= "dfree cache time",
2169 .offset
= LOCAL_VAR(iDfreeCacheTime
),
2172 .flags
= FLAG_ADVANCED
,
2175 .label
= "dfree command",
2178 .offset
= LOCAL_VAR(szDfree
),
2181 .flags
= FLAG_ADVANCED
,
2184 .label
= "get quota command",
2186 .p_class
= P_GLOBAL
,
2187 .offset
= GLOBAL_VAR(szGetQuota
),
2190 .flags
= FLAG_ADVANCED
,
2193 .label
= "set quota command",
2195 .p_class
= P_GLOBAL
,
2196 .offset
= GLOBAL_VAR(szSetQuota
),
2199 .flags
= FLAG_ADVANCED
,
2202 .label
= "remote announce",
2204 .p_class
= P_GLOBAL
,
2205 .offset
= GLOBAL_VAR(szRemoteAnnounce
),
2208 .flags
= FLAG_ADVANCED
,
2211 .label
= "remote browse sync",
2213 .p_class
= P_GLOBAL
,
2214 .offset
= GLOBAL_VAR(szRemoteBrowseSync
),
2217 .flags
= FLAG_ADVANCED
,
2220 .label
= "socket address",
2222 .p_class
= P_GLOBAL
,
2223 .offset
= GLOBAL_VAR(szSocketAddress
),
2226 .flags
= FLAG_ADVANCED
,
2229 .label
= "nmbd bind explicit broadcast",
2231 .p_class
= P_GLOBAL
,
2232 .offset
= GLOBAL_VAR(bNmbdBindExplicitBroadcast
),
2235 .flags
= FLAG_ADVANCED
,
2238 .label
= "homedir map",
2240 .p_class
= P_GLOBAL
,
2241 .offset
= GLOBAL_VAR(szNISHomeMapName
),
2244 .flags
= FLAG_ADVANCED
,
2247 .label
= "afs username map",
2249 .p_class
= P_GLOBAL
,
2250 .offset
= GLOBAL_VAR(szAfsUsernameMap
),
2253 .flags
= FLAG_ADVANCED
,
2256 .label
= "afs token lifetime",
2258 .p_class
= P_GLOBAL
,
2259 .offset
= GLOBAL_VAR(iAfsTokenLifetime
),
2262 .flags
= FLAG_ADVANCED
,
2265 .label
= "log nt token command",
2267 .p_class
= P_GLOBAL
,
2268 .offset
= GLOBAL_VAR(szLogNtTokenCommand
),
2271 .flags
= FLAG_ADVANCED
,
2274 .label
= "NIS homedir",
2276 .p_class
= P_GLOBAL
,
2277 .offset
= GLOBAL_VAR(bNISHomeMap
),
2280 .flags
= FLAG_ADVANCED
,
2286 .offset
= LOCAL_VAR(valid
),
2295 .offset
= LOCAL_VAR(szCopy
),
2296 .special
= handle_copy
,
2304 .offset
= LOCAL_VAR(szInclude
),
2305 .special
= handle_include
,
2307 .flags
= FLAG_HIDE
|FLAG_META
,
2313 .offset
= LOCAL_VAR(szPreExec
),
2316 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
2322 .offset
= LOCAL_VAR(szPreExec
),
2325 .flags
= FLAG_ADVANCED
,
2328 .label
= "preexec close",
2331 .offset
= LOCAL_VAR(bPreexecClose
),
2334 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2337 .label
= "postexec",
2340 .offset
= LOCAL_VAR(szPostExec
),
2343 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
2346 .label
= "root preexec",
2349 .offset
= LOCAL_VAR(szRootPreExec
),
2352 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
2355 .label
= "root preexec close",
2358 .offset
= LOCAL_VAR(bRootpreexecClose
),
2361 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2364 .label
= "root postexec",
2367 .offset
= LOCAL_VAR(szRootPostExec
),
2370 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
2373 .label
= "available",
2376 .offset
= LOCAL_VAR(bAvailable
),
2379 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
2382 .label
= "registry shares",
2384 .p_class
= P_GLOBAL
,
2385 .offset
= GLOBAL_VAR(bRegistryShares
),
2388 .flags
= FLAG_ADVANCED
,
2391 .label
= "usershare allow guests",
2393 .p_class
= P_GLOBAL
,
2394 .offset
= GLOBAL_VAR(bUsershareAllowGuests
),
2397 .flags
= FLAG_ADVANCED
,
2400 .label
= "usershare max shares",
2402 .p_class
= P_GLOBAL
,
2403 .offset
= GLOBAL_VAR(iUsershareMaxShares
),
2406 .flags
= FLAG_ADVANCED
,
2409 .label
= "usershare owner only",
2411 .p_class
= P_GLOBAL
,
2412 .offset
= GLOBAL_VAR(bUsershareOwnerOnly
),
2415 .flags
= FLAG_ADVANCED
,
2418 .label
= "usershare path",
2420 .p_class
= P_GLOBAL
,
2421 .offset
= GLOBAL_VAR(szUsersharePath
),
2424 .flags
= FLAG_ADVANCED
,
2427 .label
= "usershare prefix allow list",
2429 .p_class
= P_GLOBAL
,
2430 .offset
= GLOBAL_VAR(szUsersharePrefixAllowList
),
2433 .flags
= FLAG_ADVANCED
,
2436 .label
= "usershare prefix deny list",
2438 .p_class
= P_GLOBAL
,
2439 .offset
= GLOBAL_VAR(szUsersharePrefixDenyList
),
2442 .flags
= FLAG_ADVANCED
,
2445 .label
= "usershare template share",
2447 .p_class
= P_GLOBAL
,
2448 .offset
= GLOBAL_VAR(szUsershareTemplateShare
),
2451 .flags
= FLAG_ADVANCED
,
2457 .offset
= LOCAL_VAR(volume
),
2460 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2466 .offset
= LOCAL_VAR(fstype
),
2469 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2472 .label
= "set directory",
2475 .offset
= LOCAL_VAR(bNo_set_dir
),
2478 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2481 .label
= "allow insecure wide links",
2483 .p_class
= P_GLOBAL
,
2484 .offset
= GLOBAL_VAR(bAllowInsecureWidelinks
),
2487 .flags
= FLAG_ADVANCED
,
2490 .label
= "wide links",
2493 .offset
= LOCAL_VAR(bWidelinks
),
2496 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2499 .label
= "follow symlinks",
2502 .offset
= LOCAL_VAR(bSymlinks
),
2505 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2508 .label
= "dont descend",
2511 .offset
= LOCAL_VAR(szDontdescend
),
2514 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2517 .label
= "magic script",
2520 .offset
= LOCAL_VAR(szMagicScript
),
2523 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2526 .label
= "magic output",
2529 .offset
= LOCAL_VAR(szMagicOutput
),
2532 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2535 .label
= "delete readonly",
2538 .offset
= LOCAL_VAR(bDeleteReadonly
),
2541 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2544 .label
= "dos filemode",
2547 .offset
= LOCAL_VAR(bDosFilemode
),
2550 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2553 .label
= "dos filetimes",
2556 .offset
= LOCAL_VAR(bDosFiletimes
),
2559 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2562 .label
= "dos filetime resolution",
2565 .offset
= LOCAL_VAR(bDosFiletimeResolution
),
2568 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2571 .label
= "fake directory create times",
2574 .offset
= LOCAL_VAR(bFakeDirCreateTimes
),
2577 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
2580 .label
= "async smb echo handler",
2582 .p_class
= P_GLOBAL
,
2583 .offset
= GLOBAL_VAR(bAsyncSMBEchoHandler
),
2586 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
2589 .label
= "panic action",
2591 .p_class
= P_GLOBAL
,
2592 .offset
= GLOBAL_VAR(szPanicAction
),
2595 .flags
= FLAG_ADVANCED
,
2598 .label
= "perfcount module",
2600 .p_class
= P_GLOBAL
,
2601 .offset
= GLOBAL_VAR(szSMBPerfcountModule
),
2604 .flags
= FLAG_ADVANCED
,
2607 {N_("VFS module options"), P_SEP
, P_SEPARATOR
},
2610 .label
= "vfs objects",
2613 .offset
= LOCAL_VAR(szVfsObjects
),
2616 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2619 .label
= "vfs object",
2622 .offset
= LOCAL_VAR(szVfsObjects
),
2629 {N_("MSDFS options"), P_SEP
, P_SEPARATOR
},
2632 .label
= "msdfs root",
2635 .offset
= LOCAL_VAR(bMSDfsRoot
),
2638 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2641 .label
= "msdfs proxy",
2644 .offset
= LOCAL_VAR(szMSDfsProxy
),
2647 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2650 .label
= "host msdfs",
2652 .p_class
= P_GLOBAL
,
2653 .offset
= GLOBAL_VAR(bHostMSDfs
),
2656 .flags
= FLAG_ADVANCED
,
2659 {N_("Winbind options"), P_SEP
, P_SEPARATOR
},
2662 .label
= "passdb expand explicit",
2664 .p_class
= P_GLOBAL
,
2665 .offset
= GLOBAL_VAR(bPassdbExpandExplicit
),
2668 .flags
= FLAG_ADVANCED
,
2671 .label
= "idmap backend",
2673 .p_class
= P_GLOBAL
,
2674 .offset
= GLOBAL_VAR(szIdmapBackend
),
2675 .special
= handle_idmap_backend
,
2677 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
2680 .label
= "idmap cache time",
2682 .p_class
= P_GLOBAL
,
2683 .offset
= GLOBAL_VAR(iIdmapCacheTime
),
2686 .flags
= FLAG_ADVANCED
,
2689 .label
= "idmap negative cache time",
2691 .p_class
= P_GLOBAL
,
2692 .offset
= GLOBAL_VAR(iIdmapNegativeCacheTime
),
2695 .flags
= FLAG_ADVANCED
,
2698 .label
= "idmap uid",
2700 .p_class
= P_GLOBAL
,
2701 .offset
= GLOBAL_VAR(szIdmapUID
),
2702 .special
= handle_idmap_uid
,
2704 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
2707 .label
= "winbind uid",
2709 .p_class
= P_GLOBAL
,
2710 .offset
= GLOBAL_VAR(szIdmapUID
),
2711 .special
= handle_idmap_uid
,
2716 .label
= "idmap gid",
2718 .p_class
= P_GLOBAL
,
2719 .offset
= GLOBAL_VAR(szIdmapGID
),
2720 .special
= handle_idmap_gid
,
2722 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
2725 .label
= "winbind gid",
2727 .p_class
= P_GLOBAL
,
2728 .offset
= GLOBAL_VAR(szIdmapGID
),
2729 .special
= handle_idmap_gid
,
2734 .label
= "template homedir",
2736 .p_class
= P_GLOBAL
,
2737 .offset
= GLOBAL_VAR(szTemplateHomedir
),
2740 .flags
= FLAG_ADVANCED
,
2743 .label
= "template shell",
2745 .p_class
= P_GLOBAL
,
2746 .offset
= GLOBAL_VAR(szTemplateShell
),
2749 .flags
= FLAG_ADVANCED
,
2752 .label
= "winbind separator",
2754 .p_class
= P_GLOBAL
,
2755 .offset
= GLOBAL_VAR(szWinbindSeparator
),
2758 .flags
= FLAG_ADVANCED
,
2761 .label
= "winbind cache time",
2763 .p_class
= P_GLOBAL
,
2764 .offset
= GLOBAL_VAR(winbind_cache_time
),
2767 .flags
= FLAG_ADVANCED
,
2770 .label
= "winbind reconnect delay",
2772 .p_class
= P_GLOBAL
,
2773 .offset
= GLOBAL_VAR(winbind_reconnect_delay
),
2776 .flags
= FLAG_ADVANCED
,
2779 .label
= "winbind max clients",
2781 .p_class
= P_GLOBAL
,
2782 .offset
= GLOBAL_VAR(winbind_max_clients
),
2785 .flags
= FLAG_ADVANCED
,
2788 .label
= "winbind enum users",
2790 .p_class
= P_GLOBAL
,
2791 .offset
= GLOBAL_VAR(bWinbindEnumUsers
),
2794 .flags
= FLAG_ADVANCED
,
2797 .label
= "winbind enum groups",
2799 .p_class
= P_GLOBAL
,
2800 .offset
= GLOBAL_VAR(bWinbindEnumGroups
),
2803 .flags
= FLAG_ADVANCED
,
2806 .label
= "winbind use default domain",
2808 .p_class
= P_GLOBAL
,
2809 .offset
= GLOBAL_VAR(bWinbindUseDefaultDomain
),
2812 .flags
= FLAG_ADVANCED
,
2815 .label
= "winbind trusted domains only",
2817 .p_class
= P_GLOBAL
,
2818 .offset
= GLOBAL_VAR(bWinbindTrustedDomainsOnly
),
2821 .flags
= FLAG_ADVANCED
,
2824 .label
= "winbind nested groups",
2826 .p_class
= P_GLOBAL
,
2827 .offset
= GLOBAL_VAR(bWinbindNestedGroups
),
2830 .flags
= FLAG_ADVANCED
,
2833 .label
= "winbind expand groups",
2835 .p_class
= P_GLOBAL
,
2836 .offset
= GLOBAL_VAR(winbind_expand_groups
),
2839 .flags
= FLAG_ADVANCED
,
2842 .label
= "winbind nss info",
2844 .p_class
= P_GLOBAL
,
2845 .offset
= GLOBAL_VAR(szWinbindNssInfo
),
2848 .flags
= FLAG_ADVANCED
,
2851 .label
= "winbind refresh tickets",
2853 .p_class
= P_GLOBAL
,
2854 .offset
= GLOBAL_VAR(bWinbindRefreshTickets
),
2857 .flags
= FLAG_ADVANCED
,
2860 .label
= "winbind offline logon",
2862 .p_class
= P_GLOBAL
,
2863 .offset
= GLOBAL_VAR(bWinbindOfflineLogon
),
2866 .flags
= FLAG_ADVANCED
,
2869 .label
= "winbind normalize names",
2871 .p_class
= P_GLOBAL
,
2872 .offset
= GLOBAL_VAR(bWinbindNormalizeNames
),
2875 .flags
= FLAG_ADVANCED
,
2878 .label
= "winbind rpc only",
2880 .p_class
= P_GLOBAL
,
2881 .offset
= GLOBAL_VAR(bWinbindRpcOnly
),
2884 .flags
= FLAG_ADVANCED
,
2887 .label
= "create krb5 conf",
2889 .p_class
= P_GLOBAL
,
2890 .offset
= GLOBAL_VAR(bCreateKrb5Conf
),
2893 .flags
= FLAG_ADVANCED
,
2896 .label
= "ncalrpc dir",
2898 .p_class
= P_GLOBAL
,
2899 .offset
= GLOBAL_VAR(ncalrpc_dir
),
2902 .flags
= FLAG_ADVANCED
,
2905 .label
= "winbind max domain connections",
2907 .p_class
= P_GLOBAL
,
2908 .offset
= GLOBAL_VAR(winbindMaxDomainConnections
),
2911 .flags
= FLAG_ADVANCED
,
2914 .label
= "winbindd socket directory",
2916 .p_class
= P_GLOBAL
,
2917 .offset
= GLOBAL_VAR(szWinbinddSocketDirectory
),
2920 .flags
= FLAG_ADVANCED
,
2923 .label
= "winbindd privileged socket directory",
2925 .p_class
= P_GLOBAL
,
2926 .offset
= GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory
),
2929 .flags
= FLAG_ADVANCED
,
2932 .label
= "winbind sealed pipes",
2934 .p_class
= P_GLOBAL
,
2935 .offset
= GLOBAL_VAR(bWinbindSealedPipes
),
2938 .flags
= FLAG_ADVANCED
,
2941 {N_("DNS options"), P_SEP
, P_SEPARATOR
},
2943 .label
= "allow dns updates",
2945 .p_class
= P_GLOBAL
,
2946 .offset
= GLOBAL_VAR(allow_dns_updates
),
2948 .enum_list
= enum_dns_update_settings
,
2949 .flags
= FLAG_ADVANCED
,
2952 .label
= "dns forwarder",
2954 .p_class
= P_GLOBAL
,
2955 .offset
= GLOBAL_VAR(dns_forwarder
),
2958 .flags
= FLAG_ADVANCED
,
2961 .label
= "dns recursive queries",
2963 .p_class
= P_GLOBAL
,
2964 .offset
= GLOBAL_VAR(dns_recursive_queries
),
2969 .label
= "dns update command",
2971 .p_class
= P_GLOBAL
,
2972 .offset
= GLOBAL_VAR(szDNSUpdateCommand
),
2975 .flags
= FLAG_ADVANCED
,
2978 .label
= "nsupdate command",
2980 .p_class
= P_GLOBAL
,
2981 .offset
= GLOBAL_VAR(szNSUpdateCommand
),
2984 .flags
= FLAG_ADVANCED
,
2987 .label
= "rndc command",
2989 .p_class
= P_GLOBAL
,
2990 .offset
= GLOBAL_VAR(szRNDCCommand
),
2993 .flags
= FLAG_ADVANCED
,
2996 .label
= "multicast dns register",
2998 .p_class
= P_GLOBAL
,
2999 .offset
= GLOBAL_VAR(bMulticastDnsRegister
),
3002 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
3005 {N_("AD DC options"), P_SEP
, P_SEPARATOR
},
3008 .label
= "samba kcc command",
3010 .p_class
= P_GLOBAL
,
3011 .offset
= GLOBAL_VAR(szSambaKCCCommand
),
3014 .flags
= FLAG_ADVANCED
,
3017 .label
= "server services",
3019 .p_class
= P_GLOBAL
,
3020 .offset
= GLOBAL_VAR(server_services
),
3025 .label
= "dcerpc endpoint servers",
3027 .p_class
= P_GLOBAL
,
3028 .offset
= GLOBAL_VAR(dcerpc_ep_servers
),
3033 .label
= "spn update command",
3035 .p_class
= P_GLOBAL
,
3036 .offset
= GLOBAL_VAR(szSPNUpdateCommand
),
3039 .flags
= FLAG_ADVANCED
,
3042 .label
= "share backend",
3044 .p_class
= P_GLOBAL
,
3045 .offset
= GLOBAL_VAR(szShareBackend
),
3050 .label
= "ntvfs handler",
3053 .offset
= LOCAL_VAR(ntvfs_handler
),
3058 {N_("TLS options"), P_SEP
, P_SEPARATOR
},
3061 .label
= "tls enabled",
3063 .p_class
= P_GLOBAL
,
3064 .offset
= GLOBAL_VAR(tls_enabled
),
3069 .label
= "tls keyfile",
3071 .p_class
= P_GLOBAL
,
3072 .offset
= GLOBAL_VAR(tls_keyfile
),
3077 .label
= "tls certfile",
3079 .p_class
= P_GLOBAL
,
3080 .offset
= GLOBAL_VAR(tls_certfile
),
3085 .label
= "tls cafile",
3087 .p_class
= P_GLOBAL
,
3088 .offset
= GLOBAL_VAR(tls_cafile
),
3093 .label
= "tls crlfile",
3095 .p_class
= P_GLOBAL
,
3096 .offset
= GLOBAL_VAR(tls_crlfile
),
3101 .label
= "tls dh params file",
3103 .p_class
= P_GLOBAL
,
3104 .offset
= GLOBAL_VAR(tls_dhpfile
),
3109 {NULL
, P_BOOL
, P_NONE
, 0, NULL
, NULL
, 0}
3113 /* local variables */
3114 struct loadparm_context
{
3115 const char *szConfigFile
;
3116 struct loadparm_global
*globals
;
3117 struct loadparm_service
**services
;
3118 struct loadparm_service
*sDefault
;
3119 struct smb_iconv_handle
*iconv_handle
;
3121 struct loadparm_service
*currentService
;
3122 bool bInGlobalSection
;
3124 struct file_lists
*next
;
3129 unsigned int flags
[NUMPARAMETERS
];
3132 bool global
; /* Is this the global context, which may set
3133 * global variables such as debug level etc? */
3134 const struct loadparm_s3_helpers
*s3_fns
;
3138 struct loadparm_service
*lpcfg_default_service(struct loadparm_context
*lp_ctx
)
3140 if (lp_ctx
->s3_fns
) {
3141 return lp_ctx
->s3_fns
->get_default_loadparm_service();
3143 return lp_ctx
->sDefault
;
3147 * Convenience routine to grab string parameters into temporary memory
3148 * and run standard_sub_basic on them.
3150 * The buffers can be written to by
3151 * callers without affecting the source string.
3154 static const char *lp_string(const char *s
)
3156 #if 0 /* until REWRITE done to make thread-safe */
3157 size_t len
= s
? strlen(s
) : 0;
3161 /* The follow debug is useful for tracking down memory problems
3162 especially if you have an inner loop that is calling a lp_*()
3163 function that returns a string. Perhaps this debug should be
3164 present all the time? */
3167 DEBUG(10, ("lp_string(%s)\n", s
));
3170 #if 0 /* until REWRITE done to make thread-safe */
3172 lp_talloc
= talloc_init("lp_talloc");
3174 ret
= talloc_array(lp_talloc
, char, len
+ 100); /* leave room for substitution */
3182 strlcpy(ret
, s
, len
);
3184 if (trim_string(ret
, "\"", "\"")) {
3185 if (strchr(ret
,'"') != NULL
)
3186 strlcpy(ret
, s
, len
);
3189 standard_sub_basic(ret
,len
+100);
3196 In this section all the functions that are used to access the
3197 parameters from the rest of the program are defined
3201 * the creation of separate lpcfg_*() and lp_*() functions is to allow
3202 * for code compatibility between existing Samba4 and Samba3 code.
3205 /* this global context supports the lp_*() function varients */
3206 static struct loadparm_context
*global_loadparm_context
;
3208 #define lpcfg_default_service global_loadparm_context->sDefault
3209 #define lpcfg_global_service(i) global_loadparm_context->services[i]
3211 #define FN_GLOBAL_STRING(fn_name,var_name) \
3212 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
3213 if (lp_ctx == NULL) return NULL; \
3214 if (lp_ctx->s3_fns) { \
3215 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
3216 return lp_ctx->s3_fns->fn_name(); \
3218 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
3221 #define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
3222 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
3223 if (lp_ctx == NULL) return NULL; \
3224 if (lp_ctx->s3_fns) { \
3225 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
3226 return lp_ctx->s3_fns->fn_name(); \
3228 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
3231 #define FN_GLOBAL_LIST(fn_name,var_name) \
3232 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
3233 if (lp_ctx == NULL) return NULL; \
3234 if (lp_ctx->s3_fns) { \
3235 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
3236 return lp_ctx->s3_fns->fn_name(); \
3238 return lp_ctx->globals->var_name; \
3241 #define FN_GLOBAL_BOOL(fn_name,var_name) \
3242 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
3243 if (lp_ctx == NULL) return false; \
3244 if (lp_ctx->s3_fns) { \
3245 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
3246 return lp_ctx->s3_fns->fn_name(); \
3248 return lp_ctx->globals->var_name; \
3251 #define FN_GLOBAL_INTEGER(fn_name,var_name) \
3252 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
3253 if (lp_ctx->s3_fns) { \
3254 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
3255 return lp_ctx->s3_fns->fn_name(); \
3257 return lp_ctx->globals->var_name; \
3260 /* Local parameters don't need the ->s3_fns because the struct
3261 * loadparm_service is shared and lpcfg_service() checks the ->s3_fns
3263 #define FN_LOCAL_STRING(fn_name,val) \
3264 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, \
3265 struct loadparm_service *sDefault) { \
3266 return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val))); \
3269 #define FN_LOCAL_CONST_STRING(fn_name,val) FN_LOCAL_STRING(fn_name, val)
3271 #define FN_LOCAL_LIST(fn_name,val) \
3272 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, \
3273 struct loadparm_service *sDefault) {\
3274 return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val); \
3277 #define FN_LOCAL_PARM_BOOL(fn_name, val) FN_LOCAL_BOOL(fn_name, val)
3279 #define FN_LOCAL_BOOL(fn_name,val) \
3280 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, \
3281 struct loadparm_service *sDefault) { \
3282 return((service != NULL)? service->val : sDefault->val); \
3285 #define FN_LOCAL_INTEGER(fn_name,val) \
3286 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, \
3287 struct loadparm_service *sDefault) { \
3288 return((service != NULL)? service->val : sDefault->val); \
3291 #define FN_LOCAL_PARM_INTEGER(fn_name, val) FN_LOCAL_INTEGER(fn_name, val)
3293 #define FN_LOCAL_PARM_CHAR(fn_name, val) FN_LOCAL_CHAR(fn_name, val)
3295 #define FN_LOCAL_CHAR(fn_name,val) \
3296 _PUBLIC_ char lpcfg_ ## fn_name(struct loadparm_service *service, \
3297 struct loadparm_service *sDefault) { \
3298 return((service != NULL)? service->val : sDefault->val); \
3301 #include "lib/param/param_functions.c"
3303 /* These functions remain only in lib/param for now */
3304 FN_GLOBAL_BOOL(readraw
, bReadRaw
)
3305 FN_GLOBAL_BOOL(writeraw
, bWriteRaw
)
3306 FN_GLOBAL_STRING(cachedir
, szCacheDir
)
3307 FN_GLOBAL_STRING(socket_address
, szSocketAddress
)
3308 FN_GLOBAL_STRING(statedir
, szStateDir
)
3310 /* local prototypes */
3311 static int map_parameter(const char *pszParmName
);
3312 static struct loadparm_service
*getservicebyname(struct loadparm_context
*lp_ctx
,
3313 const char *pszServiceName
);
3314 static void copy_service(struct loadparm_service
*pserviceDest
,
3315 struct loadparm_service
*pserviceSource
,
3316 struct bitmap
*pcopymapDest
);
3317 static bool lpcfg_service_ok(struct loadparm_service
*service
);
3318 static bool do_section(const char *pszSectionName
, void *);
3319 static void init_copymap(struct loadparm_service
*pservice
);
3321 /* This is a helper function for parametrical options support. */
3322 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
3323 /* Actual parametrical functions are quite simple */
3324 const char *lpcfg_get_parametric(struct loadparm_context
*lp_ctx
,
3325 struct loadparm_service
*service
,
3326 const char *type
, const char *option
)
3328 char *vfskey_tmp
= NULL
;
3329 char *vfskey
= NULL
;
3330 struct parmlist_entry
*data
;
3335 if (lp_ctx
->s3_fns
) {
3336 return lp_ctx
->s3_fns
->get_parametric(service
, type
, option
);
3339 data
= (service
== NULL
? lp_ctx
->globals
->param_opt
: service
->param_opt
);
3341 vfskey_tmp
= talloc_asprintf(NULL
, "%s:%s", type
, option
);
3342 if (vfskey_tmp
== NULL
) return NULL
;
3343 vfskey
= strlower_talloc(NULL
, vfskey_tmp
);
3344 talloc_free(vfskey_tmp
);
3347 if (strcmp(data
->key
, vfskey
) == 0) {
3348 talloc_free(vfskey
);
3354 if (service
!= NULL
) {
3355 /* Try to fetch the same option but from globals */
3356 /* but only if we are not already working with globals */
3357 for (data
= lp_ctx
->globals
->param_opt
; data
;
3358 data
= data
->next
) {
3359 if (strcmp(data
->key
, vfskey
) == 0) {
3360 talloc_free(vfskey
);
3366 talloc_free(vfskey
);
3373 * convenience routine to return int parameters.
3375 static int lp_int(const char *s
)
3379 DEBUG(0,("lp_int(%s): is called with NULL!\n",s
));
3383 return strtol(s
, NULL
, 0);
3387 * convenience routine to return unsigned long parameters.
3389 static unsigned long lp_ulong(const char *s
)
3393 DEBUG(0,("lp_ulong(%s): is called with NULL!\n",s
));
3397 return strtoul(s
, NULL
, 0);
3401 * convenience routine to return unsigned long parameters.
3403 static long lp_long(const char *s
)
3407 DEBUG(0,("lp_long(%s): is called with NULL!\n",s
));
3411 return strtol(s
, NULL
, 0);
3415 * convenience routine to return unsigned long parameters.
3417 static double lp_double(const char *s
)
3421 DEBUG(0,("lp_double(%s): is called with NULL!\n",s
));
3425 return strtod(s
, NULL
);
3429 * convenience routine to return boolean parameters.
3431 static bool lp_bool(const char *s
)
3436 DEBUG(0,("lp_bool(%s): is called with NULL!\n",s
));
3440 if (!set_boolean(s
, &ret
)) {
3441 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s
));
3450 * Return parametric option from a given service. Type is a part of option before ':'
3451 * Parametric option has following syntax: 'Type: option = value'
3452 * Returned value is allocated in 'lp_talloc' context
3455 const char *lpcfg_parm_string(struct loadparm_context
*lp_ctx
,
3456 struct loadparm_service
*service
, const char *type
,
3459 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
3462 return lp_string(value
);
3468 * Return parametric option from a given service. Type is a part of option before ':'
3469 * Parametric option has following syntax: 'Type: option = value'
3470 * Returned value is allocated in 'lp_talloc' context
3473 const char **lpcfg_parm_string_list(TALLOC_CTX
*mem_ctx
,
3474 struct loadparm_context
*lp_ctx
,
3475 struct loadparm_service
*service
,
3477 const char *option
, const char *separator
)
3479 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
3482 return (const char **)str_list_make(mem_ctx
, value
, separator
);
3488 * Return parametric option from a given service. Type is a part of option before ':'
3489 * Parametric option has following syntax: 'Type: option = value'
3492 int lpcfg_parm_int(struct loadparm_context
*lp_ctx
,
3493 struct loadparm_service
*service
, const char *type
,
3494 const char *option
, int default_v
)
3496 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
3499 return lp_int(value
);
3505 * Return parametric option from a given service. Type is a part of
3506 * option before ':'.
3507 * Parametric option has following syntax: 'Type: option = value'.
3510 int lpcfg_parm_bytes(struct loadparm_context
*lp_ctx
,
3511 struct loadparm_service
*service
, const char *type
,
3512 const char *option
, int default_v
)
3516 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
3518 if (value
&& conv_str_size_error(value
, &bval
)) {
3519 if (bval
<= INT_MAX
) {
3528 * Return parametric option from a given service.
3529 * Type is a part of option before ':'
3530 * Parametric option has following syntax: 'Type: option = value'
3532 unsigned long lpcfg_parm_ulong(struct loadparm_context
*lp_ctx
,
3533 struct loadparm_service
*service
, const char *type
,
3534 const char *option
, unsigned long default_v
)
3536 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
3539 return lp_ulong(value
);
3544 long lpcfg_parm_long(struct loadparm_context
*lp_ctx
,
3545 struct loadparm_service
*service
, const char *type
,
3546 const char *option
, long default_v
)
3548 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
3551 return lp_long(value
);
3556 double lpcfg_parm_double(struct loadparm_context
*lp_ctx
,
3557 struct loadparm_service
*service
, const char *type
,
3558 const char *option
, double default_v
)
3560 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
3563 return lp_double(value
);
3569 * Return parametric option from a given service. Type is a part of option before ':'
3570 * Parametric option has following syntax: 'Type: option = value'
3573 bool lpcfg_parm_bool(struct loadparm_context
*lp_ctx
,
3574 struct loadparm_service
*service
, const char *type
,
3575 const char *option
, bool default_v
)
3577 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
3580 return lp_bool(value
);
3587 * Initialise a service to the defaults.
3590 static struct loadparm_service
*init_service(TALLOC_CTX
*mem_ctx
, struct loadparm_service
*sDefault
)
3592 struct loadparm_service
*pservice
=
3593 talloc_zero(mem_ctx
, struct loadparm_service
);
3594 copy_service(pservice
, sDefault
, NULL
);
3599 * Set a string value, deallocating any existing space, and allocing the space
3602 static bool lpcfg_string_set(TALLOC_CTX
*mem_ctx
, char **dest
, const char *src
)
3609 *dest
= talloc_strdup(mem_ctx
, src
);
3610 if ((*dest
) == NULL
) {
3611 DEBUG(0,("Out of memory in string_set\n"));
3619 * Set a string value, deallocating any existing space, and allocing the space
3622 static bool lpcfg_string_set_upper(TALLOC_CTX
*mem_ctx
, char **dest
, const char *src
)
3629 *dest
= strupper_talloc(mem_ctx
, src
);
3630 if ((*dest
) == NULL
) {
3631 DEBUG(0,("Out of memory in string_set_upper\n"));
3641 * Add a new service to the services array initialising it with the given
3645 struct loadparm_service
*lpcfg_add_service(struct loadparm_context
*lp_ctx
,
3646 const struct loadparm_service
*pservice
,
3650 struct loadparm_service tservice
;
3651 int num_to_alloc
= lp_ctx
->iNumServices
+ 1;
3652 struct parmlist_entry
*data
, *pdata
;
3654 if (pservice
== NULL
) {
3655 pservice
= lp_ctx
->sDefault
;
3658 tservice
= *pservice
;
3660 /* it might already exist */
3662 struct loadparm_service
*service
= getservicebyname(lp_ctx
,
3664 if (service
!= NULL
) {
3665 /* Clean all parametric options for service */
3666 /* They will be added during parsing again */
3667 data
= service
->param_opt
;
3673 service
->param_opt
= NULL
;
3678 /* find an invalid one */
3679 for (i
= 0; i
< lp_ctx
->iNumServices
; i
++)
3680 if (lp_ctx
->services
[i
] == NULL
)
3683 /* if not, then create one */
3684 if (i
== lp_ctx
->iNumServices
) {
3685 struct loadparm_service
**tsp
;
3687 tsp
= talloc_realloc(lp_ctx
, lp_ctx
->services
, struct loadparm_service
*, num_to_alloc
);
3690 DEBUG(0,("lpcfg_add_service: failed to enlarge services!\n"));
3693 lp_ctx
->services
= tsp
;
3694 lp_ctx
->services
[lp_ctx
->iNumServices
] = NULL
;
3697 lp_ctx
->iNumServices
++;
3700 lp_ctx
->services
[i
] = init_service(lp_ctx
->services
, lp_ctx
->sDefault
);
3701 if (lp_ctx
->services
[i
] == NULL
) {
3702 DEBUG(0,("lpcfg_add_service: out of memory!\n"));
3705 copy_service(lp_ctx
->services
[i
], &tservice
, NULL
);
3707 lpcfg_string_set(lp_ctx
->services
[i
], &lp_ctx
->services
[i
]->szService
, name
);
3708 return lp_ctx
->services
[i
];
3712 * Add a new home service, with the specified home directory, defaults coming
3713 * from service ifrom.
3716 bool lpcfg_add_home(struct loadparm_context
*lp_ctx
,
3717 const char *pszHomename
,
3718 struct loadparm_service
*default_service
,
3719 const char *user
, const char *pszHomedir
)
3721 struct loadparm_service
*service
;
3723 service
= lpcfg_add_service(lp_ctx
, default_service
, pszHomename
);
3725 if (service
== NULL
)
3728 if (!(*(default_service
->szPath
))
3729 || strequal(default_service
->szPath
, lp_ctx
->sDefault
->szPath
)) {
3730 service
->szPath
= talloc_strdup(service
, pszHomedir
);
3732 service
->szPath
= string_sub_talloc(service
, lpcfg_pathname(default_service
, lp_ctx
->sDefault
), "%H", pszHomedir
);
3735 if (!(*(service
->comment
))) {
3736 service
->comment
= talloc_asprintf(service
, "Home directory of %s", user
);
3738 service
->bAvailable
= default_service
->bAvailable
;
3739 service
->bBrowseable
= default_service
->bBrowseable
;
3741 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
3742 pszHomename
, user
, service
->szPath
));
3748 * Add a new printer service, with defaults coming from service iFrom.
3751 bool lpcfg_add_printer(struct loadparm_context
*lp_ctx
,
3752 const char *pszPrintername
,
3753 struct loadparm_service
*default_service
)
3755 const char *comment
= "From Printcap";
3756 struct loadparm_service
*service
;
3757 service
= lpcfg_add_service(lp_ctx
, default_service
, pszPrintername
);
3759 if (service
== NULL
)
3762 /* note that we do NOT default the availability flag to True - */
3763 /* we take it from the default service passed. This allows all */
3764 /* dynamic printers to be disabled by disabling the [printers] */
3765 /* entry (if/when the 'available' keyword is implemented!). */
3767 /* the printer name is set to the service name. */
3768 lpcfg_string_set(service
, &service
->szPrintername
, pszPrintername
);
3769 lpcfg_string_set(service
, &service
->comment
, comment
);
3770 service
->bBrowseable
= default_service
->bBrowseable
;
3771 /* Printers cannot be read_only. */
3772 service
->bRead_only
= false;
3773 /* Printer services must be printable. */
3774 service
->bPrint_ok
= true;
3776 DEBUG(3, ("adding printer service %s\n", pszPrintername
));
3782 * Map a parameter's string representation to something we can use.
3783 * Returns False if the parameter string is not recognised, else TRUE.
3786 static int map_parameter(const char *pszParmName
)
3790 if (*pszParmName
== '-')
3793 for (iIndex
= 0; parm_table
[iIndex
].label
; iIndex
++)
3794 if (strwicmp(parm_table
[iIndex
].label
, pszParmName
) == 0)
3797 /* Warn only if it isn't parametric option */
3798 if (strchr(pszParmName
, ':') == NULL
)
3799 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName
));
3800 /* We do return 'fail' for parametric options as well because they are
3801 stored in different storage
3808 return the parameter structure for a parameter
3810 struct parm_struct
*lpcfg_parm_struct(struct loadparm_context
*lp_ctx
, const char *name
)
3814 if (lp_ctx
->s3_fns
) {
3815 return lp_ctx
->s3_fns
->get_parm_struct(name
);
3818 parmnum
= map_parameter(name
);
3819 if (parmnum
== -1) return NULL
;
3820 return &parm_table
[parmnum
];
3824 return the parameter pointer for a parameter
3826 void *lpcfg_parm_ptr(struct loadparm_context
*lp_ctx
,
3827 struct loadparm_service
*service
, struct parm_struct
*parm
)
3829 if (lp_ctx
->s3_fns
) {
3830 return lp_ctx
->s3_fns
->get_parm_ptr(service
, parm
);
3833 if (service
== NULL
) {
3834 if (parm
->p_class
== P_LOCAL
)
3835 return ((char *)lp_ctx
->sDefault
)+parm
->offset
;
3836 else if (parm
->p_class
== P_GLOBAL
)
3837 return ((char *)lp_ctx
->globals
)+parm
->offset
;
3840 return ((char *)service
) + parm
->offset
;
3845 return the parameter pointer for a parameter
3847 bool lpcfg_parm_is_cmdline(struct loadparm_context
*lp_ctx
, const char *name
)
3851 if (lp_ctx
->s3_fns
) {
3852 struct parm_struct
*parm
= lp_ctx
->s3_fns
->get_parm_struct(name
);
3854 return parm
->flags
& FLAG_CMDLINE
;
3859 parmnum
= map_parameter(name
);
3860 if (parmnum
== -1) return false;
3862 return lp_ctx
->flags
[parmnum
] & FLAG_CMDLINE
;
3866 * Find a service by name. Otherwise works like get_service.
3869 static struct loadparm_service
*getservicebyname(struct loadparm_context
*lp_ctx
,
3870 const char *pszServiceName
)
3874 if (lp_ctx
->s3_fns
) {
3875 return lp_ctx
->s3_fns
->get_service(pszServiceName
);
3878 for (iService
= lp_ctx
->iNumServices
- 1; iService
>= 0; iService
--)
3879 if (lp_ctx
->services
[iService
] != NULL
&&
3880 strwicmp(lp_ctx
->services
[iService
]->szService
, pszServiceName
) == 0) {
3881 return lp_ctx
->services
[iService
];
3888 * Copy a service structure to another.
3889 * If pcopymapDest is NULL then copy all fields
3892 static void copy_service(struct loadparm_service
*pserviceDest
,
3893 struct loadparm_service
*pserviceSource
,
3894 struct bitmap
*pcopymapDest
)
3897 bool bcopyall
= (pcopymapDest
== NULL
);
3898 struct parmlist_entry
*data
, *pdata
, *paramo
;
3901 for (i
= 0; parm_table
[i
].label
; i
++)
3902 if (parm_table
[i
].p_class
== P_LOCAL
&&
3903 (bcopyall
|| bitmap_query(pcopymapDest
, i
))) {
3905 ((char *)pserviceSource
) + parm_table
[i
].offset
;
3907 ((char *)pserviceDest
) + parm_table
[i
].offset
;
3909 switch (parm_table
[i
].type
) {
3911 *(bool *)dest_ptr
= *(bool *)src_ptr
;
3918 *(int *)dest_ptr
= *(int *)src_ptr
;
3922 lpcfg_string_set(pserviceDest
,
3928 lpcfg_string_set_upper(pserviceDest
,
3933 *(const char ***)dest_ptr
= (const char **)str_list_copy(pserviceDest
,
3934 *(const char ***)src_ptr
);
3942 init_copymap(pserviceDest
);
3943 if (pserviceSource
->copymap
)
3944 bitmap_copy(pserviceDest
->copymap
,
3945 pserviceSource
->copymap
);
3948 data
= pserviceSource
->param_opt
;
3951 pdata
= pserviceDest
->param_opt
;
3952 /* Traverse destination */
3954 /* If we already have same option, override it */
3955 if (strcmp(pdata
->key
, data
->key
) == 0) {
3956 talloc_free(pdata
->value
);
3957 pdata
->value
= talloc_strdup(pdata
,
3962 pdata
= pdata
->next
;
3965 paramo
= talloc_zero(pserviceDest
, struct parmlist_entry
);
3968 paramo
->key
= talloc_strdup(paramo
, data
->key
);
3969 paramo
->value
= talloc_strdup(paramo
, data
->value
);
3970 DLIST_ADD(pserviceDest
->param_opt
, paramo
);
3977 * Check a service for consistency. Return False if the service is in any way
3978 * incomplete or faulty, else True.
3980 static bool lpcfg_service_ok(struct loadparm_service
*service
)
3985 if (service
->szService
[0] == '\0') {
3986 DEBUG(0, ("The following message indicates an internal error:\n"));
3987 DEBUG(0, ("No service name in service entry.\n"));
3991 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
3992 /* I can't see why you'd want a non-printable printer service... */
3993 if (strwicmp(service
->szService
, PRINTERS_NAME
) == 0) {
3994 if (!service
->bPrint_ok
) {
3995 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
3996 service
->szService
));
3997 service
->bPrint_ok
= true;
3999 /* [printers] service must also be non-browsable. */
4000 if (service
->bBrowseable
)
4001 service
->bBrowseable
= false;
4004 /* If a service is flagged unavailable, log the fact at level 0. */
4005 if (!service
->bAvailable
)
4006 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
4007 service
->szService
));
4013 /*******************************************************************
4014 Keep a linked list of all config files so we know when one has changed
4015 it's date and needs to be reloaded.
4016 ********************************************************************/
4018 static void add_to_file_list(struct loadparm_context
*lp_ctx
,
4019 const char *fname
, const char *subfname
)
4021 struct file_lists
*f
= lp_ctx
->file_lists
;
4024 if (f
->name
&& !strcmp(f
->name
, fname
))
4030 f
= talloc(lp_ctx
, struct file_lists
);
4033 f
->next
= lp_ctx
->file_lists
;
4034 f
->name
= talloc_strdup(f
, fname
);
4039 f
->subfname
= talloc_strdup(f
, subfname
);
4044 lp_ctx
->file_lists
= f
;
4045 f
->modtime
= file_modtime(subfname
);
4047 time_t t
= file_modtime(subfname
);
4053 /*******************************************************************
4054 Check if a config file has changed date.
4055 ********************************************************************/
4056 bool lpcfg_file_list_changed(struct loadparm_context
*lp_ctx
)
4058 struct file_lists
*f
;
4059 DEBUG(6, ("lp_file_list_changed()\n"));
4061 for (f
= lp_ctx
->file_lists
; f
!= NULL
; f
= f
->next
) {
4065 n2
= standard_sub_basic(lp_ctx
, f
->name
);
4067 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
4068 f
->name
, n2
, ctime(&f
->modtime
)));
4070 mod_time
= file_modtime(n2
);
4072 if (mod_time
&& ((f
->modtime
!= mod_time
) || (f
->subfname
== NULL
) || (strcmp(n2
, f
->subfname
) != 0))) {
4073 DEBUGADD(6, ("file %s modified: %s\n", n2
,
4075 f
->modtime
= mod_time
;
4076 talloc_free(f
->subfname
);
4077 f
->subfname
= talloc_strdup(f
, n2
);
4084 /***************************************************************************
4085 Handle the "realm" parameter
4086 ***************************************************************************/
4088 static bool handle_realm(struct loadparm_context
*lp_ctx
, int unused
,
4089 const char *pszParmValue
, char **ptr
)
4091 lpcfg_string_set(lp_ctx
, ptr
, pszParmValue
);
4093 talloc_free(lp_ctx
->globals
->szRealm_upper
);
4094 talloc_free(lp_ctx
->globals
->szRealm_lower
);
4096 lp_ctx
->globals
->szRealm_upper
= strupper_talloc(lp_ctx
, pszParmValue
);
4097 lp_ctx
->globals
->szRealm_lower
= strlower_talloc(lp_ctx
, pszParmValue
);
4102 /***************************************************************************
4103 Handle the include operation.
4104 ***************************************************************************/
4106 static bool handle_include(struct loadparm_context
*lp_ctx
, int unused
,
4107 const char *pszParmValue
, char **ptr
)
4109 char *fname
= standard_sub_basic(lp_ctx
, pszParmValue
);
4111 add_to_file_list(lp_ctx
, pszParmValue
, fname
);
4113 lpcfg_string_set(lp_ctx
, ptr
, fname
);
4115 if (file_exist(fname
))
4116 return pm_process(fname
, do_section
, do_parameter
, lp_ctx
);
4118 DEBUG(2, ("Can't find include file %s\n", fname
));
4123 /***************************************************************************
4124 Handle the interpretation of the copy parameter.
4125 ***************************************************************************/
4127 static bool handle_copy(struct loadparm_context
*lp_ctx
, int unused
,
4128 const char *pszParmValue
, char **ptr
)
4131 struct loadparm_service
*serviceTemp
;
4133 lpcfg_string_set(lp_ctx
, ptr
, pszParmValue
);
4137 DEBUG(3, ("Copying service from service %s\n", pszParmValue
));
4139 if ((serviceTemp
= getservicebyname(lp_ctx
, pszParmValue
)) != NULL
) {
4140 if (serviceTemp
== lp_ctx
->currentService
) {
4141 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue
));
4143 copy_service(lp_ctx
->currentService
,
4145 lp_ctx
->currentService
->copymap
);
4149 DEBUG(0, ("Unable to copy service - source not found: %s\n",
4157 static bool handle_debuglevel(struct loadparm_context
*lp_ctx
, int unused
,
4158 const char *pszParmValue
, char **ptr
)
4161 lpcfg_string_set(lp_ctx
, ptr
, pszParmValue
);
4162 if (lp_ctx
->global
) {
4163 return debug_parse_levels(pszParmValue
);
4168 static bool handle_logfile(struct loadparm_context
*lp_ctx
, int unused
,
4169 const char *pszParmValue
, char **ptr
)
4171 debug_set_logfile(pszParmValue
);
4172 if (lp_ctx
->global
) {
4173 lpcfg_string_set(lp_ctx
, ptr
, pszParmValue
);
4178 /***************************************************************************
4179 Initialise a copymap.
4180 ***************************************************************************/
4182 static void init_copymap(struct loadparm_service
*pservice
)
4186 TALLOC_FREE(pservice
->copymap
);
4188 pservice
->copymap
= bitmap_talloc(NULL
, NUMPARAMETERS
);
4189 if (!pservice
->copymap
)
4191 ("Couldn't allocate copymap!! (size %d)\n",
4192 (int)NUMPARAMETERS
));
4194 for (i
= 0; i
< NUMPARAMETERS
; i
++)
4195 bitmap_set(pservice
->copymap
, i
);
4199 * Process a parametric option
4201 static bool lp_do_parameter_parametric(struct loadparm_context
*lp_ctx
,
4202 struct loadparm_service
*service
,
4203 const char *pszParmName
,
4204 const char *pszParmValue
, int flags
)
4206 struct parmlist_entry
*paramo
, *data
;
4208 TALLOC_CTX
*mem_ctx
;
4210 while (isspace((unsigned char)*pszParmName
)) {
4214 name
= strlower_talloc(lp_ctx
, pszParmName
);
4215 if (!name
) return false;
4217 if (service
== NULL
) {
4218 data
= lp_ctx
->globals
->param_opt
;
4219 mem_ctx
= lp_ctx
->globals
;
4221 data
= service
->param_opt
;
4225 /* Traverse destination */
4226 for (paramo
=data
; paramo
; paramo
=paramo
->next
) {
4227 /* If we already have the option set, override it unless
4228 it was a command line option and the new one isn't */
4229 if (strcmp(paramo
->key
, name
) == 0) {
4230 if ((paramo
->priority
& FLAG_CMDLINE
) &&
4231 !(flags
& FLAG_CMDLINE
)) {
4236 talloc_free(paramo
->value
);
4237 paramo
->value
= talloc_strdup(paramo
, pszParmValue
);
4238 paramo
->priority
= flags
;
4244 paramo
= talloc_zero(mem_ctx
, struct parmlist_entry
);
4247 paramo
->key
= talloc_strdup(paramo
, name
);
4248 paramo
->value
= talloc_strdup(paramo
, pszParmValue
);
4249 paramo
->priority
= flags
;
4250 if (service
== NULL
) {
4251 DLIST_ADD(lp_ctx
->globals
->param_opt
, paramo
);
4253 DLIST_ADD(service
->param_opt
, paramo
);
4261 static bool set_variable(TALLOC_CTX
*mem_ctx
, int parmnum
, void *parm_ptr
,
4262 const char *pszParmName
, const char *pszParmValue
,
4263 struct loadparm_context
*lp_ctx
, bool on_globals
)
4266 /* if it is a special case then go ahead */
4267 if (parm_table
[parmnum
].special
) {
4269 ret
= parm_table
[parmnum
].special(lp_ctx
, -1, pszParmValue
,
4274 goto mark_non_default
;
4277 /* now switch on the type of variable it is */
4278 switch (parm_table
[parmnum
].type
)
4282 if (!set_boolean(pszParmValue
, &b
)) {
4283 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue
));
4286 *(bool *)parm_ptr
= b
;
4292 if (!set_boolean(pszParmValue
, &b
)) {
4293 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue
));
4296 *(bool *)parm_ptr
= !b
;
4301 *(int *)parm_ptr
= atoi(pszParmValue
);
4305 *(char *)parm_ptr
= *pszParmValue
;
4309 *(int *)parm_ptr
= strtol(pszParmValue
, NULL
, 8);
4315 if (conv_str_size_error(pszParmValue
, &val
)) {
4316 if (val
<= INT_MAX
) {
4317 *(int *)parm_ptr
= (int)val
;
4322 DEBUG(0,("lp_do_parameter(%s): value is not "
4323 "a valid size specifier!\n", pszParmValue
));
4328 *(const char ***)parm_ptr
= (const char **)str_list_make(mem_ctx
,
4329 pszParmValue
, NULL
);
4333 char **new_list
= str_list_make(mem_ctx
,
4334 pszParmValue
, NULL
);
4335 for (i
=0; new_list
[i
]; i
++) {
4336 if (new_list
[i
][0] == '+' && new_list
[i
][1]) {
4337 if (!str_list_check(*(const char ***)parm_ptr
,
4339 *(const char ***)parm_ptr
= str_list_add(*(const char ***)parm_ptr
,
4342 } else if (new_list
[i
][0] == '-' && new_list
[i
][1]) {
4343 str_list_remove(*(const char ***)parm_ptr
,
4347 DEBUG(0, ("Unsupported list syntax for: %s = %s\n",
4348 pszParmName
, pszParmValue
));
4351 *(const char ***)parm_ptr
= (const char **) new_list
;
4358 lpcfg_string_set(mem_ctx
, (char **)parm_ptr
, pszParmValue
);
4362 lpcfg_string_set_upper(mem_ctx
, (char **)parm_ptr
, pszParmValue
);
4366 for (i
= 0; parm_table
[parmnum
].enum_list
[i
].name
; i
++) {
4369 parm_table
[parmnum
].enum_list
[i
].name
)) {
4371 parm_table
[parmnum
].
4376 if (!parm_table
[parmnum
].enum_list
[i
].name
) {
4377 DEBUG(0,("Unknown enumerated value '%s' for '%s'\n",
4378 pszParmValue
, pszParmName
));
4388 if (on_globals
&& (lp_ctx
->flags
[parmnum
] & FLAG_DEFAULT
)) {
4389 lp_ctx
->flags
[parmnum
] &= ~FLAG_DEFAULT
;
4390 /* we have to also unset FLAG_DEFAULT on aliases */
4391 for (i
=parmnum
-1;i
>=0 && parm_table
[i
].offset
== parm_table
[parmnum
].offset
;i
--) {
4392 lp_ctx
->flags
[i
] &= ~FLAG_DEFAULT
;
4394 for (i
=parmnum
+1;i
<NUMPARAMETERS
&& parm_table
[i
].offset
== parm_table
[parmnum
].offset
;i
++) {
4395 lp_ctx
->flags
[i
] &= ~FLAG_DEFAULT
;
4402 bool lpcfg_do_global_parameter(struct loadparm_context
*lp_ctx
,
4403 const char *pszParmName
, const char *pszParmValue
)
4405 int parmnum
= map_parameter(pszParmName
);
4409 if (strchr(pszParmName
, ':')) {
4410 return lp_do_parameter_parametric(lp_ctx
, NULL
, pszParmName
, pszParmValue
, 0);
4412 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName
));
4416 /* if the flag has been set on the command line, then don't allow override,
4417 but don't report an error */
4418 if (lp_ctx
->flags
[parmnum
] & FLAG_CMDLINE
) {
4422 parm_ptr
= lpcfg_parm_ptr(lp_ctx
, NULL
, &parm_table
[parmnum
]);
4424 return set_variable(lp_ctx
->globals
, parmnum
, parm_ptr
,
4425 pszParmName
, pszParmValue
, lp_ctx
, true);
4428 bool lpcfg_do_service_parameter(struct loadparm_context
*lp_ctx
,
4429 struct loadparm_service
*service
,
4430 const char *pszParmName
, const char *pszParmValue
)
4434 int parmnum
= map_parameter(pszParmName
);
4437 if (strchr(pszParmName
, ':')) {
4438 return lp_do_parameter_parametric(lp_ctx
, service
, pszParmName
, pszParmValue
, 0);
4440 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName
));
4444 /* if the flag has been set on the command line, then don't allow override,
4445 but don't report an error */
4446 if (lp_ctx
->flags
[parmnum
] & FLAG_CMDLINE
) {
4450 if (parm_table
[parmnum
].p_class
== P_GLOBAL
) {
4452 ("Global parameter %s found in service section!\n",
4456 parm_ptr
= ((char *)service
) + parm_table
[parmnum
].offset
;
4458 if (!service
->copymap
)
4459 init_copymap(service
);
4461 /* this handles the aliases - set the copymap for other
4462 * entries with the same data pointer */
4463 for (i
= 0; parm_table
[i
].label
; i
++)
4464 if (parm_table
[i
].offset
== parm_table
[parmnum
].offset
&&
4465 parm_table
[i
].p_class
== parm_table
[parmnum
].p_class
)
4466 bitmap_clear(service
->copymap
, i
);
4468 return set_variable(service
, parmnum
, parm_ptr
, pszParmName
,
4469 pszParmValue
, lp_ctx
, false);
4473 * Process a parameter.
4476 static bool do_parameter(const char *pszParmName
, const char *pszParmValue
,
4479 struct loadparm_context
*lp_ctx
= (struct loadparm_context
*)userdata
;
4481 if (lp_ctx
->bInGlobalSection
)
4482 return lpcfg_do_global_parameter(lp_ctx
, pszParmName
,
4485 return lpcfg_do_service_parameter(lp_ctx
, lp_ctx
->currentService
,
4486 pszParmName
, pszParmValue
);
4490 variable argument do parameter
4492 bool lpcfg_do_global_parameter_var(struct loadparm_context
*lp_ctx
, const char *pszParmName
, const char *fmt
, ...) PRINTF_ATTRIBUTE(3, 4);
4493 bool lpcfg_do_global_parameter_var(struct loadparm_context
*lp_ctx
,
4494 const char *pszParmName
, const char *fmt
, ...)
4501 s
= talloc_vasprintf(NULL
, fmt
, ap
);
4503 ret
= lpcfg_do_global_parameter(lp_ctx
, pszParmName
, s
);
4510 set a parameter from the commandline - this is called from command line parameter
4511 parsing code. It sets the parameter then marks the parameter as unable to be modified
4512 by smb.conf processing
4514 bool lpcfg_set_cmdline(struct loadparm_context
*lp_ctx
, const char *pszParmName
,
4515 const char *pszParmValue
)
4520 if (lp_ctx
->s3_fns
) {
4521 return lp_ctx
->s3_fns
->set_cmdline(pszParmName
, pszParmValue
);
4524 parmnum
= map_parameter(pszParmName
);
4526 while (isspace((unsigned char)*pszParmValue
)) pszParmValue
++;
4529 if (parmnum
< 0 && strchr(pszParmName
, ':')) {
4530 /* set a parametric option */
4531 return lp_do_parameter_parametric(lp_ctx
, NULL
, pszParmName
,
4532 pszParmValue
, FLAG_CMDLINE
);
4536 DEBUG(0,("Unknown option '%s'\n", pszParmName
));
4540 /* reset the CMDLINE flag in case this has been called before */
4541 lp_ctx
->flags
[parmnum
] &= ~FLAG_CMDLINE
;
4543 if (!lpcfg_do_global_parameter(lp_ctx
, pszParmName
, pszParmValue
)) {
4547 lp_ctx
->flags
[parmnum
] |= FLAG_CMDLINE
;
4549 /* we have to also set FLAG_CMDLINE on aliases */
4550 for (i
=parmnum
-1;i
>=0 && parm_table
[i
].offset
== parm_table
[parmnum
].offset
;i
--) {
4551 lp_ctx
->flags
[i
] |= FLAG_CMDLINE
;
4553 for (i
=parmnum
+1;i
<NUMPARAMETERS
&& parm_table
[i
].offset
== parm_table
[parmnum
].offset
;i
++) {
4554 lp_ctx
->flags
[i
] |= FLAG_CMDLINE
;
4561 set a option from the commandline in 'a=b' format. Use to support --option
4563 bool lpcfg_set_option(struct loadparm_context
*lp_ctx
, const char *option
)
4568 s
= talloc_strdup(NULL
, option
);
4581 ret
= lpcfg_set_cmdline(lp_ctx
, s
, p
+1);
4587 #define BOOLSTR(b) ((b) ? "Yes" : "No")
4590 * Print a parameter of the specified type.
4593 static void print_parameter(struct parm_struct
*p
, void *ptr
, FILE * f
)
4595 /* For the seperation of lists values that we print below */
4596 const char *list_sep
= ", ";
4601 for (i
= 0; p
->enum_list
[i
].name
; i
++) {
4602 if (*(int *)ptr
== p
->enum_list
[i
].value
) {
4604 p
->enum_list
[i
].name
);
4611 fprintf(f
, "%s", BOOLSTR(*(bool *)ptr
));
4615 fprintf(f
, "%s", BOOLSTR(!*(bool *)ptr
));
4620 fprintf(f
, "%d", *(int *)ptr
);
4624 fprintf(f
, "%c", *(char *)ptr
);
4628 int val
= *(int *)ptr
;
4632 fprintf(f
, "0%o", val
);
4641 if ((char ***)ptr
&& *(char ***)ptr
) {
4642 char **list
= *(char ***)ptr
;
4643 for (; *list
; list
++) {
4644 /* surround strings with whitespace in double quotes */
4645 if (*(list
+1) == NULL
) {
4646 /* last item, no extra separator */
4649 if ( strchr_m( *list
, ' ' ) ) {
4650 fprintf(f
, "\"%s\"%s", *list
, list_sep
);
4652 fprintf(f
, "%s%s", *list
, list_sep
);
4660 if (*(char **)ptr
) {
4661 fprintf(f
, "%s", *(char **)ptr
);
4670 * Check if two parameters are equal.
4673 static bool equal_parameter(parm_type type
, void *ptr1
, void *ptr2
)
4678 return (*((bool *)ptr1
) == *((bool *)ptr2
));
4684 return (*((int *)ptr1
) == *((int *)ptr2
));
4687 return (*((char *)ptr1
) == *((char *)ptr2
));
4691 return str_list_equal(*(const char ***)ptr1
, *(const char ***)ptr2
);
4696 char *p1
= *(char **)ptr1
, *p2
= *(char **)ptr2
;
4701 return (p1
== p2
|| strequal(p1
, p2
));
4710 * Process a new section (service).
4712 * At this stage all sections are services.
4713 * Later we'll have special sections that permit server parameters to be set.
4714 * Returns True on success, False on failure.
4717 static bool do_section(const char *pszSectionName
, void *userdata
)
4719 struct loadparm_context
*lp_ctx
= (struct loadparm_context
*)userdata
;
4721 bool isglobal
= ((strwicmp(pszSectionName
, GLOBAL_NAME
) == 0) ||
4722 (strwicmp(pszSectionName
, GLOBAL_NAME2
) == 0));
4725 /* if we've just struck a global section, note the fact. */
4726 lp_ctx
->bInGlobalSection
= isglobal
;
4728 /* check for multiple global sections */
4729 if (lp_ctx
->bInGlobalSection
) {
4730 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName
));
4734 /* if we have a current service, tidy it up before moving on */
4737 if (lp_ctx
->currentService
!= NULL
)
4738 bRetval
= lpcfg_service_ok(lp_ctx
->currentService
);
4740 /* if all is still well, move to the next record in the services array */
4742 /* We put this here to avoid an odd message order if messages are */
4743 /* issued by the post-processing of a previous section. */
4744 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName
));
4746 if ((lp_ctx
->currentService
= lpcfg_add_service(lp_ctx
, lp_ctx
->sDefault
,
4749 DEBUG(0, ("Failed to add a new service\n"));
4759 * Determine if a particular base parameter is currently set to the default value.
4762 static bool is_default(struct loadparm_service
*sDefault
, int i
)
4764 void *def_ptr
= ((char *)sDefault
) + parm_table
[i
].offset
;
4765 if (!defaults_saved
)
4767 switch (parm_table
[i
].type
) {
4770 return str_list_equal((const char **)parm_table
[i
].def
.lvalue
,
4771 (const char **)def_ptr
);
4774 return strequal(parm_table
[i
].def
.svalue
,
4778 return parm_table
[i
].def
.bvalue
==
4785 return parm_table
[i
].def
.ivalue
==
4794 *Display the contents of the global structure.
4797 static void dump_globals(struct loadparm_context
*lp_ctx
, FILE *f
,
4801 struct parmlist_entry
*data
;
4803 fprintf(f
, "# Global parameters\n[global]\n");
4805 for (i
= 0; parm_table
[i
].label
; i
++)
4806 if (parm_table
[i
].p_class
== P_GLOBAL
&&
4807 (i
== 0 || (parm_table
[i
].offset
!= parm_table
[i
- 1].offset
))) {
4808 if (!show_defaults
&& (lp_ctx
->flags
[i
] & FLAG_DEFAULT
))
4810 fprintf(f
, "\t%s = ", parm_table
[i
].label
);
4811 print_parameter(&parm_table
[i
], lpcfg_parm_ptr(lp_ctx
, NULL
, &parm_table
[i
]), f
);
4814 if (lp_ctx
->globals
->param_opt
!= NULL
) {
4815 for (data
= lp_ctx
->globals
->param_opt
; data
;
4816 data
= data
->next
) {
4817 if (!show_defaults
&& (data
->priority
& FLAG_DEFAULT
)) {
4820 fprintf(f
, "\t%s = %s\n", data
->key
, data
->value
);
4827 * Display the contents of a single services record.
4830 static void dump_a_service(struct loadparm_service
* pService
, struct loadparm_service
*sDefault
, FILE * f
,
4831 unsigned int *flags
)
4834 struct parmlist_entry
*data
;
4836 if (pService
!= sDefault
)
4837 fprintf(f
, "\n[%s]\n", pService
->szService
);
4839 for (i
= 0; parm_table
[i
].label
; i
++) {
4840 if (parm_table
[i
].p_class
== P_LOCAL
&&
4841 (*parm_table
[i
].label
!= '-') &&
4842 (i
== 0 || (parm_table
[i
].offset
!= parm_table
[i
- 1].offset
)))
4844 if (pService
== sDefault
) {
4845 if (flags
&& (flags
[i
] & FLAG_DEFAULT
)) {
4848 if (defaults_saved
) {
4849 if (is_default(sDefault
, i
)) {
4854 if (equal_parameter(parm_table
[i
].type
,
4855 ((char *)pService
) +
4856 parm_table
[i
].offset
,
4857 ((char *)sDefault
) +
4858 parm_table
[i
].offset
))
4862 fprintf(f
, "\t%s = ", parm_table
[i
].label
);
4863 print_parameter(&parm_table
[i
],
4864 ((char *)pService
) + parm_table
[i
].offset
, f
);
4868 if (pService
->param_opt
!= NULL
) {
4869 for (data
= pService
->param_opt
; data
; data
= data
->next
) {
4870 fprintf(f
, "\t%s = %s\n", data
->key
, data
->value
);
4875 bool lpcfg_dump_a_parameter(struct loadparm_context
*lp_ctx
,
4876 struct loadparm_service
*service
,
4877 const char *parm_name
, FILE * f
)
4879 struct parm_struct
*parm
;
4882 parm
= lpcfg_parm_struct(lp_ctx
, parm_name
);
4887 ptr
= lpcfg_parm_ptr(lp_ctx
, service
,parm
);
4889 print_parameter(parm
, ptr
, f
);
4895 * Return info about the next parameter in a service.
4896 * snum==-1 gives the globals.
4897 * Return NULL when out of parameters.
4901 struct parm_struct
*lpcfg_next_parameter(struct loadparm_context
*lp_ctx
, int snum
, int *i
,
4905 /* do the globals */
4906 for (; parm_table
[*i
].label
; (*i
)++) {
4907 if ((*parm_table
[*i
].label
== '-'))
4911 && (parm_table
[*i
].offset
==
4912 parm_table
[(*i
) - 1].offset
)
4913 && (parm_table
[*i
].p_class
==
4914 parm_table
[(*i
) - 1].p_class
))
4917 return &parm_table
[(*i
)++];
4920 struct loadparm_service
*pService
= lp_ctx
->services
[snum
];
4922 for (; parm_table
[*i
].label
; (*i
)++) {
4923 if (parm_table
[*i
].p_class
== P_LOCAL
&&
4924 (*parm_table
[*i
].label
!= '-') &&
4926 (parm_table
[*i
].offset
!=
4927 parm_table
[(*i
) - 1].offset
)))
4929 if (allparameters
||
4930 !equal_parameter(parm_table
[*i
].type
,
4931 ((char *)pService
) +
4932 parm_table
[*i
].offset
,
4933 ((char *)lp_ctx
->sDefault
) +
4934 parm_table
[*i
].offset
))
4936 return &parm_table
[(*i
)++];
4947 * Auto-load some home services.
4949 static void lpcfg_add_auto_services(struct loadparm_context
*lp_ctx
,
4957 * Unload unused services.
4960 void lpcfg_killunused(struct loadparm_context
*lp_ctx
,
4961 struct smbsrv_connection
*smb
,
4962 bool (*snumused
) (struct smbsrv_connection
*, int))
4965 for (i
= 0; i
< lp_ctx
->iNumServices
; i
++) {
4966 if (lp_ctx
->services
[i
] == NULL
)
4969 if (!snumused
|| !snumused(smb
, i
)) {
4970 talloc_free(lp_ctx
->services
[i
]);
4971 lp_ctx
->services
[i
] = NULL
;
4977 static int lpcfg_destructor(struct loadparm_context
*lp_ctx
)
4979 struct parmlist_entry
*data
;
4981 if (lp_ctx
->refuse_free
) {
4982 /* someone is trying to free the
4983 global_loadparm_context.
4984 We can't allow that. */
4988 if (lp_ctx
->globals
->param_opt
!= NULL
) {
4989 struct parmlist_entry
*next
;
4990 for (data
= lp_ctx
->globals
->param_opt
; data
; data
=next
) {
4992 if (data
->priority
& FLAG_CMDLINE
) continue;
4993 DLIST_REMOVE(lp_ctx
->globals
->param_opt
, data
);
5002 * Initialise the global parameter structure.
5004 * Note that most callers should use loadparm_init_global() instead
5006 struct loadparm_context
*loadparm_init(TALLOC_CTX
*mem_ctx
)
5010 struct loadparm_context
*lp_ctx
;
5011 struct parmlist_entry
*parm
;
5014 lp_ctx
= talloc_zero(mem_ctx
, struct loadparm_context
);
5018 talloc_set_destructor(lp_ctx
, lpcfg_destructor
);
5019 lp_ctx
->bInGlobalSection
= true;
5020 lp_ctx
->globals
= talloc_zero(lp_ctx
, struct loadparm_global
);
5021 lp_ctx
->sDefault
= talloc_zero(lp_ctx
, struct loadparm_service
);
5023 lp_ctx
->sDefault
->iMaxPrintJobs
= 1000;
5024 lp_ctx
->sDefault
->bAvailable
= true;
5025 lp_ctx
->sDefault
->bBrowseable
= true;
5026 lp_ctx
->sDefault
->bRead_only
= true;
5027 lp_ctx
->sDefault
->bMap_archive
= true;
5028 lp_ctx
->sDefault
->iStrictLocking
= true;
5029 lp_ctx
->sDefault
->bOpLocks
= true;
5030 lp_ctx
->sDefault
->iCreate_mask
= 0744;
5031 lp_ctx
->sDefault
->iCreate_force_mode
= 0000;
5032 lp_ctx
->sDefault
->iDir_mask
= 0755;
5033 lp_ctx
->sDefault
->iDir_force_mode
= 0000;
5035 DEBUG(3, ("Initialising global parameters\n"));
5037 for (i
= 0; parm_table
[i
].label
; i
++) {
5038 if ((parm_table
[i
].type
== P_STRING
||
5039 parm_table
[i
].type
== P_USTRING
) &&
5040 !(lp_ctx
->flags
[i
] & FLAG_CMDLINE
)) {
5042 if (parm_table
[i
].p_class
== P_LOCAL
) {
5043 r
= (char **)(((char *)lp_ctx
->sDefault
) + parm_table
[i
].offset
);
5045 r
= (char **)(((char *)lp_ctx
->globals
) + parm_table
[i
].offset
);
5047 *r
= talloc_strdup(lp_ctx
, "");
5051 logfile
= talloc_asprintf(lp_ctx
, "%s/log.samba", dyn_LOGFILEBASE
);
5052 lpcfg_do_global_parameter(lp_ctx
, "log file", logfile
);
5053 talloc_free(logfile
);
5055 lpcfg_do_global_parameter(lp_ctx
, "log level", "0");
5057 lpcfg_do_global_parameter(lp_ctx
, "share backend", "classic");
5059 lpcfg_do_global_parameter(lp_ctx
, "server role", "auto");
5060 lpcfg_do_global_parameter(lp_ctx
, "domain logons", "No");
5061 lpcfg_do_global_parameter(lp_ctx
, "domain master", "Auto");
5063 /* options that can be set on the command line must be initialised via
5064 the slower lpcfg_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
5066 lpcfg_do_global_parameter(lp_ctx
, "socket options", "TCP_NODELAY");
5068 lpcfg_do_global_parameter(lp_ctx
, "workgroup", DEFAULT_WORKGROUP
);
5069 myname
= get_myname(lp_ctx
);
5070 lpcfg_do_global_parameter(lp_ctx
, "netbios name", myname
);
5071 talloc_free(myname
);
5072 lpcfg_do_global_parameter(lp_ctx
, "name resolve order", "wins host bcast");
5074 lpcfg_do_global_parameter(lp_ctx
, "fstype", "NTFS");
5076 lpcfg_do_global_parameter(lp_ctx
, "ntvfs handler", "unixuid default");
5077 lpcfg_do_global_parameter(lp_ctx
, "max connections", "-1");
5079 lpcfg_do_global_parameter(lp_ctx
, "dcerpc endpoint servers", "epmapper wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi dssetup unixinfo browser eventlog6 backupkey dnsserver");
5080 lpcfg_do_global_parameter(lp_ctx
, "server services", "s3fs rpc nbt wrepl ldap cldap kdc drepl winbind ntp_signd kcc dnsupdate");
5081 /* the winbind method for domain controllers is for both RODC
5082 auth forwarding and for trusted domains */
5083 lpcfg_do_global_parameter(lp_ctx
, "private dir", dyn_PRIVATE_DIR
);
5084 lpcfg_do_global_parameter(lp_ctx
, "registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
5086 /* This hive should be dynamically generated by Samba using
5087 data from the sam, but for the moment leave it in a tdb to
5088 keep regedt32 from popping up an annoying dialog. */
5089 lpcfg_do_global_parameter(lp_ctx
, "registry:HKEY_USERS", "hku.ldb");
5091 /* using UTF8 by default allows us to support all chars */
5092 lpcfg_do_global_parameter(lp_ctx
, "unix charset", "UTF8");
5094 /* Use codepage 850 as a default for the dos character set */
5095 lpcfg_do_global_parameter(lp_ctx
, "dos charset", "CP850");
5098 * Allow the default PASSWD_CHAT to be overridden in local.h.
5100 lpcfg_do_global_parameter(lp_ctx
, "passwd chat", DEFAULT_PASSWD_CHAT
);
5102 lpcfg_do_global_parameter(lp_ctx
, "pid directory", dyn_PIDDIR
);
5103 lpcfg_do_global_parameter(lp_ctx
, "lock dir", dyn_LOCKDIR
);
5104 lpcfg_do_global_parameter(lp_ctx
, "state directory", dyn_STATEDIR
);
5105 lpcfg_do_global_parameter(lp_ctx
, "cache directory", dyn_CACHEDIR
);
5106 lpcfg_do_global_parameter(lp_ctx
, "ncalrpc dir", dyn_NCALRPCDIR
);
5108 lpcfg_do_global_parameter(lp_ctx
, "socket address", "");
5109 lpcfg_do_global_parameter_var(lp_ctx
, "server string",
5110 "Samba %s", SAMBA_VERSION_STRING
);
5112 lpcfg_do_global_parameter(lp_ctx
, "password server", "*");
5114 lpcfg_do_global_parameter(lp_ctx
, "max mux", "50");
5115 lpcfg_do_global_parameter(lp_ctx
, "max xmit", "12288");
5116 lpcfg_do_global_parameter(lp_ctx
, "host msdfs", "true");
5118 lpcfg_do_global_parameter(lp_ctx
, "password level", "0");
5119 lpcfg_do_global_parameter(lp_ctx
, "LargeReadwrite", "True");
5120 lpcfg_do_global_parameter(lp_ctx
, "server min protocol", "CORE");
5121 lpcfg_do_global_parameter(lp_ctx
, "server max protocol", "NT1");
5122 lpcfg_do_global_parameter(lp_ctx
, "client min protocol", "CORE");
5123 lpcfg_do_global_parameter(lp_ctx
, "client max protocol", "NT1");
5124 lpcfg_do_global_parameter(lp_ctx
, "security", "AUTO");
5125 lpcfg_do_global_parameter(lp_ctx
, "paranoid server security", "True");
5126 lpcfg_do_global_parameter(lp_ctx
, "EncryptPasswords", "True");
5127 lpcfg_do_global_parameter(lp_ctx
, "ReadRaw", "True");
5128 lpcfg_do_global_parameter(lp_ctx
, "WriteRaw", "True");
5129 lpcfg_do_global_parameter(lp_ctx
, "NullPasswords", "False");
5130 lpcfg_do_global_parameter(lp_ctx
, "ObeyPamRestrictions", "False");
5132 lpcfg_do_global_parameter(lp_ctx
, "TimeServer", "False");
5133 lpcfg_do_global_parameter(lp_ctx
, "BindInterfacesOnly", "False");
5134 lpcfg_do_global_parameter(lp_ctx
, "Unicode", "True");
5135 lpcfg_do_global_parameter(lp_ctx
, "ClientLanManAuth", "False");
5136 lpcfg_do_global_parameter(lp_ctx
, "ClientNTLMv2Auth", "True");
5137 lpcfg_do_global_parameter(lp_ctx
, "LanmanAuth", "False");
5138 lpcfg_do_global_parameter(lp_ctx
, "NTLMAuth", "True");
5139 lpcfg_do_global_parameter(lp_ctx
, "client use spnego principal", "False");
5141 lpcfg_do_global_parameter(lp_ctx
, "UnixExtensions", "False");
5143 lpcfg_do_global_parameter(lp_ctx
, "PreferredMaster", "Auto");
5144 lpcfg_do_global_parameter(lp_ctx
, "LocalMaster", "True");
5146 lpcfg_do_global_parameter(lp_ctx
, "wins support", "False");
5147 lpcfg_do_global_parameter(lp_ctx
, "dns proxy", "True");
5149 lpcfg_do_global_parameter(lp_ctx
, "winbind separator", "\\");
5150 lpcfg_do_global_parameter(lp_ctx
, "winbind sealed pipes", "True");
5151 lpcfg_do_global_parameter(lp_ctx
, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR
);
5152 #if _SAMBA_BUILD_ >= 4
5153 lpcfg_do_global_parameter(lp_ctx
, "winbindd privileged socket directory", dyn_WINBINDD_PRIVILEGED_SOCKET_DIR
);
5154 lpcfg_do_global_parameter(lp_ctx
, "ntp signd socket directory", dyn_NTP_SIGND_SOCKET_DIR
);
5155 lpcfg_do_global_parameter_var(lp_ctx
, "dns update command", "%s/samba_dnsupdate", dyn_SCRIPTSBINDIR
);
5156 lpcfg_do_global_parameter_var(lp_ctx
, "spn update command", "%s/samba_spnupdate", dyn_SCRIPTSBINDIR
);
5157 lpcfg_do_global_parameter_var(lp_ctx
, "samba kcc command",
5158 "%s/samba_kcc", dyn_SCRIPTSBINDIR
);
5160 lpcfg_do_global_parameter(lp_ctx
, "template shell", "/bin/false");
5161 lpcfg_do_global_parameter(lp_ctx
, "template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%");
5163 lpcfg_do_global_parameter(lp_ctx
, "client signing", "default");
5164 lpcfg_do_global_parameter(lp_ctx
, "server signing", "default");
5166 lpcfg_do_global_parameter(lp_ctx
, "use spnego", "True");
5168 lpcfg_do_global_parameter(lp_ctx
, "use mmap", "True");
5170 lpcfg_do_global_parameter(lp_ctx
, "smb ports", "445 139");
5171 lpcfg_do_global_parameter(lp_ctx
, "nbt port", "137");
5172 lpcfg_do_global_parameter(lp_ctx
, "dgram port", "138");
5173 lpcfg_do_global_parameter(lp_ctx
, "cldap port", "389");
5174 lpcfg_do_global_parameter(lp_ctx
, "krb5 port", "88");
5175 lpcfg_do_global_parameter(lp_ctx
, "kpasswd port", "464");
5176 lpcfg_do_global_parameter(lp_ctx
, "web port", "901");
5178 lpcfg_do_global_parameter(lp_ctx
, "nt status support", "True");
5180 lpcfg_do_global_parameter(lp_ctx
, "max wins ttl", "518400"); /* 6 days */
5181 lpcfg_do_global_parameter(lp_ctx
, "min wins ttl", "10");
5183 lpcfg_do_global_parameter(lp_ctx
, "tls enabled", "True");
5184 lpcfg_do_global_parameter(lp_ctx
, "tls keyfile", "tls/key.pem");
5185 lpcfg_do_global_parameter(lp_ctx
, "tls certfile", "tls/cert.pem");
5186 lpcfg_do_global_parameter(lp_ctx
, "tls cafile", "tls/ca.pem");
5187 lpcfg_do_global_parameter(lp_ctx
, "prefork children:smb", "4");
5189 lpcfg_do_global_parameter(lp_ctx
, "rndc command", "/usr/sbin/rndc");
5190 lpcfg_do_global_parameter(lp_ctx
, "nsupdate command", "/usr/bin/nsupdate -g");
5192 lpcfg_do_global_parameter(lp_ctx
, "allow dns updates", "False");
5193 lpcfg_do_global_parameter(lp_ctx
, "dns recursive queries", "False");
5194 lpcfg_do_global_parameter(lp_ctx
, "dns forwarder", "");
5196 for (i
= 0; parm_table
[i
].label
; i
++) {
5197 if (!(lp_ctx
->flags
[i
] & FLAG_CMDLINE
)) {
5198 lp_ctx
->flags
[i
] |= FLAG_DEFAULT
;
5202 for (parm
=lp_ctx
->globals
->param_opt
; parm
; parm
=parm
->next
) {
5203 if (!(parm
->priority
& FLAG_CMDLINE
)) {
5204 parm
->priority
|= FLAG_DEFAULT
;
5212 * Initialise the global parameter structure.
5214 struct loadparm_context
*loadparm_init_global(bool load_default
)
5216 if (global_loadparm_context
== NULL
) {
5217 global_loadparm_context
= loadparm_init(NULL
);
5219 if (global_loadparm_context
== NULL
) {
5222 global_loadparm_context
->global
= true;
5223 if (load_default
&& !global_loadparm_context
->loaded
) {
5224 lpcfg_load_default(global_loadparm_context
);
5226 global_loadparm_context
->refuse_free
= true;
5227 return global_loadparm_context
;
5231 * Initialise the global parameter structure.
5233 struct loadparm_context
*loadparm_init_s3(TALLOC_CTX
*mem_ctx
,
5234 const struct loadparm_s3_helpers
*s3_fns
)
5236 struct loadparm_context
*loadparm_context
= talloc_zero(mem_ctx
, struct loadparm_context
);
5237 if (!loadparm_context
) {
5240 loadparm_context
->s3_fns
= s3_fns
;
5241 return loadparm_context
;
5244 const char *lpcfg_configfile(struct loadparm_context
*lp_ctx
)
5246 return lp_ctx
->szConfigFile
;
5249 const char *lp_default_path(void)
5251 if (getenv("SMB_CONF_PATH"))
5252 return getenv("SMB_CONF_PATH");
5254 return dyn_CONFIGFILE
;
5258 * Update the internal state of a loadparm context after settings
5261 static bool lpcfg_update(struct loadparm_context
*lp_ctx
)
5263 struct debug_settings settings
;
5264 lpcfg_add_auto_services(lp_ctx
, lpcfg_auto_services(lp_ctx
));
5266 if (!lp_ctx
->globals
->szWINSservers
&& lp_ctx
->globals
->bWINSsupport
) {
5267 lpcfg_do_global_parameter(lp_ctx
, "wins server", "127.0.0.1");
5270 if (!lp_ctx
->global
) {
5274 panic_action
= lp_ctx
->globals
->panic_action
;
5276 reload_charcnv(lp_ctx
);
5278 ZERO_STRUCT(settings
);
5279 /* Add any more debug-related smb.conf parameters created in
5281 settings
.timestamp_logs
= true;
5282 debug_set_settings(&settings
);
5284 /* FIXME: This is a bit of a hack, but we can't use a global, since
5285 * not everything that uses lp also uses the socket library */
5286 if (lpcfg_parm_bool(lp_ctx
, NULL
, "socket", "testnonblock", false)) {
5287 setenv("SOCKET_TESTNONBLOCK", "1", 1);
5289 unsetenv("SOCKET_TESTNONBLOCK");
5295 bool lpcfg_load_default(struct loadparm_context
*lp_ctx
)
5299 path
= lp_default_path();
5301 if (!file_exist(path
)) {
5302 /* We allow the default smb.conf file to not exist,
5303 * basically the equivalent of an empty file. */
5304 return lpcfg_update(lp_ctx
);
5307 return lpcfg_load(lp_ctx
, path
);
5311 * Load the services array from the services file.
5313 * Return True on success, False on failure.
5315 bool lpcfg_load(struct loadparm_context
*lp_ctx
, const char *filename
)
5320 filename
= talloc_strdup(lp_ctx
, filename
);
5322 lp_ctx
->szConfigFile
= filename
;
5324 if (lp_ctx
->s3_fns
) {
5325 return lp_ctx
->s3_fns
->load(filename
);
5328 lp_ctx
->bInGlobalSection
= true;
5329 n2
= standard_sub_basic(lp_ctx
, lp_ctx
->szConfigFile
);
5330 DEBUG(2, ("lpcfg_load: refreshing parameters from %s\n", n2
));
5332 add_to_file_list(lp_ctx
, lp_ctx
->szConfigFile
, n2
);
5334 /* We get sections first, so have to start 'behind' to make up */
5335 lp_ctx
->currentService
= NULL
;
5336 bRetval
= pm_process(n2
, do_section
, do_parameter
, lp_ctx
);
5338 /* finish up the last section */
5339 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval
)));
5341 if (lp_ctx
->currentService
!= NULL
)
5342 bRetval
= lpcfg_service_ok(lp_ctx
->currentService
);
5344 bRetval
= bRetval
&& lpcfg_update(lp_ctx
);
5346 /* we do this unconditionally, so that it happens even
5347 for a missing smb.conf */
5348 reload_charcnv(lp_ctx
);
5350 if (bRetval
== true) {
5351 /* set this up so that any child python tasks will
5352 find the right smb.conf */
5353 setenv("SMB_CONF_PATH", filename
, 1);
5355 /* set the context used by the lp_*() function
5357 global_loadparm_context
= lp_ctx
;
5358 lp_ctx
->loaded
= true;
5365 * Return the max number of services.
5368 int lpcfg_numservices(struct loadparm_context
*lp_ctx
)
5370 if (lp_ctx
->s3_fns
) {
5371 return lp_ctx
->s3_fns
->get_numservices();
5374 return lp_ctx
->iNumServices
;
5378 * Display the contents of the services array in human-readable form.
5381 void lpcfg_dump(struct loadparm_context
*lp_ctx
, FILE *f
, bool show_defaults
,
5386 if (lp_ctx
->s3_fns
) {
5387 lp_ctx
->s3_fns
->dump(f
, show_defaults
, maxtoprint
);
5391 defaults_saved
= !show_defaults
;
5393 dump_globals(lp_ctx
, f
, show_defaults
);
5395 dump_a_service(lp_ctx
->sDefault
, lp_ctx
->sDefault
, f
, lp_ctx
->flags
);
5397 for (iService
= 0; iService
< maxtoprint
; iService
++)
5398 lpcfg_dump_one(f
, show_defaults
, lp_ctx
->services
[iService
], lp_ctx
->sDefault
);
5402 * Display the contents of one service in human-readable form.
5404 void lpcfg_dump_one(FILE *f
, bool show_defaults
, struct loadparm_service
*service
, struct loadparm_service
*sDefault
)
5406 if (service
!= NULL
) {
5407 if (service
->szService
[0] == '\0')
5409 dump_a_service(service
, sDefault
, f
, NULL
);
5413 struct loadparm_service
*lpcfg_servicebynum(struct loadparm_context
*lp_ctx
,
5416 if (lp_ctx
->s3_fns
) {
5417 return lp_ctx
->s3_fns
->get_servicebynum(snum
);
5420 return lp_ctx
->services
[snum
];
5423 struct loadparm_service
*lpcfg_service(struct loadparm_context
*lp_ctx
,
5424 const char *service_name
)
5429 if (lp_ctx
->s3_fns
) {
5430 return lp_ctx
->s3_fns
->get_service(service_name
);
5433 for (iService
= lp_ctx
->iNumServices
- 1; iService
>= 0; iService
--) {
5434 if (lp_ctx
->services
[iService
] &&
5435 lp_ctx
->services
[iService
]->szService
) {
5437 * The substitution here is used to support %U is
5440 serviceName
= standard_sub_basic(
5441 lp_ctx
->services
[iService
],
5442 lp_ctx
->services
[iService
]->szService
);
5443 if (strequal(serviceName
, service_name
)) {
5444 talloc_free(serviceName
);
5445 return lp_ctx
->services
[iService
];
5447 talloc_free(serviceName
);
5451 DEBUG(7,("lpcfg_servicenumber: couldn't find %s\n", service_name
));
5455 const char *lpcfg_servicename(const struct loadparm_service
*service
)
5457 return lp_string((const char *)service
->szService
);
5461 * A useful volume label function.
5463 const char *lpcfg_volume_label(struct loadparm_service
*service
, struct loadparm_service
*sDefault
)
5466 ret
= lp_string((const char *)((service
!= NULL
&& service
->volume
!= NULL
) ?
5467 service
->volume
: sDefault
->volume
));
5469 return lpcfg_servicename(service
);
5474 * If we are PDC then prefer us as DMB
5476 const char *lpcfg_printername(struct loadparm_service
*service
, struct loadparm_service
*sDefault
)
5479 ret
= lp_string((const char *)((service
!= NULL
&& service
->szPrintername
!= NULL
) ?
5480 service
->szPrintername
: sDefault
->szPrintername
));
5481 if (ret
== NULL
|| (ret
!= NULL
&& *ret
== '\0'))
5482 ret
= lpcfg_servicename(service
);
5489 * Return the max print jobs per queue.
5491 int lpcfg_maxprintjobs(struct loadparm_service
*service
, struct loadparm_service
*sDefault
)
5493 int maxjobs
= (service
!= NULL
) ? service
->iMaxPrintJobs
: sDefault
->iMaxPrintJobs
;
5494 if (maxjobs
<= 0 || maxjobs
>= PRINT_MAX_JOBID
)
5495 maxjobs
= PRINT_MAX_JOBID
- 1;
5500 struct smb_iconv_handle
*lpcfg_iconv_handle(struct loadparm_context
*lp_ctx
)
5502 if (lp_ctx
== NULL
) {
5503 return get_iconv_handle();
5505 return lp_ctx
->iconv_handle
;
5508 _PUBLIC_
void reload_charcnv(struct loadparm_context
*lp_ctx
)
5510 struct smb_iconv_handle
*old_ic
= lp_ctx
->iconv_handle
;
5511 if (!lp_ctx
->global
) {
5515 if (old_ic
== NULL
) {
5516 old_ic
= global_iconv_handle
;
5518 lp_ctx
->iconv_handle
= smb_iconv_handle_reinit_lp(lp_ctx
, lp_ctx
, old_ic
);
5519 global_iconv_handle
= lp_ctx
->iconv_handle
;
5522 _PUBLIC_
char *lpcfg_tls_keyfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
)
5524 return lpcfg_private_path(mem_ctx
, lp_ctx
, lp_ctx
->globals
->tls_keyfile
);
5527 _PUBLIC_
char *lpcfg_tls_certfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
)
5529 return lpcfg_private_path(mem_ctx
, lp_ctx
, lp_ctx
->globals
->tls_certfile
);
5532 _PUBLIC_
char *lpcfg_tls_cafile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
)
5534 return lpcfg_private_path(mem_ctx
, lp_ctx
, lp_ctx
->globals
->tls_cafile
);
5537 _PUBLIC_
char *lpcfg_tls_crlfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
)
5539 return lpcfg_private_path(mem_ctx
, lp_ctx
, lp_ctx
->globals
->tls_crlfile
);
5542 _PUBLIC_
char *lpcfg_tls_dhpfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
)
5544 return lpcfg_private_path(mem_ctx
, lp_ctx
, lp_ctx
->globals
->tls_dhpfile
);
5547 struct gensec_settings
*lpcfg_gensec_settings(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
)
5549 struct gensec_settings
*settings
= talloc_zero(mem_ctx
, struct gensec_settings
);
5550 if (settings
== NULL
)
5552 SMB_ASSERT(lp_ctx
!= NULL
);
5553 settings
->lp_ctx
= talloc_reference(settings
, lp_ctx
);
5554 settings
->target_hostname
= lpcfg_parm_string(lp_ctx
, NULL
, "gensec", "target_hostname");
5558 int lpcfg_server_role(struct loadparm_context
*lp_ctx
)
5560 int domain_master
= lpcfg__domain_master(lp_ctx
);
5562 return lp_find_server_role(lpcfg__server_role(lp_ctx
),
5563 lpcfg__security(lp_ctx
),
5564 lpcfg__domain_logons(lp_ctx
),
5565 (domain_master
== true) ||
5566 (domain_master
== Auto
));
5569 int lpcfg_security(struct loadparm_context
*lp_ctx
)
5571 return lp_find_security(lpcfg__server_role(lp_ctx
),
5572 lpcfg__security(lp_ctx
));