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"
60 #include "lib/smbconf/smbconf.h"
61 #include "lib/smbconf/smbconf_init.h"
62 #include "lib/param/loadparm.h"
65 #include "../librpc/gen_ndr/svcctl.h"
67 #include "smb_signing.h"
70 #include "../lib/util/bitmap.h"
72 #ifdef HAVE_SYS_SYSCTL_H
73 #include <sys/sysctl.h>
76 #ifdef HAVE_HTTPCONNECTENCRYPT
77 #include <cups/http.h>
82 extern userdom_struct current_user_info;
84 /* the special value for the include parameter
85 * to be interpreted not as a file name but to
86 * trigger loading of the global smb.conf options
88 #ifndef INCLUDE_REGISTRY_NAME
89 #define INCLUDE_REGISTRY_NAME "registry"
92 static bool in_client = false; /* Not in the client by default */
93 static struct smbconf_csn conf_last_csn;
95 #define CONFIG_BACKEND_FILE 0
96 #define CONFIG_BACKEND_REGISTRY 1
98 static int config_backend = CONFIG_BACKEND_FILE;
100 /* some helpful bits */
101 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
102 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
104 #define USERSHARE_VALID 1
105 #define USERSHARE_PENDING_DELETE 2
107 static bool defaults_saved = false;
109 #define LOADPARM_EXTRA_GLOBALS \
110 struct parmlist_entry *param_opt; \
113 int iminreceivefile; \
114 char *szPrintcapname; \
116 int iPreferredMaster; \
118 char *szLdapMachineSuffix; \
119 char *szLdapUserSuffix; \
120 char *szLdapIdmapSuffix; \
121 char *szLdapGroupSuffix; \
124 char *szSocketAddress; \
125 char *szUsershareTemplateShare; \
128 int winbindMaxDomainConnections; \
129 int ismb2_max_credits;
130 #define LOADPARM_EXTRA_LOCALS \
133 struct timespec usershare_last_mod; \
139 struct parmlist_entry *param_opt; \
140 struct bitmap *copymap; \
141 char dummy[3]; /* for alignment */
143 #include "param/param_global.h"
144 #include "param/param_local.h"
146 static struct loadparm_global Globals;
148 /* This is a default service used to prime a services structure */
149 static struct loadparm_service sDefault =
154 .usershare_last_mod = {0, 0},
158 .szInvalidUsers = NULL,
159 .szValidUsers = NULL,
160 .szAdminUsers = NULL,
165 .szRootPreExec = NULL,
166 .szRootPostExec = NULL,
167 .szCupsOptions = NULL,
168 .szPrintcommand = NULL,
169 .szLpqcommand = NULL,
170 .szLprmcommand = NULL,
171 .szLppausecommand = NULL,
172 .szLpresumecommand = NULL,
173 .szQueuepausecommand = NULL,
174 .szQueueresumecommand = NULL,
175 .szPrintername = NULL,
176 .szPrintjobUsername = NULL,
177 .szDontdescend = NULL,
178 .szHostsallow = NULL,
180 .szMagicScript = NULL,
181 .szMagicOutput = NULL,
184 .szVetoOplockFiles = NULL,
190 .printer_admin = NULL,
193 .szVfsObjects = NULL,
194 .szMSDfsProxy = NULL,
195 .szAioWriteBehind = NULL,
198 .iMaxPrintJobs = 1000,
199 .iMaxReportedPrintJobs = 0,
200 .iWriteCacheSize = 0,
201 .iCreate_mask = 0744,
202 .iCreate_force_mode = 0,
203 .iSecurity_mask = 0777,
204 .iSecurity_force_mode = 0,
206 .iDir_force_mode = 0,
207 .iDir_Security_mask = 0777,
208 .iDir_Security_force_mode = 0,
209 .iMaxConnections = 0,
210 .iDefaultCase = CASE_LOWER,
211 .iPrinting = DEFAULT_PRINTING,
212 .iOplockContentionLimit = 2,
215 .iDfreeCacheTime = 0,
216 .bPreexecClose = false,
217 .bRootpreexecClose = false,
218 .iCaseSensitive = Auto,
219 .bCasePreserve = true,
220 .bShortCasePreserve = true,
221 .bHideDotFiles = true,
222 .bHideSpecialFiles = false,
223 .bHideUnReadable = false,
224 .bHideUnWriteableFiles = false,
226 .bAccessBasedShareEnum = false,
230 .bGuest_only = false,
231 .bAdministrative_share = false,
234 .bPrintNotifyBackchannel = true,
235 .bMap_system = false,
236 .bMap_hidden = false,
237 .bMap_archive = true,
238 .bStoreDosAttributes = false,
239 .bDmapiSupport = false,
241 .iStrictLocking = Auto,
242 .bPosixLocking = true,
245 .bLevel2OpLocks = true,
247 .bMangledNames = true,
250 .bSyncAlways = false,
251 .bStrictAllocate = false,
252 .bStrictSync = false,
255 .bDeleteReadonly = false,
256 .bFakeOplocks = false,
257 .bDeleteVetoFiles = false,
258 .bDosFilemode = false,
259 .bDosFiletimes = true,
260 .bDosFiletimeResolution = false,
261 .bFakeDirCreateTimes = false,
262 .bBlockingLocks = true,
263 .bInheritPerms = false,
264 .bInheritACLS = false,
265 .bInheritOwner = false,
267 .bUseClientDriver = false,
268 .bDefaultDevmode = true,
269 .bForcePrintername = false,
270 .bNTAclSupport = true,
271 .bForceUnknownAclUser = false,
272 .bUseSendfile = false,
273 .bProfileAcls = false,
274 .bMap_acl_inherit = false,
277 .bAclCheckPermissions = true,
278 .bAclMapFullControl = true,
279 .bAclGroupControl = false,
280 .bChangeNotify = true,
281 .bKernelChangeNotify = true,
282 .iallocation_roundup_size = SMB_ROUNDUP_ALLOCATION_SIZE,
285 .iMap_readonly = MAP_READONLY_YES,
286 #ifdef BROKEN_DIRECTORY_HANDLING
287 .iDirectoryNameCacheSize = 0,
289 .iDirectoryNameCacheSize = 100,
291 .ismb_encrypt = Auto,
296 /* local variables */
297 static struct loadparm_service **ServicePtrs = NULL;
298 static int iNumServices = 0;
299 static int iServiceIndex = 0;
300 static struct db_context *ServiceHash;
301 static int *invalid_services = NULL;
302 static int num_invalid_services = 0;
303 static bool bInGlobalSection = true;
304 static bool bGlobalOnly = false;
306 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
308 /* prototypes for the special type handlers */
309 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
310 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
311 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
312 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
313 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
314 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
315 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
316 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
317 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
318 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
319 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
320 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
322 static void set_allowed_client_auth(void);
324 static void add_to_file_list(const char *fname, const char *subfname);
325 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
327 static const struct enum_list enum_protocol[] = {
328 {PROTOCOL_SMB2, "SMB2"},
329 {PROTOCOL_NT1, "NT1"},
330 {PROTOCOL_LANMAN2, "LANMAN2"},
331 {PROTOCOL_LANMAN1, "LANMAN1"},
332 {PROTOCOL_CORE, "CORE"},
333 {PROTOCOL_COREPLUS, "COREPLUS"},
334 {PROTOCOL_COREPLUS, "CORE+"},
338 static const struct enum_list enum_security[] = {
339 {SEC_SHARE, "SHARE"},
341 {SEC_SERVER, "SERVER"},
342 {SEC_DOMAIN, "DOMAIN"},
349 static const struct enum_list enum_printing[] = {
350 {PRINT_SYSV, "sysv"},
352 {PRINT_HPUX, "hpux"},
356 {PRINT_LPRNG, "lprng"},
357 {PRINT_CUPS, "cups"},
358 {PRINT_IPRINT, "iprint"},
360 {PRINT_LPROS2, "os2"},
361 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
362 {PRINT_TEST, "test"},
364 #endif /* DEVELOPER */
368 static const struct enum_list enum_ldap_sasl_wrapping[] = {
370 {ADS_AUTH_SASL_SIGN, "sign"},
371 {ADS_AUTH_SASL_SEAL, "seal"},
375 static const struct enum_list enum_ldap_ssl[] = {
376 {LDAP_SSL_OFF, "no"},
377 {LDAP_SSL_OFF, "off"},
378 {LDAP_SSL_START_TLS, "start tls"},
379 {LDAP_SSL_START_TLS, "start_tls"},
383 /* LDAP Dereferencing Alias types */
384 #define SAMBA_LDAP_DEREF_NEVER 0
385 #define SAMBA_LDAP_DEREF_SEARCHING 1
386 #define SAMBA_LDAP_DEREF_FINDING 2
387 #define SAMBA_LDAP_DEREF_ALWAYS 3
389 static const struct enum_list enum_ldap_deref[] = {
390 {SAMBA_LDAP_DEREF_NEVER, "never"},
391 {SAMBA_LDAP_DEREF_SEARCHING, "searching"},
392 {SAMBA_LDAP_DEREF_FINDING, "finding"},
393 {SAMBA_LDAP_DEREF_ALWAYS, "always"},
397 static const struct enum_list enum_ldap_passwd_sync[] = {
398 {LDAP_PASSWD_SYNC_OFF, "no"},
399 {LDAP_PASSWD_SYNC_OFF, "off"},
400 {LDAP_PASSWD_SYNC_ON, "yes"},
401 {LDAP_PASSWD_SYNC_ON, "on"},
402 {LDAP_PASSWD_SYNC_ONLY, "only"},
406 static const struct enum_list enum_map_readonly[] = {
407 {MAP_READONLY_NO, "no"},
408 {MAP_READONLY_NO, "false"},
409 {MAP_READONLY_NO, "0"},
410 {MAP_READONLY_YES, "yes"},
411 {MAP_READONLY_YES, "true"},
412 {MAP_READONLY_YES, "1"},
413 {MAP_READONLY_PERMISSIONS, "permissions"},
414 {MAP_READONLY_PERMISSIONS, "perms"},
418 static const struct enum_list enum_case[] = {
419 {CASE_LOWER, "lower"},
420 {CASE_UPPER, "upper"},
426 static const struct enum_list enum_bool_auto[] = {
437 static const struct enum_list enum_csc_policy[] = {
438 {CSC_POLICY_MANUAL, "manual"},
439 {CSC_POLICY_DOCUMENTS, "documents"},
440 {CSC_POLICY_PROGRAMS, "programs"},
441 {CSC_POLICY_DISABLE, "disable"},
445 /* SMB signing types. */
446 static const struct enum_list enum_smb_signing_vals[] = {
458 {Required, "required"},
459 {Required, "mandatory"},
461 {Required, "forced"},
462 {Required, "enforced"},
466 /* ACL compatibility options. */
467 static const struct enum_list enum_acl_compat_vals[] = {
468 { ACL_COMPAT_AUTO, "auto" },
469 { ACL_COMPAT_WINNT, "winnt" },
470 { ACL_COMPAT_WIN2K, "win2k" },
475 Do you want session setups at user level security with a invalid
476 password to be rejected or allowed in as guest? WinNT rejects them
477 but it can be a pain as it means "net view" needs to use a password
479 You have 3 choices in the setting of map_to_guest:
481 "Never" means session setups with an invalid password
482 are rejected. This is the default.
484 "Bad User" means session setups with an invalid password
485 are rejected, unless the username does not exist, in which case it
486 is treated as a guest login
488 "Bad Password" means session setups with an invalid password
489 are treated as a guest login
491 Note that map_to_guest only has an effect in user or server
495 static const struct enum_list enum_map_to_guest[] = {
496 {NEVER_MAP_TO_GUEST, "Never"},
497 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
498 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
499 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
503 /* Config backend options */
505 static const struct enum_list enum_config_backend[] = {
506 {CONFIG_BACKEND_FILE, "file"},
507 {CONFIG_BACKEND_REGISTRY, "registry"},
511 /* ADS kerberos ticket verification options */
513 static const struct enum_list enum_kerberos_method[] = {
514 {KERBEROS_VERIFY_SECRETS, "default"},
515 {KERBEROS_VERIFY_SECRETS, "secrets only"},
516 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
517 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
518 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
522 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
524 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
525 * screen in SWAT. This is used to exclude parameters as well as to squash all
526 * parameters that have been duplicated by pseudonyms.
528 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
529 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
530 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
533 * NOTE2: Handling of duplicated (synonym) parameters:
534 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
535 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
536 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
537 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
540 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
541 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
543 static struct parm_struct parm_table[] = {
544 {N_("Base Options"), P_SEP, P_SEPARATOR},
547 .label = "dos charset",
550 .offset = GLOBAL_VAR(dos_charset),
551 .special = handle_dos_charset,
553 .flags = FLAG_ADVANCED
556 .label = "unix charset",
559 .offset = GLOBAL_VAR(unix_charset),
560 .special = handle_charset,
562 .flags = FLAG_ADVANCED
568 .offset = LOCAL_VAR(comment),
571 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
577 .offset = LOCAL_VAR(szPath),
580 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
583 .label = "directory",
586 .offset = LOCAL_VAR(szPath),
592 .label = "workgroup",
595 .offset = GLOBAL_VAR(szWorkgroup),
598 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
604 .offset = GLOBAL_VAR(szRealm),
605 .special = handle_realm,
607 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
610 .label = "netbios name",
613 .offset = GLOBAL_VAR(szNetbiosName),
616 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
619 .label = "netbios aliases",
622 .offset = GLOBAL_VAR(szNetbiosAliases),
623 .special = handle_netbios_aliases,
625 .flags = FLAG_ADVANCED,
628 .label = "netbios scope",
631 .offset = GLOBAL_VAR(szNetbiosScope),
634 .flags = FLAG_ADVANCED,
637 .label = "server string",
640 .offset = GLOBAL_VAR(szServerString),
643 .flags = FLAG_BASIC | FLAG_ADVANCED,
646 .label = "interfaces",
649 .offset = GLOBAL_VAR(szInterfaces),
652 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
655 .label = "bind interfaces only",
658 .offset = GLOBAL_VAR(bBindInterfacesOnly),
661 .flags = FLAG_ADVANCED | FLAG_WIZARD,
664 .label = "config backend",
667 .offset = GLOBAL_VAR(ConfigBackend),
669 .enum_list = enum_config_backend,
670 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
673 {N_("Security Options"), P_SEP, P_SEPARATOR},
679 .offset = GLOBAL_VAR(security),
681 .enum_list = enum_security,
682 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
685 .label = "auth methods",
688 .offset = GLOBAL_VAR(AuthMethods),
691 .flags = FLAG_ADVANCED,
694 .label = "encrypt passwords",
697 .offset = GLOBAL_VAR(bEncryptPasswords),
700 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
703 .label = "client schannel",
706 .offset = GLOBAL_VAR(clientSchannel),
708 .enum_list = enum_bool_auto,
709 .flags = FLAG_BASIC | FLAG_ADVANCED,
712 .label = "server schannel",
715 .offset = GLOBAL_VAR(serverSchannel),
717 .enum_list = enum_bool_auto,
718 .flags = FLAG_BASIC | FLAG_ADVANCED,
721 .label = "allow trusted domains",
724 .offset = GLOBAL_VAR(bAllowTrustedDomains),
727 .flags = FLAG_ADVANCED,
730 .label = "map to guest",
733 .offset = GLOBAL_VAR(map_to_guest),
735 .enum_list = enum_map_to_guest,
736 .flags = FLAG_ADVANCED,
739 .label = "null passwords",
742 .offset = GLOBAL_VAR(bNullPasswords),
745 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
748 .label = "obey pam restrictions",
751 .offset = GLOBAL_VAR(bObeyPamRestrictions),
754 .flags = FLAG_ADVANCED,
757 .label = "password server",
760 .offset = GLOBAL_VAR(szPasswordServer),
763 .flags = FLAG_ADVANCED | FLAG_WIZARD,
766 .label = "smb passwd file",
769 .offset = GLOBAL_VAR(szSMBPasswdFile),
772 .flags = FLAG_ADVANCED,
775 .label = "private dir",
778 .offset = GLOBAL_VAR(szPrivateDir),
781 .flags = FLAG_ADVANCED,
784 .label = "passdb backend",
787 .offset = GLOBAL_VAR(szPassdbBackend),
790 .flags = FLAG_ADVANCED | FLAG_WIZARD,
793 .label = "algorithmic rid base",
796 .offset = GLOBAL_VAR(AlgorithmicRidBase),
799 .flags = FLAG_ADVANCED,
802 .label = "root directory",
805 .offset = GLOBAL_VAR(szRootdir),
808 .flags = FLAG_ADVANCED,
814 .offset = GLOBAL_VAR(szRootdir),
823 .offset = GLOBAL_VAR(szRootdir),
829 .label = "guest account",
832 .offset = GLOBAL_VAR(szGuestaccount),
835 .flags = FLAG_BASIC | FLAG_ADVANCED,
838 .label = "enable privileges",
841 .offset = GLOBAL_VAR(bEnablePrivileges),
844 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
848 .label = "pam password change",
851 .offset = GLOBAL_VAR(bPamPasswordChange),
854 .flags = FLAG_ADVANCED,
857 .label = "passwd program",
860 .offset = GLOBAL_VAR(szPasswdProgram),
863 .flags = FLAG_ADVANCED,
866 .label = "passwd chat",
869 .offset = GLOBAL_VAR(szPasswdChat),
872 .flags = FLAG_ADVANCED,
875 .label = "passwd chat debug",
878 .offset = GLOBAL_VAR(bPasswdChatDebug),
881 .flags = FLAG_ADVANCED,
884 .label = "passwd chat timeout",
887 .offset = GLOBAL_VAR(iPasswdChatTimeout),
890 .flags = FLAG_ADVANCED,
893 .label = "check password script",
896 .offset = GLOBAL_VAR(szCheckPasswordScript),
899 .flags = FLAG_ADVANCED,
902 .label = "username map",
905 .offset = GLOBAL_VAR(szUsernameMap),
908 .flags = FLAG_ADVANCED,
911 .label = "password level",
914 .offset = GLOBAL_VAR(pwordlevel),
917 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
920 .label = "username level",
923 .offset = GLOBAL_VAR(unamelevel),
926 .flags = FLAG_ADVANCED,
929 .label = "unix password sync",
932 .offset = GLOBAL_VAR(bUnixPasswdSync),
935 .flags = FLAG_ADVANCED,
938 .label = "restrict anonymous",
941 .offset = GLOBAL_VAR(restrict_anonymous),
944 .flags = FLAG_ADVANCED,
947 .label = "lanman auth",
950 .offset = GLOBAL_VAR(bLanmanAuth),
953 .flags = FLAG_ADVANCED,
956 .label = "ntlm auth",
959 .offset = GLOBAL_VAR(bNTLMAuth),
962 .flags = FLAG_ADVANCED,
965 .label = "client NTLMv2 auth",
968 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
971 .flags = FLAG_ADVANCED,
974 .label = "client lanman auth",
977 .offset = GLOBAL_VAR(bClientLanManAuth),
980 .flags = FLAG_ADVANCED,
983 .label = "client plaintext auth",
986 .offset = GLOBAL_VAR(bClientPlaintextAuth),
989 .flags = FLAG_ADVANCED,
992 .label = "client use spnego principal",
995 .offset = GLOBAL_VAR(client_use_spnego_principal),
998 .flags = FLAG_ADVANCED,
1001 .label = "send spnego principal",
1003 .p_class = P_GLOBAL,
1004 .offset = GLOBAL_VAR(send_spnego_principal),
1007 .flags = FLAG_ADVANCED,
1010 .label = "username",
1013 .offset = LOCAL_VAR(szUsername),
1016 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
1022 .offset = LOCAL_VAR(szUsername),
1031 .offset = LOCAL_VAR(szUsername),
1037 .label = "invalid users",
1040 .offset = LOCAL_VAR(szInvalidUsers),
1043 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1046 .label = "valid users",
1049 .offset = LOCAL_VAR(szValidUsers),
1052 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1055 .label = "admin users",
1058 .offset = LOCAL_VAR(szAdminUsers),
1061 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1064 .label = "read list",
1067 .offset = LOCAL_VAR(readlist),
1070 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1073 .label = "write list",
1076 .offset = LOCAL_VAR(writelist),
1079 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1082 .label = "printer admin",
1085 .offset = LOCAL_VAR(printer_admin),
1088 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1091 .label = "force user",
1094 .offset = LOCAL_VAR(force_user),
1097 .flags = FLAG_ADVANCED | FLAG_SHARE,
1100 .label = "force group",
1103 .offset = LOCAL_VAR(force_group),
1106 .flags = FLAG_ADVANCED | FLAG_SHARE,
1112 .offset = LOCAL_VAR(force_group),
1115 .flags = FLAG_ADVANCED,
1118 .label = "read only",
1121 .offset = LOCAL_VAR(bRead_only),
1124 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1127 .label = "write ok",
1130 .offset = LOCAL_VAR(bRead_only),
1136 .label = "writeable",
1139 .offset = LOCAL_VAR(bRead_only),
1145 .label = "writable",
1148 .offset = LOCAL_VAR(bRead_only),
1154 .label = "acl check permissions",
1157 .offset = LOCAL_VAR(bAclCheckPermissions),
1160 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1163 .label = "acl group control",
1166 .offset = LOCAL_VAR(bAclGroupControl),
1169 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1172 .label = "acl map full control",
1175 .offset = LOCAL_VAR(bAclMapFullControl),
1178 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1181 .label = "create mask",
1184 .offset = LOCAL_VAR(iCreate_mask),
1187 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1190 .label = "create mode",
1193 .offset = LOCAL_VAR(iCreate_mask),
1199 .label = "force create mode",
1202 .offset = LOCAL_VAR(iCreate_force_mode),
1205 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1208 .label = "security mask",
1211 .offset = LOCAL_VAR(iSecurity_mask),
1214 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1217 .label = "force security mode",
1220 .offset = LOCAL_VAR(iSecurity_force_mode),
1223 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1226 .label = "directory mask",
1229 .offset = LOCAL_VAR(iDir_mask),
1232 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1235 .label = "directory mode",
1238 .offset = LOCAL_VAR(iDir_mask),
1241 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1244 .label = "force directory mode",
1247 .offset = LOCAL_VAR(iDir_force_mode),
1250 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1253 .label = "directory security mask",
1256 .offset = LOCAL_VAR(iDir_Security_mask),
1259 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1262 .label = "force directory security mode",
1265 .offset = LOCAL_VAR(iDir_Security_force_mode),
1268 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1271 .label = "force unknown acl user",
1274 .offset = LOCAL_VAR(bForceUnknownAclUser),
1277 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1280 .label = "inherit permissions",
1283 .offset = LOCAL_VAR(bInheritPerms),
1286 .flags = FLAG_ADVANCED | FLAG_SHARE,
1289 .label = "inherit acls",
1292 .offset = LOCAL_VAR(bInheritACLS),
1295 .flags = FLAG_ADVANCED | FLAG_SHARE,
1298 .label = "inherit owner",
1301 .offset = LOCAL_VAR(bInheritOwner),
1304 .flags = FLAG_ADVANCED | FLAG_SHARE,
1307 .label = "guest only",
1310 .offset = LOCAL_VAR(bGuest_only),
1313 .flags = FLAG_ADVANCED | FLAG_SHARE,
1316 .label = "only guest",
1319 .offset = LOCAL_VAR(bGuest_only),
1325 .label = "administrative share",
1328 .offset = LOCAL_VAR(bAdministrative_share),
1331 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1335 .label = "guest ok",
1338 .offset = LOCAL_VAR(bGuest_ok),
1341 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1347 .offset = LOCAL_VAR(bGuest_ok),
1353 .label = "only user",
1356 .offset = LOCAL_VAR(bOnlyUser),
1359 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1362 .label = "hosts allow",
1365 .offset = LOCAL_VAR(szHostsallow),
1368 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1371 .label = "allow hosts",
1374 .offset = LOCAL_VAR(szHostsallow),
1380 .label = "hosts deny",
1383 .offset = LOCAL_VAR(szHostsdeny),
1386 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1389 .label = "deny hosts",
1392 .offset = LOCAL_VAR(szHostsdeny),
1398 .label = "preload modules",
1400 .p_class = P_GLOBAL,
1401 .offset = GLOBAL_VAR(szPreloadModules),
1404 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1407 .label = "dedicated keytab file",
1409 .p_class = P_GLOBAL,
1410 .offset = GLOBAL_VAR(szDedicatedKeytabFile),
1413 .flags = FLAG_ADVANCED,
1416 .label = "kerberos method",
1418 .p_class = P_GLOBAL,
1419 .offset = GLOBAL_VAR(iKerberosMethod),
1421 .enum_list = enum_kerberos_method,
1422 .flags = FLAG_ADVANCED,
1425 .label = "map untrusted to domain",
1427 .p_class = P_GLOBAL,
1428 .offset = GLOBAL_VAR(bMapUntrustedToDomain),
1431 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1435 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1438 .label = "log level",
1440 .p_class = P_GLOBAL,
1441 .offset = GLOBAL_VAR(szLogLevel),
1442 .special = handle_debug_list,
1444 .flags = FLAG_ADVANCED,
1447 .label = "debuglevel",
1449 .p_class = P_GLOBAL,
1450 .offset = GLOBAL_VAR(szLogLevel),
1451 .special = handle_debug_list,
1458 .p_class = P_GLOBAL,
1459 .offset = GLOBAL_VAR(syslog),
1462 .flags = FLAG_ADVANCED,
1465 .label = "syslog only",
1467 .p_class = P_GLOBAL,
1468 .offset = GLOBAL_VAR(bSyslogOnly),
1471 .flags = FLAG_ADVANCED,
1474 .label = "log file",
1476 .p_class = P_GLOBAL,
1477 .offset = GLOBAL_VAR(szLogFile),
1480 .flags = FLAG_ADVANCED,
1483 .label = "max log size",
1485 .p_class = P_GLOBAL,
1486 .offset = GLOBAL_VAR(max_log_size),
1489 .flags = FLAG_ADVANCED,
1492 .label = "debug timestamp",
1494 .p_class = P_GLOBAL,
1495 .offset = GLOBAL_VAR(bTimestampLogs),
1498 .flags = FLAG_ADVANCED,
1501 .label = "timestamp logs",
1503 .p_class = P_GLOBAL,
1504 .offset = GLOBAL_VAR(bTimestampLogs),
1507 .flags = FLAG_ADVANCED,
1510 .label = "debug prefix timestamp",
1512 .p_class = P_GLOBAL,
1513 .offset = GLOBAL_VAR(bDebugPrefixTimestamp),
1516 .flags = FLAG_ADVANCED,
1519 .label = "debug hires timestamp",
1521 .p_class = P_GLOBAL,
1522 .offset = GLOBAL_VAR(bDebugHiresTimestamp),
1525 .flags = FLAG_ADVANCED,
1528 .label = "debug pid",
1530 .p_class = P_GLOBAL,
1531 .offset = GLOBAL_VAR(bDebugPid),
1534 .flags = FLAG_ADVANCED,
1537 .label = "debug uid",
1539 .p_class = P_GLOBAL,
1540 .offset = GLOBAL_VAR(bDebugUid),
1543 .flags = FLAG_ADVANCED,
1546 .label = "debug class",
1548 .p_class = P_GLOBAL,
1549 .offset = GLOBAL_VAR(bDebugClass),
1552 .flags = FLAG_ADVANCED,
1555 .label = "enable core files",
1557 .p_class = P_GLOBAL,
1558 .offset = GLOBAL_VAR(bEnableCoreFiles),
1561 .flags = FLAG_ADVANCED,
1564 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1567 .label = "allocation roundup size",
1570 .offset = LOCAL_VAR(iallocation_roundup_size),
1573 .flags = FLAG_ADVANCED,
1576 .label = "aio read size",
1579 .offset = LOCAL_VAR(iAioReadSize),
1582 .flags = FLAG_ADVANCED,
1585 .label = "aio write size",
1588 .offset = LOCAL_VAR(iAioWriteSize),
1591 .flags = FLAG_ADVANCED,
1594 .label = "aio write behind",
1597 .offset = LOCAL_VAR(szAioWriteBehind),
1600 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1603 .label = "smb ports",
1605 .p_class = P_GLOBAL,
1606 .offset = GLOBAL_VAR(smb_ports),
1609 .flags = FLAG_ADVANCED,
1612 .label = "large readwrite",
1614 .p_class = P_GLOBAL,
1615 .offset = GLOBAL_VAR(bLargeReadwrite),
1618 .flags = FLAG_ADVANCED,
1621 .label = "max protocol",
1623 .p_class = P_GLOBAL,
1624 .offset = GLOBAL_VAR(maxprotocol),
1626 .enum_list = enum_protocol,
1627 .flags = FLAG_ADVANCED,
1630 .label = "protocol",
1632 .p_class = P_GLOBAL,
1633 .offset = GLOBAL_VAR(maxprotocol),
1635 .enum_list = enum_protocol,
1636 .flags = FLAG_ADVANCED,
1639 .label = "min protocol",
1641 .p_class = P_GLOBAL,
1642 .offset = GLOBAL_VAR(minprotocol),
1644 .enum_list = enum_protocol,
1645 .flags = FLAG_ADVANCED,
1648 .label = "min receivefile size",
1650 .p_class = P_GLOBAL,
1651 .offset = GLOBAL_VAR(iminreceivefile),
1654 .flags = FLAG_ADVANCED,
1657 .label = "read raw",
1659 .p_class = P_GLOBAL,
1660 .offset = GLOBAL_VAR(bReadRaw),
1663 .flags = FLAG_ADVANCED,
1666 .label = "write raw",
1668 .p_class = P_GLOBAL,
1669 .offset = GLOBAL_VAR(bWriteRaw),
1672 .flags = FLAG_ADVANCED,
1675 .label = "disable netbios",
1677 .p_class = P_GLOBAL,
1678 .offset = GLOBAL_VAR(bDisableNetbios),
1681 .flags = FLAG_ADVANCED,
1684 .label = "reset on zero vc",
1686 .p_class = P_GLOBAL,
1687 .offset = GLOBAL_VAR(bResetOnZeroVC),
1690 .flags = FLAG_ADVANCED,
1693 .label = "log writeable files on exit",
1695 .p_class = P_GLOBAL,
1696 .offset = GLOBAL_VAR(bLogWriteableFilesOnExit),
1699 .flags = FLAG_ADVANCED,
1702 .label = "acl compatibility",
1704 .p_class = P_GLOBAL,
1705 .offset = GLOBAL_VAR(iAclCompat),
1707 .enum_list = enum_acl_compat_vals,
1708 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1711 .label = "defer sharing violations",
1713 .p_class = P_GLOBAL,
1714 .offset = GLOBAL_VAR(bDeferSharingViolations),
1717 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1720 .label = "ea support",
1723 .offset = LOCAL_VAR(bEASupport),
1726 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1729 .label = "nt acl support",
1732 .offset = LOCAL_VAR(bNTAclSupport),
1735 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1738 .label = "nt pipe support",
1740 .p_class = P_GLOBAL,
1741 .offset = GLOBAL_VAR(bNTPipeSupport),
1744 .flags = FLAG_ADVANCED,
1747 .label = "nt status support",
1749 .p_class = P_GLOBAL,
1750 .offset = GLOBAL_VAR(bNTStatusSupport),
1753 .flags = FLAG_ADVANCED,
1756 .label = "profile acls",
1759 .offset = LOCAL_VAR(bProfileAcls),
1762 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1765 .label = "map acl inherit",
1768 .offset = LOCAL_VAR(bMap_acl_inherit),
1771 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1774 .label = "afs share",
1777 .offset = LOCAL_VAR(bAfs_Share),
1780 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1785 .p_class = P_GLOBAL,
1786 .offset = GLOBAL_VAR(max_mux),
1789 .flags = FLAG_ADVANCED,
1792 .label = "max xmit",
1794 .p_class = P_GLOBAL,
1795 .offset = GLOBAL_VAR(max_xmit),
1798 .flags = FLAG_ADVANCED,
1801 .label = "name resolve order",
1803 .p_class = P_GLOBAL,
1804 .offset = GLOBAL_VAR(szNameResolveOrder),
1807 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1812 .p_class = P_GLOBAL,
1813 .offset = GLOBAL_VAR(max_ttl),
1816 .flags = FLAG_ADVANCED,
1819 .label = "max wins ttl",
1821 .p_class = P_GLOBAL,
1822 .offset = GLOBAL_VAR(max_wins_ttl),
1825 .flags = FLAG_ADVANCED,
1828 .label = "min wins ttl",
1830 .p_class = P_GLOBAL,
1831 .offset = GLOBAL_VAR(min_wins_ttl),
1834 .flags = FLAG_ADVANCED,
1837 .label = "time server",
1839 .p_class = P_GLOBAL,
1840 .offset = GLOBAL_VAR(bTimeServer),
1843 .flags = FLAG_ADVANCED,
1846 .label = "unix extensions",
1848 .p_class = P_GLOBAL,
1849 .offset = GLOBAL_VAR(bUnixExtensions),
1852 .flags = FLAG_ADVANCED,
1855 .label = "use spnego",
1857 .p_class = P_GLOBAL,
1858 .offset = GLOBAL_VAR(bUseSpnego),
1861 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
1864 .label = "client signing",
1866 .p_class = P_GLOBAL,
1867 .offset = GLOBAL_VAR(client_signing),
1869 .enum_list = enum_smb_signing_vals,
1870 .flags = FLAG_ADVANCED,
1873 .label = "server signing",
1875 .p_class = P_GLOBAL,
1876 .offset = GLOBAL_VAR(server_signing),
1878 .enum_list = enum_smb_signing_vals,
1879 .flags = FLAG_ADVANCED,
1882 .label = "smb encrypt",
1885 .offset = LOCAL_VAR(ismb_encrypt),
1887 .enum_list = enum_smb_signing_vals,
1888 .flags = FLAG_ADVANCED,
1891 .label = "client use spnego",
1893 .p_class = P_GLOBAL,
1894 .offset = GLOBAL_VAR(bClientUseSpnego),
1897 .flags = FLAG_ADVANCED,
1900 .label = "client ldap sasl wrapping",
1902 .p_class = P_GLOBAL,
1903 .offset = GLOBAL_VAR(client_ldap_sasl_wrapping),
1905 .enum_list = enum_ldap_sasl_wrapping,
1906 .flags = FLAG_ADVANCED,
1909 .label = "enable asu support",
1911 .p_class = P_GLOBAL,
1912 .offset = GLOBAL_VAR(bASUSupport),
1915 .flags = FLAG_ADVANCED,
1918 .label = "svcctl list",
1920 .p_class = P_GLOBAL,
1921 .offset = GLOBAL_VAR(szServicesList),
1924 .flags = FLAG_ADVANCED,
1927 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
1930 .label = "block size",
1933 .offset = LOCAL_VAR(iBlock_size),
1936 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1939 .label = "deadtime",
1941 .p_class = P_GLOBAL,
1942 .offset = GLOBAL_VAR(deadtime),
1945 .flags = FLAG_ADVANCED,
1948 .label = "getwd cache",
1950 .p_class = P_GLOBAL,
1951 .offset = GLOBAL_VAR(getwd_cache),
1954 .flags = FLAG_ADVANCED,
1957 .label = "keepalive",
1959 .p_class = P_GLOBAL,
1960 .offset = GLOBAL_VAR(iKeepalive),
1963 .flags = FLAG_ADVANCED,
1966 .label = "change notify",
1969 .offset = LOCAL_VAR(bChangeNotify),
1972 .flags = FLAG_ADVANCED | FLAG_SHARE,
1975 .label = "directory name cache size",
1978 .offset = LOCAL_VAR(iDirectoryNameCacheSize),
1981 .flags = FLAG_ADVANCED | FLAG_SHARE,
1984 .label = "kernel change notify",
1987 .offset = LOCAL_VAR(bKernelChangeNotify),
1990 .flags = FLAG_ADVANCED | FLAG_SHARE,
1993 .label = "lpq cache time",
1995 .p_class = P_GLOBAL,
1996 .offset = GLOBAL_VAR(lpqcachetime),
1999 .flags = FLAG_ADVANCED,
2002 .label = "max smbd processes",
2004 .p_class = P_GLOBAL,
2005 .offset = GLOBAL_VAR(iMaxSmbdProcesses),
2008 .flags = FLAG_ADVANCED,
2011 .label = "max connections",
2014 .offset = LOCAL_VAR(iMaxConnections),
2017 .flags = FLAG_ADVANCED | FLAG_SHARE,
2020 .label = "paranoid server security",
2022 .p_class = P_GLOBAL,
2023 .offset = GLOBAL_VAR(paranoid_server_security),
2026 .flags = FLAG_ADVANCED,
2029 .label = "max disk size",
2031 .p_class = P_GLOBAL,
2032 .offset = GLOBAL_VAR(maxdisksize),
2035 .flags = FLAG_ADVANCED,
2038 .label = "max open files",
2040 .p_class = P_GLOBAL,
2041 .offset = GLOBAL_VAR(max_open_files),
2044 .flags = FLAG_ADVANCED,
2047 .label = "min print space",
2050 .offset = LOCAL_VAR(iMinPrintSpace),
2053 .flags = FLAG_ADVANCED | FLAG_PRINT,
2056 .label = "socket options",
2058 .p_class = P_GLOBAL,
2059 .offset = GLOBAL_VAR(szSocketOptions),
2062 .flags = FLAG_ADVANCED,
2065 .label = "strict allocate",
2068 .offset = LOCAL_VAR(bStrictAllocate),
2071 .flags = FLAG_ADVANCED | FLAG_SHARE,
2074 .label = "strict sync",
2077 .offset = LOCAL_VAR(bStrictSync),
2080 .flags = FLAG_ADVANCED | FLAG_SHARE,
2083 .label = "sync always",
2086 .offset = LOCAL_VAR(bSyncAlways),
2089 .flags = FLAG_ADVANCED | FLAG_SHARE,
2092 .label = "use mmap",
2094 .p_class = P_GLOBAL,
2095 .offset = GLOBAL_VAR(bUseMmap),
2098 .flags = FLAG_ADVANCED,
2101 .label = "use sendfile",
2104 .offset = LOCAL_VAR(bUseSendfile),
2107 .flags = FLAG_ADVANCED | FLAG_SHARE,
2110 .label = "hostname lookups",
2112 .p_class = P_GLOBAL,
2113 .offset = GLOBAL_VAR(bHostnameLookups),
2116 .flags = FLAG_ADVANCED,
2119 .label = "write cache size",
2122 .offset = LOCAL_VAR(iWriteCacheSize),
2125 .flags = FLAG_ADVANCED | FLAG_SHARE,
2128 .label = "name cache timeout",
2130 .p_class = P_GLOBAL,
2131 .offset = GLOBAL_VAR(name_cache_timeout),
2134 .flags = FLAG_ADVANCED,
2137 .label = "ctdbd socket",
2139 .p_class = P_GLOBAL,
2140 .offset = GLOBAL_VAR(ctdbdSocket),
2143 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2146 .label = "cluster addresses",
2148 .p_class = P_GLOBAL,
2149 .offset = GLOBAL_VAR(szClusterAddresses),
2152 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2155 .label = "clustering",
2157 .p_class = P_GLOBAL,
2158 .offset = GLOBAL_VAR(clustering),
2161 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2164 .label = "ctdb timeout",
2166 .p_class = P_GLOBAL,
2167 .offset = GLOBAL_VAR(ctdb_timeout),
2170 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2173 .label = "ctdb locktime warn threshold",
2175 .p_class = P_GLOBAL,
2176 .offset = GLOBAL_VAR(ctdb_locktime_warn_threshold),
2179 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2182 .label = "smb2 max read",
2184 .p_class = P_GLOBAL,
2185 .offset = GLOBAL_VAR(ismb2_max_read),
2188 .flags = FLAG_ADVANCED,
2191 .label = "smb2 max write",
2193 .p_class = P_GLOBAL,
2194 .offset = GLOBAL_VAR(ismb2_max_write),
2197 .flags = FLAG_ADVANCED,
2200 .label = "smb2 max trans",
2202 .p_class = P_GLOBAL,
2203 .offset = GLOBAL_VAR(ismb2_max_trans),
2206 .flags = FLAG_ADVANCED,
2209 .label = "smb2 max credits",
2211 .p_class = P_GLOBAL,
2212 .offset = GLOBAL_VAR(ismb2_max_credits),
2215 .flags = FLAG_ADVANCED,
2218 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2221 .label = "max reported print jobs",
2224 .offset = LOCAL_VAR(iMaxReportedPrintJobs),
2227 .flags = FLAG_ADVANCED | FLAG_PRINT,
2230 .label = "max print jobs",
2233 .offset = LOCAL_VAR(iMaxPrintJobs),
2236 .flags = FLAG_ADVANCED | FLAG_PRINT,
2239 .label = "load printers",
2241 .p_class = P_GLOBAL,
2242 .offset = GLOBAL_VAR(bLoadPrinters),
2245 .flags = FLAG_ADVANCED | FLAG_PRINT,
2248 .label = "printcap cache time",
2250 .p_class = P_GLOBAL,
2251 .offset = GLOBAL_VAR(PrintcapCacheTime),
2254 .flags = FLAG_ADVANCED | FLAG_PRINT,
2257 .label = "printcap name",
2259 .p_class = P_GLOBAL,
2260 .offset = GLOBAL_VAR(szPrintcapname),
2263 .flags = FLAG_ADVANCED | FLAG_PRINT,
2266 .label = "printcap",
2268 .p_class = P_GLOBAL,
2269 .offset = GLOBAL_VAR(szPrintcapname),
2275 .label = "printable",
2278 .offset = LOCAL_VAR(bPrint_ok),
2281 .flags = FLAG_ADVANCED | FLAG_PRINT,
2284 .label = "print notify backchannel",
2287 .offset = LOCAL_VAR(bPrintNotifyBackchannel),
2290 .flags = FLAG_ADVANCED,
2293 .label = "print ok",
2296 .offset = LOCAL_VAR(bPrint_ok),
2302 .label = "printing",
2305 .offset = LOCAL_VAR(iPrinting),
2306 .special = handle_printing,
2307 .enum_list = enum_printing,
2308 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2311 .label = "cups options",
2314 .offset = LOCAL_VAR(szCupsOptions),
2317 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2320 .label = "cups server",
2322 .p_class = P_GLOBAL,
2323 .offset = GLOBAL_VAR(szCupsServer),
2326 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2329 .label = "cups encrypt",
2331 .p_class = P_GLOBAL,
2332 .offset = GLOBAL_VAR(CupsEncrypt),
2334 .enum_list = enum_bool_auto,
2335 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2339 .label = "cups connection timeout",
2341 .p_class = P_GLOBAL,
2342 .offset = GLOBAL_VAR(cups_connection_timeout),
2345 .flags = FLAG_ADVANCED,
2348 .label = "iprint server",
2350 .p_class = P_GLOBAL,
2351 .offset = GLOBAL_VAR(szIPrintServer),
2354 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2357 .label = "print command",
2360 .offset = LOCAL_VAR(szPrintcommand),
2363 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2366 .label = "disable spoolss",
2368 .p_class = P_GLOBAL,
2369 .offset = GLOBAL_VAR(bDisableSpoolss),
2372 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2375 .label = "enable spoolss",
2377 .p_class = P_GLOBAL,
2378 .offset = GLOBAL_VAR(bDisableSpoolss),
2384 .label = "lpq command",
2387 .offset = LOCAL_VAR(szLpqcommand),
2390 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2393 .label = "lprm command",
2396 .offset = LOCAL_VAR(szLprmcommand),
2399 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2402 .label = "lppause command",
2405 .offset = LOCAL_VAR(szLppausecommand),
2408 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2411 .label = "lpresume command",
2414 .offset = LOCAL_VAR(szLpresumecommand),
2417 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2420 .label = "queuepause command",
2423 .offset = LOCAL_VAR(szQueuepausecommand),
2426 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2429 .label = "queueresume command",
2432 .offset = LOCAL_VAR(szQueueresumecommand),
2435 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2438 .label = "addport command",
2440 .p_class = P_GLOBAL,
2441 .offset = GLOBAL_VAR(szAddPortCommand),
2444 .flags = FLAG_ADVANCED,
2447 .label = "enumports command",
2449 .p_class = P_GLOBAL,
2450 .offset = GLOBAL_VAR(szEnumPortsCommand),
2453 .flags = FLAG_ADVANCED,
2456 .label = "addprinter command",
2458 .p_class = P_GLOBAL,
2459 .offset = GLOBAL_VAR(szAddPrinterCommand),
2462 .flags = FLAG_ADVANCED,
2465 .label = "deleteprinter command",
2467 .p_class = P_GLOBAL,
2468 .offset = GLOBAL_VAR(szDeletePrinterCommand),
2471 .flags = FLAG_ADVANCED,
2474 .label = "show add printer wizard",
2476 .p_class = P_GLOBAL,
2477 .offset = GLOBAL_VAR(bMsAddPrinterWizard),
2480 .flags = FLAG_ADVANCED,
2483 .label = "os2 driver map",
2485 .p_class = P_GLOBAL,
2486 .offset = GLOBAL_VAR(szOs2DriverMap),
2489 .flags = FLAG_ADVANCED,
2493 .label = "printer name",
2496 .offset = LOCAL_VAR(szPrintername),
2499 .flags = FLAG_ADVANCED | FLAG_PRINT,
2505 .offset = LOCAL_VAR(szPrintername),
2511 .label = "use client driver",
2514 .offset = LOCAL_VAR(bUseClientDriver),
2517 .flags = FLAG_ADVANCED | FLAG_PRINT,
2520 .label = "default devmode",
2523 .offset = LOCAL_VAR(bDefaultDevmode),
2526 .flags = FLAG_ADVANCED | FLAG_PRINT,
2529 .label = "force printername",
2532 .offset = LOCAL_VAR(bForcePrintername),
2535 .flags = FLAG_ADVANCED | FLAG_PRINT,
2538 .label = "printjob username",
2541 .offset = LOCAL_VAR(szPrintjobUsername),
2544 .flags = FLAG_ADVANCED | FLAG_PRINT,
2547 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2550 .label = "mangling method",
2552 .p_class = P_GLOBAL,
2553 .offset = GLOBAL_VAR(szManglingMethod),
2556 .flags = FLAG_ADVANCED,
2559 .label = "mangle prefix",
2561 .p_class = P_GLOBAL,
2562 .offset = GLOBAL_VAR(mangle_prefix),
2565 .flags = FLAG_ADVANCED,
2569 .label = "default case",
2572 .offset = LOCAL_VAR(iDefaultCase),
2574 .enum_list = enum_case,
2575 .flags = FLAG_ADVANCED | FLAG_SHARE,
2578 .label = "case sensitive",
2581 .offset = LOCAL_VAR(iCaseSensitive),
2583 .enum_list = enum_bool_auto,
2584 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2587 .label = "casesignames",
2590 .offset = LOCAL_VAR(iCaseSensitive),
2592 .enum_list = enum_bool_auto,
2593 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2596 .label = "preserve case",
2599 .offset = LOCAL_VAR(bCasePreserve),
2602 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2605 .label = "short preserve case",
2608 .offset = LOCAL_VAR(bShortCasePreserve),
2611 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2614 .label = "mangling char",
2617 .offset = LOCAL_VAR(magic_char),
2620 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2623 .label = "hide dot files",
2626 .offset = LOCAL_VAR(bHideDotFiles),
2629 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2632 .label = "hide special files",
2635 .offset = LOCAL_VAR(bHideSpecialFiles),
2638 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2641 .label = "hide unreadable",
2644 .offset = LOCAL_VAR(bHideUnReadable),
2647 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2650 .label = "hide unwriteable files",
2653 .offset = LOCAL_VAR(bHideUnWriteableFiles),
2656 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2659 .label = "delete veto files",
2662 .offset = LOCAL_VAR(bDeleteVetoFiles),
2665 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2668 .label = "veto files",
2671 .offset = LOCAL_VAR(szVetoFiles),
2674 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2677 .label = "hide files",
2680 .offset = LOCAL_VAR(szHideFiles),
2683 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2686 .label = "veto oplock files",
2689 .offset = LOCAL_VAR(szVetoOplockFiles),
2692 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2695 .label = "map archive",
2698 .offset = LOCAL_VAR(bMap_archive),
2701 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2704 .label = "map hidden",
2707 .offset = LOCAL_VAR(bMap_hidden),
2710 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2713 .label = "map system",
2716 .offset = LOCAL_VAR(bMap_system),
2719 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2722 .label = "map readonly",
2725 .offset = LOCAL_VAR(iMap_readonly),
2727 .enum_list = enum_map_readonly,
2728 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2731 .label = "mangled names",
2734 .offset = LOCAL_VAR(bMangledNames),
2737 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2740 .label = "max stat cache size",
2742 .p_class = P_GLOBAL,
2743 .offset = GLOBAL_VAR(iMaxStatCacheSize),
2746 .flags = FLAG_ADVANCED,
2749 .label = "stat cache",
2751 .p_class = P_GLOBAL,
2752 .offset = GLOBAL_VAR(bStatCache),
2755 .flags = FLAG_ADVANCED,
2758 .label = "store dos attributes",
2761 .offset = LOCAL_VAR(bStoreDosAttributes),
2764 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2767 .label = "dmapi support",
2770 .offset = LOCAL_VAR(bDmapiSupport),
2773 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2777 {N_("Domain Options"), P_SEP, P_SEPARATOR},
2780 .label = "machine password timeout",
2782 .p_class = P_GLOBAL,
2783 .offset = GLOBAL_VAR(machine_password_timeout),
2786 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2789 {N_("Logon Options"), P_SEP, P_SEPARATOR},
2792 .label = "add user script",
2794 .p_class = P_GLOBAL,
2795 .offset = GLOBAL_VAR(szAddUserScript),
2798 .flags = FLAG_ADVANCED,
2801 .label = "rename user script",
2803 .p_class = P_GLOBAL,
2804 .offset = GLOBAL_VAR(szRenameUserScript),
2807 .flags = FLAG_ADVANCED,
2810 .label = "delete user script",
2812 .p_class = P_GLOBAL,
2813 .offset = GLOBAL_VAR(szDelUserScript),
2816 .flags = FLAG_ADVANCED,
2819 .label = "add group script",
2821 .p_class = P_GLOBAL,
2822 .offset = GLOBAL_VAR(szAddGroupScript),
2825 .flags = FLAG_ADVANCED,
2828 .label = "delete group script",
2830 .p_class = P_GLOBAL,
2831 .offset = GLOBAL_VAR(szDelGroupScript),
2834 .flags = FLAG_ADVANCED,
2837 .label = "add user to group script",
2839 .p_class = P_GLOBAL,
2840 .offset = GLOBAL_VAR(szAddUserToGroupScript),
2843 .flags = FLAG_ADVANCED,
2846 .label = "delete user from group script",
2848 .p_class = P_GLOBAL,
2849 .offset = GLOBAL_VAR(szDelUserFromGroupScript),
2852 .flags = FLAG_ADVANCED,
2855 .label = "set primary group script",
2857 .p_class = P_GLOBAL,
2858 .offset = GLOBAL_VAR(szSetPrimaryGroupScript),
2861 .flags = FLAG_ADVANCED,
2864 .label = "add machine script",
2866 .p_class = P_GLOBAL,
2867 .offset = GLOBAL_VAR(szAddMachineScript),
2870 .flags = FLAG_ADVANCED,
2873 .label = "shutdown script",
2875 .p_class = P_GLOBAL,
2876 .offset = GLOBAL_VAR(szShutdownScript),
2879 .flags = FLAG_ADVANCED,
2882 .label = "abort shutdown script",
2884 .p_class = P_GLOBAL,
2885 .offset = GLOBAL_VAR(szAbortShutdownScript),
2888 .flags = FLAG_ADVANCED,
2891 .label = "username map script",
2893 .p_class = P_GLOBAL,
2894 .offset = GLOBAL_VAR(szUsernameMapScript),
2897 .flags = FLAG_ADVANCED,
2900 .label = "username map cache time",
2902 .p_class = P_GLOBAL,
2903 .offset = GLOBAL_VAR(iUsernameMapCacheTime),
2906 .flags = FLAG_ADVANCED,
2909 .label = "logon script",
2911 .p_class = P_GLOBAL,
2912 .offset = GLOBAL_VAR(szLogonScript),
2915 .flags = FLAG_ADVANCED,
2918 .label = "logon path",
2920 .p_class = P_GLOBAL,
2921 .offset = GLOBAL_VAR(szLogonPath),
2924 .flags = FLAG_ADVANCED,
2927 .label = "logon drive",
2929 .p_class = P_GLOBAL,
2930 .offset = GLOBAL_VAR(szLogonDrive),
2933 .flags = FLAG_ADVANCED,
2936 .label = "logon home",
2938 .p_class = P_GLOBAL,
2939 .offset = GLOBAL_VAR(szLogonHome),
2942 .flags = FLAG_ADVANCED,
2945 .label = "domain logons",
2947 .p_class = P_GLOBAL,
2948 .offset = GLOBAL_VAR(bDomainLogons),
2951 .flags = FLAG_ADVANCED,
2955 .label = "init logon delayed hosts",
2957 .p_class = P_GLOBAL,
2958 .offset = GLOBAL_VAR(szInitLogonDelayedHosts),
2961 .flags = FLAG_ADVANCED,
2965 .label = "init logon delay",
2967 .p_class = P_GLOBAL,
2968 .offset = GLOBAL_VAR(InitLogonDelay),
2971 .flags = FLAG_ADVANCED,
2975 {N_("Browse Options"), P_SEP, P_SEPARATOR},
2978 .label = "os level",
2980 .p_class = P_GLOBAL,
2981 .offset = GLOBAL_VAR(os_level),
2984 .flags = FLAG_BASIC | FLAG_ADVANCED,
2987 .label = "lm announce",
2989 .p_class = P_GLOBAL,
2990 .offset = GLOBAL_VAR(lm_announce),
2992 .enum_list = enum_bool_auto,
2993 .flags = FLAG_ADVANCED,
2996 .label = "lm interval",
2998 .p_class = P_GLOBAL,
2999 .offset = GLOBAL_VAR(lm_interval),
3002 .flags = FLAG_ADVANCED,
3005 .label = "preferred master",
3007 .p_class = P_GLOBAL,
3008 .offset = GLOBAL_VAR(iPreferredMaster),
3010 .enum_list = enum_bool_auto,
3011 .flags = FLAG_BASIC | FLAG_ADVANCED,
3014 .label = "prefered master",
3016 .p_class = P_GLOBAL,
3017 .offset = GLOBAL_VAR(iPreferredMaster),
3019 .enum_list = enum_bool_auto,
3023 .label = "local master",
3025 .p_class = P_GLOBAL,
3026 .offset = GLOBAL_VAR(bLocalMaster),
3029 .flags = FLAG_BASIC | FLAG_ADVANCED,
3032 .label = "domain master",
3034 .p_class = P_GLOBAL,
3035 .offset = GLOBAL_VAR(iDomainMaster),
3037 .enum_list = enum_bool_auto,
3038 .flags = FLAG_BASIC | FLAG_ADVANCED,
3041 .label = "browse list",
3043 .p_class = P_GLOBAL,
3044 .offset = GLOBAL_VAR(bBrowseList),
3047 .flags = FLAG_ADVANCED,
3050 .label = "browseable",
3053 .offset = LOCAL_VAR(bBrowseable),
3056 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3059 .label = "browsable",
3062 .offset = LOCAL_VAR(bBrowseable),
3068 .label = "access based share enum",
3071 .offset = LOCAL_VAR(bAccessBasedShareEnum),
3074 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3077 .label = "enhanced browsing",
3079 .p_class = P_GLOBAL,
3080 .offset = GLOBAL_VAR(enhanced_browsing),
3083 .flags = FLAG_ADVANCED,
3086 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3089 .label = "dns proxy",
3091 .p_class = P_GLOBAL,
3092 .offset = GLOBAL_VAR(bDNSproxy),
3095 .flags = FLAG_ADVANCED,
3098 .label = "wins proxy",
3100 .p_class = P_GLOBAL,
3101 .offset = GLOBAL_VAR(bWINSproxy),
3104 .flags = FLAG_ADVANCED,
3107 .label = "wins server",
3109 .p_class = P_GLOBAL,
3110 .offset = GLOBAL_VAR(szWINSservers),
3113 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3116 .label = "wins support",
3118 .p_class = P_GLOBAL,
3119 .offset = GLOBAL_VAR(bWINSsupport),
3122 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3125 .label = "wins hook",
3127 .p_class = P_GLOBAL,
3128 .offset = GLOBAL_VAR(szWINSHook),
3131 .flags = FLAG_ADVANCED,
3134 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3137 .label = "blocking locks",
3140 .offset = LOCAL_VAR(bBlockingLocks),
3143 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3146 .label = "csc policy",
3149 .offset = LOCAL_VAR(iCSCPolicy),
3151 .enum_list = enum_csc_policy,
3152 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3155 .label = "fake oplocks",
3158 .offset = LOCAL_VAR(bFakeOplocks),
3161 .flags = FLAG_ADVANCED | FLAG_SHARE,
3164 .label = "kernel oplocks",
3166 .p_class = P_GLOBAL,
3167 .offset = GLOBAL_VAR(bKernelOplocks),
3170 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3176 .offset = LOCAL_VAR(bLocking),
3179 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3182 .label = "lock spin time",
3184 .p_class = P_GLOBAL,
3185 .offset = GLOBAL_VAR(iLockSpinTime),
3188 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3194 .offset = LOCAL_VAR(bOpLocks),
3197 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3200 .label = "level2 oplocks",
3203 .offset = LOCAL_VAR(bLevel2OpLocks),
3206 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3209 .label = "oplock break wait time",
3211 .p_class = P_GLOBAL,
3212 .offset = GLOBAL_VAR(oplock_break_wait_time),
3215 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3218 .label = "oplock contention limit",
3221 .offset = LOCAL_VAR(iOplockContentionLimit),
3224 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3227 .label = "posix locking",
3230 .offset = LOCAL_VAR(bPosixLocking),
3233 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3236 .label = "strict locking",
3239 .offset = LOCAL_VAR(iStrictLocking),
3241 .enum_list = enum_bool_auto,
3242 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3245 .label = "share modes",
3248 .offset = LOCAL_VAR(bShareModes),
3251 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3254 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3257 .label = "ldap admin dn",
3259 .p_class = P_GLOBAL,
3260 .offset = GLOBAL_VAR(szLdapAdminDn),
3263 .flags = FLAG_ADVANCED,
3266 .label = "ldap delete dn",
3268 .p_class = P_GLOBAL,
3269 .offset = GLOBAL_VAR(ldap_delete_dn),
3272 .flags = FLAG_ADVANCED,
3275 .label = "ldap group suffix",
3277 .p_class = P_GLOBAL,
3278 .offset = GLOBAL_VAR(szLdapGroupSuffix),
3281 .flags = FLAG_ADVANCED,
3284 .label = "ldap idmap suffix",
3286 .p_class = P_GLOBAL,
3287 .offset = GLOBAL_VAR(szLdapIdmapSuffix),
3290 .flags = FLAG_ADVANCED,
3293 .label = "ldap machine suffix",
3295 .p_class = P_GLOBAL,
3296 .offset = GLOBAL_VAR(szLdapMachineSuffix),
3299 .flags = FLAG_ADVANCED,
3302 .label = "ldap passwd sync",
3304 .p_class = P_GLOBAL,
3305 .offset = GLOBAL_VAR(ldap_passwd_sync),
3307 .enum_list = enum_ldap_passwd_sync,
3308 .flags = FLAG_ADVANCED,
3311 .label = "ldap password sync",
3313 .p_class = P_GLOBAL,
3314 .offset = GLOBAL_VAR(ldap_passwd_sync),
3316 .enum_list = enum_ldap_passwd_sync,
3320 .label = "ldap replication sleep",
3322 .p_class = P_GLOBAL,
3323 .offset = GLOBAL_VAR(ldap_replication_sleep),
3326 .flags = FLAG_ADVANCED,
3329 .label = "ldap suffix",
3331 .p_class = P_GLOBAL,
3332 .offset = GLOBAL_VAR(szLdapSuffix),
3335 .flags = FLAG_ADVANCED,
3338 .label = "ldap ssl",
3340 .p_class = P_GLOBAL,
3341 .offset = GLOBAL_VAR(ldap_ssl),
3343 .enum_list = enum_ldap_ssl,
3344 .flags = FLAG_ADVANCED,
3347 .label = "ldap ssl ads",
3349 .p_class = P_GLOBAL,
3350 .offset = GLOBAL_VAR(ldap_ssl_ads),
3353 .flags = FLAG_ADVANCED,
3356 .label = "ldap deref",
3358 .p_class = P_GLOBAL,
3359 .offset = GLOBAL_VAR(ldap_deref),
3361 .enum_list = enum_ldap_deref,
3362 .flags = FLAG_ADVANCED,
3365 .label = "ldap follow referral",
3367 .p_class = P_GLOBAL,
3368 .offset = GLOBAL_VAR(ldap_follow_referral),
3370 .enum_list = enum_bool_auto,
3371 .flags = FLAG_ADVANCED,
3374 .label = "ldap timeout",
3376 .p_class = P_GLOBAL,
3377 .offset = GLOBAL_VAR(ldap_timeout),
3380 .flags = FLAG_ADVANCED,
3383 .label = "ldap connection timeout",
3385 .p_class = P_GLOBAL,
3386 .offset = GLOBAL_VAR(ldap_connection_timeout),
3389 .flags = FLAG_ADVANCED,
3392 .label = "ldap page size",
3394 .p_class = P_GLOBAL,
3395 .offset = GLOBAL_VAR(ldap_page_size),
3398 .flags = FLAG_ADVANCED,
3401 .label = "ldap user suffix",
3403 .p_class = P_GLOBAL,
3404 .offset = GLOBAL_VAR(szLdapUserSuffix),
3407 .flags = FLAG_ADVANCED,
3410 .label = "ldap debug level",
3412 .p_class = P_GLOBAL,
3413 .offset = GLOBAL_VAR(ldap_debug_level),
3414 .special = handle_ldap_debug_level,
3416 .flags = FLAG_ADVANCED,
3419 .label = "ldap debug threshold",
3421 .p_class = P_GLOBAL,
3422 .offset = GLOBAL_VAR(ldap_debug_threshold),
3425 .flags = FLAG_ADVANCED,
3428 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3431 .label = "eventlog list",
3433 .p_class = P_GLOBAL,
3434 .offset = GLOBAL_VAR(szEventLogs),
3437 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3440 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3443 .label = "add share command",
3445 .p_class = P_GLOBAL,
3446 .offset = GLOBAL_VAR(szAddShareCommand),
3449 .flags = FLAG_ADVANCED,
3452 .label = "change share command",
3454 .p_class = P_GLOBAL,
3455 .offset = GLOBAL_VAR(szChangeShareCommand),
3458 .flags = FLAG_ADVANCED,
3461 .label = "delete share command",
3463 .p_class = P_GLOBAL,
3464 .offset = GLOBAL_VAR(szDeleteShareCommand),
3467 .flags = FLAG_ADVANCED,
3470 .label = "config file",
3472 .p_class = P_GLOBAL,
3473 .offset = GLOBAL_VAR(szConfigFile),
3476 .flags = FLAG_HIDE|FLAG_META,
3481 .p_class = P_GLOBAL,
3482 .offset = GLOBAL_VAR(szAutoServices),
3485 .flags = FLAG_ADVANCED,
3488 .label = "auto services",
3490 .p_class = P_GLOBAL,
3491 .offset = GLOBAL_VAR(szAutoServices),
3494 .flags = FLAG_ADVANCED,
3497 .label = "lock directory",
3499 .p_class = P_GLOBAL,
3500 .offset = GLOBAL_VAR(szLockDir),
3503 .flags = FLAG_ADVANCED,
3506 .label = "lock dir",
3508 .p_class = P_GLOBAL,
3509 .offset = GLOBAL_VAR(szLockDir),
3515 .label = "state directory",
3517 .p_class = P_GLOBAL,
3518 .offset = GLOBAL_VAR(szStateDir),
3521 .flags = FLAG_ADVANCED,
3524 .label = "cache directory",
3526 .p_class = P_GLOBAL,
3527 .offset = GLOBAL_VAR(szCacheDir),
3530 .flags = FLAG_ADVANCED,
3533 .label = "pid directory",
3535 .p_class = P_GLOBAL,
3536 .offset = GLOBAL_VAR(szPidDir),
3539 .flags = FLAG_ADVANCED,
3543 .label = "utmp directory",
3545 .p_class = P_GLOBAL,
3546 .offset = GLOBAL_VAR(szUtmpDir),
3549 .flags = FLAG_ADVANCED,
3552 .label = "wtmp directory",
3554 .p_class = P_GLOBAL,
3555 .offset = GLOBAL_VAR(szWtmpDir),
3558 .flags = FLAG_ADVANCED,
3563 .p_class = P_GLOBAL,
3564 .offset = GLOBAL_VAR(bUtmp),
3567 .flags = FLAG_ADVANCED,
3571 .label = "default service",
3573 .p_class = P_GLOBAL,
3574 .offset = GLOBAL_VAR(szDefaultService),
3577 .flags = FLAG_ADVANCED,
3582 .p_class = P_GLOBAL,
3583 .offset = GLOBAL_VAR(szDefaultService),
3586 .flags = FLAG_ADVANCED,
3589 .label = "message command",
3591 .p_class = P_GLOBAL,
3592 .offset = GLOBAL_VAR(szMsgCommand),
3595 .flags = FLAG_ADVANCED,
3598 .label = "dfree cache time",
3601 .offset = LOCAL_VAR(iDfreeCacheTime),
3604 .flags = FLAG_ADVANCED,
3607 .label = "dfree command",
3610 .offset = LOCAL_VAR(szDfree),
3613 .flags = FLAG_ADVANCED,
3616 .label = "get quota command",
3618 .p_class = P_GLOBAL,
3619 .offset = GLOBAL_VAR(szGetQuota),
3622 .flags = FLAG_ADVANCED,
3625 .label = "set quota command",
3627 .p_class = P_GLOBAL,
3628 .offset = GLOBAL_VAR(szSetQuota),
3631 .flags = FLAG_ADVANCED,
3634 .label = "remote announce",
3636 .p_class = P_GLOBAL,
3637 .offset = GLOBAL_VAR(szRemoteAnnounce),
3640 .flags = FLAG_ADVANCED,
3643 .label = "remote browse sync",
3645 .p_class = P_GLOBAL,
3646 .offset = GLOBAL_VAR(szRemoteBrowseSync),
3649 .flags = FLAG_ADVANCED,
3652 .label = "socket address",
3654 .p_class = P_GLOBAL,
3655 .offset = GLOBAL_VAR(szSocketAddress),
3658 .flags = FLAG_ADVANCED,
3661 .label = "nmbd bind explicit broadcast",
3663 .p_class = P_GLOBAL,
3664 .offset = GLOBAL_VAR(bNmbdBindExplicitBroadcast),
3667 .flags = FLAG_ADVANCED,
3670 .label = "homedir map",
3672 .p_class = P_GLOBAL,
3673 .offset = GLOBAL_VAR(szNISHomeMapName),
3676 .flags = FLAG_ADVANCED,
3679 .label = "afs username map",
3681 .p_class = P_GLOBAL,
3682 .offset = GLOBAL_VAR(szAfsUsernameMap),
3685 .flags = FLAG_ADVANCED,
3688 .label = "afs token lifetime",
3690 .p_class = P_GLOBAL,
3691 .offset = GLOBAL_VAR(iAfsTokenLifetime),
3694 .flags = FLAG_ADVANCED,
3697 .label = "log nt token command",
3699 .p_class = P_GLOBAL,
3700 .offset = GLOBAL_VAR(szLogNtTokenCommand),
3703 .flags = FLAG_ADVANCED,
3706 .label = "NIS homedir",
3708 .p_class = P_GLOBAL,
3709 .offset = GLOBAL_VAR(bNISHomeMap),
3712 .flags = FLAG_ADVANCED,
3718 .offset = LOCAL_VAR(valid),
3727 .offset = LOCAL_VAR(szCopy),
3728 .special = handle_copy,
3736 .offset = LOCAL_VAR(szInclude),
3737 .special = handle_include,
3739 .flags = FLAG_HIDE|FLAG_META,
3745 .offset = LOCAL_VAR(szPreExec),
3748 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3754 .offset = LOCAL_VAR(szPreExec),
3757 .flags = FLAG_ADVANCED,
3760 .label = "preexec close",
3763 .offset = LOCAL_VAR(bPreexecClose),
3766 .flags = FLAG_ADVANCED | FLAG_SHARE,
3769 .label = "postexec",
3772 .offset = LOCAL_VAR(szPostExec),
3775 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3778 .label = "root preexec",
3781 .offset = LOCAL_VAR(szRootPreExec),
3784 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3787 .label = "root preexec close",
3790 .offset = LOCAL_VAR(bRootpreexecClose),
3793 .flags = FLAG_ADVANCED | FLAG_SHARE,
3796 .label = "root postexec",
3799 .offset = LOCAL_VAR(szRootPostExec),
3802 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3805 .label = "available",
3808 .offset = LOCAL_VAR(bAvailable),
3811 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3814 .label = "registry shares",
3816 .p_class = P_GLOBAL,
3817 .offset = GLOBAL_VAR(bRegistryShares),
3820 .flags = FLAG_ADVANCED,
3823 .label = "usershare allow guests",
3825 .p_class = P_GLOBAL,
3826 .offset = GLOBAL_VAR(bUsershareAllowGuests),
3829 .flags = FLAG_ADVANCED,
3832 .label = "usershare max shares",
3834 .p_class = P_GLOBAL,
3835 .offset = GLOBAL_VAR(iUsershareMaxShares),
3838 .flags = FLAG_ADVANCED,
3841 .label = "usershare owner only",
3843 .p_class = P_GLOBAL,
3844 .offset = GLOBAL_VAR(bUsershareOwnerOnly),
3847 .flags = FLAG_ADVANCED,
3850 .label = "usershare path",
3852 .p_class = P_GLOBAL,
3853 .offset = GLOBAL_VAR(szUsersharePath),
3856 .flags = FLAG_ADVANCED,
3859 .label = "usershare prefix allow list",
3861 .p_class = P_GLOBAL,
3862 .offset = GLOBAL_VAR(szUsersharePrefixAllowList),
3865 .flags = FLAG_ADVANCED,
3868 .label = "usershare prefix deny list",
3870 .p_class = P_GLOBAL,
3871 .offset = GLOBAL_VAR(szUsersharePrefixDenyList),
3874 .flags = FLAG_ADVANCED,
3877 .label = "usershare template share",
3879 .p_class = P_GLOBAL,
3880 .offset = GLOBAL_VAR(szUsershareTemplateShare),
3883 .flags = FLAG_ADVANCED,
3889 .offset = LOCAL_VAR(volume),
3892 .flags = FLAG_ADVANCED | FLAG_SHARE,
3898 .offset = LOCAL_VAR(fstype),
3901 .flags = FLAG_ADVANCED | FLAG_SHARE,
3904 .label = "set directory",
3907 .offset = LOCAL_VAR(bNo_set_dir),
3910 .flags = FLAG_ADVANCED | FLAG_SHARE,
3913 .label = "wide links",
3916 .offset = LOCAL_VAR(bWidelinks),
3919 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3922 .label = "follow symlinks",
3925 .offset = LOCAL_VAR(bSymlinks),
3928 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3931 .label = "dont descend",
3934 .offset = LOCAL_VAR(szDontdescend),
3937 .flags = FLAG_ADVANCED | FLAG_SHARE,
3940 .label = "magic script",
3943 .offset = LOCAL_VAR(szMagicScript),
3946 .flags = FLAG_ADVANCED | FLAG_SHARE,
3949 .label = "magic output",
3952 .offset = LOCAL_VAR(szMagicOutput),
3955 .flags = FLAG_ADVANCED | FLAG_SHARE,
3958 .label = "delete readonly",
3961 .offset = LOCAL_VAR(bDeleteReadonly),
3964 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3967 .label = "dos filemode",
3970 .offset = LOCAL_VAR(bDosFilemode),
3973 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3976 .label = "dos filetimes",
3979 .offset = LOCAL_VAR(bDosFiletimes),
3982 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3985 .label = "dos filetime resolution",
3988 .offset = LOCAL_VAR(bDosFiletimeResolution),
3991 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3994 .label = "fake directory create times",
3997 .offset = LOCAL_VAR(bFakeDirCreateTimes),
4000 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4003 .label = "async smb echo handler",
4005 .p_class = P_GLOBAL,
4006 .offset = GLOBAL_VAR(bAsyncSMBEchoHandler),
4009 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4012 .label = "multicast dns register",
4014 .p_class = P_GLOBAL,
4015 .offset = GLOBAL_VAR(bMulticastDnsRegister),
4018 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4021 .label = "panic action",
4023 .p_class = P_GLOBAL,
4024 .offset = GLOBAL_VAR(szPanicAction),
4027 .flags = FLAG_ADVANCED,
4030 .label = "perfcount module",
4032 .p_class = P_GLOBAL,
4033 .offset = GLOBAL_VAR(szSMBPerfcountModule),
4036 .flags = FLAG_ADVANCED,
4039 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4042 .label = "vfs objects",
4045 .offset = LOCAL_VAR(szVfsObjects),
4048 .flags = FLAG_ADVANCED | FLAG_SHARE,
4051 .label = "vfs object",
4054 .offset = LOCAL_VAR(szVfsObjects),
4061 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4064 .label = "msdfs root",
4067 .offset = LOCAL_VAR(bMSDfsRoot),
4070 .flags = FLAG_ADVANCED | FLAG_SHARE,
4073 .label = "msdfs proxy",
4076 .offset = LOCAL_VAR(szMSDfsProxy),
4079 .flags = FLAG_ADVANCED | FLAG_SHARE,
4082 .label = "host msdfs",
4084 .p_class = P_GLOBAL,
4085 .offset = GLOBAL_VAR(bHostMSDfs),
4088 .flags = FLAG_ADVANCED,
4091 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4094 .label = "passdb expand explicit",
4096 .p_class = P_GLOBAL,
4097 .offset = GLOBAL_VAR(bPassdbExpandExplicit),
4100 .flags = FLAG_ADVANCED,
4103 .label = "idmap backend",
4105 .p_class = P_GLOBAL,
4106 .offset = GLOBAL_VAR(szIdmapBackend),
4107 .special = handle_idmap_backend,
4109 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4112 .label = "idmap cache time",
4114 .p_class = P_GLOBAL,
4115 .offset = GLOBAL_VAR(iIdmapCacheTime),
4118 .flags = FLAG_ADVANCED,
4121 .label = "idmap negative cache time",
4123 .p_class = P_GLOBAL,
4124 .offset = GLOBAL_VAR(iIdmapNegativeCacheTime),
4127 .flags = FLAG_ADVANCED,
4130 .label = "idmap uid",
4132 .p_class = P_GLOBAL,
4133 .offset = GLOBAL_VAR(szIdmapUID),
4134 .special = handle_idmap_uid,
4136 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4139 .label = "winbind uid",
4141 .p_class = P_GLOBAL,
4142 .offset = GLOBAL_VAR(szIdmapUID),
4143 .special = handle_idmap_uid,
4148 .label = "idmap gid",
4150 .p_class = P_GLOBAL,
4151 .offset = GLOBAL_VAR(szIdmapGID),
4152 .special = handle_idmap_gid,
4154 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4157 .label = "winbind gid",
4159 .p_class = P_GLOBAL,
4160 .offset = GLOBAL_VAR(szIdmapGID),
4161 .special = handle_idmap_gid,
4166 .label = "template homedir",
4168 .p_class = P_GLOBAL,
4169 .offset = GLOBAL_VAR(szTemplateHomedir),
4172 .flags = FLAG_ADVANCED,
4175 .label = "template shell",
4177 .p_class = P_GLOBAL,
4178 .offset = GLOBAL_VAR(szTemplateShell),
4181 .flags = FLAG_ADVANCED,
4184 .label = "winbind separator",
4186 .p_class = P_GLOBAL,
4187 .offset = GLOBAL_VAR(szWinbindSeparator),
4190 .flags = FLAG_ADVANCED,
4193 .label = "winbind cache time",
4195 .p_class = P_GLOBAL,
4196 .offset = GLOBAL_VAR(winbind_cache_time),
4199 .flags = FLAG_ADVANCED,
4202 .label = "winbind reconnect delay",
4204 .p_class = P_GLOBAL,
4205 .offset = GLOBAL_VAR(winbind_reconnect_delay),
4208 .flags = FLAG_ADVANCED,
4211 .label = "winbind max clients",
4213 .p_class = P_GLOBAL,
4214 .offset = GLOBAL_VAR(winbind_max_clients),
4217 .flags = FLAG_ADVANCED,
4220 .label = "winbind enum users",
4222 .p_class = P_GLOBAL,
4223 .offset = GLOBAL_VAR(bWinbindEnumUsers),
4226 .flags = FLAG_ADVANCED,
4229 .label = "winbind enum groups",
4231 .p_class = P_GLOBAL,
4232 .offset = GLOBAL_VAR(bWinbindEnumGroups),
4235 .flags = FLAG_ADVANCED,
4238 .label = "winbind use default domain",
4240 .p_class = P_GLOBAL,
4241 .offset = GLOBAL_VAR(bWinbindUseDefaultDomain),
4244 .flags = FLAG_ADVANCED,
4247 .label = "winbind trusted domains only",
4249 .p_class = P_GLOBAL,
4250 .offset = GLOBAL_VAR(bWinbindTrustedDomainsOnly),
4253 .flags = FLAG_ADVANCED,
4256 .label = "winbind nested groups",
4258 .p_class = P_GLOBAL,
4259 .offset = GLOBAL_VAR(bWinbindNestedGroups),
4262 .flags = FLAG_ADVANCED,
4265 .label = "winbind expand groups",
4267 .p_class = P_GLOBAL,
4268 .offset = GLOBAL_VAR(winbind_expand_groups),
4271 .flags = FLAG_ADVANCED,
4274 .label = "winbind nss info",
4276 .p_class = P_GLOBAL,
4277 .offset = GLOBAL_VAR(szWinbindNssInfo),
4280 .flags = FLAG_ADVANCED,
4283 .label = "winbind refresh tickets",
4285 .p_class = P_GLOBAL,
4286 .offset = GLOBAL_VAR(bWinbindRefreshTickets),
4289 .flags = FLAG_ADVANCED,
4292 .label = "winbind offline logon",
4294 .p_class = P_GLOBAL,
4295 .offset = GLOBAL_VAR(bWinbindOfflineLogon),
4298 .flags = FLAG_ADVANCED,
4301 .label = "winbind normalize names",
4303 .p_class = P_GLOBAL,
4304 .offset = GLOBAL_VAR(bWinbindNormalizeNames),
4307 .flags = FLAG_ADVANCED,
4310 .label = "winbind rpc only",
4312 .p_class = P_GLOBAL,
4313 .offset = GLOBAL_VAR(bWinbindRpcOnly),
4316 .flags = FLAG_ADVANCED,
4319 .label = "create krb5 conf",
4321 .p_class = P_GLOBAL,
4322 .offset = GLOBAL_VAR(bCreateKrb5Conf),
4325 .flags = FLAG_ADVANCED,
4328 .label = "ncalrpc dir",
4330 .p_class = P_GLOBAL,
4331 .offset = GLOBAL_VAR(ncalrpc_dir),
4334 .flags = FLAG_ADVANCED,
4337 .label = "winbind max domain connections",
4339 .p_class = P_GLOBAL,
4340 .offset = GLOBAL_VAR(winbindMaxDomainConnections),
4343 .flags = FLAG_ADVANCED,
4346 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
4349 /***************************************************************************
4350 Initialise the sDefault parameter structure for the printer values.
4351 ***************************************************************************/
4353 static void init_printer_values(struct loadparm_service *pService)
4355 /* choose defaults depending on the type of printing */
4356 switch (pService->iPrinting) {
4361 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4362 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4363 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4368 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4369 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4370 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4371 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4372 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4373 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4374 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4380 /* set the lpq command to contain the destination printer
4381 name only. This is used by cups_queue_get() */
4382 string_set(&pService->szLpqcommand, "%p");
4383 string_set(&pService->szLprmcommand, "");
4384 string_set(&pService->szPrintcommand, "");
4385 string_set(&pService->szLppausecommand, "");
4386 string_set(&pService->szLpresumecommand, "");
4387 string_set(&pService->szQueuepausecommand, "");
4388 string_set(&pService->szQueueresumecommand, "");
4390 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4391 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4392 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4393 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4394 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4395 string_set(&pService->szQueuepausecommand, "disable '%p'");
4396 string_set(&pService->szQueueresumecommand, "enable '%p'");
4397 #endif /* HAVE_CUPS */
4402 string_set(&pService->szLpqcommand, "lpstat -o%p");
4403 string_set(&pService->szLprmcommand, "cancel %p-%j");
4404 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4405 string_set(&pService->szQueuepausecommand, "disable %p");
4406 string_set(&pService->szQueueresumecommand, "enable %p");
4408 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4409 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4414 string_set(&pService->szLpqcommand, "lpq -P%p");
4415 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4416 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4419 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
4423 const char *tdbfile;
4426 tdbfile = talloc_asprintf(
4427 talloc_tos(), "tdbfile=%s",
4428 lp_parm_const_string(-1, "vlp", "tdbfile",
4430 if (tdbfile == NULL) {
4431 tdbfile="tdbfile=/tmp/vlp.tdb";
4434 tmp = talloc_asprintf(talloc_tos(), "vlp %s print %%p %%s",
4436 string_set(&pService->szPrintcommand,
4437 tmp ? tmp : "vlp print %p %s");
4440 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpq %%p",
4442 string_set(&pService->szLpqcommand,
4443 tmp ? tmp : "vlp lpq %p");
4446 tmp = talloc_asprintf(talloc_tos(), "vlp %s lprm %%p %%j",
4448 string_set(&pService->szLprmcommand,
4449 tmp ? tmp : "vlp lprm %p %j");
4452 tmp = talloc_asprintf(talloc_tos(), "vlp %s lppause %%p %%j",
4454 string_set(&pService->szLppausecommand,
4455 tmp ? tmp : "vlp lppause %p %j");
4458 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpresume %%p %%j",
4460 string_set(&pService->szLpresumecommand,
4461 tmp ? tmp : "vlp lpresume %p %j");
4464 tmp = talloc_asprintf(talloc_tos(), "vlp %s queuepause %%p",
4466 string_set(&pService->szQueuepausecommand,
4467 tmp ? tmp : "vlp queuepause %p");
4470 tmp = talloc_asprintf(talloc_tos(), "vlp %s queueresume %%p",
4472 string_set(&pService->szQueueresumecommand,
4473 tmp ? tmp : "vlp queueresume %p");
4478 #endif /* DEVELOPER */
4483 * Function to return the default value for the maximum number of open
4484 * file descriptors permitted. This function tries to consult the
4485 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4486 * the smaller of those.
4488 static int max_open_files(void)
4490 int sysctl_max = MAX_OPEN_FILES;
4491 int rlimit_max = MAX_OPEN_FILES;
4493 #ifdef HAVE_SYSCTLBYNAME
4495 size_t size = sizeof(sysctl_max);
4496 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4501 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4507 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4508 rlimit_max = rl.rlim_cur;
4510 #if defined(RLIM_INFINITY)
4511 if(rl.rlim_cur == RLIM_INFINITY)
4512 rlimit_max = MAX_OPEN_FILES;
4517 if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4518 DEBUG(2,("max_open_files: increasing sysctl_max (%d) to "
4519 "minimum Windows limit (%d)\n",
4521 MIN_OPEN_FILES_WINDOWS));
4522 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4525 if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4526 DEBUG(2,("rlimit_max: increasing rlimit_max (%d) to "
4527 "minimum Windows limit (%d)\n",
4529 MIN_OPEN_FILES_WINDOWS));
4530 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4533 return MIN(sysctl_max, rlimit_max);
4537 * Common part of freeing allocated data for one parameter.
4539 static void free_one_parameter_common(void *parm_ptr,
4540 struct parm_struct parm)
4542 if ((parm.type == P_STRING) ||
4543 (parm.type == P_USTRING))
4545 string_free((char**)parm_ptr);
4546 } else if (parm.type == P_LIST) {
4547 TALLOC_FREE(*((char***)parm_ptr));
4552 * Free the allocated data for one parameter for a share
4553 * given as a service struct.
4555 static void free_one_parameter(struct loadparm_service *service,
4556 struct parm_struct parm)
4560 if (parm.p_class != P_LOCAL) {
4564 parm_ptr = lp_parm_ptr(service, &parm);
4566 free_one_parameter_common(parm_ptr, parm);
4570 * Free the allocated parameter data of a share given
4571 * as a service struct.
4573 static void free_parameters(struct loadparm_service *service)
4577 for (i=0; parm_table[i].label; i++) {
4578 free_one_parameter(service, parm_table[i]);
4583 * Free the allocated data for one parameter for a given share
4584 * specified by an snum.
4586 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4591 parm_ptr = lp_parm_ptr(NULL, &parm);
4592 } else if (parm.p_class != P_LOCAL) {
4595 parm_ptr = lp_local_ptr_by_snum(snum, &parm);
4598 free_one_parameter_common(parm_ptr, parm);
4602 * Free the allocated parameter data for a share specified
4605 static void free_parameters_by_snum(int snum)
4609 for (i=0; parm_table[i].label; i++) {
4610 free_one_parameter_by_snum(snum, parm_table[i]);
4615 * Free the allocated global parameters.
4617 static void free_global_parameters(void)
4619 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4622 static int map_parameter(const char *pszParmName);
4624 struct lp_stored_option {
4625 struct lp_stored_option *prev, *next;
4630 static struct lp_stored_option *stored_options;
4633 save options set by lp_set_cmdline() into a list. This list is
4634 re-applied when we do a globals reset, so that cmdline set options
4635 are sticky across reloads of smb.conf
4637 static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
4639 struct lp_stored_option *entry, *entry_next;
4640 for (entry = stored_options; entry != NULL; entry = entry_next) {
4641 entry_next = entry->next;
4642 if (strcmp(pszParmName, entry->label) == 0) {
4643 DLIST_REMOVE(stored_options, entry);
4649 entry = talloc(NULL, struct lp_stored_option);
4654 entry->label = talloc_strdup(entry, pszParmName);
4655 if (!entry->label) {
4660 entry->value = talloc_strdup(entry, pszParmValue);
4661 if (!entry->value) {
4666 DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
4671 static bool apply_lp_set_cmdline(void)
4673 struct lp_stored_option *entry = NULL;
4674 for (entry = stored_options; entry != NULL; entry = entry->next) {
4675 if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
4676 DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
4677 entry->label, entry->value));
4684 /***************************************************************************
4685 Initialise the global parameter structure.
4686 ***************************************************************************/
4688 static void init_globals(bool reinit_globals)
4690 static bool done_init = false;
4694 /* If requested to initialize only once and we've already done it... */
4695 if (!reinit_globals && done_init) {
4696 /* ... then we have nothing more to do */
4701 /* The logfile can be set before this is invoked. Free it if so. */
4702 if (Globals.szLogFile != NULL) {
4703 string_free(&Globals.szLogFile);
4704 Globals.szLogFile = NULL;
4708 free_global_parameters();
4711 /* This memset and the free_global_parameters() above will
4712 * wipe out smb.conf options set with lp_set_cmdline(). The
4713 * apply_lp_set_cmdline() call puts these values back in the
4714 * table once the defaults are set */
4715 memset((void *)&Globals, '\0', sizeof(Globals));
4717 for (i = 0; parm_table[i].label; i++) {
4718 if ((parm_table[i].type == P_STRING ||
4719 parm_table[i].type == P_USTRING))
4721 string_set(lp_parm_ptr(NULL, &parm_table[i]), "");
4726 string_set(&sDefault.fstype, FSTYPE_STRING);
4727 string_set(&sDefault.szPrintjobUsername, "%U");
4729 init_printer_values(&sDefault);
4732 DEBUG(3, ("Initialising global parameters\n"));
4734 /* Must manually force to upper case here, as this does not go via the handler */
4735 string_set(&Globals.szNetbiosName, myhostname_upper());
4737 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4738 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4740 /* use the new 'hash2' method by default, with a prefix of 1 */
4741 string_set(&Globals.szManglingMethod, "hash2");
4742 Globals.mangle_prefix = 1;
4744 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4746 /* using UTF8 by default allows us to support all chars */
4747 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4749 /* Use codepage 850 as a default for the dos character set */
4750 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4753 * Allow the default PASSWD_CHAT to be overridden in local.h.
4755 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4757 string_set(&Globals.szWorkgroup, DEFAULT_WORKGROUP);
4759 string_set(&Globals.szPasswdProgram, "");
4760 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4761 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4762 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4763 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4764 string_set(&Globals.szSocketAddress, "0.0.0.0");
4766 * By default support explicit binding to broadcast
4769 Globals.bNmbdBindExplicitBroadcast = true;
4771 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4772 smb_panic("init_globals: ENOMEM");
4774 string_set(&Globals.szServerString, s);
4777 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4780 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
4782 string_set(&Globals.szLogonDrive, "");
4783 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4784 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4785 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4787 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
4788 string_set(&Globals.szPasswordServer, "*");
4790 Globals.AlgorithmicRidBase = BASE_RID;
4792 Globals.bLoadPrinters = true;
4793 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4795 Globals.ConfigBackend = config_backend;
4797 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4798 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4799 Globals.max_xmit = 0x4104;
4800 Globals.max_mux = 50; /* This is *needed* for profile support. */
4801 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4802 Globals.bDisableSpoolss = false;
4803 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4804 Globals.pwordlevel = 0;
4805 Globals.unamelevel = 0;
4806 Globals.deadtime = 0;
4807 Globals.getwd_cache = true;
4808 Globals.bLargeReadwrite = true;
4809 Globals.max_log_size = 5000;
4810 Globals.max_open_files = max_open_files();
4811 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4812 Globals.maxprotocol = PROTOCOL_NT1;
4813 Globals.minprotocol = PROTOCOL_CORE;
4814 Globals.security = SEC_USER;
4815 Globals.paranoid_server_security = true;
4816 Globals.bEncryptPasswords = true;
4817 Globals.clientSchannel = Auto;
4818 Globals.serverSchannel = Auto;
4819 Globals.bReadRaw = true;
4820 Globals.bWriteRaw = true;
4821 Globals.bNullPasswords = false;
4822 Globals.bObeyPamRestrictions = false;
4824 Globals.bSyslogOnly = false;
4825 Globals.bTimestampLogs = true;
4826 string_set(&Globals.szLogLevel, "0");
4827 Globals.bDebugPrefixTimestamp = false;
4828 Globals.bDebugHiresTimestamp = true;
4829 Globals.bDebugPid = false;
4830 Globals.bDebugUid = false;
4831 Globals.bDebugClass = false;
4832 Globals.bEnableCoreFiles = true;
4833 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4834 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4835 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4836 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4837 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
4838 Globals.lm_interval = 60;
4839 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4840 Globals.bNISHomeMap = false;
4841 #ifdef WITH_NISPLUS_HOME
4842 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4844 string_set(&Globals.szNISHomeMapName, "auto.home");
4847 Globals.bTimeServer = false;
4848 Globals.bBindInterfacesOnly = false;
4849 Globals.bUnixPasswdSync = false;
4850 Globals.bPamPasswordChange = false;
4851 Globals.bPasswdChatDebug = false;
4852 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4853 Globals.bNTPipeSupport = true; /* Do NT pipes by default. */
4854 Globals.bNTStatusSupport = true; /* Use NT status by default. */
4855 Globals.bStatCache = true; /* use stat cache by default */
4856 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4857 Globals.restrict_anonymous = 0;
4858 Globals.bClientLanManAuth = false; /* Do NOT use the LanMan hash if it is available */
4859 Globals.bClientPlaintextAuth = false; /* Do NOT use a plaintext password even if is requested by the server */
4860 Globals.bLanmanAuth = false; /* Do NOT use the LanMan hash, even if it is supplied */
4861 Globals.bNTLMAuth = true; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4862 Globals.bClientNTLMv2Auth = true; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
4863 /* Note, that we will also use NTLM2 session security (which is different), if it is available */
4865 Globals.map_to_guest = 0; /* By Default, "Never" */
4866 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4867 Globals.enhanced_browsing = true;
4868 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4869 #ifdef MMAP_BLACKLIST
4870 Globals.bUseMmap = false;
4872 Globals.bUseMmap = true;
4874 Globals.bUnixExtensions = true;
4875 Globals.bResetOnZeroVC = false;
4876 Globals.bLogWriteableFilesOnExit = false;
4877 Globals.bCreateKrb5Conf = true;
4878 Globals.winbindMaxDomainConnections = 1;
4880 /* hostname lookups can be very expensive and are broken on
4881 a large number of sites (tridge) */
4882 Globals.bHostnameLookups = false;
4884 string_set(&Globals.szPassdbBackend, "tdbsam");
4885 string_set(&Globals.szLdapSuffix, "");
4886 string_set(&Globals.szLdapMachineSuffix, "");
4887 string_set(&Globals.szLdapUserSuffix, "");
4888 string_set(&Globals.szLdapGroupSuffix, "");
4889 string_set(&Globals.szLdapIdmapSuffix, "");
4891 string_set(&Globals.szLdapAdminDn, "");
4892 Globals.ldap_ssl = LDAP_SSL_START_TLS;
4893 Globals.ldap_ssl_ads = false;
4894 Globals.ldap_deref = -1;
4895 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
4896 Globals.ldap_delete_dn = false;
4897 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
4898 Globals.ldap_follow_referral = Auto;
4899 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
4900 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
4901 Globals.ldap_page_size = LDAP_PAGE_SIZE;
4903 Globals.ldap_debug_level = 0;
4904 Globals.ldap_debug_threshold = 10;
4906 /* This is what we tell the afs client. in reality we set the token
4907 * to never expire, though, when this runs out the afs client will
4908 * forget the token. Set to 0 to get NEVERDATE.*/
4909 Globals.iAfsTokenLifetime = 604800;
4910 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
4912 /* these parameters are set to defaults that are more appropriate
4913 for the increasing samba install base:
4915 as a member of the workgroup, that will possibly become a
4916 _local_ master browser (lm = true). this is opposed to a forced
4917 local master browser startup (pm = true).
4919 doesn't provide WINS server service by default (wsupp = false),
4920 and doesn't provide domain master browser services by default, either.
4924 Globals.bMsAddPrinterWizard = true;
4925 Globals.os_level = 20;
4926 Globals.bLocalMaster = true;
4927 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
4928 Globals.bDomainLogons = false;
4929 Globals.bBrowseList = true;
4930 Globals.bWINSsupport = false;
4931 Globals.bWINSproxy = false;
4933 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
4934 Globals.InitLogonDelay = 100; /* 100 ms default delay */
4936 Globals.bDNSproxy = true;
4938 /* this just means to use them if they exist */
4939 Globals.bKernelOplocks = true;
4941 Globals.bAllowTrustedDomains = true;
4942 string_set(&Globals.szIdmapBackend, "tdb");
4944 string_set(&Globals.szTemplateShell, "/bin/false");
4945 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
4946 string_set(&Globals.szWinbindSeparator, "\\");
4948 string_set(&Globals.szCupsServer, "");
4949 string_set(&Globals.szIPrintServer, "");
4951 string_set(&Globals.ctdbdSocket, "");
4952 Globals.szClusterAddresses = NULL;
4953 Globals.clustering = false;
4954 Globals.ctdb_timeout = 0;
4955 Globals.ctdb_locktime_warn_threshold = 0;
4957 Globals.winbind_cache_time = 300; /* 5 minutes */
4958 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
4959 Globals.winbind_max_clients = 200;
4960 Globals.bWinbindEnumUsers = false;
4961 Globals.bWinbindEnumGroups = false;
4962 Globals.bWinbindUseDefaultDomain = false;
4963 Globals.bWinbindTrustedDomainsOnly = false;
4964 Globals.bWinbindNestedGroups = true;
4965 Globals.winbind_expand_groups = 1;
4966 Globals.szWinbindNssInfo = str_list_make_v3(NULL, "template", NULL);
4967 Globals.bWinbindRefreshTickets = false;
4968 Globals.bWinbindOfflineLogon = false;
4970 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
4971 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
4973 Globals.bPassdbExpandExplicit = false;
4975 Globals.name_cache_timeout = 660; /* In seconds */
4977 Globals.bUseSpnego = true;
4978 Globals.bClientUseSpnego = true;
4980 Globals.client_signing = Auto;
4981 Globals.server_signing = false;
4983 Globals.bDeferSharingViolations = true;
4984 string_set(&Globals.smb_ports, SMB_PORTS);
4986 Globals.bEnablePrivileges = true;
4987 Globals.bHostMSDfs = true;
4988 Globals.bASUSupport = false;
4990 /* User defined shares. */
4991 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
4992 smb_panic("init_globals: ENOMEM");
4994 string_set(&Globals.szUsersharePath, s);
4996 string_set(&Globals.szUsershareTemplateShare, "");
4997 Globals.iUsershareMaxShares = 0;
4998 /* By default disallow sharing of directories not owned by the sharer. */
4999 Globals.bUsershareOwnerOnly = true;
5000 /* By default disallow guest access to usershares. */
5001 Globals.bUsershareAllowGuests = false;
5003 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5005 /* By default no shares out of the registry */
5006 Globals.bRegistryShares = false;
5008 Globals.iminreceivefile = 0;
5010 Globals.bMapUntrustedToDomain = false;
5011 Globals.bMulticastDnsRegister = true;
5013 Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ;
5014 Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE;
5015 Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT;
5016 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5018 string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
5020 /* Now put back the settings that were set with lp_set_cmdline() */
5021 apply_lp_set_cmdline();
5024 /*******************************************************************
5025 Convenience routine to grab string parameters into temporary memory
5026 and run standard_sub_basic on them. The buffers can be written to by
5027 callers without affecting the source string.
5028 ********************************************************************/
5030 static char *lp_string(const char *s)
5033 TALLOC_CTX *ctx = talloc_tos();
5035 /* The follow debug is useful for tracking down memory problems
5036 especially if you have an inner loop that is calling a lp_*()
5037 function that returns a string. Perhaps this debug should be
5038 present all the time? */
5041 DEBUG(10, ("lp_string(%s)\n", s));
5047 ret = talloc_sub_basic(ctx,
5048 get_current_username(),
5049 current_user_info.domain,
5051 if (trim_char(ret, '\"', '\"')) {
5052 if (strchr(ret,'\"') != NULL) {
5054 ret = talloc_sub_basic(ctx,
5055 get_current_username(),
5056 current_user_info.domain,
5064 In this section all the functions that are used to access the
5065 parameters from the rest of the program are defined
5068 #define FN_GLOBAL_STRING(fn_name,ptr) \
5069 char *fn_name(void) {return(lp_string(*(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : ""));}
5070 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5071 const char *fn_name(void) {return(*(const char **)(&Globals.ptr) ? *(const char **)(&Globals.ptr) : "");}
5072 #define FN_GLOBAL_LIST(fn_name,ptr) \
5073 const char **fn_name(void) {return(*(const char ***)(&Globals.ptr));}
5074 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5075 bool fn_name(void) {return(*(bool *)(&Globals.ptr));}
5076 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5077 char fn_name(void) {return(*(char *)(&Globals.ptr));}
5078 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5079 int fn_name(void) {return(*(int *)(&Globals.ptr));}
5081 #define FN_LOCAL_STRING(fn_name,val) \
5082 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5083 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5084 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5085 #define FN_LOCAL_LIST(fn_name,val) \
5086 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5087 #define FN_LOCAL_BOOL(fn_name,val) \
5088 bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5089 #define FN_LOCAL_INTEGER(fn_name,val) \
5090 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5092 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5093 bool fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5094 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5095 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5096 #define FN_LOCAL_CHAR(fn_name,val) \
5097 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5099 FN_GLOBAL_CONST_STRING(lp_smb_ports, smb_ports)
5100 FN_GLOBAL_CONST_STRING(lp_dos_charset, dos_charset)
5101 FN_GLOBAL_CONST_STRING(lp_unix_charset, unix_charset)
5102 FN_GLOBAL_STRING(lp_logfile, szLogFile)
5103 FN_GLOBAL_STRING(lp_configfile, szConfigFile)
5104 FN_GLOBAL_CONST_STRING(lp_smb_passwd_file, szSMBPasswdFile)
5105 FN_GLOBAL_CONST_STRING(lp_private_dir, szPrivateDir)
5106 FN_GLOBAL_STRING(lp_serverstring, szServerString)
5107 FN_GLOBAL_INTEGER(lp_printcap_cache_time, PrintcapCacheTime)
5108 FN_GLOBAL_STRING(lp_addport_cmd, szAddPortCommand)
5109 FN_GLOBAL_STRING(lp_enumports_cmd, szEnumPortsCommand)
5110 FN_GLOBAL_STRING(lp_addprinter_cmd, szAddPrinterCommand)
5111 FN_GLOBAL_STRING(lp_deleteprinter_cmd, szDeletePrinterCommand)
5112 FN_GLOBAL_STRING(lp_os2_driver_map, szOs2DriverMap)
5113 FN_GLOBAL_CONST_STRING(lp_lockdir, szLockDir)
5114 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5115 * build process or in smb.conf, we use that value. Otherwise they
5116 * default to the value of lp_lockdir(). */
5117 const char *lp_statedir(void) {
5118 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5119 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5120 return(*(char **)(&Globals.szStateDir) ?
5121 *(char **)(&Globals.szStateDir) : "");
5123 return(*(char **)(&Globals.szLockDir) ?
5124 *(char **)(&Globals.szLockDir) : "");
5126 const char *lp_cachedir(void) {
5127 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5128 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5129 return(*(char **)(&Globals.szCacheDir) ?
5130 *(char **)(&Globals.szCacheDir) : "");
5132 return(*(char **)(&Globals.szLockDir) ?
5133 *(char **)(&Globals.szLockDir) : "");
5135 FN_GLOBAL_CONST_STRING(lp_piddir, szPidDir)
5136 FN_GLOBAL_STRING(lp_mangling_method, szManglingMethod)
5137 FN_GLOBAL_INTEGER(lp_mangle_prefix, mangle_prefix)
5138 FN_GLOBAL_CONST_STRING(lp_utmpdir, szUtmpDir)
5139 FN_GLOBAL_CONST_STRING(lp_wtmpdir, szWtmpDir)
5140 FN_GLOBAL_BOOL(lp_utmp, bUtmp)
5141 FN_GLOBAL_STRING(lp_rootdir, szRootdir)
5142 FN_GLOBAL_STRING(lp_perfcount_module, szSMBPerfcountModule)
5143 FN_GLOBAL_STRING(lp_defaultservice, szDefaultService)
5144 FN_GLOBAL_STRING(lp_msg_command, szMsgCommand)
5145 FN_GLOBAL_STRING(lp_get_quota_command, szGetQuota)
5146 FN_GLOBAL_STRING(lp_set_quota_command, szSetQuota)
5147 FN_GLOBAL_STRING(lp_auto_services, szAutoServices)
5148 FN_GLOBAL_STRING(lp_passwd_program, szPasswdProgram)
5149 FN_GLOBAL_STRING(lp_passwd_chat, szPasswdChat)
5150 FN_GLOBAL_CONST_STRING(lp_passwordserver, szPasswordServer)
5151 FN_GLOBAL_CONST_STRING(lp_name_resolve_order, szNameResolveOrder)
5152 FN_GLOBAL_CONST_STRING(lp_workgroup, szWorkgroup)
5153 FN_GLOBAL_CONST_STRING(lp_netbios_name, szNetbiosName)
5154 FN_GLOBAL_CONST_STRING(lp_netbios_scope, szNetbiosScope)
5155 FN_GLOBAL_CONST_STRING(lp_realm, szRealmUpper)
5156 FN_GLOBAL_CONST_STRING(lp_dnsdomain, szDnsDomain)
5157 FN_GLOBAL_CONST_STRING(lp_afs_username_map, szAfsUsernameMap)
5158 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, iAfsTokenLifetime)
5159 FN_GLOBAL_STRING(lp_log_nt_token_command, szLogNtTokenCommand)
5160 FN_GLOBAL_STRING(lp_username_map, szUsernameMap)
5161 FN_GLOBAL_CONST_STRING(lp_logon_script, szLogonScript)
5162 FN_GLOBAL_CONST_STRING(lp_logon_path, szLogonPath)
5163 FN_GLOBAL_CONST_STRING(lp_logon_drive, szLogonDrive)
5164 FN_GLOBAL_CONST_STRING(lp_logon_home, szLogonHome)
5165 FN_GLOBAL_STRING(lp_remote_announce, szRemoteAnnounce)
5166 FN_GLOBAL_STRING(lp_remote_browse_sync, szRemoteBrowseSync)
5167 FN_GLOBAL_BOOL(lp_nmbd_bind_explicit_broadcast, bNmbdBindExplicitBroadcast)
5168 FN_GLOBAL_LIST(lp_wins_server_list, szWINSservers)
5169 FN_GLOBAL_LIST(lp_interfaces, szInterfaces)
5170 FN_GLOBAL_STRING(lp_nis_home_map_name, szNISHomeMapName)
5171 FN_GLOBAL_LIST(lp_netbios_aliases, szNetbiosAliases)
5172 FN_GLOBAL_CONST_STRING(lp_passdb_backend, szPassdbBackend)
5173 FN_GLOBAL_LIST(lp_preload_modules, szPreloadModules)
5174 FN_GLOBAL_STRING(lp_panic_action, szPanicAction)
5175 FN_GLOBAL_STRING(lp_adduser_script, szAddUserScript)
5176 FN_GLOBAL_STRING(lp_renameuser_script, szRenameUserScript)
5177 FN_GLOBAL_STRING(lp_deluser_script, szDelUserScript)
5179 FN_GLOBAL_CONST_STRING(lp_guestaccount, szGuestaccount)
5180 FN_GLOBAL_STRING(lp_addgroup_script, szAddGroupScript)
5181 FN_GLOBAL_STRING(lp_delgroup_script, szDelGroupScript)
5182 FN_GLOBAL_STRING(lp_addusertogroup_script, szAddUserToGroupScript)
5183 FN_GLOBAL_STRING(lp_deluserfromgroup_script, szDelUserFromGroupScript)
5184 FN_GLOBAL_STRING(lp_setprimarygroup_script, szSetPrimaryGroupScript)
5186 FN_GLOBAL_STRING(lp_addmachine_script, szAddMachineScript)
5188 FN_GLOBAL_STRING(lp_shutdown_script, szShutdownScript)
5189 FN_GLOBAL_STRING(lp_abort_shutdown_script, szAbortShutdownScript)
5190 FN_GLOBAL_STRING(lp_username_map_script, szUsernameMapScript)
5191 FN_GLOBAL_INTEGER(lp_username_map_cache_time, iUsernameMapCacheTime)
5193 FN_GLOBAL_STRING(lp_check_password_script, szCheckPasswordScript)
5195 FN_GLOBAL_STRING(lp_wins_hook, szWINSHook)
5196 FN_GLOBAL_CONST_STRING(lp_template_homedir, szTemplateHomedir)
5197 FN_GLOBAL_CONST_STRING(lp_template_shell, szTemplateShell)
5198 FN_GLOBAL_CONST_STRING(lp_winbind_separator, szWinbindSeparator)
5199 FN_GLOBAL_INTEGER(lp_acl_compatibility, iAclCompat)
5200 FN_GLOBAL_BOOL(lp_winbind_enum_users, bWinbindEnumUsers)
5201 FN_GLOBAL_BOOL(lp_winbind_enum_groups, bWinbindEnumGroups)
5202 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, bWinbindUseDefaultDomain)
5203 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, bWinbindTrustedDomainsOnly)
5204 FN_GLOBAL_BOOL(lp_winbind_nested_groups, bWinbindNestedGroups)
5205 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, winbind_expand_groups)
5206 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, bWinbindRefreshTickets)
5207 FN_GLOBAL_BOOL(lp_winbind_offline_logon, bWinbindOfflineLogon)
5208 FN_GLOBAL_BOOL(lp_winbind_normalize_names, bWinbindNormalizeNames)
5209 FN_GLOBAL_BOOL(lp_winbind_rpc_only, bWinbindRpcOnly)
5210 FN_GLOBAL_BOOL(lp_create_krb5_conf, bCreateKrb5Conf)
5211 static FN_GLOBAL_INTEGER(lp_winbind_max_domain_connections_int,
5212 winbindMaxDomainConnections)
5214 int lp_winbind_max_domain_connections(void)
5216 if (lp_winbind_offline_logon() &&
5217 lp_winbind_max_domain_connections_int() > 1) {
5218 DEBUG(1, ("offline logons active, restricting max domain "
5219 "connections to 1\n"));
5222 return MAX(1, lp_winbind_max_domain_connections_int());
5225 FN_GLOBAL_CONST_STRING(lp_idmap_backend, szIdmapBackend)
5226 FN_GLOBAL_INTEGER(lp_idmap_cache_time, iIdmapCacheTime)
5227 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, iIdmapNegativeCacheTime)
5228 FN_GLOBAL_INTEGER(lp_keepalive, iKeepalive)
5229 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, bPassdbExpandExplicit)
5231 FN_GLOBAL_STRING(lp_ldap_suffix, szLdapSuffix)
5232 FN_GLOBAL_STRING(lp_ldap_admin_dn, szLdapAdminDn)
5233 FN_GLOBAL_INTEGER(lp_ldap_ssl, ldap_ssl)
5234 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, ldap_ssl_ads)
5235 FN_GLOBAL_INTEGER(lp_ldap_deref, ldap_deref)
5236 FN_GLOBAL_INTEGER(lp_ldap_follow_referral, ldap_follow_referral)
5237 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, ldap_passwd_sync)
5238 FN_GLOBAL_BOOL(lp_ldap_delete_dn, ldap_delete_dn)
5239 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, ldap_replication_sleep)
5240 FN_GLOBAL_INTEGER(lp_ldap_timeout, ldap_timeout)
5241 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, ldap_connection_timeout)
5242 FN_GLOBAL_INTEGER(lp_ldap_page_size, ldap_page_size)
5243 FN_GLOBAL_INTEGER(lp_ldap_debug_level, ldap_debug_level)
5244 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, ldap_debug_threshold)
5245 FN_GLOBAL_STRING(lp_add_share_cmd, szAddShareCommand)
5246 FN_GLOBAL_STRING(lp_change_share_cmd, szChangeShareCommand)
5247 FN_GLOBAL_STRING(lp_delete_share_cmd, szDeleteShareCommand)
5248 FN_GLOBAL_STRING(lp_usershare_path, szUsersharePath)
5249 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, szUsersharePrefixAllowList)
5250 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, szUsersharePrefixDenyList)
5252 FN_GLOBAL_LIST(lp_eventlog_list, szEventLogs)
5254 FN_GLOBAL_BOOL(lp_registry_shares, bRegistryShares)
5255 FN_GLOBAL_BOOL(lp_usershare_allow_guests, bUsershareAllowGuests)
5256 FN_GLOBAL_BOOL(lp_usershare_owner_only, bUsershareOwnerOnly)
5257 FN_GLOBAL_BOOL(lp_disable_netbios, bDisableNetbios)
5258 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, bResetOnZeroVC)
5259 FN_GLOBAL_BOOL(lp_log_writeable_files_on_exit, bLogWriteableFilesOnExit)
5260 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, bMsAddPrinterWizard)
5261 FN_GLOBAL_BOOL(lp_dns_proxy, bDNSproxy)
5262 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, bWINSsupport)
5263 FN_GLOBAL_BOOL(lp_wins_proxy, bWINSproxy)
5264 FN_GLOBAL_BOOL(lp_local_master, bLocalMaster)
5265 FN_GLOBAL_BOOL(lp_domain_logons, bDomainLogons)
5266 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, szInitLogonDelayedHosts)
5267 FN_GLOBAL_INTEGER(lp_init_logon_delay, InitLogonDelay)
5268 FN_GLOBAL_BOOL(lp_load_printers, bLoadPrinters)
5269 FN_GLOBAL_BOOL(_lp_readraw, bReadRaw)
5270 FN_GLOBAL_BOOL(lp_large_readwrite, bLargeReadwrite)
5271 FN_GLOBAL_BOOL(_lp_writeraw, bWriteRaw)
5272 FN_GLOBAL_BOOL(lp_null_passwords, bNullPasswords)
5273 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, bObeyPamRestrictions)
5274 FN_GLOBAL_BOOL(lp_encrypted_passwords, bEncryptPasswords)
5275 FN_GLOBAL_INTEGER(lp_client_schannel, clientSchannel)
5276 FN_GLOBAL_INTEGER(lp_server_schannel, serverSchannel)
5277 FN_GLOBAL_BOOL(lp_syslog_only, bSyslogOnly)
5278 FN_GLOBAL_BOOL(lp_timestamp_logs, bTimestampLogs)
5279 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, bDebugPrefixTimestamp)
5280 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, bDebugHiresTimestamp)
5281 FN_GLOBAL_BOOL(lp_debug_pid, bDebugPid)
5282 FN_GLOBAL_BOOL(lp_debug_uid, bDebugUid)
5283 FN_GLOBAL_BOOL(lp_debug_class, bDebugClass)
5284 FN_GLOBAL_BOOL(lp_enable_core_files, bEnableCoreFiles)
5285 FN_GLOBAL_BOOL(lp_browse_list, bBrowseList)
5286 FN_GLOBAL_BOOL(lp_nis_home_map, bNISHomeMap)
5287 static FN_GLOBAL_BOOL(lp_time_server, bTimeServer)
5288 FN_GLOBAL_BOOL(lp_bind_interfaces_only, bBindInterfacesOnly)
5289 FN_GLOBAL_BOOL(lp_pam_password_change, bPamPasswordChange)
5290 FN_GLOBAL_BOOL(lp_unix_password_sync, bUnixPasswdSync)
5291 FN_GLOBAL_BOOL(lp_passwd_chat_debug, bPasswdChatDebug)
5292 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, iPasswdChatTimeout)
5293 FN_GLOBAL_BOOL(lp_nt_pipe_support, bNTPipeSupport)
5294 FN_GLOBAL_BOOL(lp_nt_status_support, bNTStatusSupport)
5295 FN_GLOBAL_BOOL(lp_stat_cache, bStatCache)
5296 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, iMaxStatCacheSize)
5297 FN_GLOBAL_BOOL(lp_allow_trusted_domains, bAllowTrustedDomains)
5298 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, bMapUntrustedToDomain)
5299 FN_GLOBAL_INTEGER(lp_restrict_anonymous, restrict_anonymous)
5300 FN_GLOBAL_BOOL(lp_lanman_auth, bLanmanAuth)
5301 FN_GLOBAL_BOOL(lp_ntlm_auth, bNTLMAuth)
5302 FN_GLOBAL_BOOL(lp_client_plaintext_auth, bClientPlaintextAuth)
5303 FN_GLOBAL_BOOL(lp_client_lanman_auth, bClientLanManAuth)
5304 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, bClientNTLMv2Auth)
5305 FN_GLOBAL_BOOL(lp_host_msdfs, bHostMSDfs)
5306 FN_GLOBAL_BOOL(lp_kernel_oplocks, bKernelOplocks)
5307 FN_GLOBAL_BOOL(lp_enhanced_browsing, enhanced_browsing)
5308 FN_GLOBAL_BOOL(lp_use_mmap, bUseMmap)
5309 FN_GLOBAL_BOOL(lp_unix_extensions, bUnixExtensions)
5310 FN_GLOBAL_BOOL(lp_use_spnego, bUseSpnego)
5311 FN_GLOBAL_BOOL(lp_client_use_spnego, bClientUseSpnego)
5312 FN_GLOBAL_BOOL(lp_client_use_spnego_principal, client_use_spnego_principal)
5313 FN_GLOBAL_BOOL(lp_send_spnego_principal, send_spnego_principal)
5314 FN_GLOBAL_BOOL(lp_hostname_lookups, bHostnameLookups)
5315 FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
5316 FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
5317 FN_GLOBAL_CONST_STRING(lp_dedicated_keytab_file, szDedicatedKeytabFile)
5318 FN_GLOBAL_INTEGER(lp_kerberos_method, iKerberosMethod)
5319 FN_GLOBAL_BOOL(lp_defer_sharing_violations, bDeferSharingViolations)
5320 FN_GLOBAL_BOOL(lp_enable_privileges, bEnablePrivileges)
5321 FN_GLOBAL_BOOL(lp_enable_asu_support, bASUSupport)
5322 FN_GLOBAL_INTEGER(lp_os_level, os_level)
5323 FN_GLOBAL_INTEGER(lp_max_ttl, max_ttl)
5324 FN_GLOBAL_INTEGER(lp_max_wins_ttl, max_wins_ttl)
5325 FN_GLOBAL_INTEGER(lp_min_wins_ttl, min_wins_ttl)
5326 FN_GLOBAL_INTEGER(lp_max_log_size, max_log_size)
5327 FN_GLOBAL_INTEGER(lp_max_open_files, max_open_files)
5328 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, open_files_db_hash_size)
5329 FN_GLOBAL_INTEGER(lp_maxxmit, max_xmit)
5330 FN_GLOBAL_INTEGER(lp_maxmux, max_mux)
5331 FN_GLOBAL_INTEGER(lp_passwordlevel, pwordlevel)
5332 FN_GLOBAL_INTEGER(lp_usernamelevel, unamelevel)
5333 FN_GLOBAL_INTEGER(lp_deadtime, deadtime)
5334 FN_GLOBAL_BOOL(lp_getwd_cache, getwd_cache)
5335 static FN_GLOBAL_INTEGER(_lp_maxprotocol, maxprotocol)
5336 int lp_maxprotocol(void)
5338 int ret = _lp_maxprotocol();
5339 if ((ret == PROTOCOL_SMB2) && (lp_security() == SEC_SHARE)) {
5340 DEBUG(2,("WARNING!!: \"security = share\" is incompatible "
5341 "with the SMB2 protocol. Resetting to SMB1.\n" ));
5342 lp_do_parameter(-1, "max protocol", "NT1");
5343 return PROTOCOL_NT1;
5347 FN_GLOBAL_INTEGER(lp_minprotocol, minprotocol)
5348 FN_GLOBAL_INTEGER(lp_security, security)
5349 FN_GLOBAL_LIST(lp_auth_methods, AuthMethods)
5350 FN_GLOBAL_BOOL(lp_paranoid_server_security, paranoid_server_security)
5351 FN_GLOBAL_INTEGER(lp_maxdisksize, maxdisksize)
5352 FN_GLOBAL_INTEGER(lp_lpqcachetime, lpqcachetime)
5353 FN_GLOBAL_INTEGER(lp_max_smbd_processes, iMaxSmbdProcesses)
5354 FN_GLOBAL_BOOL(_lp_disable_spoolss, bDisableSpoolss)
5355 FN_GLOBAL_INTEGER(lp_syslog, syslog)
5356 FN_GLOBAL_INTEGER(lp_lm_announce, lm_announce)
5357 FN_GLOBAL_INTEGER(lp_lm_interval, lm_interval)
5358 FN_GLOBAL_INTEGER(lp_machine_password_timeout, machine_password_timeout)
5359 FN_GLOBAL_INTEGER(lp_map_to_guest, map_to_guest)
5360 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, oplock_break_wait_time)
5361 FN_GLOBAL_INTEGER(lp_lock_spin_time, iLockSpinTime)
5362 FN_GLOBAL_INTEGER(lp_usershare_max_shares, iUsershareMaxShares)
5363 FN_GLOBAL_CONST_STRING(lp_socket_options, szSocketOptions)
5364 FN_GLOBAL_INTEGER(lp_config_backend, ConfigBackend)
5365 FN_GLOBAL_INTEGER(lp_smb2_max_read, ismb2_max_read)
5366 FN_GLOBAL_INTEGER(lp_smb2_max_write, ismb2_max_write)
5367 FN_GLOBAL_INTEGER(lp_smb2_max_trans, ismb2_max_trans)
5368 int lp_smb2_max_credits(void)
5370 if (Globals.ismb2_max_credits == 0) {
5371 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5373 return Globals.ismb2_max_credits;
5375 FN_LOCAL_STRING(lp_preexec, szPreExec)
5376 FN_LOCAL_STRING(lp_postexec, szPostExec)
5377 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
5378 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
5379 FN_LOCAL_STRING(lp_servicename, szService)
5380 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
5381 FN_LOCAL_STRING(lp_pathname, szPath)
5382 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
5383 FN_LOCAL_STRING(lp_username, szUsername)
5384 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
5385 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
5386 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
5387 FN_GLOBAL_LIST(lp_svcctl_list, szServicesList)
5388 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
5389 FN_GLOBAL_STRING(lp_cups_server, szCupsServer)
5390 int lp_cups_encrypt(void)
5393 #ifdef HAVE_HTTPCONNECTENCRYPT
5394 switch (Globals.CupsEncrypt) {
5396 result = HTTP_ENCRYPT_REQUIRED;
5399 result = HTTP_ENCRYPT_ALWAYS;
5402 result = HTTP_ENCRYPT_NEVER;
5408 FN_GLOBAL_STRING(lp_iprint_server, szIPrintServer)
5409 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, cups_connection_timeout)
5410 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, ctdbdSocket)
5411 FN_GLOBAL_LIST(lp_cluster_addresses, szClusterAddresses)
5412 FN_GLOBAL_BOOL(lp_clustering, clustering)
5413 FN_GLOBAL_INTEGER(lp_ctdb_timeout, ctdb_timeout)
5414 FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, ctdb_locktime_warn_threshold)
5415 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
5416 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
5417 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
5418 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
5419 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
5420 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
5421 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
5422 static FN_LOCAL_STRING(_lp_printername, szPrintername)
5423 FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
5424 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
5425 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
5426 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
5427 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
5428 FN_LOCAL_STRING(lp_comment, comment)
5429 FN_LOCAL_STRING(lp_force_user, force_user)
5430 FN_LOCAL_STRING(lp_force_group, force_group)
5431 FN_LOCAL_LIST(lp_readlist, readlist)
5432 FN_LOCAL_LIST(lp_writelist, writelist)
5433 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
5434 FN_LOCAL_STRING(lp_fstype, fstype)
5435 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
5436 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
5437 static FN_LOCAL_STRING(lp_volume, volume)
5438 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
5439 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
5440 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
5441 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
5442 FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
5443 FN_LOCAL_STRING(lp_dfree_command, szDfree)
5444 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
5445 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
5446 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
5447 FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
5448 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
5449 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
5450 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
5451 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
5452 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
5453 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
5454 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
5455 FN_LOCAL_BOOL(lp_access_based_share_enum, bAccessBasedShareEnum)
5456 FN_LOCAL_BOOL(lp_readonly, bRead_only)
5457 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
5458 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
5459 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
5460 FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
5461 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
5462 FN_LOCAL_BOOL(lp_print_notify_backchannel, bPrintNotifyBackchannel)
5463 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
5464 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
5465 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
5466 FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
5467 FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
5468 FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
5469 FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
5470 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
5471 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
5472 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
5473 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
5474 FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames)
5475 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
5476 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
5477 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
5478 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
5479 FN_LOCAL_BOOL(lp_map_system, bMap_system)
5480 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
5481 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
5482 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
5483 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
5484 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
5485 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
5486 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
5487 FN_GLOBAL_BOOL(lp_async_smb_echo_handler, bAsyncSMBEchoHandler)
5488 FN_GLOBAL_BOOL(lp_multicast_dns_register, bMulticastDnsRegister)
5489 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
5490 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
5491 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
5492 FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
5493 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
5494 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
5495 FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
5496 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
5497 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
5498 FN_LOCAL_BOOL(lp_ea_support, bEASupport)
5499 FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
5500 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
5501 FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
5502 FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
5503 FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
5504 FN_LOCAL_BOOL(lp_acl_group_control, bAclGroupControl)
5505 FN_LOCAL_BOOL(lp_acl_map_full_control, bAclMapFullControl)
5506 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
5507 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
5508 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
5509 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
5510 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
5511 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
5512 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
5513 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
5514 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
5515 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
5516 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
5517 FN_LOCAL_INTEGER(lp_printing, iPrinting)
5518 FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
5519 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
5520 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
5521 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
5522 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
5523 FN_LOCAL_INTEGER(lp_dfree_cache_time, iDfreeCacheTime)
5524 FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
5525 FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
5526 FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
5527 FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
5528 FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
5529 FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
5530 FN_LOCAL_CHAR(lp_magicchar, magic_char)
5531 FN_GLOBAL_INTEGER(lp_winbind_cache_time, winbind_cache_time)
5532 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, winbind_reconnect_delay)
5533 FN_GLOBAL_INTEGER(lp_winbind_max_clients, winbind_max_clients)
5534 FN_GLOBAL_LIST(lp_winbind_nss_info, szWinbindNssInfo)
5535 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, AlgorithmicRidBase)
5536 FN_GLOBAL_INTEGER(lp_name_cache_timeout, name_cache_timeout)
5537 FN_GLOBAL_INTEGER(lp_client_signing, client_signing)
5538 FN_GLOBAL_INTEGER(lp_server_signing, server_signing)
5539 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, client_ldap_sasl_wrapping)
5541 FN_GLOBAL_CONST_STRING(lp_ncalrpc_dir, ncalrpc_dir)
5543 /* local prototypes */
5545 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5546 static const char *get_boolean(bool bool_value);
5547 static int getservicebyname(const char *pszServiceName,
5548 struct loadparm_service *pserviceDest);
5549 static void copy_service(struct loadparm_service *pserviceDest,
5550 struct loadparm_service *pserviceSource,
5551 struct bitmap *pcopymapDest);
5552 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5554 static bool do_section(const char *pszSectionName, void *userdata);
5555 static void init_copymap(struct loadparm_service *pservice);
5556 static bool hash_a_service(const char *name, int number);
5557 static void free_service_byindex(int iService);
5558 static void free_param_opts(struct parmlist_entry **popts);
5559 static void show_parameter(int parmIndex);
5560 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5563 * This is a helper function for parametrical options support. It returns a
5564 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5565 * parametrical functions are quite simple
5567 static struct parmlist_entry *get_parametrics_by_service(struct loadparm_service *service, const char *type,
5570 bool global_section = false;
5572 struct parmlist_entry *data;
5574 if (service == NULL) {
5575 data = Globals.param_opt;
5576 global_section = true;
5578 data = service->param_opt;
5581 if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
5582 DEBUG(0,("asprintf failed!\n"));
5587 if (strwicmp(data->key, param_key) == 0) {
5588 string_free(¶m_key);
5594 if (!global_section) {
5595 /* Try to fetch the same option but from globals */
5596 /* but only if we are not already working with Globals */
5597 data = Globals.param_opt;
5599 if (strwicmp(data->key, param_key) == 0) {
5600 string_free(¶m_key);
5607 string_free(¶m_key);
5613 * This is a helper function for parametrical options support. It returns a
5614 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5615 * parametrical functions are quite simple
5617 static struct parmlist_entry *get_parametrics(int snum, const char *type,
5620 if (snum >= iNumServices) return NULL;
5623 return get_parametrics_by_service(NULL, type, option);
5625 return get_parametrics_by_service(ServicePtrs[snum], type, option);
5630 #define MISSING_PARAMETER(name) \
5631 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5633 /*******************************************************************
5634 convenience routine to return int parameters.
5635 ********************************************************************/
5636 static int lp_int(const char *s)
5640 MISSING_PARAMETER(lp_int);
5644 return (int)strtol(s, NULL, 0);
5647 /*******************************************************************
5648 convenience routine to return unsigned long parameters.
5649 ********************************************************************/
5650 static unsigned long lp_ulong(const char *s)
5654 MISSING_PARAMETER(lp_ulong);
5658 return strtoul(s, NULL, 0);
5661 /*******************************************************************
5662 convenience routine to return boolean parameters.
5663 ********************************************************************/
5664 static bool lp_bool(const char *s)
5669 MISSING_PARAMETER(lp_bool);
5673 if (!set_boolean(s, &ret)) {
5674 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5681 /*******************************************************************
5682 convenience routine to return enum parameters.
5683 ********************************************************************/
5684 static int lp_enum(const char *s,const struct enum_list *_enum)
5688 if (!s || !*s || !_enum) {
5689 MISSING_PARAMETER(lp_enum);
5693 for (i=0; _enum[i].name; i++) {
5694 if (strequal(_enum[i].name,s))
5695 return _enum[i].value;
5698 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5702 #undef MISSING_PARAMETER
5704 /* Return parametric option from a given service. Type is a part of option before ':' */
5705 /* Parametric option has following syntax: 'Type: option = value' */
5706 /* the returned value is talloced on the talloc_tos() */
5707 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5709 struct parmlist_entry *data = get_parametrics(snum, type, option);
5711 if (data == NULL||data->value==NULL) {
5713 return lp_string(def);
5719 return lp_string(data->value);
5722 /* Return parametric option from a given service. Type is a part of option before ':' */
5723 /* Parametric option has following syntax: 'Type: option = value' */
5724 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5726 struct parmlist_entry *data = get_parametrics(snum, type, option);
5728 if (data == NULL||data->value==NULL)
5734 const char *lp_parm_const_string_service(struct loadparm_service *service, const char *type, const char *option)
5736 struct parmlist_entry *data = get_parametrics_by_service(service, type, option);
5738 if (data == NULL||data->value==NULL)
5745 /* Return parametric option from a given service. Type is a part of option before ':' */
5746 /* Parametric option has following syntax: 'Type: option = value' */
5748 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5750 struct parmlist_entry *data = get_parametrics(snum, type, option);
5752 if (data == NULL||data->value==NULL)
5753 return (const char **)def;
5755 if (data->list==NULL) {
5756 data->list = str_list_make_v3(NULL, data->value, NULL);
5759 return (const char **)data->list;
5762 /* Return parametric option from a given service. Type is a part of option before ':' */
5763 /* Parametric option has following syntax: 'Type: option = value' */
5765 int lp_parm_int(int snum, const char *type, const char *option, int def)
5767 struct parmlist_entry *data = get_parametrics(snum, type, option);
5769 if (data && data->value && *data->value)
5770 return lp_int(data->value);
5775 /* Return parametric option from a given service. Type is a part of option before ':' */
5776 /* Parametric option has following syntax: 'Type: option = value' */
5778 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5780 struct parmlist_entry *data = get_parametrics(snum, type, option);
5782 if (data && data->value && *data->value)
5783 return lp_ulong(data->value);
5788 /* Return parametric option from a given service. Type is a part of option before ':' */
5789 /* Parametric option has following syntax: 'Type: option = value' */
5791 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5793 struct parmlist_entry *data = get_parametrics(snum, type, option);
5795 if (data && data->value && *data->value)
5796 return lp_bool(data->value);
5801 /* Return parametric option from a given service. Type is a part of option before ':' */
5802 /* Parametric option has following syntax: 'Type: option = value' */
5804 int lp_parm_enum(int snum, const char *type, const char *option,
5805 const struct enum_list *_enum, int def)
5807 struct parmlist_entry *data = get_parametrics(snum, type, option);
5809 if (data && data->value && *data->value && _enum)
5810 return lp_enum(data->value, _enum);
5816 /***************************************************************************
5817 Initialise a service to the defaults.
5818 ***************************************************************************/
5820 static void init_service(struct loadparm_service *pservice)
5822 memset((char *)pservice, '\0', sizeof(struct loadparm_service));
5823 copy_service(pservice, &sDefault, NULL);
5828 * free a param_opts structure.
5829 * param_opts handling should be moved to talloc;
5830 * then this whole functions reduces to a TALLOC_FREE().
5833 static void free_param_opts(struct parmlist_entry **popts)
5835 struct parmlist_entry *opt, *next_opt;
5837 if (popts == NULL) {
5841 if (*popts != NULL) {
5842 DEBUG(5, ("Freeing parametrics:\n"));
5845 while (opt != NULL) {
5846 string_free(&opt->key);
5847 string_free(&opt->value);
5848 TALLOC_FREE(opt->list);
5849 next_opt = opt->next;
5856 /***************************************************************************
5857 Free the dynamically allocated parts of a service struct.
5858 ***************************************************************************/
5860 static void free_service(struct loadparm_service *pservice)
5865 if (pservice->szService)
5866 DEBUG(5, ("free_service: Freeing service %s\n",
5867 pservice->szService));
5869 free_parameters(pservice);
5871 string_free(&pservice->szService);
5872 TALLOC_FREE(pservice->copymap);
5874 free_param_opts(&pservice->param_opt);
5876 ZERO_STRUCTP(pservice);
5880 /***************************************************************************
5881 remove a service indexed in the ServicePtrs array from the ServiceHash
5882 and free the dynamically allocated parts
5883 ***************************************************************************/
5885 static void free_service_byindex(int idx)
5887 if ( !LP_SNUM_OK(idx) )
5890 ServicePtrs[idx]->valid = false;
5891 invalid_services[num_invalid_services++] = idx;
5893 /* we have to cleanup the hash record */
5895 if (ServicePtrs[idx]->szService) {
5896 char *canon_name = canonicalize_servicename(
5898 ServicePtrs[idx]->szService );
5900 dbwrap_delete_bystring(ServiceHash, canon_name );
5901 TALLOC_FREE(canon_name);
5904 free_service(ServicePtrs[idx]);
5907 /***************************************************************************
5908 Add a new service to the services array initialising it with the given
5910 ***************************************************************************/
5912 static int add_a_service(const struct loadparm_service *pservice, const char *name)
5915 struct loadparm_service tservice;
5916 int num_to_alloc = iNumServices + 1;
5918 tservice = *pservice;
5920 /* it might already exist */
5922 i = getservicebyname(name, NULL);
5928 /* find an invalid one */
5930 if (num_invalid_services > 0) {
5931 i = invalid_services[--num_invalid_services];
5934 /* if not, then create one */
5935 if (i == iNumServices) {
5936 struct loadparm_service **tsp;
5939 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct loadparm_service *, num_to_alloc);
5941 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
5945 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct loadparm_service);
5946 if (!ServicePtrs[iNumServices]) {
5947 DEBUG(0,("add_a_service: out of memory!\n"));
5952 /* enlarge invalid_services here for now... */
5953 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
5955 if (tinvalid == NULL) {
5956 DEBUG(0,("add_a_service: failed to enlarge "
5957 "invalid_services!\n"));
5960 invalid_services = tinvalid;
5962 free_service_byindex(i);
5965 ServicePtrs[i]->valid = true;
5967 init_service(ServicePtrs[i]);
5968 copy_service(ServicePtrs[i], &tservice, NULL);
5970 string_set(&ServicePtrs[i]->szService, name);
5972 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
5973 i, ServicePtrs[i]->szService));
5975 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
5982 /***************************************************************************
5983 Convert a string to uppercase and remove whitespaces.
5984 ***************************************************************************/
5986 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
5991 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
5995 result = talloc_strdup(ctx, src);
5996 SMB_ASSERT(result != NULL);
6002 /***************************************************************************
6003 Add a name/index pair for the services array to the hash table.
6004 ***************************************************************************/
6006 static bool hash_a_service(const char *name, int idx)
6010 if ( !ServiceHash ) {
6011 DEBUG(10,("hash_a_service: creating servicehash\n"));
6012 ServiceHash = db_open_rbt(NULL);
6013 if ( !ServiceHash ) {
6014 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
6019 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
6022 canon_name = canonicalize_servicename(talloc_tos(), name );
6024 dbwrap_store_bystring(ServiceHash, canon_name,
6025 make_tdb_data((uint8 *)&idx, sizeof(idx)),
6028 TALLOC_FREE(canon_name);
6033 /***************************************************************************
6034 Add a new home service, with the specified home directory, defaults coming
6036 ***************************************************************************/
6038 bool lp_add_home(const char *pszHomename, int iDefaultService,
6039 const char *user, const char *pszHomedir)
6043 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
6044 pszHomedir[0] == '\0') {
6048 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
6053 if (!(*(ServicePtrs[iDefaultService]->szPath))
6054 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
6055 string_set(&ServicePtrs[i]->szPath, pszHomedir);
6058 if (!(*(ServicePtrs[i]->comment))) {
6059 char *comment = NULL;
6060 if (asprintf(&comment, "Home directory of %s", user) < 0) {
6063 string_set(&ServicePtrs[i]->comment, comment);
6067 /* set the browseable flag from the global default */
6069 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6070 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
6072 ServicePtrs[i]->autoloaded = true;
6074 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
6075 user, ServicePtrs[i]->szPath ));
6080 /***************************************************************************
6081 Add a new service, based on an old one.
6082 ***************************************************************************/
6084 int lp_add_service(const char *pszService, int iDefaultService)
6086 if (iDefaultService < 0) {
6087 return add_a_service(&sDefault, pszService);
6090 return (add_a_service(ServicePtrs[iDefaultService], pszService));
6093 /***************************************************************************
6094 Add the IPC service.
6095 ***************************************************************************/
6097 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
6099 char *comment = NULL;
6100 int i = add_a_service(&sDefault, ipc_name);
6105 if (asprintf(&comment, "IPC Service (%s)",
6106 Globals.szServerString) < 0) {
6110 string_set(&ServicePtrs[i]->szPath, tmpdir());
6111 string_set(&ServicePtrs[i]->szUsername, "");
6112 string_set(&ServicePtrs[i]->comment, comment);
6113 string_set(&ServicePtrs[i]->fstype, "IPC");
6114 ServicePtrs[i]->iMaxConnections = 0;
6115 ServicePtrs[i]->bAvailable = true;
6116 ServicePtrs[i]->bRead_only = true;
6117 ServicePtrs[i]->bGuest_only = false;
6118 ServicePtrs[i]->bAdministrative_share = true;
6119 ServicePtrs[i]->bGuest_ok = guest_ok;
6120 ServicePtrs[i]->bPrint_ok = false;
6121 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6123 DEBUG(3, ("adding IPC service\n"));
6129 /***************************************************************************
6130 Add a new printer service, with defaults coming from service iFrom.
6131 ***************************************************************************/
6133 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
6135 const char *comment = "From Printcap";
6136 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6141 /* note that we do NOT default the availability flag to true - */
6142 /* we take it from the default service passed. This allows all */
6143 /* dynamic printers to be disabled by disabling the [printers] */
6144 /* entry (if/when the 'available' keyword is implemented!). */
6146 /* the printer name is set to the service name. */
6147 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6148 string_set(&ServicePtrs[i]->comment, comment);
6150 /* set the browseable flag from the gloabl default */
6151 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6153 /* Printers cannot be read_only. */
6154 ServicePtrs[i]->bRead_only = false;
6155 /* No share modes on printer services. */
6156 ServicePtrs[i]->bShareModes = false;
6157 /* No oplocks on printer services. */
6158 ServicePtrs[i]->bOpLocks = false;
6159 /* Printer services must be printable. */
6160 ServicePtrs[i]->bPrint_ok = true;
6162 DEBUG(3, ("adding printer service %s\n", pszPrintername));
6168 /***************************************************************************
6169 Check whether the given parameter name is valid.
6170 Parametric options (names containing a colon) are considered valid.
6171 ***************************************************************************/
6173 bool lp_parameter_is_valid(const char *pszParmName)
6175 return ((map_parameter(pszParmName) != -1) ||
6176 (strchr(pszParmName, ':') != NULL));
6179 /***************************************************************************
6180 Check whether the given name is the name of a global parameter.
6181 Returns true for strings belonging to parameters of class
6182 P_GLOBAL, false for all other strings, also for parametric options
6183 and strings not belonging to any option.
6184 ***************************************************************************/
6186 bool lp_parameter_is_global(const char *pszParmName)
6188 int num = map_parameter(pszParmName);
6191 return (parm_table[num].p_class == P_GLOBAL);
6197 /**************************************************************************
6198 Check whether the given name is the canonical name of a parameter.
6199 Returns false if it is not a valid parameter Name.
6200 For parametric options, true is returned.
6201 **************************************************************************/
6203 bool lp_parameter_is_canonical(const char *parm_name)
6205 if (!lp_parameter_is_valid(parm_name)) {
6209 return (map_parameter(parm_name) ==
6210 map_parameter_canonical(parm_name, NULL));
6213 /**************************************************************************
6214 Determine the canonical name for a parameter.
6215 Indicate when it is an inverse (boolean) synonym instead of a
6217 **************************************************************************/
6219 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6224 if (!lp_parameter_is_valid(parm_name)) {
6229 num = map_parameter_canonical(parm_name, inverse);
6231 /* parametric option */
6232 *canon_parm = parm_name;
6234 *canon_parm = parm_table[num].label;
6241 /**************************************************************************
6242 Determine the canonical name for a parameter.
6243 Turn the value given into the inverse boolean expression when
6244 the synonym is an invers boolean synonym.
6246 Return true if parm_name is a valid parameter name and
6247 in case it is an invers boolean synonym, if the val string could
6248 successfully be converted to the reverse bool.
6249 Return false in all other cases.
6250 **************************************************************************/
6252 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6254 const char **canon_parm,
6255 const char **canon_val)
6260 if (!lp_parameter_is_valid(parm_name)) {
6266 num = map_parameter_canonical(parm_name, &inverse);
6268 /* parametric option */
6269 *canon_parm = parm_name;
6272 *canon_parm = parm_table[num].label;
6274 if (!lp_invert_boolean(val, canon_val)) {
6286 /***************************************************************************
6287 Map a parameter's string representation to something we can use.
6288 Returns false if the parameter string is not recognised, else TRUE.
6289 ***************************************************************************/
6291 static int map_parameter(const char *pszParmName)
6295 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6298 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6299 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6302 /* Warn only if it isn't parametric option */
6303 if (strchr(pszParmName, ':') == NULL)
6304 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6305 /* We do return 'fail' for parametric options as well because they are
6306 stored in different storage
6311 /***************************************************************************
6312 Map a parameter's string representation to the index of the canonical
6313 form of the parameter (it might be a synonym).
6314 Returns -1 if the parameter string is not recognised.
6315 ***************************************************************************/
6317 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6319 int parm_num, canon_num;
6320 bool loc_inverse = false;
6322 parm_num = map_parameter(pszParmName);
6323 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6324 /* invalid, parametric or no canidate for synonyms ... */
6328 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6329 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6330 parm_num = canon_num;
6336 if (inverse != NULL) {
6337 *inverse = loc_inverse;
6342 /***************************************************************************
6343 return true if parameter number parm1 is a synonym of parameter
6344 number parm2 (parm2 being the principal name).
6345 set inverse to true if parm1 is P_BOOLREV and parm2 is P_BOOL,
6347 ***************************************************************************/
6349 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6351 if ((parm_table[parm1].offset == parm_table[parm2].offset) &&
6352 (parm_table[parm1].p_class == parm_table[parm2].p_class) &&
6353 (parm_table[parm1].flags & FLAG_HIDE) &&
6354 !(parm_table[parm2].flags & FLAG_HIDE))
6356 if (inverse != NULL) {
6357 if ((parm_table[parm1].type == P_BOOLREV) &&
6358 (parm_table[parm2].type == P_BOOL))
6370 /***************************************************************************
6371 Show one parameter's name, type, [values,] and flags.
6372 (helper functions for show_parameter_list)
6373 ***************************************************************************/
6375 static void show_parameter(int parmIndex)
6377 int enumIndex, flagIndex;
6382 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6383 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6385 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6386 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6388 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6389 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6390 "FLAG_DEPRECATED", "FLAG_HIDE", NULL};
6392 printf("%s=%s", parm_table[parmIndex].label,
6393 type[parm_table[parmIndex].type]);
6394 if (parm_table[parmIndex].type == P_ENUM) {
6397 parm_table[parmIndex].enum_list[enumIndex].name;
6401 enumIndex ? "|" : "",
6402 parm_table[parmIndex].enum_list[enumIndex].name);
6407 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6408 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6411 flag_names[flagIndex]);
6416 /* output synonyms */
6418 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6419 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6420 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6421 parm_table[parmIndex2].label);
6422 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6424 printf(" (synonyms: ");
6429 printf("%s%s", parm_table[parmIndex2].label,
6430 inverse ? "[i]" : "");
6440 /***************************************************************************
6441 Show all parameter's name, type, [values,] and flags.
6442 ***************************************************************************/
6444 void show_parameter_list(void)
6446 int classIndex, parmIndex;
6447 const char *section_names[] = { "local", "global", NULL};
6449 for (classIndex=0; section_names[classIndex]; classIndex++) {
6450 printf("[%s]\n", section_names[classIndex]);
6451 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6452 if (parm_table[parmIndex].p_class == classIndex) {
6453 show_parameter(parmIndex);
6459 /***************************************************************************
6460 Check if a given string correctly represents a boolean value.
6461 ***************************************************************************/
6463 bool lp_string_is_valid_boolean(const char *parm_value)
6465 return set_boolean(parm_value, NULL);
6468 /***************************************************************************
6469 Get the standard string representation of a boolean value ("yes" or "no")
6470 ***************************************************************************/
6472 static const char *get_boolean(bool bool_value)
6474 static const char *yes_str = "yes";
6475 static const char *no_str = "no";
6477 return (bool_value ? yes_str : no_str);
6480 /***************************************************************************
6481 Provide the string of the negated boolean value associated to the boolean
6482 given as a string. Returns false if the passed string does not correctly
6483 represent a boolean.
6484 ***************************************************************************/
6486 bool lp_invert_boolean(const char *str, const char **inverse_str)
6490 if (!set_boolean(str, &val)) {
6494 *inverse_str = get_boolean(!val);
6498 /***************************************************************************
6499 Provide the canonical string representation of a boolean value given
6500 as a string. Return true on success, false if the string given does
6501 not correctly represent a boolean.
6502 ***************************************************************************/
6504 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6508 if (!set_boolean(str, &val)) {
6512 *canon_str = get_boolean(val);
6516 /***************************************************************************
6517 Find a service by name. Otherwise works like get_service.
6518 ***************************************************************************/
6520 static int getservicebyname(const char *pszServiceName, struct loadparm_service *pserviceDest)
6526 if (ServiceHash == NULL) {
6530 canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
6532 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
6534 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
6535 iService = *(int *)data.dptr;
6538 TALLOC_FREE(canon_name);
6540 if ((iService != -1) && (LP_SNUM_OK(iService))
6541 && (pserviceDest != NULL)) {
6542 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6548 /* Return a pointer to a service by name. Unlike getservicebyname, it does not copy the service */
6549 struct loadparm_service *lp_service(const char *pszServiceName)
6551 int iService = getservicebyname(pszServiceName, NULL);
6552 if (iService == -1 || !LP_SNUM_OK(iService)) {
6555 return ServicePtrs[iService];
6559 /***************************************************************************
6560 Copy a service structure to another.
6561 If pcopymapDest is NULL then copy all fields
6562 ***************************************************************************/
6565 * Add a parametric option to a parmlist_entry,
6566 * replacing old value, if already present.
6568 static void set_param_opt(struct parmlist_entry **opt_list,
6569 const char *opt_name,
6570 const char *opt_value,
6573 struct parmlist_entry *new_opt, *opt;
6576 if (opt_list == NULL) {
6583 /* Traverse destination */
6585 /* If we already have same option, override it */
6586 if (strwicmp(opt->key, opt_name) == 0) {
6587 if ((opt->priority & FLAG_CMDLINE) &&
6588 !(priority & FLAG_CMDLINE)) {
6589 /* it's been marked as not to be
6593 string_free(&opt->value);
6594 TALLOC_FREE(opt->list);
6595 opt->value = SMB_STRDUP(opt_value);
6596 opt->priority = priority;
6603 new_opt = SMB_XMALLOC_P(struct parmlist_entry);
6604 new_opt->key = SMB_STRDUP(opt_name);
6605 new_opt->value = SMB_STRDUP(opt_value);
6606 new_opt->list = NULL;
6607 new_opt->priority = priority;
6608 DLIST_ADD(*opt_list, new_opt);
6612 static void copy_service(struct loadparm_service *pserviceDest, struct loadparm_service *pserviceSource,
6613 struct bitmap *pcopymapDest)
6616 bool bcopyall = (pcopymapDest == NULL);
6617 struct parmlist_entry *data;
6619 for (i = 0; parm_table[i].label; i++)
6620 if (parm_table[i].p_class == P_LOCAL &&
6621 (bcopyall || bitmap_query(pcopymapDest,i))) {
6622 void *src_ptr = lp_parm_ptr(pserviceSource, &parm_table[i]);
6623 void *dest_ptr = lp_parm_ptr(pserviceDest, &parm_table[i]);
6625 switch (parm_table[i].type) {
6628 *(bool *)dest_ptr = *(bool *)src_ptr;
6634 *(int *)dest_ptr = *(int *)src_ptr;
6638 *(char *)dest_ptr = *(char *)src_ptr;
6642 string_set((char **)dest_ptr,
6648 char *upper_string = strupper_talloc(talloc_tos(),
6650 string_set((char **)dest_ptr,
6652 TALLOC_FREE(upper_string);
6656 TALLOC_FREE(*((char ***)dest_ptr));
6657 *((char ***)dest_ptr) = str_list_copy(NULL,
6658 *(const char ***)src_ptr);
6666 init_copymap(pserviceDest);
6667 if (pserviceSource->copymap)
6668 bitmap_copy(pserviceDest->copymap,
6669 pserviceSource->copymap);
6672 data = pserviceSource->param_opt;
6674 set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->priority);
6679 /***************************************************************************
6680 Check a service for consistency. Return false if the service is in any way
6681 incomplete or faulty, else true.
6682 ***************************************************************************/
6684 bool service_ok(int iService)
6689 if (ServicePtrs[iService]->szService[0] == '\0') {
6690 DEBUG(0, ("The following message indicates an internal error:\n"));
6691 DEBUG(0, ("No service name in service entry.\n"));
6695 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6696 /* I can't see why you'd want a non-printable printer service... */
6697 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6698 if (!ServicePtrs[iService]->bPrint_ok) {
6699 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6700 ServicePtrs[iService]->szService));
6701 ServicePtrs[iService]->bPrint_ok = true;
6703 /* [printers] service must also be non-browsable. */
6704 if (ServicePtrs[iService]->bBrowseable)
6705 ServicePtrs[iService]->bBrowseable = false;
6708 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6709 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6710 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6712 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6713 ServicePtrs[iService]->szService));
6714 ServicePtrs[iService]->bAvailable = false;
6717 /* If a service is flagged unavailable, log the fact at level 1. */
6718 if (!ServicePtrs[iService]->bAvailable)
6719 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6720 ServicePtrs[iService]->szService));
6725 static struct smbconf_ctx *lp_smbconf_ctx(void)
6728 static struct smbconf_ctx *conf_ctx = NULL;
6730 if (conf_ctx == NULL) {
6731 err = smbconf_init(NULL, &conf_ctx, "registry:");
6732 if (!SBC_ERROR_IS_OK(err)) {
6733 DEBUG(1, ("error initializing registry configuration: "
6734 "%s\n", sbcErrorString(err)));
6742 static bool process_smbconf_service(struct smbconf_service *service)
6747 if (service == NULL) {
6751 ret = do_section(service->name, NULL);
6755 for (count = 0; count < service->num_params; count++) {
6756 ret = do_parameter(service->param_names[count],
6757 service->param_values[count],
6763 if (iServiceIndex >= 0) {
6764 return service_ok(iServiceIndex);
6770 * load a service from registry and activate it
6772 bool process_registry_service(const char *service_name)
6775 struct smbconf_service *service = NULL;
6776 TALLOC_CTX *mem_ctx = talloc_stackframe();
6777 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6780 if (conf_ctx == NULL) {
6784 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6786 if (!smbconf_share_exists(conf_ctx, service_name)) {
6788 * Registry does not contain data for this service (yet),
6789 * but make sure lp_load doesn't return false.
6795 err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6796 if (!SBC_ERROR_IS_OK(err)) {
6800 ret = process_smbconf_service(service);
6806 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6809 TALLOC_FREE(mem_ctx);
6814 * process_registry_globals
6816 static bool process_registry_globals(void)
6820 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6822 ret = do_parameter("registry shares", "yes", NULL);
6827 return process_registry_service(GLOBAL_NAME);
6830 bool process_registry_shares(void)
6834 struct smbconf_service **service = NULL;
6835 uint32_t num_shares = 0;
6836 TALLOC_CTX *mem_ctx = talloc_stackframe();
6837 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6840 if (conf_ctx == NULL) {
6844 err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6845 if (!SBC_ERROR_IS_OK(err)) {
6851 for (count = 0; count < num_shares; count++) {
6852 if (strequal(service[count]->name, GLOBAL_NAME)) {
6855 ret = process_smbconf_service(service[count]);
6862 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6865 TALLOC_FREE(mem_ctx);
6869 #define MAX_INCLUDE_DEPTH 100
6871 static uint8_t include_depth;
6873 static struct file_lists {
6874 struct file_lists *next;
6878 } *file_lists = NULL;
6880 /*******************************************************************
6881 Keep a linked list of all config files so we know when one has changed
6882 it's date and needs to be reloaded.
6883 ********************************************************************/
6885 static void add_to_file_list(const char *fname, const char *subfname)
6887 struct file_lists *f = file_lists;
6890 if (f->name && !strcmp(f->name, fname))
6896 f = SMB_MALLOC_P(struct file_lists);
6899 f->next = file_lists;
6900 f->name = SMB_STRDUP(fname);
6905 f->subfname = SMB_STRDUP(subfname);
6912 f->modtime = file_modtime(subfname);
6914 time_t t = file_modtime(subfname);
6922 * Free the file lists
6924 static void free_file_list(void)
6926 struct file_lists *f;
6927 struct file_lists *next;
6932 SAFE_FREE( f->name );
6933 SAFE_FREE( f->subfname );
6942 * Utility function for outsiders to check if we're running on registry.
6944 bool lp_config_backend_is_registry(void)
6946 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
6950 * Utility function to check if the config backend is FILE.
6952 bool lp_config_backend_is_file(void)
6954 return (lp_config_backend() == CONFIG_BACKEND_FILE);
6957 /*******************************************************************
6958 Check if a config file has changed date.
6959 ********************************************************************/
6961 bool lp_file_list_changed(void)
6963 struct file_lists *f = file_lists;
6965 DEBUG(6, ("lp_file_list_changed()\n"));
6970 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
6971 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6973 if (conf_ctx == NULL) {
6976 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
6979 DEBUGADD(6, ("registry config changed\n"));
6984 n2 = talloc_sub_basic(talloc_tos(),
6985 get_current_username(),
6986 current_user_info.domain,
6991 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
6992 f->name, n2, ctime(&f->modtime)));
6994 mod_time = file_modtime(n2);
6997 ((f->modtime != mod_time) ||
6998 (f->subfname == NULL) ||
6999 (strcmp(n2, f->subfname) != 0)))
7002 ("file %s modified: %s\n", n2,
7004 f->modtime = mod_time;
7005 SAFE_FREE(f->subfname);
7006 f->subfname = SMB_STRDUP(n2);
7019 * Initialize iconv conversion descriptors.
7021 * This is called the first time it is needed, and also called again
7022 * every time the configuration is reloaded, because the charset or
7023 * codepage might have changed.
7025 static void init_iconv(void)
7027 global_iconv_handle = smb_iconv_handle_reinit(NULL, lp_dos_charset(),
7029 true, global_iconv_handle);
7032 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7034 if (strcmp(*ptr, pszParmValue) != 0) {
7035 string_set(ptr, pszParmValue);
7041 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7043 bool is_utf8 = false;
7044 size_t len = strlen(pszParmValue);
7046 if (len == 4 || len == 5) {
7047 /* Don't use StrCaseCmp here as we don't want to
7048 initialize iconv. */
7049 if ((toupper_ascii(pszParmValue[0]) == 'U') &&
7050 (toupper_ascii(pszParmValue[1]) == 'T') &&
7051 (toupper_ascii(pszParmValue[2]) == 'F')) {
7053 if (pszParmValue[3] == '8') {
7057 if (pszParmValue[3] == '-' &&
7058 pszParmValue[4] == '8') {
7065 if (strcmp(*ptr, pszParmValue) != 0) {
7067 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
7068 "be UTF8, using (default value) %s instead.\n",
7069 DEFAULT_DOS_CHARSET));
7070 pszParmValue = DEFAULT_DOS_CHARSET;
7072 string_set(ptr, pszParmValue);
7078 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7081 char *realm = strupper_talloc(talloc_tos(), pszParmValue);
7082 char *dnsdomain = strlower_talloc(talloc_tos(), pszParmValue);
7084 ret &= string_set(&Globals.szRealm, pszParmValue);
7085 ret &= string_set(&Globals.szRealmUpper, realm);
7086 ret &= string_set(&Globals.szDnsDomain, dnsdomain);
7088 TALLOC_FREE(dnsdomain);
7093 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7095 TALLOC_FREE(Globals.szNetbiosAliases);
7096 Globals.szNetbiosAliases = str_list_make_v3(NULL, pszParmValue, NULL);
7097 return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
7100 /***************************************************************************
7101 Handle the include operation.
7102 ***************************************************************************/
7103 static bool bAllowIncludeRegistry = true;
7105 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7109 if (include_depth >= MAX_INCLUDE_DEPTH) {
7110 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
7115 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
7116 if (!bAllowIncludeRegistry) {
7119 if (bInGlobalSection) {
7122 ret = process_registry_globals();
7126 DEBUG(1, ("\"include = registry\" only effective "
7127 "in %s section\n", GLOBAL_NAME));
7132 fname = talloc_sub_basic(talloc_tos(), get_current_username(),
7133 current_user_info.domain,
7136 add_to_file_list(pszParmValue, fname);
7138 string_set(ptr, fname);
7140 if (file_exist(fname)) {
7143 ret = pm_process(fname, do_section, do_parameter, NULL);
7149 DEBUG(2, ("Can't find include file %s\n", fname));
7154 /***************************************************************************
7155 Handle the interpretation of the copy parameter.
7156 ***************************************************************************/
7158 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7162 struct loadparm_service serviceTemp;
7164 string_set(ptr, pszParmValue);
7166 init_service(&serviceTemp);
7170 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7172 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7173 if (iTemp == iServiceIndex) {
7174 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7176 copy_service(ServicePtrs[iServiceIndex],
7178 ServicePtrs[iServiceIndex]->copymap);
7182 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7186 free_service(&serviceTemp);
7190 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7192 Globals.ldap_debug_level = lp_int(pszParmValue);
7193 init_ldap_debugging();
7197 /***************************************************************************
7198 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7203 idmap uid = 1000-1999
7206 We only do simple parsing checks here. The strings are parsed into useful
7207 structures in the idmap daemon code.
7209 ***************************************************************************/
7211 /* Some lp_ routines to return idmap [ug]id information */
7213 static uid_t idmap_uid_low, idmap_uid_high;
7214 static gid_t idmap_gid_low, idmap_gid_high;
7216 bool lp_idmap_uid(uid_t *low, uid_t *high)
7218 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7222 *low = idmap_uid_low;
7225 *high = idmap_uid_high;
7230 bool lp_idmap_gid(gid_t *low, gid_t *high)
7232 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7236 *low = idmap_gid_low;
7239 *high = idmap_gid_high;
7244 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7246 lp_do_parameter(snum, "idmap config * : backend", pszParmValue);
7251 /* Do some simple checks on "idmap [ug]id" parameter values */
7253 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7255 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7260 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7262 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7267 /***************************************************************************
7268 Handle the DEBUG level list.
7269 ***************************************************************************/
7271 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValueIn, char **ptr )
7273 string_set(ptr, pszParmValueIn);
7274 return debug_parse_levels(pszParmValueIn);
7277 /***************************************************************************
7278 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7279 ***************************************************************************/
7281 static const char *append_ldap_suffix( const char *str )
7283 const char *suffix_string;
7286 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7287 Globals.szLdapSuffix );
7288 if ( !suffix_string ) {
7289 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7293 return suffix_string;
7296 const char *lp_ldap_machine_suffix(void)
7298 if (Globals.szLdapMachineSuffix[0])
7299 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7301 return lp_string(Globals.szLdapSuffix);
7304 const char *lp_ldap_user_suffix(void)
7306 if (Globals.szLdapUserSuffix[0])
7307 return append_ldap_suffix(Globals.szLdapUserSuffix);
7309 return lp_string(Globals.szLdapSuffix);
7312 const char *lp_ldap_group_suffix(void)
7314 if (Globals.szLdapGroupSuffix[0])
7315 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7317 return lp_string(Globals.szLdapSuffix);
7320 const char *lp_ldap_idmap_suffix(void)
7322 if (Globals.szLdapIdmapSuffix[0])
7323 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7325 return lp_string(Globals.szLdapSuffix);
7328 /****************************************************************************
7329 set the value for a P_ENUM
7330 ***************************************************************************/
7332 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7337 for (i = 0; parm->enum_list[i].name; i++) {
7338 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7339 *ptr = parm->enum_list[i].value;
7343 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7344 pszParmValue, parm->label));
7347 /***************************************************************************
7348 ***************************************************************************/
7350 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7352 static int parm_num = -1;
7353 struct loadparm_service *s;
7355 if ( parm_num == -1 )
7356 parm_num = map_parameter( "printing" );
7358 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7363 s = ServicePtrs[snum];
7365 init_printer_values( s );
7371 /***************************************************************************
7372 Initialise a copymap.
7373 ***************************************************************************/
7375 static void init_copymap(struct loadparm_service *pservice)
7379 TALLOC_FREE(pservice->copymap);
7381 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
7382 if (!pservice->copymap)
7384 ("Couldn't allocate copymap!! (size %d)\n",
7385 (int)NUMPARAMETERS));
7387 for (i = 0; i < NUMPARAMETERS; i++)
7388 bitmap_set(pservice->copymap, i);
7392 return the parameter pointer for a parameter
7394 void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm)
7396 if (service == NULL) {
7397 if (parm->p_class == P_LOCAL)
7398 return (void *)(((char *)&sDefault)+parm->offset);
7399 else if (parm->p_class == P_GLOBAL)
7400 return (void *)(((char *)&Globals)+parm->offset);
7403 return (void *)(((char *)service) + parm->offset);
7407 /***************************************************************************
7408 Return the local pointer to a parameter given the service number and parameter
7409 ***************************************************************************/
7411 void *lp_local_ptr_by_snum(int snum, struct parm_struct *parm)
7413 return lp_parm_ptr(ServicePtrs[snum], parm);
7416 /***************************************************************************
7417 Process a parameter for a particular service number. If snum < 0
7418 then assume we are in the globals.
7419 ***************************************************************************/
7421 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7424 void *parm_ptr = NULL; /* where we are going to store the result */
7425 struct parmlist_entry **opt_list;
7427 parmnum = map_parameter(pszParmName);
7430 if (strchr(pszParmName, ':') == NULL) {
7431 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7437 * We've got a parametric option
7440 opt_list = (snum < 0)
7441 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7442 set_param_opt(opt_list, pszParmName, pszParmValue, 0);
7447 /* if it's already been set by the command line, then we don't
7449 if (parm_table[parmnum].flags & FLAG_CMDLINE) {
7453 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7454 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7458 /* we might point at a service, the default service or a global */
7460 parm_ptr = lp_parm_ptr(NULL, &parm_table[parmnum]);
7462 if (parm_table[parmnum].p_class == P_GLOBAL) {
7464 ("Global parameter %s found in service section!\n",
7468 parm_ptr = lp_local_ptr_by_snum(snum, &parm_table[parmnum]);
7472 if (!ServicePtrs[snum]->copymap)
7473 init_copymap(ServicePtrs[snum]);
7475 /* this handles the aliases - set the copymap for other entries with
7476 the same data pointer */
7477 for (i = 0; parm_table[i].label; i++) {
7478 if ((parm_table[i].offset == parm_table[parmnum].offset)
7479 && (parm_table[i].p_class == parm_table[parmnum].p_class)) {
7480 bitmap_clear(ServicePtrs[snum]->copymap, i);
7485 /* if it is a special case then go ahead */
7486 if (parm_table[parmnum].special) {
7487 return parm_table[parmnum].special(NULL, snum, pszParmValue,
7491 /* now switch on the type of variable it is */
7492 switch (parm_table[parmnum].type)
7495 *(bool *)parm_ptr = lp_bool(pszParmValue);
7499 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7503 *(int *)parm_ptr = lp_int(pszParmValue);
7507 *(char *)parm_ptr = *pszParmValue;
7511 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7513 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7518 TALLOC_FREE(*((char ***)parm_ptr));
7519 *(char ***)parm_ptr = str_list_make_v3(
7520 NULL, pszParmValue, NULL);
7524 string_set((char **)parm_ptr, pszParmValue);
7529 char *upper_string = strupper_talloc(talloc_tos(),
7531 string_set((char **)parm_ptr, upper_string);
7532 TALLOC_FREE(upper_string);
7536 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7545 /***************************************************************************
7546 set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
7547 FLAG_CMDLINE won't be overridden by loads from smb.conf.
7548 ***************************************************************************/
7550 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
7553 parmnum = map_parameter(pszParmName);
7555 parm_table[parmnum].flags &= ~FLAG_CMDLINE;
7556 if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
7559 parm_table[parmnum].flags |= FLAG_CMDLINE;
7561 /* we have to also set FLAG_CMDLINE on aliases. Aliases must
7562 * be grouped in the table, so we don't have to search the
7565 i>=0 && parm_table[i].offset == parm_table[parmnum].offset
7566 && parm_table[i].p_class == parm_table[parmnum].p_class;
7568 parm_table[i].flags |= FLAG_CMDLINE;
7570 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset
7571 && parm_table[i].p_class == parm_table[parmnum].p_class;i++) {
7572 parm_table[i].flags |= FLAG_CMDLINE;
7576 store_lp_set_cmdline(pszParmName, pszParmValue);
7581 /* it might be parametric */
7582 if (strchr(pszParmName, ':') != NULL) {
7583 set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
7585 store_lp_set_cmdline(pszParmName, pszParmValue);
7590 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
7594 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
7596 return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
7599 /***************************************************************************
7600 Process a parameter.
7601 ***************************************************************************/
7603 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7606 if (!bInGlobalSection && bGlobalOnly)
7609 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7611 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7612 pszParmName, pszParmValue));
7616 set a option from the commandline in 'a=b' format. Use to support --option
7618 bool lp_set_option(const char *option)
7623 s = talloc_strdup(NULL, option);
7636 /* skip white spaces after the = sign */
7639 } while (*p == ' ');
7641 ret = lp_set_cmdline(s, p);
7646 /**************************************************************************
7647 Print a parameter of the specified type.
7648 ***************************************************************************/
7650 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7656 for (i = 0; p->enum_list[i].name; i++) {
7657 if (*(int *)ptr == p->enum_list[i].value) {
7659 p->enum_list[i].name);
7666 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7670 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7674 fprintf(f, "%d", *(int *)ptr);
7678 fprintf(f, "%c", *(char *)ptr);
7682 char *o = octal_string(*(int *)ptr);
7683 fprintf(f, "%s", o);
7689 if ((char ***)ptr && *(char ***)ptr) {
7690 char **list = *(char ***)ptr;
7691 for (; *list; list++) {
7692 /* surround strings with whitespace in double quotes */
7693 if ( strchr_m( *list, ' ' ) )
7694 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
7696 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
7703 if (*(char **)ptr) {
7704 fprintf(f, "%s", *(char **)ptr);
7712 /***************************************************************************
7713 Check if two parameters are equal.
7714 ***************************************************************************/
7716 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7721 return (*((bool *)ptr1) == *((bool *)ptr2));
7726 return (*((int *)ptr1) == *((int *)ptr2));
7729 return (*((char *)ptr1) == *((char *)ptr2));
7732 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7737 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7742 return (p1 == p2 || strequal(p1, p2));
7750 /***************************************************************************
7751 Initialize any local varients in the sDefault table.
7752 ***************************************************************************/
7754 void init_locals(void)
7759 /***************************************************************************
7760 Process a new section (service). At this stage all sections are services.
7761 Later we'll have special sections that permit server parameters to be set.
7762 Returns true on success, false on failure.
7763 ***************************************************************************/
7765 static bool do_section(const char *pszSectionName, void *userdata)
7768 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7769 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7772 /* if we were in a global section then do the local inits */
7773 if (bInGlobalSection && !isglobal)
7776 /* if we've just struck a global section, note the fact. */
7777 bInGlobalSection = isglobal;
7779 /* check for multiple global sections */
7780 if (bInGlobalSection) {
7781 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7785 if (!bInGlobalSection && bGlobalOnly)
7788 /* if we have a current service, tidy it up before moving on */
7791 if (iServiceIndex >= 0)
7792 bRetval = service_ok(iServiceIndex);
7794 /* if all is still well, move to the next record in the services array */
7796 /* We put this here to avoid an odd message order if messages are */
7797 /* issued by the post-processing of a previous section. */
7798 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7800 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
7802 DEBUG(0, ("Failed to add a new service\n"));
7805 /* Clean all parametric options for service */
7806 /* They will be added during parsing again */
7807 free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
7814 /***************************************************************************
7815 Determine if a partcular base parameter is currentl set to the default value.
7816 ***************************************************************************/
7818 static bool is_default(int i)
7820 if (!defaults_saved)
7822 switch (parm_table[i].type) {
7824 return str_list_equal((const char **)parm_table[i].def.lvalue,
7825 *(const char ***)lp_parm_ptr(NULL,
7829 return strequal(parm_table[i].def.svalue,
7830 *(char **)lp_parm_ptr(NULL,
7834 return parm_table[i].def.bvalue ==
7835 *(bool *)lp_parm_ptr(NULL,
7838 return parm_table[i].def.cvalue ==
7839 *(char *)lp_parm_ptr(NULL,
7844 return parm_table[i].def.ivalue ==
7845 *(int *)lp_parm_ptr(NULL,
7853 /***************************************************************************
7854 Display the contents of the global structure.
7855 ***************************************************************************/
7857 static void dump_globals(FILE *f)
7860 struct parmlist_entry *data;
7862 fprintf(f, "[global]\n");
7864 for (i = 0; parm_table[i].label; i++)
7865 if (parm_table[i].p_class == P_GLOBAL &&
7866 !(parm_table[i].flags & FLAG_META) &&
7867 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
7868 if (defaults_saved && is_default(i))
7870 fprintf(f, "\t%s = ", parm_table[i].label);
7871 print_parameter(&parm_table[i], lp_parm_ptr(NULL,
7876 if (Globals.param_opt != NULL) {
7877 data = Globals.param_opt;
7879 fprintf(f, "\t%s = %s\n", data->key, data->value);
7886 /***************************************************************************
7887 Return true if a local parameter is currently set to the global default.
7888 ***************************************************************************/
7890 bool lp_is_default(int snum, struct parm_struct *parm)
7892 return equal_parameter(parm->type,
7893 lp_parm_ptr(ServicePtrs[snum], parm),
7894 lp_parm_ptr(NULL, parm));
7897 /***************************************************************************
7898 Display the contents of a single services record.
7899 ***************************************************************************/
7901 static void dump_a_service(struct loadparm_service *pService, FILE * f)
7904 struct parmlist_entry *data;
7906 if (pService != &sDefault)
7907 fprintf(f, "[%s]\n", pService->szService);
7909 for (i = 0; parm_table[i].label; i++) {
7911 if (parm_table[i].p_class == P_LOCAL &&
7912 !(parm_table[i].flags & FLAG_META) &&
7913 (*parm_table[i].label != '-') &&
7914 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7916 if (pService == &sDefault) {
7917 if (defaults_saved && is_default(i))
7920 if (equal_parameter(parm_table[i].type,
7921 lp_parm_ptr(pService, &parm_table[i]),
7922 lp_parm_ptr(NULL, &parm_table[i])))
7926 fprintf(f, "\t%s = ", parm_table[i].label);
7927 print_parameter(&parm_table[i],
7928 lp_parm_ptr(pService, &parm_table[i]),
7934 if (pService->param_opt != NULL) {
7935 data = pService->param_opt;
7937 fprintf(f, "\t%s = %s\n", data->key, data->value);
7943 /***************************************************************************
7944 Display the contents of a parameter of a single services record.
7945 ***************************************************************************/
7947 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7950 bool result = false;
7953 fstring local_parm_name;
7955 const char *parm_opt_value;
7957 /* check for parametrical option */
7958 fstrcpy( local_parm_name, parm_name);
7959 parm_opt = strchr( local_parm_name, ':');
7964 if (strlen(parm_opt)) {
7965 parm_opt_value = lp_parm_const_string( snum,
7966 local_parm_name, parm_opt, NULL);
7967 if (parm_opt_value) {
7968 printf( "%s\n", parm_opt_value);
7975 /* check for a key and print the value */
7982 for (i = 0; parm_table[i].label; i++) {
7983 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7984 !(parm_table[i].flags & FLAG_META) &&
7985 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7986 (*parm_table[i].label != '-') &&
7987 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7992 ptr = lp_parm_ptr(NULL,
7995 ptr = lp_parm_ptr(ServicePtrs[snum],
7999 print_parameter(&parm_table[i],
8010 /***************************************************************************
8011 Return info about the requested parameter (given as a string).
8012 Return NULL when the string is not a valid parameter name.
8013 ***************************************************************************/
8015 struct parm_struct *lp_get_parameter(const char *param_name)
8017 int num = map_parameter(param_name);
8023 return &parm_table[num];
8026 /***************************************************************************
8027 Return info about the next parameter in a service.
8028 snum==GLOBAL_SECTION_SNUM gives the globals.
8029 Return NULL when out of parameters.
8030 ***************************************************************************/
8032 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
8035 /* do the globals */
8036 for (; parm_table[*i].label; (*i)++) {
8037 if (parm_table[*i].p_class == P_SEPARATOR)
8038 return &parm_table[(*i)++];
8040 if ((*parm_table[*i].label == '-'))
8044 && (parm_table[*i].offset ==
8045 parm_table[(*i) - 1].offset)
8046 && (parm_table[*i].p_class ==
8047 parm_table[(*i) - 1].p_class))
8050 if (is_default(*i) && !allparameters)
8053 return &parm_table[(*i)++];
8056 struct loadparm_service *pService = ServicePtrs[snum];
8058 for (; parm_table[*i].label; (*i)++) {
8059 if (parm_table[*i].p_class == P_SEPARATOR)
8060 return &parm_table[(*i)++];
8062 if (parm_table[*i].p_class == P_LOCAL &&
8063 (*parm_table[*i].label != '-') &&
8065 (parm_table[*i].offset !=
8066 parm_table[(*i) - 1].offset)))
8068 if (allparameters ||
8069 !equal_parameter(parm_table[*i].type,
8070 lp_parm_ptr(pService,
8075 return &parm_table[(*i)++];
8086 /***************************************************************************
8087 Display the contents of a single copy structure.
8088 ***************************************************************************/
8089 static void dump_copy_map(bool *pcopymap)
8095 printf("\n\tNon-Copied parameters:\n");
8097 for (i = 0; parm_table[i].label; i++)
8098 if (parm_table[i].p_class == P_LOCAL &&
8099 parm_table[i].ptr && !pcopymap[i] &&
8100 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8102 printf("\t\t%s\n", parm_table[i].label);
8107 /***************************************************************************
8108 Return TRUE if the passed service number is within range.
8109 ***************************************************************************/
8111 bool lp_snum_ok(int iService)
8113 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8116 /***************************************************************************
8117 Auto-load some home services.
8118 ***************************************************************************/
8120 static void lp_add_auto_services(char *str)
8130 s = SMB_STRDUP(str);
8134 homes = lp_servicenumber(HOMES_NAME);
8136 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8137 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8140 if (lp_servicenumber(p) >= 0)
8143 home = get_user_home_dir(talloc_tos(), p);
8145 if (home && home[0] && homes >= 0)
8146 lp_add_home(p, homes, p, home);
8153 /***************************************************************************
8154 Auto-load one printer.
8155 ***************************************************************************/
8157 void lp_add_one_printer(const char *name, const char *comment,
8158 const char *location, void *pdata)
8160 int printers = lp_servicenumber(PRINTERS_NAME);
8163 if (lp_servicenumber(name) < 0) {
8164 lp_add_printer(name, printers);
8165 if ((i = lp_servicenumber(name)) >= 0) {
8166 string_set(&ServicePtrs[i]->comment, comment);
8167 ServicePtrs[i]->autoloaded = true;
8172 /***************************************************************************
8173 Have we loaded a services file yet?
8174 ***************************************************************************/
8176 bool lp_loaded(void)
8181 /***************************************************************************
8182 Unload unused services.
8183 ***************************************************************************/
8185 void lp_killunused(struct smbd_server_connection *sconn,
8186 bool (*snumused) (struct smbd_server_connection *, int))
8189 for (i = 0; i < iNumServices; i++) {
8193 /* don't kill autoloaded or usershare services */
8194 if ( ServicePtrs[i]->autoloaded ||
8195 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8199 if (!snumused || !snumused(sconn, i)) {
8200 free_service_byindex(i);
8206 * Kill all except autoloaded and usershare services - convenience wrapper
8208 void lp_kill_all_services(void)
8210 lp_killunused(NULL, NULL);
8213 /***************************************************************************
8215 ***************************************************************************/
8217 void lp_killservice(int iServiceIn)
8219 if (VALID(iServiceIn)) {
8220 free_service_byindex(iServiceIn);
8224 /***************************************************************************
8225 Save the curent values of all global and sDefault parameters into the
8226 defaults union. This allows swat and testparm to show only the
8227 changed (ie. non-default) parameters.
8228 ***************************************************************************/
8230 static void lp_save_defaults(void)
8233 for (i = 0; parm_table[i].label; i++) {
8234 if (i > 0 && parm_table[i].offset == parm_table[i - 1].offset
8235 && parm_table[i].p_class == parm_table[i - 1].p_class)
8237 switch (parm_table[i].type) {
8239 parm_table[i].def.lvalue = str_list_copy(
8240 NULL, *(const char ***)lp_parm_ptr(NULL, &parm_table[i]));
8244 parm_table[i].def.svalue = SMB_STRDUP(*(char **)lp_parm_ptr(NULL, &parm_table[i]));
8248 parm_table[i].def.bvalue =
8249 *(bool *)lp_parm_ptr(NULL, &parm_table[i]);
8252 parm_table[i].def.cvalue =
8253 *(char *)lp_parm_ptr(NULL, &parm_table[i]);
8258 parm_table[i].def.ivalue =
8259 *(int *)lp_parm_ptr(NULL, &parm_table[i]);
8265 defaults_saved = true;
8268 /***********************************************************
8269 If we should send plaintext/LANMAN passwords in the clinet
8270 ************************************************************/
8272 static void set_allowed_client_auth(void)
8274 if (Globals.bClientNTLMv2Auth) {
8275 Globals.bClientLanManAuth = false;
8277 if (!Globals.bClientLanManAuth) {
8278 Globals.bClientPlaintextAuth = false;
8282 /***************************************************************************
8284 The following code allows smbd to read a user defined share file.
8285 Yes, this is my intent. Yes, I'm comfortable with that...
8287 THE FOLLOWING IS SECURITY CRITICAL CODE.
8289 It washes your clothes, it cleans your house, it guards you while you sleep...
8290 Do not f%^k with it....
8291 ***************************************************************************/
8293 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8295 /***************************************************************************
8296 Check allowed stat state of a usershare file.
8297 Ensure we print out who is dicking with us so the admin can
8298 get their sorry ass fired.
8299 ***************************************************************************/
8301 static bool check_usershare_stat(const char *fname,
8302 const SMB_STRUCT_STAT *psbuf)
8304 if (!S_ISREG(psbuf->st_ex_mode)) {
8305 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8306 "not a regular file\n",
8307 fname, (unsigned int)psbuf->st_ex_uid ));
8311 /* Ensure this doesn't have the other write bit set. */
8312 if (psbuf->st_ex_mode & S_IWOTH) {
8313 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8314 "public write. Refusing to allow as a usershare file.\n",
8315 fname, (unsigned int)psbuf->st_ex_uid ));
8319 /* Should be 10k or less. */
8320 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8321 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8322 "too large (%u) to be a user share file.\n",
8323 fname, (unsigned int)psbuf->st_ex_uid,
8324 (unsigned int)psbuf->st_ex_size ));
8331 /***************************************************************************
8332 Parse the contents of a usershare file.
8333 ***************************************************************************/
8335 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8336 SMB_STRUCT_STAT *psbuf,
8337 const char *servicename,
8341 char **pp_sharepath,
8343 char **pp_cp_servicename,
8344 struct security_descriptor **ppsd,
8347 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8348 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8351 SMB_STRUCT_STAT sbuf;
8352 char *sharepath = NULL;
8353 char *comment = NULL;
8355 *pp_sharepath = NULL;
8358 *pallow_guest = false;
8361 return USERSHARE_MALFORMED_FILE;
8364 if (strcmp(lines[0], "#VERSION 1") == 0) {
8366 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8369 return USERSHARE_MALFORMED_FILE;
8372 return USERSHARE_BAD_VERSION;
8375 if (strncmp(lines[1], "path=", 5) != 0) {
8376 return USERSHARE_MALFORMED_PATH;
8379 sharepath = talloc_strdup(ctx, &lines[1][5]);
8381 return USERSHARE_POSIX_ERR;
8383 trim_string(sharepath, " ", " ");
8385 if (strncmp(lines[2], "comment=", 8) != 0) {
8386 return USERSHARE_MALFORMED_COMMENT_DEF;
8389 comment = talloc_strdup(ctx, &lines[2][8]);
8391 return USERSHARE_POSIX_ERR;
8393 trim_string(comment, " ", " ");
8394 trim_char(comment, '"', '"');
8396 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8397 return USERSHARE_MALFORMED_ACL_DEF;
8400 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8401 return USERSHARE_ACL_ERR;
8405 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8406 return USERSHARE_MALFORMED_ACL_DEF;
8408 if (lines[4][9] == 'y') {
8409 *pallow_guest = true;
8412 /* Backwards compatible extension to file version #2. */
8414 if (strncmp(lines[5], "sharename=", 10) != 0) {
8415 return USERSHARE_MALFORMED_SHARENAME_DEF;
8417 if (!strequal(&lines[5][10], servicename)) {
8418 return USERSHARE_BAD_SHARENAME;
8420 *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
8421 if (!*pp_cp_servicename) {
8422 return USERSHARE_POSIX_ERR;
8427 if (*pp_cp_servicename == NULL) {
8428 *pp_cp_servicename = talloc_strdup(ctx, servicename);
8429 if (!*pp_cp_servicename) {
8430 return USERSHARE_POSIX_ERR;
8434 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8435 /* Path didn't change, no checks needed. */
8436 *pp_sharepath = sharepath;
8437 *pp_comment = comment;
8438 return USERSHARE_OK;
8441 /* The path *must* be absolute. */
8442 if (sharepath[0] != '/') {
8443 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8444 servicename, sharepath));
8445 return USERSHARE_PATH_NOT_ABSOLUTE;
8448 /* If there is a usershare prefix deny list ensure one of these paths
8449 doesn't match the start of the user given path. */
8450 if (prefixdenylist) {
8452 for ( i=0; prefixdenylist[i]; i++ ) {
8453 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8454 servicename, i, prefixdenylist[i], sharepath ));
8455 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8456 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8457 "usershare prefix deny list entries.\n",
8458 servicename, sharepath));
8459 return USERSHARE_PATH_IS_DENIED;
8464 /* If there is a usershare prefix allow list ensure one of these paths
8465 does match the start of the user given path. */
8467 if (prefixallowlist) {
8469 for ( i=0; prefixallowlist[i]; i++ ) {
8470 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8471 servicename, i, prefixallowlist[i], sharepath ));
8472 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8476 if (prefixallowlist[i] == NULL) {
8477 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8478 "usershare prefix allow list entries.\n",
8479 servicename, sharepath));
8480 return USERSHARE_PATH_NOT_ALLOWED;
8484 /* Ensure this is pointing to a directory. */
8485 dp = sys_opendir(sharepath);
8488 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8489 servicename, sharepath));
8490 return USERSHARE_PATH_NOT_DIRECTORY;
8493 /* Ensure the owner of the usershare file has permission to share
8496 if (sys_stat(sharepath, &sbuf, false) == -1) {
8497 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8498 servicename, sharepath, strerror(errno) ));
8500 return USERSHARE_POSIX_ERR;
8505 if (!S_ISDIR(sbuf.st_ex_mode)) {
8506 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8507 servicename, sharepath ));
8508 return USERSHARE_PATH_NOT_DIRECTORY;
8511 /* Check if sharing is restricted to owner-only. */
8512 /* psbuf is the stat of the usershare definition file,
8513 sbuf is the stat of the target directory to be shared. */
8515 if (lp_usershare_owner_only()) {
8516 /* root can share anything. */
8517 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8518 return USERSHARE_PATH_NOT_ALLOWED;
8522 *pp_sharepath = sharepath;
8523 *pp_comment = comment;
8524 return USERSHARE_OK;
8527 /***************************************************************************
8528 Deal with a usershare file.
8531 -1 - Bad name, invalid contents.
8532 - service name already existed and not a usershare, problem
8533 with permissions to share directory etc.
8534 ***************************************************************************/
8536 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8538 SMB_STRUCT_STAT sbuf;
8539 SMB_STRUCT_STAT lsbuf;
8541 char *sharepath = NULL;
8542 char *comment = NULL;
8543 char *cp_service_name = NULL;
8544 char **lines = NULL;
8548 TALLOC_CTX *ctx = talloc_stackframe();
8549 struct security_descriptor *psd = NULL;
8550 bool guest_ok = false;
8551 char *canon_name = NULL;
8552 bool added_service = false;
8555 /* Ensure share name doesn't contain invalid characters. */
8556 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8557 DEBUG(0,("process_usershare_file: share name %s contains "
8558 "invalid characters (any of %s)\n",
8559 file_name, INVALID_SHARENAME_CHARS ));
8563 canon_name = canonicalize_servicename(ctx, file_name);
8568 fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
8573 /* Minimize the race condition by doing an lstat before we
8574 open and fstat. Ensure this isn't a symlink link. */
8576 if (sys_lstat(fname, &lsbuf, false) != 0) {
8577 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8578 fname, strerror(errno) ));
8582 /* This must be a regular file, not a symlink, directory or
8583 other strange filetype. */
8584 if (!check_usershare_stat(fname, &lsbuf)) {
8589 TDB_DATA data = dbwrap_fetch_bystring(
8590 ServiceHash, canon_name, canon_name);
8594 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
8595 iService = *(int *)data.dptr;
8599 if (iService != -1 &&
8600 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8601 &lsbuf.st_ex_mtime) == 0) {
8602 /* Nothing changed - Mark valid and return. */
8603 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8605 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8610 /* Try and open the file read only - no symlinks allowed. */
8612 fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8614 fd = sys_open(fname, O_RDONLY, 0);
8618 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8619 fname, strerror(errno) ));
8623 /* Now fstat to be *SURE* it's a regular file. */
8624 if (sys_fstat(fd, &sbuf, false) != 0) {
8626 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8627 fname, strerror(errno) ));
8631 /* Is it the same dev/inode as was lstated ? */
8632 if (lsbuf.st_ex_dev != sbuf.st_ex_dev || lsbuf.st_ex_ino != sbuf.st_ex_ino) {
8634 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8635 "Symlink spoofing going on ?\n", fname ));
8639 /* This must be a regular file, not a symlink, directory or
8640 other strange filetype. */
8641 if (!check_usershare_stat(fname, &sbuf)) {
8645 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8648 if (lines == NULL) {
8649 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8650 fname, (unsigned int)sbuf.st_ex_uid ));
8654 if (parse_usershare_file(ctx, &sbuf, file_name,
8655 iService, lines, numlines, &sharepath,
8656 &comment, &cp_service_name,
8657 &psd, &guest_ok) != USERSHARE_OK) {
8661 /* Everything ok - add the service possibly using a template. */
8663 const struct loadparm_service *sp = &sDefault;
8664 if (snum_template != -1) {
8665 sp = ServicePtrs[snum_template];
8668 if ((iService = add_a_service(sp, cp_service_name)) < 0) {
8669 DEBUG(0, ("process_usershare_file: Failed to add "
8670 "new service %s\n", cp_service_name));
8674 added_service = true;
8676 /* Read only is controlled by usershare ACL below. */
8677 ServicePtrs[iService]->bRead_only = false;
8680 /* Write the ACL of the new/modified share. */
8681 if (!set_share_security(canon_name, psd)) {
8682 DEBUG(0, ("process_usershare_file: Failed to set share "
8683 "security for user share %s\n",
8688 /* If from a template it may be marked invalid. */
8689 ServicePtrs[iService]->valid = true;
8691 /* Set the service as a valid usershare. */
8692 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8694 /* Set guest access. */
8695 if (lp_usershare_allow_guests()) {
8696 ServicePtrs[iService]->bGuest_ok = guest_ok;
8699 /* And note when it was loaded. */
8700 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8701 string_set(&ServicePtrs[iService]->szPath, sharepath);
8702 string_set(&ServicePtrs[iService]->comment, comment);
8708 if (ret == -1 && iService != -1 && added_service) {
8709 lp_remove_service(iService);
8717 /***************************************************************************
8718 Checks if a usershare entry has been modified since last load.
8719 ***************************************************************************/
8721 static bool usershare_exists(int iService, struct timespec *last_mod)
8723 SMB_STRUCT_STAT lsbuf;
8724 const char *usersharepath = Globals.szUsersharePath;
8727 if (asprintf(&fname, "%s/%s",
8729 ServicePtrs[iService]->szService) < 0) {
8733 if (sys_lstat(fname, &lsbuf, false) != 0) {
8738 if (!S_ISREG(lsbuf.st_ex_mode)) {
8744 *last_mod = lsbuf.st_ex_mtime;
8748 /***************************************************************************
8749 Load a usershare service by name. Returns a valid servicenumber or -1.
8750 ***************************************************************************/
8752 int load_usershare_service(const char *servicename)
8754 SMB_STRUCT_STAT sbuf;
8755 const char *usersharepath = Globals.szUsersharePath;
8756 int max_user_shares = Globals.iUsershareMaxShares;
8757 int snum_template = -1;
8759 if (*usersharepath == 0 || max_user_shares == 0) {
8763 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8764 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8765 usersharepath, strerror(errno) ));
8769 if (!S_ISDIR(sbuf.st_ex_mode)) {
8770 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8776 * This directory must be owned by root, and have the 't' bit set.
8777 * It also must not be writable by "other".
8781 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8783 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8785 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8786 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8791 /* Ensure the template share exists if it's set. */
8792 if (Globals.szUsershareTemplateShare[0]) {
8793 /* We can't use lp_servicenumber here as we are recommending that
8794 template shares have -valid=false set. */
8795 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8796 if (ServicePtrs[snum_template]->szService &&
8797 strequal(ServicePtrs[snum_template]->szService,
8798 Globals.szUsershareTemplateShare)) {
8803 if (snum_template == -1) {
8804 DEBUG(0,("load_usershare_service: usershare template share %s "
8805 "does not exist.\n",
8806 Globals.szUsershareTemplateShare ));
8811 return process_usershare_file(usersharepath, servicename, snum_template);
8814 /***************************************************************************
8815 Load all user defined shares from the user share directory.
8816 We only do this if we're enumerating the share list.
8817 This is the function that can delete usershares that have
8819 ***************************************************************************/
8821 int load_usershare_shares(struct smbd_server_connection *sconn)
8824 SMB_STRUCT_STAT sbuf;
8825 SMB_STRUCT_DIRENT *de;
8826 int num_usershares = 0;
8827 int max_user_shares = Globals.iUsershareMaxShares;
8828 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8829 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8830 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8832 int snum_template = -1;
8833 const char *usersharepath = Globals.szUsersharePath;
8834 int ret = lp_numservices();
8836 if (max_user_shares == 0 || *usersharepath == '\0') {
8837 return lp_numservices();
8840 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8841 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8842 usersharepath, strerror(errno) ));
8847 * This directory must be owned by root, and have the 't' bit set.
8848 * It also must not be writable by "other".
8852 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8854 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8856 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8857 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8862 /* Ensure the template share exists if it's set. */
8863 if (Globals.szUsershareTemplateShare[0]) {
8864 /* We can't use lp_servicenumber here as we are recommending that
8865 template shares have -valid=false set. */
8866 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8867 if (ServicePtrs[snum_template]->szService &&
8868 strequal(ServicePtrs[snum_template]->szService,
8869 Globals.szUsershareTemplateShare)) {
8874 if (snum_template == -1) {
8875 DEBUG(0,("load_usershare_shares: usershare template share %s "
8876 "does not exist.\n",
8877 Globals.szUsershareTemplateShare ));
8882 /* Mark all existing usershares as pending delete. */
8883 for (iService = iNumServices - 1; iService >= 0; iService--) {
8884 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8885 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8889 dp = sys_opendir(usersharepath);
8891 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8892 usersharepath, strerror(errno) ));
8896 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8897 (de = sys_readdir(dp));
8898 num_dir_entries++ ) {
8900 const char *n = de->d_name;
8902 /* Ignore . and .. */
8904 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8910 /* Temporary file used when creating a share. */
8911 num_tmp_dir_entries++;
8914 /* Allow 20% tmp entries. */
8915 if (num_tmp_dir_entries > allowed_tmp_entries) {
8916 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8917 "in directory %s\n",
8918 num_tmp_dir_entries, usersharepath));
8922 r = process_usershare_file(usersharepath, n, snum_template);
8924 /* Update the services count. */
8926 if (num_usershares >= max_user_shares) {
8927 DEBUG(0,("load_usershare_shares: max user shares reached "
8928 "on file %s in directory %s\n",
8929 n, usersharepath ));
8932 } else if (r == -1) {
8933 num_bad_dir_entries++;
8936 /* Allow 20% bad entries. */
8937 if (num_bad_dir_entries > allowed_bad_entries) {
8938 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8939 "in directory %s\n",
8940 num_bad_dir_entries, usersharepath));
8944 /* Allow 20% bad entries. */
8945 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
8946 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8947 "in directory %s\n",
8948 num_dir_entries, usersharepath));
8955 /* Sweep through and delete any non-refreshed usershares that are
8956 not currently in use. */
8957 for (iService = iNumServices - 1; iService >= 0; iService--) {
8958 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
8959 if (conn_snum_used(sconn, iService)) {
8962 /* Remove from the share ACL db. */
8963 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8964 lp_servicename(iService) ));
8965 delete_share_security(lp_servicename(iService));
8966 free_service_byindex(iService);
8970 return lp_numservices();
8973 /********************************************************
8974 Destroy global resources allocated in this file
8975 ********************************************************/
8977 void gfree_loadparm(void)
8983 /* Free resources allocated to services */
8985 for ( i = 0; i < iNumServices; i++ ) {
8987 free_service_byindex(i);
8991 SAFE_FREE( ServicePtrs );
8994 /* Now release all resources allocated to global
8995 parameters and the default service */
8997 free_global_parameters();
9001 /***************************************************************************
9002 Allow client apps to specify that they are a client
9003 ***************************************************************************/
9004 void lp_set_in_client(bool b)
9010 /***************************************************************************
9011 Determine if we're running in a client app
9012 ***************************************************************************/
9013 bool lp_is_in_client(void)
9018 /***************************************************************************
9019 Load the services array from the services file. Return true on success,
9021 ***************************************************************************/
9023 static bool lp_load_ex(const char *pszFname,
9027 bool initialize_globals,
9028 bool allow_include_registry,
9029 bool allow_registry_shares)
9036 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
9038 bInGlobalSection = true;
9039 bGlobalOnly = global_only;
9040 bAllowIncludeRegistry = allow_include_registry;
9042 init_globals(initialize_globals);
9046 if (save_defaults) {
9051 free_param_opts(&Globals.param_opt);
9053 lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
9055 /* We get sections first, so have to start 'behind' to make up */
9058 if (lp_config_backend_is_file()) {
9059 n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
9060 current_user_info.domain,
9063 smb_panic("lp_load_ex: out of memory");
9066 add_to_file_list(pszFname, n2);
9068 bRetval = pm_process(n2, do_section, do_parameter, NULL);
9071 /* finish up the last section */
9072 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
9074 if (iServiceIndex >= 0) {
9075 bRetval = service_ok(iServiceIndex);
9079 if (lp_config_backend_is_registry()) {
9080 /* config backend changed to registry in config file */
9082 * We need to use this extra global variable here to
9083 * survive restart: init_globals uses this as a default
9084 * for ConfigBackend. Otherwise, init_globals would
9085 * send us into an endless loop here.
9087 config_backend = CONFIG_BACKEND_REGISTRY;
9089 DEBUG(1, ("lp_load_ex: changing to config backend "
9092 lp_kill_all_services();
9093 return lp_load_ex(pszFname, global_only, save_defaults,
9094 add_ipc, initialize_globals,
9095 allow_include_registry,
9096 allow_registry_shares);
9098 } else if (lp_config_backend_is_registry()) {
9099 bRetval = process_registry_globals();
9101 DEBUG(0, ("Illegal config backend given: %d\n",
9102 lp_config_backend()));
9106 if (bRetval && lp_registry_shares() && allow_registry_shares) {
9107 bRetval = process_registry_shares();
9110 lp_add_auto_services(lp_auto_services());
9113 /* When 'restrict anonymous = 2' guest connections to ipc$
9115 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9116 if ( lp_enable_asu_support() ) {
9117 lp_add_ipc("ADMIN$", false);
9122 set_allowed_client_auth();
9124 if (lp_security() == SEC_SHARE) {
9125 DEBUG(1, ("WARNING: The security=share option is deprecated\n"));
9126 } else if (lp_security() == SEC_SERVER) {
9127 DEBUG(1, ("WARNING: The security=server option is deprecated\n"));
9130 if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) {
9131 DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
9132 lp_passwordserver()));
9137 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9138 /* if bWINSsupport is true and we are in the client */
9139 if (lp_is_in_client() && Globals.bWINSsupport) {
9140 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9145 fault_configure(smb_panic_s3);
9147 bAllowIncludeRegistry = true;
9152 bool lp_load(const char *pszFname,
9156 bool initialize_globals)
9158 return lp_load_ex(pszFname,
9163 true, /* allow_include_registry */
9164 false); /* allow_registry_shares*/
9167 bool lp_load_initial_only(const char *pszFname)
9169 return lp_load_ex(pszFname,
9170 true, /* global only */
9171 false, /* save_defaults */
9172 false, /* add_ipc */
9173 true, /* initialize_globals */
9174 false, /* allow_include_registry */
9175 false); /* allow_registry_shares*/
9178 bool lp_load_with_registry_shares(const char *pszFname,
9182 bool initialize_globals)
9184 return lp_load_ex(pszFname,
9189 true, /* allow_include_registry */
9190 true); /* allow_registry_shares*/
9193 /***************************************************************************
9194 Return the max number of services.
9195 ***************************************************************************/
9197 int lp_numservices(void)
9199 return (iNumServices);
9202 /***************************************************************************
9203 Display the contents of the services array in human-readable form.
9204 ***************************************************************************/
9206 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9211 defaults_saved = false;
9215 dump_a_service(&sDefault, f);
9217 for (iService = 0; iService < maxtoprint; iService++) {
9219 lp_dump_one(f, show_defaults, iService);
9223 /***************************************************************************
9224 Display the contents of one service in human-readable form.
9225 ***************************************************************************/
9227 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9230 if (ServicePtrs[snum]->szService[0] == '\0')
9232 dump_a_service(ServicePtrs[snum], f);
9236 /***************************************************************************
9237 Return the number of the service with the given name, or -1 if it doesn't
9238 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9239 getservicebyname()! This works ONLY if all services have been loaded, and
9240 does not copy the found service.
9241 ***************************************************************************/
9243 int lp_servicenumber(const char *pszServiceName)
9246 fstring serviceName;
9248 if (!pszServiceName) {
9249 return GLOBAL_SECTION_SNUM;
9252 for (iService = iNumServices - 1; iService >= 0; iService--) {
9253 if (VALID(iService) && ServicePtrs[iService]->szService) {
9255 * The substitution here is used to support %U is
9258 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9259 standard_sub_basic(get_current_username(),
9260 current_user_info.domain,
9261 serviceName,sizeof(serviceName));
9262 if (strequal(serviceName, pszServiceName)) {
9268 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9269 struct timespec last_mod;
9271 if (!usershare_exists(iService, &last_mod)) {
9272 /* Remove the share security tdb entry for it. */
9273 delete_share_security(lp_servicename(iService));
9274 /* Remove it from the array. */
9275 free_service_byindex(iService);
9276 /* Doesn't exist anymore. */
9277 return GLOBAL_SECTION_SNUM;
9280 /* Has it been modified ? If so delete and reload. */
9281 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9283 /* Remove it from the array. */
9284 free_service_byindex(iService);
9285 /* and now reload it. */
9286 iService = load_usershare_service(pszServiceName);
9291 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9292 return GLOBAL_SECTION_SNUM;
9298 bool share_defined(const char *service_name)
9300 return (lp_servicenumber(service_name) != -1);
9303 /*******************************************************************
9304 A useful volume label function.
9305 ********************************************************************/
9307 const char *volume_label(int snum)
9310 const char *label = lp_volume(snum);
9312 label = lp_servicename(snum);
9315 /* This returns a 33 byte guarenteed null terminated string. */
9316 ret = talloc_strndup(talloc_tos(), label, 32);
9323 /*******************************************************************
9324 Get the default server type we will announce as via nmbd.
9325 ********************************************************************/
9327 int lp_default_server_announce(void)
9329 int default_server_announce = 0;
9330 default_server_announce |= SV_TYPE_WORKSTATION;
9331 default_server_announce |= SV_TYPE_SERVER;
9332 default_server_announce |= SV_TYPE_SERVER_UNIX;
9334 /* note that the flag should be set only if we have a
9335 printer service but nmbd doesn't actually load the
9336 services so we can't tell --jerry */
9338 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9340 default_server_announce |= SV_TYPE_SERVER_NT;
9341 default_server_announce |= SV_TYPE_NT;
9343 switch (lp_server_role()) {
9344 case ROLE_DOMAIN_MEMBER:
9345 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9347 case ROLE_DOMAIN_PDC:
9348 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9350 case ROLE_DOMAIN_BDC:
9351 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9353 case ROLE_STANDALONE:
9357 if (lp_time_server())
9358 default_server_announce |= SV_TYPE_TIME_SOURCE;
9360 if (lp_host_msdfs())
9361 default_server_announce |= SV_TYPE_DFS_SERVER;
9363 return default_server_announce;
9366 /***********************************************************
9367 If we are PDC then prefer us as DMB
9368 ************************************************************/
9370 bool lp_domain_master(void)
9372 if (Globals.iDomainMaster == Auto)
9373 return (lp_server_role() == ROLE_DOMAIN_PDC);
9375 return (bool)Globals.iDomainMaster;
9378 /***********************************************************
9379 If we are PDC then prefer us as DMB
9380 ************************************************************/
9382 bool lp_domain_master_true_or_auto(void)
9384 if (Globals.iDomainMaster) /* auto or yes */
9390 /***********************************************************
9391 If we are DMB then prefer us as LMB
9392 ************************************************************/
9394 bool lp_preferred_master(void)
9396 if (Globals.iPreferredMaster == Auto)
9397 return (lp_local_master() && lp_domain_master());
9399 return (bool)Globals.iPreferredMaster;
9402 /*******************************************************************
9404 ********************************************************************/
9406 void lp_remove_service(int snum)
9408 ServicePtrs[snum]->valid = false;
9409 invalid_services[num_invalid_services++] = snum;
9412 /*******************************************************************
9414 ********************************************************************/
9416 void lp_copy_service(int snum, const char *new_name)
9418 do_section(new_name, NULL);
9420 snum = lp_servicenumber(new_name);
9422 lp_do_parameter(snum, "copy", lp_servicename(snum));
9427 /***********************************************************
9428 Set the global name resolution order (used in smbclient).
9429 ************************************************************/
9431 void lp_set_name_resolve_order(const char *new_order)
9433 string_set(&Globals.szNameResolveOrder, new_order);
9436 const char *lp_printername(int snum)
9438 const char *ret = _lp_printername(snum);
9439 if (ret == NULL || (ret != NULL && *ret == '\0'))
9440 ret = lp_const_servicename(snum);
9446 /***********************************************************
9447 Allow daemons such as winbindd to fix their logfile name.
9448 ************************************************************/
9450 void lp_set_logfile(const char *name)
9452 string_set(&Globals.szLogFile, name);
9453 debug_set_logfile(name);
9456 /*******************************************************************
9457 Return the max print jobs per queue.
9458 ********************************************************************/
9460 int lp_maxprintjobs(int snum)
9462 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9463 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9464 maxjobs = PRINT_MAX_JOBID - 1;
9469 const char *lp_printcapname(void)
9471 if ((Globals.szPrintcapname != NULL) &&
9472 (Globals.szPrintcapname[0] != '\0'))
9473 return Globals.szPrintcapname;
9475 if (sDefault.iPrinting == PRINT_CUPS) {
9483 if (sDefault.iPrinting == PRINT_BSD)
9484 return "/etc/printcap";
9486 return PRINTCAP_NAME;
9489 static uint32 spoolss_state;
9491 bool lp_disable_spoolss( void )
9493 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9494 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9496 return spoolss_state == SVCCTL_STOPPED ? true : false;
9499 void lp_set_spoolss_state( uint32 state )
9501 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9503 spoolss_state = state;
9506 uint32 lp_get_spoolss_state( void )
9508 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9511 /*******************************************************************
9512 Ensure we don't use sendfile if server smb signing is active.
9513 ********************************************************************/
9515 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9517 bool sign_active = false;
9519 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9520 if (get_Protocol() < PROTOCOL_NT1) {
9523 if (signing_state) {
9524 sign_active = smb_signing_is_active(signing_state);
9526 return (_lp_use_sendfile(snum) &&
9527 (get_remote_arch() != RA_WIN95) &&
9531 /*******************************************************************
9532 Turn off sendfile if we find the underlying OS doesn't support it.
9533 ********************************************************************/
9535 void set_use_sendfile(int snum, bool val)
9537 if (LP_SNUM_OK(snum))
9538 ServicePtrs[snum]->bUseSendfile = val;
9540 sDefault.bUseSendfile = val;
9543 /*******************************************************************
9544 Turn off storing DOS attributes if this share doesn't support it.
9545 ********************************************************************/
9547 void set_store_dos_attributes(int snum, bool val)
9549 if (!LP_SNUM_OK(snum))
9551 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9554 void lp_set_mangling_method(const char *new_method)
9556 string_set(&Globals.szManglingMethod, new_method);
9559 /*******************************************************************
9560 Global state for POSIX pathname processing.
9561 ********************************************************************/
9563 static bool posix_pathnames;
9565 bool lp_posix_pathnames(void)
9567 return posix_pathnames;
9570 /*******************************************************************
9571 Change everything needed to ensure POSIX pathname processing (currently
9573 ********************************************************************/
9575 void lp_set_posix_pathnames(void)
9577 posix_pathnames = true;
9580 /*******************************************************************
9581 Global state for POSIX lock processing - CIFS unix extensions.
9582 ********************************************************************/
9584 bool posix_default_lock_was_set;
9585 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9587 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9589 if (posix_default_lock_was_set) {
9590 return posix_cifsx_locktype;
9592 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9596 /*******************************************************************
9597 ********************************************************************/
9599 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9601 posix_default_lock_was_set = true;
9602 posix_cifsx_locktype = val;
9605 int lp_min_receive_file_size(void)
9607 if (Globals.iminreceivefile < 0) {
9610 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9613 /*******************************************************************
9614 If socket address is an empty character string, it is necessary to
9615 define it as "0.0.0.0".
9616 ********************************************************************/
9618 const char *lp_socket_address(void)
9620 char *sock_addr = Globals.szSocketAddress;
9622 if (sock_addr[0] == '\0'){
9623 string_set(&Globals.szSocketAddress, "0.0.0.0");
9625 return Globals.szSocketAddress;
9628 /*******************************************************************
9629 Safe wide links checks.
9630 This helper function always verify the validity of wide links,
9631 even after a configuration file reload.
9632 ********************************************************************/
9634 static bool lp_widelinks_internal(int snum)
9636 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9637 sDefault.bWidelinks);
9640 void widelinks_warning(int snum)
9642 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9643 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9644 "These parameters are incompatible. "
9645 "Wide links will be disabled for this share.\n",
9646 lp_servicename(snum) ));
9650 bool lp_widelinks(int snum)
9652 /* wide links is always incompatible with unix extensions */
9653 if (lp_unix_extensions()) {
9657 return lp_widelinks_internal(snum);
9660 bool lp_writeraw(void)
9662 if (lp_async_smb_echo_handler()) {
9665 return _lp_writeraw();
9668 bool lp_readraw(void)
9670 if (lp_async_smb_echo_handler()) {
9673 return _lp_readraw();