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 struct param_opt_struct {
110 struct param_opt_struct *prev, *next;
117 #define LOADPARM_EXTRA_GLOBALS \
118 struct param_opt_struct *param_opt; \
121 int iminreceivefile; \
122 char *szPrintcapname; \
124 int iPreferredMaster; \
126 char *szLdapMachineSuffix; \
127 char *szLdapUserSuffix; \
128 char *szLdapIdmapSuffix; \
129 char *szLdapGroupSuffix; \
132 char *szSocketAddress; \
133 char *szUsershareTemplateShare; \
136 int winbindMaxDomainConnections; \
137 int ismb2_max_credits;
138 #define LOADPARM_EXTRA_LOCALS \
141 struct timespec usershare_last_mod; \
147 struct param_opt_struct *param_opt; \
148 struct bitmap *copymap; \
149 char dummy[3]; /* for alignment */
151 #include "param/param_global.h"
152 #include "param/param_local.h"
154 static struct loadparm_global Globals;
156 /* This is a default service used to prime a services structure */
157 static struct loadparm_service sDefault =
162 .usershare_last_mod = {0, 0},
166 .szInvalidUsers = NULL,
167 .szValidUsers = NULL,
168 .szAdminUsers = NULL,
173 .szRootPreExec = NULL,
174 .szRootPostExec = NULL,
175 .szCupsOptions = NULL,
176 .szPrintcommand = NULL,
177 .szLpqcommand = NULL,
178 .szLprmcommand = NULL,
179 .szLppausecommand = NULL,
180 .szLpresumecommand = NULL,
181 .szQueuepausecommand = NULL,
182 .szQueueresumecommand = NULL,
183 .szPrintername = NULL,
184 .szPrintjobUsername = NULL,
185 .szDontdescend = NULL,
186 .szHostsallow = NULL,
188 .szMagicScript = NULL,
189 .szMagicOutput = NULL,
192 .szVetoOplockFiles = NULL,
198 .printer_admin = NULL,
201 .szVfsObjects = NULL,
202 .szMSDfsProxy = NULL,
203 .szAioWriteBehind = NULL,
206 .iMaxPrintJobs = 1000,
207 .iMaxReportedPrintJobs = 0,
208 .iWriteCacheSize = 0,
209 .iCreate_mask = 0744,
210 .iCreate_force_mode = 0,
211 .iSecurity_mask = 0777,
212 .iSecurity_force_mode = 0,
214 .iDir_force_mode = 0,
215 .iDir_Security_mask = 0777,
216 .iDir_Security_force_mode = 0,
217 .iMaxConnections = 0,
218 .iDefaultCase = CASE_LOWER,
219 .iPrinting = DEFAULT_PRINTING,
220 .iOplockContentionLimit = 2,
223 .iDfreeCacheTime = 0,
224 .bPreexecClose = false,
225 .bRootpreexecClose = false,
226 .iCaseSensitive = Auto,
227 .bCasePreserve = true,
228 .bShortCasePreserve = true,
229 .bHideDotFiles = true,
230 .bHideSpecialFiles = false,
231 .bHideUnReadable = false,
232 .bHideUnWriteableFiles = false,
234 .bAccessBasedShareEnum = false,
238 .bGuest_only = false,
239 .bAdministrative_share = false,
242 .bPrintNotifyBackchannel = true,
243 .bMap_system = false,
244 .bMap_hidden = false,
245 .bMap_archive = true,
246 .bStoreDosAttributes = false,
247 .bDmapiSupport = false,
249 .iStrictLocking = Auto,
250 .bPosixLocking = true,
253 .bLevel2OpLocks = true,
255 .bMangledNames = true,
258 .bSyncAlways = false,
259 .bStrictAllocate = false,
260 .bStrictSync = false,
263 .bDeleteReadonly = false,
264 .bFakeOplocks = false,
265 .bDeleteVetoFiles = false,
266 .bDosFilemode = false,
267 .bDosFiletimes = true,
268 .bDosFiletimeResolution = false,
269 .bFakeDirCreateTimes = false,
270 .bBlockingLocks = true,
271 .bInheritPerms = false,
272 .bInheritACLS = false,
273 .bInheritOwner = false,
275 .bUseClientDriver = false,
276 .bDefaultDevmode = true,
277 .bForcePrintername = false,
278 .bNTAclSupport = true,
279 .bForceUnknownAclUser = false,
280 .bUseSendfile = false,
281 .bProfileAcls = false,
282 .bMap_acl_inherit = false,
285 .bAclCheckPermissions = true,
286 .bAclMapFullControl = true,
287 .bAclGroupControl = false,
288 .bChangeNotify = true,
289 .bKernelChangeNotify = true,
290 .iallocation_roundup_size = SMB_ROUNDUP_ALLOCATION_SIZE,
293 .iMap_readonly = MAP_READONLY_YES,
294 #ifdef BROKEN_DIRECTORY_HANDLING
295 .iDirectoryNameCacheSize = 0,
297 .iDirectoryNameCacheSize = 100,
299 .ismb_encrypt = Auto,
304 /* local variables */
305 static struct loadparm_service **ServicePtrs = NULL;
306 static int iNumServices = 0;
307 static int iServiceIndex = 0;
308 static struct db_context *ServiceHash;
309 static int *invalid_services = NULL;
310 static int num_invalid_services = 0;
311 static bool bInGlobalSection = true;
312 static bool bGlobalOnly = false;
314 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
316 /* prototypes for the special type handlers */
317 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
318 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
319 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
320 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
321 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
322 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
323 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
324 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
325 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
326 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
327 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
328 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
330 static void set_allowed_client_auth(void);
332 static void add_to_file_list(const char *fname, const char *subfname);
333 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
335 static const struct enum_list enum_protocol[] = {
336 {PROTOCOL_SMB2, "SMB2"},
337 {PROTOCOL_NT1, "NT1"},
338 {PROTOCOL_LANMAN2, "LANMAN2"},
339 {PROTOCOL_LANMAN1, "LANMAN1"},
340 {PROTOCOL_CORE, "CORE"},
341 {PROTOCOL_COREPLUS, "COREPLUS"},
342 {PROTOCOL_COREPLUS, "CORE+"},
346 static const struct enum_list enum_security[] = {
347 {SEC_SHARE, "SHARE"},
349 {SEC_SERVER, "SERVER"},
350 {SEC_DOMAIN, "DOMAIN"},
357 static const struct enum_list enum_printing[] = {
358 {PRINT_SYSV, "sysv"},
360 {PRINT_HPUX, "hpux"},
364 {PRINT_LPRNG, "lprng"},
365 {PRINT_CUPS, "cups"},
366 {PRINT_IPRINT, "iprint"},
368 {PRINT_LPROS2, "os2"},
369 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
370 {PRINT_TEST, "test"},
372 #endif /* DEVELOPER */
376 static const struct enum_list enum_ldap_sasl_wrapping[] = {
378 {ADS_AUTH_SASL_SIGN, "sign"},
379 {ADS_AUTH_SASL_SEAL, "seal"},
383 static const struct enum_list enum_ldap_ssl[] = {
384 {LDAP_SSL_OFF, "no"},
385 {LDAP_SSL_OFF, "off"},
386 {LDAP_SSL_START_TLS, "start tls"},
387 {LDAP_SSL_START_TLS, "start_tls"},
391 /* LDAP Dereferencing Alias types */
392 #define SAMBA_LDAP_DEREF_NEVER 0
393 #define SAMBA_LDAP_DEREF_SEARCHING 1
394 #define SAMBA_LDAP_DEREF_FINDING 2
395 #define SAMBA_LDAP_DEREF_ALWAYS 3
397 static const struct enum_list enum_ldap_deref[] = {
398 {SAMBA_LDAP_DEREF_NEVER, "never"},
399 {SAMBA_LDAP_DEREF_SEARCHING, "searching"},
400 {SAMBA_LDAP_DEREF_FINDING, "finding"},
401 {SAMBA_LDAP_DEREF_ALWAYS, "always"},
405 static const struct enum_list enum_ldap_passwd_sync[] = {
406 {LDAP_PASSWD_SYNC_OFF, "no"},
407 {LDAP_PASSWD_SYNC_OFF, "off"},
408 {LDAP_PASSWD_SYNC_ON, "yes"},
409 {LDAP_PASSWD_SYNC_ON, "on"},
410 {LDAP_PASSWD_SYNC_ONLY, "only"},
414 static const struct enum_list enum_map_readonly[] = {
415 {MAP_READONLY_NO, "no"},
416 {MAP_READONLY_NO, "false"},
417 {MAP_READONLY_NO, "0"},
418 {MAP_READONLY_YES, "yes"},
419 {MAP_READONLY_YES, "true"},
420 {MAP_READONLY_YES, "1"},
421 {MAP_READONLY_PERMISSIONS, "permissions"},
422 {MAP_READONLY_PERMISSIONS, "perms"},
426 static const struct enum_list enum_case[] = {
427 {CASE_LOWER, "lower"},
428 {CASE_UPPER, "upper"},
434 static const struct enum_list enum_bool_auto[] = {
445 static const struct enum_list enum_csc_policy[] = {
446 {CSC_POLICY_MANUAL, "manual"},
447 {CSC_POLICY_DOCUMENTS, "documents"},
448 {CSC_POLICY_PROGRAMS, "programs"},
449 {CSC_POLICY_DISABLE, "disable"},
453 /* SMB signing types. */
454 static const struct enum_list enum_smb_signing_vals[] = {
466 {Required, "required"},
467 {Required, "mandatory"},
469 {Required, "forced"},
470 {Required, "enforced"},
474 /* ACL compatibility options. */
475 static const struct enum_list enum_acl_compat_vals[] = {
476 { ACL_COMPAT_AUTO, "auto" },
477 { ACL_COMPAT_WINNT, "winnt" },
478 { ACL_COMPAT_WIN2K, "win2k" },
483 Do you want session setups at user level security with a invalid
484 password to be rejected or allowed in as guest? WinNT rejects them
485 but it can be a pain as it means "net view" needs to use a password
487 You have 3 choices in the setting of map_to_guest:
489 "Never" means session setups with an invalid password
490 are rejected. This is the default.
492 "Bad User" means session setups with an invalid password
493 are rejected, unless the username does not exist, in which case it
494 is treated as a guest login
496 "Bad Password" means session setups with an invalid password
497 are treated as a guest login
499 Note that map_to_guest only has an effect in user or server
503 static const struct enum_list enum_map_to_guest[] = {
504 {NEVER_MAP_TO_GUEST, "Never"},
505 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
506 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
507 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
511 /* Config backend options */
513 static const struct enum_list enum_config_backend[] = {
514 {CONFIG_BACKEND_FILE, "file"},
515 {CONFIG_BACKEND_REGISTRY, "registry"},
519 /* ADS kerberos ticket verification options */
521 static const struct enum_list enum_kerberos_method[] = {
522 {KERBEROS_VERIFY_SECRETS, "default"},
523 {KERBEROS_VERIFY_SECRETS, "secrets only"},
524 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
525 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
526 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
530 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
532 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
533 * screen in SWAT. This is used to exclude parameters as well as to squash all
534 * parameters that have been duplicated by pseudonyms.
536 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
537 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
538 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
541 * NOTE2: Handling of duplicated (synonym) parameters:
542 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
543 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
544 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
545 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
548 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
549 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
551 static struct parm_struct parm_table[] = {
552 {N_("Base Options"), P_SEP, P_SEPARATOR},
555 .label = "dos charset",
558 .offset = GLOBAL_VAR(dos_charset),
559 .special = handle_dos_charset,
561 .flags = FLAG_ADVANCED
564 .label = "unix charset",
567 .offset = GLOBAL_VAR(unix_charset),
568 .special = handle_charset,
570 .flags = FLAG_ADVANCED
576 .offset = LOCAL_VAR(comment),
579 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
585 .offset = LOCAL_VAR(szPath),
588 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
591 .label = "directory",
594 .offset = LOCAL_VAR(szPath),
600 .label = "workgroup",
603 .offset = GLOBAL_VAR(szWorkgroup),
606 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
612 .offset = GLOBAL_VAR(szRealm),
613 .special = handle_realm,
615 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
618 .label = "netbios name",
621 .offset = GLOBAL_VAR(szNetbiosName),
624 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
627 .label = "netbios aliases",
630 .offset = GLOBAL_VAR(szNetbiosAliases),
631 .special = handle_netbios_aliases,
633 .flags = FLAG_ADVANCED,
636 .label = "netbios scope",
639 .offset = GLOBAL_VAR(szNetbiosScope),
642 .flags = FLAG_ADVANCED,
645 .label = "server string",
648 .offset = GLOBAL_VAR(szServerString),
651 .flags = FLAG_BASIC | FLAG_ADVANCED,
654 .label = "interfaces",
657 .offset = GLOBAL_VAR(szInterfaces),
660 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
663 .label = "bind interfaces only",
666 .offset = GLOBAL_VAR(bBindInterfacesOnly),
669 .flags = FLAG_ADVANCED | FLAG_WIZARD,
672 .label = "config backend",
675 .offset = GLOBAL_VAR(ConfigBackend),
677 .enum_list = enum_config_backend,
678 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
681 {N_("Security Options"), P_SEP, P_SEPARATOR},
687 .offset = GLOBAL_VAR(security),
689 .enum_list = enum_security,
690 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
693 .label = "auth methods",
696 .offset = GLOBAL_VAR(AuthMethods),
699 .flags = FLAG_ADVANCED,
702 .label = "encrypt passwords",
705 .offset = GLOBAL_VAR(bEncryptPasswords),
708 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
711 .label = "client schannel",
714 .offset = GLOBAL_VAR(clientSchannel),
716 .enum_list = enum_bool_auto,
717 .flags = FLAG_BASIC | FLAG_ADVANCED,
720 .label = "server schannel",
723 .offset = GLOBAL_VAR(serverSchannel),
725 .enum_list = enum_bool_auto,
726 .flags = FLAG_BASIC | FLAG_ADVANCED,
729 .label = "allow trusted domains",
732 .offset = GLOBAL_VAR(bAllowTrustedDomains),
735 .flags = FLAG_ADVANCED,
738 .label = "map to guest",
741 .offset = GLOBAL_VAR(map_to_guest),
743 .enum_list = enum_map_to_guest,
744 .flags = FLAG_ADVANCED,
747 .label = "null passwords",
750 .offset = GLOBAL_VAR(bNullPasswords),
753 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
756 .label = "obey pam restrictions",
759 .offset = GLOBAL_VAR(bObeyPamRestrictions),
762 .flags = FLAG_ADVANCED,
765 .label = "password server",
768 .offset = GLOBAL_VAR(szPasswordServer),
771 .flags = FLAG_ADVANCED | FLAG_WIZARD,
774 .label = "smb passwd file",
777 .offset = GLOBAL_VAR(szSMBPasswdFile),
780 .flags = FLAG_ADVANCED,
783 .label = "private dir",
786 .offset = GLOBAL_VAR(szPrivateDir),
789 .flags = FLAG_ADVANCED,
792 .label = "passdb backend",
795 .offset = GLOBAL_VAR(szPassdbBackend),
798 .flags = FLAG_ADVANCED | FLAG_WIZARD,
801 .label = "algorithmic rid base",
804 .offset = GLOBAL_VAR(AlgorithmicRidBase),
807 .flags = FLAG_ADVANCED,
810 .label = "root directory",
813 .offset = GLOBAL_VAR(szRootdir),
816 .flags = FLAG_ADVANCED,
822 .offset = GLOBAL_VAR(szRootdir),
831 .offset = GLOBAL_VAR(szRootdir),
837 .label = "guest account",
840 .offset = GLOBAL_VAR(szGuestaccount),
843 .flags = FLAG_BASIC | FLAG_ADVANCED,
846 .label = "enable privileges",
849 .offset = GLOBAL_VAR(bEnablePrivileges),
852 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
856 .label = "pam password change",
859 .offset = GLOBAL_VAR(bPamPasswordChange),
862 .flags = FLAG_ADVANCED,
865 .label = "passwd program",
868 .offset = GLOBAL_VAR(szPasswdProgram),
871 .flags = FLAG_ADVANCED,
874 .label = "passwd chat",
877 .offset = GLOBAL_VAR(szPasswdChat),
880 .flags = FLAG_ADVANCED,
883 .label = "passwd chat debug",
886 .offset = GLOBAL_VAR(bPasswdChatDebug),
889 .flags = FLAG_ADVANCED,
892 .label = "passwd chat timeout",
895 .offset = GLOBAL_VAR(iPasswdChatTimeout),
898 .flags = FLAG_ADVANCED,
901 .label = "check password script",
904 .offset = GLOBAL_VAR(szCheckPasswordScript),
907 .flags = FLAG_ADVANCED,
910 .label = "username map",
913 .offset = GLOBAL_VAR(szUsernameMap),
916 .flags = FLAG_ADVANCED,
919 .label = "password level",
922 .offset = GLOBAL_VAR(pwordlevel),
925 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
928 .label = "username level",
931 .offset = GLOBAL_VAR(unamelevel),
934 .flags = FLAG_ADVANCED,
937 .label = "unix password sync",
940 .offset = GLOBAL_VAR(bUnixPasswdSync),
943 .flags = FLAG_ADVANCED,
946 .label = "restrict anonymous",
949 .offset = GLOBAL_VAR(restrict_anonymous),
952 .flags = FLAG_ADVANCED,
955 .label = "lanman auth",
958 .offset = GLOBAL_VAR(bLanmanAuth),
961 .flags = FLAG_ADVANCED,
964 .label = "ntlm auth",
967 .offset = GLOBAL_VAR(bNTLMAuth),
970 .flags = FLAG_ADVANCED,
973 .label = "client NTLMv2 auth",
976 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
979 .flags = FLAG_ADVANCED,
982 .label = "client lanman auth",
985 .offset = GLOBAL_VAR(bClientLanManAuth),
988 .flags = FLAG_ADVANCED,
991 .label = "client plaintext auth",
994 .offset = GLOBAL_VAR(bClientPlaintextAuth),
997 .flags = FLAG_ADVANCED,
1000 .label = "client use spnego principal",
1002 .p_class = P_GLOBAL,
1003 .offset = GLOBAL_VAR(client_use_spnego_principal),
1006 .flags = FLAG_ADVANCED,
1009 .label = "send spnego principal",
1011 .p_class = P_GLOBAL,
1012 .offset = GLOBAL_VAR(send_spnego_principal),
1015 .flags = FLAG_ADVANCED,
1018 .label = "username",
1021 .offset = LOCAL_VAR(szUsername),
1024 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
1030 .offset = LOCAL_VAR(szUsername),
1039 .offset = LOCAL_VAR(szUsername),
1045 .label = "invalid users",
1048 .offset = LOCAL_VAR(szInvalidUsers),
1051 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1054 .label = "valid users",
1057 .offset = LOCAL_VAR(szValidUsers),
1060 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1063 .label = "admin users",
1066 .offset = LOCAL_VAR(szAdminUsers),
1069 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1072 .label = "read list",
1075 .offset = LOCAL_VAR(readlist),
1078 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1081 .label = "write list",
1084 .offset = LOCAL_VAR(writelist),
1087 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1090 .label = "printer admin",
1093 .offset = LOCAL_VAR(printer_admin),
1096 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1099 .label = "force user",
1102 .offset = LOCAL_VAR(force_user),
1105 .flags = FLAG_ADVANCED | FLAG_SHARE,
1108 .label = "force group",
1111 .offset = LOCAL_VAR(force_group),
1114 .flags = FLAG_ADVANCED | FLAG_SHARE,
1120 .offset = LOCAL_VAR(force_group),
1123 .flags = FLAG_ADVANCED,
1126 .label = "read only",
1129 .offset = LOCAL_VAR(bRead_only),
1132 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1135 .label = "write ok",
1138 .offset = LOCAL_VAR(bRead_only),
1144 .label = "writeable",
1147 .offset = LOCAL_VAR(bRead_only),
1153 .label = "writable",
1156 .offset = LOCAL_VAR(bRead_only),
1162 .label = "acl check permissions",
1165 .offset = LOCAL_VAR(bAclCheckPermissions),
1168 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1171 .label = "acl group control",
1174 .offset = LOCAL_VAR(bAclGroupControl),
1177 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1180 .label = "acl map full control",
1183 .offset = LOCAL_VAR(bAclMapFullControl),
1186 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1189 .label = "create mask",
1192 .offset = LOCAL_VAR(iCreate_mask),
1195 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1198 .label = "create mode",
1201 .offset = LOCAL_VAR(iCreate_mask),
1207 .label = "force create mode",
1210 .offset = LOCAL_VAR(iCreate_force_mode),
1213 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1216 .label = "security mask",
1219 .offset = LOCAL_VAR(iSecurity_mask),
1222 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1225 .label = "force security mode",
1228 .offset = LOCAL_VAR(iSecurity_force_mode),
1231 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1234 .label = "directory mask",
1237 .offset = LOCAL_VAR(iDir_mask),
1240 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1243 .label = "directory mode",
1246 .offset = LOCAL_VAR(iDir_mask),
1249 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1252 .label = "force directory mode",
1255 .offset = LOCAL_VAR(iDir_force_mode),
1258 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1261 .label = "directory security mask",
1264 .offset = LOCAL_VAR(iDir_Security_mask),
1267 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1270 .label = "force directory security mode",
1273 .offset = LOCAL_VAR(iDir_Security_force_mode),
1276 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1279 .label = "force unknown acl user",
1282 .offset = LOCAL_VAR(bForceUnknownAclUser),
1285 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1288 .label = "inherit permissions",
1291 .offset = LOCAL_VAR(bInheritPerms),
1294 .flags = FLAG_ADVANCED | FLAG_SHARE,
1297 .label = "inherit acls",
1300 .offset = LOCAL_VAR(bInheritACLS),
1303 .flags = FLAG_ADVANCED | FLAG_SHARE,
1306 .label = "inherit owner",
1309 .offset = LOCAL_VAR(bInheritOwner),
1312 .flags = FLAG_ADVANCED | FLAG_SHARE,
1315 .label = "guest only",
1318 .offset = LOCAL_VAR(bGuest_only),
1321 .flags = FLAG_ADVANCED | FLAG_SHARE,
1324 .label = "only guest",
1327 .offset = LOCAL_VAR(bGuest_only),
1333 .label = "administrative share",
1336 .offset = LOCAL_VAR(bAdministrative_share),
1339 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1343 .label = "guest ok",
1346 .offset = LOCAL_VAR(bGuest_ok),
1349 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1355 .offset = LOCAL_VAR(bGuest_ok),
1361 .label = "only user",
1364 .offset = LOCAL_VAR(bOnlyUser),
1367 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1370 .label = "hosts allow",
1373 .offset = LOCAL_VAR(szHostsallow),
1376 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1379 .label = "allow hosts",
1382 .offset = LOCAL_VAR(szHostsallow),
1388 .label = "hosts deny",
1391 .offset = LOCAL_VAR(szHostsdeny),
1394 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1397 .label = "deny hosts",
1400 .offset = LOCAL_VAR(szHostsdeny),
1406 .label = "preload modules",
1408 .p_class = P_GLOBAL,
1409 .offset = GLOBAL_VAR(szPreloadModules),
1412 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1415 .label = "dedicated keytab file",
1417 .p_class = P_GLOBAL,
1418 .offset = GLOBAL_VAR(szDedicatedKeytabFile),
1421 .flags = FLAG_ADVANCED,
1424 .label = "kerberos method",
1426 .p_class = P_GLOBAL,
1427 .offset = GLOBAL_VAR(iKerberosMethod),
1429 .enum_list = enum_kerberos_method,
1430 .flags = FLAG_ADVANCED,
1433 .label = "map untrusted to domain",
1435 .p_class = P_GLOBAL,
1436 .offset = GLOBAL_VAR(bMapUntrustedToDomain),
1439 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1443 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1446 .label = "log level",
1448 .p_class = P_GLOBAL,
1449 .offset = GLOBAL_VAR(szLogLevel),
1450 .special = handle_debug_list,
1452 .flags = FLAG_ADVANCED,
1455 .label = "debuglevel",
1457 .p_class = P_GLOBAL,
1458 .offset = GLOBAL_VAR(szLogLevel),
1459 .special = handle_debug_list,
1466 .p_class = P_GLOBAL,
1467 .offset = GLOBAL_VAR(syslog),
1470 .flags = FLAG_ADVANCED,
1473 .label = "syslog only",
1475 .p_class = P_GLOBAL,
1476 .offset = GLOBAL_VAR(bSyslogOnly),
1479 .flags = FLAG_ADVANCED,
1482 .label = "log file",
1484 .p_class = P_GLOBAL,
1485 .offset = GLOBAL_VAR(szLogFile),
1488 .flags = FLAG_ADVANCED,
1491 .label = "max log size",
1493 .p_class = P_GLOBAL,
1494 .offset = GLOBAL_VAR(max_log_size),
1497 .flags = FLAG_ADVANCED,
1500 .label = "debug timestamp",
1502 .p_class = P_GLOBAL,
1503 .offset = GLOBAL_VAR(bTimestampLogs),
1506 .flags = FLAG_ADVANCED,
1509 .label = "timestamp logs",
1511 .p_class = P_GLOBAL,
1512 .offset = GLOBAL_VAR(bTimestampLogs),
1515 .flags = FLAG_ADVANCED,
1518 .label = "debug prefix timestamp",
1520 .p_class = P_GLOBAL,
1521 .offset = GLOBAL_VAR(bDebugPrefixTimestamp),
1524 .flags = FLAG_ADVANCED,
1527 .label = "debug hires timestamp",
1529 .p_class = P_GLOBAL,
1530 .offset = GLOBAL_VAR(bDebugHiresTimestamp),
1533 .flags = FLAG_ADVANCED,
1536 .label = "debug pid",
1538 .p_class = P_GLOBAL,
1539 .offset = GLOBAL_VAR(bDebugPid),
1542 .flags = FLAG_ADVANCED,
1545 .label = "debug uid",
1547 .p_class = P_GLOBAL,
1548 .offset = GLOBAL_VAR(bDebugUid),
1551 .flags = FLAG_ADVANCED,
1554 .label = "debug class",
1556 .p_class = P_GLOBAL,
1557 .offset = GLOBAL_VAR(bDebugClass),
1560 .flags = FLAG_ADVANCED,
1563 .label = "enable core files",
1565 .p_class = P_GLOBAL,
1566 .offset = GLOBAL_VAR(bEnableCoreFiles),
1569 .flags = FLAG_ADVANCED,
1572 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1575 .label = "allocation roundup size",
1578 .offset = LOCAL_VAR(iallocation_roundup_size),
1581 .flags = FLAG_ADVANCED,
1584 .label = "aio read size",
1587 .offset = LOCAL_VAR(iAioReadSize),
1590 .flags = FLAG_ADVANCED,
1593 .label = "aio write size",
1596 .offset = LOCAL_VAR(iAioWriteSize),
1599 .flags = FLAG_ADVANCED,
1602 .label = "aio write behind",
1605 .offset = LOCAL_VAR(szAioWriteBehind),
1608 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1611 .label = "smb ports",
1613 .p_class = P_GLOBAL,
1614 .offset = GLOBAL_VAR(smb_ports),
1617 .flags = FLAG_ADVANCED,
1620 .label = "large readwrite",
1622 .p_class = P_GLOBAL,
1623 .offset = GLOBAL_VAR(bLargeReadwrite),
1626 .flags = FLAG_ADVANCED,
1629 .label = "max protocol",
1631 .p_class = P_GLOBAL,
1632 .offset = GLOBAL_VAR(maxprotocol),
1634 .enum_list = enum_protocol,
1635 .flags = FLAG_ADVANCED,
1638 .label = "protocol",
1640 .p_class = P_GLOBAL,
1641 .offset = GLOBAL_VAR(maxprotocol),
1643 .enum_list = enum_protocol,
1644 .flags = FLAG_ADVANCED,
1647 .label = "min protocol",
1649 .p_class = P_GLOBAL,
1650 .offset = GLOBAL_VAR(minprotocol),
1652 .enum_list = enum_protocol,
1653 .flags = FLAG_ADVANCED,
1656 .label = "min receivefile size",
1658 .p_class = P_GLOBAL,
1659 .offset = GLOBAL_VAR(iminreceivefile),
1662 .flags = FLAG_ADVANCED,
1665 .label = "read raw",
1667 .p_class = P_GLOBAL,
1668 .offset = GLOBAL_VAR(bReadRaw),
1671 .flags = FLAG_ADVANCED,
1674 .label = "write raw",
1676 .p_class = P_GLOBAL,
1677 .offset = GLOBAL_VAR(bWriteRaw),
1680 .flags = FLAG_ADVANCED,
1683 .label = "disable netbios",
1685 .p_class = P_GLOBAL,
1686 .offset = GLOBAL_VAR(bDisableNetbios),
1689 .flags = FLAG_ADVANCED,
1692 .label = "reset on zero vc",
1694 .p_class = P_GLOBAL,
1695 .offset = GLOBAL_VAR(bResetOnZeroVC),
1698 .flags = FLAG_ADVANCED,
1701 .label = "log writeable files on exit",
1703 .p_class = P_GLOBAL,
1704 .offset = GLOBAL_VAR(bLogWriteableFilesOnExit),
1707 .flags = FLAG_ADVANCED,
1710 .label = "acl compatibility",
1712 .p_class = P_GLOBAL,
1713 .offset = GLOBAL_VAR(iAclCompat),
1715 .enum_list = enum_acl_compat_vals,
1716 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1719 .label = "defer sharing violations",
1721 .p_class = P_GLOBAL,
1722 .offset = GLOBAL_VAR(bDeferSharingViolations),
1725 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1728 .label = "ea support",
1731 .offset = LOCAL_VAR(bEASupport),
1734 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1737 .label = "nt acl support",
1740 .offset = LOCAL_VAR(bNTAclSupport),
1743 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1746 .label = "nt pipe support",
1748 .p_class = P_GLOBAL,
1749 .offset = GLOBAL_VAR(bNTPipeSupport),
1752 .flags = FLAG_ADVANCED,
1755 .label = "nt status support",
1757 .p_class = P_GLOBAL,
1758 .offset = GLOBAL_VAR(bNTStatusSupport),
1761 .flags = FLAG_ADVANCED,
1764 .label = "profile acls",
1767 .offset = LOCAL_VAR(bProfileAcls),
1770 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1773 .label = "map acl inherit",
1776 .offset = LOCAL_VAR(bMap_acl_inherit),
1779 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1782 .label = "afs share",
1785 .offset = LOCAL_VAR(bAfs_Share),
1788 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1793 .p_class = P_GLOBAL,
1794 .offset = GLOBAL_VAR(max_mux),
1797 .flags = FLAG_ADVANCED,
1800 .label = "max xmit",
1802 .p_class = P_GLOBAL,
1803 .offset = GLOBAL_VAR(max_xmit),
1806 .flags = FLAG_ADVANCED,
1809 .label = "name resolve order",
1811 .p_class = P_GLOBAL,
1812 .offset = GLOBAL_VAR(szNameResolveOrder),
1815 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1820 .p_class = P_GLOBAL,
1821 .offset = GLOBAL_VAR(max_ttl),
1824 .flags = FLAG_ADVANCED,
1827 .label = "max wins ttl",
1829 .p_class = P_GLOBAL,
1830 .offset = GLOBAL_VAR(max_wins_ttl),
1833 .flags = FLAG_ADVANCED,
1836 .label = "min wins ttl",
1838 .p_class = P_GLOBAL,
1839 .offset = GLOBAL_VAR(min_wins_ttl),
1842 .flags = FLAG_ADVANCED,
1845 .label = "time server",
1847 .p_class = P_GLOBAL,
1848 .offset = GLOBAL_VAR(bTimeServer),
1851 .flags = FLAG_ADVANCED,
1854 .label = "unix extensions",
1856 .p_class = P_GLOBAL,
1857 .offset = GLOBAL_VAR(bUnixExtensions),
1860 .flags = FLAG_ADVANCED,
1863 .label = "use spnego",
1865 .p_class = P_GLOBAL,
1866 .offset = GLOBAL_VAR(bUseSpnego),
1869 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
1872 .label = "client signing",
1874 .p_class = P_GLOBAL,
1875 .offset = GLOBAL_VAR(client_signing),
1877 .enum_list = enum_smb_signing_vals,
1878 .flags = FLAG_ADVANCED,
1881 .label = "server signing",
1883 .p_class = P_GLOBAL,
1884 .offset = GLOBAL_VAR(server_signing),
1886 .enum_list = enum_smb_signing_vals,
1887 .flags = FLAG_ADVANCED,
1890 .label = "smb encrypt",
1893 .offset = LOCAL_VAR(ismb_encrypt),
1895 .enum_list = enum_smb_signing_vals,
1896 .flags = FLAG_ADVANCED,
1899 .label = "client use spnego",
1901 .p_class = P_GLOBAL,
1902 .offset = GLOBAL_VAR(bClientUseSpnego),
1905 .flags = FLAG_ADVANCED,
1908 .label = "client ldap sasl wrapping",
1910 .p_class = P_GLOBAL,
1911 .offset = GLOBAL_VAR(client_ldap_sasl_wrapping),
1913 .enum_list = enum_ldap_sasl_wrapping,
1914 .flags = FLAG_ADVANCED,
1917 .label = "enable asu support",
1919 .p_class = P_GLOBAL,
1920 .offset = GLOBAL_VAR(bASUSupport),
1923 .flags = FLAG_ADVANCED,
1926 .label = "svcctl list",
1928 .p_class = P_GLOBAL,
1929 .offset = GLOBAL_VAR(szServicesList),
1932 .flags = FLAG_ADVANCED,
1935 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
1938 .label = "block size",
1941 .offset = LOCAL_VAR(iBlock_size),
1944 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1947 .label = "deadtime",
1949 .p_class = P_GLOBAL,
1950 .offset = GLOBAL_VAR(deadtime),
1953 .flags = FLAG_ADVANCED,
1956 .label = "getwd cache",
1958 .p_class = P_GLOBAL,
1959 .offset = GLOBAL_VAR(getwd_cache),
1962 .flags = FLAG_ADVANCED,
1965 .label = "keepalive",
1967 .p_class = P_GLOBAL,
1968 .offset = GLOBAL_VAR(iKeepalive),
1971 .flags = FLAG_ADVANCED,
1974 .label = "change notify",
1977 .offset = LOCAL_VAR(bChangeNotify),
1980 .flags = FLAG_ADVANCED | FLAG_SHARE,
1983 .label = "directory name cache size",
1986 .offset = LOCAL_VAR(iDirectoryNameCacheSize),
1989 .flags = FLAG_ADVANCED | FLAG_SHARE,
1992 .label = "kernel change notify",
1995 .offset = LOCAL_VAR(bKernelChangeNotify),
1998 .flags = FLAG_ADVANCED | FLAG_SHARE,
2001 .label = "lpq cache time",
2003 .p_class = P_GLOBAL,
2004 .offset = GLOBAL_VAR(lpqcachetime),
2007 .flags = FLAG_ADVANCED,
2010 .label = "max smbd processes",
2012 .p_class = P_GLOBAL,
2013 .offset = GLOBAL_VAR(iMaxSmbdProcesses),
2016 .flags = FLAG_ADVANCED,
2019 .label = "max connections",
2022 .offset = LOCAL_VAR(iMaxConnections),
2025 .flags = FLAG_ADVANCED | FLAG_SHARE,
2028 .label = "paranoid server security",
2030 .p_class = P_GLOBAL,
2031 .offset = GLOBAL_VAR(paranoid_server_security),
2034 .flags = FLAG_ADVANCED,
2037 .label = "max disk size",
2039 .p_class = P_GLOBAL,
2040 .offset = GLOBAL_VAR(maxdisksize),
2043 .flags = FLAG_ADVANCED,
2046 .label = "max open files",
2048 .p_class = P_GLOBAL,
2049 .offset = GLOBAL_VAR(max_open_files),
2052 .flags = FLAG_ADVANCED,
2055 .label = "min print space",
2058 .offset = LOCAL_VAR(iMinPrintSpace),
2061 .flags = FLAG_ADVANCED | FLAG_PRINT,
2064 .label = "socket options",
2066 .p_class = P_GLOBAL,
2067 .offset = GLOBAL_VAR(szSocketOptions),
2070 .flags = FLAG_ADVANCED,
2073 .label = "strict allocate",
2076 .offset = LOCAL_VAR(bStrictAllocate),
2079 .flags = FLAG_ADVANCED | FLAG_SHARE,
2082 .label = "strict sync",
2085 .offset = LOCAL_VAR(bStrictSync),
2088 .flags = FLAG_ADVANCED | FLAG_SHARE,
2091 .label = "sync always",
2094 .offset = LOCAL_VAR(bSyncAlways),
2097 .flags = FLAG_ADVANCED | FLAG_SHARE,
2100 .label = "use mmap",
2102 .p_class = P_GLOBAL,
2103 .offset = GLOBAL_VAR(bUseMmap),
2106 .flags = FLAG_ADVANCED,
2109 .label = "use sendfile",
2112 .offset = LOCAL_VAR(bUseSendfile),
2115 .flags = FLAG_ADVANCED | FLAG_SHARE,
2118 .label = "hostname lookups",
2120 .p_class = P_GLOBAL,
2121 .offset = GLOBAL_VAR(bHostnameLookups),
2124 .flags = FLAG_ADVANCED,
2127 .label = "write cache size",
2130 .offset = LOCAL_VAR(iWriteCacheSize),
2133 .flags = FLAG_ADVANCED | FLAG_SHARE,
2136 .label = "name cache timeout",
2138 .p_class = P_GLOBAL,
2139 .offset = GLOBAL_VAR(name_cache_timeout),
2142 .flags = FLAG_ADVANCED,
2145 .label = "ctdbd socket",
2147 .p_class = P_GLOBAL,
2148 .offset = GLOBAL_VAR(ctdbdSocket),
2151 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2154 .label = "cluster addresses",
2156 .p_class = P_GLOBAL,
2157 .offset = GLOBAL_VAR(szClusterAddresses),
2160 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2163 .label = "clustering",
2165 .p_class = P_GLOBAL,
2166 .offset = GLOBAL_VAR(clustering),
2169 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2172 .label = "ctdb timeout",
2174 .p_class = P_GLOBAL,
2175 .offset = GLOBAL_VAR(ctdb_timeout),
2178 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2181 .label = "ctdb locktime warn threshold",
2183 .p_class = P_GLOBAL,
2184 .offset = GLOBAL_VAR(ctdb_locktime_warn_threshold),
2187 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2190 .label = "smb2 max read",
2192 .p_class = P_GLOBAL,
2193 .offset = GLOBAL_VAR(ismb2_max_read),
2196 .flags = FLAG_ADVANCED,
2199 .label = "smb2 max write",
2201 .p_class = P_GLOBAL,
2202 .offset = GLOBAL_VAR(ismb2_max_write),
2205 .flags = FLAG_ADVANCED,
2208 .label = "smb2 max trans",
2210 .p_class = P_GLOBAL,
2211 .offset = GLOBAL_VAR(ismb2_max_trans),
2214 .flags = FLAG_ADVANCED,
2217 .label = "smb2 max credits",
2219 .p_class = P_GLOBAL,
2220 .offset = GLOBAL_VAR(ismb2_max_credits),
2223 .flags = FLAG_ADVANCED,
2226 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2229 .label = "max reported print jobs",
2232 .offset = LOCAL_VAR(iMaxReportedPrintJobs),
2235 .flags = FLAG_ADVANCED | FLAG_PRINT,
2238 .label = "max print jobs",
2241 .offset = LOCAL_VAR(iMaxPrintJobs),
2244 .flags = FLAG_ADVANCED | FLAG_PRINT,
2247 .label = "load printers",
2249 .p_class = P_GLOBAL,
2250 .offset = GLOBAL_VAR(bLoadPrinters),
2253 .flags = FLAG_ADVANCED | FLAG_PRINT,
2256 .label = "printcap cache time",
2258 .p_class = P_GLOBAL,
2259 .offset = GLOBAL_VAR(PrintcapCacheTime),
2262 .flags = FLAG_ADVANCED | FLAG_PRINT,
2265 .label = "printcap name",
2267 .p_class = P_GLOBAL,
2268 .offset = GLOBAL_VAR(szPrintcapname),
2271 .flags = FLAG_ADVANCED | FLAG_PRINT,
2274 .label = "printcap",
2276 .p_class = P_GLOBAL,
2277 .offset = GLOBAL_VAR(szPrintcapname),
2283 .label = "printable",
2286 .offset = LOCAL_VAR(bPrint_ok),
2289 .flags = FLAG_ADVANCED | FLAG_PRINT,
2292 .label = "print notify backchannel",
2295 .offset = LOCAL_VAR(bPrintNotifyBackchannel),
2298 .flags = FLAG_ADVANCED,
2301 .label = "print ok",
2304 .offset = LOCAL_VAR(bPrint_ok),
2310 .label = "printing",
2313 .offset = LOCAL_VAR(iPrinting),
2314 .special = handle_printing,
2315 .enum_list = enum_printing,
2316 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2319 .label = "cups options",
2322 .offset = LOCAL_VAR(szCupsOptions),
2325 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2328 .label = "cups server",
2330 .p_class = P_GLOBAL,
2331 .offset = GLOBAL_VAR(szCupsServer),
2334 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2337 .label = "cups encrypt",
2339 .p_class = P_GLOBAL,
2340 .offset = GLOBAL_VAR(CupsEncrypt),
2342 .enum_list = enum_bool_auto,
2343 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2347 .label = "cups connection timeout",
2349 .p_class = P_GLOBAL,
2350 .offset = GLOBAL_VAR(cups_connection_timeout),
2353 .flags = FLAG_ADVANCED,
2356 .label = "iprint server",
2358 .p_class = P_GLOBAL,
2359 .offset = GLOBAL_VAR(szIPrintServer),
2362 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2365 .label = "print command",
2368 .offset = LOCAL_VAR(szPrintcommand),
2371 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2374 .label = "disable spoolss",
2376 .p_class = P_GLOBAL,
2377 .offset = GLOBAL_VAR(bDisableSpoolss),
2380 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2383 .label = "enable spoolss",
2385 .p_class = P_GLOBAL,
2386 .offset = GLOBAL_VAR(bDisableSpoolss),
2392 .label = "lpq command",
2395 .offset = LOCAL_VAR(szLpqcommand),
2398 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2401 .label = "lprm command",
2404 .offset = LOCAL_VAR(szLprmcommand),
2407 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2410 .label = "lppause command",
2413 .offset = LOCAL_VAR(szLppausecommand),
2416 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2419 .label = "lpresume command",
2422 .offset = LOCAL_VAR(szLpresumecommand),
2425 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2428 .label = "queuepause command",
2431 .offset = LOCAL_VAR(szQueuepausecommand),
2434 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2437 .label = "queueresume command",
2440 .offset = LOCAL_VAR(szQueueresumecommand),
2443 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2446 .label = "addport command",
2448 .p_class = P_GLOBAL,
2449 .offset = GLOBAL_VAR(szAddPortCommand),
2452 .flags = FLAG_ADVANCED,
2455 .label = "enumports command",
2457 .p_class = P_GLOBAL,
2458 .offset = GLOBAL_VAR(szEnumPortsCommand),
2461 .flags = FLAG_ADVANCED,
2464 .label = "addprinter command",
2466 .p_class = P_GLOBAL,
2467 .offset = GLOBAL_VAR(szAddPrinterCommand),
2470 .flags = FLAG_ADVANCED,
2473 .label = "deleteprinter command",
2475 .p_class = P_GLOBAL,
2476 .offset = GLOBAL_VAR(szDeletePrinterCommand),
2479 .flags = FLAG_ADVANCED,
2482 .label = "show add printer wizard",
2484 .p_class = P_GLOBAL,
2485 .offset = GLOBAL_VAR(bMsAddPrinterWizard),
2488 .flags = FLAG_ADVANCED,
2491 .label = "os2 driver map",
2493 .p_class = P_GLOBAL,
2494 .offset = GLOBAL_VAR(szOs2DriverMap),
2497 .flags = FLAG_ADVANCED,
2501 .label = "printer name",
2504 .offset = LOCAL_VAR(szPrintername),
2507 .flags = FLAG_ADVANCED | FLAG_PRINT,
2513 .offset = LOCAL_VAR(szPrintername),
2519 .label = "use client driver",
2522 .offset = LOCAL_VAR(bUseClientDriver),
2525 .flags = FLAG_ADVANCED | FLAG_PRINT,
2528 .label = "default devmode",
2531 .offset = LOCAL_VAR(bDefaultDevmode),
2534 .flags = FLAG_ADVANCED | FLAG_PRINT,
2537 .label = "force printername",
2540 .offset = LOCAL_VAR(bForcePrintername),
2543 .flags = FLAG_ADVANCED | FLAG_PRINT,
2546 .label = "printjob username",
2549 .offset = LOCAL_VAR(szPrintjobUsername),
2552 .flags = FLAG_ADVANCED | FLAG_PRINT,
2555 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2558 .label = "mangling method",
2560 .p_class = P_GLOBAL,
2561 .offset = GLOBAL_VAR(szManglingMethod),
2564 .flags = FLAG_ADVANCED,
2567 .label = "mangle prefix",
2569 .p_class = P_GLOBAL,
2570 .offset = GLOBAL_VAR(mangle_prefix),
2573 .flags = FLAG_ADVANCED,
2577 .label = "default case",
2580 .offset = LOCAL_VAR(iDefaultCase),
2582 .enum_list = enum_case,
2583 .flags = FLAG_ADVANCED | FLAG_SHARE,
2586 .label = "case sensitive",
2589 .offset = LOCAL_VAR(iCaseSensitive),
2591 .enum_list = enum_bool_auto,
2592 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2595 .label = "casesignames",
2598 .offset = LOCAL_VAR(iCaseSensitive),
2600 .enum_list = enum_bool_auto,
2601 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2604 .label = "preserve case",
2607 .offset = LOCAL_VAR(bCasePreserve),
2610 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2613 .label = "short preserve case",
2616 .offset = LOCAL_VAR(bShortCasePreserve),
2619 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2622 .label = "mangling char",
2625 .offset = LOCAL_VAR(magic_char),
2628 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2631 .label = "hide dot files",
2634 .offset = LOCAL_VAR(bHideDotFiles),
2637 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2640 .label = "hide special files",
2643 .offset = LOCAL_VAR(bHideSpecialFiles),
2646 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2649 .label = "hide unreadable",
2652 .offset = LOCAL_VAR(bHideUnReadable),
2655 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2658 .label = "hide unwriteable files",
2661 .offset = LOCAL_VAR(bHideUnWriteableFiles),
2664 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2667 .label = "delete veto files",
2670 .offset = LOCAL_VAR(bDeleteVetoFiles),
2673 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2676 .label = "veto files",
2679 .offset = LOCAL_VAR(szVetoFiles),
2682 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2685 .label = "hide files",
2688 .offset = LOCAL_VAR(szHideFiles),
2691 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2694 .label = "veto oplock files",
2697 .offset = LOCAL_VAR(szVetoOplockFiles),
2700 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2703 .label = "map archive",
2706 .offset = LOCAL_VAR(bMap_archive),
2709 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2712 .label = "map hidden",
2715 .offset = LOCAL_VAR(bMap_hidden),
2718 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2721 .label = "map system",
2724 .offset = LOCAL_VAR(bMap_system),
2727 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2730 .label = "map readonly",
2733 .offset = LOCAL_VAR(iMap_readonly),
2735 .enum_list = enum_map_readonly,
2736 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2739 .label = "mangled names",
2742 .offset = LOCAL_VAR(bMangledNames),
2745 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2748 .label = "max stat cache size",
2750 .p_class = P_GLOBAL,
2751 .offset = GLOBAL_VAR(iMaxStatCacheSize),
2754 .flags = FLAG_ADVANCED,
2757 .label = "stat cache",
2759 .p_class = P_GLOBAL,
2760 .offset = GLOBAL_VAR(bStatCache),
2763 .flags = FLAG_ADVANCED,
2766 .label = "store dos attributes",
2769 .offset = LOCAL_VAR(bStoreDosAttributes),
2772 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2775 .label = "dmapi support",
2778 .offset = LOCAL_VAR(bDmapiSupport),
2781 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2785 {N_("Domain Options"), P_SEP, P_SEPARATOR},
2788 .label = "machine password timeout",
2790 .p_class = P_GLOBAL,
2791 .offset = GLOBAL_VAR(machine_password_timeout),
2794 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2797 {N_("Logon Options"), P_SEP, P_SEPARATOR},
2800 .label = "add user script",
2802 .p_class = P_GLOBAL,
2803 .offset = GLOBAL_VAR(szAddUserScript),
2806 .flags = FLAG_ADVANCED,
2809 .label = "rename user script",
2811 .p_class = P_GLOBAL,
2812 .offset = GLOBAL_VAR(szRenameUserScript),
2815 .flags = FLAG_ADVANCED,
2818 .label = "delete user script",
2820 .p_class = P_GLOBAL,
2821 .offset = GLOBAL_VAR(szDelUserScript),
2824 .flags = FLAG_ADVANCED,
2827 .label = "add group script",
2829 .p_class = P_GLOBAL,
2830 .offset = GLOBAL_VAR(szAddGroupScript),
2833 .flags = FLAG_ADVANCED,
2836 .label = "delete group script",
2838 .p_class = P_GLOBAL,
2839 .offset = GLOBAL_VAR(szDelGroupScript),
2842 .flags = FLAG_ADVANCED,
2845 .label = "add user to group script",
2847 .p_class = P_GLOBAL,
2848 .offset = GLOBAL_VAR(szAddUserToGroupScript),
2851 .flags = FLAG_ADVANCED,
2854 .label = "delete user from group script",
2856 .p_class = P_GLOBAL,
2857 .offset = GLOBAL_VAR(szDelUserFromGroupScript),
2860 .flags = FLAG_ADVANCED,
2863 .label = "set primary group script",
2865 .p_class = P_GLOBAL,
2866 .offset = GLOBAL_VAR(szSetPrimaryGroupScript),
2869 .flags = FLAG_ADVANCED,
2872 .label = "add machine script",
2874 .p_class = P_GLOBAL,
2875 .offset = GLOBAL_VAR(szAddMachineScript),
2878 .flags = FLAG_ADVANCED,
2881 .label = "shutdown script",
2883 .p_class = P_GLOBAL,
2884 .offset = GLOBAL_VAR(szShutdownScript),
2887 .flags = FLAG_ADVANCED,
2890 .label = "abort shutdown script",
2892 .p_class = P_GLOBAL,
2893 .offset = GLOBAL_VAR(szAbortShutdownScript),
2896 .flags = FLAG_ADVANCED,
2899 .label = "username map script",
2901 .p_class = P_GLOBAL,
2902 .offset = GLOBAL_VAR(szUsernameMapScript),
2905 .flags = FLAG_ADVANCED,
2908 .label = "username map cache time",
2910 .p_class = P_GLOBAL,
2911 .offset = GLOBAL_VAR(iUsernameMapCacheTime),
2914 .flags = FLAG_ADVANCED,
2917 .label = "logon script",
2919 .p_class = P_GLOBAL,
2920 .offset = GLOBAL_VAR(szLogonScript),
2923 .flags = FLAG_ADVANCED,
2926 .label = "logon path",
2928 .p_class = P_GLOBAL,
2929 .offset = GLOBAL_VAR(szLogonPath),
2932 .flags = FLAG_ADVANCED,
2935 .label = "logon drive",
2937 .p_class = P_GLOBAL,
2938 .offset = GLOBAL_VAR(szLogonDrive),
2941 .flags = FLAG_ADVANCED,
2944 .label = "logon home",
2946 .p_class = P_GLOBAL,
2947 .offset = GLOBAL_VAR(szLogonHome),
2950 .flags = FLAG_ADVANCED,
2953 .label = "domain logons",
2955 .p_class = P_GLOBAL,
2956 .offset = GLOBAL_VAR(bDomainLogons),
2959 .flags = FLAG_ADVANCED,
2963 .label = "init logon delayed hosts",
2965 .p_class = P_GLOBAL,
2966 .offset = GLOBAL_VAR(szInitLogonDelayedHosts),
2969 .flags = FLAG_ADVANCED,
2973 .label = "init logon delay",
2975 .p_class = P_GLOBAL,
2976 .offset = GLOBAL_VAR(InitLogonDelay),
2979 .flags = FLAG_ADVANCED,
2983 {N_("Browse Options"), P_SEP, P_SEPARATOR},
2986 .label = "os level",
2988 .p_class = P_GLOBAL,
2989 .offset = GLOBAL_VAR(os_level),
2992 .flags = FLAG_BASIC | FLAG_ADVANCED,
2995 .label = "lm announce",
2997 .p_class = P_GLOBAL,
2998 .offset = GLOBAL_VAR(lm_announce),
3000 .enum_list = enum_bool_auto,
3001 .flags = FLAG_ADVANCED,
3004 .label = "lm interval",
3006 .p_class = P_GLOBAL,
3007 .offset = GLOBAL_VAR(lm_interval),
3010 .flags = FLAG_ADVANCED,
3013 .label = "preferred master",
3015 .p_class = P_GLOBAL,
3016 .offset = GLOBAL_VAR(iPreferredMaster),
3018 .enum_list = enum_bool_auto,
3019 .flags = FLAG_BASIC | FLAG_ADVANCED,
3022 .label = "prefered master",
3024 .p_class = P_GLOBAL,
3025 .offset = GLOBAL_VAR(iPreferredMaster),
3027 .enum_list = enum_bool_auto,
3031 .label = "local master",
3033 .p_class = P_GLOBAL,
3034 .offset = GLOBAL_VAR(bLocalMaster),
3037 .flags = FLAG_BASIC | FLAG_ADVANCED,
3040 .label = "domain master",
3042 .p_class = P_GLOBAL,
3043 .offset = GLOBAL_VAR(iDomainMaster),
3045 .enum_list = enum_bool_auto,
3046 .flags = FLAG_BASIC | FLAG_ADVANCED,
3049 .label = "browse list",
3051 .p_class = P_GLOBAL,
3052 .offset = GLOBAL_VAR(bBrowseList),
3055 .flags = FLAG_ADVANCED,
3058 .label = "browseable",
3061 .offset = LOCAL_VAR(bBrowseable),
3064 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3067 .label = "browsable",
3070 .offset = LOCAL_VAR(bBrowseable),
3076 .label = "access based share enum",
3079 .offset = LOCAL_VAR(bAccessBasedShareEnum),
3082 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3085 .label = "enhanced browsing",
3087 .p_class = P_GLOBAL,
3088 .offset = GLOBAL_VAR(enhanced_browsing),
3091 .flags = FLAG_ADVANCED,
3094 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3097 .label = "dns proxy",
3099 .p_class = P_GLOBAL,
3100 .offset = GLOBAL_VAR(bDNSproxy),
3103 .flags = FLAG_ADVANCED,
3106 .label = "wins proxy",
3108 .p_class = P_GLOBAL,
3109 .offset = GLOBAL_VAR(bWINSproxy),
3112 .flags = FLAG_ADVANCED,
3115 .label = "wins server",
3117 .p_class = P_GLOBAL,
3118 .offset = GLOBAL_VAR(szWINSservers),
3121 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3124 .label = "wins support",
3126 .p_class = P_GLOBAL,
3127 .offset = GLOBAL_VAR(bWINSsupport),
3130 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3133 .label = "wins hook",
3135 .p_class = P_GLOBAL,
3136 .offset = GLOBAL_VAR(szWINSHook),
3139 .flags = FLAG_ADVANCED,
3142 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3145 .label = "blocking locks",
3148 .offset = LOCAL_VAR(bBlockingLocks),
3151 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3154 .label = "csc policy",
3157 .offset = LOCAL_VAR(iCSCPolicy),
3159 .enum_list = enum_csc_policy,
3160 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3163 .label = "fake oplocks",
3166 .offset = LOCAL_VAR(bFakeOplocks),
3169 .flags = FLAG_ADVANCED | FLAG_SHARE,
3172 .label = "kernel oplocks",
3174 .p_class = P_GLOBAL,
3175 .offset = GLOBAL_VAR(bKernelOplocks),
3178 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3184 .offset = LOCAL_VAR(bLocking),
3187 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3190 .label = "lock spin time",
3192 .p_class = P_GLOBAL,
3193 .offset = GLOBAL_VAR(iLockSpinTime),
3196 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3202 .offset = LOCAL_VAR(bOpLocks),
3205 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3208 .label = "level2 oplocks",
3211 .offset = LOCAL_VAR(bLevel2OpLocks),
3214 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3217 .label = "oplock break wait time",
3219 .p_class = P_GLOBAL,
3220 .offset = GLOBAL_VAR(oplock_break_wait_time),
3223 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3226 .label = "oplock contention limit",
3229 .offset = LOCAL_VAR(iOplockContentionLimit),
3232 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3235 .label = "posix locking",
3238 .offset = LOCAL_VAR(bPosixLocking),
3241 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3244 .label = "strict locking",
3247 .offset = LOCAL_VAR(iStrictLocking),
3249 .enum_list = enum_bool_auto,
3250 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3253 .label = "share modes",
3256 .offset = LOCAL_VAR(bShareModes),
3259 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3262 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3265 .label = "ldap admin dn",
3267 .p_class = P_GLOBAL,
3268 .offset = GLOBAL_VAR(szLdapAdminDn),
3271 .flags = FLAG_ADVANCED,
3274 .label = "ldap delete dn",
3276 .p_class = P_GLOBAL,
3277 .offset = GLOBAL_VAR(ldap_delete_dn),
3280 .flags = FLAG_ADVANCED,
3283 .label = "ldap group suffix",
3285 .p_class = P_GLOBAL,
3286 .offset = GLOBAL_VAR(szLdapGroupSuffix),
3289 .flags = FLAG_ADVANCED,
3292 .label = "ldap idmap suffix",
3294 .p_class = P_GLOBAL,
3295 .offset = GLOBAL_VAR(szLdapIdmapSuffix),
3298 .flags = FLAG_ADVANCED,
3301 .label = "ldap machine suffix",
3303 .p_class = P_GLOBAL,
3304 .offset = GLOBAL_VAR(szLdapMachineSuffix),
3307 .flags = FLAG_ADVANCED,
3310 .label = "ldap passwd sync",
3312 .p_class = P_GLOBAL,
3313 .offset = GLOBAL_VAR(ldap_passwd_sync),
3315 .enum_list = enum_ldap_passwd_sync,
3316 .flags = FLAG_ADVANCED,
3319 .label = "ldap password sync",
3321 .p_class = P_GLOBAL,
3322 .offset = GLOBAL_VAR(ldap_passwd_sync),
3324 .enum_list = enum_ldap_passwd_sync,
3328 .label = "ldap replication sleep",
3330 .p_class = P_GLOBAL,
3331 .offset = GLOBAL_VAR(ldap_replication_sleep),
3334 .flags = FLAG_ADVANCED,
3337 .label = "ldap suffix",
3339 .p_class = P_GLOBAL,
3340 .offset = GLOBAL_VAR(szLdapSuffix),
3343 .flags = FLAG_ADVANCED,
3346 .label = "ldap ssl",
3348 .p_class = P_GLOBAL,
3349 .offset = GLOBAL_VAR(ldap_ssl),
3351 .enum_list = enum_ldap_ssl,
3352 .flags = FLAG_ADVANCED,
3355 .label = "ldap ssl ads",
3357 .p_class = P_GLOBAL,
3358 .offset = GLOBAL_VAR(ldap_ssl_ads),
3361 .flags = FLAG_ADVANCED,
3364 .label = "ldap deref",
3366 .p_class = P_GLOBAL,
3367 .offset = GLOBAL_VAR(ldap_deref),
3369 .enum_list = enum_ldap_deref,
3370 .flags = FLAG_ADVANCED,
3373 .label = "ldap follow referral",
3375 .p_class = P_GLOBAL,
3376 .offset = GLOBAL_VAR(ldap_follow_referral),
3378 .enum_list = enum_bool_auto,
3379 .flags = FLAG_ADVANCED,
3382 .label = "ldap timeout",
3384 .p_class = P_GLOBAL,
3385 .offset = GLOBAL_VAR(ldap_timeout),
3388 .flags = FLAG_ADVANCED,
3391 .label = "ldap connection timeout",
3393 .p_class = P_GLOBAL,
3394 .offset = GLOBAL_VAR(ldap_connection_timeout),
3397 .flags = FLAG_ADVANCED,
3400 .label = "ldap page size",
3402 .p_class = P_GLOBAL,
3403 .offset = GLOBAL_VAR(ldap_page_size),
3406 .flags = FLAG_ADVANCED,
3409 .label = "ldap user suffix",
3411 .p_class = P_GLOBAL,
3412 .offset = GLOBAL_VAR(szLdapUserSuffix),
3415 .flags = FLAG_ADVANCED,
3418 .label = "ldap debug level",
3420 .p_class = P_GLOBAL,
3421 .offset = GLOBAL_VAR(ldap_debug_level),
3422 .special = handle_ldap_debug_level,
3424 .flags = FLAG_ADVANCED,
3427 .label = "ldap debug threshold",
3429 .p_class = P_GLOBAL,
3430 .offset = GLOBAL_VAR(ldap_debug_threshold),
3433 .flags = FLAG_ADVANCED,
3436 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3439 .label = "eventlog list",
3441 .p_class = P_GLOBAL,
3442 .offset = GLOBAL_VAR(szEventLogs),
3445 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3448 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3451 .label = "add share command",
3453 .p_class = P_GLOBAL,
3454 .offset = GLOBAL_VAR(szAddShareCommand),
3457 .flags = FLAG_ADVANCED,
3460 .label = "change share command",
3462 .p_class = P_GLOBAL,
3463 .offset = GLOBAL_VAR(szChangeShareCommand),
3466 .flags = FLAG_ADVANCED,
3469 .label = "delete share command",
3471 .p_class = P_GLOBAL,
3472 .offset = GLOBAL_VAR(szDeleteShareCommand),
3475 .flags = FLAG_ADVANCED,
3478 .label = "config file",
3480 .p_class = P_GLOBAL,
3481 .offset = GLOBAL_VAR(szConfigFile),
3484 .flags = FLAG_HIDE|FLAG_META,
3489 .p_class = P_GLOBAL,
3490 .offset = GLOBAL_VAR(szAutoServices),
3493 .flags = FLAG_ADVANCED,
3496 .label = "auto services",
3498 .p_class = P_GLOBAL,
3499 .offset = GLOBAL_VAR(szAutoServices),
3502 .flags = FLAG_ADVANCED,
3505 .label = "lock directory",
3507 .p_class = P_GLOBAL,
3508 .offset = GLOBAL_VAR(szLockDir),
3511 .flags = FLAG_ADVANCED,
3514 .label = "lock dir",
3516 .p_class = P_GLOBAL,
3517 .offset = GLOBAL_VAR(szLockDir),
3523 .label = "state directory",
3525 .p_class = P_GLOBAL,
3526 .offset = GLOBAL_VAR(szStateDir),
3529 .flags = FLAG_ADVANCED,
3532 .label = "cache directory",
3534 .p_class = P_GLOBAL,
3535 .offset = GLOBAL_VAR(szCacheDir),
3538 .flags = FLAG_ADVANCED,
3541 .label = "pid directory",
3543 .p_class = P_GLOBAL,
3544 .offset = GLOBAL_VAR(szPidDir),
3547 .flags = FLAG_ADVANCED,
3551 .label = "utmp directory",
3553 .p_class = P_GLOBAL,
3554 .offset = GLOBAL_VAR(szUtmpDir),
3557 .flags = FLAG_ADVANCED,
3560 .label = "wtmp directory",
3562 .p_class = P_GLOBAL,
3563 .offset = GLOBAL_VAR(szWtmpDir),
3566 .flags = FLAG_ADVANCED,
3571 .p_class = P_GLOBAL,
3572 .offset = GLOBAL_VAR(bUtmp),
3575 .flags = FLAG_ADVANCED,
3579 .label = "default service",
3581 .p_class = P_GLOBAL,
3582 .offset = GLOBAL_VAR(szDefaultService),
3585 .flags = FLAG_ADVANCED,
3590 .p_class = P_GLOBAL,
3591 .offset = GLOBAL_VAR(szDefaultService),
3594 .flags = FLAG_ADVANCED,
3597 .label = "message command",
3599 .p_class = P_GLOBAL,
3600 .offset = GLOBAL_VAR(szMsgCommand),
3603 .flags = FLAG_ADVANCED,
3606 .label = "dfree cache time",
3609 .offset = LOCAL_VAR(iDfreeCacheTime),
3612 .flags = FLAG_ADVANCED,
3615 .label = "dfree command",
3618 .offset = LOCAL_VAR(szDfree),
3621 .flags = FLAG_ADVANCED,
3624 .label = "get quota command",
3626 .p_class = P_GLOBAL,
3627 .offset = GLOBAL_VAR(szGetQuota),
3630 .flags = FLAG_ADVANCED,
3633 .label = "set quota command",
3635 .p_class = P_GLOBAL,
3636 .offset = GLOBAL_VAR(szSetQuota),
3639 .flags = FLAG_ADVANCED,
3642 .label = "remote announce",
3644 .p_class = P_GLOBAL,
3645 .offset = GLOBAL_VAR(szRemoteAnnounce),
3648 .flags = FLAG_ADVANCED,
3651 .label = "remote browse sync",
3653 .p_class = P_GLOBAL,
3654 .offset = GLOBAL_VAR(szRemoteBrowseSync),
3657 .flags = FLAG_ADVANCED,
3660 .label = "socket address",
3662 .p_class = P_GLOBAL,
3663 .offset = GLOBAL_VAR(szSocketAddress),
3666 .flags = FLAG_ADVANCED,
3669 .label = "nmbd bind explicit broadcast",
3671 .p_class = P_GLOBAL,
3672 .offset = GLOBAL_VAR(bNmbdBindExplicitBroadcast),
3675 .flags = FLAG_ADVANCED,
3678 .label = "homedir map",
3680 .p_class = P_GLOBAL,
3681 .offset = GLOBAL_VAR(szNISHomeMapName),
3684 .flags = FLAG_ADVANCED,
3687 .label = "afs username map",
3689 .p_class = P_GLOBAL,
3690 .offset = GLOBAL_VAR(szAfsUsernameMap),
3693 .flags = FLAG_ADVANCED,
3696 .label = "afs token lifetime",
3698 .p_class = P_GLOBAL,
3699 .offset = GLOBAL_VAR(iAfsTokenLifetime),
3702 .flags = FLAG_ADVANCED,
3705 .label = "log nt token command",
3707 .p_class = P_GLOBAL,
3708 .offset = GLOBAL_VAR(szLogNtTokenCommand),
3711 .flags = FLAG_ADVANCED,
3714 .label = "NIS homedir",
3716 .p_class = P_GLOBAL,
3717 .offset = GLOBAL_VAR(bNISHomeMap),
3720 .flags = FLAG_ADVANCED,
3726 .offset = LOCAL_VAR(valid),
3735 .offset = LOCAL_VAR(szCopy),
3736 .special = handle_copy,
3744 .offset = LOCAL_VAR(szInclude),
3745 .special = handle_include,
3747 .flags = FLAG_HIDE|FLAG_META,
3753 .offset = LOCAL_VAR(szPreExec),
3756 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3762 .offset = LOCAL_VAR(szPreExec),
3765 .flags = FLAG_ADVANCED,
3768 .label = "preexec close",
3771 .offset = LOCAL_VAR(bPreexecClose),
3774 .flags = FLAG_ADVANCED | FLAG_SHARE,
3777 .label = "postexec",
3780 .offset = LOCAL_VAR(szPostExec),
3783 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3786 .label = "root preexec",
3789 .offset = LOCAL_VAR(szRootPreExec),
3792 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3795 .label = "root preexec close",
3798 .offset = LOCAL_VAR(bRootpreexecClose),
3801 .flags = FLAG_ADVANCED | FLAG_SHARE,
3804 .label = "root postexec",
3807 .offset = LOCAL_VAR(szRootPostExec),
3810 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3813 .label = "available",
3816 .offset = LOCAL_VAR(bAvailable),
3819 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3822 .label = "registry shares",
3824 .p_class = P_GLOBAL,
3825 .offset = GLOBAL_VAR(bRegistryShares),
3828 .flags = FLAG_ADVANCED,
3831 .label = "usershare allow guests",
3833 .p_class = P_GLOBAL,
3834 .offset = GLOBAL_VAR(bUsershareAllowGuests),
3837 .flags = FLAG_ADVANCED,
3840 .label = "usershare max shares",
3842 .p_class = P_GLOBAL,
3843 .offset = GLOBAL_VAR(iUsershareMaxShares),
3846 .flags = FLAG_ADVANCED,
3849 .label = "usershare owner only",
3851 .p_class = P_GLOBAL,
3852 .offset = GLOBAL_VAR(bUsershareOwnerOnly),
3855 .flags = FLAG_ADVANCED,
3858 .label = "usershare path",
3860 .p_class = P_GLOBAL,
3861 .offset = GLOBAL_VAR(szUsersharePath),
3864 .flags = FLAG_ADVANCED,
3867 .label = "usershare prefix allow list",
3869 .p_class = P_GLOBAL,
3870 .offset = GLOBAL_VAR(szUsersharePrefixAllowList),
3873 .flags = FLAG_ADVANCED,
3876 .label = "usershare prefix deny list",
3878 .p_class = P_GLOBAL,
3879 .offset = GLOBAL_VAR(szUsersharePrefixDenyList),
3882 .flags = FLAG_ADVANCED,
3885 .label = "usershare template share",
3887 .p_class = P_GLOBAL,
3888 .offset = GLOBAL_VAR(szUsershareTemplateShare),
3891 .flags = FLAG_ADVANCED,
3897 .offset = LOCAL_VAR(volume),
3900 .flags = FLAG_ADVANCED | FLAG_SHARE,
3906 .offset = LOCAL_VAR(fstype),
3909 .flags = FLAG_ADVANCED | FLAG_SHARE,
3912 .label = "set directory",
3915 .offset = LOCAL_VAR(bNo_set_dir),
3918 .flags = FLAG_ADVANCED | FLAG_SHARE,
3921 .label = "wide links",
3924 .offset = LOCAL_VAR(bWidelinks),
3927 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3930 .label = "follow symlinks",
3933 .offset = LOCAL_VAR(bSymlinks),
3936 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3939 .label = "dont descend",
3942 .offset = LOCAL_VAR(szDontdescend),
3945 .flags = FLAG_ADVANCED | FLAG_SHARE,
3948 .label = "magic script",
3951 .offset = LOCAL_VAR(szMagicScript),
3954 .flags = FLAG_ADVANCED | FLAG_SHARE,
3957 .label = "magic output",
3960 .offset = LOCAL_VAR(szMagicOutput),
3963 .flags = FLAG_ADVANCED | FLAG_SHARE,
3966 .label = "delete readonly",
3969 .offset = LOCAL_VAR(bDeleteReadonly),
3972 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3975 .label = "dos filemode",
3978 .offset = LOCAL_VAR(bDosFilemode),
3981 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3984 .label = "dos filetimes",
3987 .offset = LOCAL_VAR(bDosFiletimes),
3990 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3993 .label = "dos filetime resolution",
3996 .offset = LOCAL_VAR(bDosFiletimeResolution),
3999 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4002 .label = "fake directory create times",
4005 .offset = LOCAL_VAR(bFakeDirCreateTimes),
4008 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4011 .label = "async smb echo handler",
4013 .p_class = P_GLOBAL,
4014 .offset = GLOBAL_VAR(bAsyncSMBEchoHandler),
4017 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4020 .label = "multicast dns register",
4022 .p_class = P_GLOBAL,
4023 .offset = GLOBAL_VAR(bMulticastDnsRegister),
4026 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4029 .label = "panic action",
4031 .p_class = P_GLOBAL,
4032 .offset = GLOBAL_VAR(szPanicAction),
4035 .flags = FLAG_ADVANCED,
4038 .label = "perfcount module",
4040 .p_class = P_GLOBAL,
4041 .offset = GLOBAL_VAR(szSMBPerfcountModule),
4044 .flags = FLAG_ADVANCED,
4047 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4050 .label = "vfs objects",
4053 .offset = LOCAL_VAR(szVfsObjects),
4056 .flags = FLAG_ADVANCED | FLAG_SHARE,
4059 .label = "vfs object",
4062 .offset = LOCAL_VAR(szVfsObjects),
4069 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4072 .label = "msdfs root",
4075 .offset = LOCAL_VAR(bMSDfsRoot),
4078 .flags = FLAG_ADVANCED | FLAG_SHARE,
4081 .label = "msdfs proxy",
4084 .offset = LOCAL_VAR(szMSDfsProxy),
4087 .flags = FLAG_ADVANCED | FLAG_SHARE,
4090 .label = "host msdfs",
4092 .p_class = P_GLOBAL,
4093 .offset = GLOBAL_VAR(bHostMSDfs),
4096 .flags = FLAG_ADVANCED,
4099 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4102 .label = "passdb expand explicit",
4104 .p_class = P_GLOBAL,
4105 .offset = GLOBAL_VAR(bPassdbExpandExplicit),
4108 .flags = FLAG_ADVANCED,
4111 .label = "idmap backend",
4113 .p_class = P_GLOBAL,
4114 .offset = GLOBAL_VAR(szIdmapBackend),
4115 .special = handle_idmap_backend,
4117 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4120 .label = "idmap cache time",
4122 .p_class = P_GLOBAL,
4123 .offset = GLOBAL_VAR(iIdmapCacheTime),
4126 .flags = FLAG_ADVANCED,
4129 .label = "idmap negative cache time",
4131 .p_class = P_GLOBAL,
4132 .offset = GLOBAL_VAR(iIdmapNegativeCacheTime),
4135 .flags = FLAG_ADVANCED,
4138 .label = "idmap uid",
4140 .p_class = P_GLOBAL,
4141 .offset = GLOBAL_VAR(szIdmapUID),
4142 .special = handle_idmap_uid,
4144 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4147 .label = "winbind uid",
4149 .p_class = P_GLOBAL,
4150 .offset = GLOBAL_VAR(szIdmapUID),
4151 .special = handle_idmap_uid,
4156 .label = "idmap gid",
4158 .p_class = P_GLOBAL,
4159 .offset = GLOBAL_VAR(szIdmapGID),
4160 .special = handle_idmap_gid,
4162 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4165 .label = "winbind gid",
4167 .p_class = P_GLOBAL,
4168 .offset = GLOBAL_VAR(szIdmapGID),
4169 .special = handle_idmap_gid,
4174 .label = "template homedir",
4176 .p_class = P_GLOBAL,
4177 .offset = GLOBAL_VAR(szTemplateHomedir),
4180 .flags = FLAG_ADVANCED,
4183 .label = "template shell",
4185 .p_class = P_GLOBAL,
4186 .offset = GLOBAL_VAR(szTemplateShell),
4189 .flags = FLAG_ADVANCED,
4192 .label = "winbind separator",
4194 .p_class = P_GLOBAL,
4195 .offset = GLOBAL_VAR(szWinbindSeparator),
4198 .flags = FLAG_ADVANCED,
4201 .label = "winbind cache time",
4203 .p_class = P_GLOBAL,
4204 .offset = GLOBAL_VAR(winbind_cache_time),
4207 .flags = FLAG_ADVANCED,
4210 .label = "winbind reconnect delay",
4212 .p_class = P_GLOBAL,
4213 .offset = GLOBAL_VAR(winbind_reconnect_delay),
4216 .flags = FLAG_ADVANCED,
4219 .label = "winbind max clients",
4221 .p_class = P_GLOBAL,
4222 .offset = GLOBAL_VAR(winbind_max_clients),
4225 .flags = FLAG_ADVANCED,
4228 .label = "winbind enum users",
4230 .p_class = P_GLOBAL,
4231 .offset = GLOBAL_VAR(bWinbindEnumUsers),
4234 .flags = FLAG_ADVANCED,
4237 .label = "winbind enum groups",
4239 .p_class = P_GLOBAL,
4240 .offset = GLOBAL_VAR(bWinbindEnumGroups),
4243 .flags = FLAG_ADVANCED,
4246 .label = "winbind use default domain",
4248 .p_class = P_GLOBAL,
4249 .offset = GLOBAL_VAR(bWinbindUseDefaultDomain),
4252 .flags = FLAG_ADVANCED,
4255 .label = "winbind trusted domains only",
4257 .p_class = P_GLOBAL,
4258 .offset = GLOBAL_VAR(bWinbindTrustedDomainsOnly),
4261 .flags = FLAG_ADVANCED,
4264 .label = "winbind nested groups",
4266 .p_class = P_GLOBAL,
4267 .offset = GLOBAL_VAR(bWinbindNestedGroups),
4270 .flags = FLAG_ADVANCED,
4273 .label = "winbind expand groups",
4275 .p_class = P_GLOBAL,
4276 .offset = GLOBAL_VAR(winbind_expand_groups),
4279 .flags = FLAG_ADVANCED,
4282 .label = "winbind nss info",
4284 .p_class = P_GLOBAL,
4285 .offset = GLOBAL_VAR(szWinbindNssInfo),
4288 .flags = FLAG_ADVANCED,
4291 .label = "winbind refresh tickets",
4293 .p_class = P_GLOBAL,
4294 .offset = GLOBAL_VAR(bWinbindRefreshTickets),
4297 .flags = FLAG_ADVANCED,
4300 .label = "winbind offline logon",
4302 .p_class = P_GLOBAL,
4303 .offset = GLOBAL_VAR(bWinbindOfflineLogon),
4306 .flags = FLAG_ADVANCED,
4309 .label = "winbind normalize names",
4311 .p_class = P_GLOBAL,
4312 .offset = GLOBAL_VAR(bWinbindNormalizeNames),
4315 .flags = FLAG_ADVANCED,
4318 .label = "winbind rpc only",
4320 .p_class = P_GLOBAL,
4321 .offset = GLOBAL_VAR(bWinbindRpcOnly),
4324 .flags = FLAG_ADVANCED,
4327 .label = "create krb5 conf",
4329 .p_class = P_GLOBAL,
4330 .offset = GLOBAL_VAR(bCreateKrb5Conf),
4333 .flags = FLAG_ADVANCED,
4336 .label = "ncalrpc dir",
4338 .p_class = P_GLOBAL,
4339 .offset = GLOBAL_VAR(ncalrpc_dir),
4342 .flags = FLAG_ADVANCED,
4345 .label = "winbind max domain connections",
4347 .p_class = P_GLOBAL,
4348 .offset = GLOBAL_VAR(winbindMaxDomainConnections),
4351 .flags = FLAG_ADVANCED,
4354 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
4357 /***************************************************************************
4358 Initialise the sDefault parameter structure for the printer values.
4359 ***************************************************************************/
4361 static void init_printer_values(struct loadparm_service *pService)
4363 /* choose defaults depending on the type of printing */
4364 switch (pService->iPrinting) {
4369 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4370 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4371 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4376 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4377 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4378 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4379 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4380 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4381 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4382 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4388 /* set the lpq command to contain the destination printer
4389 name only. This is used by cups_queue_get() */
4390 string_set(&pService->szLpqcommand, "%p");
4391 string_set(&pService->szLprmcommand, "");
4392 string_set(&pService->szPrintcommand, "");
4393 string_set(&pService->szLppausecommand, "");
4394 string_set(&pService->szLpresumecommand, "");
4395 string_set(&pService->szQueuepausecommand, "");
4396 string_set(&pService->szQueueresumecommand, "");
4398 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4399 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4400 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4401 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4402 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4403 string_set(&pService->szQueuepausecommand, "disable '%p'");
4404 string_set(&pService->szQueueresumecommand, "enable '%p'");
4405 #endif /* HAVE_CUPS */
4410 string_set(&pService->szLpqcommand, "lpstat -o%p");
4411 string_set(&pService->szLprmcommand, "cancel %p-%j");
4412 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4413 string_set(&pService->szQueuepausecommand, "disable %p");
4414 string_set(&pService->szQueueresumecommand, "enable %p");
4416 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4417 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4422 string_set(&pService->szLpqcommand, "lpq -P%p");
4423 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4424 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4427 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
4431 const char *tdbfile;
4434 tdbfile = talloc_asprintf(
4435 talloc_tos(), "tdbfile=%s",
4436 lp_parm_const_string(-1, "vlp", "tdbfile",
4438 if (tdbfile == NULL) {
4439 tdbfile="tdbfile=/tmp/vlp.tdb";
4442 tmp = talloc_asprintf(talloc_tos(), "vlp %s print %%p %%s",
4444 string_set(&pService->szPrintcommand,
4445 tmp ? tmp : "vlp print %p %s");
4448 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpq %%p",
4450 string_set(&pService->szLpqcommand,
4451 tmp ? tmp : "vlp lpq %p");
4454 tmp = talloc_asprintf(talloc_tos(), "vlp %s lprm %%p %%j",
4456 string_set(&pService->szLprmcommand,
4457 tmp ? tmp : "vlp lprm %p %j");
4460 tmp = talloc_asprintf(talloc_tos(), "vlp %s lppause %%p %%j",
4462 string_set(&pService->szLppausecommand,
4463 tmp ? tmp : "vlp lppause %p %j");
4466 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpresume %%p %%j",
4468 string_set(&pService->szLpresumecommand,
4469 tmp ? tmp : "vlp lpresume %p %j");
4472 tmp = talloc_asprintf(talloc_tos(), "vlp %s queuepause %%p",
4474 string_set(&pService->szQueuepausecommand,
4475 tmp ? tmp : "vlp queuepause %p");
4478 tmp = talloc_asprintf(talloc_tos(), "vlp %s queueresume %%p",
4480 string_set(&pService->szQueueresumecommand,
4481 tmp ? tmp : "vlp queueresume %p");
4486 #endif /* DEVELOPER */
4491 * Function to return the default value for the maximum number of open
4492 * file descriptors permitted. This function tries to consult the
4493 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4494 * the smaller of those.
4496 static int max_open_files(void)
4498 int sysctl_max = MAX_OPEN_FILES;
4499 int rlimit_max = MAX_OPEN_FILES;
4501 #ifdef HAVE_SYSCTLBYNAME
4503 size_t size = sizeof(sysctl_max);
4504 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4509 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4515 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4516 rlimit_max = rl.rlim_cur;
4518 #if defined(RLIM_INFINITY)
4519 if(rl.rlim_cur == RLIM_INFINITY)
4520 rlimit_max = MAX_OPEN_FILES;
4525 if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4526 DEBUG(2,("max_open_files: increasing sysctl_max (%d) to "
4527 "minimum Windows limit (%d)\n",
4529 MIN_OPEN_FILES_WINDOWS));
4530 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4533 if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4534 DEBUG(2,("rlimit_max: increasing rlimit_max (%d) to "
4535 "minimum Windows limit (%d)\n",
4537 MIN_OPEN_FILES_WINDOWS));
4538 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4541 return MIN(sysctl_max, rlimit_max);
4545 * Common part of freeing allocated data for one parameter.
4547 static void free_one_parameter_common(void *parm_ptr,
4548 struct parm_struct parm)
4550 if ((parm.type == P_STRING) ||
4551 (parm.type == P_USTRING))
4553 string_free((char**)parm_ptr);
4554 } else if (parm.type == P_LIST) {
4555 TALLOC_FREE(*((char***)parm_ptr));
4560 * Free the allocated data for one parameter for a share
4561 * given as a service struct.
4563 static void free_one_parameter(struct loadparm_service *service,
4564 struct parm_struct parm)
4568 if (parm.p_class != P_LOCAL) {
4572 parm_ptr = lp_parm_ptr(service, &parm);
4574 free_one_parameter_common(parm_ptr, parm);
4578 * Free the allocated parameter data of a share given
4579 * as a service struct.
4581 static void free_parameters(struct loadparm_service *service)
4585 for (i=0; parm_table[i].label; i++) {
4586 free_one_parameter(service, parm_table[i]);
4591 * Free the allocated data for one parameter for a given share
4592 * specified by an snum.
4594 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4599 parm_ptr = lp_parm_ptr(NULL, &parm);
4600 } else if (parm.p_class != P_LOCAL) {
4603 parm_ptr = lp_local_ptr_by_snum(snum, &parm);
4606 free_one_parameter_common(parm_ptr, parm);
4610 * Free the allocated parameter data for a share specified
4613 static void free_parameters_by_snum(int snum)
4617 for (i=0; parm_table[i].label; i++) {
4618 free_one_parameter_by_snum(snum, parm_table[i]);
4623 * Free the allocated global parameters.
4625 static void free_global_parameters(void)
4627 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4630 static int map_parameter(const char *pszParmName);
4632 struct lp_stored_option {
4633 struct lp_stored_option *prev, *next;
4638 static struct lp_stored_option *stored_options;
4641 save options set by lp_set_cmdline() into a list. This list is
4642 re-applied when we do a globals reset, so that cmdline set options
4643 are sticky across reloads of smb.conf
4645 static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
4647 struct lp_stored_option *entry, *entry_next;
4648 for (entry = stored_options; entry != NULL; entry = entry_next) {
4649 entry_next = entry->next;
4650 if (strcmp(pszParmName, entry->label) == 0) {
4651 DLIST_REMOVE(stored_options, entry);
4657 entry = talloc(NULL, struct lp_stored_option);
4662 entry->label = talloc_strdup(entry, pszParmName);
4663 if (!entry->label) {
4668 entry->value = talloc_strdup(entry, pszParmValue);
4669 if (!entry->value) {
4674 DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
4679 static bool apply_lp_set_cmdline(void)
4681 struct lp_stored_option *entry = NULL;
4682 for (entry = stored_options; entry != NULL; entry = entry->next) {
4683 if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
4684 DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
4685 entry->label, entry->value));
4692 /***************************************************************************
4693 Initialise the global parameter structure.
4694 ***************************************************************************/
4696 static void init_globals(bool reinit_globals)
4698 static bool done_init = false;
4702 /* If requested to initialize only once and we've already done it... */
4703 if (!reinit_globals && done_init) {
4704 /* ... then we have nothing more to do */
4709 /* The logfile can be set before this is invoked. Free it if so. */
4710 if (Globals.szLogFile != NULL) {
4711 string_free(&Globals.szLogFile);
4712 Globals.szLogFile = NULL;
4716 free_global_parameters();
4719 /* This memset and the free_global_parameters() above will
4720 * wipe out smb.conf options set with lp_set_cmdline(). The
4721 * apply_lp_set_cmdline() call puts these values back in the
4722 * table once the defaults are set */
4723 memset((void *)&Globals, '\0', sizeof(Globals));
4725 for (i = 0; parm_table[i].label; i++) {
4726 if ((parm_table[i].type == P_STRING ||
4727 parm_table[i].type == P_USTRING))
4729 string_set(lp_parm_ptr(NULL, &parm_table[i]), "");
4734 string_set(&sDefault.fstype, FSTYPE_STRING);
4735 string_set(&sDefault.szPrintjobUsername, "%U");
4737 init_printer_values(&sDefault);
4740 DEBUG(3, ("Initialising global parameters\n"));
4742 /* Must manually force to upper case here, as this does not go via the handler */
4743 string_set(&Globals.szNetbiosName, myhostname_upper());
4745 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4746 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4748 /* use the new 'hash2' method by default, with a prefix of 1 */
4749 string_set(&Globals.szManglingMethod, "hash2");
4750 Globals.mangle_prefix = 1;
4752 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4754 /* using UTF8 by default allows us to support all chars */
4755 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4757 /* Use codepage 850 as a default for the dos character set */
4758 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4761 * Allow the default PASSWD_CHAT to be overridden in local.h.
4763 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4765 string_set(&Globals.szWorkgroup, DEFAULT_WORKGROUP);
4767 string_set(&Globals.szPasswdProgram, "");
4768 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4769 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4770 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4771 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4772 string_set(&Globals.szSocketAddress, "0.0.0.0");
4774 * By default support explicit binding to broadcast
4777 Globals.bNmbdBindExplicitBroadcast = true;
4779 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4780 smb_panic("init_globals: ENOMEM");
4782 string_set(&Globals.szServerString, s);
4785 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4788 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
4790 string_set(&Globals.szLogonDrive, "");
4791 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4792 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4793 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4795 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
4796 string_set(&Globals.szPasswordServer, "*");
4798 Globals.AlgorithmicRidBase = BASE_RID;
4800 Globals.bLoadPrinters = true;
4801 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4803 Globals.ConfigBackend = config_backend;
4805 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4806 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4807 Globals.max_xmit = 0x4104;
4808 Globals.max_mux = 50; /* This is *needed* for profile support. */
4809 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4810 Globals.bDisableSpoolss = false;
4811 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4812 Globals.pwordlevel = 0;
4813 Globals.unamelevel = 0;
4814 Globals.deadtime = 0;
4815 Globals.getwd_cache = true;
4816 Globals.bLargeReadwrite = true;
4817 Globals.max_log_size = 5000;
4818 Globals.max_open_files = max_open_files();
4819 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4820 Globals.maxprotocol = PROTOCOL_NT1;
4821 Globals.minprotocol = PROTOCOL_CORE;
4822 Globals.security = SEC_USER;
4823 Globals.paranoid_server_security = true;
4824 Globals.bEncryptPasswords = true;
4825 Globals.clientSchannel = Auto;
4826 Globals.serverSchannel = Auto;
4827 Globals.bReadRaw = true;
4828 Globals.bWriteRaw = true;
4829 Globals.bNullPasswords = false;
4830 Globals.bObeyPamRestrictions = false;
4832 Globals.bSyslogOnly = false;
4833 Globals.bTimestampLogs = true;
4834 string_set(&Globals.szLogLevel, "0");
4835 Globals.bDebugPrefixTimestamp = false;
4836 Globals.bDebugHiresTimestamp = true;
4837 Globals.bDebugPid = false;
4838 Globals.bDebugUid = false;
4839 Globals.bDebugClass = false;
4840 Globals.bEnableCoreFiles = true;
4841 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4842 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4843 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4844 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4845 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
4846 Globals.lm_interval = 60;
4847 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4848 Globals.bNISHomeMap = false;
4849 #ifdef WITH_NISPLUS_HOME
4850 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4852 string_set(&Globals.szNISHomeMapName, "auto.home");
4855 Globals.bTimeServer = false;
4856 Globals.bBindInterfacesOnly = false;
4857 Globals.bUnixPasswdSync = false;
4858 Globals.bPamPasswordChange = false;
4859 Globals.bPasswdChatDebug = false;
4860 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4861 Globals.bNTPipeSupport = true; /* Do NT pipes by default. */
4862 Globals.bNTStatusSupport = true; /* Use NT status by default. */
4863 Globals.bStatCache = true; /* use stat cache by default */
4864 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4865 Globals.restrict_anonymous = 0;
4866 Globals.bClientLanManAuth = false; /* Do NOT use the LanMan hash if it is available */
4867 Globals.bClientPlaintextAuth = false; /* Do NOT use a plaintext password even if is requested by the server */
4868 Globals.bLanmanAuth = false; /* Do NOT use the LanMan hash, even if it is supplied */
4869 Globals.bNTLMAuth = true; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4870 Globals.bClientNTLMv2Auth = true; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
4871 /* Note, that we will also use NTLM2 session security (which is different), if it is available */
4873 Globals.map_to_guest = 0; /* By Default, "Never" */
4874 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4875 Globals.enhanced_browsing = true;
4876 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4877 #ifdef MMAP_BLACKLIST
4878 Globals.bUseMmap = false;
4880 Globals.bUseMmap = true;
4882 Globals.bUnixExtensions = true;
4883 Globals.bResetOnZeroVC = false;
4884 Globals.bLogWriteableFilesOnExit = false;
4885 Globals.bCreateKrb5Conf = true;
4886 Globals.winbindMaxDomainConnections = 1;
4888 /* hostname lookups can be very expensive and are broken on
4889 a large number of sites (tridge) */
4890 Globals.bHostnameLookups = false;
4892 string_set(&Globals.szPassdbBackend, "tdbsam");
4893 string_set(&Globals.szLdapSuffix, "");
4894 string_set(&Globals.szLdapMachineSuffix, "");
4895 string_set(&Globals.szLdapUserSuffix, "");
4896 string_set(&Globals.szLdapGroupSuffix, "");
4897 string_set(&Globals.szLdapIdmapSuffix, "");
4899 string_set(&Globals.szLdapAdminDn, "");
4900 Globals.ldap_ssl = LDAP_SSL_START_TLS;
4901 Globals.ldap_ssl_ads = false;
4902 Globals.ldap_deref = -1;
4903 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
4904 Globals.ldap_delete_dn = false;
4905 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
4906 Globals.ldap_follow_referral = Auto;
4907 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
4908 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
4909 Globals.ldap_page_size = LDAP_PAGE_SIZE;
4911 Globals.ldap_debug_level = 0;
4912 Globals.ldap_debug_threshold = 10;
4914 /* This is what we tell the afs client. in reality we set the token
4915 * to never expire, though, when this runs out the afs client will
4916 * forget the token. Set to 0 to get NEVERDATE.*/
4917 Globals.iAfsTokenLifetime = 604800;
4918 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
4920 /* these parameters are set to defaults that are more appropriate
4921 for the increasing samba install base:
4923 as a member of the workgroup, that will possibly become a
4924 _local_ master browser (lm = true). this is opposed to a forced
4925 local master browser startup (pm = true).
4927 doesn't provide WINS server service by default (wsupp = false),
4928 and doesn't provide domain master browser services by default, either.
4932 Globals.bMsAddPrinterWizard = true;
4933 Globals.os_level = 20;
4934 Globals.bLocalMaster = true;
4935 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
4936 Globals.bDomainLogons = false;
4937 Globals.bBrowseList = true;
4938 Globals.bWINSsupport = false;
4939 Globals.bWINSproxy = false;
4941 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
4942 Globals.InitLogonDelay = 100; /* 100 ms default delay */
4944 Globals.bDNSproxy = true;
4946 /* this just means to use them if they exist */
4947 Globals.bKernelOplocks = true;
4949 Globals.bAllowTrustedDomains = true;
4950 string_set(&Globals.szIdmapBackend, "tdb");
4952 string_set(&Globals.szTemplateShell, "/bin/false");
4953 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
4954 string_set(&Globals.szWinbindSeparator, "\\");
4956 string_set(&Globals.szCupsServer, "");
4957 string_set(&Globals.szIPrintServer, "");
4959 string_set(&Globals.ctdbdSocket, "");
4960 Globals.szClusterAddresses = NULL;
4961 Globals.clustering = false;
4962 Globals.ctdb_timeout = 0;
4963 Globals.ctdb_locktime_warn_threshold = 0;
4965 Globals.winbind_cache_time = 300; /* 5 minutes */
4966 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
4967 Globals.winbind_max_clients = 200;
4968 Globals.bWinbindEnumUsers = false;
4969 Globals.bWinbindEnumGroups = false;
4970 Globals.bWinbindUseDefaultDomain = false;
4971 Globals.bWinbindTrustedDomainsOnly = false;
4972 Globals.bWinbindNestedGroups = true;
4973 Globals.winbind_expand_groups = 1;
4974 Globals.szWinbindNssInfo = str_list_make_v3(NULL, "template", NULL);
4975 Globals.bWinbindRefreshTickets = false;
4976 Globals.bWinbindOfflineLogon = false;
4978 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
4979 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
4981 Globals.bPassdbExpandExplicit = false;
4983 Globals.name_cache_timeout = 660; /* In seconds */
4985 Globals.bUseSpnego = true;
4986 Globals.bClientUseSpnego = true;
4988 Globals.client_signing = Auto;
4989 Globals.server_signing = false;
4991 Globals.bDeferSharingViolations = true;
4992 string_set(&Globals.smb_ports, SMB_PORTS);
4994 Globals.bEnablePrivileges = true;
4995 Globals.bHostMSDfs = true;
4996 Globals.bASUSupport = false;
4998 /* User defined shares. */
4999 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5000 smb_panic("init_globals: ENOMEM");
5002 string_set(&Globals.szUsersharePath, s);
5004 string_set(&Globals.szUsershareTemplateShare, "");
5005 Globals.iUsershareMaxShares = 0;
5006 /* By default disallow sharing of directories not owned by the sharer. */
5007 Globals.bUsershareOwnerOnly = true;
5008 /* By default disallow guest access to usershares. */
5009 Globals.bUsershareAllowGuests = false;
5011 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5013 /* By default no shares out of the registry */
5014 Globals.bRegistryShares = false;
5016 Globals.iminreceivefile = 0;
5018 Globals.bMapUntrustedToDomain = false;
5019 Globals.bMulticastDnsRegister = true;
5021 Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ;
5022 Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE;
5023 Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT;
5024 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5026 string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
5028 /* Now put back the settings that were set with lp_set_cmdline() */
5029 apply_lp_set_cmdline();
5032 /*******************************************************************
5033 Convenience routine to grab string parameters into temporary memory
5034 and run standard_sub_basic on them. The buffers can be written to by
5035 callers without affecting the source string.
5036 ********************************************************************/
5038 static char *lp_string(const char *s)
5041 TALLOC_CTX *ctx = talloc_tos();
5043 /* The follow debug is useful for tracking down memory problems
5044 especially if you have an inner loop that is calling a lp_*()
5045 function that returns a string. Perhaps this debug should be
5046 present all the time? */
5049 DEBUG(10, ("lp_string(%s)\n", s));
5055 ret = talloc_sub_basic(ctx,
5056 get_current_username(),
5057 current_user_info.domain,
5059 if (trim_char(ret, '\"', '\"')) {
5060 if (strchr(ret,'\"') != NULL) {
5062 ret = talloc_sub_basic(ctx,
5063 get_current_username(),
5064 current_user_info.domain,
5072 In this section all the functions that are used to access the
5073 parameters from the rest of the program are defined
5076 #define FN_GLOBAL_STRING(fn_name,ptr) \
5077 char *fn_name(void) {return(lp_string(*(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : ""));}
5078 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5079 const char *fn_name(void) {return(*(const char **)(&Globals.ptr) ? *(const char **)(&Globals.ptr) : "");}
5080 #define FN_GLOBAL_LIST(fn_name,ptr) \
5081 const char **fn_name(void) {return(*(const char ***)(&Globals.ptr));}
5082 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5083 bool fn_name(void) {return(*(bool *)(&Globals.ptr));}
5084 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5085 char fn_name(void) {return(*(char *)(&Globals.ptr));}
5086 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5087 int fn_name(void) {return(*(int *)(&Globals.ptr));}
5089 #define FN_LOCAL_STRING(fn_name,val) \
5090 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5091 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5092 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5093 #define FN_LOCAL_LIST(fn_name,val) \
5094 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5095 #define FN_LOCAL_BOOL(fn_name,val) \
5096 bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5097 #define FN_LOCAL_INTEGER(fn_name,val) \
5098 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5100 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5101 bool fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5102 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5103 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5104 #define FN_LOCAL_CHAR(fn_name,val) \
5105 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5107 FN_GLOBAL_CONST_STRING(lp_smb_ports, smb_ports)
5108 FN_GLOBAL_CONST_STRING(lp_dos_charset, dos_charset)
5109 FN_GLOBAL_CONST_STRING(lp_unix_charset, unix_charset)
5110 FN_GLOBAL_STRING(lp_logfile, szLogFile)
5111 FN_GLOBAL_STRING(lp_configfile, szConfigFile)
5112 FN_GLOBAL_CONST_STRING(lp_smb_passwd_file, szSMBPasswdFile)
5113 FN_GLOBAL_CONST_STRING(lp_private_dir, szPrivateDir)
5114 FN_GLOBAL_STRING(lp_serverstring, szServerString)
5115 FN_GLOBAL_INTEGER(lp_printcap_cache_time, PrintcapCacheTime)
5116 FN_GLOBAL_STRING(lp_addport_cmd, szAddPortCommand)
5117 FN_GLOBAL_STRING(lp_enumports_cmd, szEnumPortsCommand)
5118 FN_GLOBAL_STRING(lp_addprinter_cmd, szAddPrinterCommand)
5119 FN_GLOBAL_STRING(lp_deleteprinter_cmd, szDeletePrinterCommand)
5120 FN_GLOBAL_STRING(lp_os2_driver_map, szOs2DriverMap)
5121 FN_GLOBAL_CONST_STRING(lp_lockdir, szLockDir)
5122 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5123 * build process or in smb.conf, we use that value. Otherwise they
5124 * default to the value of lp_lockdir(). */
5125 const char *lp_statedir(void) {
5126 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5127 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5128 return(*(char **)(&Globals.szStateDir) ?
5129 *(char **)(&Globals.szStateDir) : "");
5131 return(*(char **)(&Globals.szLockDir) ?
5132 *(char **)(&Globals.szLockDir) : "");
5134 const char *lp_cachedir(void) {
5135 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5136 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5137 return(*(char **)(&Globals.szCacheDir) ?
5138 *(char **)(&Globals.szCacheDir) : "");
5140 return(*(char **)(&Globals.szLockDir) ?
5141 *(char **)(&Globals.szLockDir) : "");
5143 FN_GLOBAL_CONST_STRING(lp_piddir, szPidDir)
5144 FN_GLOBAL_STRING(lp_mangling_method, szManglingMethod)
5145 FN_GLOBAL_INTEGER(lp_mangle_prefix, mangle_prefix)
5146 FN_GLOBAL_CONST_STRING(lp_utmpdir, szUtmpDir)
5147 FN_GLOBAL_CONST_STRING(lp_wtmpdir, szWtmpDir)
5148 FN_GLOBAL_BOOL(lp_utmp, bUtmp)
5149 FN_GLOBAL_STRING(lp_rootdir, szRootdir)
5150 FN_GLOBAL_STRING(lp_perfcount_module, szSMBPerfcountModule)
5151 FN_GLOBAL_STRING(lp_defaultservice, szDefaultService)
5152 FN_GLOBAL_STRING(lp_msg_command, szMsgCommand)
5153 FN_GLOBAL_STRING(lp_get_quota_command, szGetQuota)
5154 FN_GLOBAL_STRING(lp_set_quota_command, szSetQuota)
5155 FN_GLOBAL_STRING(lp_auto_services, szAutoServices)
5156 FN_GLOBAL_STRING(lp_passwd_program, szPasswdProgram)
5157 FN_GLOBAL_STRING(lp_passwd_chat, szPasswdChat)
5158 FN_GLOBAL_CONST_STRING(lp_passwordserver, szPasswordServer)
5159 FN_GLOBAL_CONST_STRING(lp_name_resolve_order, szNameResolveOrder)
5160 FN_GLOBAL_CONST_STRING(lp_workgroup, szWorkgroup)
5161 FN_GLOBAL_CONST_STRING(lp_netbios_name, szNetbiosName)
5162 FN_GLOBAL_CONST_STRING(lp_netbios_scope, szNetbiosScope)
5163 FN_GLOBAL_CONST_STRING(lp_realm, szRealmUpper)
5164 FN_GLOBAL_CONST_STRING(lp_dnsdomain, szDnsDomain)
5165 FN_GLOBAL_CONST_STRING(lp_afs_username_map, szAfsUsernameMap)
5166 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, iAfsTokenLifetime)
5167 FN_GLOBAL_STRING(lp_log_nt_token_command, szLogNtTokenCommand)
5168 FN_GLOBAL_STRING(lp_username_map, szUsernameMap)
5169 FN_GLOBAL_CONST_STRING(lp_logon_script, szLogonScript)
5170 FN_GLOBAL_CONST_STRING(lp_logon_path, szLogonPath)
5171 FN_GLOBAL_CONST_STRING(lp_logon_drive, szLogonDrive)
5172 FN_GLOBAL_CONST_STRING(lp_logon_home, szLogonHome)
5173 FN_GLOBAL_STRING(lp_remote_announce, szRemoteAnnounce)
5174 FN_GLOBAL_STRING(lp_remote_browse_sync, szRemoteBrowseSync)
5175 FN_GLOBAL_BOOL(lp_nmbd_bind_explicit_broadcast, bNmbdBindExplicitBroadcast)
5176 FN_GLOBAL_LIST(lp_wins_server_list, szWINSservers)
5177 FN_GLOBAL_LIST(lp_interfaces, szInterfaces)
5178 FN_GLOBAL_STRING(lp_nis_home_map_name, szNISHomeMapName)
5179 FN_GLOBAL_LIST(lp_netbios_aliases, szNetbiosAliases)
5180 FN_GLOBAL_CONST_STRING(lp_passdb_backend, szPassdbBackend)
5181 FN_GLOBAL_LIST(lp_preload_modules, szPreloadModules)
5182 FN_GLOBAL_STRING(lp_panic_action, szPanicAction)
5183 FN_GLOBAL_STRING(lp_adduser_script, szAddUserScript)
5184 FN_GLOBAL_STRING(lp_renameuser_script, szRenameUserScript)
5185 FN_GLOBAL_STRING(lp_deluser_script, szDelUserScript)
5187 FN_GLOBAL_CONST_STRING(lp_guestaccount, szGuestaccount)
5188 FN_GLOBAL_STRING(lp_addgroup_script, szAddGroupScript)
5189 FN_GLOBAL_STRING(lp_delgroup_script, szDelGroupScript)
5190 FN_GLOBAL_STRING(lp_addusertogroup_script, szAddUserToGroupScript)
5191 FN_GLOBAL_STRING(lp_deluserfromgroup_script, szDelUserFromGroupScript)
5192 FN_GLOBAL_STRING(lp_setprimarygroup_script, szSetPrimaryGroupScript)
5194 FN_GLOBAL_STRING(lp_addmachine_script, szAddMachineScript)
5196 FN_GLOBAL_STRING(lp_shutdown_script, szShutdownScript)
5197 FN_GLOBAL_STRING(lp_abort_shutdown_script, szAbortShutdownScript)
5198 FN_GLOBAL_STRING(lp_username_map_script, szUsernameMapScript)
5199 FN_GLOBAL_INTEGER(lp_username_map_cache_time, iUsernameMapCacheTime)
5201 FN_GLOBAL_STRING(lp_check_password_script, szCheckPasswordScript)
5203 FN_GLOBAL_STRING(lp_wins_hook, szWINSHook)
5204 FN_GLOBAL_CONST_STRING(lp_template_homedir, szTemplateHomedir)
5205 FN_GLOBAL_CONST_STRING(lp_template_shell, szTemplateShell)
5206 FN_GLOBAL_CONST_STRING(lp_winbind_separator, szWinbindSeparator)
5207 FN_GLOBAL_INTEGER(lp_acl_compatibility, iAclCompat)
5208 FN_GLOBAL_BOOL(lp_winbind_enum_users, bWinbindEnumUsers)
5209 FN_GLOBAL_BOOL(lp_winbind_enum_groups, bWinbindEnumGroups)
5210 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, bWinbindUseDefaultDomain)
5211 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, bWinbindTrustedDomainsOnly)
5212 FN_GLOBAL_BOOL(lp_winbind_nested_groups, bWinbindNestedGroups)
5213 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, winbind_expand_groups)
5214 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, bWinbindRefreshTickets)
5215 FN_GLOBAL_BOOL(lp_winbind_offline_logon, bWinbindOfflineLogon)
5216 FN_GLOBAL_BOOL(lp_winbind_normalize_names, bWinbindNormalizeNames)
5217 FN_GLOBAL_BOOL(lp_winbind_rpc_only, bWinbindRpcOnly)
5218 FN_GLOBAL_BOOL(lp_create_krb5_conf, bCreateKrb5Conf)
5219 static FN_GLOBAL_INTEGER(lp_winbind_max_domain_connections_int,
5220 winbindMaxDomainConnections)
5222 int lp_winbind_max_domain_connections(void)
5224 if (lp_winbind_offline_logon() &&
5225 lp_winbind_max_domain_connections_int() > 1) {
5226 DEBUG(1, ("offline logons active, restricting max domain "
5227 "connections to 1\n"));
5230 return MAX(1, lp_winbind_max_domain_connections_int());
5233 FN_GLOBAL_CONST_STRING(lp_idmap_backend, szIdmapBackend)
5234 FN_GLOBAL_INTEGER(lp_idmap_cache_time, iIdmapCacheTime)
5235 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, iIdmapNegativeCacheTime)
5236 FN_GLOBAL_INTEGER(lp_keepalive, iKeepalive)
5237 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, bPassdbExpandExplicit)
5239 FN_GLOBAL_STRING(lp_ldap_suffix, szLdapSuffix)
5240 FN_GLOBAL_STRING(lp_ldap_admin_dn, szLdapAdminDn)
5241 FN_GLOBAL_INTEGER(lp_ldap_ssl, ldap_ssl)
5242 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, ldap_ssl_ads)
5243 FN_GLOBAL_INTEGER(lp_ldap_deref, ldap_deref)
5244 FN_GLOBAL_INTEGER(lp_ldap_follow_referral, ldap_follow_referral)
5245 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, ldap_passwd_sync)
5246 FN_GLOBAL_BOOL(lp_ldap_delete_dn, ldap_delete_dn)
5247 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, ldap_replication_sleep)
5248 FN_GLOBAL_INTEGER(lp_ldap_timeout, ldap_timeout)
5249 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, ldap_connection_timeout)
5250 FN_GLOBAL_INTEGER(lp_ldap_page_size, ldap_page_size)
5251 FN_GLOBAL_INTEGER(lp_ldap_debug_level, ldap_debug_level)
5252 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, ldap_debug_threshold)
5253 FN_GLOBAL_STRING(lp_add_share_cmd, szAddShareCommand)
5254 FN_GLOBAL_STRING(lp_change_share_cmd, szChangeShareCommand)
5255 FN_GLOBAL_STRING(lp_delete_share_cmd, szDeleteShareCommand)
5256 FN_GLOBAL_STRING(lp_usershare_path, szUsersharePath)
5257 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, szUsersharePrefixAllowList)
5258 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, szUsersharePrefixDenyList)
5260 FN_GLOBAL_LIST(lp_eventlog_list, szEventLogs)
5262 FN_GLOBAL_BOOL(lp_registry_shares, bRegistryShares)
5263 FN_GLOBAL_BOOL(lp_usershare_allow_guests, bUsershareAllowGuests)
5264 FN_GLOBAL_BOOL(lp_usershare_owner_only, bUsershareOwnerOnly)
5265 FN_GLOBAL_BOOL(lp_disable_netbios, bDisableNetbios)
5266 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, bResetOnZeroVC)
5267 FN_GLOBAL_BOOL(lp_log_writeable_files_on_exit, bLogWriteableFilesOnExit)
5268 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, bMsAddPrinterWizard)
5269 FN_GLOBAL_BOOL(lp_dns_proxy, bDNSproxy)
5270 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, bWINSsupport)
5271 FN_GLOBAL_BOOL(lp_wins_proxy, bWINSproxy)
5272 FN_GLOBAL_BOOL(lp_local_master, bLocalMaster)
5273 FN_GLOBAL_BOOL(lp_domain_logons, bDomainLogons)
5274 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, szInitLogonDelayedHosts)
5275 FN_GLOBAL_INTEGER(lp_init_logon_delay, InitLogonDelay)
5276 FN_GLOBAL_BOOL(lp_load_printers, bLoadPrinters)
5277 FN_GLOBAL_BOOL(_lp_readraw, bReadRaw)
5278 FN_GLOBAL_BOOL(lp_large_readwrite, bLargeReadwrite)
5279 FN_GLOBAL_BOOL(_lp_writeraw, bWriteRaw)
5280 FN_GLOBAL_BOOL(lp_null_passwords, bNullPasswords)
5281 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, bObeyPamRestrictions)
5282 FN_GLOBAL_BOOL(lp_encrypted_passwords, bEncryptPasswords)
5283 FN_GLOBAL_INTEGER(lp_client_schannel, clientSchannel)
5284 FN_GLOBAL_INTEGER(lp_server_schannel, serverSchannel)
5285 FN_GLOBAL_BOOL(lp_syslog_only, bSyslogOnly)
5286 FN_GLOBAL_BOOL(lp_timestamp_logs, bTimestampLogs)
5287 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, bDebugPrefixTimestamp)
5288 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, bDebugHiresTimestamp)
5289 FN_GLOBAL_BOOL(lp_debug_pid, bDebugPid)
5290 FN_GLOBAL_BOOL(lp_debug_uid, bDebugUid)
5291 FN_GLOBAL_BOOL(lp_debug_class, bDebugClass)
5292 FN_GLOBAL_BOOL(lp_enable_core_files, bEnableCoreFiles)
5293 FN_GLOBAL_BOOL(lp_browse_list, bBrowseList)
5294 FN_GLOBAL_BOOL(lp_nis_home_map, bNISHomeMap)
5295 static FN_GLOBAL_BOOL(lp_time_server, bTimeServer)
5296 FN_GLOBAL_BOOL(lp_bind_interfaces_only, bBindInterfacesOnly)
5297 FN_GLOBAL_BOOL(lp_pam_password_change, bPamPasswordChange)
5298 FN_GLOBAL_BOOL(lp_unix_password_sync, bUnixPasswdSync)
5299 FN_GLOBAL_BOOL(lp_passwd_chat_debug, bPasswdChatDebug)
5300 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, iPasswdChatTimeout)
5301 FN_GLOBAL_BOOL(lp_nt_pipe_support, bNTPipeSupport)
5302 FN_GLOBAL_BOOL(lp_nt_status_support, bNTStatusSupport)
5303 FN_GLOBAL_BOOL(lp_stat_cache, bStatCache)
5304 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, iMaxStatCacheSize)
5305 FN_GLOBAL_BOOL(lp_allow_trusted_domains, bAllowTrustedDomains)
5306 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, bMapUntrustedToDomain)
5307 FN_GLOBAL_INTEGER(lp_restrict_anonymous, restrict_anonymous)
5308 FN_GLOBAL_BOOL(lp_lanman_auth, bLanmanAuth)
5309 FN_GLOBAL_BOOL(lp_ntlm_auth, bNTLMAuth)
5310 FN_GLOBAL_BOOL(lp_client_plaintext_auth, bClientPlaintextAuth)
5311 FN_GLOBAL_BOOL(lp_client_lanman_auth, bClientLanManAuth)
5312 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, bClientNTLMv2Auth)
5313 FN_GLOBAL_BOOL(lp_host_msdfs, bHostMSDfs)
5314 FN_GLOBAL_BOOL(lp_kernel_oplocks, bKernelOplocks)
5315 FN_GLOBAL_BOOL(lp_enhanced_browsing, enhanced_browsing)
5316 FN_GLOBAL_BOOL(lp_use_mmap, bUseMmap)
5317 FN_GLOBAL_BOOL(lp_unix_extensions, bUnixExtensions)
5318 FN_GLOBAL_BOOL(lp_use_spnego, bUseSpnego)
5319 FN_GLOBAL_BOOL(lp_client_use_spnego, bClientUseSpnego)
5320 FN_GLOBAL_BOOL(lp_client_use_spnego_principal, client_use_spnego_principal)
5321 FN_GLOBAL_BOOL(lp_send_spnego_principal, send_spnego_principal)
5322 FN_GLOBAL_BOOL(lp_hostname_lookups, bHostnameLookups)
5323 FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
5324 FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
5325 FN_GLOBAL_CONST_STRING(lp_dedicated_keytab_file, szDedicatedKeytabFile)
5326 FN_GLOBAL_INTEGER(lp_kerberos_method, iKerberosMethod)
5327 FN_GLOBAL_BOOL(lp_defer_sharing_violations, bDeferSharingViolations)
5328 FN_GLOBAL_BOOL(lp_enable_privileges, bEnablePrivileges)
5329 FN_GLOBAL_BOOL(lp_enable_asu_support, bASUSupport)
5330 FN_GLOBAL_INTEGER(lp_os_level, os_level)
5331 FN_GLOBAL_INTEGER(lp_max_ttl, max_ttl)
5332 FN_GLOBAL_INTEGER(lp_max_wins_ttl, max_wins_ttl)
5333 FN_GLOBAL_INTEGER(lp_min_wins_ttl, min_wins_ttl)
5334 FN_GLOBAL_INTEGER(lp_max_log_size, max_log_size)
5335 FN_GLOBAL_INTEGER(lp_max_open_files, max_open_files)
5336 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, open_files_db_hash_size)
5337 FN_GLOBAL_INTEGER(lp_maxxmit, max_xmit)
5338 FN_GLOBAL_INTEGER(lp_maxmux, max_mux)
5339 FN_GLOBAL_INTEGER(lp_passwordlevel, pwordlevel)
5340 FN_GLOBAL_INTEGER(lp_usernamelevel, unamelevel)
5341 FN_GLOBAL_INTEGER(lp_deadtime, deadtime)
5342 FN_GLOBAL_BOOL(lp_getwd_cache, getwd_cache)
5343 static FN_GLOBAL_INTEGER(_lp_maxprotocol, maxprotocol)
5344 int lp_maxprotocol(void)
5346 int ret = _lp_maxprotocol();
5347 if ((ret == PROTOCOL_SMB2) && (lp_security() == SEC_SHARE)) {
5348 DEBUG(2,("WARNING!!: \"security = share\" is incompatible "
5349 "with the SMB2 protocol. Resetting to SMB1.\n" ));
5350 lp_do_parameter(-1, "max protocol", "NT1");
5351 return PROTOCOL_NT1;
5355 FN_GLOBAL_INTEGER(lp_minprotocol, minprotocol)
5356 FN_GLOBAL_INTEGER(lp_security, security)
5357 FN_GLOBAL_LIST(lp_auth_methods, AuthMethods)
5358 FN_GLOBAL_BOOL(lp_paranoid_server_security, paranoid_server_security)
5359 FN_GLOBAL_INTEGER(lp_maxdisksize, maxdisksize)
5360 FN_GLOBAL_INTEGER(lp_lpqcachetime, lpqcachetime)
5361 FN_GLOBAL_INTEGER(lp_max_smbd_processes, iMaxSmbdProcesses)
5362 FN_GLOBAL_BOOL(_lp_disable_spoolss, bDisableSpoolss)
5363 FN_GLOBAL_INTEGER(lp_syslog, syslog)
5364 FN_GLOBAL_INTEGER(lp_lm_announce, lm_announce)
5365 FN_GLOBAL_INTEGER(lp_lm_interval, lm_interval)
5366 FN_GLOBAL_INTEGER(lp_machine_password_timeout, machine_password_timeout)
5367 FN_GLOBAL_INTEGER(lp_map_to_guest, map_to_guest)
5368 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, oplock_break_wait_time)
5369 FN_GLOBAL_INTEGER(lp_lock_spin_time, iLockSpinTime)
5370 FN_GLOBAL_INTEGER(lp_usershare_max_shares, iUsershareMaxShares)
5371 FN_GLOBAL_CONST_STRING(lp_socket_options, szSocketOptions)
5372 FN_GLOBAL_INTEGER(lp_config_backend, ConfigBackend)
5373 FN_GLOBAL_INTEGER(lp_smb2_max_read, ismb2_max_read)
5374 FN_GLOBAL_INTEGER(lp_smb2_max_write, ismb2_max_write)
5375 FN_GLOBAL_INTEGER(lp_smb2_max_trans, ismb2_max_trans)
5376 int lp_smb2_max_credits(void)
5378 if (Globals.ismb2_max_credits == 0) {
5379 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5381 return Globals.ismb2_max_credits;
5383 FN_LOCAL_STRING(lp_preexec, szPreExec)
5384 FN_LOCAL_STRING(lp_postexec, szPostExec)
5385 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
5386 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
5387 FN_LOCAL_STRING(lp_servicename, szService)
5388 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
5389 FN_LOCAL_STRING(lp_pathname, szPath)
5390 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
5391 FN_LOCAL_STRING(lp_username, szUsername)
5392 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
5393 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
5394 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
5395 FN_GLOBAL_LIST(lp_svcctl_list, szServicesList)
5396 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
5397 FN_GLOBAL_STRING(lp_cups_server, szCupsServer)
5398 int lp_cups_encrypt(void)
5401 #ifdef HAVE_HTTPCONNECTENCRYPT
5402 switch (Globals.CupsEncrypt) {
5404 result = HTTP_ENCRYPT_REQUIRED;
5407 result = HTTP_ENCRYPT_ALWAYS;
5410 result = HTTP_ENCRYPT_NEVER;
5416 FN_GLOBAL_STRING(lp_iprint_server, szIPrintServer)
5417 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, cups_connection_timeout)
5418 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, ctdbdSocket)
5419 FN_GLOBAL_LIST(lp_cluster_addresses, szClusterAddresses)
5420 FN_GLOBAL_BOOL(lp_clustering, clustering)
5421 FN_GLOBAL_INTEGER(lp_ctdb_timeout, ctdb_timeout)
5422 FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, ctdb_locktime_warn_threshold)
5423 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
5424 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
5425 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
5426 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
5427 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
5428 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
5429 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
5430 static FN_LOCAL_STRING(_lp_printername, szPrintername)
5431 FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
5432 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
5433 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
5434 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
5435 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
5436 FN_LOCAL_STRING(lp_comment, comment)
5437 FN_LOCAL_STRING(lp_force_user, force_user)
5438 FN_LOCAL_STRING(lp_force_group, force_group)
5439 FN_LOCAL_LIST(lp_readlist, readlist)
5440 FN_LOCAL_LIST(lp_writelist, writelist)
5441 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
5442 FN_LOCAL_STRING(lp_fstype, fstype)
5443 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
5444 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
5445 static FN_LOCAL_STRING(lp_volume, volume)
5446 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
5447 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
5448 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
5449 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
5450 FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
5451 FN_LOCAL_STRING(lp_dfree_command, szDfree)
5452 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
5453 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
5454 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
5455 FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
5456 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
5457 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
5458 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
5459 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
5460 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
5461 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
5462 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
5463 FN_LOCAL_BOOL(lp_access_based_share_enum, bAccessBasedShareEnum)
5464 FN_LOCAL_BOOL(lp_readonly, bRead_only)
5465 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
5466 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
5467 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
5468 FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
5469 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
5470 FN_LOCAL_BOOL(lp_print_notify_backchannel, bPrintNotifyBackchannel)
5471 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
5472 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
5473 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
5474 FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
5475 FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
5476 FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
5477 FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
5478 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
5479 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
5480 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
5481 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
5482 FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames)
5483 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
5484 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
5485 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
5486 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
5487 FN_LOCAL_BOOL(lp_map_system, bMap_system)
5488 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
5489 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
5490 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
5491 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
5492 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
5493 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
5494 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
5495 FN_GLOBAL_BOOL(lp_async_smb_echo_handler, bAsyncSMBEchoHandler)
5496 FN_GLOBAL_BOOL(lp_multicast_dns_register, bMulticastDnsRegister)
5497 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
5498 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
5499 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
5500 FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
5501 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
5502 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
5503 FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
5504 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
5505 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
5506 FN_LOCAL_BOOL(lp_ea_support, bEASupport)
5507 FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
5508 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
5509 FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
5510 FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
5511 FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
5512 FN_LOCAL_BOOL(lp_acl_group_control, bAclGroupControl)
5513 FN_LOCAL_BOOL(lp_acl_map_full_control, bAclMapFullControl)
5514 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
5515 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
5516 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
5517 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
5518 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
5519 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
5520 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
5521 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
5522 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
5523 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
5524 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
5525 FN_LOCAL_INTEGER(lp_printing, iPrinting)
5526 FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
5527 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
5528 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
5529 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
5530 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
5531 FN_LOCAL_INTEGER(lp_dfree_cache_time, iDfreeCacheTime)
5532 FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
5533 FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
5534 FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
5535 FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
5536 FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
5537 FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
5538 FN_LOCAL_CHAR(lp_magicchar, magic_char)
5539 FN_GLOBAL_INTEGER(lp_winbind_cache_time, winbind_cache_time)
5540 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, winbind_reconnect_delay)
5541 FN_GLOBAL_INTEGER(lp_winbind_max_clients, winbind_max_clients)
5542 FN_GLOBAL_LIST(lp_winbind_nss_info, szWinbindNssInfo)
5543 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, AlgorithmicRidBase)
5544 FN_GLOBAL_INTEGER(lp_name_cache_timeout, name_cache_timeout)
5545 FN_GLOBAL_INTEGER(lp_client_signing, client_signing)
5546 FN_GLOBAL_INTEGER(lp_server_signing, server_signing)
5547 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, client_ldap_sasl_wrapping)
5549 FN_GLOBAL_CONST_STRING(lp_ncalrpc_dir, ncalrpc_dir)
5551 /* local prototypes */
5553 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5554 static const char *get_boolean(bool bool_value);
5555 static int getservicebyname(const char *pszServiceName,
5556 struct loadparm_service *pserviceDest);
5557 static void copy_service(struct loadparm_service *pserviceDest,
5558 struct loadparm_service *pserviceSource,
5559 struct bitmap *pcopymapDest);
5560 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5562 static bool do_section(const char *pszSectionName, void *userdata);
5563 static void init_copymap(struct loadparm_service *pservice);
5564 static bool hash_a_service(const char *name, int number);
5565 static void free_service_byindex(int iService);
5566 static void free_param_opts(struct param_opt_struct **popts);
5567 static void show_parameter(int parmIndex);
5568 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5571 * This is a helper function for parametrical options support. It returns a
5572 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5573 * parametrical functions are quite simple
5575 static struct param_opt_struct *get_parametrics_by_service(struct loadparm_service *service, const char *type,
5578 bool global_section = false;
5580 struct param_opt_struct *data;
5582 if (service == NULL) {
5583 data = Globals.param_opt;
5584 global_section = true;
5586 data = service->param_opt;
5589 if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
5590 DEBUG(0,("asprintf failed!\n"));
5595 if (strwicmp(data->key, param_key) == 0) {
5596 string_free(¶m_key);
5602 if (!global_section) {
5603 /* Try to fetch the same option but from globals */
5604 /* but only if we are not already working with Globals */
5605 data = Globals.param_opt;
5607 if (strwicmp(data->key, param_key) == 0) {
5608 string_free(¶m_key);
5615 string_free(¶m_key);
5621 * This is a helper function for parametrical options support. It returns a
5622 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5623 * parametrical functions are quite simple
5625 static struct param_opt_struct *get_parametrics(int snum, const char *type,
5628 struct param_opt_struct *data;
5630 if (snum >= iNumServices) return NULL;
5633 return get_parametrics_by_service(NULL, type, option);
5635 return get_parametrics_by_service(ServicePtrs[snum], type, option);
5640 #define MISSING_PARAMETER(name) \
5641 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5643 /*******************************************************************
5644 convenience routine to return int parameters.
5645 ********************************************************************/
5646 static int lp_int(const char *s)
5650 MISSING_PARAMETER(lp_int);
5654 return (int)strtol(s, NULL, 0);
5657 /*******************************************************************
5658 convenience routine to return unsigned long parameters.
5659 ********************************************************************/
5660 static unsigned long lp_ulong(const char *s)
5664 MISSING_PARAMETER(lp_ulong);
5668 return strtoul(s, NULL, 0);
5671 /*******************************************************************
5672 convenience routine to return boolean parameters.
5673 ********************************************************************/
5674 static bool lp_bool(const char *s)
5679 MISSING_PARAMETER(lp_bool);
5683 if (!set_boolean(s, &ret)) {
5684 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5691 /*******************************************************************
5692 convenience routine to return enum parameters.
5693 ********************************************************************/
5694 static int lp_enum(const char *s,const struct enum_list *_enum)
5698 if (!s || !*s || !_enum) {
5699 MISSING_PARAMETER(lp_enum);
5703 for (i=0; _enum[i].name; i++) {
5704 if (strequal(_enum[i].name,s))
5705 return _enum[i].value;
5708 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5712 #undef MISSING_PARAMETER
5714 /* Return parametric option from a given service. Type is a part of option before ':' */
5715 /* Parametric option has following syntax: 'Type: option = value' */
5716 /* the returned value is talloced on the talloc_tos() */
5717 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5719 struct param_opt_struct *data = get_parametrics(snum, type, option);
5721 if (data == NULL||data->value==NULL) {
5723 return lp_string(def);
5729 return lp_string(data->value);
5732 /* Return parametric option from a given service. Type is a part of option before ':' */
5733 /* Parametric option has following syntax: 'Type: option = value' */
5734 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5736 struct param_opt_struct *data = get_parametrics(snum, type, option);
5738 if (data == NULL||data->value==NULL)
5744 const char *lp_parm_const_string_service(struct loadparm_service *service, const char *type, const char *option)
5746 struct param_opt_struct *data = get_parametrics_by_service(service, type, option);
5748 if (data == NULL||data->value==NULL)
5755 /* Return parametric option from a given service. Type is a part of option before ':' */
5756 /* Parametric option has following syntax: 'Type: option = value' */
5758 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5760 struct param_opt_struct *data = get_parametrics(snum, type, option);
5762 if (data == NULL||data->value==NULL)
5763 return (const char **)def;
5765 if (data->list==NULL) {
5766 data->list = str_list_make_v3(NULL, data->value, NULL);
5769 return (const char **)data->list;
5772 /* Return parametric option from a given service. Type is a part of option before ':' */
5773 /* Parametric option has following syntax: 'Type: option = value' */
5775 int lp_parm_int(int snum, const char *type, const char *option, int def)
5777 struct param_opt_struct *data = get_parametrics(snum, type, option);
5779 if (data && data->value && *data->value)
5780 return lp_int(data->value);
5785 /* Return parametric option from a given service. Type is a part of option before ':' */
5786 /* Parametric option has following syntax: 'Type: option = value' */
5788 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5790 struct param_opt_struct *data = get_parametrics(snum, type, option);
5792 if (data && data->value && *data->value)
5793 return lp_ulong(data->value);
5798 /* Return parametric option from a given service. Type is a part of option before ':' */
5799 /* Parametric option has following syntax: 'Type: option = value' */
5801 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5803 struct param_opt_struct *data = get_parametrics(snum, type, option);
5805 if (data && data->value && *data->value)
5806 return lp_bool(data->value);
5811 /* Return parametric option from a given service. Type is a part of option before ':' */
5812 /* Parametric option has following syntax: 'Type: option = value' */
5814 int lp_parm_enum(int snum, const char *type, const char *option,
5815 const struct enum_list *_enum, int def)
5817 struct param_opt_struct *data = get_parametrics(snum, type, option);
5819 if (data && data->value && *data->value && _enum)
5820 return lp_enum(data->value, _enum);
5826 /***************************************************************************
5827 Initialise a service to the defaults.
5828 ***************************************************************************/
5830 static void init_service(struct loadparm_service *pservice)
5832 memset((char *)pservice, '\0', sizeof(struct loadparm_service));
5833 copy_service(pservice, &sDefault, NULL);
5838 * free a param_opts structure.
5839 * param_opts handling should be moved to talloc;
5840 * then this whole functions reduces to a TALLOC_FREE().
5843 static void free_param_opts(struct param_opt_struct **popts)
5845 struct param_opt_struct *opt, *next_opt;
5847 if (popts == NULL) {
5851 if (*popts != NULL) {
5852 DEBUG(5, ("Freeing parametrics:\n"));
5855 while (opt != NULL) {
5856 string_free(&opt->key);
5857 string_free(&opt->value);
5858 TALLOC_FREE(opt->list);
5859 next_opt = opt->next;
5866 /***************************************************************************
5867 Free the dynamically allocated parts of a service struct.
5868 ***************************************************************************/
5870 static void free_service(struct loadparm_service *pservice)
5875 if (pservice->szService)
5876 DEBUG(5, ("free_service: Freeing service %s\n",
5877 pservice->szService));
5879 free_parameters(pservice);
5881 string_free(&pservice->szService);
5882 TALLOC_FREE(pservice->copymap);
5884 free_param_opts(&pservice->param_opt);
5886 ZERO_STRUCTP(pservice);
5890 /***************************************************************************
5891 remove a service indexed in the ServicePtrs array from the ServiceHash
5892 and free the dynamically allocated parts
5893 ***************************************************************************/
5895 static void free_service_byindex(int idx)
5897 if ( !LP_SNUM_OK(idx) )
5900 ServicePtrs[idx]->valid = false;
5901 invalid_services[num_invalid_services++] = idx;
5903 /* we have to cleanup the hash record */
5905 if (ServicePtrs[idx]->szService) {
5906 char *canon_name = canonicalize_servicename(
5908 ServicePtrs[idx]->szService );
5910 dbwrap_delete_bystring(ServiceHash, canon_name );
5911 TALLOC_FREE(canon_name);
5914 free_service(ServicePtrs[idx]);
5917 /***************************************************************************
5918 Add a new service to the services array initialising it with the given
5920 ***************************************************************************/
5922 static int add_a_service(const struct loadparm_service *pservice, const char *name)
5925 struct loadparm_service tservice;
5926 int num_to_alloc = iNumServices + 1;
5928 tservice = *pservice;
5930 /* it might already exist */
5932 i = getservicebyname(name, NULL);
5938 /* find an invalid one */
5940 if (num_invalid_services > 0) {
5941 i = invalid_services[--num_invalid_services];
5944 /* if not, then create one */
5945 if (i == iNumServices) {
5946 struct loadparm_service **tsp;
5949 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct loadparm_service *, num_to_alloc);
5951 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
5955 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct loadparm_service);
5956 if (!ServicePtrs[iNumServices]) {
5957 DEBUG(0,("add_a_service: out of memory!\n"));
5962 /* enlarge invalid_services here for now... */
5963 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
5965 if (tinvalid == NULL) {
5966 DEBUG(0,("add_a_service: failed to enlarge "
5967 "invalid_services!\n"));
5970 invalid_services = tinvalid;
5972 free_service_byindex(i);
5975 ServicePtrs[i]->valid = true;
5977 init_service(ServicePtrs[i]);
5978 copy_service(ServicePtrs[i], &tservice, NULL);
5980 string_set(&ServicePtrs[i]->szService, name);
5982 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
5983 i, ServicePtrs[i]->szService));
5985 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
5992 /***************************************************************************
5993 Convert a string to uppercase and remove whitespaces.
5994 ***************************************************************************/
5996 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
6001 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
6005 result = talloc_strdup(ctx, src);
6006 SMB_ASSERT(result != NULL);
6012 /***************************************************************************
6013 Add a name/index pair for the services array to the hash table.
6014 ***************************************************************************/
6016 static bool hash_a_service(const char *name, int idx)
6020 if ( !ServiceHash ) {
6021 DEBUG(10,("hash_a_service: creating servicehash\n"));
6022 ServiceHash = db_open_rbt(NULL);
6023 if ( !ServiceHash ) {
6024 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
6029 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
6032 canon_name = canonicalize_servicename(talloc_tos(), name );
6034 dbwrap_store_bystring(ServiceHash, canon_name,
6035 make_tdb_data((uint8 *)&idx, sizeof(idx)),
6038 TALLOC_FREE(canon_name);
6043 /***************************************************************************
6044 Add a new home service, with the specified home directory, defaults coming
6046 ***************************************************************************/
6048 bool lp_add_home(const char *pszHomename, int iDefaultService,
6049 const char *user, const char *pszHomedir)
6053 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
6054 pszHomedir[0] == '\0') {
6058 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
6063 if (!(*(ServicePtrs[iDefaultService]->szPath))
6064 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
6065 string_set(&ServicePtrs[i]->szPath, pszHomedir);
6068 if (!(*(ServicePtrs[i]->comment))) {
6069 char *comment = NULL;
6070 if (asprintf(&comment, "Home directory of %s", user) < 0) {
6073 string_set(&ServicePtrs[i]->comment, comment);
6077 /* set the browseable flag from the global default */
6079 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6080 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
6082 ServicePtrs[i]->autoloaded = true;
6084 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
6085 user, ServicePtrs[i]->szPath ));
6090 /***************************************************************************
6091 Add a new service, based on an old one.
6092 ***************************************************************************/
6094 int lp_add_service(const char *pszService, int iDefaultService)
6096 if (iDefaultService < 0) {
6097 return add_a_service(&sDefault, pszService);
6100 return (add_a_service(ServicePtrs[iDefaultService], pszService));
6103 /***************************************************************************
6104 Add the IPC service.
6105 ***************************************************************************/
6107 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
6109 char *comment = NULL;
6110 int i = add_a_service(&sDefault, ipc_name);
6115 if (asprintf(&comment, "IPC Service (%s)",
6116 Globals.szServerString) < 0) {
6120 string_set(&ServicePtrs[i]->szPath, tmpdir());
6121 string_set(&ServicePtrs[i]->szUsername, "");
6122 string_set(&ServicePtrs[i]->comment, comment);
6123 string_set(&ServicePtrs[i]->fstype, "IPC");
6124 ServicePtrs[i]->iMaxConnections = 0;
6125 ServicePtrs[i]->bAvailable = true;
6126 ServicePtrs[i]->bRead_only = true;
6127 ServicePtrs[i]->bGuest_only = false;
6128 ServicePtrs[i]->bAdministrative_share = true;
6129 ServicePtrs[i]->bGuest_ok = guest_ok;
6130 ServicePtrs[i]->bPrint_ok = false;
6131 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6133 DEBUG(3, ("adding IPC service\n"));
6139 /***************************************************************************
6140 Add a new printer service, with defaults coming from service iFrom.
6141 ***************************************************************************/
6143 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
6145 const char *comment = "From Printcap";
6146 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6151 /* note that we do NOT default the availability flag to true - */
6152 /* we take it from the default service passed. This allows all */
6153 /* dynamic printers to be disabled by disabling the [printers] */
6154 /* entry (if/when the 'available' keyword is implemented!). */
6156 /* the printer name is set to the service name. */
6157 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6158 string_set(&ServicePtrs[i]->comment, comment);
6160 /* set the browseable flag from the gloabl default */
6161 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6163 /* Printers cannot be read_only. */
6164 ServicePtrs[i]->bRead_only = false;
6165 /* No share modes on printer services. */
6166 ServicePtrs[i]->bShareModes = false;
6167 /* No oplocks on printer services. */
6168 ServicePtrs[i]->bOpLocks = false;
6169 /* Printer services must be printable. */
6170 ServicePtrs[i]->bPrint_ok = true;
6172 DEBUG(3, ("adding printer service %s\n", pszPrintername));
6178 /***************************************************************************
6179 Check whether the given parameter name is valid.
6180 Parametric options (names containing a colon) are considered valid.
6181 ***************************************************************************/
6183 bool lp_parameter_is_valid(const char *pszParmName)
6185 return ((map_parameter(pszParmName) != -1) ||
6186 (strchr(pszParmName, ':') != NULL));
6189 /***************************************************************************
6190 Check whether the given name is the name of a global parameter.
6191 Returns true for strings belonging to parameters of class
6192 P_GLOBAL, false for all other strings, also for parametric options
6193 and strings not belonging to any option.
6194 ***************************************************************************/
6196 bool lp_parameter_is_global(const char *pszParmName)
6198 int num = map_parameter(pszParmName);
6201 return (parm_table[num].p_class == P_GLOBAL);
6207 /**************************************************************************
6208 Check whether the given name is the canonical name of a parameter.
6209 Returns false if it is not a valid parameter Name.
6210 For parametric options, true is returned.
6211 **************************************************************************/
6213 bool lp_parameter_is_canonical(const char *parm_name)
6215 if (!lp_parameter_is_valid(parm_name)) {
6219 return (map_parameter(parm_name) ==
6220 map_parameter_canonical(parm_name, NULL));
6223 /**************************************************************************
6224 Determine the canonical name for a parameter.
6225 Indicate when it is an inverse (boolean) synonym instead of a
6227 **************************************************************************/
6229 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6234 if (!lp_parameter_is_valid(parm_name)) {
6239 num = map_parameter_canonical(parm_name, inverse);
6241 /* parametric option */
6242 *canon_parm = parm_name;
6244 *canon_parm = parm_table[num].label;
6251 /**************************************************************************
6252 Determine the canonical name for a parameter.
6253 Turn the value given into the inverse boolean expression when
6254 the synonym is an invers boolean synonym.
6256 Return true if parm_name is a valid parameter name and
6257 in case it is an invers boolean synonym, if the val string could
6258 successfully be converted to the reverse bool.
6259 Return false in all other cases.
6260 **************************************************************************/
6262 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6264 const char **canon_parm,
6265 const char **canon_val)
6270 if (!lp_parameter_is_valid(parm_name)) {
6276 num = map_parameter_canonical(parm_name, &inverse);
6278 /* parametric option */
6279 *canon_parm = parm_name;
6282 *canon_parm = parm_table[num].label;
6284 if (!lp_invert_boolean(val, canon_val)) {
6296 /***************************************************************************
6297 Map a parameter's string representation to something we can use.
6298 Returns false if the parameter string is not recognised, else TRUE.
6299 ***************************************************************************/
6301 static int map_parameter(const char *pszParmName)
6305 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6308 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6309 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6312 /* Warn only if it isn't parametric option */
6313 if (strchr(pszParmName, ':') == NULL)
6314 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6315 /* We do return 'fail' for parametric options as well because they are
6316 stored in different storage
6321 /***************************************************************************
6322 Map a parameter's string representation to the index of the canonical
6323 form of the parameter (it might be a synonym).
6324 Returns -1 if the parameter string is not recognised.
6325 ***************************************************************************/
6327 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6329 int parm_num, canon_num;
6330 bool loc_inverse = false;
6332 parm_num = map_parameter(pszParmName);
6333 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6334 /* invalid, parametric or no canidate for synonyms ... */
6338 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6339 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6340 parm_num = canon_num;
6346 if (inverse != NULL) {
6347 *inverse = loc_inverse;
6352 /***************************************************************************
6353 return true if parameter number parm1 is a synonym of parameter
6354 number parm2 (parm2 being the principal name).
6355 set inverse to true if parm1 is P_BOOLREV and parm2 is P_BOOL,
6357 ***************************************************************************/
6359 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6361 if ((parm_table[parm1].offset == parm_table[parm2].offset) &&
6362 (parm_table[parm1].flags & FLAG_HIDE) &&
6363 !(parm_table[parm2].flags & FLAG_HIDE))
6365 if (inverse != NULL) {
6366 if ((parm_table[parm1].type == P_BOOLREV) &&
6367 (parm_table[parm2].type == P_BOOL))
6379 /***************************************************************************
6380 Show one parameter's name, type, [values,] and flags.
6381 (helper functions for show_parameter_list)
6382 ***************************************************************************/
6384 static void show_parameter(int parmIndex)
6386 int enumIndex, flagIndex;
6391 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6392 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6394 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6395 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6397 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6398 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6399 "FLAG_DEPRECATED", "FLAG_HIDE", NULL};
6401 printf("%s=%s", parm_table[parmIndex].label,
6402 type[parm_table[parmIndex].type]);
6403 if (parm_table[parmIndex].type == P_ENUM) {
6406 parm_table[parmIndex].enum_list[enumIndex].name;
6410 enumIndex ? "|" : "",
6411 parm_table[parmIndex].enum_list[enumIndex].name);
6416 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6417 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6420 flag_names[flagIndex]);
6425 /* output synonyms */
6427 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6428 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6429 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6430 parm_table[parmIndex2].label);
6431 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6433 printf(" (synonyms: ");
6438 printf("%s%s", parm_table[parmIndex2].label,
6439 inverse ? "[i]" : "");
6449 /***************************************************************************
6450 Show all parameter's name, type, [values,] and flags.
6451 ***************************************************************************/
6453 void show_parameter_list(void)
6455 int classIndex, parmIndex;
6456 const char *section_names[] = { "local", "global", NULL};
6458 for (classIndex=0; section_names[classIndex]; classIndex++) {
6459 printf("[%s]\n", section_names[classIndex]);
6460 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6461 if (parm_table[parmIndex].p_class == classIndex) {
6462 show_parameter(parmIndex);
6468 /***************************************************************************
6469 Check if a given string correctly represents a boolean value.
6470 ***************************************************************************/
6472 bool lp_string_is_valid_boolean(const char *parm_value)
6474 return set_boolean(parm_value, NULL);
6477 /***************************************************************************
6478 Get the standard string representation of a boolean value ("yes" or "no")
6479 ***************************************************************************/
6481 static const char *get_boolean(bool bool_value)
6483 static const char *yes_str = "yes";
6484 static const char *no_str = "no";
6486 return (bool_value ? yes_str : no_str);
6489 /***************************************************************************
6490 Provide the string of the negated boolean value associated to the boolean
6491 given as a string. Returns false if the passed string does not correctly
6492 represent a boolean.
6493 ***************************************************************************/
6495 bool lp_invert_boolean(const char *str, const char **inverse_str)
6499 if (!set_boolean(str, &val)) {
6503 *inverse_str = get_boolean(!val);
6507 /***************************************************************************
6508 Provide the canonical string representation of a boolean value given
6509 as a string. Return true on success, false if the string given does
6510 not correctly represent a boolean.
6511 ***************************************************************************/
6513 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6517 if (!set_boolean(str, &val)) {
6521 *canon_str = get_boolean(val);
6525 /***************************************************************************
6526 Find a service by name. Otherwise works like get_service.
6527 ***************************************************************************/
6529 static int getservicebyname(const char *pszServiceName, struct loadparm_service *pserviceDest)
6535 if (ServiceHash == NULL) {
6539 canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
6541 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
6543 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
6544 iService = *(int *)data.dptr;
6547 TALLOC_FREE(canon_name);
6549 if ((iService != -1) && (LP_SNUM_OK(iService))
6550 && (pserviceDest != NULL)) {
6551 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6557 /* Return a pointer to a service by name. Unlike getservicebyname, it does not copy the service */
6558 struct loadparm_service *lp_service(const char *pszServiceName)
6560 int iService = getservicebyname(pszServiceName, NULL);
6561 if (iService == -1 || !LP_SNUM_OK(iService)) {
6564 return ServicePtrs[iService];
6568 /***************************************************************************
6569 Copy a service structure to another.
6570 If pcopymapDest is NULL then copy all fields
6571 ***************************************************************************/
6574 * Add a parametric option to a param_opt_struct,
6575 * replacing old value, if already present.
6577 static void set_param_opt(struct param_opt_struct **opt_list,
6578 const char *opt_name,
6579 const char *opt_value,
6582 struct param_opt_struct *new_opt, *opt;
6585 if (opt_list == NULL) {
6592 /* Traverse destination */
6594 /* If we already have same option, override it */
6595 if (strwicmp(opt->key, opt_name) == 0) {
6596 if ((opt->flags & FLAG_CMDLINE) &&
6597 !(flags & FLAG_CMDLINE)) {
6598 /* it's been marked as not to be
6602 string_free(&opt->value);
6603 TALLOC_FREE(opt->list);
6604 opt->value = SMB_STRDUP(opt_value);
6612 new_opt = SMB_XMALLOC_P(struct param_opt_struct);
6613 new_opt->key = SMB_STRDUP(opt_name);
6614 new_opt->value = SMB_STRDUP(opt_value);
6615 new_opt->list = NULL;
6616 new_opt->flags = flags;
6617 DLIST_ADD(*opt_list, new_opt);
6621 static void copy_service(struct loadparm_service *pserviceDest, struct loadparm_service *pserviceSource,
6622 struct bitmap *pcopymapDest)
6625 bool bcopyall = (pcopymapDest == NULL);
6626 struct param_opt_struct *data;
6628 for (i = 0; parm_table[i].label; i++)
6629 if (parm_table[i].p_class == P_LOCAL &&
6630 (bcopyall || bitmap_query(pcopymapDest,i))) {
6631 void *src_ptr = lp_parm_ptr(pserviceSource, &parm_table[i]);
6632 void *dest_ptr = lp_parm_ptr(pserviceDest, &parm_table[i]);
6634 switch (parm_table[i].type) {
6637 *(bool *)dest_ptr = *(bool *)src_ptr;
6643 *(int *)dest_ptr = *(int *)src_ptr;
6647 *(char *)dest_ptr = *(char *)src_ptr;
6651 string_set((char **)dest_ptr,
6657 char *upper_string = strupper_talloc(talloc_tos(),
6659 string_set((char **)dest_ptr,
6661 TALLOC_FREE(upper_string);
6665 TALLOC_FREE(*((char ***)dest_ptr));
6666 *((char ***)dest_ptr) = str_list_copy(NULL,
6667 *(const char ***)src_ptr);
6675 init_copymap(pserviceDest);
6676 if (pserviceSource->copymap)
6677 bitmap_copy(pserviceDest->copymap,
6678 pserviceSource->copymap);
6681 data = pserviceSource->param_opt;
6683 set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->flags);
6688 /***************************************************************************
6689 Check a service for consistency. Return false if the service is in any way
6690 incomplete or faulty, else true.
6691 ***************************************************************************/
6693 bool service_ok(int iService)
6698 if (ServicePtrs[iService]->szService[0] == '\0') {
6699 DEBUG(0, ("The following message indicates an internal error:\n"));
6700 DEBUG(0, ("No service name in service entry.\n"));
6704 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6705 /* I can't see why you'd want a non-printable printer service... */
6706 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6707 if (!ServicePtrs[iService]->bPrint_ok) {
6708 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6709 ServicePtrs[iService]->szService));
6710 ServicePtrs[iService]->bPrint_ok = true;
6712 /* [printers] service must also be non-browsable. */
6713 if (ServicePtrs[iService]->bBrowseable)
6714 ServicePtrs[iService]->bBrowseable = false;
6717 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6718 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6719 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6721 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6722 ServicePtrs[iService]->szService));
6723 ServicePtrs[iService]->bAvailable = false;
6726 /* If a service is flagged unavailable, log the fact at level 1. */
6727 if (!ServicePtrs[iService]->bAvailable)
6728 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6729 ServicePtrs[iService]->szService));
6734 static struct smbconf_ctx *lp_smbconf_ctx(void)
6737 static struct smbconf_ctx *conf_ctx = NULL;
6739 if (conf_ctx == NULL) {
6740 err = smbconf_init(NULL, &conf_ctx, "registry:");
6741 if (!SBC_ERROR_IS_OK(err)) {
6742 DEBUG(1, ("error initializing registry configuration: "
6743 "%s\n", sbcErrorString(err)));
6751 static bool process_smbconf_service(struct smbconf_service *service)
6756 if (service == NULL) {
6760 ret = do_section(service->name, NULL);
6764 for (count = 0; count < service->num_params; count++) {
6765 ret = do_parameter(service->param_names[count],
6766 service->param_values[count],
6772 if (iServiceIndex >= 0) {
6773 return service_ok(iServiceIndex);
6779 * load a service from registry and activate it
6781 bool process_registry_service(const char *service_name)
6784 struct smbconf_service *service = NULL;
6785 TALLOC_CTX *mem_ctx = talloc_stackframe();
6786 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6789 if (conf_ctx == NULL) {
6793 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6795 if (!smbconf_share_exists(conf_ctx, service_name)) {
6797 * Registry does not contain data for this service (yet),
6798 * but make sure lp_load doesn't return false.
6804 err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6805 if (!SBC_ERROR_IS_OK(err)) {
6809 ret = process_smbconf_service(service);
6815 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6818 TALLOC_FREE(mem_ctx);
6823 * process_registry_globals
6825 static bool process_registry_globals(void)
6829 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6831 ret = do_parameter("registry shares", "yes", NULL);
6836 return process_registry_service(GLOBAL_NAME);
6839 bool process_registry_shares(void)
6843 struct smbconf_service **service = NULL;
6844 uint32_t num_shares = 0;
6845 TALLOC_CTX *mem_ctx = talloc_stackframe();
6846 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6849 if (conf_ctx == NULL) {
6853 err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6854 if (!SBC_ERROR_IS_OK(err)) {
6860 for (count = 0; count < num_shares; count++) {
6861 if (strequal(service[count]->name, GLOBAL_NAME)) {
6864 ret = process_smbconf_service(service[count]);
6871 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6874 TALLOC_FREE(mem_ctx);
6878 #define MAX_INCLUDE_DEPTH 100
6880 static uint8_t include_depth;
6882 static struct file_lists {
6883 struct file_lists *next;
6887 } *file_lists = NULL;
6889 /*******************************************************************
6890 Keep a linked list of all config files so we know when one has changed
6891 it's date and needs to be reloaded.
6892 ********************************************************************/
6894 static void add_to_file_list(const char *fname, const char *subfname)
6896 struct file_lists *f = file_lists;
6899 if (f->name && !strcmp(f->name, fname))
6905 f = SMB_MALLOC_P(struct file_lists);
6908 f->next = file_lists;
6909 f->name = SMB_STRDUP(fname);
6914 f->subfname = SMB_STRDUP(subfname);
6921 f->modtime = file_modtime(subfname);
6923 time_t t = file_modtime(subfname);
6931 * Free the file lists
6933 static void free_file_list(void)
6935 struct file_lists *f;
6936 struct file_lists *next;
6941 SAFE_FREE( f->name );
6942 SAFE_FREE( f->subfname );
6951 * Utility function for outsiders to check if we're running on registry.
6953 bool lp_config_backend_is_registry(void)
6955 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
6959 * Utility function to check if the config backend is FILE.
6961 bool lp_config_backend_is_file(void)
6963 return (lp_config_backend() == CONFIG_BACKEND_FILE);
6966 /*******************************************************************
6967 Check if a config file has changed date.
6968 ********************************************************************/
6970 bool lp_file_list_changed(void)
6972 struct file_lists *f = file_lists;
6974 DEBUG(6, ("lp_file_list_changed()\n"));
6979 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
6980 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6982 if (conf_ctx == NULL) {
6985 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
6988 DEBUGADD(6, ("registry config changed\n"));
6993 n2 = talloc_sub_basic(talloc_tos(),
6994 get_current_username(),
6995 current_user_info.domain,
7000 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
7001 f->name, n2, ctime(&f->modtime)));
7003 mod_time = file_modtime(n2);
7006 ((f->modtime != mod_time) ||
7007 (f->subfname == NULL) ||
7008 (strcmp(n2, f->subfname) != 0)))
7011 ("file %s modified: %s\n", n2,
7013 f->modtime = mod_time;
7014 SAFE_FREE(f->subfname);
7015 f->subfname = SMB_STRDUP(n2);
7028 * Initialize iconv conversion descriptors.
7030 * This is called the first time it is needed, and also called again
7031 * every time the configuration is reloaded, because the charset or
7032 * codepage might have changed.
7034 static void init_iconv(void)
7036 global_iconv_handle = smb_iconv_handle_reinit(NULL, lp_dos_charset(),
7038 true, global_iconv_handle);
7041 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7043 if (strcmp(*ptr, pszParmValue) != 0) {
7044 string_set(ptr, pszParmValue);
7050 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7052 bool is_utf8 = false;
7053 size_t len = strlen(pszParmValue);
7055 if (len == 4 || len == 5) {
7056 /* Don't use StrCaseCmp here as we don't want to
7057 initialize iconv. */
7058 if ((toupper_ascii(pszParmValue[0]) == 'U') &&
7059 (toupper_ascii(pszParmValue[1]) == 'T') &&
7060 (toupper_ascii(pszParmValue[2]) == 'F')) {
7062 if (pszParmValue[3] == '8') {
7066 if (pszParmValue[3] == '-' &&
7067 pszParmValue[4] == '8') {
7074 if (strcmp(*ptr, pszParmValue) != 0) {
7076 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
7077 "be UTF8, using (default value) %s instead.\n",
7078 DEFAULT_DOS_CHARSET));
7079 pszParmValue = DEFAULT_DOS_CHARSET;
7081 string_set(ptr, pszParmValue);
7087 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7090 char *realm = strupper_talloc(talloc_tos(), pszParmValue);
7091 char *dnsdomain = strlower_talloc(talloc_tos(), pszParmValue);
7093 ret &= string_set(&Globals.szRealm, pszParmValue);
7094 ret &= string_set(&Globals.szRealmUpper, realm);
7095 ret &= string_set(&Globals.szDnsDomain, dnsdomain);
7097 TALLOC_FREE(dnsdomain);
7102 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7104 TALLOC_FREE(Globals.szNetbiosAliases);
7105 Globals.szNetbiosAliases = str_list_make_v3(NULL, pszParmValue, NULL);
7106 return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
7109 /***************************************************************************
7110 Handle the include operation.
7111 ***************************************************************************/
7112 static bool bAllowIncludeRegistry = true;
7114 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7118 if (include_depth >= MAX_INCLUDE_DEPTH) {
7119 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
7124 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
7125 if (!bAllowIncludeRegistry) {
7128 if (bInGlobalSection) {
7131 ret = process_registry_globals();
7135 DEBUG(1, ("\"include = registry\" only effective "
7136 "in %s section\n", GLOBAL_NAME));
7141 fname = talloc_sub_basic(talloc_tos(), get_current_username(),
7142 current_user_info.domain,
7145 add_to_file_list(pszParmValue, fname);
7147 string_set(ptr, fname);
7149 if (file_exist(fname)) {
7152 ret = pm_process(fname, do_section, do_parameter, NULL);
7158 DEBUG(2, ("Can't find include file %s\n", fname));
7163 /***************************************************************************
7164 Handle the interpretation of the copy parameter.
7165 ***************************************************************************/
7167 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7171 struct loadparm_service serviceTemp;
7173 string_set(ptr, pszParmValue);
7175 init_service(&serviceTemp);
7179 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7181 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7182 if (iTemp == iServiceIndex) {
7183 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7185 copy_service(ServicePtrs[iServiceIndex],
7187 ServicePtrs[iServiceIndex]->copymap);
7191 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7195 free_service(&serviceTemp);
7199 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7201 Globals.ldap_debug_level = lp_int(pszParmValue);
7202 init_ldap_debugging();
7206 /***************************************************************************
7207 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7212 idmap uid = 1000-1999
7215 We only do simple parsing checks here. The strings are parsed into useful
7216 structures in the idmap daemon code.
7218 ***************************************************************************/
7220 /* Some lp_ routines to return idmap [ug]id information */
7222 static uid_t idmap_uid_low, idmap_uid_high;
7223 static gid_t idmap_gid_low, idmap_gid_high;
7225 bool lp_idmap_uid(uid_t *low, uid_t *high)
7227 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7231 *low = idmap_uid_low;
7234 *high = idmap_uid_high;
7239 bool lp_idmap_gid(gid_t *low, gid_t *high)
7241 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7245 *low = idmap_gid_low;
7248 *high = idmap_gid_high;
7253 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7255 lp_do_parameter(snum, "idmap config * : backend", pszParmValue);
7260 /* Do some simple checks on "idmap [ug]id" parameter values */
7262 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7264 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7269 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7271 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7276 /***************************************************************************
7277 Handle the DEBUG level list.
7278 ***************************************************************************/
7280 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValueIn, char **ptr )
7282 string_set(ptr, pszParmValueIn);
7283 return debug_parse_levels(pszParmValueIn);
7286 /***************************************************************************
7287 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7288 ***************************************************************************/
7290 static const char *append_ldap_suffix( const char *str )
7292 const char *suffix_string;
7295 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7296 Globals.szLdapSuffix );
7297 if ( !suffix_string ) {
7298 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7302 return suffix_string;
7305 const char *lp_ldap_machine_suffix(void)
7307 if (Globals.szLdapMachineSuffix[0])
7308 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7310 return lp_string(Globals.szLdapSuffix);
7313 const char *lp_ldap_user_suffix(void)
7315 if (Globals.szLdapUserSuffix[0])
7316 return append_ldap_suffix(Globals.szLdapUserSuffix);
7318 return lp_string(Globals.szLdapSuffix);
7321 const char *lp_ldap_group_suffix(void)
7323 if (Globals.szLdapGroupSuffix[0])
7324 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7326 return lp_string(Globals.szLdapSuffix);
7329 const char *lp_ldap_idmap_suffix(void)
7331 if (Globals.szLdapIdmapSuffix[0])
7332 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7334 return lp_string(Globals.szLdapSuffix);
7337 /****************************************************************************
7338 set the value for a P_ENUM
7339 ***************************************************************************/
7341 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7346 for (i = 0; parm->enum_list[i].name; i++) {
7347 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7348 *ptr = parm->enum_list[i].value;
7352 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7353 pszParmValue, parm->label));
7356 /***************************************************************************
7357 ***************************************************************************/
7359 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7361 static int parm_num = -1;
7362 struct loadparm_service *s;
7364 if ( parm_num == -1 )
7365 parm_num = map_parameter( "printing" );
7367 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7372 s = ServicePtrs[snum];
7374 init_printer_values( s );
7380 /***************************************************************************
7381 Initialise a copymap.
7382 ***************************************************************************/
7384 static void init_copymap(struct loadparm_service *pservice)
7388 TALLOC_FREE(pservice->copymap);
7390 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
7391 if (!pservice->copymap)
7393 ("Couldn't allocate copymap!! (size %d)\n",
7394 (int)NUMPARAMETERS));
7396 for (i = 0; i < NUMPARAMETERS; i++)
7397 bitmap_set(pservice->copymap, i);
7401 return the parameter pointer for a parameter
7403 void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm)
7405 if (service == NULL) {
7406 if (parm->p_class == P_LOCAL)
7407 return (void *)(((char *)&sDefault)+parm->offset);
7408 else if (parm->p_class == P_GLOBAL)
7409 return (void *)(((char *)&Globals)+parm->offset);
7412 return (void *)(((char *)service) + parm->offset);
7416 /***************************************************************************
7417 Return the local pointer to a parameter given the service number and parameter
7418 ***************************************************************************/
7420 void *lp_local_ptr_by_snum(int snum, struct parm_struct *parm)
7422 return lp_parm_ptr(ServicePtrs[snum], parm);
7425 /***************************************************************************
7426 Process a parameter for a particular service number. If snum < 0
7427 then assume we are in the globals.
7428 ***************************************************************************/
7430 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7433 void *parm_ptr = NULL; /* where we are going to store the result */
7434 struct param_opt_struct **opt_list;
7436 parmnum = map_parameter(pszParmName);
7439 if (strchr(pszParmName, ':') == NULL) {
7440 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7446 * We've got a parametric option
7449 opt_list = (snum < 0)
7450 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7451 set_param_opt(opt_list, pszParmName, pszParmValue, 0);
7456 /* if it's already been set by the command line, then we don't
7458 if (parm_table[parmnum].flags & FLAG_CMDLINE) {
7462 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7463 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7467 /* we might point at a service, the default service or a global */
7469 parm_ptr = lp_parm_ptr(NULL, &parm_table[parmnum]);
7471 if (parm_table[parmnum].p_class == P_GLOBAL) {
7473 ("Global parameter %s found in service section!\n",
7477 parm_ptr = lp_local_ptr_by_snum(snum, &parm_table[parmnum]);
7481 if (!ServicePtrs[snum]->copymap)
7482 init_copymap(ServicePtrs[snum]);
7484 /* this handles the aliases - set the copymap for other entries with
7485 the same data pointer */
7486 for (i = 0; parm_table[i].label; i++)
7487 if (parm_table[i].offset == parm_table[parmnum].offset)
7488 bitmap_clear(ServicePtrs[snum]->copymap, i);
7491 /* if it is a special case then go ahead */
7492 if (parm_table[parmnum].special) {
7493 return parm_table[parmnum].special(NULL, snum, pszParmValue,
7497 /* now switch on the type of variable it is */
7498 switch (parm_table[parmnum].type)
7501 *(bool *)parm_ptr = lp_bool(pszParmValue);
7505 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7509 *(int *)parm_ptr = lp_int(pszParmValue);
7513 *(char *)parm_ptr = *pszParmValue;
7517 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7519 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7524 TALLOC_FREE(*((char ***)parm_ptr));
7525 *(char ***)parm_ptr = str_list_make_v3(
7526 NULL, pszParmValue, NULL);
7530 string_set((char **)parm_ptr, pszParmValue);
7535 char *upper_string = strupper_talloc(talloc_tos(),
7537 string_set((char **)parm_ptr, upper_string);
7538 TALLOC_FREE(upper_string);
7542 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7551 /***************************************************************************
7552 set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
7553 FLAG_CMDLINE won't be overridden by loads from smb.conf.
7554 ***************************************************************************/
7556 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
7559 parmnum = map_parameter(pszParmName);
7561 parm_table[parmnum].flags &= ~FLAG_CMDLINE;
7562 if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
7565 parm_table[parmnum].flags |= FLAG_CMDLINE;
7567 /* we have to also set FLAG_CMDLINE on aliases. Aliases must
7568 * be grouped in the table, so we don't have to search the
7570 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
7571 parm_table[i].flags |= FLAG_CMDLINE;
7573 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
7574 parm_table[i].flags |= FLAG_CMDLINE;
7578 store_lp_set_cmdline(pszParmName, pszParmValue);
7583 /* it might be parametric */
7584 if (strchr(pszParmName, ':') != NULL) {
7585 set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
7587 store_lp_set_cmdline(pszParmName, pszParmValue);
7592 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
7596 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
7598 return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
7601 /***************************************************************************
7602 Process a parameter.
7603 ***************************************************************************/
7605 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7608 if (!bInGlobalSection && bGlobalOnly)
7611 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7613 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7614 pszParmName, pszParmValue));
7618 set a option from the commandline in 'a=b' format. Use to support --option
7620 bool lp_set_option(const char *option)
7625 s = talloc_strdup(NULL, option);
7638 /* skip white spaces after the = sign */
7641 } while (*p == ' ');
7643 ret = lp_set_cmdline(s, p);
7648 /**************************************************************************
7649 Print a parameter of the specified type.
7650 ***************************************************************************/
7652 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7658 for (i = 0; p->enum_list[i].name; i++) {
7659 if (*(int *)ptr == p->enum_list[i].value) {
7661 p->enum_list[i].name);
7668 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7672 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7676 fprintf(f, "%d", *(int *)ptr);
7680 fprintf(f, "%c", *(char *)ptr);
7684 char *o = octal_string(*(int *)ptr);
7685 fprintf(f, "%s", o);
7691 if ((char ***)ptr && *(char ***)ptr) {
7692 char **list = *(char ***)ptr;
7693 for (; *list; list++) {
7694 /* surround strings with whitespace in double quotes */
7695 if ( strchr_m( *list, ' ' ) )
7696 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
7698 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
7705 if (*(char **)ptr) {
7706 fprintf(f, "%s", *(char **)ptr);
7714 /***************************************************************************
7715 Check if two parameters are equal.
7716 ***************************************************************************/
7718 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7723 return (*((bool *)ptr1) == *((bool *)ptr2));
7728 return (*((int *)ptr1) == *((int *)ptr2));
7731 return (*((char *)ptr1) == *((char *)ptr2));
7734 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7739 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7744 return (p1 == p2 || strequal(p1, p2));
7752 /***************************************************************************
7753 Initialize any local varients in the sDefault table.
7754 ***************************************************************************/
7756 void init_locals(void)
7761 /***************************************************************************
7762 Process a new section (service). At this stage all sections are services.
7763 Later we'll have special sections that permit server parameters to be set.
7764 Returns true on success, false on failure.
7765 ***************************************************************************/
7767 static bool do_section(const char *pszSectionName, void *userdata)
7770 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7771 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7774 /* if we were in a global section then do the local inits */
7775 if (bInGlobalSection && !isglobal)
7778 /* if we've just struck a global section, note the fact. */
7779 bInGlobalSection = isglobal;
7781 /* check for multiple global sections */
7782 if (bInGlobalSection) {
7783 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7787 if (!bInGlobalSection && bGlobalOnly)
7790 /* if we have a current service, tidy it up before moving on */
7793 if (iServiceIndex >= 0)
7794 bRetval = service_ok(iServiceIndex);
7796 /* if all is still well, move to the next record in the services array */
7798 /* We put this here to avoid an odd message order if messages are */
7799 /* issued by the post-processing of a previous section. */
7800 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7802 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
7804 DEBUG(0, ("Failed to add a new service\n"));
7807 /* Clean all parametric options for service */
7808 /* They will be added during parsing again */
7809 free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
7816 /***************************************************************************
7817 Determine if a partcular base parameter is currentl set to the default value.
7818 ***************************************************************************/
7820 static bool is_default(int i)
7822 if (!defaults_saved)
7824 switch (parm_table[i].type) {
7826 return str_list_equal((const char **)parm_table[i].def.lvalue,
7827 *(const char ***)lp_parm_ptr(NULL,
7831 return strequal(parm_table[i].def.svalue,
7832 *(char **)lp_parm_ptr(NULL,
7836 return parm_table[i].def.bvalue ==
7837 *(bool *)lp_parm_ptr(NULL,
7840 return parm_table[i].def.cvalue ==
7841 *(char *)lp_parm_ptr(NULL,
7846 return parm_table[i].def.ivalue ==
7847 *(int *)lp_parm_ptr(NULL,
7855 /***************************************************************************
7856 Display the contents of the global structure.
7857 ***************************************************************************/
7859 static void dump_globals(FILE *f)
7862 struct param_opt_struct *data;
7864 fprintf(f, "[global]\n");
7866 for (i = 0; parm_table[i].label; i++)
7867 if (parm_table[i].p_class == P_GLOBAL &&
7868 !(parm_table[i].flags & FLAG_META) &&
7869 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
7870 if (defaults_saved && is_default(i))
7872 fprintf(f, "\t%s = ", parm_table[i].label);
7873 print_parameter(&parm_table[i], lp_parm_ptr(NULL,
7878 if (Globals.param_opt != NULL) {
7879 data = Globals.param_opt;
7881 fprintf(f, "\t%s = %s\n", data->key, data->value);
7888 /***************************************************************************
7889 Return true if a local parameter is currently set to the global default.
7890 ***************************************************************************/
7892 bool lp_is_default(int snum, struct parm_struct *parm)
7894 return equal_parameter(parm->type,
7895 lp_parm_ptr(ServicePtrs[snum], parm),
7896 lp_parm_ptr(NULL, parm));
7899 /***************************************************************************
7900 Display the contents of a single services record.
7901 ***************************************************************************/
7903 static void dump_a_service(struct loadparm_service *pService, FILE * f)
7906 struct param_opt_struct *data;
7908 if (pService != &sDefault)
7909 fprintf(f, "[%s]\n", pService->szService);
7911 for (i = 0; parm_table[i].label; i++) {
7913 if (parm_table[i].p_class == P_LOCAL &&
7914 !(parm_table[i].flags & FLAG_META) &&
7915 (*parm_table[i].label != '-') &&
7916 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7918 if (pService == &sDefault) {
7919 if (defaults_saved && is_default(i))
7922 if (equal_parameter(parm_table[i].type,
7923 lp_parm_ptr(pService, &parm_table[i]),
7924 lp_parm_ptr(NULL, &parm_table[i])))
7928 fprintf(f, "\t%s = ", parm_table[i].label);
7929 print_parameter(&parm_table[i],
7930 lp_parm_ptr(pService, &parm_table[i]),
7936 if (pService->param_opt != NULL) {
7937 data = pService->param_opt;
7939 fprintf(f, "\t%s = %s\n", data->key, data->value);
7945 /***************************************************************************
7946 Display the contents of a parameter of a single services record.
7947 ***************************************************************************/
7949 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7952 bool result = false;
7955 fstring local_parm_name;
7957 const char *parm_opt_value;
7959 /* check for parametrical option */
7960 fstrcpy( local_parm_name, parm_name);
7961 parm_opt = strchr( local_parm_name, ':');
7966 if (strlen(parm_opt)) {
7967 parm_opt_value = lp_parm_const_string( snum,
7968 local_parm_name, parm_opt, NULL);
7969 if (parm_opt_value) {
7970 printf( "%s\n", parm_opt_value);
7977 /* check for a key and print the value */
7984 for (i = 0; parm_table[i].label; i++) {
7985 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7986 !(parm_table[i].flags & FLAG_META) &&
7987 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7988 (*parm_table[i].label != '-') &&
7989 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7994 ptr = lp_parm_ptr(NULL,
7997 ptr = lp_parm_ptr(ServicePtrs[snum],
8001 print_parameter(&parm_table[i],
8012 /***************************************************************************
8013 Return info about the requested parameter (given as a string).
8014 Return NULL when the string is not a valid parameter name.
8015 ***************************************************************************/
8017 struct parm_struct *lp_get_parameter(const char *param_name)
8019 int num = map_parameter(param_name);
8025 return &parm_table[num];
8028 /***************************************************************************
8029 Return info about the next parameter in a service.
8030 snum==GLOBAL_SECTION_SNUM gives the globals.
8031 Return NULL when out of parameters.
8032 ***************************************************************************/
8034 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
8037 /* do the globals */
8038 for (; parm_table[*i].label; (*i)++) {
8039 if (parm_table[*i].p_class == P_SEPARATOR)
8040 return &parm_table[(*i)++];
8042 if ((*parm_table[*i].label == '-'))
8046 && (parm_table[*i].offset ==
8047 parm_table[(*i) - 1].offset))
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)
8236 switch (parm_table[i].type) {
8238 parm_table[i].def.lvalue = str_list_copy(
8239 NULL, *(const char ***)lp_parm_ptr(NULL, &parm_table[i]));
8243 parm_table[i].def.svalue = SMB_STRDUP(*(char **)lp_parm_ptr(NULL, &parm_table[i]));
8247 parm_table[i].def.bvalue =
8248 *(bool *)lp_parm_ptr(NULL, &parm_table[i]);
8251 parm_table[i].def.cvalue =
8252 *(char *)lp_parm_ptr(NULL, &parm_table[i]);
8257 parm_table[i].def.ivalue =
8258 *(int *)lp_parm_ptr(NULL, &parm_table[i]);
8264 defaults_saved = true;
8267 /***********************************************************
8268 If we should send plaintext/LANMAN passwords in the clinet
8269 ************************************************************/
8271 static void set_allowed_client_auth(void)
8273 if (Globals.bClientNTLMv2Auth) {
8274 Globals.bClientLanManAuth = false;
8276 if (!Globals.bClientLanManAuth) {
8277 Globals.bClientPlaintextAuth = false;
8281 /***************************************************************************
8283 The following code allows smbd to read a user defined share file.
8284 Yes, this is my intent. Yes, I'm comfortable with that...
8286 THE FOLLOWING IS SECURITY CRITICAL CODE.
8288 It washes your clothes, it cleans your house, it guards you while you sleep...
8289 Do not f%^k with it....
8290 ***************************************************************************/
8292 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8294 /***************************************************************************
8295 Check allowed stat state of a usershare file.
8296 Ensure we print out who is dicking with us so the admin can
8297 get their sorry ass fired.
8298 ***************************************************************************/
8300 static bool check_usershare_stat(const char *fname,
8301 const SMB_STRUCT_STAT *psbuf)
8303 if (!S_ISREG(psbuf->st_ex_mode)) {
8304 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8305 "not a regular file\n",
8306 fname, (unsigned int)psbuf->st_ex_uid ));
8310 /* Ensure this doesn't have the other write bit set. */
8311 if (psbuf->st_ex_mode & S_IWOTH) {
8312 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8313 "public write. Refusing to allow as a usershare file.\n",
8314 fname, (unsigned int)psbuf->st_ex_uid ));
8318 /* Should be 10k or less. */
8319 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8320 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8321 "too large (%u) to be a user share file.\n",
8322 fname, (unsigned int)psbuf->st_ex_uid,
8323 (unsigned int)psbuf->st_ex_size ));
8330 /***************************************************************************
8331 Parse the contents of a usershare file.
8332 ***************************************************************************/
8334 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8335 SMB_STRUCT_STAT *psbuf,
8336 const char *servicename,
8340 char **pp_sharepath,
8342 char **pp_cp_servicename,
8343 struct security_descriptor **ppsd,
8346 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8347 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8350 SMB_STRUCT_STAT sbuf;
8351 char *sharepath = NULL;
8352 char *comment = NULL;
8354 *pp_sharepath = NULL;
8357 *pallow_guest = false;
8360 return USERSHARE_MALFORMED_FILE;
8363 if (strcmp(lines[0], "#VERSION 1") == 0) {
8365 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8368 return USERSHARE_MALFORMED_FILE;
8371 return USERSHARE_BAD_VERSION;
8374 if (strncmp(lines[1], "path=", 5) != 0) {
8375 return USERSHARE_MALFORMED_PATH;
8378 sharepath = talloc_strdup(ctx, &lines[1][5]);
8380 return USERSHARE_POSIX_ERR;
8382 trim_string(sharepath, " ", " ");
8384 if (strncmp(lines[2], "comment=", 8) != 0) {
8385 return USERSHARE_MALFORMED_COMMENT_DEF;
8388 comment = talloc_strdup(ctx, &lines[2][8]);
8390 return USERSHARE_POSIX_ERR;
8392 trim_string(comment, " ", " ");
8393 trim_char(comment, '"', '"');
8395 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8396 return USERSHARE_MALFORMED_ACL_DEF;
8399 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8400 return USERSHARE_ACL_ERR;
8404 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8405 return USERSHARE_MALFORMED_ACL_DEF;
8407 if (lines[4][9] == 'y') {
8408 *pallow_guest = true;
8411 /* Backwards compatible extension to file version #2. */
8413 if (strncmp(lines[5], "sharename=", 10) != 0) {
8414 return USERSHARE_MALFORMED_SHARENAME_DEF;
8416 if (!strequal(&lines[5][10], servicename)) {
8417 return USERSHARE_BAD_SHARENAME;
8419 *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
8420 if (!*pp_cp_servicename) {
8421 return USERSHARE_POSIX_ERR;
8426 if (*pp_cp_servicename == NULL) {
8427 *pp_cp_servicename = talloc_strdup(ctx, servicename);
8428 if (!*pp_cp_servicename) {
8429 return USERSHARE_POSIX_ERR;
8433 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8434 /* Path didn't change, no checks needed. */
8435 *pp_sharepath = sharepath;
8436 *pp_comment = comment;
8437 return USERSHARE_OK;
8440 /* The path *must* be absolute. */
8441 if (sharepath[0] != '/') {
8442 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8443 servicename, sharepath));
8444 return USERSHARE_PATH_NOT_ABSOLUTE;
8447 /* If there is a usershare prefix deny list ensure one of these paths
8448 doesn't match the start of the user given path. */
8449 if (prefixdenylist) {
8451 for ( i=0; prefixdenylist[i]; i++ ) {
8452 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8453 servicename, i, prefixdenylist[i], sharepath ));
8454 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8455 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8456 "usershare prefix deny list entries.\n",
8457 servicename, sharepath));
8458 return USERSHARE_PATH_IS_DENIED;
8463 /* If there is a usershare prefix allow list ensure one of these paths
8464 does match the start of the user given path. */
8466 if (prefixallowlist) {
8468 for ( i=0; prefixallowlist[i]; i++ ) {
8469 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8470 servicename, i, prefixallowlist[i], sharepath ));
8471 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8475 if (prefixallowlist[i] == NULL) {
8476 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8477 "usershare prefix allow list entries.\n",
8478 servicename, sharepath));
8479 return USERSHARE_PATH_NOT_ALLOWED;
8483 /* Ensure this is pointing to a directory. */
8484 dp = sys_opendir(sharepath);
8487 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8488 servicename, sharepath));
8489 return USERSHARE_PATH_NOT_DIRECTORY;
8492 /* Ensure the owner of the usershare file has permission to share
8495 if (sys_stat(sharepath, &sbuf, false) == -1) {
8496 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8497 servicename, sharepath, strerror(errno) ));
8499 return USERSHARE_POSIX_ERR;
8504 if (!S_ISDIR(sbuf.st_ex_mode)) {
8505 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8506 servicename, sharepath ));
8507 return USERSHARE_PATH_NOT_DIRECTORY;
8510 /* Check if sharing is restricted to owner-only. */
8511 /* psbuf is the stat of the usershare definition file,
8512 sbuf is the stat of the target directory to be shared. */
8514 if (lp_usershare_owner_only()) {
8515 /* root can share anything. */
8516 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8517 return USERSHARE_PATH_NOT_ALLOWED;
8521 *pp_sharepath = sharepath;
8522 *pp_comment = comment;
8523 return USERSHARE_OK;
8526 /***************************************************************************
8527 Deal with a usershare file.
8530 -1 - Bad name, invalid contents.
8531 - service name already existed and not a usershare, problem
8532 with permissions to share directory etc.
8533 ***************************************************************************/
8535 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8537 SMB_STRUCT_STAT sbuf;
8538 SMB_STRUCT_STAT lsbuf;
8540 char *sharepath = NULL;
8541 char *comment = NULL;
8542 char *cp_service_name = NULL;
8543 char **lines = NULL;
8547 TALLOC_CTX *ctx = talloc_stackframe();
8548 struct security_descriptor *psd = NULL;
8549 bool guest_ok = false;
8550 char *canon_name = NULL;
8551 bool added_service = false;
8554 /* Ensure share name doesn't contain invalid characters. */
8555 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8556 DEBUG(0,("process_usershare_file: share name %s contains "
8557 "invalid characters (any of %s)\n",
8558 file_name, INVALID_SHARENAME_CHARS ));
8562 canon_name = canonicalize_servicename(ctx, file_name);
8567 fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
8572 /* Minimize the race condition by doing an lstat before we
8573 open and fstat. Ensure this isn't a symlink link. */
8575 if (sys_lstat(fname, &lsbuf, false) != 0) {
8576 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8577 fname, strerror(errno) ));
8581 /* This must be a regular file, not a symlink, directory or
8582 other strange filetype. */
8583 if (!check_usershare_stat(fname, &lsbuf)) {
8588 TDB_DATA data = dbwrap_fetch_bystring(
8589 ServiceHash, canon_name, canon_name);
8593 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
8594 iService = *(int *)data.dptr;
8598 if (iService != -1 &&
8599 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8600 &lsbuf.st_ex_mtime) == 0) {
8601 /* Nothing changed - Mark valid and return. */
8602 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8604 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8609 /* Try and open the file read only - no symlinks allowed. */
8611 fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8613 fd = sys_open(fname, O_RDONLY, 0);
8617 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8618 fname, strerror(errno) ));
8622 /* Now fstat to be *SURE* it's a regular file. */
8623 if (sys_fstat(fd, &sbuf, false) != 0) {
8625 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8626 fname, strerror(errno) ));
8630 /* Is it the same dev/inode as was lstated ? */
8631 if (lsbuf.st_ex_dev != sbuf.st_ex_dev || lsbuf.st_ex_ino != sbuf.st_ex_ino) {
8633 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8634 "Symlink spoofing going on ?\n", fname ));
8638 /* This must be a regular file, not a symlink, directory or
8639 other strange filetype. */
8640 if (!check_usershare_stat(fname, &sbuf)) {
8644 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8647 if (lines == NULL) {
8648 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8649 fname, (unsigned int)sbuf.st_ex_uid ));
8653 if (parse_usershare_file(ctx, &sbuf, file_name,
8654 iService, lines, numlines, &sharepath,
8655 &comment, &cp_service_name,
8656 &psd, &guest_ok) != USERSHARE_OK) {
8660 /* Everything ok - add the service possibly using a template. */
8662 const struct loadparm_service *sp = &sDefault;
8663 if (snum_template != -1) {
8664 sp = ServicePtrs[snum_template];
8667 if ((iService = add_a_service(sp, cp_service_name)) < 0) {
8668 DEBUG(0, ("process_usershare_file: Failed to add "
8669 "new service %s\n", cp_service_name));
8673 added_service = true;
8675 /* Read only is controlled by usershare ACL below. */
8676 ServicePtrs[iService]->bRead_only = false;
8679 /* Write the ACL of the new/modified share. */
8680 if (!set_share_security(canon_name, psd)) {
8681 DEBUG(0, ("process_usershare_file: Failed to set share "
8682 "security for user share %s\n",
8687 /* If from a template it may be marked invalid. */
8688 ServicePtrs[iService]->valid = true;
8690 /* Set the service as a valid usershare. */
8691 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8693 /* Set guest access. */
8694 if (lp_usershare_allow_guests()) {
8695 ServicePtrs[iService]->bGuest_ok = guest_ok;
8698 /* And note when it was loaded. */
8699 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8700 string_set(&ServicePtrs[iService]->szPath, sharepath);
8701 string_set(&ServicePtrs[iService]->comment, comment);
8707 if (ret == -1 && iService != -1 && added_service) {
8708 lp_remove_service(iService);
8716 /***************************************************************************
8717 Checks if a usershare entry has been modified since last load.
8718 ***************************************************************************/
8720 static bool usershare_exists(int iService, struct timespec *last_mod)
8722 SMB_STRUCT_STAT lsbuf;
8723 const char *usersharepath = Globals.szUsersharePath;
8726 if (asprintf(&fname, "%s/%s",
8728 ServicePtrs[iService]->szService) < 0) {
8732 if (sys_lstat(fname, &lsbuf, false) != 0) {
8737 if (!S_ISREG(lsbuf.st_ex_mode)) {
8743 *last_mod = lsbuf.st_ex_mtime;
8747 /***************************************************************************
8748 Load a usershare service by name. Returns a valid servicenumber or -1.
8749 ***************************************************************************/
8751 int load_usershare_service(const char *servicename)
8753 SMB_STRUCT_STAT sbuf;
8754 const char *usersharepath = Globals.szUsersharePath;
8755 int max_user_shares = Globals.iUsershareMaxShares;
8756 int snum_template = -1;
8758 if (*usersharepath == 0 || max_user_shares == 0) {
8762 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8763 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8764 usersharepath, strerror(errno) ));
8768 if (!S_ISDIR(sbuf.st_ex_mode)) {
8769 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8775 * This directory must be owned by root, and have the 't' bit set.
8776 * It also must not be writable by "other".
8780 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8782 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8784 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8785 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8790 /* Ensure the template share exists if it's set. */
8791 if (Globals.szUsershareTemplateShare[0]) {
8792 /* We can't use lp_servicenumber here as we are recommending that
8793 template shares have -valid=false set. */
8794 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8795 if (ServicePtrs[snum_template]->szService &&
8796 strequal(ServicePtrs[snum_template]->szService,
8797 Globals.szUsershareTemplateShare)) {
8802 if (snum_template == -1) {
8803 DEBUG(0,("load_usershare_service: usershare template share %s "
8804 "does not exist.\n",
8805 Globals.szUsershareTemplateShare ));
8810 return process_usershare_file(usersharepath, servicename, snum_template);
8813 /***************************************************************************
8814 Load all user defined shares from the user share directory.
8815 We only do this if we're enumerating the share list.
8816 This is the function that can delete usershares that have
8818 ***************************************************************************/
8820 int load_usershare_shares(struct smbd_server_connection *sconn)
8823 SMB_STRUCT_STAT sbuf;
8824 SMB_STRUCT_DIRENT *de;
8825 int num_usershares = 0;
8826 int max_user_shares = Globals.iUsershareMaxShares;
8827 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8828 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8829 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8831 int snum_template = -1;
8832 const char *usersharepath = Globals.szUsersharePath;
8833 int ret = lp_numservices();
8835 if (max_user_shares == 0 || *usersharepath == '\0') {
8836 return lp_numservices();
8839 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8840 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8841 usersharepath, strerror(errno) ));
8846 * This directory must be owned by root, and have the 't' bit set.
8847 * It also must not be writable by "other".
8851 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8853 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8855 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8856 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8861 /* Ensure the template share exists if it's set. */
8862 if (Globals.szUsershareTemplateShare[0]) {
8863 /* We can't use lp_servicenumber here as we are recommending that
8864 template shares have -valid=false set. */
8865 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8866 if (ServicePtrs[snum_template]->szService &&
8867 strequal(ServicePtrs[snum_template]->szService,
8868 Globals.szUsershareTemplateShare)) {
8873 if (snum_template == -1) {
8874 DEBUG(0,("load_usershare_shares: usershare template share %s "
8875 "does not exist.\n",
8876 Globals.szUsershareTemplateShare ));
8881 /* Mark all existing usershares as pending delete. */
8882 for (iService = iNumServices - 1; iService >= 0; iService--) {
8883 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8884 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8888 dp = sys_opendir(usersharepath);
8890 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8891 usersharepath, strerror(errno) ));
8895 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8896 (de = sys_readdir(dp));
8897 num_dir_entries++ ) {
8899 const char *n = de->d_name;
8901 /* Ignore . and .. */
8903 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8909 /* Temporary file used when creating a share. */
8910 num_tmp_dir_entries++;
8913 /* Allow 20% tmp entries. */
8914 if (num_tmp_dir_entries > allowed_tmp_entries) {
8915 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8916 "in directory %s\n",
8917 num_tmp_dir_entries, usersharepath));
8921 r = process_usershare_file(usersharepath, n, snum_template);
8923 /* Update the services count. */
8925 if (num_usershares >= max_user_shares) {
8926 DEBUG(0,("load_usershare_shares: max user shares reached "
8927 "on file %s in directory %s\n",
8928 n, usersharepath ));
8931 } else if (r == -1) {
8932 num_bad_dir_entries++;
8935 /* Allow 20% bad entries. */
8936 if (num_bad_dir_entries > allowed_bad_entries) {
8937 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8938 "in directory %s\n",
8939 num_bad_dir_entries, usersharepath));
8943 /* Allow 20% bad entries. */
8944 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
8945 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8946 "in directory %s\n",
8947 num_dir_entries, usersharepath));
8954 /* Sweep through and delete any non-refreshed usershares that are
8955 not currently in use. */
8956 for (iService = iNumServices - 1; iService >= 0; iService--) {
8957 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
8958 if (conn_snum_used(sconn, iService)) {
8961 /* Remove from the share ACL db. */
8962 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8963 lp_servicename(iService) ));
8964 delete_share_security(lp_servicename(iService));
8965 free_service_byindex(iService);
8969 return lp_numservices();
8972 /********************************************************
8973 Destroy global resources allocated in this file
8974 ********************************************************/
8976 void gfree_loadparm(void)
8982 /* Free resources allocated to services */
8984 for ( i = 0; i < iNumServices; i++ ) {
8986 free_service_byindex(i);
8990 SAFE_FREE( ServicePtrs );
8993 /* Now release all resources allocated to global
8994 parameters and the default service */
8996 free_global_parameters();
9000 /***************************************************************************
9001 Allow client apps to specify that they are a client
9002 ***************************************************************************/
9003 void lp_set_in_client(bool b)
9009 /***************************************************************************
9010 Determine if we're running in a client app
9011 ***************************************************************************/
9012 bool lp_is_in_client(void)
9017 /***************************************************************************
9018 Load the services array from the services file. Return true on success,
9020 ***************************************************************************/
9022 static bool lp_load_ex(const char *pszFname,
9026 bool initialize_globals,
9027 bool allow_include_registry,
9028 bool allow_registry_shares)
9035 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
9037 bInGlobalSection = true;
9038 bGlobalOnly = global_only;
9039 bAllowIncludeRegistry = allow_include_registry;
9041 init_globals(initialize_globals);
9045 if (save_defaults) {
9050 free_param_opts(&Globals.param_opt);
9052 lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
9054 /* We get sections first, so have to start 'behind' to make up */
9057 if (lp_config_backend_is_file()) {
9058 n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
9059 current_user_info.domain,
9062 smb_panic("lp_load_ex: out of memory");
9065 add_to_file_list(pszFname, n2);
9067 bRetval = pm_process(n2, do_section, do_parameter, NULL);
9070 /* finish up the last section */
9071 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
9073 if (iServiceIndex >= 0) {
9074 bRetval = service_ok(iServiceIndex);
9078 if (lp_config_backend_is_registry()) {
9079 /* config backend changed to registry in config file */
9081 * We need to use this extra global variable here to
9082 * survive restart: init_globals uses this as a default
9083 * for ConfigBackend. Otherwise, init_globals would
9084 * send us into an endless loop here.
9086 config_backend = CONFIG_BACKEND_REGISTRY;
9088 DEBUG(1, ("lp_load_ex: changing to config backend "
9091 lp_kill_all_services();
9092 return lp_load_ex(pszFname, global_only, save_defaults,
9093 add_ipc, initialize_globals,
9094 allow_include_registry,
9095 allow_registry_shares);
9097 } else if (lp_config_backend_is_registry()) {
9098 bRetval = process_registry_globals();
9100 DEBUG(0, ("Illegal config backend given: %d\n",
9101 lp_config_backend()));
9105 if (bRetval && lp_registry_shares() && allow_registry_shares) {
9106 bRetval = process_registry_shares();
9109 lp_add_auto_services(lp_auto_services());
9112 /* When 'restrict anonymous = 2' guest connections to ipc$
9114 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9115 if ( lp_enable_asu_support() ) {
9116 lp_add_ipc("ADMIN$", false);
9121 set_allowed_client_auth();
9123 if (lp_security() == SEC_SHARE) {
9124 DEBUG(1, ("WARNING: The security=share option is deprecated\n"));
9125 } else if (lp_security() == SEC_SERVER) {
9126 DEBUG(1, ("WARNING: The security=server option is deprecated\n"));
9129 if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) {
9130 DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
9131 lp_passwordserver()));
9136 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9137 /* if bWINSsupport is true and we are in the client */
9138 if (lp_is_in_client() && Globals.bWINSsupport) {
9139 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9144 fault_configure(smb_panic_s3);
9146 bAllowIncludeRegistry = true;
9151 bool lp_load(const char *pszFname,
9155 bool initialize_globals)
9157 return lp_load_ex(pszFname,
9162 true, /* allow_include_registry */
9163 false); /* allow_registry_shares*/
9166 bool lp_load_initial_only(const char *pszFname)
9168 return lp_load_ex(pszFname,
9169 true, /* global only */
9170 false, /* save_defaults */
9171 false, /* add_ipc */
9172 true, /* initialize_globals */
9173 false, /* allow_include_registry */
9174 false); /* allow_registry_shares*/
9177 bool lp_load_with_registry_shares(const char *pszFname,
9181 bool initialize_globals)
9183 return lp_load_ex(pszFname,
9188 true, /* allow_include_registry */
9189 true); /* allow_registry_shares*/
9192 /***************************************************************************
9193 Return the max number of services.
9194 ***************************************************************************/
9196 int lp_numservices(void)
9198 return (iNumServices);
9201 /***************************************************************************
9202 Display the contents of the services array in human-readable form.
9203 ***************************************************************************/
9205 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9210 defaults_saved = false;
9214 dump_a_service(&sDefault, f);
9216 for (iService = 0; iService < maxtoprint; iService++) {
9218 lp_dump_one(f, show_defaults, iService);
9222 /***************************************************************************
9223 Display the contents of one service in human-readable form.
9224 ***************************************************************************/
9226 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9229 if (ServicePtrs[snum]->szService[0] == '\0')
9231 dump_a_service(ServicePtrs[snum], f);
9235 /***************************************************************************
9236 Return the number of the service with the given name, or -1 if it doesn't
9237 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9238 getservicebyname()! This works ONLY if all services have been loaded, and
9239 does not copy the found service.
9240 ***************************************************************************/
9242 int lp_servicenumber(const char *pszServiceName)
9245 fstring serviceName;
9247 if (!pszServiceName) {
9248 return GLOBAL_SECTION_SNUM;
9251 for (iService = iNumServices - 1; iService >= 0; iService--) {
9252 if (VALID(iService) && ServicePtrs[iService]->szService) {
9254 * The substitution here is used to support %U is
9257 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9258 standard_sub_basic(get_current_username(),
9259 current_user_info.domain,
9260 serviceName,sizeof(serviceName));
9261 if (strequal(serviceName, pszServiceName)) {
9267 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9268 struct timespec last_mod;
9270 if (!usershare_exists(iService, &last_mod)) {
9271 /* Remove the share security tdb entry for it. */
9272 delete_share_security(lp_servicename(iService));
9273 /* Remove it from the array. */
9274 free_service_byindex(iService);
9275 /* Doesn't exist anymore. */
9276 return GLOBAL_SECTION_SNUM;
9279 /* Has it been modified ? If so delete and reload. */
9280 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9282 /* Remove it from the array. */
9283 free_service_byindex(iService);
9284 /* and now reload it. */
9285 iService = load_usershare_service(pszServiceName);
9290 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9291 return GLOBAL_SECTION_SNUM;
9297 bool share_defined(const char *service_name)
9299 return (lp_servicenumber(service_name) != -1);
9302 /*******************************************************************
9303 A useful volume label function.
9304 ********************************************************************/
9306 const char *volume_label(int snum)
9309 const char *label = lp_volume(snum);
9311 label = lp_servicename(snum);
9314 /* This returns a 33 byte guarenteed null terminated string. */
9315 ret = talloc_strndup(talloc_tos(), label, 32);
9322 /*******************************************************************
9323 Get the default server type we will announce as via nmbd.
9324 ********************************************************************/
9326 int lp_default_server_announce(void)
9328 int default_server_announce = 0;
9329 default_server_announce |= SV_TYPE_WORKSTATION;
9330 default_server_announce |= SV_TYPE_SERVER;
9331 default_server_announce |= SV_TYPE_SERVER_UNIX;
9333 /* note that the flag should be set only if we have a
9334 printer service but nmbd doesn't actually load the
9335 services so we can't tell --jerry */
9337 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9339 default_server_announce |= SV_TYPE_SERVER_NT;
9340 default_server_announce |= SV_TYPE_NT;
9342 switch (lp_server_role()) {
9343 case ROLE_DOMAIN_MEMBER:
9344 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9346 case ROLE_DOMAIN_PDC:
9347 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9349 case ROLE_DOMAIN_BDC:
9350 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9352 case ROLE_STANDALONE:
9356 if (lp_time_server())
9357 default_server_announce |= SV_TYPE_TIME_SOURCE;
9359 if (lp_host_msdfs())
9360 default_server_announce |= SV_TYPE_DFS_SERVER;
9362 return default_server_announce;
9365 /***********************************************************
9366 If we are PDC then prefer us as DMB
9367 ************************************************************/
9369 bool lp_domain_master(void)
9371 if (Globals.iDomainMaster == Auto)
9372 return (lp_server_role() == ROLE_DOMAIN_PDC);
9374 return (bool)Globals.iDomainMaster;
9377 /***********************************************************
9378 If we are PDC then prefer us as DMB
9379 ************************************************************/
9381 bool lp_domain_master_true_or_auto(void)
9383 if (Globals.iDomainMaster) /* auto or yes */
9389 /***********************************************************
9390 If we are DMB then prefer us as LMB
9391 ************************************************************/
9393 bool lp_preferred_master(void)
9395 if (Globals.iPreferredMaster == Auto)
9396 return (lp_local_master() && lp_domain_master());
9398 return (bool)Globals.iPreferredMaster;
9401 /*******************************************************************
9403 ********************************************************************/
9405 void lp_remove_service(int snum)
9407 ServicePtrs[snum]->valid = false;
9408 invalid_services[num_invalid_services++] = snum;
9411 /*******************************************************************
9413 ********************************************************************/
9415 void lp_copy_service(int snum, const char *new_name)
9417 do_section(new_name, NULL);
9419 snum = lp_servicenumber(new_name);
9421 lp_do_parameter(snum, "copy", lp_servicename(snum));
9426 /***********************************************************
9427 Set the global name resolution order (used in smbclient).
9428 ************************************************************/
9430 void lp_set_name_resolve_order(const char *new_order)
9432 string_set(&Globals.szNameResolveOrder, new_order);
9435 const char *lp_printername(int snum)
9437 const char *ret = _lp_printername(snum);
9438 if (ret == NULL || (ret != NULL && *ret == '\0'))
9439 ret = lp_const_servicename(snum);
9445 /***********************************************************
9446 Allow daemons such as winbindd to fix their logfile name.
9447 ************************************************************/
9449 void lp_set_logfile(const char *name)
9451 string_set(&Globals.szLogFile, name);
9452 debug_set_logfile(name);
9455 /*******************************************************************
9456 Return the max print jobs per queue.
9457 ********************************************************************/
9459 int lp_maxprintjobs(int snum)
9461 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9462 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9463 maxjobs = PRINT_MAX_JOBID - 1;
9468 const char *lp_printcapname(void)
9470 if ((Globals.szPrintcapname != NULL) &&
9471 (Globals.szPrintcapname[0] != '\0'))
9472 return Globals.szPrintcapname;
9474 if (sDefault.iPrinting == PRINT_CUPS) {
9482 if (sDefault.iPrinting == PRINT_BSD)
9483 return "/etc/printcap";
9485 return PRINTCAP_NAME;
9488 static uint32 spoolss_state;
9490 bool lp_disable_spoolss( void )
9492 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9493 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9495 return spoolss_state == SVCCTL_STOPPED ? true : false;
9498 void lp_set_spoolss_state( uint32 state )
9500 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9502 spoolss_state = state;
9505 uint32 lp_get_spoolss_state( void )
9507 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9510 /*******************************************************************
9511 Ensure we don't use sendfile if server smb signing is active.
9512 ********************************************************************/
9514 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9516 bool sign_active = false;
9518 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9519 if (get_Protocol() < PROTOCOL_NT1) {
9522 if (signing_state) {
9523 sign_active = smb_signing_is_active(signing_state);
9525 return (_lp_use_sendfile(snum) &&
9526 (get_remote_arch() != RA_WIN95) &&
9530 /*******************************************************************
9531 Turn off sendfile if we find the underlying OS doesn't support it.
9532 ********************************************************************/
9534 void set_use_sendfile(int snum, bool val)
9536 if (LP_SNUM_OK(snum))
9537 ServicePtrs[snum]->bUseSendfile = val;
9539 sDefault.bUseSendfile = val;
9542 /*******************************************************************
9543 Turn off storing DOS attributes if this share doesn't support it.
9544 ********************************************************************/
9546 void set_store_dos_attributes(int snum, bool val)
9548 if (!LP_SNUM_OK(snum))
9550 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9553 void lp_set_mangling_method(const char *new_method)
9555 string_set(&Globals.szManglingMethod, new_method);
9558 /*******************************************************************
9559 Global state for POSIX pathname processing.
9560 ********************************************************************/
9562 static bool posix_pathnames;
9564 bool lp_posix_pathnames(void)
9566 return posix_pathnames;
9569 /*******************************************************************
9570 Change everything needed to ensure POSIX pathname processing (currently
9572 ********************************************************************/
9574 void lp_set_posix_pathnames(void)
9576 posix_pathnames = true;
9579 /*******************************************************************
9580 Global state for POSIX lock processing - CIFS unix extensions.
9581 ********************************************************************/
9583 bool posix_default_lock_was_set;
9584 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9586 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9588 if (posix_default_lock_was_set) {
9589 return posix_cifsx_locktype;
9591 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9595 /*******************************************************************
9596 ********************************************************************/
9598 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9600 posix_default_lock_was_set = true;
9601 posix_cifsx_locktype = val;
9604 int lp_min_receive_file_size(void)
9606 if (Globals.iminreceivefile < 0) {
9609 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9612 /*******************************************************************
9613 If socket address is an empty character string, it is necessary to
9614 define it as "0.0.0.0".
9615 ********************************************************************/
9617 const char *lp_socket_address(void)
9619 char *sock_addr = Globals.szSocketAddress;
9621 if (sock_addr[0] == '\0'){
9622 string_set(&Globals.szSocketAddress, "0.0.0.0");
9624 return Globals.szSocketAddress;
9627 /*******************************************************************
9628 Safe wide links checks.
9629 This helper function always verify the validity of wide links,
9630 even after a configuration file reload.
9631 ********************************************************************/
9633 static bool lp_widelinks_internal(int snum)
9635 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9636 sDefault.bWidelinks);
9639 void widelinks_warning(int snum)
9641 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9642 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9643 "These parameters are incompatible. "
9644 "Wide links will be disabled for this share.\n",
9645 lp_servicename(snum) ));
9649 bool lp_widelinks(int snum)
9651 /* wide links is always incompatible with unix extensions */
9652 if (lp_unix_extensions()) {
9656 return lp_widelinks_internal(snum);
9659 bool lp_writeraw(void)
9661 if (lp_async_smb_echo_handler()) {
9664 return _lp_writeraw();
9667 bool lp_readraw(void)
9669 if (lp_async_smb_echo_handler()) {
9672 return _lp_readraw();