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) Michael Adam 2008
13 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
14 Copyright (C) Andrew Bartlett 2011
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
57 #include "system/filesys.h"
59 #include "lib/param/loadparm.h"
61 #include "lib/smbconf/smbconf.h"
62 #include "lib/smbconf/smbconf_init.h"
65 #include "../librpc/gen_ndr/svcctl.h"
67 #include "../libcli/smb/smb_signing.h"
68 #include "dbwrap/dbwrap.h"
69 #include "dbwrap/dbwrap_rbt.h"
70 #include "../lib/util/bitmap.h"
71 #include "../source4/dns_server/dns_update.h"
73 #ifdef HAVE_SYS_SYSCTL_H
74 #include <sys/sysctl.h>
77 #ifdef HAVE_HTTPCONNECTENCRYPT
78 #include <cups/http.h>
81 #ifdef CLUSTER_SUPPORT
82 #include "ctdb_private.h"
87 extern userdom_struct current_user_info;
89 /* the special value for the include parameter
90 * to be interpreted not as a file name but to
91 * trigger loading of the global smb.conf options
93 #ifndef INCLUDE_REGISTRY_NAME
94 #define INCLUDE_REGISTRY_NAME "registry"
97 static bool in_client = false; /* Not in the client by default */
98 static struct smbconf_csn conf_last_csn;
100 static int config_backend = CONFIG_BACKEND_FILE;
102 /* some helpful bits */
103 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
104 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
106 #define USERSHARE_VALID 1
107 #define USERSHARE_PENDING_DELETE 2
109 static bool defaults_saved = false;
111 #define LOADPARM_EXTRA_GLOBALS \
112 struct parmlist_entry *param_opt; \
115 int iminreceivefile; \
116 char *szPrintcapname; \
118 int iPreferredMaster; \
120 char *szLdapMachineSuffix; \
121 char *szLdapUserSuffix; \
122 char *szLdapIdmapSuffix; \
123 char *szLdapGroupSuffix; \
126 char *szSocketAddress; \
127 char *szUsershareTemplateShare; \
130 int winbindMaxDomainConnections; \
131 int ismb2_max_credits; \
133 char *tls_certfile; \
137 char *panic_action; \
138 int bPreferredMaster;
140 #include "param/param_global.h"
142 static struct loadparm_global Globals;
144 /* This is a default service used to prime a services structure */
145 static struct loadparm_service sDefault =
150 .usershare_last_mod = {0, 0},
154 .szInvalidUsers = NULL,
155 .szValidUsers = NULL,
156 .szAdminUsers = NULL,
161 .szRootPreExec = NULL,
162 .szRootPostExec = NULL,
163 .szCupsOptions = NULL,
164 .szPrintcommand = NULL,
165 .szLpqcommand = NULL,
166 .szLprmcommand = NULL,
167 .szLppausecommand = NULL,
168 .szLpresumecommand = NULL,
169 .szQueuepausecommand = NULL,
170 .szQueueresumecommand = NULL,
171 .szPrintername = NULL,
172 .szPrintjobUsername = NULL,
173 .szDontdescend = NULL,
174 .szHostsallow = NULL,
176 .szMagicScript = NULL,
177 .szMagicOutput = NULL,
180 .szVetoOplockFiles = NULL,
188 .szVfsObjects = NULL,
189 .szMSDfsProxy = NULL,
190 .szAioWriteBehind = NULL,
193 .iMaxPrintJobs = 1000,
194 .iMaxReportedPrintJobs = 0,
195 .iWriteCacheSize = 0,
196 .iCreate_mask = 0744,
197 .iCreate_force_mode = 0,
198 .iSecurity_mask = 0777,
199 .iSecurity_force_mode = 0,
201 .iDir_force_mode = 0,
202 .iDir_Security_mask = 0777,
203 .iDir_Security_force_mode = 0,
204 .iMaxConnections = 0,
205 .iDefaultCase = CASE_LOWER,
206 .iPrinting = DEFAULT_PRINTING,
207 .iOplockContentionLimit = 2,
210 .iDfreeCacheTime = 0,
211 .bPreexecClose = false,
212 .bRootpreexecClose = false,
213 .iCaseSensitive = Auto,
214 .bCasePreserve = true,
215 .bShortCasePreserve = true,
216 .bHideDotFiles = true,
217 .bHideSpecialFiles = false,
218 .bHideUnReadable = false,
219 .bHideUnWriteableFiles = false,
221 .bAccessBasedShareEnum = false,
225 .bGuest_only = false,
226 .bAdministrative_share = false,
229 .bPrintNotifyBackchannel = true,
230 .bMap_system = false,
231 .bMap_hidden = false,
232 .bMap_archive = true,
233 .bStoreDosAttributes = false,
234 .bDmapiSupport = false,
236 .iStrictLocking = Auto,
237 .bPosixLocking = true,
240 .bKernelOplocks = false,
241 .bLevel2OpLocks = true,
243 .bMangledNames = true,
246 .bSyncAlways = false,
247 .bStrictAllocate = false,
248 .bStrictSync = false,
251 .bDeleteReadonly = false,
252 .bFakeOplocks = false,
253 .bDeleteVetoFiles = false,
254 .bDosFilemode = false,
255 .bDosFiletimes = true,
256 .bDosFiletimeResolution = false,
257 .bFakeDirCreateTimes = false,
258 .bBlockingLocks = true,
259 .bInheritPerms = false,
260 .bInheritACLS = false,
261 .bInheritOwner = false,
263 .bUseClientDriver = false,
264 .bDefaultDevmode = true,
265 .bForcePrintername = false,
266 .bNTAclSupport = true,
267 .bForceUnknownAclUser = false,
268 .bUseSendfile = false,
269 .bProfileAcls = false,
270 .bMap_acl_inherit = false,
273 .bAclCheckPermissions = true,
274 .bAclMapFullControl = true,
275 .bAclGroupControl = false,
276 .bChangeNotify = true,
277 .bKernelChangeNotify = true,
278 .iallocation_roundup_size = SMB_ROUNDUP_ALLOCATION_SIZE,
281 .iMap_readonly = MAP_READONLY_YES,
282 #ifdef BROKEN_DIRECTORY_HANDLING
283 .iDirectoryNameCacheSize = 0,
285 .iDirectoryNameCacheSize = 100,
287 .ismb_encrypt = Auto,
292 /* local variables */
293 static struct loadparm_service **ServicePtrs = NULL;
294 static int iNumServices = 0;
295 static int iServiceIndex = 0;
296 static struct db_context *ServiceHash;
297 static int *invalid_services = NULL;
298 static int num_invalid_services = 0;
299 static bool bInGlobalSection = true;
300 static bool bGlobalOnly = false;
302 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
304 /* prototypes for the special type handlers */
305 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
306 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
307 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
308 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
309 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
310 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
311 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
312 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
313 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
314 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
315 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
316 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
318 static void set_allowed_client_auth(void);
320 static void add_to_file_list(const char *fname, const char *subfname);
321 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
322 static void free_param_opts(struct parmlist_entry **popts);
324 #include "lib/param/param_table.c"
326 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
328 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
329 * screen in SWAT. This is used to exclude parameters as well as to squash all
330 * parameters that have been duplicated by pseudonyms.
332 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
333 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
334 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
337 * NOTE2: Handling of duplicated (synonym) parameters:
338 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
339 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
340 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
341 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
344 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
345 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
348 static struct parm_struct parm_table[] = {
349 {N_("Base Options"), P_SEP, P_SEPARATOR},
352 .label = "dos charset",
355 .offset = GLOBAL_VAR(dos_charset),
356 .special = handle_dos_charset,
358 .flags = FLAG_ADVANCED
361 .label = "unix charset",
364 .offset = GLOBAL_VAR(unix_charset),
365 .special = handle_charset,
367 .flags = FLAG_ADVANCED
373 .offset = LOCAL_VAR(comment),
376 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
382 .offset = LOCAL_VAR(szPath),
385 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
388 .label = "directory",
391 .offset = LOCAL_VAR(szPath),
397 .label = "workgroup",
400 .offset = GLOBAL_VAR(szWorkgroup),
403 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
409 .offset = GLOBAL_VAR(szRealm),
410 .special = handle_realm,
412 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
415 .label = "netbios name",
418 .offset = GLOBAL_VAR(szNetbiosName),
421 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
424 .label = "netbios aliases",
427 .offset = GLOBAL_VAR(szNetbiosAliases),
428 .special = handle_netbios_aliases,
430 .flags = FLAG_ADVANCED,
433 .label = "netbios scope",
436 .offset = GLOBAL_VAR(szNetbiosScope),
439 .flags = FLAG_ADVANCED,
442 .label = "server string",
445 .offset = GLOBAL_VAR(szServerString),
448 .flags = FLAG_BASIC | FLAG_ADVANCED,
451 .label = "interfaces",
454 .offset = GLOBAL_VAR(szInterfaces),
457 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
460 .label = "bind interfaces only",
463 .offset = GLOBAL_VAR(bBindInterfacesOnly),
466 .flags = FLAG_ADVANCED | FLAG_WIZARD,
469 .label = "config backend",
472 .offset = GLOBAL_VAR(ConfigBackend),
474 .enum_list = enum_config_backend,
475 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
478 .label = "server role",
481 .offset = GLOBAL_VAR(server_role),
483 .enum_list = enum_server_role,
484 .flags = FLAG_BASIC | FLAG_ADVANCED,
487 {N_("Security Options"), P_SEP, P_SEPARATOR},
493 .offset = GLOBAL_VAR(security),
495 .enum_list = enum_security,
496 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
499 .label = "auth methods",
502 .offset = GLOBAL_VAR(AuthMethods),
505 .flags = FLAG_ADVANCED,
508 .label = "encrypt passwords",
511 .offset = GLOBAL_VAR(bEncryptPasswords),
514 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
517 .label = "client schannel",
520 .offset = GLOBAL_VAR(clientSchannel),
522 .enum_list = enum_bool_auto,
523 .flags = FLAG_BASIC | FLAG_ADVANCED,
526 .label = "server schannel",
529 .offset = GLOBAL_VAR(serverSchannel),
531 .enum_list = enum_bool_auto,
532 .flags = FLAG_BASIC | FLAG_ADVANCED,
535 .label = "allow trusted domains",
538 .offset = GLOBAL_VAR(bAllowTrustedDomains),
541 .flags = FLAG_ADVANCED,
544 .label = "map to guest",
547 .offset = GLOBAL_VAR(map_to_guest),
549 .enum_list = enum_map_to_guest,
550 .flags = FLAG_ADVANCED,
553 .label = "null passwords",
556 .offset = GLOBAL_VAR(bNullPasswords),
559 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
562 .label = "obey pam restrictions",
565 .offset = GLOBAL_VAR(bObeyPamRestrictions),
568 .flags = FLAG_ADVANCED,
571 .label = "password server",
574 .offset = GLOBAL_VAR(szPasswordServer),
577 .flags = FLAG_ADVANCED | FLAG_WIZARD,
580 .label = "smb passwd file",
583 .offset = GLOBAL_VAR(szSMBPasswdFile),
586 .flags = FLAG_ADVANCED,
589 .label = "private dir",
592 .offset = GLOBAL_VAR(szPrivateDir),
595 .flags = FLAG_ADVANCED,
598 .label = "private directory",
601 .offset = GLOBAL_VAR(szPrivateDir),
607 .label = "passdb backend",
610 .offset = GLOBAL_VAR(passdb_backend),
613 .flags = FLAG_ADVANCED | FLAG_WIZARD,
616 .label = "algorithmic rid base",
619 .offset = GLOBAL_VAR(AlgorithmicRidBase),
622 .flags = FLAG_ADVANCED,
625 .label = "root directory",
628 .offset = GLOBAL_VAR(szRootdir),
631 .flags = FLAG_ADVANCED,
637 .offset = GLOBAL_VAR(szRootdir),
646 .offset = GLOBAL_VAR(szRootdir),
652 .label = "guest account",
655 .offset = GLOBAL_VAR(szGuestaccount),
658 .flags = FLAG_BASIC | FLAG_ADVANCED,
661 .label = "enable privileges",
664 .offset = GLOBAL_VAR(bEnablePrivileges),
667 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
671 .label = "pam password change",
674 .offset = GLOBAL_VAR(bPamPasswordChange),
677 .flags = FLAG_ADVANCED,
680 .label = "passwd program",
683 .offset = GLOBAL_VAR(szPasswdProgram),
686 .flags = FLAG_ADVANCED,
689 .label = "passwd chat",
692 .offset = GLOBAL_VAR(szPasswdChat),
695 .flags = FLAG_ADVANCED,
698 .label = "passwd chat debug",
701 .offset = GLOBAL_VAR(bPasswdChatDebug),
704 .flags = FLAG_ADVANCED,
707 .label = "passwd chat timeout",
710 .offset = GLOBAL_VAR(iPasswdChatTimeout),
713 .flags = FLAG_ADVANCED,
716 .label = "check password script",
719 .offset = GLOBAL_VAR(szCheckPasswordScript),
722 .flags = FLAG_ADVANCED,
725 .label = "username map",
728 .offset = GLOBAL_VAR(szUsernameMap),
731 .flags = FLAG_ADVANCED,
734 .label = "password level",
737 .offset = GLOBAL_VAR(pwordlevel),
740 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
743 .label = "username level",
746 .offset = GLOBAL_VAR(unamelevel),
749 .flags = FLAG_ADVANCED,
752 .label = "unix password sync",
755 .offset = GLOBAL_VAR(bUnixPasswdSync),
758 .flags = FLAG_ADVANCED,
761 .label = "restrict anonymous",
764 .offset = GLOBAL_VAR(restrict_anonymous),
767 .flags = FLAG_ADVANCED,
770 .label = "lanman auth",
773 .offset = GLOBAL_VAR(bLanmanAuth),
776 .flags = FLAG_ADVANCED,
779 .label = "ntlm auth",
782 .offset = GLOBAL_VAR(bNTLMAuth),
785 .flags = FLAG_ADVANCED,
788 .label = "client NTLMv2 auth",
791 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
794 .flags = FLAG_ADVANCED,
797 .label = "client lanman auth",
800 .offset = GLOBAL_VAR(bClientLanManAuth),
803 .flags = FLAG_ADVANCED,
806 .label = "client plaintext auth",
809 .offset = GLOBAL_VAR(bClientPlaintextAuth),
812 .flags = FLAG_ADVANCED,
815 .label = "client use spnego principal",
818 .offset = GLOBAL_VAR(client_use_spnego_principal),
821 .flags = FLAG_ADVANCED,
827 .offset = LOCAL_VAR(szUsername),
830 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
836 .offset = LOCAL_VAR(szUsername),
845 .offset = LOCAL_VAR(szUsername),
851 .label = "invalid users",
854 .offset = LOCAL_VAR(szInvalidUsers),
857 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
860 .label = "valid users",
863 .offset = LOCAL_VAR(szValidUsers),
866 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
869 .label = "admin users",
872 .offset = LOCAL_VAR(szAdminUsers),
875 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
878 .label = "read list",
881 .offset = LOCAL_VAR(readlist),
884 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
887 .label = "write list",
890 .offset = LOCAL_VAR(writelist),
893 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
896 .label = "force user",
899 .offset = LOCAL_VAR(force_user),
902 .flags = FLAG_ADVANCED | FLAG_SHARE,
905 .label = "force group",
908 .offset = LOCAL_VAR(force_group),
911 .flags = FLAG_ADVANCED | FLAG_SHARE,
917 .offset = LOCAL_VAR(force_group),
920 .flags = FLAG_ADVANCED,
923 .label = "read only",
926 .offset = LOCAL_VAR(bRead_only),
929 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
935 .offset = LOCAL_VAR(bRead_only),
941 .label = "writeable",
944 .offset = LOCAL_VAR(bRead_only),
953 .offset = LOCAL_VAR(bRead_only),
959 .label = "acl check permissions",
962 .offset = LOCAL_VAR(bAclCheckPermissions),
965 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
968 .label = "acl group control",
971 .offset = LOCAL_VAR(bAclGroupControl),
974 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
977 .label = "acl map full control",
980 .offset = LOCAL_VAR(bAclMapFullControl),
983 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
986 .label = "create mask",
989 .offset = LOCAL_VAR(iCreate_mask),
992 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
995 .label = "create mode",
998 .offset = LOCAL_VAR(iCreate_mask),
1004 .label = "force create mode",
1007 .offset = LOCAL_VAR(iCreate_force_mode),
1010 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1013 .label = "security mask",
1016 .offset = LOCAL_VAR(iSecurity_mask),
1019 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1022 .label = "force security mode",
1025 .offset = LOCAL_VAR(iSecurity_force_mode),
1028 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1031 .label = "directory mask",
1034 .offset = LOCAL_VAR(iDir_mask),
1037 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1040 .label = "directory mode",
1043 .offset = LOCAL_VAR(iDir_mask),
1046 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1049 .label = "force directory mode",
1052 .offset = LOCAL_VAR(iDir_force_mode),
1055 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1058 .label = "directory security mask",
1061 .offset = LOCAL_VAR(iDir_Security_mask),
1064 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1067 .label = "force directory security mode",
1070 .offset = LOCAL_VAR(iDir_Security_force_mode),
1073 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1076 .label = "force unknown acl user",
1079 .offset = LOCAL_VAR(bForceUnknownAclUser),
1082 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1085 .label = "inherit permissions",
1088 .offset = LOCAL_VAR(bInheritPerms),
1091 .flags = FLAG_ADVANCED | FLAG_SHARE,
1094 .label = "inherit acls",
1097 .offset = LOCAL_VAR(bInheritACLS),
1100 .flags = FLAG_ADVANCED | FLAG_SHARE,
1103 .label = "inherit owner",
1106 .offset = LOCAL_VAR(bInheritOwner),
1109 .flags = FLAG_ADVANCED | FLAG_SHARE,
1112 .label = "guest only",
1115 .offset = LOCAL_VAR(bGuest_only),
1118 .flags = FLAG_ADVANCED | FLAG_SHARE,
1121 .label = "only guest",
1124 .offset = LOCAL_VAR(bGuest_only),
1130 .label = "administrative share",
1133 .offset = LOCAL_VAR(bAdministrative_share),
1136 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1140 .label = "guest ok",
1143 .offset = LOCAL_VAR(bGuest_ok),
1146 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1152 .offset = LOCAL_VAR(bGuest_ok),
1158 .label = "only user",
1161 .offset = LOCAL_VAR(bOnlyUser),
1164 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1167 .label = "hosts allow",
1170 .offset = LOCAL_VAR(szHostsallow),
1173 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1176 .label = "allow hosts",
1179 .offset = LOCAL_VAR(szHostsallow),
1185 .label = "hosts deny",
1188 .offset = LOCAL_VAR(szHostsdeny),
1191 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1194 .label = "deny hosts",
1197 .offset = LOCAL_VAR(szHostsdeny),
1203 .label = "preload modules",
1205 .p_class = P_GLOBAL,
1206 .offset = GLOBAL_VAR(szPreloadModules),
1209 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1212 .label = "dedicated keytab file",
1214 .p_class = P_GLOBAL,
1215 .offset = GLOBAL_VAR(szDedicatedKeytabFile),
1218 .flags = FLAG_ADVANCED,
1221 .label = "kerberos method",
1223 .p_class = P_GLOBAL,
1224 .offset = GLOBAL_VAR(iKerberosMethod),
1226 .enum_list = enum_kerberos_method,
1227 .flags = FLAG_ADVANCED,
1230 .label = "map untrusted to domain",
1232 .p_class = P_GLOBAL,
1233 .offset = GLOBAL_VAR(bMapUntrustedToDomain),
1236 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1240 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1243 .label = "log level",
1245 .p_class = P_GLOBAL,
1246 .offset = GLOBAL_VAR(loglevel),
1247 .special = handle_debug_list,
1249 .flags = FLAG_ADVANCED,
1252 .label = "debuglevel",
1254 .p_class = P_GLOBAL,
1255 .offset = GLOBAL_VAR(loglevel),
1256 .special = handle_debug_list,
1263 .p_class = P_GLOBAL,
1264 .offset = GLOBAL_VAR(syslog),
1267 .flags = FLAG_ADVANCED,
1270 .label = "syslog only",
1272 .p_class = P_GLOBAL,
1273 .offset = GLOBAL_VAR(bSyslogOnly),
1276 .flags = FLAG_ADVANCED,
1279 .label = "log file",
1281 .p_class = P_GLOBAL,
1282 .offset = GLOBAL_VAR(logfile),
1285 .flags = FLAG_ADVANCED,
1288 .label = "max log size",
1290 .p_class = P_GLOBAL,
1291 .offset = GLOBAL_VAR(max_log_size),
1294 .flags = FLAG_ADVANCED,
1297 .label = "debug timestamp",
1299 .p_class = P_GLOBAL,
1300 .offset = GLOBAL_VAR(bTimestampLogs),
1303 .flags = FLAG_ADVANCED,
1306 .label = "timestamp logs",
1308 .p_class = P_GLOBAL,
1309 .offset = GLOBAL_VAR(bTimestampLogs),
1312 .flags = FLAG_ADVANCED,
1315 .label = "debug prefix timestamp",
1317 .p_class = P_GLOBAL,
1318 .offset = GLOBAL_VAR(bDebugPrefixTimestamp),
1321 .flags = FLAG_ADVANCED,
1324 .label = "debug hires timestamp",
1326 .p_class = P_GLOBAL,
1327 .offset = GLOBAL_VAR(bDebugHiresTimestamp),
1330 .flags = FLAG_ADVANCED,
1333 .label = "debug pid",
1335 .p_class = P_GLOBAL,
1336 .offset = GLOBAL_VAR(bDebugPid),
1339 .flags = FLAG_ADVANCED,
1342 .label = "debug uid",
1344 .p_class = P_GLOBAL,
1345 .offset = GLOBAL_VAR(bDebugUid),
1348 .flags = FLAG_ADVANCED,
1351 .label = "debug class",
1353 .p_class = P_GLOBAL,
1354 .offset = GLOBAL_VAR(bDebugClass),
1357 .flags = FLAG_ADVANCED,
1360 .label = "enable core files",
1362 .p_class = P_GLOBAL,
1363 .offset = GLOBAL_VAR(bEnableCoreFiles),
1366 .flags = FLAG_ADVANCED,
1369 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1372 .label = "allocation roundup size",
1375 .offset = LOCAL_VAR(iallocation_roundup_size),
1378 .flags = FLAG_ADVANCED,
1381 .label = "aio read size",
1384 .offset = LOCAL_VAR(iAioReadSize),
1387 .flags = FLAG_ADVANCED,
1390 .label = "aio write size",
1393 .offset = LOCAL_VAR(iAioWriteSize),
1396 .flags = FLAG_ADVANCED,
1399 .label = "aio write behind",
1402 .offset = LOCAL_VAR(szAioWriteBehind),
1405 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1408 .label = "smb ports",
1410 .p_class = P_GLOBAL,
1411 .offset = GLOBAL_VAR(smb_ports),
1414 .flags = FLAG_ADVANCED,
1417 .label = "large readwrite",
1419 .p_class = P_GLOBAL,
1420 .offset = GLOBAL_VAR(bLargeReadwrite),
1423 .flags = FLAG_ADVANCED,
1426 .label = "server max protocol",
1428 .p_class = P_GLOBAL,
1429 .offset = GLOBAL_VAR(srv_maxprotocol),
1431 .enum_list = enum_protocol,
1432 .flags = FLAG_ADVANCED,
1435 .label = "max protocol",
1437 .p_class = P_GLOBAL,
1438 .offset = GLOBAL_VAR(srv_maxprotocol),
1440 .enum_list = enum_protocol,
1441 .flags = FLAG_ADVANCED,
1444 .label = "protocol",
1446 .p_class = P_GLOBAL,
1447 .offset = GLOBAL_VAR(srv_maxprotocol),
1449 .enum_list = enum_protocol,
1450 .flags = FLAG_ADVANCED,
1453 .label = "server min protocol",
1455 .p_class = P_GLOBAL,
1456 .offset = GLOBAL_VAR(srv_minprotocol),
1458 .enum_list = enum_protocol,
1459 .flags = FLAG_ADVANCED,
1462 .label = "min protocol",
1464 .p_class = P_GLOBAL,
1465 .offset = GLOBAL_VAR(srv_minprotocol),
1467 .enum_list = enum_protocol,
1468 .flags = FLAG_ADVANCED,
1471 .label = "client max protocol",
1473 .p_class = P_GLOBAL,
1474 .offset = GLOBAL_VAR(cli_maxprotocol),
1476 .enum_list = enum_protocol,
1477 .flags = FLAG_ADVANCED,
1480 .label = "client min protocol",
1482 .p_class = P_GLOBAL,
1483 .offset = GLOBAL_VAR(cli_minprotocol),
1485 .enum_list = enum_protocol,
1486 .flags = FLAG_ADVANCED,
1491 .p_class = P_GLOBAL,
1492 .offset = GLOBAL_VAR(bUnicode),
1497 .label = "min receivefile size",
1499 .p_class = P_GLOBAL,
1500 .offset = GLOBAL_VAR(iminreceivefile),
1503 .flags = FLAG_ADVANCED,
1506 .label = "read raw",
1508 .p_class = P_GLOBAL,
1509 .offset = GLOBAL_VAR(bReadRaw),
1512 .flags = FLAG_ADVANCED,
1515 .label = "write raw",
1517 .p_class = P_GLOBAL,
1518 .offset = GLOBAL_VAR(bWriteRaw),
1521 .flags = FLAG_ADVANCED,
1524 .label = "disable netbios",
1526 .p_class = P_GLOBAL,
1527 .offset = GLOBAL_VAR(bDisableNetbios),
1530 .flags = FLAG_ADVANCED,
1533 .label = "reset on zero vc",
1535 .p_class = P_GLOBAL,
1536 .offset = GLOBAL_VAR(bResetOnZeroVC),
1539 .flags = FLAG_ADVANCED,
1542 .label = "log writeable files on exit",
1544 .p_class = P_GLOBAL,
1545 .offset = GLOBAL_VAR(bLogWriteableFilesOnExit),
1548 .flags = FLAG_ADVANCED,
1551 .label = "acl compatibility",
1553 .p_class = P_GLOBAL,
1554 .offset = GLOBAL_VAR(iAclCompat),
1556 .enum_list = enum_acl_compat_vals,
1557 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1560 .label = "defer sharing violations",
1562 .p_class = P_GLOBAL,
1563 .offset = GLOBAL_VAR(bDeferSharingViolations),
1566 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1569 .label = "ea support",
1572 .offset = LOCAL_VAR(bEASupport),
1575 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1578 .label = "nt acl support",
1581 .offset = LOCAL_VAR(bNTAclSupport),
1584 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1587 .label = "nt pipe support",
1589 .p_class = P_GLOBAL,
1590 .offset = GLOBAL_VAR(bNTPipeSupport),
1593 .flags = FLAG_ADVANCED,
1596 .label = "nt status support",
1598 .p_class = P_GLOBAL,
1599 .offset = GLOBAL_VAR(bNTStatusSupport),
1602 .flags = FLAG_ADVANCED,
1605 .label = "profile acls",
1608 .offset = LOCAL_VAR(bProfileAcls),
1611 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1614 .label = "map acl inherit",
1617 .offset = LOCAL_VAR(bMap_acl_inherit),
1620 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1623 .label = "afs share",
1626 .offset = LOCAL_VAR(bAfs_Share),
1629 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1634 .p_class = P_GLOBAL,
1635 .offset = GLOBAL_VAR(max_mux),
1638 .flags = FLAG_ADVANCED,
1641 .label = "max xmit",
1643 .p_class = P_GLOBAL,
1644 .offset = GLOBAL_VAR(max_xmit),
1647 .flags = FLAG_ADVANCED,
1650 .label = "name resolve order",
1652 .p_class = P_GLOBAL,
1653 .offset = GLOBAL_VAR(szNameResolveOrder),
1656 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1661 .p_class = P_GLOBAL,
1662 .offset = GLOBAL_VAR(max_ttl),
1665 .flags = FLAG_ADVANCED,
1668 .label = "max wins ttl",
1670 .p_class = P_GLOBAL,
1671 .offset = GLOBAL_VAR(max_wins_ttl),
1674 .flags = FLAG_ADVANCED,
1677 .label = "min wins ttl",
1679 .p_class = P_GLOBAL,
1680 .offset = GLOBAL_VAR(min_wins_ttl),
1683 .flags = FLAG_ADVANCED,
1686 .label = "time server",
1688 .p_class = P_GLOBAL,
1689 .offset = GLOBAL_VAR(bTimeServer),
1692 .flags = FLAG_ADVANCED,
1695 .label = "unix extensions",
1697 .p_class = P_GLOBAL,
1698 .offset = GLOBAL_VAR(bUnixExtensions),
1701 .flags = FLAG_ADVANCED,
1704 .label = "use spnego",
1706 .p_class = P_GLOBAL,
1707 .offset = GLOBAL_VAR(bUseSpnego),
1710 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
1713 .label = "client signing",
1715 .p_class = P_GLOBAL,
1716 .offset = GLOBAL_VAR(client_signing),
1718 .enum_list = enum_smb_signing_vals,
1719 .flags = FLAG_ADVANCED,
1722 .label = "server signing",
1724 .p_class = P_GLOBAL,
1725 .offset = GLOBAL_VAR(server_signing),
1727 .enum_list = enum_smb_signing_vals,
1728 .flags = FLAG_ADVANCED,
1731 .label = "smb encrypt",
1734 .offset = LOCAL_VAR(ismb_encrypt),
1736 .enum_list = enum_smb_signing_vals,
1737 .flags = FLAG_ADVANCED,
1740 .label = "client use spnego",
1742 .p_class = P_GLOBAL,
1743 .offset = GLOBAL_VAR(bClientUseSpnego),
1746 .flags = FLAG_ADVANCED,
1749 .label = "client ldap sasl wrapping",
1751 .p_class = P_GLOBAL,
1752 .offset = GLOBAL_VAR(client_ldap_sasl_wrapping),
1754 .enum_list = enum_ldap_sasl_wrapping,
1755 .flags = FLAG_ADVANCED,
1758 .label = "enable asu support",
1760 .p_class = P_GLOBAL,
1761 .offset = GLOBAL_VAR(bASUSupport),
1764 .flags = FLAG_ADVANCED,
1767 .label = "svcctl list",
1769 .p_class = P_GLOBAL,
1770 .offset = GLOBAL_VAR(szServicesList),
1773 .flags = FLAG_ADVANCED,
1776 .label = "cldap port",
1778 .p_class = P_GLOBAL,
1779 .offset = GLOBAL_VAR(cldap_port),
1784 .label = "dgram port",
1786 .p_class = P_GLOBAL,
1787 .offset = GLOBAL_VAR(dgram_port),
1792 .label = "nbt port",
1794 .p_class = P_GLOBAL,
1795 .offset = GLOBAL_VAR(nbt_port),
1800 .label = "krb5 port",
1802 .p_class = P_GLOBAL,
1803 .offset = GLOBAL_VAR(krb5_port),
1808 .label = "kpasswd port",
1810 .p_class = P_GLOBAL,
1811 .offset = GLOBAL_VAR(kpasswd_port),
1816 .label = "web port",
1818 .p_class = P_GLOBAL,
1819 .offset = GLOBAL_VAR(web_port),
1824 .label = "rpc big endian",
1826 .p_class = P_GLOBAL,
1827 .offset = GLOBAL_VAR(bRpcBigEndian),
1832 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
1835 .label = "block size",
1838 .offset = LOCAL_VAR(iBlock_size),
1841 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1844 .label = "deadtime",
1846 .p_class = P_GLOBAL,
1847 .offset = GLOBAL_VAR(deadtime),
1850 .flags = FLAG_ADVANCED,
1853 .label = "getwd cache",
1855 .p_class = P_GLOBAL,
1856 .offset = GLOBAL_VAR(getwd_cache),
1859 .flags = FLAG_ADVANCED,
1862 .label = "keepalive",
1864 .p_class = P_GLOBAL,
1865 .offset = GLOBAL_VAR(iKeepalive),
1868 .flags = FLAG_ADVANCED,
1871 .label = "change notify",
1874 .offset = LOCAL_VAR(bChangeNotify),
1877 .flags = FLAG_ADVANCED | FLAG_SHARE,
1880 .label = "directory name cache size",
1883 .offset = LOCAL_VAR(iDirectoryNameCacheSize),
1886 .flags = FLAG_ADVANCED | FLAG_SHARE,
1889 .label = "kernel change notify",
1892 .offset = LOCAL_VAR(bKernelChangeNotify),
1895 .flags = FLAG_ADVANCED | FLAG_SHARE,
1898 .label = "lpq cache time",
1900 .p_class = P_GLOBAL,
1901 .offset = GLOBAL_VAR(lpqcachetime),
1904 .flags = FLAG_ADVANCED,
1907 .label = "max smbd processes",
1909 .p_class = P_GLOBAL,
1910 .offset = GLOBAL_VAR(iMaxSmbdProcesses),
1913 .flags = FLAG_ADVANCED,
1916 .label = "max connections",
1919 .offset = LOCAL_VAR(iMaxConnections),
1922 .flags = FLAG_ADVANCED | FLAG_SHARE,
1925 .label = "paranoid server security",
1927 .p_class = P_GLOBAL,
1928 .offset = GLOBAL_VAR(paranoid_server_security),
1931 .flags = FLAG_ADVANCED,
1934 .label = "max disk size",
1936 .p_class = P_GLOBAL,
1937 .offset = GLOBAL_VAR(maxdisksize),
1940 .flags = FLAG_ADVANCED,
1943 .label = "max open files",
1945 .p_class = P_GLOBAL,
1946 .offset = GLOBAL_VAR(max_open_files),
1949 .flags = FLAG_ADVANCED,
1952 .label = "min print space",
1955 .offset = LOCAL_VAR(iMinPrintSpace),
1958 .flags = FLAG_ADVANCED | FLAG_PRINT,
1961 .label = "socket options",
1963 .p_class = P_GLOBAL,
1964 .offset = GLOBAL_VAR(socket_options),
1967 .flags = FLAG_ADVANCED,
1970 .label = "strict allocate",
1973 .offset = LOCAL_VAR(bStrictAllocate),
1976 .flags = FLAG_ADVANCED | FLAG_SHARE,
1979 .label = "strict sync",
1982 .offset = LOCAL_VAR(bStrictSync),
1985 .flags = FLAG_ADVANCED | FLAG_SHARE,
1988 .label = "sync always",
1991 .offset = LOCAL_VAR(bSyncAlways),
1994 .flags = FLAG_ADVANCED | FLAG_SHARE,
1997 .label = "use mmap",
1999 .p_class = P_GLOBAL,
2000 .offset = GLOBAL_VAR(bUseMmap),
2003 .flags = FLAG_ADVANCED,
2006 .label = "use sendfile",
2009 .offset = LOCAL_VAR(bUseSendfile),
2012 .flags = FLAG_ADVANCED | FLAG_SHARE,
2015 .label = "hostname lookups",
2017 .p_class = P_GLOBAL,
2018 .offset = GLOBAL_VAR(bHostnameLookups),
2021 .flags = FLAG_ADVANCED,
2024 .label = "write cache size",
2027 .offset = LOCAL_VAR(iWriteCacheSize),
2030 .flags = FLAG_ADVANCED | FLAG_SHARE,
2033 .label = "name cache timeout",
2035 .p_class = P_GLOBAL,
2036 .offset = GLOBAL_VAR(name_cache_timeout),
2039 .flags = FLAG_ADVANCED,
2042 .label = "ctdbd socket",
2044 .p_class = P_GLOBAL,
2045 .offset = GLOBAL_VAR(ctdbdSocket),
2048 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2051 .label = "cluster addresses",
2053 .p_class = P_GLOBAL,
2054 .offset = GLOBAL_VAR(szClusterAddresses),
2057 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2060 .label = "clustering",
2062 .p_class = P_GLOBAL,
2063 .offset = GLOBAL_VAR(clustering),
2066 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2069 .label = "ctdb timeout",
2071 .p_class = P_GLOBAL,
2072 .offset = GLOBAL_VAR(ctdb_timeout),
2075 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2078 .label = "ctdb locktime warn threshold",
2080 .p_class = P_GLOBAL,
2081 .offset = GLOBAL_VAR(ctdb_locktime_warn_threshold),
2084 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2087 .label = "smb2 max read",
2089 .p_class = P_GLOBAL,
2090 .offset = GLOBAL_VAR(ismb2_max_read),
2093 .flags = FLAG_ADVANCED,
2096 .label = "smb2 max write",
2098 .p_class = P_GLOBAL,
2099 .offset = GLOBAL_VAR(ismb2_max_write),
2102 .flags = FLAG_ADVANCED,
2105 .label = "smb2 max trans",
2107 .p_class = P_GLOBAL,
2108 .offset = GLOBAL_VAR(ismb2_max_trans),
2111 .flags = FLAG_ADVANCED,
2114 .label = "smb2 max credits",
2116 .p_class = P_GLOBAL,
2117 .offset = GLOBAL_VAR(ismb2_max_credits),
2120 .flags = FLAG_ADVANCED,
2123 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2126 .label = "max reported print jobs",
2129 .offset = LOCAL_VAR(iMaxReportedPrintJobs),
2132 .flags = FLAG_ADVANCED | FLAG_PRINT,
2135 .label = "max print jobs",
2138 .offset = LOCAL_VAR(iMaxPrintJobs),
2141 .flags = FLAG_ADVANCED | FLAG_PRINT,
2144 .label = "load printers",
2146 .p_class = P_GLOBAL,
2147 .offset = GLOBAL_VAR(bLoadPrinters),
2150 .flags = FLAG_ADVANCED | FLAG_PRINT,
2153 .label = "printcap cache time",
2155 .p_class = P_GLOBAL,
2156 .offset = GLOBAL_VAR(PrintcapCacheTime),
2159 .flags = FLAG_ADVANCED | FLAG_PRINT,
2162 .label = "printcap name",
2164 .p_class = P_GLOBAL,
2165 .offset = GLOBAL_VAR(szPrintcapname),
2168 .flags = FLAG_ADVANCED | FLAG_PRINT,
2171 .label = "printcap",
2173 .p_class = P_GLOBAL,
2174 .offset = GLOBAL_VAR(szPrintcapname),
2180 .label = "printable",
2183 .offset = LOCAL_VAR(bPrint_ok),
2186 .flags = FLAG_ADVANCED | FLAG_PRINT,
2189 .label = "print notify backchannel",
2192 .offset = LOCAL_VAR(bPrintNotifyBackchannel),
2195 .flags = FLAG_ADVANCED,
2198 .label = "print ok",
2201 .offset = LOCAL_VAR(bPrint_ok),
2207 .label = "printing",
2210 .offset = LOCAL_VAR(iPrinting),
2211 .special = handle_printing,
2212 .enum_list = enum_printing,
2213 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2216 .label = "cups options",
2219 .offset = LOCAL_VAR(szCupsOptions),
2222 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2225 .label = "cups server",
2227 .p_class = P_GLOBAL,
2228 .offset = GLOBAL_VAR(szCupsServer),
2231 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2234 .label = "cups encrypt",
2236 .p_class = P_GLOBAL,
2237 .offset = GLOBAL_VAR(CupsEncrypt),
2239 .enum_list = enum_bool_auto,
2240 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2244 .label = "cups connection timeout",
2246 .p_class = P_GLOBAL,
2247 .offset = GLOBAL_VAR(cups_connection_timeout),
2250 .flags = FLAG_ADVANCED,
2253 .label = "iprint server",
2255 .p_class = P_GLOBAL,
2256 .offset = GLOBAL_VAR(szIPrintServer),
2259 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2262 .label = "print command",
2265 .offset = LOCAL_VAR(szPrintcommand),
2268 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2271 .label = "disable spoolss",
2273 .p_class = P_GLOBAL,
2274 .offset = GLOBAL_VAR(bDisableSpoolss),
2277 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2280 .label = "enable spoolss",
2282 .p_class = P_GLOBAL,
2283 .offset = GLOBAL_VAR(bDisableSpoolss),
2289 .label = "lpq command",
2292 .offset = LOCAL_VAR(szLpqcommand),
2295 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2298 .label = "lprm command",
2301 .offset = LOCAL_VAR(szLprmcommand),
2304 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2307 .label = "lppause command",
2310 .offset = LOCAL_VAR(szLppausecommand),
2313 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2316 .label = "lpresume command",
2319 .offset = LOCAL_VAR(szLpresumecommand),
2322 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2325 .label = "queuepause command",
2328 .offset = LOCAL_VAR(szQueuepausecommand),
2331 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2334 .label = "queueresume command",
2337 .offset = LOCAL_VAR(szQueueresumecommand),
2340 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2343 .label = "addport command",
2345 .p_class = P_GLOBAL,
2346 .offset = GLOBAL_VAR(szAddPortCommand),
2349 .flags = FLAG_ADVANCED,
2352 .label = "enumports command",
2354 .p_class = P_GLOBAL,
2355 .offset = GLOBAL_VAR(szEnumPortsCommand),
2358 .flags = FLAG_ADVANCED,
2361 .label = "addprinter command",
2363 .p_class = P_GLOBAL,
2364 .offset = GLOBAL_VAR(szAddPrinterCommand),
2367 .flags = FLAG_ADVANCED,
2370 .label = "deleteprinter command",
2372 .p_class = P_GLOBAL,
2373 .offset = GLOBAL_VAR(szDeletePrinterCommand),
2376 .flags = FLAG_ADVANCED,
2379 .label = "show add printer wizard",
2381 .p_class = P_GLOBAL,
2382 .offset = GLOBAL_VAR(bMsAddPrinterWizard),
2385 .flags = FLAG_ADVANCED,
2388 .label = "os2 driver map",
2390 .p_class = P_GLOBAL,
2391 .offset = GLOBAL_VAR(szOs2DriverMap),
2394 .flags = FLAG_ADVANCED,
2398 .label = "printer name",
2401 .offset = LOCAL_VAR(szPrintername),
2404 .flags = FLAG_ADVANCED | FLAG_PRINT,
2410 .offset = LOCAL_VAR(szPrintername),
2416 .label = "use client driver",
2419 .offset = LOCAL_VAR(bUseClientDriver),
2422 .flags = FLAG_ADVANCED | FLAG_PRINT,
2425 .label = "default devmode",
2428 .offset = LOCAL_VAR(bDefaultDevmode),
2431 .flags = FLAG_ADVANCED | FLAG_PRINT,
2434 .label = "force printername",
2437 .offset = LOCAL_VAR(bForcePrintername),
2440 .flags = FLAG_ADVANCED | FLAG_PRINT,
2443 .label = "printjob username",
2446 .offset = LOCAL_VAR(szPrintjobUsername),
2449 .flags = FLAG_ADVANCED | FLAG_PRINT,
2452 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2455 .label = "mangling method",
2457 .p_class = P_GLOBAL,
2458 .offset = GLOBAL_VAR(szManglingMethod),
2461 .flags = FLAG_ADVANCED,
2464 .label = "mangle prefix",
2466 .p_class = P_GLOBAL,
2467 .offset = GLOBAL_VAR(mangle_prefix),
2470 .flags = FLAG_ADVANCED,
2474 .label = "default case",
2477 .offset = LOCAL_VAR(iDefaultCase),
2479 .enum_list = enum_case,
2480 .flags = FLAG_ADVANCED | FLAG_SHARE,
2483 .label = "case sensitive",
2486 .offset = LOCAL_VAR(iCaseSensitive),
2488 .enum_list = enum_bool_auto,
2489 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2492 .label = "casesignames",
2495 .offset = LOCAL_VAR(iCaseSensitive),
2497 .enum_list = enum_bool_auto,
2498 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2501 .label = "preserve case",
2504 .offset = LOCAL_VAR(bCasePreserve),
2507 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2510 .label = "short preserve case",
2513 .offset = LOCAL_VAR(bShortCasePreserve),
2516 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2519 .label = "mangling char",
2522 .offset = LOCAL_VAR(magic_char),
2525 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2528 .label = "hide dot files",
2531 .offset = LOCAL_VAR(bHideDotFiles),
2534 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2537 .label = "hide special files",
2540 .offset = LOCAL_VAR(bHideSpecialFiles),
2543 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2546 .label = "hide unreadable",
2549 .offset = LOCAL_VAR(bHideUnReadable),
2552 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2555 .label = "hide unwriteable files",
2558 .offset = LOCAL_VAR(bHideUnWriteableFiles),
2561 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2564 .label = "delete veto files",
2567 .offset = LOCAL_VAR(bDeleteVetoFiles),
2570 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2573 .label = "veto files",
2576 .offset = LOCAL_VAR(szVetoFiles),
2579 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2582 .label = "hide files",
2585 .offset = LOCAL_VAR(szHideFiles),
2588 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2591 .label = "veto oplock files",
2594 .offset = LOCAL_VAR(szVetoOplockFiles),
2597 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2600 .label = "map archive",
2603 .offset = LOCAL_VAR(bMap_archive),
2606 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2609 .label = "map hidden",
2612 .offset = LOCAL_VAR(bMap_hidden),
2615 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2618 .label = "map system",
2621 .offset = LOCAL_VAR(bMap_system),
2624 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2627 .label = "map readonly",
2630 .offset = LOCAL_VAR(iMap_readonly),
2632 .enum_list = enum_map_readonly,
2633 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2636 .label = "mangled names",
2639 .offset = LOCAL_VAR(bMangledNames),
2642 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2645 .label = "max stat cache size",
2647 .p_class = P_GLOBAL,
2648 .offset = GLOBAL_VAR(iMaxStatCacheSize),
2651 .flags = FLAG_ADVANCED,
2654 .label = "stat cache",
2656 .p_class = P_GLOBAL,
2657 .offset = GLOBAL_VAR(bStatCache),
2660 .flags = FLAG_ADVANCED,
2663 .label = "store dos attributes",
2666 .offset = LOCAL_VAR(bStoreDosAttributes),
2669 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2672 .label = "dmapi support",
2675 .offset = LOCAL_VAR(bDmapiSupport),
2678 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2682 {N_("Domain Options"), P_SEP, P_SEPARATOR},
2685 .label = "machine password timeout",
2687 .p_class = P_GLOBAL,
2688 .offset = GLOBAL_VAR(machine_password_timeout),
2691 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2694 {N_("Logon Options"), P_SEP, P_SEPARATOR},
2697 .label = "add user script",
2699 .p_class = P_GLOBAL,
2700 .offset = GLOBAL_VAR(szAddUserScript),
2703 .flags = FLAG_ADVANCED,
2706 .label = "rename user script",
2708 .p_class = P_GLOBAL,
2709 .offset = GLOBAL_VAR(szRenameUserScript),
2712 .flags = FLAG_ADVANCED,
2715 .label = "delete user script",
2717 .p_class = P_GLOBAL,
2718 .offset = GLOBAL_VAR(szDelUserScript),
2721 .flags = FLAG_ADVANCED,
2724 .label = "add group script",
2726 .p_class = P_GLOBAL,
2727 .offset = GLOBAL_VAR(szAddGroupScript),
2730 .flags = FLAG_ADVANCED,
2733 .label = "delete group script",
2735 .p_class = P_GLOBAL,
2736 .offset = GLOBAL_VAR(szDelGroupScript),
2739 .flags = FLAG_ADVANCED,
2742 .label = "add user to group script",
2744 .p_class = P_GLOBAL,
2745 .offset = GLOBAL_VAR(szAddUserToGroupScript),
2748 .flags = FLAG_ADVANCED,
2751 .label = "delete user from group script",
2753 .p_class = P_GLOBAL,
2754 .offset = GLOBAL_VAR(szDelUserFromGroupScript),
2757 .flags = FLAG_ADVANCED,
2760 .label = "set primary group script",
2762 .p_class = P_GLOBAL,
2763 .offset = GLOBAL_VAR(szSetPrimaryGroupScript),
2766 .flags = FLAG_ADVANCED,
2769 .label = "add machine script",
2771 .p_class = P_GLOBAL,
2772 .offset = GLOBAL_VAR(szAddMachineScript),
2775 .flags = FLAG_ADVANCED,
2778 .label = "shutdown script",
2780 .p_class = P_GLOBAL,
2781 .offset = GLOBAL_VAR(szShutdownScript),
2784 .flags = FLAG_ADVANCED,
2787 .label = "abort shutdown script",
2789 .p_class = P_GLOBAL,
2790 .offset = GLOBAL_VAR(szAbortShutdownScript),
2793 .flags = FLAG_ADVANCED,
2796 .label = "username map script",
2798 .p_class = P_GLOBAL,
2799 .offset = GLOBAL_VAR(szUsernameMapScript),
2802 .flags = FLAG_ADVANCED,
2805 .label = "username map cache time",
2807 .p_class = P_GLOBAL,
2808 .offset = GLOBAL_VAR(iUsernameMapCacheTime),
2811 .flags = FLAG_ADVANCED,
2814 .label = "logon script",
2816 .p_class = P_GLOBAL,
2817 .offset = GLOBAL_VAR(szLogonScript),
2820 .flags = FLAG_ADVANCED,
2823 .label = "logon path",
2825 .p_class = P_GLOBAL,
2826 .offset = GLOBAL_VAR(szLogonPath),
2829 .flags = FLAG_ADVANCED,
2832 .label = "logon drive",
2834 .p_class = P_GLOBAL,
2835 .offset = GLOBAL_VAR(szLogonDrive),
2838 .flags = FLAG_ADVANCED,
2841 .label = "logon home",
2843 .p_class = P_GLOBAL,
2844 .offset = GLOBAL_VAR(szLogonHome),
2847 .flags = FLAG_ADVANCED,
2850 .label = "domain logons",
2852 .p_class = P_GLOBAL,
2853 .offset = GLOBAL_VAR(bDomainLogons),
2856 .flags = FLAG_ADVANCED,
2860 .label = "init logon delayed hosts",
2862 .p_class = P_GLOBAL,
2863 .offset = GLOBAL_VAR(szInitLogonDelayedHosts),
2866 .flags = FLAG_ADVANCED,
2870 .label = "init logon delay",
2872 .p_class = P_GLOBAL,
2873 .offset = GLOBAL_VAR(InitLogonDelay),
2876 .flags = FLAG_ADVANCED,
2880 {N_("Browse Options"), P_SEP, P_SEPARATOR},
2883 .label = "os level",
2885 .p_class = P_GLOBAL,
2886 .offset = GLOBAL_VAR(os_level),
2889 .flags = FLAG_BASIC | FLAG_ADVANCED,
2892 .label = "lm announce",
2894 .p_class = P_GLOBAL,
2895 .offset = GLOBAL_VAR(lm_announce),
2897 .enum_list = enum_bool_auto,
2898 .flags = FLAG_ADVANCED,
2901 .label = "lm interval",
2903 .p_class = P_GLOBAL,
2904 .offset = GLOBAL_VAR(lm_interval),
2907 .flags = FLAG_ADVANCED,
2910 .label = "preferred master",
2912 .p_class = P_GLOBAL,
2913 .offset = GLOBAL_VAR(iPreferredMaster),
2915 .enum_list = enum_bool_auto,
2916 .flags = FLAG_BASIC | FLAG_ADVANCED,
2919 .label = "prefered master",
2921 .p_class = P_GLOBAL,
2922 .offset = GLOBAL_VAR(iPreferredMaster),
2924 .enum_list = enum_bool_auto,
2928 .label = "local master",
2930 .p_class = P_GLOBAL,
2931 .offset = GLOBAL_VAR(bLocalMaster),
2934 .flags = FLAG_BASIC | FLAG_ADVANCED,
2937 .label = "domain master",
2939 .p_class = P_GLOBAL,
2940 .offset = GLOBAL_VAR(domain_master),
2942 .enum_list = enum_bool_auto,
2943 .flags = FLAG_BASIC | FLAG_ADVANCED,
2946 .label = "browse list",
2948 .p_class = P_GLOBAL,
2949 .offset = GLOBAL_VAR(bBrowseList),
2952 .flags = FLAG_ADVANCED,
2955 .label = "browseable",
2958 .offset = LOCAL_VAR(bBrowseable),
2961 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
2964 .label = "browsable",
2967 .offset = LOCAL_VAR(bBrowseable),
2973 .label = "access based share enum",
2976 .offset = LOCAL_VAR(bAccessBasedShareEnum),
2979 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
2982 .label = "enhanced browsing",
2984 .p_class = P_GLOBAL,
2985 .offset = GLOBAL_VAR(enhanced_browsing),
2988 .flags = FLAG_ADVANCED,
2991 {N_("WINS Options"), P_SEP, P_SEPARATOR},
2994 .label = "dns proxy",
2996 .p_class = P_GLOBAL,
2997 .offset = GLOBAL_VAR(bWINSdnsProxy),
3000 .flags = FLAG_ADVANCED,
3003 .label = "wins proxy",
3005 .p_class = P_GLOBAL,
3006 .offset = GLOBAL_VAR(bWINSproxy),
3009 .flags = FLAG_ADVANCED,
3012 .label = "wins server",
3014 .p_class = P_GLOBAL,
3015 .offset = GLOBAL_VAR(szWINSservers),
3018 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3021 .label = "wins support",
3023 .p_class = P_GLOBAL,
3024 .offset = GLOBAL_VAR(bWINSsupport),
3027 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3030 .label = "wins hook",
3032 .p_class = P_GLOBAL,
3033 .offset = GLOBAL_VAR(szWINSHook),
3036 .flags = FLAG_ADVANCED,
3039 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3042 .label = "blocking locks",
3045 .offset = LOCAL_VAR(bBlockingLocks),
3048 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3051 .label = "csc policy",
3054 .offset = LOCAL_VAR(iCSCPolicy),
3056 .enum_list = enum_csc_policy,
3057 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3060 .label = "fake oplocks",
3063 .offset = LOCAL_VAR(bFakeOplocks),
3066 .flags = FLAG_ADVANCED | FLAG_SHARE,
3069 .label = "kernel oplocks",
3072 .offset = LOCAL_VAR(bKernelOplocks),
3075 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3081 .offset = LOCAL_VAR(bLocking),
3084 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3087 .label = "lock spin time",
3089 .p_class = P_GLOBAL,
3090 .offset = GLOBAL_VAR(iLockSpinTime),
3093 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3099 .offset = LOCAL_VAR(bOpLocks),
3102 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3105 .label = "level2 oplocks",
3108 .offset = LOCAL_VAR(bLevel2OpLocks),
3111 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3114 .label = "oplock break wait time",
3116 .p_class = P_GLOBAL,
3117 .offset = GLOBAL_VAR(oplock_break_wait_time),
3120 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3123 .label = "oplock contention limit",
3126 .offset = LOCAL_VAR(iOplockContentionLimit),
3129 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3132 .label = "posix locking",
3135 .offset = LOCAL_VAR(bPosixLocking),
3138 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3141 .label = "strict locking",
3144 .offset = LOCAL_VAR(iStrictLocking),
3146 .enum_list = enum_bool_auto,
3147 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3150 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3153 .label = "ldap admin dn",
3155 .p_class = P_GLOBAL,
3156 .offset = GLOBAL_VAR(szLdapAdminDn),
3159 .flags = FLAG_ADVANCED,
3162 .label = "ldap delete dn",
3164 .p_class = P_GLOBAL,
3165 .offset = GLOBAL_VAR(ldap_delete_dn),
3168 .flags = FLAG_ADVANCED,
3171 .label = "ldap group suffix",
3173 .p_class = P_GLOBAL,
3174 .offset = GLOBAL_VAR(szLdapGroupSuffix),
3177 .flags = FLAG_ADVANCED,
3180 .label = "ldap idmap suffix",
3182 .p_class = P_GLOBAL,
3183 .offset = GLOBAL_VAR(szLdapIdmapSuffix),
3186 .flags = FLAG_ADVANCED,
3189 .label = "ldap machine suffix",
3191 .p_class = P_GLOBAL,
3192 .offset = GLOBAL_VAR(szLdapMachineSuffix),
3195 .flags = FLAG_ADVANCED,
3198 .label = "ldap passwd sync",
3200 .p_class = P_GLOBAL,
3201 .offset = GLOBAL_VAR(ldap_passwd_sync),
3203 .enum_list = enum_ldap_passwd_sync,
3204 .flags = FLAG_ADVANCED,
3207 .label = "ldap password sync",
3209 .p_class = P_GLOBAL,
3210 .offset = GLOBAL_VAR(ldap_passwd_sync),
3212 .enum_list = enum_ldap_passwd_sync,
3216 .label = "ldap replication sleep",
3218 .p_class = P_GLOBAL,
3219 .offset = GLOBAL_VAR(ldap_replication_sleep),
3222 .flags = FLAG_ADVANCED,
3225 .label = "ldap suffix",
3227 .p_class = P_GLOBAL,
3228 .offset = GLOBAL_VAR(szLdapSuffix),
3231 .flags = FLAG_ADVANCED,
3234 .label = "ldap ssl",
3236 .p_class = P_GLOBAL,
3237 .offset = GLOBAL_VAR(ldap_ssl),
3239 .enum_list = enum_ldap_ssl,
3240 .flags = FLAG_ADVANCED,
3243 .label = "ldap ssl ads",
3245 .p_class = P_GLOBAL,
3246 .offset = GLOBAL_VAR(ldap_ssl_ads),
3249 .flags = FLAG_ADVANCED,
3252 .label = "ldap deref",
3254 .p_class = P_GLOBAL,
3255 .offset = GLOBAL_VAR(ldap_deref),
3257 .enum_list = enum_ldap_deref,
3258 .flags = FLAG_ADVANCED,
3261 .label = "ldap follow referral",
3263 .p_class = P_GLOBAL,
3264 .offset = GLOBAL_VAR(ldap_follow_referral),
3266 .enum_list = enum_bool_auto,
3267 .flags = FLAG_ADVANCED,
3270 .label = "ldap timeout",
3272 .p_class = P_GLOBAL,
3273 .offset = GLOBAL_VAR(ldap_timeout),
3276 .flags = FLAG_ADVANCED,
3279 .label = "ldap connection timeout",
3281 .p_class = P_GLOBAL,
3282 .offset = GLOBAL_VAR(ldap_connection_timeout),
3285 .flags = FLAG_ADVANCED,
3288 .label = "ldap page size",
3290 .p_class = P_GLOBAL,
3291 .offset = GLOBAL_VAR(ldap_page_size),
3294 .flags = FLAG_ADVANCED,
3297 .label = "ldap user suffix",
3299 .p_class = P_GLOBAL,
3300 .offset = GLOBAL_VAR(szLdapUserSuffix),
3303 .flags = FLAG_ADVANCED,
3306 .label = "ldap debug level",
3308 .p_class = P_GLOBAL,
3309 .offset = GLOBAL_VAR(ldap_debug_level),
3310 .special = handle_ldap_debug_level,
3312 .flags = FLAG_ADVANCED,
3315 .label = "ldap debug threshold",
3317 .p_class = P_GLOBAL,
3318 .offset = GLOBAL_VAR(ldap_debug_threshold),
3321 .flags = FLAG_ADVANCED,
3324 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3327 .label = "eventlog list",
3329 .p_class = P_GLOBAL,
3330 .offset = GLOBAL_VAR(szEventLogs),
3333 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3336 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3339 .label = "add share command",
3341 .p_class = P_GLOBAL,
3342 .offset = GLOBAL_VAR(szAddShareCommand),
3345 .flags = FLAG_ADVANCED,
3348 .label = "change share command",
3350 .p_class = P_GLOBAL,
3351 .offset = GLOBAL_VAR(szChangeShareCommand),
3354 .flags = FLAG_ADVANCED,
3357 .label = "delete share command",
3359 .p_class = P_GLOBAL,
3360 .offset = GLOBAL_VAR(szDeleteShareCommand),
3363 .flags = FLAG_ADVANCED,
3366 .label = "config file",
3368 .p_class = P_GLOBAL,
3369 .offset = GLOBAL_VAR(szConfigFile),
3372 .flags = FLAG_HIDE|FLAG_META,
3377 .p_class = P_GLOBAL,
3378 .offset = GLOBAL_VAR(szAutoServices),
3381 .flags = FLAG_ADVANCED,
3384 .label = "auto services",
3386 .p_class = P_GLOBAL,
3387 .offset = GLOBAL_VAR(szAutoServices),
3390 .flags = FLAG_ADVANCED,
3393 .label = "lock directory",
3395 .p_class = P_GLOBAL,
3396 .offset = GLOBAL_VAR(szLockDir),
3399 .flags = FLAG_ADVANCED,
3402 .label = "lock dir",
3404 .p_class = P_GLOBAL,
3405 .offset = GLOBAL_VAR(szLockDir),
3411 .label = "state directory",
3413 .p_class = P_GLOBAL,
3414 .offset = GLOBAL_VAR(szStateDir),
3417 .flags = FLAG_ADVANCED,
3420 .label = "cache directory",
3422 .p_class = P_GLOBAL,
3423 .offset = GLOBAL_VAR(szCacheDir),
3426 .flags = FLAG_ADVANCED,
3429 .label = "pid directory",
3431 .p_class = P_GLOBAL,
3432 .offset = GLOBAL_VAR(szPidDir),
3435 .flags = FLAG_ADVANCED,
3438 .label = "ntp signd socket directory",
3440 .p_class = P_GLOBAL,
3441 .offset = GLOBAL_VAR(szNTPSignDSocketDirectory),
3444 .flags = FLAG_ADVANCED,
3449 .label = "utmp directory",
3451 .p_class = P_GLOBAL,
3452 .offset = GLOBAL_VAR(szUtmpDir),
3455 .flags = FLAG_ADVANCED,
3458 .label = "wtmp directory",
3460 .p_class = P_GLOBAL,
3461 .offset = GLOBAL_VAR(szWtmpDir),
3464 .flags = FLAG_ADVANCED,
3469 .p_class = P_GLOBAL,
3470 .offset = GLOBAL_VAR(bUtmp),
3473 .flags = FLAG_ADVANCED,
3477 .label = "default service",
3479 .p_class = P_GLOBAL,
3480 .offset = GLOBAL_VAR(szDefaultService),
3483 .flags = FLAG_ADVANCED,
3488 .p_class = P_GLOBAL,
3489 .offset = GLOBAL_VAR(szDefaultService),
3492 .flags = FLAG_ADVANCED,
3495 .label = "message command",
3497 .p_class = P_GLOBAL,
3498 .offset = GLOBAL_VAR(szMsgCommand),
3501 .flags = FLAG_ADVANCED,
3504 .label = "dfree cache time",
3507 .offset = LOCAL_VAR(iDfreeCacheTime),
3510 .flags = FLAG_ADVANCED,
3513 .label = "dfree command",
3516 .offset = LOCAL_VAR(szDfree),
3519 .flags = FLAG_ADVANCED,
3522 .label = "get quota command",
3524 .p_class = P_GLOBAL,
3525 .offset = GLOBAL_VAR(szGetQuota),
3528 .flags = FLAG_ADVANCED,
3531 .label = "set quota command",
3533 .p_class = P_GLOBAL,
3534 .offset = GLOBAL_VAR(szSetQuota),
3537 .flags = FLAG_ADVANCED,
3540 .label = "remote announce",
3542 .p_class = P_GLOBAL,
3543 .offset = GLOBAL_VAR(szRemoteAnnounce),
3546 .flags = FLAG_ADVANCED,
3549 .label = "remote browse sync",
3551 .p_class = P_GLOBAL,
3552 .offset = GLOBAL_VAR(szRemoteBrowseSync),
3555 .flags = FLAG_ADVANCED,
3558 .label = "socket address",
3560 .p_class = P_GLOBAL,
3561 .offset = GLOBAL_VAR(szSocketAddress),
3564 .flags = FLAG_ADVANCED,
3567 .label = "nmbd bind explicit broadcast",
3569 .p_class = P_GLOBAL,
3570 .offset = GLOBAL_VAR(bNmbdBindExplicitBroadcast),
3573 .flags = FLAG_ADVANCED,
3576 .label = "homedir map",
3578 .p_class = P_GLOBAL,
3579 .offset = GLOBAL_VAR(szNISHomeMapName),
3582 .flags = FLAG_ADVANCED,
3585 .label = "afs username map",
3587 .p_class = P_GLOBAL,
3588 .offset = GLOBAL_VAR(szAfsUsernameMap),
3591 .flags = FLAG_ADVANCED,
3594 .label = "afs token lifetime",
3596 .p_class = P_GLOBAL,
3597 .offset = GLOBAL_VAR(iAfsTokenLifetime),
3600 .flags = FLAG_ADVANCED,
3603 .label = "log nt token command",
3605 .p_class = P_GLOBAL,
3606 .offset = GLOBAL_VAR(szLogNtTokenCommand),
3609 .flags = FLAG_ADVANCED,
3612 .label = "NIS homedir",
3614 .p_class = P_GLOBAL,
3615 .offset = GLOBAL_VAR(bNISHomeMap),
3618 .flags = FLAG_ADVANCED,
3624 .offset = LOCAL_VAR(valid),
3633 .offset = LOCAL_VAR(szCopy),
3634 .special = handle_copy,
3642 .offset = LOCAL_VAR(szInclude),
3643 .special = handle_include,
3645 .flags = FLAG_HIDE|FLAG_META,
3651 .offset = LOCAL_VAR(szPreExec),
3654 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3660 .offset = LOCAL_VAR(szPreExec),
3663 .flags = FLAG_ADVANCED,
3666 .label = "preexec close",
3669 .offset = LOCAL_VAR(bPreexecClose),
3672 .flags = FLAG_ADVANCED | FLAG_SHARE,
3675 .label = "postexec",
3678 .offset = LOCAL_VAR(szPostExec),
3681 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3684 .label = "root preexec",
3687 .offset = LOCAL_VAR(szRootPreExec),
3690 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3693 .label = "root preexec close",
3696 .offset = LOCAL_VAR(bRootpreexecClose),
3699 .flags = FLAG_ADVANCED | FLAG_SHARE,
3702 .label = "root postexec",
3705 .offset = LOCAL_VAR(szRootPostExec),
3708 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3711 .label = "available",
3714 .offset = LOCAL_VAR(bAvailable),
3717 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3720 .label = "registry shares",
3722 .p_class = P_GLOBAL,
3723 .offset = GLOBAL_VAR(bRegistryShares),
3726 .flags = FLAG_ADVANCED,
3729 .label = "usershare allow guests",
3731 .p_class = P_GLOBAL,
3732 .offset = GLOBAL_VAR(bUsershareAllowGuests),
3735 .flags = FLAG_ADVANCED,
3738 .label = "usershare max shares",
3740 .p_class = P_GLOBAL,
3741 .offset = GLOBAL_VAR(iUsershareMaxShares),
3744 .flags = FLAG_ADVANCED,
3747 .label = "usershare owner only",
3749 .p_class = P_GLOBAL,
3750 .offset = GLOBAL_VAR(bUsershareOwnerOnly),
3753 .flags = FLAG_ADVANCED,
3756 .label = "usershare path",
3758 .p_class = P_GLOBAL,
3759 .offset = GLOBAL_VAR(szUsersharePath),
3762 .flags = FLAG_ADVANCED,
3765 .label = "usershare prefix allow list",
3767 .p_class = P_GLOBAL,
3768 .offset = GLOBAL_VAR(szUsersharePrefixAllowList),
3771 .flags = FLAG_ADVANCED,
3774 .label = "usershare prefix deny list",
3776 .p_class = P_GLOBAL,
3777 .offset = GLOBAL_VAR(szUsersharePrefixDenyList),
3780 .flags = FLAG_ADVANCED,
3783 .label = "usershare template share",
3785 .p_class = P_GLOBAL,
3786 .offset = GLOBAL_VAR(szUsershareTemplateShare),
3789 .flags = FLAG_ADVANCED,
3795 .offset = LOCAL_VAR(volume),
3798 .flags = FLAG_ADVANCED | FLAG_SHARE,
3804 .offset = LOCAL_VAR(fstype),
3807 .flags = FLAG_ADVANCED | FLAG_SHARE,
3810 .label = "set directory",
3813 .offset = LOCAL_VAR(bNo_set_dir),
3816 .flags = FLAG_ADVANCED | FLAG_SHARE,
3819 .label = "allow insecure wide links",
3821 .p_class = P_GLOBAL,
3822 .offset = GLOBAL_VAR(bAllowInsecureWidelinks),
3825 .flags = FLAG_ADVANCED,
3828 .label = "wide links",
3831 .offset = LOCAL_VAR(bWidelinks),
3834 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3837 .label = "follow symlinks",
3840 .offset = LOCAL_VAR(bSymlinks),
3843 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3846 .label = "dont descend",
3849 .offset = LOCAL_VAR(szDontdescend),
3852 .flags = FLAG_ADVANCED | FLAG_SHARE,
3855 .label = "magic script",
3858 .offset = LOCAL_VAR(szMagicScript),
3861 .flags = FLAG_ADVANCED | FLAG_SHARE,
3864 .label = "magic output",
3867 .offset = LOCAL_VAR(szMagicOutput),
3870 .flags = FLAG_ADVANCED | FLAG_SHARE,
3873 .label = "delete readonly",
3876 .offset = LOCAL_VAR(bDeleteReadonly),
3879 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3882 .label = "dos filemode",
3885 .offset = LOCAL_VAR(bDosFilemode),
3888 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3891 .label = "dos filetimes",
3894 .offset = LOCAL_VAR(bDosFiletimes),
3897 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3900 .label = "dos filetime resolution",
3903 .offset = LOCAL_VAR(bDosFiletimeResolution),
3906 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3909 .label = "fake directory create times",
3912 .offset = LOCAL_VAR(bFakeDirCreateTimes),
3915 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3918 .label = "async smb echo handler",
3920 .p_class = P_GLOBAL,
3921 .offset = GLOBAL_VAR(bAsyncSMBEchoHandler),
3924 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3927 .label = "panic action",
3929 .p_class = P_GLOBAL,
3930 .offset = GLOBAL_VAR(szPanicAction),
3933 .flags = FLAG_ADVANCED,
3936 .label = "perfcount module",
3938 .p_class = P_GLOBAL,
3939 .offset = GLOBAL_VAR(szSMBPerfcountModule),
3942 .flags = FLAG_ADVANCED,
3945 {N_("VFS module options"), P_SEP, P_SEPARATOR},
3948 .label = "vfs objects",
3951 .offset = LOCAL_VAR(szVfsObjects),
3954 .flags = FLAG_ADVANCED | FLAG_SHARE,
3957 .label = "vfs object",
3960 .offset = LOCAL_VAR(szVfsObjects),
3967 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
3970 .label = "msdfs root",
3973 .offset = LOCAL_VAR(bMSDfsRoot),
3976 .flags = FLAG_ADVANCED | FLAG_SHARE,
3979 .label = "msdfs proxy",
3982 .offset = LOCAL_VAR(szMSDfsProxy),
3985 .flags = FLAG_ADVANCED | FLAG_SHARE,
3988 .label = "host msdfs",
3990 .p_class = P_GLOBAL,
3991 .offset = GLOBAL_VAR(bHostMSDfs),
3994 .flags = FLAG_ADVANCED,
3997 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4000 .label = "passdb expand explicit",
4002 .p_class = P_GLOBAL,
4003 .offset = GLOBAL_VAR(bPassdbExpandExplicit),
4006 .flags = FLAG_ADVANCED,
4009 .label = "idmap backend",
4011 .p_class = P_GLOBAL,
4012 .offset = GLOBAL_VAR(szIdmapBackend),
4013 .special = handle_idmap_backend,
4015 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4018 .label = "idmap cache time",
4020 .p_class = P_GLOBAL,
4021 .offset = GLOBAL_VAR(iIdmapCacheTime),
4024 .flags = FLAG_ADVANCED,
4027 .label = "idmap negative cache time",
4029 .p_class = P_GLOBAL,
4030 .offset = GLOBAL_VAR(iIdmapNegativeCacheTime),
4033 .flags = FLAG_ADVANCED,
4036 .label = "idmap uid",
4038 .p_class = P_GLOBAL,
4039 .offset = GLOBAL_VAR(szIdmapUID),
4040 .special = handle_idmap_uid,
4042 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4045 .label = "winbind uid",
4047 .p_class = P_GLOBAL,
4048 .offset = GLOBAL_VAR(szIdmapUID),
4049 .special = handle_idmap_uid,
4054 .label = "idmap gid",
4056 .p_class = P_GLOBAL,
4057 .offset = GLOBAL_VAR(szIdmapGID),
4058 .special = handle_idmap_gid,
4060 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4063 .label = "winbind gid",
4065 .p_class = P_GLOBAL,
4066 .offset = GLOBAL_VAR(szIdmapGID),
4067 .special = handle_idmap_gid,
4072 .label = "template homedir",
4074 .p_class = P_GLOBAL,
4075 .offset = GLOBAL_VAR(szTemplateHomedir),
4078 .flags = FLAG_ADVANCED,
4081 .label = "template shell",
4083 .p_class = P_GLOBAL,
4084 .offset = GLOBAL_VAR(szTemplateShell),
4087 .flags = FLAG_ADVANCED,
4090 .label = "winbind separator",
4092 .p_class = P_GLOBAL,
4093 .offset = GLOBAL_VAR(szWinbindSeparator),
4096 .flags = FLAG_ADVANCED,
4099 .label = "winbind cache time",
4101 .p_class = P_GLOBAL,
4102 .offset = GLOBAL_VAR(winbind_cache_time),
4105 .flags = FLAG_ADVANCED,
4108 .label = "winbind reconnect delay",
4110 .p_class = P_GLOBAL,
4111 .offset = GLOBAL_VAR(winbind_reconnect_delay),
4114 .flags = FLAG_ADVANCED,
4117 .label = "winbind max clients",
4119 .p_class = P_GLOBAL,
4120 .offset = GLOBAL_VAR(winbind_max_clients),
4123 .flags = FLAG_ADVANCED,
4126 .label = "winbind enum users",
4128 .p_class = P_GLOBAL,
4129 .offset = GLOBAL_VAR(bWinbindEnumUsers),
4132 .flags = FLAG_ADVANCED,
4135 .label = "winbind enum groups",
4137 .p_class = P_GLOBAL,
4138 .offset = GLOBAL_VAR(bWinbindEnumGroups),
4141 .flags = FLAG_ADVANCED,
4144 .label = "winbind use default domain",
4146 .p_class = P_GLOBAL,
4147 .offset = GLOBAL_VAR(bWinbindUseDefaultDomain),
4150 .flags = FLAG_ADVANCED,
4153 .label = "winbind trusted domains only",
4155 .p_class = P_GLOBAL,
4156 .offset = GLOBAL_VAR(bWinbindTrustedDomainsOnly),
4159 .flags = FLAG_ADVANCED,
4162 .label = "winbind nested groups",
4164 .p_class = P_GLOBAL,
4165 .offset = GLOBAL_VAR(bWinbindNestedGroups),
4168 .flags = FLAG_ADVANCED,
4171 .label = "winbind expand groups",
4173 .p_class = P_GLOBAL,
4174 .offset = GLOBAL_VAR(winbind_expand_groups),
4177 .flags = FLAG_ADVANCED,
4180 .label = "winbind nss info",
4182 .p_class = P_GLOBAL,
4183 .offset = GLOBAL_VAR(szWinbindNssInfo),
4186 .flags = FLAG_ADVANCED,
4189 .label = "winbind refresh tickets",
4191 .p_class = P_GLOBAL,
4192 .offset = GLOBAL_VAR(bWinbindRefreshTickets),
4195 .flags = FLAG_ADVANCED,
4198 .label = "winbind offline logon",
4200 .p_class = P_GLOBAL,
4201 .offset = GLOBAL_VAR(bWinbindOfflineLogon),
4204 .flags = FLAG_ADVANCED,
4207 .label = "winbind normalize names",
4209 .p_class = P_GLOBAL,
4210 .offset = GLOBAL_VAR(bWinbindNormalizeNames),
4213 .flags = FLAG_ADVANCED,
4216 .label = "winbind rpc only",
4218 .p_class = P_GLOBAL,
4219 .offset = GLOBAL_VAR(bWinbindRpcOnly),
4222 .flags = FLAG_ADVANCED,
4225 .label = "create krb5 conf",
4227 .p_class = P_GLOBAL,
4228 .offset = GLOBAL_VAR(bCreateKrb5Conf),
4231 .flags = FLAG_ADVANCED,
4234 .label = "ncalrpc dir",
4236 .p_class = P_GLOBAL,
4237 .offset = GLOBAL_VAR(ncalrpc_dir),
4240 .flags = FLAG_ADVANCED,
4243 .label = "winbind max domain connections",
4245 .p_class = P_GLOBAL,
4246 .offset = GLOBAL_VAR(winbindMaxDomainConnections),
4249 .flags = FLAG_ADVANCED,
4252 .label = "winbindd socket directory",
4254 .p_class = P_GLOBAL,
4255 .offset = GLOBAL_VAR(szWinbinddSocketDirectory),
4258 .flags = FLAG_ADVANCED,
4261 .label = "winbindd privileged socket directory",
4263 .p_class = P_GLOBAL,
4264 .offset = GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory),
4267 .flags = FLAG_ADVANCED,
4270 .label = "winbind sealed pipes",
4272 .p_class = P_GLOBAL,
4273 .offset = GLOBAL_VAR(bWinbindSealedPipes),
4276 .flags = FLAG_ADVANCED,
4279 {N_("DNS options"), P_SEP, P_SEPARATOR},
4281 .label = "allow dns updates",
4283 .p_class = P_GLOBAL,
4284 .offset = GLOBAL_VAR(allow_dns_updates),
4286 .enum_list = enum_dns_update_settings,
4287 .flags = FLAG_ADVANCED,
4290 .label = "dns forwarder",
4292 .p_class = P_GLOBAL,
4293 .offset = GLOBAL_VAR(dns_forwarder),
4296 .flags = FLAG_ADVANCED,
4299 .label = "dns recursive queries",
4301 .p_class = P_GLOBAL,
4302 .offset = GLOBAL_VAR(dns_recursive_queries),
4307 .label = "dns update command",
4309 .p_class = P_GLOBAL,
4310 .offset = GLOBAL_VAR(szDNSUpdateCommand),
4313 .flags = FLAG_ADVANCED,
4316 .label = "nsupdate command",
4318 .p_class = P_GLOBAL,
4319 .offset = GLOBAL_VAR(szNSUpdateCommand),
4322 .flags = FLAG_ADVANCED,
4325 .label = "rndc command",
4327 .p_class = P_GLOBAL,
4328 .offset = GLOBAL_VAR(szRNDCCommand),
4331 .flags = FLAG_ADVANCED,
4334 .label = "multicast dns register",
4336 .p_class = P_GLOBAL,
4337 .offset = GLOBAL_VAR(bMulticastDnsRegister),
4340 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4343 {N_("AD DC options"), P_SEP, P_SEPARATOR},
4346 .label = "samba kcc command",
4348 .p_class = P_GLOBAL,
4349 .offset = GLOBAL_VAR(szSambaKCCCommand),
4352 .flags = FLAG_ADVANCED,
4355 .label = "server services",
4357 .p_class = P_GLOBAL,
4358 .offset = GLOBAL_VAR(server_services),
4363 .label = "dcerpc endpoint servers",
4365 .p_class = P_GLOBAL,
4366 .offset = GLOBAL_VAR(dcerpc_ep_servers),
4371 .label = "spn update command",
4373 .p_class = P_GLOBAL,
4374 .offset = GLOBAL_VAR(szSPNUpdateCommand),
4377 .flags = FLAG_ADVANCED,
4380 .label = "share backend",
4382 .p_class = P_GLOBAL,
4383 .offset = GLOBAL_VAR(szShareBackend),
4388 .label = "ntvfs handler",
4391 .offset = LOCAL_VAR(ntvfs_handler),
4396 {N_("TLS options"), P_SEP, P_SEPARATOR},
4399 .label = "tls enabled",
4401 .p_class = P_GLOBAL,
4402 .offset = GLOBAL_VAR(tls_enabled),
4407 .label = "tls keyfile",
4409 .p_class = P_GLOBAL,
4410 .offset = GLOBAL_VAR(tls_keyfile),
4415 .label = "tls certfile",
4417 .p_class = P_GLOBAL,
4418 .offset = GLOBAL_VAR(tls_certfile),
4423 .label = "tls cafile",
4425 .p_class = P_GLOBAL,
4426 .offset = GLOBAL_VAR(tls_cafile),
4431 .label = "tls crlfile",
4433 .p_class = P_GLOBAL,
4434 .offset = GLOBAL_VAR(tls_crlfile),
4439 .label = "tls dh params file",
4441 .p_class = P_GLOBAL,
4442 .offset = GLOBAL_VAR(tls_dhpfile),
4447 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
4450 /***************************************************************************
4451 Initialise the sDefault parameter structure for the printer values.
4452 ***************************************************************************/
4454 static void init_printer_values(struct loadparm_service *pService)
4456 /* choose defaults depending on the type of printing */
4457 switch (pService->iPrinting) {
4462 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4463 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4464 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4469 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4470 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4471 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4472 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4473 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4474 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4475 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4481 /* set the lpq command to contain the destination printer
4482 name only. This is used by cups_queue_get() */
4483 string_set(&pService->szLpqcommand, "%p");
4484 string_set(&pService->szLprmcommand, "");
4485 string_set(&pService->szPrintcommand, "");
4486 string_set(&pService->szLppausecommand, "");
4487 string_set(&pService->szLpresumecommand, "");
4488 string_set(&pService->szQueuepausecommand, "");
4489 string_set(&pService->szQueueresumecommand, "");
4491 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4492 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4493 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4494 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4495 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4496 string_set(&pService->szQueuepausecommand, "disable '%p'");
4497 string_set(&pService->szQueueresumecommand, "enable '%p'");
4498 #endif /* HAVE_CUPS */
4503 string_set(&pService->szLpqcommand, "lpstat -o%p");
4504 string_set(&pService->szLprmcommand, "cancel %p-%j");
4505 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4506 string_set(&pService->szQueuepausecommand, "disable %p");
4507 string_set(&pService->szQueueresumecommand, "enable %p");
4509 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4510 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4515 string_set(&pService->szLpqcommand, "lpq -P%p");
4516 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4517 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4520 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
4524 const char *tdbfile;
4525 TALLOC_CTX *tmp_ctx = talloc_stackframe();
4528 tdbfile = talloc_asprintf(
4529 tmp_ctx, "tdbfile=%s",
4530 lp_parm_const_string(-1, "vlp", "tdbfile",
4532 if (tdbfile == NULL) {
4533 tdbfile="tdbfile=/tmp/vlp.tdb";
4536 tmp = talloc_asprintf(tmp_ctx, "vlp %s print %%p %%s",
4538 string_set(&pService->szPrintcommand,
4539 tmp ? tmp : "vlp print %p %s");
4541 tmp = talloc_asprintf(tmp_ctx, "vlp %s lpq %%p",
4543 string_set(&pService->szLpqcommand,
4544 tmp ? tmp : "vlp lpq %p");
4546 tmp = talloc_asprintf(tmp_ctx, "vlp %s lprm %%p %%j",
4548 string_set(&pService->szLprmcommand,
4549 tmp ? tmp : "vlp lprm %p %j");
4551 tmp = talloc_asprintf(tmp_ctx, "vlp %s lppause %%p %%j",
4553 string_set(&pService->szLppausecommand,
4554 tmp ? tmp : "vlp lppause %p %j");
4556 tmp = talloc_asprintf(tmp_ctx, "vlp %s lpresume %%p %%j",
4558 string_set(&pService->szLpresumecommand,
4559 tmp ? tmp : "vlp lpresume %p %j");
4561 tmp = talloc_asprintf(tmp_ctx, "vlp %s queuepause %%p",
4563 string_set(&pService->szQueuepausecommand,
4564 tmp ? tmp : "vlp queuepause %p");
4566 tmp = talloc_asprintf(tmp_ctx, "vlp %s queueresume %%p",
4568 string_set(&pService->szQueueresumecommand,
4569 tmp ? tmp : "vlp queueresume %p");
4570 TALLOC_FREE(tmp_ctx);
4574 #endif /* DEVELOPER */
4579 * Function to return the default value for the maximum number of open
4580 * file descriptors permitted. This function tries to consult the
4581 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4582 * the smaller of those.
4584 static int max_open_files(void)
4586 int sysctl_max = MAX_OPEN_FILES;
4587 int rlimit_max = MAX_OPEN_FILES;
4589 #ifdef HAVE_SYSCTLBYNAME
4591 size_t size = sizeof(sysctl_max);
4592 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4597 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4603 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4604 rlimit_max = rl.rlim_cur;
4606 #if defined(RLIM_INFINITY)
4607 if(rl.rlim_cur == RLIM_INFINITY)
4608 rlimit_max = MAX_OPEN_FILES;
4613 if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4614 DEBUG(2,("max_open_files: increasing sysctl_max (%d) to "
4615 "minimum Windows limit (%d)\n",
4617 MIN_OPEN_FILES_WINDOWS));
4618 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4621 if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4622 DEBUG(2,("rlimit_max: increasing rlimit_max (%d) to "
4623 "minimum Windows limit (%d)\n",
4625 MIN_OPEN_FILES_WINDOWS));
4626 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4629 return MIN(sysctl_max, rlimit_max);
4633 * Common part of freeing allocated data for one parameter.
4635 static void free_one_parameter_common(void *parm_ptr,
4636 struct parm_struct parm)
4638 if ((parm.type == P_STRING) ||
4639 (parm.type == P_USTRING))
4641 string_free((char**)parm_ptr);
4642 } else if (parm.type == P_LIST) {
4643 TALLOC_FREE(*((char***)parm_ptr));
4648 * Free the allocated data for one parameter for a share
4649 * given as a service struct.
4651 static void free_one_parameter(struct loadparm_service *service,
4652 struct parm_struct parm)
4656 if (parm.p_class != P_LOCAL) {
4660 parm_ptr = lp_parm_ptr(service, &parm);
4662 free_one_parameter_common(parm_ptr, parm);
4666 * Free the allocated parameter data of a share given
4667 * as a service struct.
4669 static void free_parameters(struct loadparm_service *service)
4673 for (i=0; parm_table[i].label; i++) {
4674 free_one_parameter(service, parm_table[i]);
4679 * Free the allocated data for one parameter for a given share
4680 * specified by an snum.
4682 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4687 parm_ptr = lp_parm_ptr(NULL, &parm);
4688 } else if (parm.p_class != P_LOCAL) {
4691 parm_ptr = lp_local_ptr_by_snum(snum, &parm);
4694 free_one_parameter_common(parm_ptr, parm);
4698 * Free the allocated parameter data for a share specified
4701 static void free_parameters_by_snum(int snum)
4705 for (i=0; parm_table[i].label; i++) {
4706 free_one_parameter_by_snum(snum, parm_table[i]);
4711 * Free the allocated global parameters.
4713 static void free_global_parameters(void)
4715 free_param_opts(&Globals.param_opt);
4716 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4719 static int map_parameter(const char *pszParmName);
4721 struct lp_stored_option {
4722 struct lp_stored_option *prev, *next;
4727 static struct lp_stored_option *stored_options;
4730 save options set by lp_set_cmdline() into a list. This list is
4731 re-applied when we do a globals reset, so that cmdline set options
4732 are sticky across reloads of smb.conf
4734 static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
4736 struct lp_stored_option *entry, *entry_next;
4737 for (entry = stored_options; entry != NULL; entry = entry_next) {
4738 entry_next = entry->next;
4739 if (strcmp(pszParmName, entry->label) == 0) {
4740 DLIST_REMOVE(stored_options, entry);
4746 entry = talloc(NULL, struct lp_stored_option);
4751 entry->label = talloc_strdup(entry, pszParmName);
4752 if (!entry->label) {
4757 entry->value = talloc_strdup(entry, pszParmValue);
4758 if (!entry->value) {
4763 DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
4768 static bool apply_lp_set_cmdline(void)
4770 struct lp_stored_option *entry = NULL;
4771 for (entry = stored_options; entry != NULL; entry = entry->next) {
4772 if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
4773 DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
4774 entry->label, entry->value));
4781 /***************************************************************************
4782 Initialise the global parameter structure.
4783 ***************************************************************************/
4785 static void init_globals(bool reinit_globals)
4787 static bool done_init = false;
4791 /* If requested to initialize only once and we've already done it... */
4792 if (!reinit_globals && done_init) {
4793 /* ... then we have nothing more to do */
4798 /* The logfile can be set before this is invoked. Free it if so. */
4799 if (Globals.logfile != NULL) {
4800 string_free(&Globals.logfile);
4801 Globals.logfile = NULL;
4805 free_global_parameters();
4808 /* This memset and the free_global_parameters() above will
4809 * wipe out smb.conf options set with lp_set_cmdline(). The
4810 * apply_lp_set_cmdline() call puts these values back in the
4811 * table once the defaults are set */
4812 ZERO_STRUCT(Globals);
4814 for (i = 0; parm_table[i].label; i++) {
4815 if ((parm_table[i].type == P_STRING ||
4816 parm_table[i].type == P_USTRING))
4818 string_set((char **)lp_parm_ptr(NULL, &parm_table[i]), "");
4823 string_set(&sDefault.fstype, FSTYPE_STRING);
4824 string_set(&sDefault.szPrintjobUsername, "%U");
4826 init_printer_values(&sDefault);
4829 DEBUG(3, ("Initialising global parameters\n"));
4831 /* Must manually force to upper case here, as this does not go via the handler */
4832 string_set(&Globals.szNetbiosName, myhostname_upper());
4834 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4835 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4837 /* use the new 'hash2' method by default, with a prefix of 1 */
4838 string_set(&Globals.szManglingMethod, "hash2");
4839 Globals.mangle_prefix = 1;
4841 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4843 /* using UTF8 by default allows us to support all chars */
4844 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4846 /* Use codepage 850 as a default for the dos character set */
4847 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4850 * Allow the default PASSWD_CHAT to be overridden in local.h.
4852 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4854 string_set(&Globals.szWorkgroup, DEFAULT_WORKGROUP);
4856 string_set(&Globals.szPasswdProgram, "");
4857 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4858 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4859 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4860 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4861 string_set(&Globals.szSocketAddress, "0.0.0.0");
4863 * By default support explicit binding to broadcast
4866 Globals.bNmbdBindExplicitBroadcast = true;
4868 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4869 smb_panic("init_globals: ENOMEM");
4871 string_set(&Globals.szServerString, s);
4874 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4877 string_set(&Globals.socket_options, DEFAULT_SOCKET_OPTIONS);
4879 string_set(&Globals.szLogonDrive, "");
4880 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4881 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4882 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4884 Globals.szNameResolveOrder = (const char **)str_list_make_v3(NULL, "lmhosts wins host bcast", NULL);
4885 string_set(&Globals.szPasswordServer, "*");
4887 Globals.AlgorithmicRidBase = BASE_RID;
4889 Globals.bLoadPrinters = true;
4890 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4892 Globals.ConfigBackend = config_backend;
4893 Globals.server_role = ROLE_AUTO;
4895 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4896 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4897 Globals.max_xmit = 0x4104;
4898 Globals.max_mux = 50; /* This is *needed* for profile support. */
4899 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4900 Globals.bDisableSpoolss = false;
4901 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4902 Globals.pwordlevel = 0;
4903 Globals.unamelevel = 0;
4904 Globals.deadtime = 0;
4905 Globals.getwd_cache = true;
4906 Globals.bLargeReadwrite = true;
4907 Globals.max_log_size = 5000;
4908 Globals.max_open_files = max_open_files();
4909 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4910 Globals.srv_maxprotocol = PROTOCOL_SMB2_10;
4911 Globals.srv_minprotocol = PROTOCOL_LANMAN1;
4912 Globals.security = SEC_USER;
4913 Globals.paranoid_server_security = true;
4914 Globals.bEncryptPasswords = true;
4915 Globals.clientSchannel = Auto;
4916 Globals.serverSchannel = Auto;
4917 Globals.bReadRaw = true;
4918 Globals.bWriteRaw = true;
4919 Globals.bNullPasswords = false;
4920 Globals.bObeyPamRestrictions = false;
4922 Globals.bSyslogOnly = false;
4923 Globals.bTimestampLogs = true;
4924 string_set(&Globals.loglevel, "0");
4925 Globals.bDebugPrefixTimestamp = false;
4926 Globals.bDebugHiresTimestamp = true;
4927 Globals.bDebugPid = false;
4928 Globals.bDebugUid = false;
4929 Globals.bDebugClass = false;
4930 Globals.bEnableCoreFiles = true;
4931 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4932 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4933 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4934 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4935 Globals.lm_announce = Auto; /* = Auto: send only if LM clients found */
4936 Globals.lm_interval = 60;
4937 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4938 Globals.bNISHomeMap = false;
4939 #ifdef WITH_NISPLUS_HOME
4940 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4942 string_set(&Globals.szNISHomeMapName, "auto.home");
4945 Globals.bTimeServer = false;
4946 Globals.bBindInterfacesOnly = false;
4947 Globals.bUnixPasswdSync = false;
4948 Globals.bPamPasswordChange = false;
4949 Globals.bPasswdChatDebug = false;
4950 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4951 Globals.bNTPipeSupport = true; /* Do NT pipes by default. */
4952 Globals.bNTStatusSupport = true; /* Use NT status by default. */
4953 Globals.bStatCache = true; /* use stat cache by default */
4954 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4955 Globals.restrict_anonymous = 0;
4956 Globals.bClientLanManAuth = false; /* Do NOT use the LanMan hash if it is available */
4957 Globals.bClientPlaintextAuth = false; /* Do NOT use a plaintext password even if is requested by the server */
4958 Globals.bLanmanAuth = false; /* Do NOT use the LanMan hash, even if it is supplied */
4959 Globals.bNTLMAuth = true; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4960 Globals.bClientNTLMv2Auth = true; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
4961 /* Note, that we will also use NTLM2 session security (which is different), if it is available */
4963 Globals.map_to_guest = 0; /* By Default, "Never" */
4964 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4965 Globals.enhanced_browsing = true;
4966 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4967 #ifdef MMAP_BLACKLIST
4968 Globals.bUseMmap = false;
4970 Globals.bUseMmap = true;
4972 Globals.bUnicode = true;
4973 Globals.bUnixExtensions = true;
4974 Globals.bResetOnZeroVC = false;
4975 Globals.bLogWriteableFilesOnExit = false;
4976 Globals.bCreateKrb5Conf = true;
4977 Globals.winbindMaxDomainConnections = 1;
4979 /* hostname lookups can be very expensive and are broken on
4980 a large number of sites (tridge) */
4981 Globals.bHostnameLookups = false;
4983 string_set(&Globals.passdb_backend, "tdbsam");
4984 string_set(&Globals.szLdapSuffix, "");
4985 string_set(&Globals.szLdapMachineSuffix, "");
4986 string_set(&Globals.szLdapUserSuffix, "");
4987 string_set(&Globals.szLdapGroupSuffix, "");
4988 string_set(&Globals.szLdapIdmapSuffix, "");
4990 string_set(&Globals.szLdapAdminDn, "");
4991 Globals.ldap_ssl = LDAP_SSL_START_TLS;
4992 Globals.ldap_ssl_ads = false;
4993 Globals.ldap_deref = -1;
4994 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
4995 Globals.ldap_delete_dn = false;
4996 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
4997 Globals.ldap_follow_referral = Auto;
4998 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
4999 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
5000 Globals.ldap_page_size = LDAP_PAGE_SIZE;
5002 Globals.ldap_debug_level = 0;
5003 Globals.ldap_debug_threshold = 10;
5005 /* This is what we tell the afs client. in reality we set the token
5006 * to never expire, though, when this runs out the afs client will
5007 * forget the token. Set to 0 to get NEVERDATE.*/
5008 Globals.iAfsTokenLifetime = 604800;
5009 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
5011 /* these parameters are set to defaults that are more appropriate
5012 for the increasing samba install base:
5014 as a member of the workgroup, that will possibly become a
5015 _local_ master browser (lm = true). this is opposed to a forced
5016 local master browser startup (pm = true).
5018 doesn't provide WINS server service by default (wsupp = false),
5019 and doesn't provide domain master browser services by default, either.
5023 Globals.bMsAddPrinterWizard = true;
5024 Globals.os_level = 20;
5025 Globals.bLocalMaster = true;
5026 Globals.domain_master = Auto; /* depending on bDomainLogons */
5027 Globals.bDomainLogons = false;
5028 Globals.bBrowseList = true;
5029 Globals.bWINSsupport = false;
5030 Globals.bWINSproxy = false;
5032 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
5033 Globals.InitLogonDelay = 100; /* 100 ms default delay */
5035 Globals.bWINSdnsProxy = true;
5037 Globals.bAllowTrustedDomains = true;
5038 string_set(&Globals.szIdmapBackend, "tdb");
5040 string_set(&Globals.szTemplateShell, "/bin/false");
5041 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
5042 string_set(&Globals.szWinbindSeparator, "\\");
5044 string_set(&Globals.szCupsServer, "");
5045 string_set(&Globals.szIPrintServer, "");
5047 #ifdef CLUSTER_SUPPORT
5048 string_set(&Globals.ctdbdSocket, CTDB_PATH);
5050 string_set(&Globals.ctdbdSocket, "");
5053 Globals.szClusterAddresses = NULL;
5054 Globals.clustering = false;
5055 Globals.ctdb_timeout = 0;
5056 Globals.ctdb_locktime_warn_threshold = 0;
5058 Globals.winbind_cache_time = 300; /* 5 minutes */
5059 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
5060 Globals.winbind_max_clients = 200;
5061 Globals.bWinbindEnumUsers = false;
5062 Globals.bWinbindEnumGroups = false;
5063 Globals.bWinbindUseDefaultDomain = false;
5064 Globals.bWinbindTrustedDomainsOnly = false;
5065 Globals.bWinbindNestedGroups = true;
5066 Globals.winbind_expand_groups = 1;
5067 Globals.szWinbindNssInfo = (const char **)str_list_make_v3(NULL, "template", NULL);
5068 Globals.bWinbindRefreshTickets = false;
5069 Globals.bWinbindOfflineLogon = false;
5071 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
5072 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
5074 Globals.bPassdbExpandExplicit = false;
5076 Globals.name_cache_timeout = 660; /* In seconds */
5078 Globals.bUseSpnego = true;
5079 Globals.bClientUseSpnego = true;
5081 Globals.client_signing = SMB_SIGNING_DEFAULT;
5082 Globals.server_signing = SMB_SIGNING_DEFAULT;
5084 Globals.bDeferSharingViolations = true;
5085 Globals.smb_ports = (const char **)str_list_make_v3(NULL, SMB_PORTS, NULL);
5087 Globals.bEnablePrivileges = true;
5088 Globals.bHostMSDfs = true;
5089 Globals.bASUSupport = false;
5091 /* User defined shares. */
5092 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5093 smb_panic("init_globals: ENOMEM");
5095 string_set(&Globals.szUsersharePath, s);
5097 string_set(&Globals.szUsershareTemplateShare, "");
5098 Globals.iUsershareMaxShares = 0;
5099 /* By default disallow sharing of directories not owned by the sharer. */
5100 Globals.bUsershareOwnerOnly = true;
5101 /* By default disallow guest access to usershares. */
5102 Globals.bUsershareAllowGuests = false;
5104 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5106 /* By default no shares out of the registry */
5107 Globals.bRegistryShares = false;
5109 Globals.iminreceivefile = 0;
5111 Globals.bMapUntrustedToDomain = false;
5112 Globals.bMulticastDnsRegister = true;
5114 Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ;
5115 Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE;
5116 Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT;
5117 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5119 string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
5121 /* Now put back the settings that were set with lp_set_cmdline() */
5122 apply_lp_set_cmdline();
5125 /*******************************************************************
5126 Convenience routine to grab string parameters into talloced memory
5127 and run standard_sub_basic on them. The buffers can be written to by
5128 callers without affecting the source string.
5129 ********************************************************************/
5131 static char *lp_string(TALLOC_CTX *ctx, const char *s)
5135 /* The follow debug is useful for tracking down memory problems
5136 especially if you have an inner loop that is calling a lp_*()
5137 function that returns a string. Perhaps this debug should be
5138 present all the time? */
5141 DEBUG(10, ("lp_string(%s)\n", s));
5147 ret = talloc_sub_basic(ctx,
5148 get_current_username(),
5149 current_user_info.domain,
5151 if (trim_char(ret, '\"', '\"')) {
5152 if (strchr(ret,'\"') != NULL) {
5154 ret = talloc_sub_basic(ctx,
5155 get_current_username(),
5156 current_user_info.domain,
5164 In this section all the functions that are used to access the
5165 parameters from the rest of the program are defined
5168 #define FN_GLOBAL_STRING(fn_name,ptr) \
5169 char *lp_ ## fn_name(TALLOC_CTX *ctx) {return(lp_string((ctx), *(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : ""));}
5170 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5171 const char *lp_ ## fn_name(void) {return(*(const char **)(&Globals.ptr) ? *(const char **)(&Globals.ptr) : "");}
5172 #define FN_GLOBAL_LIST(fn_name,ptr) \
5173 const char **lp_ ## fn_name(void) {return(*(const char ***)(&Globals.ptr));}
5174 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5175 bool lp_ ## fn_name(void) {return(*(bool *)(&Globals.ptr));}
5176 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5177 char lp_ ## fn_name(void) {return(*(char *)(&Globals.ptr));}
5178 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5179 int lp_ ## fn_name(void) {return(*(int *)(&Globals.ptr));}
5181 #define FN_LOCAL_STRING(fn_name,val) \
5182 char *lp_ ## fn_name(TALLOC_CTX *ctx,int i) {return(lp_string((ctx), (LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5183 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5184 const char *lp_ ## fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5185 #define FN_LOCAL_LIST(fn_name,val) \
5186 const char **lp_ ## fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5187 #define FN_LOCAL_BOOL(fn_name,val) \
5188 bool lp_ ## fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5189 #define FN_LOCAL_INTEGER(fn_name,val) \
5190 int lp_ ## fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5192 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5193 bool lp_ ## fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5194 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5195 int lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5196 #define FN_LOCAL_CHAR(fn_name,val) \
5197 char lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5200 static FN_GLOBAL_BOOL(domain_logons, bDomainLogons)
5201 static FN_GLOBAL_BOOL(_readraw, bReadRaw)
5202 static FN_GLOBAL_BOOL(_writeraw, bWriteRaw)
5204 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5205 * build process or in smb.conf, we use that value. Otherwise they
5206 * default to the value of lp_lockdir(). */
5207 const char *lp_statedir(void) {
5208 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5209 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5210 return(*(char **)(&Globals.szStateDir) ?
5211 *(char **)(&Globals.szStateDir) : "");
5213 return(*(char **)(&Globals.szLockDir) ?
5214 *(char **)(&Globals.szLockDir) : "");
5216 const char *lp_cachedir(void) {
5217 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5218 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5219 return(*(char **)(&Globals.szCacheDir) ?
5220 *(char **)(&Globals.szCacheDir) : "");
5222 return(*(char **)(&Globals.szLockDir) ?
5223 *(char **)(&Globals.szLockDir) : "");
5225 static FN_GLOBAL_INTEGER(winbind_max_domain_connections_int,
5226 winbindMaxDomainConnections)
5228 int lp_winbind_max_domain_connections(void)
5230 if (lp_winbind_offline_logon() &&
5231 lp_winbind_max_domain_connections_int() > 1) {
5232 DEBUG(1, ("offline logons active, restricting max domain "
5233 "connections to 1\n"));
5236 return MAX(1, lp_winbind_max_domain_connections_int());
5239 int lp_smb2_max_credits(void)
5241 if (Globals.ismb2_max_credits == 0) {
5242 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5244 return Globals.ismb2_max_credits;
5246 int lp_cups_encrypt(void)
5249 #ifdef HAVE_HTTPCONNECTENCRYPT
5250 switch (Globals.CupsEncrypt) {
5252 result = HTTP_ENCRYPT_REQUIRED;
5255 result = HTTP_ENCRYPT_ALWAYS;
5258 result = HTTP_ENCRYPT_NEVER;
5265 /* These functions remain in source3/param for now */
5267 FN_GLOBAL_INTEGER(security, security)
5268 FN_GLOBAL_INTEGER(usershare_max_shares, iUsershareMaxShares)
5269 FN_GLOBAL_STRING(configfile, szConfigFile)
5271 #include "lib/param/param_functions.c"
5273 FN_LOCAL_STRING(servicename, szService)
5274 FN_LOCAL_CONST_STRING(const_servicename, szService)
5276 /* local prototypes */
5278 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5279 static const char *get_boolean(bool bool_value);
5280 static int getservicebyname(const char *pszServiceName,
5281 struct loadparm_service *pserviceDest);
5282 static void copy_service(struct loadparm_service *pserviceDest,
5283 struct loadparm_service *pserviceSource,
5284 struct bitmap *pcopymapDest);
5285 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5287 static bool do_section(const char *pszSectionName, void *userdata);
5288 static void init_copymap(struct loadparm_service *pservice);
5289 static bool hash_a_service(const char *name, int number);
5290 static void free_service_byindex(int iService);
5291 static void show_parameter(int parmIndex);
5292 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5295 * This is a helper function for parametrical options support. It returns a
5296 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5297 * parametrical functions are quite simple
5299 static struct parmlist_entry *get_parametrics_by_service(struct loadparm_service *service, const char *type,
5302 bool global_section = false;
5304 struct parmlist_entry *data;
5306 if (service == NULL) {
5307 data = Globals.param_opt;
5308 global_section = true;
5310 data = service->param_opt;
5313 if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
5314 DEBUG(0,("asprintf failed!\n"));
5319 if (strwicmp(data->key, param_key) == 0) {
5320 string_free(¶m_key);
5326 if (!global_section) {
5327 /* Try to fetch the same option but from globals */
5328 /* but only if we are not already working with Globals */
5329 data = Globals.param_opt;
5331 if (strwicmp(data->key, param_key) == 0) {
5332 string_free(¶m_key);
5339 string_free(¶m_key);
5345 * This is a helper function for parametrical options support. It returns a
5346 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5347 * parametrical functions are quite simple
5349 static struct parmlist_entry *get_parametrics(int snum, const char *type,
5352 if (snum >= iNumServices) return NULL;
5355 return get_parametrics_by_service(NULL, type, option);
5357 return get_parametrics_by_service(ServicePtrs[snum], type, option);
5362 #define MISSING_PARAMETER(name) \
5363 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5365 /*******************************************************************
5366 convenience routine to return int parameters.
5367 ********************************************************************/
5368 static int lp_int(const char *s)
5372 MISSING_PARAMETER(lp_int);
5376 return (int)strtol(s, NULL, 0);
5379 /*******************************************************************
5380 convenience routine to return unsigned long parameters.
5381 ********************************************************************/
5382 static unsigned long lp_ulong(const char *s)
5386 MISSING_PARAMETER(lp_ulong);
5390 return strtoul(s, NULL, 0);
5393 /*******************************************************************
5394 convenience routine to return boolean parameters.
5395 ********************************************************************/
5396 static bool lp_bool(const char *s)
5401 MISSING_PARAMETER(lp_bool);
5405 if (!set_boolean(s, &ret)) {
5406 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5413 /*******************************************************************
5414 convenience routine to return enum parameters.
5415 ********************************************************************/
5416 static int lp_enum(const char *s,const struct enum_list *_enum)
5420 if (!s || !*s || !_enum) {
5421 MISSING_PARAMETER(lp_enum);
5425 for (i=0; _enum[i].name; i++) {
5426 if (strequal(_enum[i].name,s))
5427 return _enum[i].value;
5430 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5434 #undef MISSING_PARAMETER
5436 /* Return parametric option from a given service. Type is a part of option before ':' */
5437 /* Parametric option has following syntax: 'Type: option = value' */
5438 char *lp_parm_talloc_string(TALLOC_CTX *ctx, int snum, const char *type, const char *option, const char *def)
5440 struct parmlist_entry *data = get_parametrics(snum, type, option);
5442 if (data == NULL||data->value==NULL) {
5444 return lp_string(ctx, def);
5450 return lp_string(ctx, data->value);
5453 /* Return parametric option from a given service. Type is a part of option before ':' */
5454 /* Parametric option has following syntax: 'Type: option = value' */
5455 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5457 struct parmlist_entry *data = get_parametrics(snum, type, option);
5459 if (data == NULL||data->value==NULL)
5465 const char *lp_parm_const_string_service(struct loadparm_service *service, const char *type, const char *option)
5467 struct parmlist_entry *data = get_parametrics_by_service(service, type, option);
5469 if (data == NULL||data->value==NULL)
5476 /* Return parametric option from a given service. Type is a part of option before ':' */
5477 /* Parametric option has following syntax: 'Type: option = value' */
5479 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5481 struct parmlist_entry *data = get_parametrics(snum, type, option);
5483 if (data == NULL||data->value==NULL)
5484 return (const char **)def;
5486 if (data->list==NULL) {
5487 data->list = str_list_make_v3(NULL, data->value, NULL);
5490 return (const char **)data->list;
5493 /* Return parametric option from a given service. Type is a part of option before ':' */
5494 /* Parametric option has following syntax: 'Type: option = value' */
5496 int lp_parm_int(int snum, const char *type, const char *option, int def)
5498 struct parmlist_entry *data = get_parametrics(snum, type, option);
5500 if (data && data->value && *data->value)
5501 return lp_int(data->value);
5506 /* Return parametric option from a given service. Type is a part of option before ':' */
5507 /* Parametric option has following syntax: 'Type: option = value' */
5509 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5511 struct parmlist_entry *data = get_parametrics(snum, type, option);
5513 if (data && data->value && *data->value)
5514 return lp_ulong(data->value);
5519 /* Return parametric option from a given service. Type is a part of option before ':' */
5520 /* Parametric option has following syntax: 'Type: option = value' */
5522 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5524 struct parmlist_entry *data = get_parametrics(snum, type, option);
5526 if (data && data->value && *data->value)
5527 return lp_bool(data->value);
5532 /* Return parametric option from a given service. Type is a part of option before ':' */
5533 /* Parametric option has following syntax: 'Type: option = value' */
5535 int lp_parm_enum(int snum, const char *type, const char *option,
5536 const struct enum_list *_enum, int def)
5538 struct parmlist_entry *data = get_parametrics(snum, type, option);
5540 if (data && data->value && *data->value && _enum)
5541 return lp_enum(data->value, _enum);
5547 /***************************************************************************
5548 Initialise a service to the defaults.
5549 ***************************************************************************/
5551 static void init_service(struct loadparm_service *pservice)
5553 memset((char *)pservice, '\0', sizeof(struct loadparm_service));
5554 copy_service(pservice, &sDefault, NULL);
5559 * free a param_opts structure.
5560 * param_opts handling should be moved to talloc;
5561 * then this whole functions reduces to a TALLOC_FREE().
5564 static void free_param_opts(struct parmlist_entry **popts)
5566 struct parmlist_entry *opt, *next_opt;
5568 if (popts == NULL) {
5572 if (*popts != NULL) {
5573 DEBUG(5, ("Freeing parametrics:\n"));
5576 while (opt != NULL) {
5577 string_free(&opt->key);
5578 string_free(&opt->value);
5579 TALLOC_FREE(opt->list);
5580 next_opt = opt->next;
5587 /***************************************************************************
5588 Free the dynamically allocated parts of a service struct.
5589 ***************************************************************************/
5591 static void free_service(struct loadparm_service *pservice)
5596 if (pservice->szService)
5597 DEBUG(5, ("free_service: Freeing service %s\n",
5598 pservice->szService));
5600 free_parameters(pservice);
5602 string_free(&pservice->szService);
5603 TALLOC_FREE(pservice->copymap);
5605 free_param_opts(&pservice->param_opt);
5607 ZERO_STRUCTP(pservice);
5611 /***************************************************************************
5612 remove a service indexed in the ServicePtrs array from the ServiceHash
5613 and free the dynamically allocated parts
5614 ***************************************************************************/
5616 static void free_service_byindex(int idx)
5618 if ( !LP_SNUM_OK(idx) )
5621 ServicePtrs[idx]->valid = false;
5622 invalid_services[num_invalid_services++] = idx;
5624 /* we have to cleanup the hash record */
5626 if (ServicePtrs[idx]->szService) {
5627 char *canon_name = canonicalize_servicename(
5629 ServicePtrs[idx]->szService );
5631 dbwrap_delete_bystring(ServiceHash, canon_name );
5632 TALLOC_FREE(canon_name);
5635 free_service(ServicePtrs[idx]);
5638 /***************************************************************************
5639 Add a new service to the services array initialising it with the given
5641 ***************************************************************************/
5643 static int add_a_service(const struct loadparm_service *pservice, const char *name)
5646 struct loadparm_service tservice;
5647 int num_to_alloc = iNumServices + 1;
5649 tservice = *pservice;
5651 /* it might already exist */
5653 i = getservicebyname(name, NULL);
5659 /* find an invalid one */
5661 if (num_invalid_services > 0) {
5662 i = invalid_services[--num_invalid_services];
5665 /* if not, then create one */
5666 if (i == iNumServices) {
5667 struct loadparm_service **tsp;
5670 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct loadparm_service *, num_to_alloc);
5672 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
5676 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct loadparm_service);
5677 if (!ServicePtrs[iNumServices]) {
5678 DEBUG(0,("add_a_service: out of memory!\n"));
5683 /* enlarge invalid_services here for now... */
5684 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
5686 if (tinvalid == NULL) {
5687 DEBUG(0,("add_a_service: failed to enlarge "
5688 "invalid_services!\n"));
5691 invalid_services = tinvalid;
5693 free_service_byindex(i);
5696 ServicePtrs[i]->valid = true;
5698 init_service(ServicePtrs[i]);
5699 copy_service(ServicePtrs[i], &tservice, NULL);
5701 string_set(&ServicePtrs[i]->szService, name);
5703 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
5704 i, ServicePtrs[i]->szService));
5706 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
5713 /***************************************************************************
5714 Convert a string to uppercase and remove whitespaces.
5715 ***************************************************************************/
5717 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
5722 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
5726 result = talloc_strdup(ctx, src);
5727 SMB_ASSERT(result != NULL);
5733 /***************************************************************************
5734 Add a name/index pair for the services array to the hash table.
5735 ***************************************************************************/
5737 static bool hash_a_service(const char *name, int idx)
5741 if ( !ServiceHash ) {
5742 DEBUG(10,("hash_a_service: creating servicehash\n"));
5743 ServiceHash = db_open_rbt(NULL);
5744 if ( !ServiceHash ) {
5745 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
5750 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
5753 canon_name = canonicalize_servicename(talloc_tos(), name );
5755 dbwrap_store_bystring(ServiceHash, canon_name,
5756 make_tdb_data((uint8 *)&idx, sizeof(idx)),
5759 TALLOC_FREE(canon_name);
5764 /***************************************************************************
5765 Add a new home service, with the specified home directory, defaults coming
5767 ***************************************************************************/
5769 bool lp_add_home(const char *pszHomename, int iDefaultService,
5770 const char *user, const char *pszHomedir)
5774 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
5775 pszHomedir[0] == '\0') {
5779 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
5784 if (!(*(ServicePtrs[iDefaultService]->szPath))
5785 || strequal(ServicePtrs[iDefaultService]->szPath,
5786 lp_pathname(talloc_tos(), GLOBAL_SECTION_SNUM))) {
5787 string_set(&ServicePtrs[i]->szPath, pszHomedir);
5790 if (!(*(ServicePtrs[i]->comment))) {
5791 char *comment = NULL;
5792 if (asprintf(&comment, "Home directory of %s", user) < 0) {
5795 string_set(&ServicePtrs[i]->comment, comment);
5799 /* set the browseable flag from the global default */
5801 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5802 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
5804 ServicePtrs[i]->autoloaded = true;
5806 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
5807 user, ServicePtrs[i]->szPath ));
5812 /***************************************************************************
5813 Add a new service, based on an old one.
5814 ***************************************************************************/
5816 int lp_add_service(const char *pszService, int iDefaultService)
5818 if (iDefaultService < 0) {
5819 return add_a_service(&sDefault, pszService);
5822 return (add_a_service(ServicePtrs[iDefaultService], pszService));
5825 /***************************************************************************
5826 Add the IPC service.
5827 ***************************************************************************/
5829 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
5831 char *comment = NULL;
5832 int i = add_a_service(&sDefault, ipc_name);
5837 if (asprintf(&comment, "IPC Service (%s)",
5838 Globals.szServerString) < 0) {
5842 string_set(&ServicePtrs[i]->szPath, tmpdir());
5843 string_set(&ServicePtrs[i]->szUsername, "");
5844 string_set(&ServicePtrs[i]->comment, comment);
5845 string_set(&ServicePtrs[i]->fstype, "IPC");
5846 ServicePtrs[i]->iMaxConnections = 0;
5847 ServicePtrs[i]->bAvailable = true;
5848 ServicePtrs[i]->bRead_only = true;
5849 ServicePtrs[i]->bGuest_only = false;
5850 ServicePtrs[i]->bAdministrative_share = true;
5851 ServicePtrs[i]->bGuest_ok = guest_ok;
5852 ServicePtrs[i]->bPrint_ok = false;
5853 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5855 DEBUG(3, ("adding IPC service\n"));
5861 /***************************************************************************
5862 Add a new printer service, with defaults coming from service iFrom.
5863 ***************************************************************************/
5865 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
5867 const char *comment = "From Printcap";
5868 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
5873 /* note that we do NOT default the availability flag to true - */
5874 /* we take it from the default service passed. This allows all */
5875 /* dynamic printers to be disabled by disabling the [printers] */
5876 /* entry (if/when the 'available' keyword is implemented!). */
5878 /* the printer name is set to the service name. */
5879 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
5880 string_set(&ServicePtrs[i]->comment, comment);
5882 /* set the browseable flag from the gloabl default */
5883 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5885 /* Printers cannot be read_only. */
5886 ServicePtrs[i]->bRead_only = false;
5887 /* No share modes on printer services. */
5888 ServicePtrs[i]->bShareModes = false;
5889 /* No oplocks on printer services. */
5890 ServicePtrs[i]->bOpLocks = false;
5891 /* Printer services must be printable. */
5892 ServicePtrs[i]->bPrint_ok = true;
5894 DEBUG(3, ("adding printer service %s\n", pszPrintername));
5900 /***************************************************************************
5901 Check whether the given parameter name is valid.
5902 Parametric options (names containing a colon) are considered valid.
5903 ***************************************************************************/
5905 bool lp_parameter_is_valid(const char *pszParmName)
5907 return ((map_parameter(pszParmName) != -1) ||
5908 (strchr(pszParmName, ':') != NULL));
5911 /***************************************************************************
5912 Check whether the given name is the name of a global parameter.
5913 Returns true for strings belonging to parameters of class
5914 P_GLOBAL, false for all other strings, also for parametric options
5915 and strings not belonging to any option.
5916 ***************************************************************************/
5918 bool lp_parameter_is_global(const char *pszParmName)
5920 int num = map_parameter(pszParmName);
5923 return (parm_table[num].p_class == P_GLOBAL);
5929 /**************************************************************************
5930 Check whether the given name is the canonical name of a parameter.
5931 Returns false if it is not a valid parameter Name.
5932 For parametric options, true is returned.
5933 **************************************************************************/
5935 bool lp_parameter_is_canonical(const char *parm_name)
5937 if (!lp_parameter_is_valid(parm_name)) {
5941 return (map_parameter(parm_name) ==
5942 map_parameter_canonical(parm_name, NULL));
5945 /**************************************************************************
5946 Determine the canonical name for a parameter.
5947 Indicate when it is an inverse (boolean) synonym instead of a
5949 **************************************************************************/
5951 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
5956 if (!lp_parameter_is_valid(parm_name)) {
5961 num = map_parameter_canonical(parm_name, inverse);
5963 /* parametric option */
5964 *canon_parm = parm_name;
5966 *canon_parm = parm_table[num].label;
5973 /**************************************************************************
5974 Determine the canonical name for a parameter.
5975 Turn the value given into the inverse boolean expression when
5976 the synonym is an invers boolean synonym.
5978 Return true if parm_name is a valid parameter name and
5979 in case it is an invers boolean synonym, if the val string could
5980 successfully be converted to the reverse bool.
5981 Return false in all other cases.
5982 **************************************************************************/
5984 bool lp_canonicalize_parameter_with_value(const char *parm_name,
5986 const char **canon_parm,
5987 const char **canon_val)
5992 if (!lp_parameter_is_valid(parm_name)) {
5998 num = map_parameter_canonical(parm_name, &inverse);
6000 /* parametric option */
6001 *canon_parm = parm_name;
6004 *canon_parm = parm_table[num].label;
6006 if (!lp_invert_boolean(val, canon_val)) {
6018 /***************************************************************************
6019 Map a parameter's string representation to something we can use.
6020 Returns false if the parameter string is not recognised, else TRUE.
6021 ***************************************************************************/
6023 static int map_parameter(const char *pszParmName)
6027 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6030 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6031 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6034 /* Warn only if it isn't parametric option */
6035 if (strchr(pszParmName, ':') == NULL)
6036 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6037 /* We do return 'fail' for parametric options as well because they are
6038 stored in different storage
6043 /***************************************************************************
6044 Map a parameter's string representation to the index of the canonical
6045 form of the parameter (it might be a synonym).
6046 Returns -1 if the parameter string is not recognised.
6047 ***************************************************************************/
6049 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6051 int parm_num, canon_num;
6052 bool loc_inverse = false;
6054 parm_num = map_parameter(pszParmName);
6055 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6056 /* invalid, parametric or no canidate for synonyms ... */
6060 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6061 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6062 parm_num = canon_num;
6068 if (inverse != NULL) {
6069 *inverse = loc_inverse;
6074 /***************************************************************************
6075 return true if parameter number parm1 is a synonym of parameter
6076 number parm2 (parm2 being the principal name).
6077 set inverse to true if parm1 is P_BOOLREV and parm2 is P_BOOL,
6079 ***************************************************************************/
6081 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6083 if ((parm_table[parm1].offset == parm_table[parm2].offset) &&
6084 (parm_table[parm1].p_class == parm_table[parm2].p_class) &&
6085 (parm_table[parm1].flags & FLAG_HIDE) &&
6086 !(parm_table[parm2].flags & FLAG_HIDE))
6088 if (inverse != NULL) {
6089 if ((parm_table[parm1].type == P_BOOLREV) &&
6090 (parm_table[parm2].type == P_BOOL))
6102 /***************************************************************************
6103 Show one parameter's name, type, [values,] and flags.
6104 (helper functions for show_parameter_list)
6105 ***************************************************************************/
6107 static void show_parameter(int parmIndex)
6109 int enumIndex, flagIndex;
6114 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6115 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6117 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6118 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6120 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6121 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6122 "FLAG_DEPRECATED", "FLAG_HIDE", NULL};
6124 printf("%s=%s", parm_table[parmIndex].label,
6125 type[parm_table[parmIndex].type]);
6126 if (parm_table[parmIndex].type == P_ENUM) {
6129 parm_table[parmIndex].enum_list[enumIndex].name;
6133 enumIndex ? "|" : "",
6134 parm_table[parmIndex].enum_list[enumIndex].name);
6139 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6140 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6143 flag_names[flagIndex]);
6148 /* output synonyms */
6150 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6151 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6152 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6153 parm_table[parmIndex2].label);
6154 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6156 printf(" (synonyms: ");
6161 printf("%s%s", parm_table[parmIndex2].label,
6162 inverse ? "[i]" : "");
6172 /***************************************************************************
6173 Show all parameter's name, type, [values,] and flags.
6174 ***************************************************************************/
6176 void show_parameter_list(void)
6178 int classIndex, parmIndex;
6179 const char *section_names[] = { "local", "global", NULL};
6181 for (classIndex=0; section_names[classIndex]; classIndex++) {
6182 printf("[%s]\n", section_names[classIndex]);
6183 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6184 if (parm_table[parmIndex].p_class == classIndex) {
6185 show_parameter(parmIndex);
6191 /***************************************************************************
6192 Check if a given string correctly represents a boolean value.
6193 ***************************************************************************/
6195 bool lp_string_is_valid_boolean(const char *parm_value)
6197 return set_boolean(parm_value, NULL);
6200 /***************************************************************************
6201 Get the standard string representation of a boolean value ("yes" or "no")
6202 ***************************************************************************/
6204 static const char *get_boolean(bool bool_value)
6206 static const char *yes_str = "yes";
6207 static const char *no_str = "no";
6209 return (bool_value ? yes_str : no_str);
6212 /***************************************************************************
6213 Provide the string of the negated boolean value associated to the boolean
6214 given as a string. Returns false if the passed string does not correctly
6215 represent a boolean.
6216 ***************************************************************************/
6218 bool lp_invert_boolean(const char *str, const char **inverse_str)
6222 if (!set_boolean(str, &val)) {
6226 *inverse_str = get_boolean(!val);
6230 /***************************************************************************
6231 Provide the canonical string representation of a boolean value given
6232 as a string. Return true on success, false if the string given does
6233 not correctly represent a boolean.
6234 ***************************************************************************/
6236 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6240 if (!set_boolean(str, &val)) {
6244 *canon_str = get_boolean(val);
6248 /***************************************************************************
6249 Find a service by name. Otherwise works like get_service.
6250 ***************************************************************************/
6252 static int getservicebyname(const char *pszServiceName, struct loadparm_service *pserviceDest)
6259 if (ServiceHash == NULL) {
6263 canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
6265 status = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name,
6268 if (NT_STATUS_IS_OK(status) &&
6269 (data.dptr != NULL) &&
6270 (data.dsize == sizeof(iService)))
6272 iService = *(int *)data.dptr;
6275 TALLOC_FREE(canon_name);
6277 if ((iService != -1) && (LP_SNUM_OK(iService))
6278 && (pserviceDest != NULL)) {
6279 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6285 /* Return a pointer to a service by name. Unlike getservicebyname, it does not copy the service */
6286 struct loadparm_service *lp_service(const char *pszServiceName)
6288 int iService = getservicebyname(pszServiceName, NULL);
6289 if (iService == -1 || !LP_SNUM_OK(iService)) {
6292 return ServicePtrs[iService];
6295 struct loadparm_service *lp_servicebynum(int snum)
6297 if ((snum == -1) || !LP_SNUM_OK(snum)) {
6300 return ServicePtrs[snum];
6303 struct loadparm_service *lp_default_loadparm_service()
6309 /***************************************************************************
6310 Copy a service structure to another.
6311 If pcopymapDest is NULL then copy all fields
6312 ***************************************************************************/
6315 * Add a parametric option to a parmlist_entry,
6316 * replacing old value, if already present.
6318 static void set_param_opt(struct parmlist_entry **opt_list,
6319 const char *opt_name,
6320 const char *opt_value,
6323 struct parmlist_entry *new_opt, *opt;
6326 if (opt_list == NULL) {
6333 /* Traverse destination */
6335 /* If we already have same option, override it */
6336 if (strwicmp(opt->key, opt_name) == 0) {
6337 if ((opt->priority & FLAG_CMDLINE) &&
6338 !(priority & FLAG_CMDLINE)) {
6339 /* it's been marked as not to be
6343 string_free(&opt->value);
6344 TALLOC_FREE(opt->list);
6345 opt->value = SMB_STRDUP(opt_value);
6346 opt->priority = priority;
6353 new_opt = SMB_XMALLOC_P(struct parmlist_entry);
6354 new_opt->key = SMB_STRDUP(opt_name);
6355 new_opt->value = SMB_STRDUP(opt_value);
6356 new_opt->list = NULL;
6357 new_opt->priority = priority;
6358 DLIST_ADD(*opt_list, new_opt);
6362 static void copy_service(struct loadparm_service *pserviceDest, struct loadparm_service *pserviceSource,
6363 struct bitmap *pcopymapDest)
6366 bool bcopyall = (pcopymapDest == NULL);
6367 struct parmlist_entry *data;
6369 for (i = 0; parm_table[i].label; i++)
6370 if (parm_table[i].p_class == P_LOCAL &&
6371 (bcopyall || bitmap_query(pcopymapDest,i))) {
6372 void *src_ptr = lp_parm_ptr(pserviceSource, &parm_table[i]);
6373 void *dest_ptr = lp_parm_ptr(pserviceDest, &parm_table[i]);
6375 switch (parm_table[i].type) {
6378 *(bool *)dest_ptr = *(bool *)src_ptr;
6385 *(int *)dest_ptr = *(int *)src_ptr;
6389 *(char *)dest_ptr = *(char *)src_ptr;
6393 string_set((char **)dest_ptr,
6399 char *upper_string = strupper_talloc(talloc_tos(),
6401 string_set((char **)dest_ptr,
6403 TALLOC_FREE(upper_string);
6407 TALLOC_FREE(*((char ***)dest_ptr));
6408 *((char ***)dest_ptr) = str_list_copy(NULL,
6409 *(const char ***)src_ptr);
6417 init_copymap(pserviceDest);
6418 if (pserviceSource->copymap)
6419 bitmap_copy(pserviceDest->copymap,
6420 pserviceSource->copymap);
6423 data = pserviceSource->param_opt;
6425 set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->priority);
6430 /***************************************************************************
6431 Check a service for consistency. Return false if the service is in any way
6432 incomplete or faulty, else true.
6433 ***************************************************************************/
6435 bool service_ok(int iService)
6440 if (ServicePtrs[iService]->szService[0] == '\0') {
6441 DEBUG(0, ("The following message indicates an internal error:\n"));
6442 DEBUG(0, ("No service name in service entry.\n"));
6446 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6447 /* I can't see why you'd want a non-printable printer service... */
6448 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6449 if (!ServicePtrs[iService]->bPrint_ok) {
6450 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6451 ServicePtrs[iService]->szService));
6452 ServicePtrs[iService]->bPrint_ok = true;
6454 /* [printers] service must also be non-browsable. */
6455 if (ServicePtrs[iService]->bBrowseable)
6456 ServicePtrs[iService]->bBrowseable = false;
6459 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6460 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6461 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6463 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6464 ServicePtrs[iService]->szService));
6465 ServicePtrs[iService]->bAvailable = false;
6468 /* If a service is flagged unavailable, log the fact at level 1. */
6469 if (!ServicePtrs[iService]->bAvailable)
6470 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6471 ServicePtrs[iService]->szService));
6476 static struct smbconf_ctx *lp_smbconf_ctx(void)
6479 static struct smbconf_ctx *conf_ctx = NULL;
6481 if (conf_ctx == NULL) {
6482 err = smbconf_init(NULL, &conf_ctx, "registry:");
6483 if (!SBC_ERROR_IS_OK(err)) {
6484 DEBUG(1, ("error initializing registry configuration: "
6485 "%s\n", sbcErrorString(err)));
6493 static bool process_smbconf_service(struct smbconf_service *service)
6498 if (service == NULL) {
6502 ret = do_section(service->name, NULL);
6506 for (count = 0; count < service->num_params; count++) {
6507 ret = do_parameter(service->param_names[count],
6508 service->param_values[count],
6514 if (iServiceIndex >= 0) {
6515 return service_ok(iServiceIndex);
6521 * load a service from registry and activate it
6523 bool process_registry_service(const char *service_name)
6526 struct smbconf_service *service = NULL;
6527 TALLOC_CTX *mem_ctx = talloc_stackframe();
6528 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6531 if (conf_ctx == NULL) {
6535 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6537 if (!smbconf_share_exists(conf_ctx, service_name)) {
6539 * Registry does not contain data for this service (yet),
6540 * but make sure lp_load doesn't return false.
6546 err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6547 if (!SBC_ERROR_IS_OK(err)) {
6551 ret = process_smbconf_service(service);
6557 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6560 TALLOC_FREE(mem_ctx);
6565 * process_registry_globals
6567 static bool process_registry_globals(void)
6571 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6573 ret = do_parameter("registry shares", "yes", NULL);
6578 return process_registry_service(GLOBAL_NAME);
6581 bool process_registry_shares(void)
6585 struct smbconf_service **service = NULL;
6586 uint32_t num_shares = 0;
6587 TALLOC_CTX *mem_ctx = talloc_stackframe();
6588 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6591 if (conf_ctx == NULL) {
6595 err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6596 if (!SBC_ERROR_IS_OK(err)) {
6602 for (count = 0; count < num_shares; count++) {
6603 if (strequal(service[count]->name, GLOBAL_NAME)) {
6606 ret = process_smbconf_service(service[count]);
6613 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6616 TALLOC_FREE(mem_ctx);
6621 * reload those shares from registry that are already
6622 * activated in the services array.
6624 static bool reload_registry_shares(void)
6629 for (i = 0; i < iNumServices; i++) {
6634 if (ServicePtrs[i]->usershare == USERSHARE_VALID) {
6638 ret = process_registry_service(ServicePtrs[i]->szService);
6649 #define MAX_INCLUDE_DEPTH 100
6651 static uint8_t include_depth;
6653 static struct file_lists {
6654 struct file_lists *next;
6658 } *file_lists = NULL;
6660 /*******************************************************************
6661 Keep a linked list of all config files so we know when one has changed
6662 it's date and needs to be reloaded.
6663 ********************************************************************/
6665 static void add_to_file_list(const char *fname, const char *subfname)
6667 struct file_lists *f = file_lists;
6670 if (f->name && !strcmp(f->name, fname))
6676 f = SMB_MALLOC_P(struct file_lists);
6679 f->next = file_lists;
6680 f->name = SMB_STRDUP(fname);
6685 f->subfname = SMB_STRDUP(subfname);
6692 f->modtime = file_modtime(subfname);
6694 time_t t = file_modtime(subfname);
6702 * Free the file lists
6704 static void free_file_list(void)
6706 struct file_lists *f;
6707 struct file_lists *next;
6712 SAFE_FREE( f->name );
6713 SAFE_FREE( f->subfname );
6722 * Utility function for outsiders to check if we're running on registry.
6724 bool lp_config_backend_is_registry(void)
6726 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
6730 * Utility function to check if the config backend is FILE.
6732 bool lp_config_backend_is_file(void)
6734 return (lp_config_backend() == CONFIG_BACKEND_FILE);
6737 /*******************************************************************
6738 Check if a config file has changed date.
6739 ********************************************************************/
6741 bool lp_file_list_changed(void)
6743 struct file_lists *f = file_lists;
6745 DEBUG(6, ("lp_file_list_changed()\n"));
6750 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
6751 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6753 if (conf_ctx == NULL) {
6756 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
6759 DEBUGADD(6, ("registry config changed\n"));
6764 n2 = talloc_sub_basic(talloc_tos(),
6765 get_current_username(),
6766 current_user_info.domain,
6771 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
6772 f->name, n2, ctime(&f->modtime)));
6774 mod_time = file_modtime(n2);
6777 ((f->modtime != mod_time) ||
6778 (f->subfname == NULL) ||
6779 (strcmp(n2, f->subfname) != 0)))
6782 ("file %s modified: %s\n", n2,
6784 f->modtime = mod_time;
6785 SAFE_FREE(f->subfname);
6786 f->subfname = SMB_STRDUP(n2);
6799 * Initialize iconv conversion descriptors.
6801 * This is called the first time it is needed, and also called again
6802 * every time the configuration is reloaded, because the charset or
6803 * codepage might have changed.
6805 static void init_iconv(void)
6807 global_iconv_handle = smb_iconv_handle_reinit(NULL, lp_dos_charset(),
6809 true, global_iconv_handle);
6812 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6814 if (strcmp(*ptr, pszParmValue) != 0) {
6815 string_set(ptr, pszParmValue);
6821 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6823 bool is_utf8 = false;
6824 size_t len = strlen(pszParmValue);
6826 if (len == 4 || len == 5) {
6827 /* Don't use StrCaseCmp here as we don't want to
6828 initialize iconv. */
6829 if ((toupper_m(pszParmValue[0]) == 'U') &&
6830 (toupper_m(pszParmValue[1]) == 'T') &&
6831 (toupper_m(pszParmValue[2]) == 'F')) {
6833 if (pszParmValue[3] == '8') {
6837 if (pszParmValue[3] == '-' &&
6838 pszParmValue[4] == '8') {
6845 if (strcmp(*ptr, pszParmValue) != 0) {
6847 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
6848 "be UTF8, using (default value) %s instead.\n",
6849 DEFAULT_DOS_CHARSET));
6850 pszParmValue = DEFAULT_DOS_CHARSET;
6852 string_set(ptr, pszParmValue);
6858 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6861 char *realm = strupper_talloc(talloc_tos(), pszParmValue);
6862 char *dnsdomain = strlower_talloc(realm, pszParmValue);
6864 ret &= string_set(&Globals.szRealm, pszParmValue);
6865 ret &= string_set(&Globals.szRealm_upper, realm);
6866 ret &= string_set(&Globals.szRealm_lower, dnsdomain);
6872 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6874 TALLOC_FREE(Globals.szNetbiosAliases);
6875 Globals.szNetbiosAliases = (const char **)str_list_make_v3(NULL, pszParmValue, NULL);
6876 return set_netbios_aliases(Globals.szNetbiosAliases);
6879 /***************************************************************************
6880 Handle the include operation.
6881 ***************************************************************************/
6882 static bool bAllowIncludeRegistry = true;
6884 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6888 if (include_depth >= MAX_INCLUDE_DEPTH) {
6889 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
6894 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
6895 if (!bAllowIncludeRegistry) {
6898 if (bInGlobalSection) {
6901 ret = process_registry_globals();
6905 DEBUG(1, ("\"include = registry\" only effective "
6906 "in %s section\n", GLOBAL_NAME));
6911 fname = talloc_sub_basic(talloc_tos(), get_current_username(),
6912 current_user_info.domain,
6915 add_to_file_list(pszParmValue, fname);
6917 string_set(ptr, fname);
6919 if (file_exist(fname)) {
6922 ret = pm_process(fname, do_section, do_parameter, NULL);
6928 DEBUG(2, ("Can't find include file %s\n", fname));
6933 /***************************************************************************
6934 Handle the interpretation of the copy parameter.
6935 ***************************************************************************/
6937 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6941 struct loadparm_service serviceTemp;
6943 string_set(ptr, pszParmValue);
6945 init_service(&serviceTemp);
6949 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
6951 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
6952 if (iTemp == iServiceIndex) {
6953 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
6955 copy_service(ServicePtrs[iServiceIndex],
6957 ServicePtrs[iServiceIndex]->copymap);
6961 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
6965 free_service(&serviceTemp);
6969 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6971 Globals.ldap_debug_level = lp_int(pszParmValue);
6972 init_ldap_debugging();
6976 /***************************************************************************
6977 Handle idmap/non unix account uid and gid allocation parameters. The format of these
6982 idmap uid = 1000-1999
6985 We only do simple parsing checks here. The strings are parsed into useful
6986 structures in the idmap daemon code.
6988 ***************************************************************************/
6990 /* Some lp_ routines to return idmap [ug]id information */
6992 static uid_t idmap_uid_low, idmap_uid_high;
6993 static gid_t idmap_gid_low, idmap_gid_high;
6995 bool lp_idmap_uid(uid_t *low, uid_t *high)
6997 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7001 *low = idmap_uid_low;
7004 *high = idmap_uid_high;
7009 bool lp_idmap_gid(gid_t *low, gid_t *high)
7011 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7015 *low = idmap_gid_low;
7018 *high = idmap_gid_high;
7023 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7025 lp_do_parameter(snum, "idmap config * : backend", pszParmValue);
7030 /* Do some simple checks on "idmap [ug]id" parameter values */
7032 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7034 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7039 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7041 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7046 /***************************************************************************
7047 Handle the DEBUG level list.
7048 ***************************************************************************/
7050 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValueIn, char **ptr )
7052 string_set(ptr, pszParmValueIn);
7053 return debug_parse_levels(pszParmValueIn);
7056 /***************************************************************************
7057 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7058 ***************************************************************************/
7060 static const char *append_ldap_suffix(TALLOC_CTX *ctx, const char *str )
7062 const char *suffix_string;
7064 suffix_string = talloc_asprintf(ctx, "%s,%s", str,
7065 Globals.szLdapSuffix );
7066 if ( !suffix_string ) {
7067 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7071 return suffix_string;
7074 const char *lp_ldap_machine_suffix(TALLOC_CTX *ctx)
7076 if (Globals.szLdapMachineSuffix[0])
7077 return append_ldap_suffix(ctx, Globals.szLdapMachineSuffix);
7079 return lp_string(ctx, Globals.szLdapSuffix);
7082 const char *lp_ldap_user_suffix(TALLOC_CTX *ctx)
7084 if (Globals.szLdapUserSuffix[0])
7085 return append_ldap_suffix(ctx, Globals.szLdapUserSuffix);
7087 return lp_string(ctx, Globals.szLdapSuffix);
7090 const char *lp_ldap_group_suffix(TALLOC_CTX *ctx)
7092 if (Globals.szLdapGroupSuffix[0])
7093 return append_ldap_suffix(ctx, Globals.szLdapGroupSuffix);
7095 return lp_string(ctx, Globals.szLdapSuffix);
7098 const char *lp_ldap_idmap_suffix(TALLOC_CTX *ctx)
7100 if (Globals.szLdapIdmapSuffix[0])
7101 return append_ldap_suffix(ctx, Globals.szLdapIdmapSuffix);
7103 return lp_string(ctx, Globals.szLdapSuffix);
7106 /****************************************************************************
7107 set the value for a P_ENUM
7108 ***************************************************************************/
7110 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7115 for (i = 0; parm->enum_list[i].name; i++) {
7116 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7117 *ptr = parm->enum_list[i].value;
7121 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7122 pszParmValue, parm->label));
7125 /***************************************************************************
7126 ***************************************************************************/
7128 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7130 static int parm_num = -1;
7131 struct loadparm_service *s;
7133 if ( parm_num == -1 )
7134 parm_num = map_parameter( "printing" );
7136 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7141 s = ServicePtrs[snum];
7143 init_printer_values( s );
7149 /***************************************************************************
7150 Initialise a copymap.
7151 ***************************************************************************/
7153 static void init_copymap(struct loadparm_service *pservice)
7157 TALLOC_FREE(pservice->copymap);
7159 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
7160 if (!pservice->copymap)
7162 ("Couldn't allocate copymap!! (size %d)\n",
7163 (int)NUMPARAMETERS));
7165 for (i = 0; i < NUMPARAMETERS; i++)
7166 bitmap_set(pservice->copymap, i);
7170 return the parameter pointer for a parameter
7172 void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm)
7174 if (service == NULL) {
7175 if (parm->p_class == P_LOCAL)
7176 return (void *)(((char *)&sDefault)+parm->offset);
7177 else if (parm->p_class == P_GLOBAL)
7178 return (void *)(((char *)&Globals)+parm->offset);
7181 return (void *)(((char *)service) + parm->offset);
7185 /***************************************************************************
7186 Return the local pointer to a parameter given the service number and parameter
7187 ***************************************************************************/
7189 void *lp_local_ptr_by_snum(int snum, struct parm_struct *parm)
7191 return lp_parm_ptr(ServicePtrs[snum], parm);
7194 /***************************************************************************
7195 Process a parameter for a particular service number. If snum < 0
7196 then assume we are in the globals.
7197 ***************************************************************************/
7199 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7202 void *parm_ptr = NULL; /* where we are going to store the result */
7203 struct parmlist_entry **opt_list;
7205 parmnum = map_parameter(pszParmName);
7208 if (strchr(pszParmName, ':') == NULL) {
7209 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7215 * We've got a parametric option
7218 opt_list = (snum < 0)
7219 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7220 set_param_opt(opt_list, pszParmName, pszParmValue, 0);
7225 /* if it's already been set by the command line, then we don't
7227 if (parm_table[parmnum].flags & FLAG_CMDLINE) {
7231 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7232 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7236 /* we might point at a service, the default service or a global */
7238 parm_ptr = lp_parm_ptr(NULL, &parm_table[parmnum]);
7240 if (parm_table[parmnum].p_class == P_GLOBAL) {
7242 ("Global parameter %s found in service section!\n",
7246 parm_ptr = lp_local_ptr_by_snum(snum, &parm_table[parmnum]);
7250 if (!ServicePtrs[snum]->copymap)
7251 init_copymap(ServicePtrs[snum]);
7253 /* this handles the aliases - set the copymap for other entries with
7254 the same data pointer */
7255 for (i = 0; parm_table[i].label; i++) {
7256 if ((parm_table[i].offset == parm_table[parmnum].offset)
7257 && (parm_table[i].p_class == parm_table[parmnum].p_class)) {
7258 bitmap_clear(ServicePtrs[snum]->copymap, i);
7263 /* if it is a special case then go ahead */
7264 if (parm_table[parmnum].special) {
7265 return parm_table[parmnum].special(NULL, snum, pszParmValue,
7269 /* now switch on the type of variable it is */
7270 switch (parm_table[parmnum].type)
7273 *(bool *)parm_ptr = lp_bool(pszParmValue);
7277 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7281 *(int *)parm_ptr = lp_int(pszParmValue);
7285 *(char *)parm_ptr = *pszParmValue;
7289 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7291 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7298 if (conv_str_size_error(pszParmValue, &val)) {
7299 if (val <= INT_MAX) {
7300 *(int *)parm_ptr = (int)val;
7305 DEBUG(0,("lp_do_parameter(%s): value is not "
7306 "a valid size specifier!\n", pszParmValue));
7312 TALLOC_FREE(*((char ***)parm_ptr));
7313 *(char ***)parm_ptr = str_list_make_v3(
7314 NULL, pszParmValue, NULL);
7318 string_set((char **)parm_ptr, pszParmValue);
7323 char *upper_string = strupper_talloc(talloc_tos(),
7325 string_set((char **)parm_ptr, upper_string);
7326 TALLOC_FREE(upper_string);
7330 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7339 /***************************************************************************
7340 set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
7341 FLAG_CMDLINE won't be overridden by loads from smb.conf.
7342 ***************************************************************************/
7344 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
7347 parmnum = map_parameter(pszParmName);
7349 parm_table[parmnum].flags &= ~FLAG_CMDLINE;
7350 if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
7353 parm_table[parmnum].flags |= FLAG_CMDLINE;
7355 /* we have to also set FLAG_CMDLINE on aliases. Aliases must
7356 * be grouped in the table, so we don't have to search the
7359 i>=0 && parm_table[i].offset == parm_table[parmnum].offset
7360 && parm_table[i].p_class == parm_table[parmnum].p_class;
7362 parm_table[i].flags |= FLAG_CMDLINE;
7364 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset
7365 && parm_table[i].p_class == parm_table[parmnum].p_class;i++) {
7366 parm_table[i].flags |= FLAG_CMDLINE;
7370 store_lp_set_cmdline(pszParmName, pszParmValue);
7375 /* it might be parametric */
7376 if (strchr(pszParmName, ':') != NULL) {
7377 set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
7379 store_lp_set_cmdline(pszParmName, pszParmValue);
7384 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
7388 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
7390 return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
7393 /***************************************************************************
7394 Process a parameter.
7395 ***************************************************************************/
7397 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7400 if (!bInGlobalSection && bGlobalOnly)
7403 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7405 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7406 pszParmName, pszParmValue));
7410 set a option from the commandline in 'a=b' format. Use to support --option
7412 bool lp_set_option(const char *option)
7417 s = talloc_strdup(NULL, option);
7430 /* skip white spaces after the = sign */
7433 } while (*p == ' ');
7435 ret = lp_set_cmdline(s, p);
7440 /**************************************************************************
7441 Print a parameter of the specified type.
7442 ***************************************************************************/
7444 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7446 /* For the seperation of lists values that we print below */
7447 const char *list_sep = ", ";
7452 for (i = 0; p->enum_list[i].name; i++) {
7453 if (*(int *)ptr == p->enum_list[i].value) {
7455 p->enum_list[i].name);
7462 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7466 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7471 fprintf(f, "%d", *(int *)ptr);
7475 fprintf(f, "%c", *(char *)ptr);
7479 int val = *(int *)ptr;
7483 fprintf(f, "0%o", val);
7492 if ((char ***)ptr && *(char ***)ptr) {
7493 char **list = *(char ***)ptr;
7494 for (; *list; list++) {
7495 /* surround strings with whitespace in double quotes */
7496 if (*(list+1) == NULL) {
7497 /* last item, no extra separator */
7500 if ( strchr_m( *list, ' ' ) ) {
7501 fprintf(f, "\"%s\"%s", *list, list_sep);
7503 fprintf(f, "%s%s", *list, list_sep);
7511 if (*(char **)ptr) {
7512 fprintf(f, "%s", *(char **)ptr);
7520 /***************************************************************************
7521 Check if two parameters are equal.
7522 ***************************************************************************/
7524 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7529 return (*((bool *)ptr1) == *((bool *)ptr2));
7535 return (*((int *)ptr1) == *((int *)ptr2));
7538 return (*((char *)ptr1) == *((char *)ptr2));
7542 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7547 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7552 return (p1 == p2 || strequal(p1, p2));
7560 /***************************************************************************
7561 Initialize any local varients in the sDefault table.
7562 ***************************************************************************/
7564 void init_locals(void)
7569 /***************************************************************************
7570 Process a new section (service). At this stage all sections are services.
7571 Later we'll have special sections that permit server parameters to be set.
7572 Returns true on success, false on failure.
7573 ***************************************************************************/
7575 static bool do_section(const char *pszSectionName, void *userdata)
7578 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7579 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7582 /* if we were in a global section then do the local inits */
7583 if (bInGlobalSection && !isglobal)
7586 /* if we've just struck a global section, note the fact. */
7587 bInGlobalSection = isglobal;
7589 /* check for multiple global sections */
7590 if (bInGlobalSection) {
7591 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7595 if (!bInGlobalSection && bGlobalOnly)
7598 /* if we have a current service, tidy it up before moving on */
7601 if (iServiceIndex >= 0)
7602 bRetval = service_ok(iServiceIndex);
7604 /* if all is still well, move to the next record in the services array */
7606 /* We put this here to avoid an odd message order if messages are */
7607 /* issued by the post-processing of a previous section. */
7608 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7610 iServiceIndex = add_a_service(&sDefault, pszSectionName);
7611 if (iServiceIndex < 0) {
7612 DEBUG(0, ("Failed to add a new service\n"));
7615 /* Clean all parametric options for service */
7616 /* They will be added during parsing again */
7617 free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
7624 /***************************************************************************
7625 Determine if a partcular base parameter is currentl set to the default value.
7626 ***************************************************************************/
7628 static bool is_default(int i)
7630 if (!defaults_saved)
7632 switch (parm_table[i].type) {
7635 return str_list_equal((const char **)parm_table[i].def.lvalue,
7636 *(const char ***)lp_parm_ptr(NULL,
7640 return strequal(parm_table[i].def.svalue,
7641 *(char **)lp_parm_ptr(NULL,
7645 return parm_table[i].def.bvalue ==
7646 *(bool *)lp_parm_ptr(NULL,
7649 return parm_table[i].def.cvalue ==
7650 *(char *)lp_parm_ptr(NULL,
7656 return parm_table[i].def.ivalue ==
7657 *(int *)lp_parm_ptr(NULL,
7665 /***************************************************************************
7666 Display the contents of the global structure.
7667 ***************************************************************************/
7669 static void dump_globals(FILE *f)
7672 struct parmlist_entry *data;
7674 fprintf(f, "[global]\n");
7676 for (i = 0; parm_table[i].label; i++)
7677 if (parm_table[i].p_class == P_GLOBAL &&
7678 !(parm_table[i].flags & FLAG_META) &&
7679 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
7680 if (defaults_saved && is_default(i))
7682 fprintf(f, "\t%s = ", parm_table[i].label);
7683 print_parameter(&parm_table[i], lp_parm_ptr(NULL,
7688 if (Globals.param_opt != NULL) {
7689 data = Globals.param_opt;
7691 fprintf(f, "\t%s = %s\n", data->key, data->value);
7698 /***************************************************************************
7699 Return true if a local parameter is currently set to the global default.
7700 ***************************************************************************/
7702 bool lp_is_default(int snum, struct parm_struct *parm)
7704 return equal_parameter(parm->type,
7705 lp_parm_ptr(ServicePtrs[snum], parm),
7706 lp_parm_ptr(NULL, parm));
7709 /***************************************************************************
7710 Display the contents of a single services record.
7711 ***************************************************************************/
7713 static void dump_a_service(struct loadparm_service *pService, FILE * f)
7716 struct parmlist_entry *data;
7718 if (pService != &sDefault)
7719 fprintf(f, "[%s]\n", pService->szService);
7721 for (i = 0; parm_table[i].label; i++) {
7723 if (parm_table[i].p_class == P_LOCAL &&
7724 !(parm_table[i].flags & FLAG_META) &&
7725 (*parm_table[i].label != '-') &&
7726 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7728 if (pService == &sDefault) {
7729 if (defaults_saved && is_default(i))
7732 if (equal_parameter(parm_table[i].type,
7733 lp_parm_ptr(pService, &parm_table[i]),
7734 lp_parm_ptr(NULL, &parm_table[i])))
7738 fprintf(f, "\t%s = ", parm_table[i].label);
7739 print_parameter(&parm_table[i],
7740 lp_parm_ptr(pService, &parm_table[i]),
7746 if (pService->param_opt != NULL) {
7747 data = pService->param_opt;
7749 fprintf(f, "\t%s = %s\n", data->key, data->value);
7755 /***************************************************************************
7756 Display the contents of a parameter of a single services record.
7757 ***************************************************************************/
7759 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7762 bool result = false;
7765 fstring local_parm_name;
7767 const char *parm_opt_value;
7769 /* check for parametrical option */
7770 fstrcpy( local_parm_name, parm_name);
7771 parm_opt = strchr( local_parm_name, ':');
7776 if (strlen(parm_opt)) {
7777 parm_opt_value = lp_parm_const_string( snum,
7778 local_parm_name, parm_opt, NULL);
7779 if (parm_opt_value) {
7780 printf( "%s\n", parm_opt_value);
7787 /* check for a key and print the value */
7794 for (i = 0; parm_table[i].label; i++) {
7795 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7796 !(parm_table[i].flags & FLAG_META) &&
7797 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7798 (*parm_table[i].label != '-') &&
7799 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7804 ptr = lp_parm_ptr(NULL,
7807 ptr = lp_parm_ptr(ServicePtrs[snum],
7811 print_parameter(&parm_table[i],
7822 /***************************************************************************
7823 Return info about the requested parameter (given as a string).
7824 Return NULL when the string is not a valid parameter name.
7825 ***************************************************************************/
7827 struct parm_struct *lp_get_parameter(const char *param_name)
7829 int num = map_parameter(param_name);
7835 return &parm_table[num];
7838 /***************************************************************************
7839 Return info about the next parameter in a service.
7840 snum==GLOBAL_SECTION_SNUM gives the globals.
7841 Return NULL when out of parameters.
7842 ***************************************************************************/
7844 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
7847 /* do the globals */
7848 for (; parm_table[*i].label; (*i)++) {
7849 if (parm_table[*i].p_class == P_SEPARATOR)
7850 return &parm_table[(*i)++];
7852 if ((*parm_table[*i].label == '-'))
7856 && (parm_table[*i].offset ==
7857 parm_table[(*i) - 1].offset)
7858 && (parm_table[*i].p_class ==
7859 parm_table[(*i) - 1].p_class))
7862 if (is_default(*i) && !allparameters)
7865 return &parm_table[(*i)++];
7868 struct loadparm_service *pService = ServicePtrs[snum];
7870 for (; parm_table[*i].label; (*i)++) {
7871 if (parm_table[*i].p_class == P_SEPARATOR)
7872 return &parm_table[(*i)++];
7874 if (parm_table[*i].p_class == P_LOCAL &&
7875 (*parm_table[*i].label != '-') &&
7877 (parm_table[*i].offset !=
7878 parm_table[(*i) - 1].offset)))
7880 if (allparameters ||
7881 !equal_parameter(parm_table[*i].type,
7882 lp_parm_ptr(pService,
7887 return &parm_table[(*i)++];
7898 /***************************************************************************
7899 Display the contents of a single copy structure.
7900 ***************************************************************************/
7901 static void dump_copy_map(bool *pcopymap)
7907 printf("\n\tNon-Copied parameters:\n");
7909 for (i = 0; parm_table[i].label; i++)
7910 if (parm_table[i].p_class == P_LOCAL &&
7911 parm_table[i].ptr && !pcopymap[i] &&
7912 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7914 printf("\t\t%s\n", parm_table[i].label);
7919 /***************************************************************************
7920 Return TRUE if the passed service number is within range.
7921 ***************************************************************************/
7923 bool lp_snum_ok(int iService)
7925 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
7928 /***************************************************************************
7929 Auto-load some home services.
7930 ***************************************************************************/
7932 static void lp_add_auto_services(char *str)
7942 s = SMB_STRDUP(str);
7946 homes = lp_servicenumber(HOMES_NAME);
7948 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
7949 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
7952 if (lp_servicenumber(p) >= 0)
7955 home = get_user_home_dir(talloc_tos(), p);
7957 if (home && home[0] && homes >= 0)
7958 lp_add_home(p, homes, p, home);
7965 /***************************************************************************
7966 Auto-load one printer.
7967 ***************************************************************************/
7969 void lp_add_one_printer(const char *name, const char *comment,
7970 const char *location, void *pdata)
7972 int printers = lp_servicenumber(PRINTERS_NAME);
7975 if (lp_servicenumber(name) < 0) {
7976 lp_add_printer(name, printers);
7977 if ((i = lp_servicenumber(name)) >= 0) {
7978 string_set(&ServicePtrs[i]->comment, comment);
7979 ServicePtrs[i]->autoloaded = true;
7984 /***************************************************************************
7985 Have we loaded a services file yet?
7986 ***************************************************************************/
7988 bool lp_loaded(void)
7993 /***************************************************************************
7994 Unload unused services.
7995 ***************************************************************************/
7997 void lp_killunused(struct smbd_server_connection *sconn,
7998 bool (*snumused) (struct smbd_server_connection *, int))
8001 for (i = 0; i < iNumServices; i++) {
8005 /* don't kill autoloaded or usershare services */
8006 if ( ServicePtrs[i]->autoloaded ||
8007 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8011 if (!snumused || !snumused(sconn, i)) {
8012 free_service_byindex(i);
8018 * Kill all except autoloaded and usershare services - convenience wrapper
8020 void lp_kill_all_services(void)
8022 lp_killunused(NULL, NULL);
8025 /***************************************************************************
8027 ***************************************************************************/
8029 void lp_killservice(int iServiceIn)
8031 if (VALID(iServiceIn)) {
8032 free_service_byindex(iServiceIn);
8036 /***************************************************************************
8037 Save the curent values of all global and sDefault parameters into the
8038 defaults union. This allows swat and testparm to show only the
8039 changed (ie. non-default) parameters.
8040 ***************************************************************************/
8042 static void lp_save_defaults(void)
8045 for (i = 0; parm_table[i].label; i++) {
8046 if (i > 0 && parm_table[i].offset == parm_table[i - 1].offset
8047 && parm_table[i].p_class == parm_table[i - 1].p_class)
8049 switch (parm_table[i].type) {
8052 parm_table[i].def.lvalue = str_list_copy(
8053 NULL, *(const char ***)lp_parm_ptr(NULL, &parm_table[i]));
8057 parm_table[i].def.svalue = SMB_STRDUP(*(char **)lp_parm_ptr(NULL, &parm_table[i]));
8061 parm_table[i].def.bvalue =
8062 *(bool *)lp_parm_ptr(NULL, &parm_table[i]);
8065 parm_table[i].def.cvalue =
8066 *(char *)lp_parm_ptr(NULL, &parm_table[i]);
8072 parm_table[i].def.ivalue =
8073 *(int *)lp_parm_ptr(NULL, &parm_table[i]);
8079 defaults_saved = true;
8082 /***********************************************************
8083 If we should send plaintext/LANMAN passwords in the clinet
8084 ************************************************************/
8086 static void set_allowed_client_auth(void)
8088 if (Globals.bClientNTLMv2Auth) {
8089 Globals.bClientLanManAuth = false;
8091 if (!Globals.bClientLanManAuth) {
8092 Globals.bClientPlaintextAuth = false;
8096 /***************************************************************************
8098 The following code allows smbd to read a user defined share file.
8099 Yes, this is my intent. Yes, I'm comfortable with that...
8101 THE FOLLOWING IS SECURITY CRITICAL CODE.
8103 It washes your clothes, it cleans your house, it guards you while you sleep...
8104 Do not f%^k with it....
8105 ***************************************************************************/
8107 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8109 /***************************************************************************
8110 Check allowed stat state of a usershare file.
8111 Ensure we print out who is dicking with us so the admin can
8112 get their sorry ass fired.
8113 ***************************************************************************/
8115 static bool check_usershare_stat(const char *fname,
8116 const SMB_STRUCT_STAT *psbuf)
8118 if (!S_ISREG(psbuf->st_ex_mode)) {
8119 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8120 "not a regular file\n",
8121 fname, (unsigned int)psbuf->st_ex_uid ));
8125 /* Ensure this doesn't have the other write bit set. */
8126 if (psbuf->st_ex_mode & S_IWOTH) {
8127 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8128 "public write. Refusing to allow as a usershare file.\n",
8129 fname, (unsigned int)psbuf->st_ex_uid ));
8133 /* Should be 10k or less. */
8134 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8135 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8136 "too large (%u) to be a user share file.\n",
8137 fname, (unsigned int)psbuf->st_ex_uid,
8138 (unsigned int)psbuf->st_ex_size ));
8145 /***************************************************************************
8146 Parse the contents of a usershare file.
8147 ***************************************************************************/
8149 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8150 SMB_STRUCT_STAT *psbuf,
8151 const char *servicename,
8155 char **pp_sharepath,
8157 char **pp_cp_servicename,
8158 struct security_descriptor **ppsd,
8161 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8162 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8165 SMB_STRUCT_STAT sbuf;
8166 char *sharepath = NULL;
8167 char *comment = NULL;
8169 *pp_sharepath = NULL;
8172 *pallow_guest = false;
8175 return USERSHARE_MALFORMED_FILE;
8178 if (strcmp(lines[0], "#VERSION 1") == 0) {
8180 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8183 return USERSHARE_MALFORMED_FILE;
8186 return USERSHARE_BAD_VERSION;
8189 if (strncmp(lines[1], "path=", 5) != 0) {
8190 return USERSHARE_MALFORMED_PATH;
8193 sharepath = talloc_strdup(ctx, &lines[1][5]);
8195 return USERSHARE_POSIX_ERR;
8197 trim_string(sharepath, " ", " ");
8199 if (strncmp(lines[2], "comment=", 8) != 0) {
8200 return USERSHARE_MALFORMED_COMMENT_DEF;
8203 comment = talloc_strdup(ctx, &lines[2][8]);
8205 return USERSHARE_POSIX_ERR;
8207 trim_string(comment, " ", " ");
8208 trim_char(comment, '"', '"');
8210 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8211 return USERSHARE_MALFORMED_ACL_DEF;
8214 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8215 return USERSHARE_ACL_ERR;
8219 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8220 return USERSHARE_MALFORMED_ACL_DEF;
8222 if (lines[4][9] == 'y') {
8223 *pallow_guest = true;
8226 /* Backwards compatible extension to file version #2. */
8228 if (strncmp(lines[5], "sharename=", 10) != 0) {
8229 return USERSHARE_MALFORMED_SHARENAME_DEF;
8231 if (!strequal(&lines[5][10], servicename)) {
8232 return USERSHARE_BAD_SHARENAME;
8234 *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
8235 if (!*pp_cp_servicename) {
8236 return USERSHARE_POSIX_ERR;
8241 if (*pp_cp_servicename == NULL) {
8242 *pp_cp_servicename = talloc_strdup(ctx, servicename);
8243 if (!*pp_cp_servicename) {
8244 return USERSHARE_POSIX_ERR;
8248 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8249 /* Path didn't change, no checks needed. */
8250 *pp_sharepath = sharepath;
8251 *pp_comment = comment;
8252 return USERSHARE_OK;
8255 /* The path *must* be absolute. */
8256 if (sharepath[0] != '/') {
8257 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8258 servicename, sharepath));
8259 return USERSHARE_PATH_NOT_ABSOLUTE;
8262 /* If there is a usershare prefix deny list ensure one of these paths
8263 doesn't match the start of the user given path. */
8264 if (prefixdenylist) {
8266 for ( i=0; prefixdenylist[i]; i++ ) {
8267 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8268 servicename, i, prefixdenylist[i], sharepath ));
8269 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8270 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8271 "usershare prefix deny list entries.\n",
8272 servicename, sharepath));
8273 return USERSHARE_PATH_IS_DENIED;
8278 /* If there is a usershare prefix allow list ensure one of these paths
8279 does match the start of the user given path. */
8281 if (prefixallowlist) {
8283 for ( i=0; prefixallowlist[i]; i++ ) {
8284 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8285 servicename, i, prefixallowlist[i], sharepath ));
8286 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8290 if (prefixallowlist[i] == NULL) {
8291 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8292 "usershare prefix allow list entries.\n",
8293 servicename, sharepath));
8294 return USERSHARE_PATH_NOT_ALLOWED;
8298 /* Ensure this is pointing to a directory. */
8299 dp = opendir(sharepath);
8302 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8303 servicename, sharepath));
8304 return USERSHARE_PATH_NOT_DIRECTORY;
8307 /* Ensure the owner of the usershare file has permission to share
8310 if (sys_stat(sharepath, &sbuf, false) == -1) {
8311 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8312 servicename, sharepath, strerror(errno) ));
8314 return USERSHARE_POSIX_ERR;
8319 if (!S_ISDIR(sbuf.st_ex_mode)) {
8320 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8321 servicename, sharepath ));
8322 return USERSHARE_PATH_NOT_DIRECTORY;
8325 /* Check if sharing is restricted to owner-only. */
8326 /* psbuf is the stat of the usershare definition file,
8327 sbuf is the stat of the target directory to be shared. */
8329 if (lp_usershare_owner_only()) {
8330 /* root can share anything. */
8331 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8332 return USERSHARE_PATH_NOT_ALLOWED;
8336 *pp_sharepath = sharepath;
8337 *pp_comment = comment;
8338 return USERSHARE_OK;
8341 /***************************************************************************
8342 Deal with a usershare file.
8345 -1 - Bad name, invalid contents.
8346 - service name already existed and not a usershare, problem
8347 with permissions to share directory etc.
8348 ***************************************************************************/
8350 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8352 SMB_STRUCT_STAT sbuf;
8353 SMB_STRUCT_STAT lsbuf;
8355 char *sharepath = NULL;
8356 char *comment = NULL;
8357 char *cp_service_name = NULL;
8358 char **lines = NULL;
8362 TALLOC_CTX *ctx = talloc_stackframe();
8363 struct security_descriptor *psd = NULL;
8364 bool guest_ok = false;
8365 char *canon_name = NULL;
8366 bool added_service = false;
8369 /* Ensure share name doesn't contain invalid characters. */
8370 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8371 DEBUG(0,("process_usershare_file: share name %s contains "
8372 "invalid characters (any of %s)\n",
8373 file_name, INVALID_SHARENAME_CHARS ));
8377 canon_name = canonicalize_servicename(ctx, file_name);
8382 fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
8387 /* Minimize the race condition by doing an lstat before we
8388 open and fstat. Ensure this isn't a symlink link. */
8390 if (sys_lstat(fname, &lsbuf, false) != 0) {
8391 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8392 fname, strerror(errno) ));
8396 /* This must be a regular file, not a symlink, directory or
8397 other strange filetype. */
8398 if (!check_usershare_stat(fname, &lsbuf)) {
8406 status = dbwrap_fetch_bystring(ServiceHash, canon_name,
8411 if (NT_STATUS_IS_OK(status) &&
8412 (data.dptr != NULL) &&
8413 (data.dsize == sizeof(iService))) {
8414 memcpy(&iService, data.dptr, sizeof(iService));
8418 if (iService != -1 &&
8419 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8420 &lsbuf.st_ex_mtime) == 0) {
8421 /* Nothing changed - Mark valid and return. */
8422 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8424 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8429 /* Try and open the file read only - no symlinks allowed. */
8431 fd = open(fname, O_RDONLY|O_NOFOLLOW, 0);
8433 fd = open(fname, O_RDONLY, 0);
8437 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8438 fname, strerror(errno) ));
8442 /* Now fstat to be *SURE* it's a regular file. */
8443 if (sys_fstat(fd, &sbuf, false) != 0) {
8445 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8446 fname, strerror(errno) ));
8450 /* Is it the same dev/inode as was lstated ? */
8451 if (!check_same_stat(&lsbuf, &sbuf)) {
8453 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8454 "Symlink spoofing going on ?\n", fname ));
8458 /* This must be a regular file, not a symlink, directory or
8459 other strange filetype. */
8460 if (!check_usershare_stat(fname, &sbuf)) {
8464 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8467 if (lines == NULL) {
8468 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8469 fname, (unsigned int)sbuf.st_ex_uid ));
8473 if (parse_usershare_file(ctx, &sbuf, file_name,
8474 iService, lines, numlines, &sharepath,
8475 &comment, &cp_service_name,
8476 &psd, &guest_ok) != USERSHARE_OK) {
8480 /* Everything ok - add the service possibly using a template. */
8482 const struct loadparm_service *sp = &sDefault;
8483 if (snum_template != -1) {
8484 sp = ServicePtrs[snum_template];
8487 if ((iService = add_a_service(sp, cp_service_name)) < 0) {
8488 DEBUG(0, ("process_usershare_file: Failed to add "
8489 "new service %s\n", cp_service_name));
8493 added_service = true;
8495 /* Read only is controlled by usershare ACL below. */
8496 ServicePtrs[iService]->bRead_only = false;
8499 /* Write the ACL of the new/modified share. */
8500 if (!set_share_security(canon_name, psd)) {
8501 DEBUG(0, ("process_usershare_file: Failed to set share "
8502 "security for user share %s\n",
8507 /* If from a template it may be marked invalid. */
8508 ServicePtrs[iService]->valid = true;
8510 /* Set the service as a valid usershare. */
8511 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8513 /* Set guest access. */
8514 if (lp_usershare_allow_guests()) {
8515 ServicePtrs[iService]->bGuest_ok = guest_ok;
8518 /* And note when it was loaded. */
8519 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8520 string_set(&ServicePtrs[iService]->szPath, sharepath);
8521 string_set(&ServicePtrs[iService]->comment, comment);
8527 if (ret == -1 && iService != -1 && added_service) {
8528 lp_remove_service(iService);
8536 /***************************************************************************
8537 Checks if a usershare entry has been modified since last load.
8538 ***************************************************************************/
8540 static bool usershare_exists(int iService, struct timespec *last_mod)
8542 SMB_STRUCT_STAT lsbuf;
8543 const char *usersharepath = Globals.szUsersharePath;
8546 if (asprintf(&fname, "%s/%s",
8548 ServicePtrs[iService]->szService) < 0) {
8552 if (sys_lstat(fname, &lsbuf, false) != 0) {
8557 if (!S_ISREG(lsbuf.st_ex_mode)) {
8563 *last_mod = lsbuf.st_ex_mtime;
8567 /***************************************************************************
8568 Load a usershare service by name. Returns a valid servicenumber or -1.
8569 ***************************************************************************/
8571 int load_usershare_service(const char *servicename)
8573 SMB_STRUCT_STAT sbuf;
8574 const char *usersharepath = Globals.szUsersharePath;
8575 int max_user_shares = Globals.iUsershareMaxShares;
8576 int snum_template = -1;
8578 if (*usersharepath == 0 || max_user_shares == 0) {
8582 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8583 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8584 usersharepath, strerror(errno) ));
8588 if (!S_ISDIR(sbuf.st_ex_mode)) {
8589 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8595 * This directory must be owned by root, and have the 't' bit set.
8596 * It also must not be writable by "other".
8600 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8602 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8604 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8605 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8610 /* Ensure the template share exists if it's set. */
8611 if (Globals.szUsershareTemplateShare[0]) {
8612 /* We can't use lp_servicenumber here as we are recommending that
8613 template shares have -valid=false set. */
8614 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8615 if (ServicePtrs[snum_template]->szService &&
8616 strequal(ServicePtrs[snum_template]->szService,
8617 Globals.szUsershareTemplateShare)) {
8622 if (snum_template == -1) {
8623 DEBUG(0,("load_usershare_service: usershare template share %s "
8624 "does not exist.\n",
8625 Globals.szUsershareTemplateShare ));
8630 return process_usershare_file(usersharepath, servicename, snum_template);
8633 /***************************************************************************
8634 Load all user defined shares from the user share directory.
8635 We only do this if we're enumerating the share list.
8636 This is the function that can delete usershares that have
8638 ***************************************************************************/
8640 int load_usershare_shares(struct smbd_server_connection *sconn,
8641 bool (*snumused) (struct smbd_server_connection *, int))
8644 SMB_STRUCT_STAT sbuf;
8646 int num_usershares = 0;
8647 int max_user_shares = Globals.iUsershareMaxShares;
8648 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8649 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8650 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8652 int snum_template = -1;
8653 const char *usersharepath = Globals.szUsersharePath;
8654 int ret = lp_numservices();
8655 TALLOC_CTX *tmp_ctx;
8657 if (max_user_shares == 0 || *usersharepath == '\0') {
8658 return lp_numservices();
8661 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8662 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8663 usersharepath, strerror(errno) ));
8668 * This directory must be owned by root, and have the 't' bit set.
8669 * It also must not be writable by "other".
8673 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8675 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8677 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8678 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8683 /* Ensure the template share exists if it's set. */
8684 if (Globals.szUsershareTemplateShare[0]) {
8685 /* We can't use lp_servicenumber here as we are recommending that
8686 template shares have -valid=false set. */
8687 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8688 if (ServicePtrs[snum_template]->szService &&
8689 strequal(ServicePtrs[snum_template]->szService,
8690 Globals.szUsershareTemplateShare)) {
8695 if (snum_template == -1) {
8696 DEBUG(0,("load_usershare_shares: usershare template share %s "
8697 "does not exist.\n",
8698 Globals.szUsershareTemplateShare ));
8703 /* Mark all existing usershares as pending delete. */
8704 for (iService = iNumServices - 1; iService >= 0; iService--) {
8705 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8706 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8710 dp = opendir(usersharepath);
8712 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8713 usersharepath, strerror(errno) ));
8717 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8719 num_dir_entries++ ) {
8721 const char *n = de->d_name;
8723 /* Ignore . and .. */
8725 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8731 /* Temporary file used when creating a share. */
8732 num_tmp_dir_entries++;
8735 /* Allow 20% tmp entries. */
8736 if (num_tmp_dir_entries > allowed_tmp_entries) {
8737 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8738 "in directory %s\n",
8739 num_tmp_dir_entries, usersharepath));
8743 r = process_usershare_file(usersharepath, n, snum_template);
8745 /* Update the services count. */
8747 if (num_usershares >= max_user_shares) {
8748 DEBUG(0,("load_usershare_shares: max user shares reached "
8749 "on file %s in directory %s\n",
8750 n, usersharepath ));
8753 } else if (r == -1) {
8754 num_bad_dir_entries++;
8757 /* Allow 20% bad entries. */
8758 if (num_bad_dir_entries > allowed_bad_entries) {
8759 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8760 "in directory %s\n",
8761 num_bad_dir_entries, usersharepath));
8765 /* Allow 20% bad entries. */
8766 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
8767 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8768 "in directory %s\n",
8769 num_dir_entries, usersharepath));
8776 /* Sweep through and delete any non-refreshed usershares that are
8777 not currently in use. */
8778 tmp_ctx = talloc_stackframe();
8779 for (iService = iNumServices - 1; iService >= 0; iService--) {
8780 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
8783 if (snumused && snumused(sconn, iService)) {
8787 servname = lp_servicename(tmp_ctx, iService);
8789 /* Remove from the share ACL db. */
8790 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8792 delete_share_security(servname);
8793 free_service_byindex(iService);
8796 talloc_free(tmp_ctx);
8798 return lp_numservices();
8801 /********************************************************
8802 Destroy global resources allocated in this file
8803 ********************************************************/
8805 void gfree_loadparm(void)
8811 /* Free resources allocated to services */
8813 for ( i = 0; i < iNumServices; i++ ) {
8815 free_service_byindex(i);
8819 SAFE_FREE( ServicePtrs );
8822 /* Now release all resources allocated to global
8823 parameters and the default service */
8825 free_global_parameters();
8829 /***************************************************************************
8830 Allow client apps to specify that they are a client
8831 ***************************************************************************/
8832 static void lp_set_in_client(bool b)
8838 /***************************************************************************
8839 Determine if we're running in a client app
8840 ***************************************************************************/
8841 static bool lp_is_in_client(void)
8846 /***************************************************************************
8847 Load the services array from the services file. Return true on success,
8849 ***************************************************************************/
8851 static bool lp_load_ex(const char *pszFname,
8855 bool initialize_globals,
8856 bool allow_include_registry,
8857 bool load_all_shares)
8864 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
8866 bInGlobalSection = true;
8867 bGlobalOnly = global_only;
8868 bAllowIncludeRegistry = allow_include_registry;
8870 init_globals(initialize_globals);
8874 if (save_defaults) {
8879 if (!initialize_globals) {
8880 free_param_opts(&Globals.param_opt);
8881 apply_lp_set_cmdline();
8884 lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
8886 /* We get sections first, so have to start 'behind' to make up */
8889 if (lp_config_backend_is_file()) {
8890 n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
8891 current_user_info.domain,
8894 smb_panic("lp_load_ex: out of memory");
8897 add_to_file_list(pszFname, n2);
8899 bRetval = pm_process(n2, do_section, do_parameter, NULL);
8902 /* finish up the last section */
8903 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
8905 if (iServiceIndex >= 0) {
8906 bRetval = service_ok(iServiceIndex);
8910 if (lp_config_backend_is_registry()) {
8911 /* config backend changed to registry in config file */
8913 * We need to use this extra global variable here to
8914 * survive restart: init_globals uses this as a default
8915 * for ConfigBackend. Otherwise, init_globals would
8916 * send us into an endless loop here.
8918 config_backend = CONFIG_BACKEND_REGISTRY;
8920 DEBUG(1, ("lp_load_ex: changing to config backend "
8923 lp_kill_all_services();
8924 return lp_load_ex(pszFname, global_only, save_defaults,
8925 add_ipc, initialize_globals,
8926 allow_include_registry,
8929 } else if (lp_config_backend_is_registry()) {
8930 bRetval = process_registry_globals();
8932 DEBUG(0, ("Illegal config backend given: %d\n",
8933 lp_config_backend()));
8937 if (bRetval && lp_registry_shares()) {
8938 if (load_all_shares) {
8939 bRetval = process_registry_shares();
8941 bRetval = reload_registry_shares();
8946 char *serv = lp_auto_services(talloc_tos());
8947 lp_add_auto_services(serv);
8952 /* When 'restrict anonymous = 2' guest connections to ipc$
8954 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
8955 if ( lp_enable_asu_support() ) {
8956 lp_add_ipc("ADMIN$", false);
8960 set_allowed_client_auth();
8962 if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) {
8963 DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
8964 lp_passwordserver()));
8969 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
8970 /* if bWINSsupport is true and we are in the client */
8971 if (lp_is_in_client() && Globals.bWINSsupport) {
8972 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
8977 fault_configure(smb_panic_s3);
8979 bAllowIncludeRegistry = true;
8984 bool lp_load(const char *pszFname,
8988 bool initialize_globals)
8990 return lp_load_ex(pszFname,
8995 true, /* allow_include_registry */
8996 false); /* load_all_shares*/
8999 bool lp_load_initial_only(const char *pszFname)
9001 return lp_load_ex(pszFname,
9002 true, /* global only */
9003 false, /* save_defaults */
9004 false, /* add_ipc */
9005 true, /* initialize_globals */
9006 false, /* allow_include_registry */
9007 false); /* load_all_shares*/
9011 * most common lp_load wrapper, loading only the globals
9013 bool lp_load_global(const char *file_name)
9015 return lp_load_ex(file_name,
9016 true, /* global_only */
9017 false, /* save_defaults */
9018 false, /* add_ipc */
9019 true, /* initialize_globals */
9020 true, /* allow_include_registry */
9021 false); /* load_all_shares*/
9025 * lp_load wrapper, especially for clients
9027 bool lp_load_client(const char *file_name)
9029 lp_set_in_client(true);
9031 return lp_load_global(file_name);
9035 * lp_load wrapper, loading only globals, but intended
9036 * for subsequent calls, not reinitializing the globals
9039 bool lp_load_global_no_reinit(const char *file_name)
9041 return lp_load_ex(file_name,
9042 true, /* global_only */
9043 false, /* save_defaults */
9044 false, /* add_ipc */
9045 false, /* initialize_globals */
9046 true, /* allow_include_registry */
9047 false); /* load_all_shares*/
9051 * lp_load wrapper, especially for clients, no reinitialization
9053 bool lp_load_client_no_reinit(const char *file_name)
9055 lp_set_in_client(true);
9057 return lp_load_global_no_reinit(file_name);
9060 bool lp_load_with_registry_shares(const char *pszFname,
9064 bool initialize_globals)
9066 return lp_load_ex(pszFname,
9071 true, /* allow_include_registry */
9072 true); /* load_all_shares*/
9075 /***************************************************************************
9076 Return the max number of services.
9077 ***************************************************************************/
9079 int lp_numservices(void)
9081 return (iNumServices);
9084 /***************************************************************************
9085 Display the contents of the services array in human-readable form.
9086 ***************************************************************************/
9088 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9093 defaults_saved = false;
9097 dump_a_service(&sDefault, f);
9099 for (iService = 0; iService < maxtoprint; iService++) {
9101 lp_dump_one(f, show_defaults, iService);
9105 /***************************************************************************
9106 Display the contents of one service in human-readable form.
9107 ***************************************************************************/
9109 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9112 if (ServicePtrs[snum]->szService[0] == '\0')
9114 dump_a_service(ServicePtrs[snum], f);
9118 /***************************************************************************
9119 Return the number of the service with the given name, or -1 if it doesn't
9120 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9121 getservicebyname()! This works ONLY if all services have been loaded, and
9122 does not copy the found service.
9123 ***************************************************************************/
9125 int lp_servicenumber(const char *pszServiceName)
9128 fstring serviceName;
9130 if (!pszServiceName) {
9131 return GLOBAL_SECTION_SNUM;
9134 for (iService = iNumServices - 1; iService >= 0; iService--) {
9135 if (VALID(iService) && ServicePtrs[iService]->szService) {
9137 * The substitution here is used to support %U is
9140 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9141 standard_sub_basic(get_current_username(),
9142 current_user_info.domain,
9143 serviceName,sizeof(serviceName));
9144 if (strequal(serviceName, pszServiceName)) {
9150 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9151 struct timespec last_mod;
9153 if (!usershare_exists(iService, &last_mod)) {
9154 /* Remove the share security tdb entry for it. */
9155 delete_share_security(lp_servicename(talloc_tos(), iService));
9156 /* Remove it from the array. */
9157 free_service_byindex(iService);
9158 /* Doesn't exist anymore. */
9159 return GLOBAL_SECTION_SNUM;
9162 /* Has it been modified ? If so delete and reload. */
9163 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9165 /* Remove it from the array. */
9166 free_service_byindex(iService);
9167 /* and now reload it. */
9168 iService = load_usershare_service(pszServiceName);
9173 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9174 return GLOBAL_SECTION_SNUM;
9180 /*******************************************************************
9181 A useful volume label function.
9182 ********************************************************************/
9184 const char *volume_label(TALLOC_CTX *ctx, int snum)
9187 const char *label = lp_volume(ctx, snum);
9189 label = lp_servicename(ctx, snum);
9192 /* This returns a 33 byte guarenteed null terminated string. */
9193 ret = talloc_strndup(ctx, label, 32);
9200 /*******************************************************************
9201 Get the default server type we will announce as via nmbd.
9202 ********************************************************************/
9204 int lp_default_server_announce(void)
9206 int default_server_announce = 0;
9207 default_server_announce |= SV_TYPE_WORKSTATION;
9208 default_server_announce |= SV_TYPE_SERVER;
9209 default_server_announce |= SV_TYPE_SERVER_UNIX;
9211 /* note that the flag should be set only if we have a
9212 printer service but nmbd doesn't actually load the
9213 services so we can't tell --jerry */
9215 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9217 default_server_announce |= SV_TYPE_SERVER_NT;
9218 default_server_announce |= SV_TYPE_NT;
9220 switch (lp_server_role()) {
9221 case ROLE_DOMAIN_MEMBER:
9222 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9224 case ROLE_DOMAIN_PDC:
9225 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9227 case ROLE_DOMAIN_BDC:
9228 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9230 case ROLE_STANDALONE:
9234 if (lp_time_server())
9235 default_server_announce |= SV_TYPE_TIME_SOURCE;
9237 if (lp_host_msdfs())
9238 default_server_announce |= SV_TYPE_DFS_SERVER;
9240 return default_server_announce;
9243 /***********************************************************
9244 If we are PDC then prefer us as DMB
9245 ************************************************************/
9247 bool lp_domain_master(void)
9249 if (Globals.domain_master == Auto)
9250 return (lp_server_role() == ROLE_DOMAIN_PDC);
9252 return (bool)Globals.domain_master;
9255 /***********************************************************
9256 If we are PDC then prefer us as DMB
9257 ************************************************************/
9259 static bool lp_domain_master_true_or_auto(void)
9261 if (Globals.domain_master) /* auto or yes */
9267 /***********************************************************
9268 If we are DMB then prefer us as LMB
9269 ************************************************************/
9271 bool lp_preferred_master(void)
9273 if (Globals.iPreferredMaster == Auto)
9274 return (lp_local_master() && lp_domain_master());
9276 return (bool)Globals.iPreferredMaster;
9279 /*******************************************************************
9281 ********************************************************************/
9283 void lp_remove_service(int snum)
9285 ServicePtrs[snum]->valid = false;
9286 invalid_services[num_invalid_services++] = snum;
9289 /*******************************************************************
9291 ********************************************************************/
9293 void lp_copy_service(int snum, const char *new_name)
9295 do_section(new_name, NULL);
9297 snum = lp_servicenumber(new_name);
9299 char *name = lp_servicename(talloc_tos(), snum);
9300 lp_do_parameter(snum, "copy", name);
9305 const char *lp_printername(TALLOC_CTX *ctx, int snum)
9307 const char *ret = lp__printername(talloc_tos(), snum);
9308 if (ret == NULL || *ret == '\0') {
9309 ret = lp_const_servicename(snum);
9316 /***********************************************************
9317 Allow daemons such as winbindd to fix their logfile name.
9318 ************************************************************/
9320 void lp_set_logfile(const char *name)
9322 string_set(&Globals.logfile, name);
9323 debug_set_logfile(name);
9326 /*******************************************************************
9327 Return the max print jobs per queue.
9328 ********************************************************************/
9330 int lp_maxprintjobs(int snum)
9332 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9333 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9334 maxjobs = PRINT_MAX_JOBID - 1;
9339 const char *lp_printcapname(void)
9341 if ((Globals.szPrintcapname != NULL) &&
9342 (Globals.szPrintcapname[0] != '\0'))
9343 return Globals.szPrintcapname;
9345 if (sDefault.iPrinting == PRINT_CUPS) {
9353 if (sDefault.iPrinting == PRINT_BSD)
9354 return "/etc/printcap";
9356 return PRINTCAP_NAME;
9359 static uint32 spoolss_state;
9361 bool lp_disable_spoolss( void )
9363 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9364 spoolss_state = lp__disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9366 return spoolss_state == SVCCTL_STOPPED ? true : false;
9369 void lp_set_spoolss_state( uint32 state )
9371 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9373 spoolss_state = state;
9376 uint32 lp_get_spoolss_state( void )
9378 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9381 /*******************************************************************
9382 Ensure we don't use sendfile if server smb signing is active.
9383 ********************************************************************/
9385 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9387 bool sign_active = false;
9389 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9390 if (get_Protocol() < PROTOCOL_NT1) {
9393 if (signing_state) {
9394 sign_active = smb_signing_is_active(signing_state);
9396 return (lp__use_sendfile(snum) &&
9397 (get_remote_arch() != RA_WIN95) &&
9401 /*******************************************************************
9402 Turn off sendfile if we find the underlying OS doesn't support it.
9403 ********************************************************************/
9405 void set_use_sendfile(int snum, bool val)
9407 if (LP_SNUM_OK(snum))
9408 ServicePtrs[snum]->bUseSendfile = val;
9410 sDefault.bUseSendfile = val;
9413 /*******************************************************************
9414 Turn off storing DOS attributes if this share doesn't support it.
9415 ********************************************************************/
9417 void set_store_dos_attributes(int snum, bool val)
9419 if (!LP_SNUM_OK(snum))
9421 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9424 void lp_set_mangling_method(const char *new_method)
9426 string_set(&Globals.szManglingMethod, new_method);
9429 /*******************************************************************
9430 Global state for POSIX pathname processing.
9431 ********************************************************************/
9433 static bool posix_pathnames;
9435 bool lp_posix_pathnames(void)
9437 return posix_pathnames;
9440 /*******************************************************************
9441 Change everything needed to ensure POSIX pathname processing (currently
9443 ********************************************************************/
9445 void lp_set_posix_pathnames(void)
9447 posix_pathnames = true;
9450 /*******************************************************************
9451 Global state for POSIX lock processing - CIFS unix extensions.
9452 ********************************************************************/
9454 bool posix_default_lock_was_set;
9455 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9457 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9459 if (posix_default_lock_was_set) {
9460 return posix_cifsx_locktype;
9462 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9466 /*******************************************************************
9467 ********************************************************************/
9469 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9471 posix_default_lock_was_set = true;
9472 posix_cifsx_locktype = val;
9475 int lp_min_receive_file_size(void)
9477 if (Globals.iminreceivefile < 0) {
9480 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9483 /*******************************************************************
9484 If socket address is an empty character string, it is necessary to
9485 define it as "0.0.0.0".
9486 ********************************************************************/
9488 const char *lp_socket_address(void)
9490 char *sock_addr = Globals.szSocketAddress;
9492 if (sock_addr[0] == '\0'){
9493 string_set(&Globals.szSocketAddress, "0.0.0.0");
9495 return Globals.szSocketAddress;
9498 /*******************************************************************
9499 Safe wide links checks.
9500 This helper function always verify the validity of wide links,
9501 even after a configuration file reload.
9502 ********************************************************************/
9504 static bool lp_widelinks_internal(int snum)
9506 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9507 sDefault.bWidelinks);
9510 void widelinks_warning(int snum)
9512 if (lp_allow_insecure_widelinks()) {
9516 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9517 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9518 "These parameters are incompatible. "
9519 "Wide links will be disabled for this share.\n",
9520 lp_servicename(talloc_tos(), snum) ));
9524 bool lp_widelinks(int snum)
9526 /* wide links is always incompatible with unix extensions */
9527 if (lp_unix_extensions()) {
9529 * Unless we have "allow insecure widelinks"
9532 if (!lp_allow_insecure_widelinks()) {
9537 return lp_widelinks_internal(snum);
9540 bool lp_writeraw(void)
9542 if (lp_async_smb_echo_handler()) {
9545 return lp__writeraw();
9548 bool lp_readraw(void)
9550 if (lp_async_smb_echo_handler()) {
9553 return lp__readraw();
9556 int lp_server_role(void)
9558 return lp_find_server_role(lp__server_role(),
9561 lp_domain_master_true_or_auto());