2 Unix SMB/CIFS implementation.
3 Parameter loading functions
4 Copyright (C) Karl Auer 1993-1998
6 Largely re-written by Andrew Tridgell, September 1994
8 Copyright (C) Simo Sorce 2001
9 Copyright (C) Alexander Bokovoy 2002
10 Copyright (C) Stefan (metze) Metzmacher 2002
11 Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
12 Copyright (C) Michael Adam 2008
13 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
14 Copyright (C) Andrew Bartlett 2011
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 3 of the License, or
19 (at your option) any later version.
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program. If not, see <http://www.gnu.org/licenses/>.
33 * This module provides suitable callback functions for the params
34 * module. It builds the internal table of service details which is
35 * then used by the rest of the server.
39 * 1) add it to the global or service structure definition
40 * 2) add it to the parm_table
41 * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
42 * 4) If it's a global then initialise it in init_globals. If a local
43 * (ie. service) parameter then initialise it in the sDefault structure
47 * The configuration file is processed sequentially for speed. It is NOT
48 * accessed randomly as happens in 'real' Windows. For this reason, there
49 * is a fair bit of sequence-dependent code here - ie., code which assumes
50 * that certain things happen before others. In particular, the code which
51 * happens at the boundary between sections is delicately poised, so be
57 #include "system/filesys.h"
60 #include "lib/smbconf/smbconf.h"
61 #include "lib/smbconf/smbconf_init.h"
62 #include "lib/param/loadparm.h"
65 #include "../librpc/gen_ndr/svcctl.h"
67 #include "smb_signing.h"
70 #include "../lib/util/bitmap.h"
72 #ifdef HAVE_SYS_SYSCTL_H
73 #include <sys/sysctl.h>
76 #ifdef HAVE_HTTPCONNECTENCRYPT
77 #include <cups/http.h>
82 extern userdom_struct current_user_info;
84 /* the special value for the include parameter
85 * to be interpreted not as a file name but to
86 * trigger loading of the global smb.conf options
88 #ifndef INCLUDE_REGISTRY_NAME
89 #define INCLUDE_REGISTRY_NAME "registry"
92 static bool in_client = false; /* Not in the client by default */
93 static struct smbconf_csn conf_last_csn;
95 #define CONFIG_BACKEND_FILE 0
96 #define CONFIG_BACKEND_REGISTRY 1
98 static int config_backend = CONFIG_BACKEND_FILE;
100 /* some helpful bits */
101 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
102 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
104 #define USERSHARE_VALID 1
105 #define USERSHARE_PENDING_DELETE 2
107 static bool defaults_saved = false;
109 #define LOADPARM_EXTRA_GLOBALS \
110 struct parmlist_entry *param_opt; \
113 int iminreceivefile; \
114 char *szPrintcapname; \
116 int iPreferredMaster; \
118 char *szLdapMachineSuffix; \
119 char *szLdapUserSuffix; \
120 char *szLdapIdmapSuffix; \
121 char *szLdapGroupSuffix; \
124 char *szSocketAddress; \
125 char *szUsershareTemplateShare; \
128 int winbindMaxDomainConnections; \
129 int ismb2_max_credits;
131 #include "param/param_global.h"
133 static struct loadparm_global Globals;
135 /* This is a default service used to prime a services structure */
136 static struct loadparm_service sDefault =
141 .usershare_last_mod = {0, 0},
145 .szInvalidUsers = NULL,
146 .szValidUsers = NULL,
147 .szAdminUsers = NULL,
152 .szRootPreExec = NULL,
153 .szRootPostExec = NULL,
154 .szCupsOptions = NULL,
155 .szPrintcommand = NULL,
156 .szLpqcommand = NULL,
157 .szLprmcommand = NULL,
158 .szLppausecommand = NULL,
159 .szLpresumecommand = NULL,
160 .szQueuepausecommand = NULL,
161 .szQueueresumecommand = NULL,
162 .szPrintername = NULL,
163 .szPrintjobUsername = NULL,
164 .szDontdescend = NULL,
165 .szHostsallow = NULL,
167 .szMagicScript = NULL,
168 .szMagicOutput = NULL,
171 .szVetoOplockFiles = NULL,
177 .printer_admin = NULL,
180 .szVfsObjects = NULL,
181 .szMSDfsProxy = NULL,
182 .szAioWriteBehind = NULL,
185 .iMaxPrintJobs = 1000,
186 .iMaxReportedPrintJobs = 0,
187 .iWriteCacheSize = 0,
188 .iCreate_mask = 0744,
189 .iCreate_force_mode = 0,
190 .iSecurity_mask = 0777,
191 .iSecurity_force_mode = 0,
193 .iDir_force_mode = 0,
194 .iDir_Security_mask = 0777,
195 .iDir_Security_force_mode = 0,
196 .iMaxConnections = 0,
197 .iDefaultCase = CASE_LOWER,
198 .iPrinting = DEFAULT_PRINTING,
199 .iOplockContentionLimit = 2,
202 .iDfreeCacheTime = 0,
203 .bPreexecClose = false,
204 .bRootpreexecClose = false,
205 .iCaseSensitive = Auto,
206 .bCasePreserve = true,
207 .bShortCasePreserve = true,
208 .bHideDotFiles = true,
209 .bHideSpecialFiles = false,
210 .bHideUnReadable = false,
211 .bHideUnWriteableFiles = false,
213 .bAccessBasedShareEnum = false,
217 .bGuest_only = false,
218 .bAdministrative_share = false,
221 .bPrintNotifyBackchannel = true,
222 .bMap_system = false,
223 .bMap_hidden = false,
224 .bMap_archive = true,
225 .bStoreDosAttributes = false,
226 .bDmapiSupport = false,
228 .iStrictLocking = Auto,
229 .bPosixLocking = true,
232 .bLevel2OpLocks = true,
234 .bMangledNames = true,
237 .bSyncAlways = false,
238 .bStrictAllocate = false,
239 .bStrictSync = false,
242 .bDeleteReadonly = false,
243 .bFakeOplocks = false,
244 .bDeleteVetoFiles = false,
245 .bDosFilemode = false,
246 .bDosFiletimes = true,
247 .bDosFiletimeResolution = false,
248 .bFakeDirCreateTimes = false,
249 .bBlockingLocks = true,
250 .bInheritPerms = false,
251 .bInheritACLS = false,
252 .bInheritOwner = false,
254 .bUseClientDriver = false,
255 .bDefaultDevmode = true,
256 .bForcePrintername = false,
257 .bNTAclSupport = true,
258 .bForceUnknownAclUser = false,
259 .bUseSendfile = false,
260 .bProfileAcls = false,
261 .bMap_acl_inherit = false,
264 .bAclCheckPermissions = true,
265 .bAclMapFullControl = true,
266 .bAclGroupControl = false,
267 .bChangeNotify = true,
268 .bKernelChangeNotify = true,
269 .iallocation_roundup_size = SMB_ROUNDUP_ALLOCATION_SIZE,
272 .iMap_readonly = MAP_READONLY_YES,
273 #ifdef BROKEN_DIRECTORY_HANDLING
274 .iDirectoryNameCacheSize = 0,
276 .iDirectoryNameCacheSize = 100,
278 .ismb_encrypt = Auto,
283 /* local variables */
284 static struct loadparm_service **ServicePtrs = NULL;
285 static int iNumServices = 0;
286 static int iServiceIndex = 0;
287 static struct db_context *ServiceHash;
288 static int *invalid_services = NULL;
289 static int num_invalid_services = 0;
290 static bool bInGlobalSection = true;
291 static bool bGlobalOnly = false;
293 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
295 /* prototypes for the special type handlers */
296 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
297 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
298 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
299 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
300 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
301 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
302 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
303 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
304 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
305 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
306 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
307 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
309 static void set_allowed_client_auth(void);
311 static void add_to_file_list(const char *fname, const char *subfname);
312 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
314 static const struct enum_list enum_protocol[] = {
315 {PROTOCOL_SMB2_02, "SMB2"},
316 {PROTOCOL_SMB2_02, "SMB2_02"},
317 {PROTOCOL_NT1, "NT1"},
318 {PROTOCOL_LANMAN2, "LANMAN2"},
319 {PROTOCOL_LANMAN1, "LANMAN1"},
320 {PROTOCOL_CORE, "CORE"},
321 {PROTOCOL_COREPLUS, "COREPLUS"},
322 {PROTOCOL_COREPLUS, "CORE+"},
326 static const struct enum_list enum_security[] = {
327 {SEC_SHARE, "SHARE"},
329 {SEC_SERVER, "SERVER"},
330 {SEC_DOMAIN, "DOMAIN"},
337 static const struct enum_list enum_printing[] = {
338 {PRINT_SYSV, "sysv"},
340 {PRINT_HPUX, "hpux"},
344 {PRINT_LPRNG, "lprng"},
345 {PRINT_CUPS, "cups"},
346 {PRINT_IPRINT, "iprint"},
348 {PRINT_LPROS2, "os2"},
349 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
350 {PRINT_TEST, "test"},
352 #endif /* DEVELOPER */
356 static const struct enum_list enum_ldap_sasl_wrapping[] = {
358 {ADS_AUTH_SASL_SIGN, "sign"},
359 {ADS_AUTH_SASL_SEAL, "seal"},
363 static const struct enum_list enum_ldap_ssl[] = {
364 {LDAP_SSL_OFF, "no"},
365 {LDAP_SSL_OFF, "off"},
366 {LDAP_SSL_START_TLS, "start tls"},
367 {LDAP_SSL_START_TLS, "start_tls"},
371 /* LDAP Dereferencing Alias types */
372 #define SAMBA_LDAP_DEREF_NEVER 0
373 #define SAMBA_LDAP_DEREF_SEARCHING 1
374 #define SAMBA_LDAP_DEREF_FINDING 2
375 #define SAMBA_LDAP_DEREF_ALWAYS 3
377 static const struct enum_list enum_ldap_deref[] = {
378 {SAMBA_LDAP_DEREF_NEVER, "never"},
379 {SAMBA_LDAP_DEREF_SEARCHING, "searching"},
380 {SAMBA_LDAP_DEREF_FINDING, "finding"},
381 {SAMBA_LDAP_DEREF_ALWAYS, "always"},
385 static const struct enum_list enum_ldap_passwd_sync[] = {
386 {LDAP_PASSWD_SYNC_OFF, "no"},
387 {LDAP_PASSWD_SYNC_OFF, "off"},
388 {LDAP_PASSWD_SYNC_ON, "yes"},
389 {LDAP_PASSWD_SYNC_ON, "on"},
390 {LDAP_PASSWD_SYNC_ONLY, "only"},
394 static const struct enum_list enum_map_readonly[] = {
395 {MAP_READONLY_NO, "no"},
396 {MAP_READONLY_NO, "false"},
397 {MAP_READONLY_NO, "0"},
398 {MAP_READONLY_YES, "yes"},
399 {MAP_READONLY_YES, "true"},
400 {MAP_READONLY_YES, "1"},
401 {MAP_READONLY_PERMISSIONS, "permissions"},
402 {MAP_READONLY_PERMISSIONS, "perms"},
406 static const struct enum_list enum_case[] = {
407 {CASE_LOWER, "lower"},
408 {CASE_UPPER, "upper"},
414 static const struct enum_list enum_bool_auto[] = {
425 static const struct enum_list enum_csc_policy[] = {
426 {CSC_POLICY_MANUAL, "manual"},
427 {CSC_POLICY_DOCUMENTS, "documents"},
428 {CSC_POLICY_PROGRAMS, "programs"},
429 {CSC_POLICY_DISABLE, "disable"},
433 /* SMB signing types. */
434 static const struct enum_list enum_smb_signing_vals[] = {
446 {Required, "required"},
447 {Required, "mandatory"},
449 {Required, "forced"},
450 {Required, "enforced"},
454 /* ACL compatibility options. */
455 static const struct enum_list enum_acl_compat_vals[] = {
456 { ACL_COMPAT_AUTO, "auto" },
457 { ACL_COMPAT_WINNT, "winnt" },
458 { ACL_COMPAT_WIN2K, "win2k" },
463 Do you want session setups at user level security with a invalid
464 password to be rejected or allowed in as guest? WinNT rejects them
465 but it can be a pain as it means "net view" needs to use a password
467 You have 3 choices in the setting of map_to_guest:
469 "Never" means session setups with an invalid password
470 are rejected. This is the default.
472 "Bad User" means session setups with an invalid password
473 are rejected, unless the username does not exist, in which case it
474 is treated as a guest login
476 "Bad Password" means session setups with an invalid password
477 are treated as a guest login
479 Note that map_to_guest only has an effect in user or server
483 static const struct enum_list enum_map_to_guest[] = {
484 {NEVER_MAP_TO_GUEST, "Never"},
485 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
486 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
487 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
491 /* Config backend options */
493 static const struct enum_list enum_config_backend[] = {
494 {CONFIG_BACKEND_FILE, "file"},
495 {CONFIG_BACKEND_REGISTRY, "registry"},
499 /* ADS kerberos ticket verification options */
501 static const struct enum_list enum_kerberos_method[] = {
502 {KERBEROS_VERIFY_SECRETS, "default"},
503 {KERBEROS_VERIFY_SECRETS, "secrets only"},
504 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
505 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
506 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
510 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
512 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
513 * screen in SWAT. This is used to exclude parameters as well as to squash all
514 * parameters that have been duplicated by pseudonyms.
516 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
517 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
518 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
521 * NOTE2: Handling of duplicated (synonym) parameters:
522 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
523 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
524 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
525 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
528 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
529 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
531 static struct parm_struct parm_table[] = {
532 {N_("Base Options"), P_SEP, P_SEPARATOR},
535 .label = "dos charset",
538 .offset = GLOBAL_VAR(dos_charset),
539 .special = handle_dos_charset,
541 .flags = FLAG_ADVANCED
544 .label = "unix charset",
547 .offset = GLOBAL_VAR(unix_charset),
548 .special = handle_charset,
550 .flags = FLAG_ADVANCED
556 .offset = LOCAL_VAR(comment),
559 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
565 .offset = LOCAL_VAR(szPath),
568 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
571 .label = "directory",
574 .offset = LOCAL_VAR(szPath),
580 .label = "workgroup",
583 .offset = GLOBAL_VAR(szWorkgroup),
586 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
592 .offset = GLOBAL_VAR(szRealm),
593 .special = handle_realm,
595 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
598 .label = "netbios name",
601 .offset = GLOBAL_VAR(szNetbiosName),
604 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
607 .label = "netbios aliases",
610 .offset = GLOBAL_VAR(szNetbiosAliases),
611 .special = handle_netbios_aliases,
613 .flags = FLAG_ADVANCED,
616 .label = "netbios scope",
619 .offset = GLOBAL_VAR(szNetbiosScope),
622 .flags = FLAG_ADVANCED,
625 .label = "server string",
628 .offset = GLOBAL_VAR(szServerString),
631 .flags = FLAG_BASIC | FLAG_ADVANCED,
634 .label = "interfaces",
637 .offset = GLOBAL_VAR(szInterfaces),
640 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
643 .label = "bind interfaces only",
646 .offset = GLOBAL_VAR(bBindInterfacesOnly),
649 .flags = FLAG_ADVANCED | FLAG_WIZARD,
652 .label = "config backend",
655 .offset = GLOBAL_VAR(ConfigBackend),
657 .enum_list = enum_config_backend,
658 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
661 {N_("Security Options"), P_SEP, P_SEPARATOR},
667 .offset = GLOBAL_VAR(security),
669 .enum_list = enum_security,
670 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
673 .label = "auth methods",
676 .offset = GLOBAL_VAR(AuthMethods),
679 .flags = FLAG_ADVANCED,
682 .label = "encrypt passwords",
685 .offset = GLOBAL_VAR(bEncryptPasswords),
688 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
691 .label = "client schannel",
694 .offset = GLOBAL_VAR(clientSchannel),
696 .enum_list = enum_bool_auto,
697 .flags = FLAG_BASIC | FLAG_ADVANCED,
700 .label = "server schannel",
703 .offset = GLOBAL_VAR(serverSchannel),
705 .enum_list = enum_bool_auto,
706 .flags = FLAG_BASIC | FLAG_ADVANCED,
709 .label = "allow trusted domains",
712 .offset = GLOBAL_VAR(bAllowTrustedDomains),
715 .flags = FLAG_ADVANCED,
718 .label = "map to guest",
721 .offset = GLOBAL_VAR(map_to_guest),
723 .enum_list = enum_map_to_guest,
724 .flags = FLAG_ADVANCED,
727 .label = "null passwords",
730 .offset = GLOBAL_VAR(bNullPasswords),
733 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
736 .label = "obey pam restrictions",
739 .offset = GLOBAL_VAR(bObeyPamRestrictions),
742 .flags = FLAG_ADVANCED,
745 .label = "password server",
748 .offset = GLOBAL_VAR(szPasswordServer),
751 .flags = FLAG_ADVANCED | FLAG_WIZARD,
754 .label = "smb passwd file",
757 .offset = GLOBAL_VAR(szSMBPasswdFile),
760 .flags = FLAG_ADVANCED,
763 .label = "private dir",
766 .offset = GLOBAL_VAR(szPrivateDir),
769 .flags = FLAG_ADVANCED,
772 .label = "passdb backend",
775 .offset = GLOBAL_VAR(szPassdbBackend),
778 .flags = FLAG_ADVANCED | FLAG_WIZARD,
781 .label = "algorithmic rid base",
784 .offset = GLOBAL_VAR(AlgorithmicRidBase),
787 .flags = FLAG_ADVANCED,
790 .label = "root directory",
793 .offset = GLOBAL_VAR(szRootdir),
796 .flags = FLAG_ADVANCED,
802 .offset = GLOBAL_VAR(szRootdir),
811 .offset = GLOBAL_VAR(szRootdir),
817 .label = "guest account",
820 .offset = GLOBAL_VAR(szGuestaccount),
823 .flags = FLAG_BASIC | FLAG_ADVANCED,
826 .label = "enable privileges",
829 .offset = GLOBAL_VAR(bEnablePrivileges),
832 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
836 .label = "pam password change",
839 .offset = GLOBAL_VAR(bPamPasswordChange),
842 .flags = FLAG_ADVANCED,
845 .label = "passwd program",
848 .offset = GLOBAL_VAR(szPasswdProgram),
851 .flags = FLAG_ADVANCED,
854 .label = "passwd chat",
857 .offset = GLOBAL_VAR(szPasswdChat),
860 .flags = FLAG_ADVANCED,
863 .label = "passwd chat debug",
866 .offset = GLOBAL_VAR(bPasswdChatDebug),
869 .flags = FLAG_ADVANCED,
872 .label = "passwd chat timeout",
875 .offset = GLOBAL_VAR(iPasswdChatTimeout),
878 .flags = FLAG_ADVANCED,
881 .label = "check password script",
884 .offset = GLOBAL_VAR(szCheckPasswordScript),
887 .flags = FLAG_ADVANCED,
890 .label = "username map",
893 .offset = GLOBAL_VAR(szUsernameMap),
896 .flags = FLAG_ADVANCED,
899 .label = "password level",
902 .offset = GLOBAL_VAR(pwordlevel),
905 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
908 .label = "username level",
911 .offset = GLOBAL_VAR(unamelevel),
914 .flags = FLAG_ADVANCED,
917 .label = "unix password sync",
920 .offset = GLOBAL_VAR(bUnixPasswdSync),
923 .flags = FLAG_ADVANCED,
926 .label = "restrict anonymous",
929 .offset = GLOBAL_VAR(restrict_anonymous),
932 .flags = FLAG_ADVANCED,
935 .label = "lanman auth",
938 .offset = GLOBAL_VAR(bLanmanAuth),
941 .flags = FLAG_ADVANCED,
944 .label = "ntlm auth",
947 .offset = GLOBAL_VAR(bNTLMAuth),
950 .flags = FLAG_ADVANCED,
953 .label = "client NTLMv2 auth",
956 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
959 .flags = FLAG_ADVANCED,
962 .label = "client lanman auth",
965 .offset = GLOBAL_VAR(bClientLanManAuth),
968 .flags = FLAG_ADVANCED,
971 .label = "client plaintext auth",
974 .offset = GLOBAL_VAR(bClientPlaintextAuth),
977 .flags = FLAG_ADVANCED,
980 .label = "client use spnego principal",
983 .offset = GLOBAL_VAR(client_use_spnego_principal),
986 .flags = FLAG_ADVANCED,
989 .label = "send spnego principal",
992 .offset = GLOBAL_VAR(send_spnego_principal),
995 .flags = FLAG_ADVANCED,
1001 .offset = LOCAL_VAR(szUsername),
1004 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
1010 .offset = LOCAL_VAR(szUsername),
1019 .offset = LOCAL_VAR(szUsername),
1025 .label = "invalid users",
1028 .offset = LOCAL_VAR(szInvalidUsers),
1031 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1034 .label = "valid users",
1037 .offset = LOCAL_VAR(szValidUsers),
1040 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1043 .label = "admin users",
1046 .offset = LOCAL_VAR(szAdminUsers),
1049 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1052 .label = "read list",
1055 .offset = LOCAL_VAR(readlist),
1058 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1061 .label = "write list",
1064 .offset = LOCAL_VAR(writelist),
1067 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1070 .label = "printer admin",
1073 .offset = LOCAL_VAR(printer_admin),
1076 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1079 .label = "force user",
1082 .offset = LOCAL_VAR(force_user),
1085 .flags = FLAG_ADVANCED | FLAG_SHARE,
1088 .label = "force group",
1091 .offset = LOCAL_VAR(force_group),
1094 .flags = FLAG_ADVANCED | FLAG_SHARE,
1100 .offset = LOCAL_VAR(force_group),
1103 .flags = FLAG_ADVANCED,
1106 .label = "read only",
1109 .offset = LOCAL_VAR(bRead_only),
1112 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1115 .label = "write ok",
1118 .offset = LOCAL_VAR(bRead_only),
1124 .label = "writeable",
1127 .offset = LOCAL_VAR(bRead_only),
1133 .label = "writable",
1136 .offset = LOCAL_VAR(bRead_only),
1142 .label = "acl check permissions",
1145 .offset = LOCAL_VAR(bAclCheckPermissions),
1148 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1151 .label = "acl group control",
1154 .offset = LOCAL_VAR(bAclGroupControl),
1157 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1160 .label = "acl map full control",
1163 .offset = LOCAL_VAR(bAclMapFullControl),
1166 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1169 .label = "create mask",
1172 .offset = LOCAL_VAR(iCreate_mask),
1175 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1178 .label = "create mode",
1181 .offset = LOCAL_VAR(iCreate_mask),
1187 .label = "force create mode",
1190 .offset = LOCAL_VAR(iCreate_force_mode),
1193 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1196 .label = "security mask",
1199 .offset = LOCAL_VAR(iSecurity_mask),
1202 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1205 .label = "force security mode",
1208 .offset = LOCAL_VAR(iSecurity_force_mode),
1211 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1214 .label = "directory mask",
1217 .offset = LOCAL_VAR(iDir_mask),
1220 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1223 .label = "directory mode",
1226 .offset = LOCAL_VAR(iDir_mask),
1229 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1232 .label = "force directory mode",
1235 .offset = LOCAL_VAR(iDir_force_mode),
1238 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1241 .label = "directory security mask",
1244 .offset = LOCAL_VAR(iDir_Security_mask),
1247 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1250 .label = "force directory security mode",
1253 .offset = LOCAL_VAR(iDir_Security_force_mode),
1256 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1259 .label = "force unknown acl user",
1262 .offset = LOCAL_VAR(bForceUnknownAclUser),
1265 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1268 .label = "inherit permissions",
1271 .offset = LOCAL_VAR(bInheritPerms),
1274 .flags = FLAG_ADVANCED | FLAG_SHARE,
1277 .label = "inherit acls",
1280 .offset = LOCAL_VAR(bInheritACLS),
1283 .flags = FLAG_ADVANCED | FLAG_SHARE,
1286 .label = "inherit owner",
1289 .offset = LOCAL_VAR(bInheritOwner),
1292 .flags = FLAG_ADVANCED | FLAG_SHARE,
1295 .label = "guest only",
1298 .offset = LOCAL_VAR(bGuest_only),
1301 .flags = FLAG_ADVANCED | FLAG_SHARE,
1304 .label = "only guest",
1307 .offset = LOCAL_VAR(bGuest_only),
1313 .label = "administrative share",
1316 .offset = LOCAL_VAR(bAdministrative_share),
1319 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1323 .label = "guest ok",
1326 .offset = LOCAL_VAR(bGuest_ok),
1329 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1335 .offset = LOCAL_VAR(bGuest_ok),
1341 .label = "only user",
1344 .offset = LOCAL_VAR(bOnlyUser),
1347 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1350 .label = "hosts allow",
1353 .offset = LOCAL_VAR(szHostsallow),
1356 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1359 .label = "allow hosts",
1362 .offset = LOCAL_VAR(szHostsallow),
1368 .label = "hosts deny",
1371 .offset = LOCAL_VAR(szHostsdeny),
1374 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1377 .label = "deny hosts",
1380 .offset = LOCAL_VAR(szHostsdeny),
1386 .label = "preload modules",
1388 .p_class = P_GLOBAL,
1389 .offset = GLOBAL_VAR(szPreloadModules),
1392 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1395 .label = "dedicated keytab file",
1397 .p_class = P_GLOBAL,
1398 .offset = GLOBAL_VAR(szDedicatedKeytabFile),
1401 .flags = FLAG_ADVANCED,
1404 .label = "kerberos method",
1406 .p_class = P_GLOBAL,
1407 .offset = GLOBAL_VAR(iKerberosMethod),
1409 .enum_list = enum_kerberos_method,
1410 .flags = FLAG_ADVANCED,
1413 .label = "map untrusted to domain",
1415 .p_class = P_GLOBAL,
1416 .offset = GLOBAL_VAR(bMapUntrustedToDomain),
1419 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1423 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1426 .label = "log level",
1428 .p_class = P_GLOBAL,
1429 .offset = GLOBAL_VAR(szLogLevel),
1430 .special = handle_debug_list,
1432 .flags = FLAG_ADVANCED,
1435 .label = "debuglevel",
1437 .p_class = P_GLOBAL,
1438 .offset = GLOBAL_VAR(szLogLevel),
1439 .special = handle_debug_list,
1446 .p_class = P_GLOBAL,
1447 .offset = GLOBAL_VAR(syslog),
1450 .flags = FLAG_ADVANCED,
1453 .label = "syslog only",
1455 .p_class = P_GLOBAL,
1456 .offset = GLOBAL_VAR(bSyslogOnly),
1459 .flags = FLAG_ADVANCED,
1462 .label = "log file",
1464 .p_class = P_GLOBAL,
1465 .offset = GLOBAL_VAR(szLogFile),
1468 .flags = FLAG_ADVANCED,
1471 .label = "max log size",
1473 .p_class = P_GLOBAL,
1474 .offset = GLOBAL_VAR(max_log_size),
1477 .flags = FLAG_ADVANCED,
1480 .label = "debug timestamp",
1482 .p_class = P_GLOBAL,
1483 .offset = GLOBAL_VAR(bTimestampLogs),
1486 .flags = FLAG_ADVANCED,
1489 .label = "timestamp logs",
1491 .p_class = P_GLOBAL,
1492 .offset = GLOBAL_VAR(bTimestampLogs),
1495 .flags = FLAG_ADVANCED,
1498 .label = "debug prefix timestamp",
1500 .p_class = P_GLOBAL,
1501 .offset = GLOBAL_VAR(bDebugPrefixTimestamp),
1504 .flags = FLAG_ADVANCED,
1507 .label = "debug hires timestamp",
1509 .p_class = P_GLOBAL,
1510 .offset = GLOBAL_VAR(bDebugHiresTimestamp),
1513 .flags = FLAG_ADVANCED,
1516 .label = "debug pid",
1518 .p_class = P_GLOBAL,
1519 .offset = GLOBAL_VAR(bDebugPid),
1522 .flags = FLAG_ADVANCED,
1525 .label = "debug uid",
1527 .p_class = P_GLOBAL,
1528 .offset = GLOBAL_VAR(bDebugUid),
1531 .flags = FLAG_ADVANCED,
1534 .label = "debug class",
1536 .p_class = P_GLOBAL,
1537 .offset = GLOBAL_VAR(bDebugClass),
1540 .flags = FLAG_ADVANCED,
1543 .label = "enable core files",
1545 .p_class = P_GLOBAL,
1546 .offset = GLOBAL_VAR(bEnableCoreFiles),
1549 .flags = FLAG_ADVANCED,
1552 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1555 .label = "allocation roundup size",
1558 .offset = LOCAL_VAR(iallocation_roundup_size),
1561 .flags = FLAG_ADVANCED,
1564 .label = "aio read size",
1567 .offset = LOCAL_VAR(iAioReadSize),
1570 .flags = FLAG_ADVANCED,
1573 .label = "aio write size",
1576 .offset = LOCAL_VAR(iAioWriteSize),
1579 .flags = FLAG_ADVANCED,
1582 .label = "aio write behind",
1585 .offset = LOCAL_VAR(szAioWriteBehind),
1588 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1591 .label = "smb ports",
1593 .p_class = P_GLOBAL,
1594 .offset = GLOBAL_VAR(smb_ports),
1597 .flags = FLAG_ADVANCED,
1600 .label = "large readwrite",
1602 .p_class = P_GLOBAL,
1603 .offset = GLOBAL_VAR(bLargeReadwrite),
1606 .flags = FLAG_ADVANCED,
1609 .label = "max protocol",
1611 .p_class = P_GLOBAL,
1612 .offset = GLOBAL_VAR(maxprotocol),
1614 .enum_list = enum_protocol,
1615 .flags = FLAG_ADVANCED,
1618 .label = "protocol",
1620 .p_class = P_GLOBAL,
1621 .offset = GLOBAL_VAR(maxprotocol),
1623 .enum_list = enum_protocol,
1624 .flags = FLAG_ADVANCED,
1627 .label = "min protocol",
1629 .p_class = P_GLOBAL,
1630 .offset = GLOBAL_VAR(minprotocol),
1632 .enum_list = enum_protocol,
1633 .flags = FLAG_ADVANCED,
1636 .label = "min receivefile size",
1638 .p_class = P_GLOBAL,
1639 .offset = GLOBAL_VAR(iminreceivefile),
1642 .flags = FLAG_ADVANCED,
1645 .label = "read raw",
1647 .p_class = P_GLOBAL,
1648 .offset = GLOBAL_VAR(bReadRaw),
1651 .flags = FLAG_ADVANCED,
1654 .label = "write raw",
1656 .p_class = P_GLOBAL,
1657 .offset = GLOBAL_VAR(bWriteRaw),
1660 .flags = FLAG_ADVANCED,
1663 .label = "disable netbios",
1665 .p_class = P_GLOBAL,
1666 .offset = GLOBAL_VAR(bDisableNetbios),
1669 .flags = FLAG_ADVANCED,
1672 .label = "reset on zero vc",
1674 .p_class = P_GLOBAL,
1675 .offset = GLOBAL_VAR(bResetOnZeroVC),
1678 .flags = FLAG_ADVANCED,
1681 .label = "log writeable files on exit",
1683 .p_class = P_GLOBAL,
1684 .offset = GLOBAL_VAR(bLogWriteableFilesOnExit),
1687 .flags = FLAG_ADVANCED,
1690 .label = "acl compatibility",
1692 .p_class = P_GLOBAL,
1693 .offset = GLOBAL_VAR(iAclCompat),
1695 .enum_list = enum_acl_compat_vals,
1696 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1699 .label = "defer sharing violations",
1701 .p_class = P_GLOBAL,
1702 .offset = GLOBAL_VAR(bDeferSharingViolations),
1705 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1708 .label = "ea support",
1711 .offset = LOCAL_VAR(bEASupport),
1714 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1717 .label = "nt acl support",
1720 .offset = LOCAL_VAR(bNTAclSupport),
1723 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1726 .label = "nt pipe support",
1728 .p_class = P_GLOBAL,
1729 .offset = GLOBAL_VAR(bNTPipeSupport),
1732 .flags = FLAG_ADVANCED,
1735 .label = "nt status support",
1737 .p_class = P_GLOBAL,
1738 .offset = GLOBAL_VAR(bNTStatusSupport),
1741 .flags = FLAG_ADVANCED,
1744 .label = "profile acls",
1747 .offset = LOCAL_VAR(bProfileAcls),
1750 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1753 .label = "map acl inherit",
1756 .offset = LOCAL_VAR(bMap_acl_inherit),
1759 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1762 .label = "afs share",
1765 .offset = LOCAL_VAR(bAfs_Share),
1768 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1773 .p_class = P_GLOBAL,
1774 .offset = GLOBAL_VAR(max_mux),
1777 .flags = FLAG_ADVANCED,
1780 .label = "max xmit",
1782 .p_class = P_GLOBAL,
1783 .offset = GLOBAL_VAR(max_xmit),
1786 .flags = FLAG_ADVANCED,
1789 .label = "name resolve order",
1791 .p_class = P_GLOBAL,
1792 .offset = GLOBAL_VAR(szNameResolveOrder),
1795 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1800 .p_class = P_GLOBAL,
1801 .offset = GLOBAL_VAR(max_ttl),
1804 .flags = FLAG_ADVANCED,
1807 .label = "max wins ttl",
1809 .p_class = P_GLOBAL,
1810 .offset = GLOBAL_VAR(max_wins_ttl),
1813 .flags = FLAG_ADVANCED,
1816 .label = "min wins ttl",
1818 .p_class = P_GLOBAL,
1819 .offset = GLOBAL_VAR(min_wins_ttl),
1822 .flags = FLAG_ADVANCED,
1825 .label = "time server",
1827 .p_class = P_GLOBAL,
1828 .offset = GLOBAL_VAR(bTimeServer),
1831 .flags = FLAG_ADVANCED,
1834 .label = "unix extensions",
1836 .p_class = P_GLOBAL,
1837 .offset = GLOBAL_VAR(bUnixExtensions),
1840 .flags = FLAG_ADVANCED,
1843 .label = "use spnego",
1845 .p_class = P_GLOBAL,
1846 .offset = GLOBAL_VAR(bUseSpnego),
1849 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
1852 .label = "client signing",
1854 .p_class = P_GLOBAL,
1855 .offset = GLOBAL_VAR(client_signing),
1857 .enum_list = enum_smb_signing_vals,
1858 .flags = FLAG_ADVANCED,
1861 .label = "server signing",
1863 .p_class = P_GLOBAL,
1864 .offset = GLOBAL_VAR(server_signing),
1866 .enum_list = enum_smb_signing_vals,
1867 .flags = FLAG_ADVANCED,
1870 .label = "smb encrypt",
1873 .offset = LOCAL_VAR(ismb_encrypt),
1875 .enum_list = enum_smb_signing_vals,
1876 .flags = FLAG_ADVANCED,
1879 .label = "client use spnego",
1881 .p_class = P_GLOBAL,
1882 .offset = GLOBAL_VAR(bClientUseSpnego),
1885 .flags = FLAG_ADVANCED,
1888 .label = "client ldap sasl wrapping",
1890 .p_class = P_GLOBAL,
1891 .offset = GLOBAL_VAR(client_ldap_sasl_wrapping),
1893 .enum_list = enum_ldap_sasl_wrapping,
1894 .flags = FLAG_ADVANCED,
1897 .label = "enable asu support",
1899 .p_class = P_GLOBAL,
1900 .offset = GLOBAL_VAR(bASUSupport),
1903 .flags = FLAG_ADVANCED,
1906 .label = "svcctl list",
1908 .p_class = P_GLOBAL,
1909 .offset = GLOBAL_VAR(szServicesList),
1912 .flags = FLAG_ADVANCED,
1915 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
1918 .label = "block size",
1921 .offset = LOCAL_VAR(iBlock_size),
1924 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1927 .label = "deadtime",
1929 .p_class = P_GLOBAL,
1930 .offset = GLOBAL_VAR(deadtime),
1933 .flags = FLAG_ADVANCED,
1936 .label = "getwd cache",
1938 .p_class = P_GLOBAL,
1939 .offset = GLOBAL_VAR(getwd_cache),
1942 .flags = FLAG_ADVANCED,
1945 .label = "keepalive",
1947 .p_class = P_GLOBAL,
1948 .offset = GLOBAL_VAR(iKeepalive),
1951 .flags = FLAG_ADVANCED,
1954 .label = "change notify",
1957 .offset = LOCAL_VAR(bChangeNotify),
1960 .flags = FLAG_ADVANCED | FLAG_SHARE,
1963 .label = "directory name cache size",
1966 .offset = LOCAL_VAR(iDirectoryNameCacheSize),
1969 .flags = FLAG_ADVANCED | FLAG_SHARE,
1972 .label = "kernel change notify",
1975 .offset = LOCAL_VAR(bKernelChangeNotify),
1978 .flags = FLAG_ADVANCED | FLAG_SHARE,
1981 .label = "lpq cache time",
1983 .p_class = P_GLOBAL,
1984 .offset = GLOBAL_VAR(lpqcachetime),
1987 .flags = FLAG_ADVANCED,
1990 .label = "max smbd processes",
1992 .p_class = P_GLOBAL,
1993 .offset = GLOBAL_VAR(iMaxSmbdProcesses),
1996 .flags = FLAG_ADVANCED,
1999 .label = "max connections",
2002 .offset = LOCAL_VAR(iMaxConnections),
2005 .flags = FLAG_ADVANCED | FLAG_SHARE,
2008 .label = "paranoid server security",
2010 .p_class = P_GLOBAL,
2011 .offset = GLOBAL_VAR(paranoid_server_security),
2014 .flags = FLAG_ADVANCED,
2017 .label = "max disk size",
2019 .p_class = P_GLOBAL,
2020 .offset = GLOBAL_VAR(maxdisksize),
2023 .flags = FLAG_ADVANCED,
2026 .label = "max open files",
2028 .p_class = P_GLOBAL,
2029 .offset = GLOBAL_VAR(max_open_files),
2032 .flags = FLAG_ADVANCED,
2035 .label = "min print space",
2038 .offset = LOCAL_VAR(iMinPrintSpace),
2041 .flags = FLAG_ADVANCED | FLAG_PRINT,
2044 .label = "socket options",
2046 .p_class = P_GLOBAL,
2047 .offset = GLOBAL_VAR(szSocketOptions),
2050 .flags = FLAG_ADVANCED,
2053 .label = "strict allocate",
2056 .offset = LOCAL_VAR(bStrictAllocate),
2059 .flags = FLAG_ADVANCED | FLAG_SHARE,
2062 .label = "strict sync",
2065 .offset = LOCAL_VAR(bStrictSync),
2068 .flags = FLAG_ADVANCED | FLAG_SHARE,
2071 .label = "sync always",
2074 .offset = LOCAL_VAR(bSyncAlways),
2077 .flags = FLAG_ADVANCED | FLAG_SHARE,
2080 .label = "use mmap",
2082 .p_class = P_GLOBAL,
2083 .offset = GLOBAL_VAR(bUseMmap),
2086 .flags = FLAG_ADVANCED,
2089 .label = "use sendfile",
2092 .offset = LOCAL_VAR(bUseSendfile),
2095 .flags = FLAG_ADVANCED | FLAG_SHARE,
2098 .label = "hostname lookups",
2100 .p_class = P_GLOBAL,
2101 .offset = GLOBAL_VAR(bHostnameLookups),
2104 .flags = FLAG_ADVANCED,
2107 .label = "write cache size",
2110 .offset = LOCAL_VAR(iWriteCacheSize),
2113 .flags = FLAG_ADVANCED | FLAG_SHARE,
2116 .label = "name cache timeout",
2118 .p_class = P_GLOBAL,
2119 .offset = GLOBAL_VAR(name_cache_timeout),
2122 .flags = FLAG_ADVANCED,
2125 .label = "ctdbd socket",
2127 .p_class = P_GLOBAL,
2128 .offset = GLOBAL_VAR(ctdbdSocket),
2131 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2134 .label = "cluster addresses",
2136 .p_class = P_GLOBAL,
2137 .offset = GLOBAL_VAR(szClusterAddresses),
2140 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2143 .label = "clustering",
2145 .p_class = P_GLOBAL,
2146 .offset = GLOBAL_VAR(clustering),
2149 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2152 .label = "ctdb timeout",
2154 .p_class = P_GLOBAL,
2155 .offset = GLOBAL_VAR(ctdb_timeout),
2158 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2161 .label = "ctdb locktime warn threshold",
2163 .p_class = P_GLOBAL,
2164 .offset = GLOBAL_VAR(ctdb_locktime_warn_threshold),
2167 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2170 .label = "smb2 max read",
2172 .p_class = P_GLOBAL,
2173 .offset = GLOBAL_VAR(ismb2_max_read),
2176 .flags = FLAG_ADVANCED,
2179 .label = "smb2 max write",
2181 .p_class = P_GLOBAL,
2182 .offset = GLOBAL_VAR(ismb2_max_write),
2185 .flags = FLAG_ADVANCED,
2188 .label = "smb2 max trans",
2190 .p_class = P_GLOBAL,
2191 .offset = GLOBAL_VAR(ismb2_max_trans),
2194 .flags = FLAG_ADVANCED,
2197 .label = "smb2 max credits",
2199 .p_class = P_GLOBAL,
2200 .offset = GLOBAL_VAR(ismb2_max_credits),
2203 .flags = FLAG_ADVANCED,
2206 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2209 .label = "max reported print jobs",
2212 .offset = LOCAL_VAR(iMaxReportedPrintJobs),
2215 .flags = FLAG_ADVANCED | FLAG_PRINT,
2218 .label = "max print jobs",
2221 .offset = LOCAL_VAR(iMaxPrintJobs),
2224 .flags = FLAG_ADVANCED | FLAG_PRINT,
2227 .label = "load printers",
2229 .p_class = P_GLOBAL,
2230 .offset = GLOBAL_VAR(bLoadPrinters),
2233 .flags = FLAG_ADVANCED | FLAG_PRINT,
2236 .label = "printcap cache time",
2238 .p_class = P_GLOBAL,
2239 .offset = GLOBAL_VAR(PrintcapCacheTime),
2242 .flags = FLAG_ADVANCED | FLAG_PRINT,
2245 .label = "printcap name",
2247 .p_class = P_GLOBAL,
2248 .offset = GLOBAL_VAR(szPrintcapname),
2251 .flags = FLAG_ADVANCED | FLAG_PRINT,
2254 .label = "printcap",
2256 .p_class = P_GLOBAL,
2257 .offset = GLOBAL_VAR(szPrintcapname),
2263 .label = "printable",
2266 .offset = LOCAL_VAR(bPrint_ok),
2269 .flags = FLAG_ADVANCED | FLAG_PRINT,
2272 .label = "print notify backchannel",
2275 .offset = LOCAL_VAR(bPrintNotifyBackchannel),
2278 .flags = FLAG_ADVANCED,
2281 .label = "print ok",
2284 .offset = LOCAL_VAR(bPrint_ok),
2290 .label = "printing",
2293 .offset = LOCAL_VAR(iPrinting),
2294 .special = handle_printing,
2295 .enum_list = enum_printing,
2296 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2299 .label = "cups options",
2302 .offset = LOCAL_VAR(szCupsOptions),
2305 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2308 .label = "cups server",
2310 .p_class = P_GLOBAL,
2311 .offset = GLOBAL_VAR(szCupsServer),
2314 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2317 .label = "cups encrypt",
2319 .p_class = P_GLOBAL,
2320 .offset = GLOBAL_VAR(CupsEncrypt),
2322 .enum_list = enum_bool_auto,
2323 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2327 .label = "cups connection timeout",
2329 .p_class = P_GLOBAL,
2330 .offset = GLOBAL_VAR(cups_connection_timeout),
2333 .flags = FLAG_ADVANCED,
2336 .label = "iprint server",
2338 .p_class = P_GLOBAL,
2339 .offset = GLOBAL_VAR(szIPrintServer),
2342 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2345 .label = "print command",
2348 .offset = LOCAL_VAR(szPrintcommand),
2351 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2354 .label = "disable spoolss",
2356 .p_class = P_GLOBAL,
2357 .offset = GLOBAL_VAR(bDisableSpoolss),
2360 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2363 .label = "enable spoolss",
2365 .p_class = P_GLOBAL,
2366 .offset = GLOBAL_VAR(bDisableSpoolss),
2372 .label = "lpq command",
2375 .offset = LOCAL_VAR(szLpqcommand),
2378 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2381 .label = "lprm command",
2384 .offset = LOCAL_VAR(szLprmcommand),
2387 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2390 .label = "lppause command",
2393 .offset = LOCAL_VAR(szLppausecommand),
2396 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2399 .label = "lpresume command",
2402 .offset = LOCAL_VAR(szLpresumecommand),
2405 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2408 .label = "queuepause command",
2411 .offset = LOCAL_VAR(szQueuepausecommand),
2414 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2417 .label = "queueresume command",
2420 .offset = LOCAL_VAR(szQueueresumecommand),
2423 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2426 .label = "addport command",
2428 .p_class = P_GLOBAL,
2429 .offset = GLOBAL_VAR(szAddPortCommand),
2432 .flags = FLAG_ADVANCED,
2435 .label = "enumports command",
2437 .p_class = P_GLOBAL,
2438 .offset = GLOBAL_VAR(szEnumPortsCommand),
2441 .flags = FLAG_ADVANCED,
2444 .label = "addprinter command",
2446 .p_class = P_GLOBAL,
2447 .offset = GLOBAL_VAR(szAddPrinterCommand),
2450 .flags = FLAG_ADVANCED,
2453 .label = "deleteprinter command",
2455 .p_class = P_GLOBAL,
2456 .offset = GLOBAL_VAR(szDeletePrinterCommand),
2459 .flags = FLAG_ADVANCED,
2462 .label = "show add printer wizard",
2464 .p_class = P_GLOBAL,
2465 .offset = GLOBAL_VAR(bMsAddPrinterWizard),
2468 .flags = FLAG_ADVANCED,
2471 .label = "os2 driver map",
2473 .p_class = P_GLOBAL,
2474 .offset = GLOBAL_VAR(szOs2DriverMap),
2477 .flags = FLAG_ADVANCED,
2481 .label = "printer name",
2484 .offset = LOCAL_VAR(szPrintername),
2487 .flags = FLAG_ADVANCED | FLAG_PRINT,
2493 .offset = LOCAL_VAR(szPrintername),
2499 .label = "use client driver",
2502 .offset = LOCAL_VAR(bUseClientDriver),
2505 .flags = FLAG_ADVANCED | FLAG_PRINT,
2508 .label = "default devmode",
2511 .offset = LOCAL_VAR(bDefaultDevmode),
2514 .flags = FLAG_ADVANCED | FLAG_PRINT,
2517 .label = "force printername",
2520 .offset = LOCAL_VAR(bForcePrintername),
2523 .flags = FLAG_ADVANCED | FLAG_PRINT,
2526 .label = "printjob username",
2529 .offset = LOCAL_VAR(szPrintjobUsername),
2532 .flags = FLAG_ADVANCED | FLAG_PRINT,
2535 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2538 .label = "mangling method",
2540 .p_class = P_GLOBAL,
2541 .offset = GLOBAL_VAR(szManglingMethod),
2544 .flags = FLAG_ADVANCED,
2547 .label = "mangle prefix",
2549 .p_class = P_GLOBAL,
2550 .offset = GLOBAL_VAR(mangle_prefix),
2553 .flags = FLAG_ADVANCED,
2557 .label = "default case",
2560 .offset = LOCAL_VAR(iDefaultCase),
2562 .enum_list = enum_case,
2563 .flags = FLAG_ADVANCED | FLAG_SHARE,
2566 .label = "case sensitive",
2569 .offset = LOCAL_VAR(iCaseSensitive),
2571 .enum_list = enum_bool_auto,
2572 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2575 .label = "casesignames",
2578 .offset = LOCAL_VAR(iCaseSensitive),
2580 .enum_list = enum_bool_auto,
2581 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2584 .label = "preserve case",
2587 .offset = LOCAL_VAR(bCasePreserve),
2590 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2593 .label = "short preserve case",
2596 .offset = LOCAL_VAR(bShortCasePreserve),
2599 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2602 .label = "mangling char",
2605 .offset = LOCAL_VAR(magic_char),
2608 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2611 .label = "hide dot files",
2614 .offset = LOCAL_VAR(bHideDotFiles),
2617 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2620 .label = "hide special files",
2623 .offset = LOCAL_VAR(bHideSpecialFiles),
2626 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2629 .label = "hide unreadable",
2632 .offset = LOCAL_VAR(bHideUnReadable),
2635 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2638 .label = "hide unwriteable files",
2641 .offset = LOCAL_VAR(bHideUnWriteableFiles),
2644 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2647 .label = "delete veto files",
2650 .offset = LOCAL_VAR(bDeleteVetoFiles),
2653 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2656 .label = "veto files",
2659 .offset = LOCAL_VAR(szVetoFiles),
2662 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2665 .label = "hide files",
2668 .offset = LOCAL_VAR(szHideFiles),
2671 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2674 .label = "veto oplock files",
2677 .offset = LOCAL_VAR(szVetoOplockFiles),
2680 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2683 .label = "map archive",
2686 .offset = LOCAL_VAR(bMap_archive),
2689 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2692 .label = "map hidden",
2695 .offset = LOCAL_VAR(bMap_hidden),
2698 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2701 .label = "map system",
2704 .offset = LOCAL_VAR(bMap_system),
2707 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2710 .label = "map readonly",
2713 .offset = LOCAL_VAR(iMap_readonly),
2715 .enum_list = enum_map_readonly,
2716 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2719 .label = "mangled names",
2722 .offset = LOCAL_VAR(bMangledNames),
2725 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2728 .label = "max stat cache size",
2730 .p_class = P_GLOBAL,
2731 .offset = GLOBAL_VAR(iMaxStatCacheSize),
2734 .flags = FLAG_ADVANCED,
2737 .label = "stat cache",
2739 .p_class = P_GLOBAL,
2740 .offset = GLOBAL_VAR(bStatCache),
2743 .flags = FLAG_ADVANCED,
2746 .label = "store dos attributes",
2749 .offset = LOCAL_VAR(bStoreDosAttributes),
2752 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2755 .label = "dmapi support",
2758 .offset = LOCAL_VAR(bDmapiSupport),
2761 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2765 {N_("Domain Options"), P_SEP, P_SEPARATOR},
2768 .label = "machine password timeout",
2770 .p_class = P_GLOBAL,
2771 .offset = GLOBAL_VAR(machine_password_timeout),
2774 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2777 {N_("Logon Options"), P_SEP, P_SEPARATOR},
2780 .label = "add user script",
2782 .p_class = P_GLOBAL,
2783 .offset = GLOBAL_VAR(szAddUserScript),
2786 .flags = FLAG_ADVANCED,
2789 .label = "rename user script",
2791 .p_class = P_GLOBAL,
2792 .offset = GLOBAL_VAR(szRenameUserScript),
2795 .flags = FLAG_ADVANCED,
2798 .label = "delete user script",
2800 .p_class = P_GLOBAL,
2801 .offset = GLOBAL_VAR(szDelUserScript),
2804 .flags = FLAG_ADVANCED,
2807 .label = "add group script",
2809 .p_class = P_GLOBAL,
2810 .offset = GLOBAL_VAR(szAddGroupScript),
2813 .flags = FLAG_ADVANCED,
2816 .label = "delete group script",
2818 .p_class = P_GLOBAL,
2819 .offset = GLOBAL_VAR(szDelGroupScript),
2822 .flags = FLAG_ADVANCED,
2825 .label = "add user to group script",
2827 .p_class = P_GLOBAL,
2828 .offset = GLOBAL_VAR(szAddUserToGroupScript),
2831 .flags = FLAG_ADVANCED,
2834 .label = "delete user from group script",
2836 .p_class = P_GLOBAL,
2837 .offset = GLOBAL_VAR(szDelUserFromGroupScript),
2840 .flags = FLAG_ADVANCED,
2843 .label = "set primary group script",
2845 .p_class = P_GLOBAL,
2846 .offset = GLOBAL_VAR(szSetPrimaryGroupScript),
2849 .flags = FLAG_ADVANCED,
2852 .label = "add machine script",
2854 .p_class = P_GLOBAL,
2855 .offset = GLOBAL_VAR(szAddMachineScript),
2858 .flags = FLAG_ADVANCED,
2861 .label = "shutdown script",
2863 .p_class = P_GLOBAL,
2864 .offset = GLOBAL_VAR(szShutdownScript),
2867 .flags = FLAG_ADVANCED,
2870 .label = "abort shutdown script",
2872 .p_class = P_GLOBAL,
2873 .offset = GLOBAL_VAR(szAbortShutdownScript),
2876 .flags = FLAG_ADVANCED,
2879 .label = "username map script",
2881 .p_class = P_GLOBAL,
2882 .offset = GLOBAL_VAR(szUsernameMapScript),
2885 .flags = FLAG_ADVANCED,
2888 .label = "username map cache time",
2890 .p_class = P_GLOBAL,
2891 .offset = GLOBAL_VAR(iUsernameMapCacheTime),
2894 .flags = FLAG_ADVANCED,
2897 .label = "logon script",
2899 .p_class = P_GLOBAL,
2900 .offset = GLOBAL_VAR(szLogonScript),
2903 .flags = FLAG_ADVANCED,
2906 .label = "logon path",
2908 .p_class = P_GLOBAL,
2909 .offset = GLOBAL_VAR(szLogonPath),
2912 .flags = FLAG_ADVANCED,
2915 .label = "logon drive",
2917 .p_class = P_GLOBAL,
2918 .offset = GLOBAL_VAR(szLogonDrive),
2921 .flags = FLAG_ADVANCED,
2924 .label = "logon home",
2926 .p_class = P_GLOBAL,
2927 .offset = GLOBAL_VAR(szLogonHome),
2930 .flags = FLAG_ADVANCED,
2933 .label = "domain logons",
2935 .p_class = P_GLOBAL,
2936 .offset = GLOBAL_VAR(bDomainLogons),
2939 .flags = FLAG_ADVANCED,
2943 .label = "init logon delayed hosts",
2945 .p_class = P_GLOBAL,
2946 .offset = GLOBAL_VAR(szInitLogonDelayedHosts),
2949 .flags = FLAG_ADVANCED,
2953 .label = "init logon delay",
2955 .p_class = P_GLOBAL,
2956 .offset = GLOBAL_VAR(InitLogonDelay),
2959 .flags = FLAG_ADVANCED,
2963 {N_("Browse Options"), P_SEP, P_SEPARATOR},
2966 .label = "os level",
2968 .p_class = P_GLOBAL,
2969 .offset = GLOBAL_VAR(os_level),
2972 .flags = FLAG_BASIC | FLAG_ADVANCED,
2975 .label = "lm announce",
2977 .p_class = P_GLOBAL,
2978 .offset = GLOBAL_VAR(lm_announce),
2980 .enum_list = enum_bool_auto,
2981 .flags = FLAG_ADVANCED,
2984 .label = "lm interval",
2986 .p_class = P_GLOBAL,
2987 .offset = GLOBAL_VAR(lm_interval),
2990 .flags = FLAG_ADVANCED,
2993 .label = "preferred master",
2995 .p_class = P_GLOBAL,
2996 .offset = GLOBAL_VAR(iPreferredMaster),
2998 .enum_list = enum_bool_auto,
2999 .flags = FLAG_BASIC | FLAG_ADVANCED,
3002 .label = "prefered master",
3004 .p_class = P_GLOBAL,
3005 .offset = GLOBAL_VAR(iPreferredMaster),
3007 .enum_list = enum_bool_auto,
3011 .label = "local master",
3013 .p_class = P_GLOBAL,
3014 .offset = GLOBAL_VAR(bLocalMaster),
3017 .flags = FLAG_BASIC | FLAG_ADVANCED,
3020 .label = "domain master",
3022 .p_class = P_GLOBAL,
3023 .offset = GLOBAL_VAR(iDomainMaster),
3025 .enum_list = enum_bool_auto,
3026 .flags = FLAG_BASIC | FLAG_ADVANCED,
3029 .label = "browse list",
3031 .p_class = P_GLOBAL,
3032 .offset = GLOBAL_VAR(bBrowseList),
3035 .flags = FLAG_ADVANCED,
3038 .label = "browseable",
3041 .offset = LOCAL_VAR(bBrowseable),
3044 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3047 .label = "browsable",
3050 .offset = LOCAL_VAR(bBrowseable),
3056 .label = "access based share enum",
3059 .offset = LOCAL_VAR(bAccessBasedShareEnum),
3062 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3065 .label = "enhanced browsing",
3067 .p_class = P_GLOBAL,
3068 .offset = GLOBAL_VAR(enhanced_browsing),
3071 .flags = FLAG_ADVANCED,
3074 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3077 .label = "dns proxy",
3079 .p_class = P_GLOBAL,
3080 .offset = GLOBAL_VAR(bDNSproxy),
3083 .flags = FLAG_ADVANCED,
3086 .label = "wins proxy",
3088 .p_class = P_GLOBAL,
3089 .offset = GLOBAL_VAR(bWINSproxy),
3092 .flags = FLAG_ADVANCED,
3095 .label = "wins server",
3097 .p_class = P_GLOBAL,
3098 .offset = GLOBAL_VAR(szWINSservers),
3101 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3104 .label = "wins support",
3106 .p_class = P_GLOBAL,
3107 .offset = GLOBAL_VAR(bWINSsupport),
3110 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3113 .label = "wins hook",
3115 .p_class = P_GLOBAL,
3116 .offset = GLOBAL_VAR(szWINSHook),
3119 .flags = FLAG_ADVANCED,
3122 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3125 .label = "blocking locks",
3128 .offset = LOCAL_VAR(bBlockingLocks),
3131 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3134 .label = "csc policy",
3137 .offset = LOCAL_VAR(iCSCPolicy),
3139 .enum_list = enum_csc_policy,
3140 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3143 .label = "fake oplocks",
3146 .offset = LOCAL_VAR(bFakeOplocks),
3149 .flags = FLAG_ADVANCED | FLAG_SHARE,
3152 .label = "kernel oplocks",
3154 .p_class = P_GLOBAL,
3155 .offset = GLOBAL_VAR(bKernelOplocks),
3158 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3164 .offset = LOCAL_VAR(bLocking),
3167 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3170 .label = "lock spin time",
3172 .p_class = P_GLOBAL,
3173 .offset = GLOBAL_VAR(iLockSpinTime),
3176 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3182 .offset = LOCAL_VAR(bOpLocks),
3185 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3188 .label = "level2 oplocks",
3191 .offset = LOCAL_VAR(bLevel2OpLocks),
3194 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3197 .label = "oplock break wait time",
3199 .p_class = P_GLOBAL,
3200 .offset = GLOBAL_VAR(oplock_break_wait_time),
3203 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3206 .label = "oplock contention limit",
3209 .offset = LOCAL_VAR(iOplockContentionLimit),
3212 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3215 .label = "posix locking",
3218 .offset = LOCAL_VAR(bPosixLocking),
3221 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3224 .label = "strict locking",
3227 .offset = LOCAL_VAR(iStrictLocking),
3229 .enum_list = enum_bool_auto,
3230 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3233 .label = "share modes",
3236 .offset = LOCAL_VAR(bShareModes),
3239 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3242 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3245 .label = "ldap admin dn",
3247 .p_class = P_GLOBAL,
3248 .offset = GLOBAL_VAR(szLdapAdminDn),
3251 .flags = FLAG_ADVANCED,
3254 .label = "ldap delete dn",
3256 .p_class = P_GLOBAL,
3257 .offset = GLOBAL_VAR(ldap_delete_dn),
3260 .flags = FLAG_ADVANCED,
3263 .label = "ldap group suffix",
3265 .p_class = P_GLOBAL,
3266 .offset = GLOBAL_VAR(szLdapGroupSuffix),
3269 .flags = FLAG_ADVANCED,
3272 .label = "ldap idmap suffix",
3274 .p_class = P_GLOBAL,
3275 .offset = GLOBAL_VAR(szLdapIdmapSuffix),
3278 .flags = FLAG_ADVANCED,
3281 .label = "ldap machine suffix",
3283 .p_class = P_GLOBAL,
3284 .offset = GLOBAL_VAR(szLdapMachineSuffix),
3287 .flags = FLAG_ADVANCED,
3290 .label = "ldap passwd sync",
3292 .p_class = P_GLOBAL,
3293 .offset = GLOBAL_VAR(ldap_passwd_sync),
3295 .enum_list = enum_ldap_passwd_sync,
3296 .flags = FLAG_ADVANCED,
3299 .label = "ldap password sync",
3301 .p_class = P_GLOBAL,
3302 .offset = GLOBAL_VAR(ldap_passwd_sync),
3304 .enum_list = enum_ldap_passwd_sync,
3308 .label = "ldap replication sleep",
3310 .p_class = P_GLOBAL,
3311 .offset = GLOBAL_VAR(ldap_replication_sleep),
3314 .flags = FLAG_ADVANCED,
3317 .label = "ldap suffix",
3319 .p_class = P_GLOBAL,
3320 .offset = GLOBAL_VAR(szLdapSuffix),
3323 .flags = FLAG_ADVANCED,
3326 .label = "ldap ssl",
3328 .p_class = P_GLOBAL,
3329 .offset = GLOBAL_VAR(ldap_ssl),
3331 .enum_list = enum_ldap_ssl,
3332 .flags = FLAG_ADVANCED,
3335 .label = "ldap ssl ads",
3337 .p_class = P_GLOBAL,
3338 .offset = GLOBAL_VAR(ldap_ssl_ads),
3341 .flags = FLAG_ADVANCED,
3344 .label = "ldap deref",
3346 .p_class = P_GLOBAL,
3347 .offset = GLOBAL_VAR(ldap_deref),
3349 .enum_list = enum_ldap_deref,
3350 .flags = FLAG_ADVANCED,
3353 .label = "ldap follow referral",
3355 .p_class = P_GLOBAL,
3356 .offset = GLOBAL_VAR(ldap_follow_referral),
3358 .enum_list = enum_bool_auto,
3359 .flags = FLAG_ADVANCED,
3362 .label = "ldap timeout",
3364 .p_class = P_GLOBAL,
3365 .offset = GLOBAL_VAR(ldap_timeout),
3368 .flags = FLAG_ADVANCED,
3371 .label = "ldap connection timeout",
3373 .p_class = P_GLOBAL,
3374 .offset = GLOBAL_VAR(ldap_connection_timeout),
3377 .flags = FLAG_ADVANCED,
3380 .label = "ldap page size",
3382 .p_class = P_GLOBAL,
3383 .offset = GLOBAL_VAR(ldap_page_size),
3386 .flags = FLAG_ADVANCED,
3389 .label = "ldap user suffix",
3391 .p_class = P_GLOBAL,
3392 .offset = GLOBAL_VAR(szLdapUserSuffix),
3395 .flags = FLAG_ADVANCED,
3398 .label = "ldap debug level",
3400 .p_class = P_GLOBAL,
3401 .offset = GLOBAL_VAR(ldap_debug_level),
3402 .special = handle_ldap_debug_level,
3404 .flags = FLAG_ADVANCED,
3407 .label = "ldap debug threshold",
3409 .p_class = P_GLOBAL,
3410 .offset = GLOBAL_VAR(ldap_debug_threshold),
3413 .flags = FLAG_ADVANCED,
3416 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3419 .label = "eventlog list",
3421 .p_class = P_GLOBAL,
3422 .offset = GLOBAL_VAR(szEventLogs),
3425 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3428 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3431 .label = "add share command",
3433 .p_class = P_GLOBAL,
3434 .offset = GLOBAL_VAR(szAddShareCommand),
3437 .flags = FLAG_ADVANCED,
3440 .label = "change share command",
3442 .p_class = P_GLOBAL,
3443 .offset = GLOBAL_VAR(szChangeShareCommand),
3446 .flags = FLAG_ADVANCED,
3449 .label = "delete share command",
3451 .p_class = P_GLOBAL,
3452 .offset = GLOBAL_VAR(szDeleteShareCommand),
3455 .flags = FLAG_ADVANCED,
3458 .label = "config file",
3460 .p_class = P_GLOBAL,
3461 .offset = GLOBAL_VAR(szConfigFile),
3464 .flags = FLAG_HIDE|FLAG_META,
3469 .p_class = P_GLOBAL,
3470 .offset = GLOBAL_VAR(szAutoServices),
3473 .flags = FLAG_ADVANCED,
3476 .label = "auto services",
3478 .p_class = P_GLOBAL,
3479 .offset = GLOBAL_VAR(szAutoServices),
3482 .flags = FLAG_ADVANCED,
3485 .label = "lock directory",
3487 .p_class = P_GLOBAL,
3488 .offset = GLOBAL_VAR(szLockDir),
3491 .flags = FLAG_ADVANCED,
3494 .label = "lock dir",
3496 .p_class = P_GLOBAL,
3497 .offset = GLOBAL_VAR(szLockDir),
3503 .label = "state directory",
3505 .p_class = P_GLOBAL,
3506 .offset = GLOBAL_VAR(szStateDir),
3509 .flags = FLAG_ADVANCED,
3512 .label = "cache directory",
3514 .p_class = P_GLOBAL,
3515 .offset = GLOBAL_VAR(szCacheDir),
3518 .flags = FLAG_ADVANCED,
3521 .label = "pid directory",
3523 .p_class = P_GLOBAL,
3524 .offset = GLOBAL_VAR(szPidDir),
3527 .flags = FLAG_ADVANCED,
3531 .label = "utmp directory",
3533 .p_class = P_GLOBAL,
3534 .offset = GLOBAL_VAR(szUtmpDir),
3537 .flags = FLAG_ADVANCED,
3540 .label = "wtmp directory",
3542 .p_class = P_GLOBAL,
3543 .offset = GLOBAL_VAR(szWtmpDir),
3546 .flags = FLAG_ADVANCED,
3551 .p_class = P_GLOBAL,
3552 .offset = GLOBAL_VAR(bUtmp),
3555 .flags = FLAG_ADVANCED,
3559 .label = "default service",
3561 .p_class = P_GLOBAL,
3562 .offset = GLOBAL_VAR(szDefaultService),
3565 .flags = FLAG_ADVANCED,
3570 .p_class = P_GLOBAL,
3571 .offset = GLOBAL_VAR(szDefaultService),
3574 .flags = FLAG_ADVANCED,
3577 .label = "message command",
3579 .p_class = P_GLOBAL,
3580 .offset = GLOBAL_VAR(szMsgCommand),
3583 .flags = FLAG_ADVANCED,
3586 .label = "dfree cache time",
3589 .offset = LOCAL_VAR(iDfreeCacheTime),
3592 .flags = FLAG_ADVANCED,
3595 .label = "dfree command",
3598 .offset = LOCAL_VAR(szDfree),
3601 .flags = FLAG_ADVANCED,
3604 .label = "get quota command",
3606 .p_class = P_GLOBAL,
3607 .offset = GLOBAL_VAR(szGetQuota),
3610 .flags = FLAG_ADVANCED,
3613 .label = "set quota command",
3615 .p_class = P_GLOBAL,
3616 .offset = GLOBAL_VAR(szSetQuota),
3619 .flags = FLAG_ADVANCED,
3622 .label = "remote announce",
3624 .p_class = P_GLOBAL,
3625 .offset = GLOBAL_VAR(szRemoteAnnounce),
3628 .flags = FLAG_ADVANCED,
3631 .label = "remote browse sync",
3633 .p_class = P_GLOBAL,
3634 .offset = GLOBAL_VAR(szRemoteBrowseSync),
3637 .flags = FLAG_ADVANCED,
3640 .label = "socket address",
3642 .p_class = P_GLOBAL,
3643 .offset = GLOBAL_VAR(szSocketAddress),
3646 .flags = FLAG_ADVANCED,
3649 .label = "nmbd bind explicit broadcast",
3651 .p_class = P_GLOBAL,
3652 .offset = GLOBAL_VAR(bNmbdBindExplicitBroadcast),
3655 .flags = FLAG_ADVANCED,
3658 .label = "homedir map",
3660 .p_class = P_GLOBAL,
3661 .offset = GLOBAL_VAR(szNISHomeMapName),
3664 .flags = FLAG_ADVANCED,
3667 .label = "afs username map",
3669 .p_class = P_GLOBAL,
3670 .offset = GLOBAL_VAR(szAfsUsernameMap),
3673 .flags = FLAG_ADVANCED,
3676 .label = "afs token lifetime",
3678 .p_class = P_GLOBAL,
3679 .offset = GLOBAL_VAR(iAfsTokenLifetime),
3682 .flags = FLAG_ADVANCED,
3685 .label = "log nt token command",
3687 .p_class = P_GLOBAL,
3688 .offset = GLOBAL_VAR(szLogNtTokenCommand),
3691 .flags = FLAG_ADVANCED,
3694 .label = "NIS homedir",
3696 .p_class = P_GLOBAL,
3697 .offset = GLOBAL_VAR(bNISHomeMap),
3700 .flags = FLAG_ADVANCED,
3706 .offset = LOCAL_VAR(valid),
3715 .offset = LOCAL_VAR(szCopy),
3716 .special = handle_copy,
3724 .offset = LOCAL_VAR(szInclude),
3725 .special = handle_include,
3727 .flags = FLAG_HIDE|FLAG_META,
3733 .offset = LOCAL_VAR(szPreExec),
3736 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3742 .offset = LOCAL_VAR(szPreExec),
3745 .flags = FLAG_ADVANCED,
3748 .label = "preexec close",
3751 .offset = LOCAL_VAR(bPreexecClose),
3754 .flags = FLAG_ADVANCED | FLAG_SHARE,
3757 .label = "postexec",
3760 .offset = LOCAL_VAR(szPostExec),
3763 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3766 .label = "root preexec",
3769 .offset = LOCAL_VAR(szRootPreExec),
3772 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3775 .label = "root preexec close",
3778 .offset = LOCAL_VAR(bRootpreexecClose),
3781 .flags = FLAG_ADVANCED | FLAG_SHARE,
3784 .label = "root postexec",
3787 .offset = LOCAL_VAR(szRootPostExec),
3790 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3793 .label = "available",
3796 .offset = LOCAL_VAR(bAvailable),
3799 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3802 .label = "registry shares",
3804 .p_class = P_GLOBAL,
3805 .offset = GLOBAL_VAR(bRegistryShares),
3808 .flags = FLAG_ADVANCED,
3811 .label = "usershare allow guests",
3813 .p_class = P_GLOBAL,
3814 .offset = GLOBAL_VAR(bUsershareAllowGuests),
3817 .flags = FLAG_ADVANCED,
3820 .label = "usershare max shares",
3822 .p_class = P_GLOBAL,
3823 .offset = GLOBAL_VAR(iUsershareMaxShares),
3826 .flags = FLAG_ADVANCED,
3829 .label = "usershare owner only",
3831 .p_class = P_GLOBAL,
3832 .offset = GLOBAL_VAR(bUsershareOwnerOnly),
3835 .flags = FLAG_ADVANCED,
3838 .label = "usershare path",
3840 .p_class = P_GLOBAL,
3841 .offset = GLOBAL_VAR(szUsersharePath),
3844 .flags = FLAG_ADVANCED,
3847 .label = "usershare prefix allow list",
3849 .p_class = P_GLOBAL,
3850 .offset = GLOBAL_VAR(szUsersharePrefixAllowList),
3853 .flags = FLAG_ADVANCED,
3856 .label = "usershare prefix deny list",
3858 .p_class = P_GLOBAL,
3859 .offset = GLOBAL_VAR(szUsersharePrefixDenyList),
3862 .flags = FLAG_ADVANCED,
3865 .label = "usershare template share",
3867 .p_class = P_GLOBAL,
3868 .offset = GLOBAL_VAR(szUsershareTemplateShare),
3871 .flags = FLAG_ADVANCED,
3877 .offset = LOCAL_VAR(volume),
3880 .flags = FLAG_ADVANCED | FLAG_SHARE,
3886 .offset = LOCAL_VAR(fstype),
3889 .flags = FLAG_ADVANCED | FLAG_SHARE,
3892 .label = "set directory",
3895 .offset = LOCAL_VAR(bNo_set_dir),
3898 .flags = FLAG_ADVANCED | FLAG_SHARE,
3901 .label = "wide links",
3904 .offset = LOCAL_VAR(bWidelinks),
3907 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3910 .label = "follow symlinks",
3913 .offset = LOCAL_VAR(bSymlinks),
3916 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3919 .label = "dont descend",
3922 .offset = LOCAL_VAR(szDontdescend),
3925 .flags = FLAG_ADVANCED | FLAG_SHARE,
3928 .label = "magic script",
3931 .offset = LOCAL_VAR(szMagicScript),
3934 .flags = FLAG_ADVANCED | FLAG_SHARE,
3937 .label = "magic output",
3940 .offset = LOCAL_VAR(szMagicOutput),
3943 .flags = FLAG_ADVANCED | FLAG_SHARE,
3946 .label = "delete readonly",
3949 .offset = LOCAL_VAR(bDeleteReadonly),
3952 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3955 .label = "dos filemode",
3958 .offset = LOCAL_VAR(bDosFilemode),
3961 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3964 .label = "dos filetimes",
3967 .offset = LOCAL_VAR(bDosFiletimes),
3970 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3973 .label = "dos filetime resolution",
3976 .offset = LOCAL_VAR(bDosFiletimeResolution),
3979 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3982 .label = "fake directory create times",
3985 .offset = LOCAL_VAR(bFakeDirCreateTimes),
3988 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3991 .label = "async smb echo handler",
3993 .p_class = P_GLOBAL,
3994 .offset = GLOBAL_VAR(bAsyncSMBEchoHandler),
3997 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4000 .label = "multicast dns register",
4002 .p_class = P_GLOBAL,
4003 .offset = GLOBAL_VAR(bMulticastDnsRegister),
4006 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4009 .label = "panic action",
4011 .p_class = P_GLOBAL,
4012 .offset = GLOBAL_VAR(szPanicAction),
4015 .flags = FLAG_ADVANCED,
4018 .label = "perfcount module",
4020 .p_class = P_GLOBAL,
4021 .offset = GLOBAL_VAR(szSMBPerfcountModule),
4024 .flags = FLAG_ADVANCED,
4027 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4030 .label = "vfs objects",
4033 .offset = LOCAL_VAR(szVfsObjects),
4036 .flags = FLAG_ADVANCED | FLAG_SHARE,
4039 .label = "vfs object",
4042 .offset = LOCAL_VAR(szVfsObjects),
4049 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4052 .label = "msdfs root",
4055 .offset = LOCAL_VAR(bMSDfsRoot),
4058 .flags = FLAG_ADVANCED | FLAG_SHARE,
4061 .label = "msdfs proxy",
4064 .offset = LOCAL_VAR(szMSDfsProxy),
4067 .flags = FLAG_ADVANCED | FLAG_SHARE,
4070 .label = "host msdfs",
4072 .p_class = P_GLOBAL,
4073 .offset = GLOBAL_VAR(bHostMSDfs),
4076 .flags = FLAG_ADVANCED,
4079 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4082 .label = "passdb expand explicit",
4084 .p_class = P_GLOBAL,
4085 .offset = GLOBAL_VAR(bPassdbExpandExplicit),
4088 .flags = FLAG_ADVANCED,
4091 .label = "idmap backend",
4093 .p_class = P_GLOBAL,
4094 .offset = GLOBAL_VAR(szIdmapBackend),
4095 .special = handle_idmap_backend,
4097 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4100 .label = "idmap cache time",
4102 .p_class = P_GLOBAL,
4103 .offset = GLOBAL_VAR(iIdmapCacheTime),
4106 .flags = FLAG_ADVANCED,
4109 .label = "idmap negative cache time",
4111 .p_class = P_GLOBAL,
4112 .offset = GLOBAL_VAR(iIdmapNegativeCacheTime),
4115 .flags = FLAG_ADVANCED,
4118 .label = "idmap uid",
4120 .p_class = P_GLOBAL,
4121 .offset = GLOBAL_VAR(szIdmapUID),
4122 .special = handle_idmap_uid,
4124 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4127 .label = "winbind uid",
4129 .p_class = P_GLOBAL,
4130 .offset = GLOBAL_VAR(szIdmapUID),
4131 .special = handle_idmap_uid,
4136 .label = "idmap gid",
4138 .p_class = P_GLOBAL,
4139 .offset = GLOBAL_VAR(szIdmapGID),
4140 .special = handle_idmap_gid,
4142 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4145 .label = "winbind gid",
4147 .p_class = P_GLOBAL,
4148 .offset = GLOBAL_VAR(szIdmapGID),
4149 .special = handle_idmap_gid,
4154 .label = "template homedir",
4156 .p_class = P_GLOBAL,
4157 .offset = GLOBAL_VAR(szTemplateHomedir),
4160 .flags = FLAG_ADVANCED,
4163 .label = "template shell",
4165 .p_class = P_GLOBAL,
4166 .offset = GLOBAL_VAR(szTemplateShell),
4169 .flags = FLAG_ADVANCED,
4172 .label = "winbind separator",
4174 .p_class = P_GLOBAL,
4175 .offset = GLOBAL_VAR(szWinbindSeparator),
4178 .flags = FLAG_ADVANCED,
4181 .label = "winbind cache time",
4183 .p_class = P_GLOBAL,
4184 .offset = GLOBAL_VAR(winbind_cache_time),
4187 .flags = FLAG_ADVANCED,
4190 .label = "winbind reconnect delay",
4192 .p_class = P_GLOBAL,
4193 .offset = GLOBAL_VAR(winbind_reconnect_delay),
4196 .flags = FLAG_ADVANCED,
4199 .label = "winbind max clients",
4201 .p_class = P_GLOBAL,
4202 .offset = GLOBAL_VAR(winbind_max_clients),
4205 .flags = FLAG_ADVANCED,
4208 .label = "winbind enum users",
4210 .p_class = P_GLOBAL,
4211 .offset = GLOBAL_VAR(bWinbindEnumUsers),
4214 .flags = FLAG_ADVANCED,
4217 .label = "winbind enum groups",
4219 .p_class = P_GLOBAL,
4220 .offset = GLOBAL_VAR(bWinbindEnumGroups),
4223 .flags = FLAG_ADVANCED,
4226 .label = "winbind use default domain",
4228 .p_class = P_GLOBAL,
4229 .offset = GLOBAL_VAR(bWinbindUseDefaultDomain),
4232 .flags = FLAG_ADVANCED,
4235 .label = "winbind trusted domains only",
4237 .p_class = P_GLOBAL,
4238 .offset = GLOBAL_VAR(bWinbindTrustedDomainsOnly),
4241 .flags = FLAG_ADVANCED,
4244 .label = "winbind nested groups",
4246 .p_class = P_GLOBAL,
4247 .offset = GLOBAL_VAR(bWinbindNestedGroups),
4250 .flags = FLAG_ADVANCED,
4253 .label = "winbind expand groups",
4255 .p_class = P_GLOBAL,
4256 .offset = GLOBAL_VAR(winbind_expand_groups),
4259 .flags = FLAG_ADVANCED,
4262 .label = "winbind nss info",
4264 .p_class = P_GLOBAL,
4265 .offset = GLOBAL_VAR(szWinbindNssInfo),
4268 .flags = FLAG_ADVANCED,
4271 .label = "winbind refresh tickets",
4273 .p_class = P_GLOBAL,
4274 .offset = GLOBAL_VAR(bWinbindRefreshTickets),
4277 .flags = FLAG_ADVANCED,
4280 .label = "winbind offline logon",
4282 .p_class = P_GLOBAL,
4283 .offset = GLOBAL_VAR(bWinbindOfflineLogon),
4286 .flags = FLAG_ADVANCED,
4289 .label = "winbind normalize names",
4291 .p_class = P_GLOBAL,
4292 .offset = GLOBAL_VAR(bWinbindNormalizeNames),
4295 .flags = FLAG_ADVANCED,
4298 .label = "winbind rpc only",
4300 .p_class = P_GLOBAL,
4301 .offset = GLOBAL_VAR(bWinbindRpcOnly),
4304 .flags = FLAG_ADVANCED,
4307 .label = "create krb5 conf",
4309 .p_class = P_GLOBAL,
4310 .offset = GLOBAL_VAR(bCreateKrb5Conf),
4313 .flags = FLAG_ADVANCED,
4316 .label = "ncalrpc dir",
4318 .p_class = P_GLOBAL,
4319 .offset = GLOBAL_VAR(ncalrpc_dir),
4322 .flags = FLAG_ADVANCED,
4325 .label = "winbind max domain connections",
4327 .p_class = P_GLOBAL,
4328 .offset = GLOBAL_VAR(winbindMaxDomainConnections),
4331 .flags = FLAG_ADVANCED,
4334 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
4337 /***************************************************************************
4338 Initialise the sDefault parameter structure for the printer values.
4339 ***************************************************************************/
4341 static void init_printer_values(struct loadparm_service *pService)
4343 /* choose defaults depending on the type of printing */
4344 switch (pService->iPrinting) {
4349 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4350 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4351 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4356 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4357 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4358 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4359 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4360 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4361 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4362 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4368 /* set the lpq command to contain the destination printer
4369 name only. This is used by cups_queue_get() */
4370 string_set(&pService->szLpqcommand, "%p");
4371 string_set(&pService->szLprmcommand, "");
4372 string_set(&pService->szPrintcommand, "");
4373 string_set(&pService->szLppausecommand, "");
4374 string_set(&pService->szLpresumecommand, "");
4375 string_set(&pService->szQueuepausecommand, "");
4376 string_set(&pService->szQueueresumecommand, "");
4378 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4379 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4380 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4381 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4382 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4383 string_set(&pService->szQueuepausecommand, "disable '%p'");
4384 string_set(&pService->szQueueresumecommand, "enable '%p'");
4385 #endif /* HAVE_CUPS */
4390 string_set(&pService->szLpqcommand, "lpstat -o%p");
4391 string_set(&pService->szLprmcommand, "cancel %p-%j");
4392 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4393 string_set(&pService->szQueuepausecommand, "disable %p");
4394 string_set(&pService->szQueueresumecommand, "enable %p");
4396 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4397 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4402 string_set(&pService->szLpqcommand, "lpq -P%p");
4403 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4404 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4407 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
4411 const char *tdbfile;
4414 tdbfile = talloc_asprintf(
4415 talloc_tos(), "tdbfile=%s",
4416 lp_parm_const_string(-1, "vlp", "tdbfile",
4418 if (tdbfile == NULL) {
4419 tdbfile="tdbfile=/tmp/vlp.tdb";
4422 tmp = talloc_asprintf(talloc_tos(), "vlp %s print %%p %%s",
4424 string_set(&pService->szPrintcommand,
4425 tmp ? tmp : "vlp print %p %s");
4428 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpq %%p",
4430 string_set(&pService->szLpqcommand,
4431 tmp ? tmp : "vlp lpq %p");
4434 tmp = talloc_asprintf(talloc_tos(), "vlp %s lprm %%p %%j",
4436 string_set(&pService->szLprmcommand,
4437 tmp ? tmp : "vlp lprm %p %j");
4440 tmp = talloc_asprintf(talloc_tos(), "vlp %s lppause %%p %%j",
4442 string_set(&pService->szLppausecommand,
4443 tmp ? tmp : "vlp lppause %p %j");
4446 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpresume %%p %%j",
4448 string_set(&pService->szLpresumecommand,
4449 tmp ? tmp : "vlp lpresume %p %j");
4452 tmp = talloc_asprintf(talloc_tos(), "vlp %s queuepause %%p",
4454 string_set(&pService->szQueuepausecommand,
4455 tmp ? tmp : "vlp queuepause %p");
4458 tmp = talloc_asprintf(talloc_tos(), "vlp %s queueresume %%p",
4460 string_set(&pService->szQueueresumecommand,
4461 tmp ? tmp : "vlp queueresume %p");
4466 #endif /* DEVELOPER */
4471 * Function to return the default value for the maximum number of open
4472 * file descriptors permitted. This function tries to consult the
4473 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4474 * the smaller of those.
4476 static int max_open_files(void)
4478 int sysctl_max = MAX_OPEN_FILES;
4479 int rlimit_max = MAX_OPEN_FILES;
4481 #ifdef HAVE_SYSCTLBYNAME
4483 size_t size = sizeof(sysctl_max);
4484 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4489 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4495 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4496 rlimit_max = rl.rlim_cur;
4498 #if defined(RLIM_INFINITY)
4499 if(rl.rlim_cur == RLIM_INFINITY)
4500 rlimit_max = MAX_OPEN_FILES;
4505 if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4506 DEBUG(2,("max_open_files: increasing sysctl_max (%d) to "
4507 "minimum Windows limit (%d)\n",
4509 MIN_OPEN_FILES_WINDOWS));
4510 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4513 if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4514 DEBUG(2,("rlimit_max: increasing rlimit_max (%d) to "
4515 "minimum Windows limit (%d)\n",
4517 MIN_OPEN_FILES_WINDOWS));
4518 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4521 return MIN(sysctl_max, rlimit_max);
4525 * Common part of freeing allocated data for one parameter.
4527 static void free_one_parameter_common(void *parm_ptr,
4528 struct parm_struct parm)
4530 if ((parm.type == P_STRING) ||
4531 (parm.type == P_USTRING))
4533 string_free((char**)parm_ptr);
4534 } else if (parm.type == P_LIST) {
4535 TALLOC_FREE(*((char***)parm_ptr));
4540 * Free the allocated data for one parameter for a share
4541 * given as a service struct.
4543 static void free_one_parameter(struct loadparm_service *service,
4544 struct parm_struct parm)
4548 if (parm.p_class != P_LOCAL) {
4552 parm_ptr = lp_parm_ptr(service, &parm);
4554 free_one_parameter_common(parm_ptr, parm);
4558 * Free the allocated parameter data of a share given
4559 * as a service struct.
4561 static void free_parameters(struct loadparm_service *service)
4565 for (i=0; parm_table[i].label; i++) {
4566 free_one_parameter(service, parm_table[i]);
4571 * Free the allocated data for one parameter for a given share
4572 * specified by an snum.
4574 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4579 parm_ptr = lp_parm_ptr(NULL, &parm);
4580 } else if (parm.p_class != P_LOCAL) {
4583 parm_ptr = lp_local_ptr_by_snum(snum, &parm);
4586 free_one_parameter_common(parm_ptr, parm);
4590 * Free the allocated parameter data for a share specified
4593 static void free_parameters_by_snum(int snum)
4597 for (i=0; parm_table[i].label; i++) {
4598 free_one_parameter_by_snum(snum, parm_table[i]);
4603 * Free the allocated global parameters.
4605 static void free_global_parameters(void)
4607 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4610 static int map_parameter(const char *pszParmName);
4612 struct lp_stored_option {
4613 struct lp_stored_option *prev, *next;
4618 static struct lp_stored_option *stored_options;
4621 save options set by lp_set_cmdline() into a list. This list is
4622 re-applied when we do a globals reset, so that cmdline set options
4623 are sticky across reloads of smb.conf
4625 static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
4627 struct lp_stored_option *entry, *entry_next;
4628 for (entry = stored_options; entry != NULL; entry = entry_next) {
4629 entry_next = entry->next;
4630 if (strcmp(pszParmName, entry->label) == 0) {
4631 DLIST_REMOVE(stored_options, entry);
4637 entry = talloc(NULL, struct lp_stored_option);
4642 entry->label = talloc_strdup(entry, pszParmName);
4643 if (!entry->label) {
4648 entry->value = talloc_strdup(entry, pszParmValue);
4649 if (!entry->value) {
4654 DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
4659 static bool apply_lp_set_cmdline(void)
4661 struct lp_stored_option *entry = NULL;
4662 for (entry = stored_options; entry != NULL; entry = entry->next) {
4663 if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
4664 DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
4665 entry->label, entry->value));
4672 /***************************************************************************
4673 Initialise the global parameter structure.
4674 ***************************************************************************/
4676 static void init_globals(bool reinit_globals)
4678 static bool done_init = false;
4682 /* If requested to initialize only once and we've already done it... */
4683 if (!reinit_globals && done_init) {
4684 /* ... then we have nothing more to do */
4689 /* The logfile can be set before this is invoked. Free it if so. */
4690 if (Globals.szLogFile != NULL) {
4691 string_free(&Globals.szLogFile);
4692 Globals.szLogFile = NULL;
4696 free_global_parameters();
4699 /* This memset and the free_global_parameters() above will
4700 * wipe out smb.conf options set with lp_set_cmdline(). The
4701 * apply_lp_set_cmdline() call puts these values back in the
4702 * table once the defaults are set */
4703 memset((void *)&Globals, '\0', sizeof(Globals));
4705 for (i = 0; parm_table[i].label; i++) {
4706 if ((parm_table[i].type == P_STRING ||
4707 parm_table[i].type == P_USTRING))
4709 string_set(lp_parm_ptr(NULL, &parm_table[i]), "");
4714 string_set(&sDefault.fstype, FSTYPE_STRING);
4715 string_set(&sDefault.szPrintjobUsername, "%U");
4717 init_printer_values(&sDefault);
4720 DEBUG(3, ("Initialising global parameters\n"));
4722 /* Must manually force to upper case here, as this does not go via the handler */
4723 string_set(&Globals.szNetbiosName, myhostname_upper());
4725 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4726 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4728 /* use the new 'hash2' method by default, with a prefix of 1 */
4729 string_set(&Globals.szManglingMethod, "hash2");
4730 Globals.mangle_prefix = 1;
4732 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4734 /* using UTF8 by default allows us to support all chars */
4735 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4737 /* Use codepage 850 as a default for the dos character set */
4738 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4741 * Allow the default PASSWD_CHAT to be overridden in local.h.
4743 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4745 string_set(&Globals.szWorkgroup, DEFAULT_WORKGROUP);
4747 string_set(&Globals.szPasswdProgram, "");
4748 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4749 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4750 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4751 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4752 string_set(&Globals.szSocketAddress, "0.0.0.0");
4754 * By default support explicit binding to broadcast
4757 Globals.bNmbdBindExplicitBroadcast = true;
4759 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4760 smb_panic("init_globals: ENOMEM");
4762 string_set(&Globals.szServerString, s);
4765 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4768 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
4770 string_set(&Globals.szLogonDrive, "");
4771 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4772 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4773 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4775 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
4776 string_set(&Globals.szPasswordServer, "*");
4778 Globals.AlgorithmicRidBase = BASE_RID;
4780 Globals.bLoadPrinters = true;
4781 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4783 Globals.ConfigBackend = config_backend;
4785 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4786 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4787 Globals.max_xmit = 0x4104;
4788 Globals.max_mux = 50; /* This is *needed* for profile support. */
4789 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4790 Globals.bDisableSpoolss = false;
4791 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4792 Globals.pwordlevel = 0;
4793 Globals.unamelevel = 0;
4794 Globals.deadtime = 0;
4795 Globals.getwd_cache = true;
4796 Globals.bLargeReadwrite = true;
4797 Globals.max_log_size = 5000;
4798 Globals.max_open_files = max_open_files();
4799 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4800 Globals.maxprotocol = PROTOCOL_NT1;
4801 Globals.minprotocol = PROTOCOL_CORE;
4802 Globals.security = SEC_USER;
4803 Globals.paranoid_server_security = true;
4804 Globals.bEncryptPasswords = true;
4805 Globals.clientSchannel = Auto;
4806 Globals.serverSchannel = Auto;
4807 Globals.bReadRaw = true;
4808 Globals.bWriteRaw = true;
4809 Globals.bNullPasswords = false;
4810 Globals.bObeyPamRestrictions = false;
4812 Globals.bSyslogOnly = false;
4813 Globals.bTimestampLogs = true;
4814 string_set(&Globals.szLogLevel, "0");
4815 Globals.bDebugPrefixTimestamp = false;
4816 Globals.bDebugHiresTimestamp = true;
4817 Globals.bDebugPid = false;
4818 Globals.bDebugUid = false;
4819 Globals.bDebugClass = false;
4820 Globals.bEnableCoreFiles = true;
4821 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4822 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4823 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4824 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4825 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
4826 Globals.lm_interval = 60;
4827 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4828 Globals.bNISHomeMap = false;
4829 #ifdef WITH_NISPLUS_HOME
4830 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4832 string_set(&Globals.szNISHomeMapName, "auto.home");
4835 Globals.bTimeServer = false;
4836 Globals.bBindInterfacesOnly = false;
4837 Globals.bUnixPasswdSync = false;
4838 Globals.bPamPasswordChange = false;
4839 Globals.bPasswdChatDebug = false;
4840 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4841 Globals.bNTPipeSupport = true; /* Do NT pipes by default. */
4842 Globals.bNTStatusSupport = true; /* Use NT status by default. */
4843 Globals.bStatCache = true; /* use stat cache by default */
4844 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4845 Globals.restrict_anonymous = 0;
4846 Globals.bClientLanManAuth = false; /* Do NOT use the LanMan hash if it is available */
4847 Globals.bClientPlaintextAuth = false; /* Do NOT use a plaintext password even if is requested by the server */
4848 Globals.bLanmanAuth = false; /* Do NOT use the LanMan hash, even if it is supplied */
4849 Globals.bNTLMAuth = true; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4850 Globals.bClientNTLMv2Auth = true; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
4851 /* Note, that we will also use NTLM2 session security (which is different), if it is available */
4853 Globals.map_to_guest = 0; /* By Default, "Never" */
4854 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4855 Globals.enhanced_browsing = true;
4856 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4857 #ifdef MMAP_BLACKLIST
4858 Globals.bUseMmap = false;
4860 Globals.bUseMmap = true;
4862 Globals.bUnixExtensions = true;
4863 Globals.bResetOnZeroVC = false;
4864 Globals.bLogWriteableFilesOnExit = false;
4865 Globals.bCreateKrb5Conf = true;
4866 Globals.winbindMaxDomainConnections = 1;
4868 /* hostname lookups can be very expensive and are broken on
4869 a large number of sites (tridge) */
4870 Globals.bHostnameLookups = false;
4872 string_set(&Globals.szPassdbBackend, "tdbsam");
4873 string_set(&Globals.szLdapSuffix, "");
4874 string_set(&Globals.szLdapMachineSuffix, "");
4875 string_set(&Globals.szLdapUserSuffix, "");
4876 string_set(&Globals.szLdapGroupSuffix, "");
4877 string_set(&Globals.szLdapIdmapSuffix, "");
4879 string_set(&Globals.szLdapAdminDn, "");
4880 Globals.ldap_ssl = LDAP_SSL_START_TLS;
4881 Globals.ldap_ssl_ads = false;
4882 Globals.ldap_deref = -1;
4883 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
4884 Globals.ldap_delete_dn = false;
4885 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
4886 Globals.ldap_follow_referral = Auto;
4887 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
4888 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
4889 Globals.ldap_page_size = LDAP_PAGE_SIZE;
4891 Globals.ldap_debug_level = 0;
4892 Globals.ldap_debug_threshold = 10;
4894 /* This is what we tell the afs client. in reality we set the token
4895 * to never expire, though, when this runs out the afs client will
4896 * forget the token. Set to 0 to get NEVERDATE.*/
4897 Globals.iAfsTokenLifetime = 604800;
4898 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
4900 /* these parameters are set to defaults that are more appropriate
4901 for the increasing samba install base:
4903 as a member of the workgroup, that will possibly become a
4904 _local_ master browser (lm = true). this is opposed to a forced
4905 local master browser startup (pm = true).
4907 doesn't provide WINS server service by default (wsupp = false),
4908 and doesn't provide domain master browser services by default, either.
4912 Globals.bMsAddPrinterWizard = true;
4913 Globals.os_level = 20;
4914 Globals.bLocalMaster = true;
4915 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
4916 Globals.bDomainLogons = false;
4917 Globals.bBrowseList = true;
4918 Globals.bWINSsupport = false;
4919 Globals.bWINSproxy = false;
4921 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
4922 Globals.InitLogonDelay = 100; /* 100 ms default delay */
4924 Globals.bDNSproxy = true;
4926 /* this just means to use them if they exist */
4927 Globals.bKernelOplocks = true;
4929 Globals.bAllowTrustedDomains = true;
4930 string_set(&Globals.szIdmapBackend, "tdb");
4932 string_set(&Globals.szTemplateShell, "/bin/false");
4933 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
4934 string_set(&Globals.szWinbindSeparator, "\\");
4936 string_set(&Globals.szCupsServer, "");
4937 string_set(&Globals.szIPrintServer, "");
4939 string_set(&Globals.ctdbdSocket, "");
4940 Globals.szClusterAddresses = NULL;
4941 Globals.clustering = false;
4942 Globals.ctdb_timeout = 0;
4943 Globals.ctdb_locktime_warn_threshold = 0;
4945 Globals.winbind_cache_time = 300; /* 5 minutes */
4946 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
4947 Globals.winbind_max_clients = 200;
4948 Globals.bWinbindEnumUsers = false;
4949 Globals.bWinbindEnumGroups = false;
4950 Globals.bWinbindUseDefaultDomain = false;
4951 Globals.bWinbindTrustedDomainsOnly = false;
4952 Globals.bWinbindNestedGroups = true;
4953 Globals.winbind_expand_groups = 1;
4954 Globals.szWinbindNssInfo = (const char **)str_list_make_v3(NULL, "template", NULL);
4955 Globals.bWinbindRefreshTickets = false;
4956 Globals.bWinbindOfflineLogon = false;
4958 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
4959 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
4961 Globals.bPassdbExpandExplicit = false;
4963 Globals.name_cache_timeout = 660; /* In seconds */
4965 Globals.bUseSpnego = true;
4966 Globals.bClientUseSpnego = true;
4968 Globals.client_signing = Auto;
4969 Globals.server_signing = false;
4971 Globals.bDeferSharingViolations = true;
4972 string_set(&Globals.smb_ports, SMB_PORTS);
4974 Globals.bEnablePrivileges = true;
4975 Globals.bHostMSDfs = true;
4976 Globals.bASUSupport = false;
4978 /* User defined shares. */
4979 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
4980 smb_panic("init_globals: ENOMEM");
4982 string_set(&Globals.szUsersharePath, s);
4984 string_set(&Globals.szUsershareTemplateShare, "");
4985 Globals.iUsershareMaxShares = 0;
4986 /* By default disallow sharing of directories not owned by the sharer. */
4987 Globals.bUsershareOwnerOnly = true;
4988 /* By default disallow guest access to usershares. */
4989 Globals.bUsershareAllowGuests = false;
4991 Globals.iKeepalive = DEFAULT_KEEPALIVE;
4993 /* By default no shares out of the registry */
4994 Globals.bRegistryShares = false;
4996 Globals.iminreceivefile = 0;
4998 Globals.bMapUntrustedToDomain = false;
4999 Globals.bMulticastDnsRegister = true;
5001 Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ;
5002 Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE;
5003 Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT;
5004 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5006 string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
5008 /* Now put back the settings that were set with lp_set_cmdline() */
5009 apply_lp_set_cmdline();
5012 /*******************************************************************
5013 Convenience routine to grab string parameters into temporary memory
5014 and run standard_sub_basic on them. The buffers can be written to by
5015 callers without affecting the source string.
5016 ********************************************************************/
5018 static char *lp_string(const char *s)
5021 TALLOC_CTX *ctx = talloc_tos();
5023 /* The follow debug is useful for tracking down memory problems
5024 especially if you have an inner loop that is calling a lp_*()
5025 function that returns a string. Perhaps this debug should be
5026 present all the time? */
5029 DEBUG(10, ("lp_string(%s)\n", s));
5035 ret = talloc_sub_basic(ctx,
5036 get_current_username(),
5037 current_user_info.domain,
5039 if (trim_char(ret, '\"', '\"')) {
5040 if (strchr(ret,'\"') != NULL) {
5042 ret = talloc_sub_basic(ctx,
5043 get_current_username(),
5044 current_user_info.domain,
5052 In this section all the functions that are used to access the
5053 parameters from the rest of the program are defined
5056 #define FN_GLOBAL_STRING(fn_name,ptr) \
5057 char *fn_name(void) {return(lp_string(*(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : ""));}
5058 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5059 const char *fn_name(void) {return(*(const char **)(&Globals.ptr) ? *(const char **)(&Globals.ptr) : "");}
5060 #define FN_GLOBAL_LIST(fn_name,ptr) \
5061 const char **fn_name(void) {return(*(const char ***)(&Globals.ptr));}
5062 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5063 bool fn_name(void) {return(*(bool *)(&Globals.ptr));}
5064 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5065 char fn_name(void) {return(*(char *)(&Globals.ptr));}
5066 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5067 int fn_name(void) {return(*(int *)(&Globals.ptr));}
5069 #define FN_LOCAL_STRING(fn_name,val) \
5070 char *lp_ ## fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5071 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5072 const char *lp_ ## fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5073 #define FN_LOCAL_LIST(fn_name,val) \
5074 const char **lp_ ## fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5075 #define FN_LOCAL_BOOL(fn_name,val) \
5076 bool lp_ ## fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5077 #define FN_LOCAL_INTEGER(fn_name,val) \
5078 int lp_ ## fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5080 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5081 bool lp_ ## fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5082 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5083 int lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5084 #define FN_LOCAL_CHAR(fn_name,val) \
5085 char lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5087 FN_GLOBAL_CONST_STRING(lp_smb_ports, smb_ports)
5088 FN_GLOBAL_CONST_STRING(lp_dos_charset, dos_charset)
5089 FN_GLOBAL_CONST_STRING(lp_unix_charset, unix_charset)
5090 FN_GLOBAL_STRING(lp_logfile, szLogFile)
5091 FN_GLOBAL_STRING(lp_configfile, szConfigFile)
5092 FN_GLOBAL_CONST_STRING(lp_smb_passwd_file, szSMBPasswdFile)
5093 FN_GLOBAL_CONST_STRING(lp_private_dir, szPrivateDir)
5094 FN_GLOBAL_STRING(lp_serverstring, szServerString)
5095 FN_GLOBAL_INTEGER(lp_printcap_cache_time, PrintcapCacheTime)
5096 FN_GLOBAL_STRING(lp_addport_cmd, szAddPortCommand)
5097 FN_GLOBAL_STRING(lp_enumports_cmd, szEnumPortsCommand)
5098 FN_GLOBAL_STRING(lp_addprinter_cmd, szAddPrinterCommand)
5099 FN_GLOBAL_STRING(lp_deleteprinter_cmd, szDeletePrinterCommand)
5100 FN_GLOBAL_STRING(lp_os2_driver_map, szOs2DriverMap)
5101 FN_GLOBAL_CONST_STRING(lp_lockdir, szLockDir)
5102 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5103 * build process or in smb.conf, we use that value. Otherwise they
5104 * default to the value of lp_lockdir(). */
5105 const char *lp_statedir(void) {
5106 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5107 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5108 return(*(char **)(&Globals.szStateDir) ?
5109 *(char **)(&Globals.szStateDir) : "");
5111 return(*(char **)(&Globals.szLockDir) ?
5112 *(char **)(&Globals.szLockDir) : "");
5114 const char *lp_cachedir(void) {
5115 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5116 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5117 return(*(char **)(&Globals.szCacheDir) ?
5118 *(char **)(&Globals.szCacheDir) : "");
5120 return(*(char **)(&Globals.szLockDir) ?
5121 *(char **)(&Globals.szLockDir) : "");
5123 FN_GLOBAL_CONST_STRING(lp_piddir, szPidDir)
5124 FN_GLOBAL_STRING(lp_mangling_method, szManglingMethod)
5125 FN_GLOBAL_INTEGER(lp_mangle_prefix, mangle_prefix)
5126 FN_GLOBAL_CONST_STRING(lp_utmpdir, szUtmpDir)
5127 FN_GLOBAL_CONST_STRING(lp_wtmpdir, szWtmpDir)
5128 FN_GLOBAL_BOOL(lp_utmp, bUtmp)
5129 FN_GLOBAL_STRING(lp_rootdir, szRootdir)
5130 FN_GLOBAL_STRING(lp_perfcount_module, szSMBPerfcountModule)
5131 FN_GLOBAL_STRING(lp_defaultservice, szDefaultService)
5132 FN_GLOBAL_STRING(lp_msg_command, szMsgCommand)
5133 FN_GLOBAL_STRING(lp_get_quota_command, szGetQuota)
5134 FN_GLOBAL_STRING(lp_set_quota_command, szSetQuota)
5135 FN_GLOBAL_STRING(lp_auto_services, szAutoServices)
5136 FN_GLOBAL_STRING(lp_passwd_program, szPasswdProgram)
5137 FN_GLOBAL_STRING(lp_passwd_chat, szPasswdChat)
5138 FN_GLOBAL_CONST_STRING(lp_passwordserver, szPasswordServer)
5139 FN_GLOBAL_CONST_STRING(lp_name_resolve_order, szNameResolveOrder)
5140 FN_GLOBAL_CONST_STRING(lp_workgroup, szWorkgroup)
5141 FN_GLOBAL_CONST_STRING(lp_netbios_name, szNetbiosName)
5142 FN_GLOBAL_CONST_STRING(lp_netbios_scope, szNetbiosScope)
5143 FN_GLOBAL_CONST_STRING(lp_realm, szRealmUpper)
5144 FN_GLOBAL_CONST_STRING(lp_dnsdomain, szDnsDomain)
5145 FN_GLOBAL_CONST_STRING(lp_afs_username_map, szAfsUsernameMap)
5146 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, iAfsTokenLifetime)
5147 FN_GLOBAL_STRING(lp_log_nt_token_command, szLogNtTokenCommand)
5148 FN_GLOBAL_STRING(lp_username_map, szUsernameMap)
5149 FN_GLOBAL_CONST_STRING(lp_logon_script, szLogonScript)
5150 FN_GLOBAL_CONST_STRING(lp_logon_path, szLogonPath)
5151 FN_GLOBAL_CONST_STRING(lp_logon_drive, szLogonDrive)
5152 FN_GLOBAL_CONST_STRING(lp_logon_home, szLogonHome)
5153 FN_GLOBAL_STRING(lp_remote_announce, szRemoteAnnounce)
5154 FN_GLOBAL_STRING(lp_remote_browse_sync, szRemoteBrowseSync)
5155 FN_GLOBAL_BOOL(lp_nmbd_bind_explicit_broadcast, bNmbdBindExplicitBroadcast)
5156 FN_GLOBAL_LIST(lp_wins_server_list, szWINSservers)
5157 FN_GLOBAL_LIST(lp_interfaces, szInterfaces)
5158 FN_GLOBAL_STRING(lp_nis_home_map_name, szNISHomeMapName)
5159 FN_GLOBAL_LIST(lp_netbios_aliases, szNetbiosAliases)
5160 FN_GLOBAL_CONST_STRING(lp_passdb_backend, szPassdbBackend)
5161 FN_GLOBAL_LIST(lp_preload_modules, szPreloadModules)
5162 FN_GLOBAL_STRING(lp_panic_action, szPanicAction)
5163 FN_GLOBAL_STRING(lp_adduser_script, szAddUserScript)
5164 FN_GLOBAL_STRING(lp_renameuser_script, szRenameUserScript)
5165 FN_GLOBAL_STRING(lp_deluser_script, szDelUserScript)
5167 FN_GLOBAL_CONST_STRING(lp_guestaccount, szGuestaccount)
5168 FN_GLOBAL_STRING(lp_addgroup_script, szAddGroupScript)
5169 FN_GLOBAL_STRING(lp_delgroup_script, szDelGroupScript)
5170 FN_GLOBAL_STRING(lp_addusertogroup_script, szAddUserToGroupScript)
5171 FN_GLOBAL_STRING(lp_deluserfromgroup_script, szDelUserFromGroupScript)
5172 FN_GLOBAL_STRING(lp_setprimarygroup_script, szSetPrimaryGroupScript)
5174 FN_GLOBAL_STRING(lp_addmachine_script, szAddMachineScript)
5176 FN_GLOBAL_STRING(lp_shutdown_script, szShutdownScript)
5177 FN_GLOBAL_STRING(lp_abort_shutdown_script, szAbortShutdownScript)
5178 FN_GLOBAL_STRING(lp_username_map_script, szUsernameMapScript)
5179 FN_GLOBAL_INTEGER(lp_username_map_cache_time, iUsernameMapCacheTime)
5181 FN_GLOBAL_STRING(lp_check_password_script, szCheckPasswordScript)
5183 FN_GLOBAL_STRING(lp_wins_hook, szWINSHook)
5184 FN_GLOBAL_CONST_STRING(lp_template_homedir, szTemplateHomedir)
5185 FN_GLOBAL_CONST_STRING(lp_template_shell, szTemplateShell)
5186 FN_GLOBAL_CONST_STRING(lp_winbind_separator, szWinbindSeparator)
5187 FN_GLOBAL_INTEGER(lp_acl_compatibility, iAclCompat)
5188 FN_GLOBAL_BOOL(lp_winbind_enum_users, bWinbindEnumUsers)
5189 FN_GLOBAL_BOOL(lp_winbind_enum_groups, bWinbindEnumGroups)
5190 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, bWinbindUseDefaultDomain)
5191 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, bWinbindTrustedDomainsOnly)
5192 FN_GLOBAL_BOOL(lp_winbind_nested_groups, bWinbindNestedGroups)
5193 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, winbind_expand_groups)
5194 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, bWinbindRefreshTickets)
5195 FN_GLOBAL_BOOL(lp_winbind_offline_logon, bWinbindOfflineLogon)
5196 FN_GLOBAL_BOOL(lp_winbind_normalize_names, bWinbindNormalizeNames)
5197 FN_GLOBAL_BOOL(lp_winbind_rpc_only, bWinbindRpcOnly)
5198 FN_GLOBAL_BOOL(lp_create_krb5_conf, bCreateKrb5Conf)
5199 static FN_GLOBAL_INTEGER(lp_winbind_max_domain_connections_int,
5200 winbindMaxDomainConnections)
5202 int lp_winbind_max_domain_connections(void)
5204 if (lp_winbind_offline_logon() &&
5205 lp_winbind_max_domain_connections_int() > 1) {
5206 DEBUG(1, ("offline logons active, restricting max domain "
5207 "connections to 1\n"));
5210 return MAX(1, lp_winbind_max_domain_connections_int());
5213 FN_GLOBAL_CONST_STRING(lp_idmap_backend, szIdmapBackend)
5214 FN_GLOBAL_INTEGER(lp_idmap_cache_time, iIdmapCacheTime)
5215 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, iIdmapNegativeCacheTime)
5216 FN_GLOBAL_INTEGER(lp_keepalive, iKeepalive)
5217 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, bPassdbExpandExplicit)
5219 FN_GLOBAL_STRING(lp_ldap_suffix, szLdapSuffix)
5220 FN_GLOBAL_STRING(lp_ldap_admin_dn, szLdapAdminDn)
5221 FN_GLOBAL_INTEGER(lp_ldap_ssl, ldap_ssl)
5222 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, ldap_ssl_ads)
5223 FN_GLOBAL_INTEGER(lp_ldap_deref, ldap_deref)
5224 FN_GLOBAL_INTEGER(lp_ldap_follow_referral, ldap_follow_referral)
5225 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, ldap_passwd_sync)
5226 FN_GLOBAL_BOOL(lp_ldap_delete_dn, ldap_delete_dn)
5227 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, ldap_replication_sleep)
5228 FN_GLOBAL_INTEGER(lp_ldap_timeout, ldap_timeout)
5229 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, ldap_connection_timeout)
5230 FN_GLOBAL_INTEGER(lp_ldap_page_size, ldap_page_size)
5231 FN_GLOBAL_INTEGER(lp_ldap_debug_level, ldap_debug_level)
5232 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, ldap_debug_threshold)
5233 FN_GLOBAL_STRING(lp_add_share_cmd, szAddShareCommand)
5234 FN_GLOBAL_STRING(lp_change_share_cmd, szChangeShareCommand)
5235 FN_GLOBAL_STRING(lp_delete_share_cmd, szDeleteShareCommand)
5236 FN_GLOBAL_STRING(lp_usershare_path, szUsersharePath)
5237 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, szUsersharePrefixAllowList)
5238 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, szUsersharePrefixDenyList)
5240 FN_GLOBAL_LIST(lp_eventlog_list, szEventLogs)
5242 FN_GLOBAL_BOOL(lp_registry_shares, bRegistryShares)
5243 FN_GLOBAL_BOOL(lp_usershare_allow_guests, bUsershareAllowGuests)
5244 FN_GLOBAL_BOOL(lp_usershare_owner_only, bUsershareOwnerOnly)
5245 FN_GLOBAL_BOOL(lp_disable_netbios, bDisableNetbios)
5246 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, bResetOnZeroVC)
5247 FN_GLOBAL_BOOL(lp_log_writeable_files_on_exit, bLogWriteableFilesOnExit)
5248 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, bMsAddPrinterWizard)
5249 FN_GLOBAL_BOOL(lp_dns_proxy, bDNSproxy)
5250 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, bWINSsupport)
5251 FN_GLOBAL_BOOL(lp_wins_proxy, bWINSproxy)
5252 FN_GLOBAL_BOOL(lp_local_master, bLocalMaster)
5253 FN_GLOBAL_BOOL(lp_domain_logons, bDomainLogons)
5254 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, szInitLogonDelayedHosts)
5255 FN_GLOBAL_INTEGER(lp_init_logon_delay, InitLogonDelay)
5256 FN_GLOBAL_BOOL(lp_load_printers, bLoadPrinters)
5257 FN_GLOBAL_BOOL(_lp_readraw, bReadRaw)
5258 FN_GLOBAL_BOOL(lp_large_readwrite, bLargeReadwrite)
5259 FN_GLOBAL_BOOL(_lp_writeraw, bWriteRaw)
5260 FN_GLOBAL_BOOL(lp_null_passwords, bNullPasswords)
5261 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, bObeyPamRestrictions)
5262 FN_GLOBAL_BOOL(lp_encrypted_passwords, bEncryptPasswords)
5263 FN_GLOBAL_INTEGER(lp_client_schannel, clientSchannel)
5264 FN_GLOBAL_INTEGER(lp_server_schannel, serverSchannel)
5265 FN_GLOBAL_BOOL(lp_syslog_only, bSyslogOnly)
5266 FN_GLOBAL_BOOL(lp_timestamp_logs, bTimestampLogs)
5267 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, bDebugPrefixTimestamp)
5268 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, bDebugHiresTimestamp)
5269 FN_GLOBAL_BOOL(lp_debug_pid, bDebugPid)
5270 FN_GLOBAL_BOOL(lp_debug_uid, bDebugUid)
5271 FN_GLOBAL_BOOL(lp_debug_class, bDebugClass)
5272 FN_GLOBAL_BOOL(lp_enable_core_files, bEnableCoreFiles)
5273 FN_GLOBAL_BOOL(lp_browse_list, bBrowseList)
5274 FN_GLOBAL_BOOL(lp_nis_home_map, bNISHomeMap)
5275 static FN_GLOBAL_BOOL(lp_time_server, bTimeServer)
5276 FN_GLOBAL_BOOL(lp_bind_interfaces_only, bBindInterfacesOnly)
5277 FN_GLOBAL_BOOL(lp_pam_password_change, bPamPasswordChange)
5278 FN_GLOBAL_BOOL(lp_unix_password_sync, bUnixPasswdSync)
5279 FN_GLOBAL_BOOL(lp_passwd_chat_debug, bPasswdChatDebug)
5280 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, iPasswdChatTimeout)
5281 FN_GLOBAL_BOOL(lp_nt_pipe_support, bNTPipeSupport)
5282 FN_GLOBAL_BOOL(lp_nt_status_support, bNTStatusSupport)
5283 FN_GLOBAL_BOOL(lp_stat_cache, bStatCache)
5284 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, iMaxStatCacheSize)
5285 FN_GLOBAL_BOOL(lp_allow_trusted_domains, bAllowTrustedDomains)
5286 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, bMapUntrustedToDomain)
5287 FN_GLOBAL_INTEGER(lp_restrict_anonymous, restrict_anonymous)
5288 FN_GLOBAL_BOOL(lp_lanman_auth, bLanmanAuth)
5289 FN_GLOBAL_BOOL(lp_ntlm_auth, bNTLMAuth)
5290 FN_GLOBAL_BOOL(lp_client_plaintext_auth, bClientPlaintextAuth)
5291 FN_GLOBAL_BOOL(lp_client_lanman_auth, bClientLanManAuth)
5292 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, bClientNTLMv2Auth)
5293 FN_GLOBAL_BOOL(lp_host_msdfs, bHostMSDfs)
5294 FN_GLOBAL_BOOL(lp_kernel_oplocks, bKernelOplocks)
5295 FN_GLOBAL_BOOL(lp_enhanced_browsing, enhanced_browsing)
5296 FN_GLOBAL_BOOL(lp_use_mmap, bUseMmap)
5297 FN_GLOBAL_BOOL(lp_unix_extensions, bUnixExtensions)
5298 FN_GLOBAL_BOOL(lp_use_spnego, bUseSpnego)
5299 FN_GLOBAL_BOOL(lp_client_use_spnego, bClientUseSpnego)
5300 FN_GLOBAL_BOOL(lp_client_use_spnego_principal, client_use_spnego_principal)
5301 FN_GLOBAL_BOOL(lp_send_spnego_principal, send_spnego_principal)
5302 FN_GLOBAL_BOOL(lp_hostname_lookups, bHostnameLookups)
5303 FN_GLOBAL_CONST_STRING(lp_dedicated_keytab_file, szDedicatedKeytabFile)
5304 FN_GLOBAL_INTEGER(lp_kerberos_method, iKerberosMethod)
5305 FN_GLOBAL_BOOL(lp_defer_sharing_violations, bDeferSharingViolations)
5306 FN_GLOBAL_BOOL(lp_enable_privileges, bEnablePrivileges)
5307 FN_GLOBAL_BOOL(lp_enable_asu_support, bASUSupport)
5308 FN_GLOBAL_INTEGER(lp_os_level, os_level)
5309 FN_GLOBAL_INTEGER(lp_max_ttl, max_ttl)
5310 FN_GLOBAL_INTEGER(lp_max_wins_ttl, max_wins_ttl)
5311 FN_GLOBAL_INTEGER(lp_min_wins_ttl, min_wins_ttl)
5312 FN_GLOBAL_INTEGER(lp_max_log_size, max_log_size)
5313 FN_GLOBAL_INTEGER(lp_max_open_files, max_open_files)
5314 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, open_files_db_hash_size)
5315 FN_GLOBAL_INTEGER(lp_maxxmit, max_xmit)
5316 FN_GLOBAL_INTEGER(lp_maxmux, max_mux)
5317 FN_GLOBAL_INTEGER(lp_passwordlevel, pwordlevel)
5318 FN_GLOBAL_INTEGER(lp_usernamelevel, unamelevel)
5319 FN_GLOBAL_INTEGER(lp_deadtime, deadtime)
5320 FN_GLOBAL_BOOL(lp_getwd_cache, getwd_cache)
5321 static FN_GLOBAL_INTEGER(_lp_maxprotocol, maxprotocol)
5322 int lp_maxprotocol(void)
5324 int ret = _lp_maxprotocol();
5325 if ((ret >= PROTOCOL_SMB2_02) && (lp_security() == SEC_SHARE)) {
5326 DEBUG(2,("WARNING!!: \"security = share\" is incompatible "
5327 "with the SMB2 protocol. Resetting to SMB1.\n" ));
5328 lp_do_parameter(-1, "max protocol", "NT1");
5329 return PROTOCOL_NT1;
5333 FN_GLOBAL_INTEGER(lp_minprotocol, minprotocol)
5334 FN_GLOBAL_INTEGER(lp_security, security)
5335 FN_GLOBAL_LIST(lp_auth_methods, AuthMethods)
5336 FN_GLOBAL_BOOL(lp_paranoid_server_security, paranoid_server_security)
5337 FN_GLOBAL_INTEGER(lp_maxdisksize, maxdisksize)
5338 FN_GLOBAL_INTEGER(lp_lpqcachetime, lpqcachetime)
5339 FN_GLOBAL_INTEGER(lp_max_smbd_processes, iMaxSmbdProcesses)
5340 FN_GLOBAL_BOOL(_lp_disable_spoolss, bDisableSpoolss)
5341 FN_GLOBAL_INTEGER(lp_syslog, syslog)
5342 FN_GLOBAL_INTEGER(lp_lm_announce, lm_announce)
5343 FN_GLOBAL_INTEGER(lp_lm_interval, lm_interval)
5344 FN_GLOBAL_INTEGER(lp_machine_password_timeout, machine_password_timeout)
5345 FN_GLOBAL_INTEGER(lp_map_to_guest, map_to_guest)
5346 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, oplock_break_wait_time)
5347 FN_GLOBAL_INTEGER(lp_lock_spin_time, iLockSpinTime)
5348 FN_GLOBAL_INTEGER(lp_usershare_max_shares, iUsershareMaxShares)
5349 FN_GLOBAL_CONST_STRING(lp_socket_options, szSocketOptions)
5350 FN_GLOBAL_INTEGER(lp_config_backend, ConfigBackend)
5351 FN_GLOBAL_INTEGER(lp_smb2_max_read, ismb2_max_read)
5352 FN_GLOBAL_INTEGER(lp_smb2_max_write, ismb2_max_write)
5353 FN_GLOBAL_INTEGER(lp_smb2_max_trans, ismb2_max_trans)
5354 int lp_smb2_max_credits(void)
5356 if (Globals.ismb2_max_credits == 0) {
5357 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5359 return Globals.ismb2_max_credits;
5361 FN_GLOBAL_LIST(lp_svcctl_list, szServicesList)
5362 FN_GLOBAL_STRING(lp_cups_server, szCupsServer)
5363 int lp_cups_encrypt(void)
5366 #ifdef HAVE_HTTPCONNECTENCRYPT
5367 switch (Globals.CupsEncrypt) {
5369 result = HTTP_ENCRYPT_REQUIRED;
5372 result = HTTP_ENCRYPT_ALWAYS;
5375 result = HTTP_ENCRYPT_NEVER;
5381 FN_GLOBAL_STRING(lp_iprint_server, szIPrintServer)
5382 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, cups_connection_timeout)
5383 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, ctdbdSocket)
5384 FN_GLOBAL_LIST(lp_cluster_addresses, szClusterAddresses)
5385 FN_GLOBAL_BOOL(lp_clustering, clustering)
5386 FN_GLOBAL_INTEGER(lp_ctdb_timeout, ctdb_timeout)
5387 FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, ctdb_locktime_warn_threshold)
5388 FN_GLOBAL_BOOL(lp_async_smb_echo_handler, bAsyncSMBEchoHandler)
5389 FN_GLOBAL_BOOL(lp_multicast_dns_register, bMulticastDnsRegister)
5390 FN_GLOBAL_INTEGER(lp_winbind_cache_time, winbind_cache_time)
5391 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, winbind_reconnect_delay)
5392 FN_GLOBAL_INTEGER(lp_winbind_max_clients, winbind_max_clients)
5393 FN_GLOBAL_LIST(lp_winbind_nss_info, szWinbindNssInfo)
5394 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, AlgorithmicRidBase)
5395 FN_GLOBAL_INTEGER(lp_name_cache_timeout, name_cache_timeout)
5396 FN_GLOBAL_INTEGER(lp_client_signing, client_signing)
5397 FN_GLOBAL_INTEGER(lp_server_signing, server_signing)
5398 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, client_ldap_sasl_wrapping)
5400 FN_GLOBAL_CONST_STRING(lp_ncalrpc_dir, ncalrpc_dir)
5402 #include "lib/param/param_functions.c"
5404 FN_LOCAL_STRING(servicename, szService)
5405 FN_LOCAL_CONST_STRING(const_servicename, szService)
5407 /* local prototypes */
5409 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5410 static const char *get_boolean(bool bool_value);
5411 static int getservicebyname(const char *pszServiceName,
5412 struct loadparm_service *pserviceDest);
5413 static void copy_service(struct loadparm_service *pserviceDest,
5414 struct loadparm_service *pserviceSource,
5415 struct bitmap *pcopymapDest);
5416 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5418 static bool do_section(const char *pszSectionName, void *userdata);
5419 static void init_copymap(struct loadparm_service *pservice);
5420 static bool hash_a_service(const char *name, int number);
5421 static void free_service_byindex(int iService);
5422 static void free_param_opts(struct parmlist_entry **popts);
5423 static void show_parameter(int parmIndex);
5424 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5427 * This is a helper function for parametrical options support. It returns a
5428 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5429 * parametrical functions are quite simple
5431 static struct parmlist_entry *get_parametrics_by_service(struct loadparm_service *service, const char *type,
5434 bool global_section = false;
5436 struct parmlist_entry *data;
5438 if (service == NULL) {
5439 data = Globals.param_opt;
5440 global_section = true;
5442 data = service->param_opt;
5445 if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
5446 DEBUG(0,("asprintf failed!\n"));
5451 if (strwicmp(data->key, param_key) == 0) {
5452 string_free(¶m_key);
5458 if (!global_section) {
5459 /* Try to fetch the same option but from globals */
5460 /* but only if we are not already working with Globals */
5461 data = Globals.param_opt;
5463 if (strwicmp(data->key, param_key) == 0) {
5464 string_free(¶m_key);
5471 string_free(¶m_key);
5477 * This is a helper function for parametrical options support. It returns a
5478 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5479 * parametrical functions are quite simple
5481 static struct parmlist_entry *get_parametrics(int snum, const char *type,
5484 if (snum >= iNumServices) return NULL;
5487 return get_parametrics_by_service(NULL, type, option);
5489 return get_parametrics_by_service(ServicePtrs[snum], type, option);
5494 #define MISSING_PARAMETER(name) \
5495 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5497 /*******************************************************************
5498 convenience routine to return int parameters.
5499 ********************************************************************/
5500 static int lp_int(const char *s)
5504 MISSING_PARAMETER(lp_int);
5508 return (int)strtol(s, NULL, 0);
5511 /*******************************************************************
5512 convenience routine to return unsigned long parameters.
5513 ********************************************************************/
5514 static unsigned long lp_ulong(const char *s)
5518 MISSING_PARAMETER(lp_ulong);
5522 return strtoul(s, NULL, 0);
5525 /*******************************************************************
5526 convenience routine to return boolean parameters.
5527 ********************************************************************/
5528 static bool lp_bool(const char *s)
5533 MISSING_PARAMETER(lp_bool);
5537 if (!set_boolean(s, &ret)) {
5538 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5545 /*******************************************************************
5546 convenience routine to return enum parameters.
5547 ********************************************************************/
5548 static int lp_enum(const char *s,const struct enum_list *_enum)
5552 if (!s || !*s || !_enum) {
5553 MISSING_PARAMETER(lp_enum);
5557 for (i=0; _enum[i].name; i++) {
5558 if (strequal(_enum[i].name,s))
5559 return _enum[i].value;
5562 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5566 #undef MISSING_PARAMETER
5568 /* Return parametric option from a given service. Type is a part of option before ':' */
5569 /* Parametric option has following syntax: 'Type: option = value' */
5570 /* the returned value is talloced on the talloc_tos() */
5571 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5573 struct parmlist_entry *data = get_parametrics(snum, type, option);
5575 if (data == NULL||data->value==NULL) {
5577 return lp_string(def);
5583 return lp_string(data->value);
5586 /* Return parametric option from a given service. Type is a part of option before ':' */
5587 /* Parametric option has following syntax: 'Type: option = value' */
5588 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5590 struct parmlist_entry *data = get_parametrics(snum, type, option);
5592 if (data == NULL||data->value==NULL)
5598 const char *lp_parm_const_string_service(struct loadparm_service *service, const char *type, const char *option)
5600 struct parmlist_entry *data = get_parametrics_by_service(service, type, option);
5602 if (data == NULL||data->value==NULL)
5609 /* Return parametric option from a given service. Type is a part of option before ':' */
5610 /* Parametric option has following syntax: 'Type: option = value' */
5612 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5614 struct parmlist_entry *data = get_parametrics(snum, type, option);
5616 if (data == NULL||data->value==NULL)
5617 return (const char **)def;
5619 if (data->list==NULL) {
5620 data->list = str_list_make_v3(NULL, data->value, NULL);
5623 return (const char **)data->list;
5626 /* Return parametric option from a given service. Type is a part of option before ':' */
5627 /* Parametric option has following syntax: 'Type: option = value' */
5629 int lp_parm_int(int snum, const char *type, const char *option, int def)
5631 struct parmlist_entry *data = get_parametrics(snum, type, option);
5633 if (data && data->value && *data->value)
5634 return lp_int(data->value);
5639 /* Return parametric option from a given service. Type is a part of option before ':' */
5640 /* Parametric option has following syntax: 'Type: option = value' */
5642 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5644 struct parmlist_entry *data = get_parametrics(snum, type, option);
5646 if (data && data->value && *data->value)
5647 return lp_ulong(data->value);
5652 /* Return parametric option from a given service. Type is a part of option before ':' */
5653 /* Parametric option has following syntax: 'Type: option = value' */
5655 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5657 struct parmlist_entry *data = get_parametrics(snum, type, option);
5659 if (data && data->value && *data->value)
5660 return lp_bool(data->value);
5665 /* Return parametric option from a given service. Type is a part of option before ':' */
5666 /* Parametric option has following syntax: 'Type: option = value' */
5668 int lp_parm_enum(int snum, const char *type, const char *option,
5669 const struct enum_list *_enum, int def)
5671 struct parmlist_entry *data = get_parametrics(snum, type, option);
5673 if (data && data->value && *data->value && _enum)
5674 return lp_enum(data->value, _enum);
5680 /***************************************************************************
5681 Initialise a service to the defaults.
5682 ***************************************************************************/
5684 static void init_service(struct loadparm_service *pservice)
5686 memset((char *)pservice, '\0', sizeof(struct loadparm_service));
5687 copy_service(pservice, &sDefault, NULL);
5692 * free a param_opts structure.
5693 * param_opts handling should be moved to talloc;
5694 * then this whole functions reduces to a TALLOC_FREE().
5697 static void free_param_opts(struct parmlist_entry **popts)
5699 struct parmlist_entry *opt, *next_opt;
5701 if (popts == NULL) {
5705 if (*popts != NULL) {
5706 DEBUG(5, ("Freeing parametrics:\n"));
5709 while (opt != NULL) {
5710 string_free(&opt->key);
5711 string_free(&opt->value);
5712 TALLOC_FREE(opt->list);
5713 next_opt = opt->next;
5720 /***************************************************************************
5721 Free the dynamically allocated parts of a service struct.
5722 ***************************************************************************/
5724 static void free_service(struct loadparm_service *pservice)
5729 if (pservice->szService)
5730 DEBUG(5, ("free_service: Freeing service %s\n",
5731 pservice->szService));
5733 free_parameters(pservice);
5735 string_free(&pservice->szService);
5736 TALLOC_FREE(pservice->copymap);
5738 free_param_opts(&pservice->param_opt);
5740 ZERO_STRUCTP(pservice);
5744 /***************************************************************************
5745 remove a service indexed in the ServicePtrs array from the ServiceHash
5746 and free the dynamically allocated parts
5747 ***************************************************************************/
5749 static void free_service_byindex(int idx)
5751 if ( !LP_SNUM_OK(idx) )
5754 ServicePtrs[idx]->valid = false;
5755 invalid_services[num_invalid_services++] = idx;
5757 /* we have to cleanup the hash record */
5759 if (ServicePtrs[idx]->szService) {
5760 char *canon_name = canonicalize_servicename(
5762 ServicePtrs[idx]->szService );
5764 dbwrap_delete_bystring(ServiceHash, canon_name );
5765 TALLOC_FREE(canon_name);
5768 free_service(ServicePtrs[idx]);
5771 /***************************************************************************
5772 Add a new service to the services array initialising it with the given
5774 ***************************************************************************/
5776 static int add_a_service(const struct loadparm_service *pservice, const char *name)
5779 struct loadparm_service tservice;
5780 int num_to_alloc = iNumServices + 1;
5782 tservice = *pservice;
5784 /* it might already exist */
5786 i = getservicebyname(name, NULL);
5792 /* find an invalid one */
5794 if (num_invalid_services > 0) {
5795 i = invalid_services[--num_invalid_services];
5798 /* if not, then create one */
5799 if (i == iNumServices) {
5800 struct loadparm_service **tsp;
5803 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct loadparm_service *, num_to_alloc);
5805 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
5809 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct loadparm_service);
5810 if (!ServicePtrs[iNumServices]) {
5811 DEBUG(0,("add_a_service: out of memory!\n"));
5816 /* enlarge invalid_services here for now... */
5817 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
5819 if (tinvalid == NULL) {
5820 DEBUG(0,("add_a_service: failed to enlarge "
5821 "invalid_services!\n"));
5824 invalid_services = tinvalid;
5826 free_service_byindex(i);
5829 ServicePtrs[i]->valid = true;
5831 init_service(ServicePtrs[i]);
5832 copy_service(ServicePtrs[i], &tservice, NULL);
5834 string_set(&ServicePtrs[i]->szService, name);
5836 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
5837 i, ServicePtrs[i]->szService));
5839 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
5846 /***************************************************************************
5847 Convert a string to uppercase and remove whitespaces.
5848 ***************************************************************************/
5850 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
5855 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
5859 result = talloc_strdup(ctx, src);
5860 SMB_ASSERT(result != NULL);
5866 /***************************************************************************
5867 Add a name/index pair for the services array to the hash table.
5868 ***************************************************************************/
5870 static bool hash_a_service(const char *name, int idx)
5874 if ( !ServiceHash ) {
5875 DEBUG(10,("hash_a_service: creating servicehash\n"));
5876 ServiceHash = db_open_rbt(NULL);
5877 if ( !ServiceHash ) {
5878 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
5883 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
5886 canon_name = canonicalize_servicename(talloc_tos(), name );
5888 dbwrap_store_bystring(ServiceHash, canon_name,
5889 make_tdb_data((uint8 *)&idx, sizeof(idx)),
5892 TALLOC_FREE(canon_name);
5897 /***************************************************************************
5898 Add a new home service, with the specified home directory, defaults coming
5900 ***************************************************************************/
5902 bool lp_add_home(const char *pszHomename, int iDefaultService,
5903 const char *user, const char *pszHomedir)
5907 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
5908 pszHomedir[0] == '\0') {
5912 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
5917 if (!(*(ServicePtrs[iDefaultService]->szPath))
5918 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
5919 string_set(&ServicePtrs[i]->szPath, pszHomedir);
5922 if (!(*(ServicePtrs[i]->comment))) {
5923 char *comment = NULL;
5924 if (asprintf(&comment, "Home directory of %s", user) < 0) {
5927 string_set(&ServicePtrs[i]->comment, comment);
5931 /* set the browseable flag from the global default */
5933 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5934 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
5936 ServicePtrs[i]->autoloaded = true;
5938 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
5939 user, ServicePtrs[i]->szPath ));
5944 /***************************************************************************
5945 Add a new service, based on an old one.
5946 ***************************************************************************/
5948 int lp_add_service(const char *pszService, int iDefaultService)
5950 if (iDefaultService < 0) {
5951 return add_a_service(&sDefault, pszService);
5954 return (add_a_service(ServicePtrs[iDefaultService], pszService));
5957 /***************************************************************************
5958 Add the IPC service.
5959 ***************************************************************************/
5961 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
5963 char *comment = NULL;
5964 int i = add_a_service(&sDefault, ipc_name);
5969 if (asprintf(&comment, "IPC Service (%s)",
5970 Globals.szServerString) < 0) {
5974 string_set(&ServicePtrs[i]->szPath, tmpdir());
5975 string_set(&ServicePtrs[i]->szUsername, "");
5976 string_set(&ServicePtrs[i]->comment, comment);
5977 string_set(&ServicePtrs[i]->fstype, "IPC");
5978 ServicePtrs[i]->iMaxConnections = 0;
5979 ServicePtrs[i]->bAvailable = true;
5980 ServicePtrs[i]->bRead_only = true;
5981 ServicePtrs[i]->bGuest_only = false;
5982 ServicePtrs[i]->bAdministrative_share = true;
5983 ServicePtrs[i]->bGuest_ok = guest_ok;
5984 ServicePtrs[i]->bPrint_ok = false;
5985 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5987 DEBUG(3, ("adding IPC service\n"));
5993 /***************************************************************************
5994 Add a new printer service, with defaults coming from service iFrom.
5995 ***************************************************************************/
5997 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
5999 const char *comment = "From Printcap";
6000 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6005 /* note that we do NOT default the availability flag to true - */
6006 /* we take it from the default service passed. This allows all */
6007 /* dynamic printers to be disabled by disabling the [printers] */
6008 /* entry (if/when the 'available' keyword is implemented!). */
6010 /* the printer name is set to the service name. */
6011 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6012 string_set(&ServicePtrs[i]->comment, comment);
6014 /* set the browseable flag from the gloabl default */
6015 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6017 /* Printers cannot be read_only. */
6018 ServicePtrs[i]->bRead_only = false;
6019 /* No share modes on printer services. */
6020 ServicePtrs[i]->bShareModes = false;
6021 /* No oplocks on printer services. */
6022 ServicePtrs[i]->bOpLocks = false;
6023 /* Printer services must be printable. */
6024 ServicePtrs[i]->bPrint_ok = true;
6026 DEBUG(3, ("adding printer service %s\n", pszPrintername));
6032 /***************************************************************************
6033 Check whether the given parameter name is valid.
6034 Parametric options (names containing a colon) are considered valid.
6035 ***************************************************************************/
6037 bool lp_parameter_is_valid(const char *pszParmName)
6039 return ((map_parameter(pszParmName) != -1) ||
6040 (strchr(pszParmName, ':') != NULL));
6043 /***************************************************************************
6044 Check whether the given name is the name of a global parameter.
6045 Returns true for strings belonging to parameters of class
6046 P_GLOBAL, false for all other strings, also for parametric options
6047 and strings not belonging to any option.
6048 ***************************************************************************/
6050 bool lp_parameter_is_global(const char *pszParmName)
6052 int num = map_parameter(pszParmName);
6055 return (parm_table[num].p_class == P_GLOBAL);
6061 /**************************************************************************
6062 Check whether the given name is the canonical name of a parameter.
6063 Returns false if it is not a valid parameter Name.
6064 For parametric options, true is returned.
6065 **************************************************************************/
6067 bool lp_parameter_is_canonical(const char *parm_name)
6069 if (!lp_parameter_is_valid(parm_name)) {
6073 return (map_parameter(parm_name) ==
6074 map_parameter_canonical(parm_name, NULL));
6077 /**************************************************************************
6078 Determine the canonical name for a parameter.
6079 Indicate when it is an inverse (boolean) synonym instead of a
6081 **************************************************************************/
6083 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6088 if (!lp_parameter_is_valid(parm_name)) {
6093 num = map_parameter_canonical(parm_name, inverse);
6095 /* parametric option */
6096 *canon_parm = parm_name;
6098 *canon_parm = parm_table[num].label;
6105 /**************************************************************************
6106 Determine the canonical name for a parameter.
6107 Turn the value given into the inverse boolean expression when
6108 the synonym is an invers boolean synonym.
6110 Return true if parm_name is a valid parameter name and
6111 in case it is an invers boolean synonym, if the val string could
6112 successfully be converted to the reverse bool.
6113 Return false in all other cases.
6114 **************************************************************************/
6116 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6118 const char **canon_parm,
6119 const char **canon_val)
6124 if (!lp_parameter_is_valid(parm_name)) {
6130 num = map_parameter_canonical(parm_name, &inverse);
6132 /* parametric option */
6133 *canon_parm = parm_name;
6136 *canon_parm = parm_table[num].label;
6138 if (!lp_invert_boolean(val, canon_val)) {
6150 /***************************************************************************
6151 Map a parameter's string representation to something we can use.
6152 Returns false if the parameter string is not recognised, else TRUE.
6153 ***************************************************************************/
6155 static int map_parameter(const char *pszParmName)
6159 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6162 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6163 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6166 /* Warn only if it isn't parametric option */
6167 if (strchr(pszParmName, ':') == NULL)
6168 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6169 /* We do return 'fail' for parametric options as well because they are
6170 stored in different storage
6175 /***************************************************************************
6176 Map a parameter's string representation to the index of the canonical
6177 form of the parameter (it might be a synonym).
6178 Returns -1 if the parameter string is not recognised.
6179 ***************************************************************************/
6181 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6183 int parm_num, canon_num;
6184 bool loc_inverse = false;
6186 parm_num = map_parameter(pszParmName);
6187 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6188 /* invalid, parametric or no canidate for synonyms ... */
6192 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6193 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6194 parm_num = canon_num;
6200 if (inverse != NULL) {
6201 *inverse = loc_inverse;
6206 /***************************************************************************
6207 return true if parameter number parm1 is a synonym of parameter
6208 number parm2 (parm2 being the principal name).
6209 set inverse to true if parm1 is P_BOOLREV and parm2 is P_BOOL,
6211 ***************************************************************************/
6213 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6215 if ((parm_table[parm1].offset == parm_table[parm2].offset) &&
6216 (parm_table[parm1].p_class == parm_table[parm2].p_class) &&
6217 (parm_table[parm1].flags & FLAG_HIDE) &&
6218 !(parm_table[parm2].flags & FLAG_HIDE))
6220 if (inverse != NULL) {
6221 if ((parm_table[parm1].type == P_BOOLREV) &&
6222 (parm_table[parm2].type == P_BOOL))
6234 /***************************************************************************
6235 Show one parameter's name, type, [values,] and flags.
6236 (helper functions for show_parameter_list)
6237 ***************************************************************************/
6239 static void show_parameter(int parmIndex)
6241 int enumIndex, flagIndex;
6246 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6247 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6249 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6250 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6252 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6253 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6254 "FLAG_DEPRECATED", "FLAG_HIDE", NULL};
6256 printf("%s=%s", parm_table[parmIndex].label,
6257 type[parm_table[parmIndex].type]);
6258 if (parm_table[parmIndex].type == P_ENUM) {
6261 parm_table[parmIndex].enum_list[enumIndex].name;
6265 enumIndex ? "|" : "",
6266 parm_table[parmIndex].enum_list[enumIndex].name);
6271 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6272 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6275 flag_names[flagIndex]);
6280 /* output synonyms */
6282 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6283 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6284 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6285 parm_table[parmIndex2].label);
6286 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6288 printf(" (synonyms: ");
6293 printf("%s%s", parm_table[parmIndex2].label,
6294 inverse ? "[i]" : "");
6304 /***************************************************************************
6305 Show all parameter's name, type, [values,] and flags.
6306 ***************************************************************************/
6308 void show_parameter_list(void)
6310 int classIndex, parmIndex;
6311 const char *section_names[] = { "local", "global", NULL};
6313 for (classIndex=0; section_names[classIndex]; classIndex++) {
6314 printf("[%s]\n", section_names[classIndex]);
6315 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6316 if (parm_table[parmIndex].p_class == classIndex) {
6317 show_parameter(parmIndex);
6323 /***************************************************************************
6324 Check if a given string correctly represents a boolean value.
6325 ***************************************************************************/
6327 bool lp_string_is_valid_boolean(const char *parm_value)
6329 return set_boolean(parm_value, NULL);
6332 /***************************************************************************
6333 Get the standard string representation of a boolean value ("yes" or "no")
6334 ***************************************************************************/
6336 static const char *get_boolean(bool bool_value)
6338 static const char *yes_str = "yes";
6339 static const char *no_str = "no";
6341 return (bool_value ? yes_str : no_str);
6344 /***************************************************************************
6345 Provide the string of the negated boolean value associated to the boolean
6346 given as a string. Returns false if the passed string does not correctly
6347 represent a boolean.
6348 ***************************************************************************/
6350 bool lp_invert_boolean(const char *str, const char **inverse_str)
6354 if (!set_boolean(str, &val)) {
6358 *inverse_str = get_boolean(!val);
6362 /***************************************************************************
6363 Provide the canonical string representation of a boolean value given
6364 as a string. Return true on success, false if the string given does
6365 not correctly represent a boolean.
6366 ***************************************************************************/
6368 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6372 if (!set_boolean(str, &val)) {
6376 *canon_str = get_boolean(val);
6380 /***************************************************************************
6381 Find a service by name. Otherwise works like get_service.
6382 ***************************************************************************/
6384 static int getservicebyname(const char *pszServiceName, struct loadparm_service *pserviceDest)
6390 if (ServiceHash == NULL) {
6394 canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
6396 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
6398 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
6399 iService = *(int *)data.dptr;
6402 TALLOC_FREE(canon_name);
6404 if ((iService != -1) && (LP_SNUM_OK(iService))
6405 && (pserviceDest != NULL)) {
6406 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6412 /* Return a pointer to a service by name. Unlike getservicebyname, it does not copy the service */
6413 struct loadparm_service *lp_service(const char *pszServiceName)
6415 int iService = getservicebyname(pszServiceName, NULL);
6416 if (iService == -1 || !LP_SNUM_OK(iService)) {
6419 return ServicePtrs[iService];
6422 struct loadparm_service *lp_servicebynum(int snum)
6424 if ((snum == -1) || !LP_SNUM_OK(snum)) {
6427 return ServicePtrs[snum];
6430 struct loadparm_service *lp_default_loadparm_service()
6436 /***************************************************************************
6437 Copy a service structure to another.
6438 If pcopymapDest is NULL then copy all fields
6439 ***************************************************************************/
6442 * Add a parametric option to a parmlist_entry,
6443 * replacing old value, if already present.
6445 static void set_param_opt(struct parmlist_entry **opt_list,
6446 const char *opt_name,
6447 const char *opt_value,
6450 struct parmlist_entry *new_opt, *opt;
6453 if (opt_list == NULL) {
6460 /* Traverse destination */
6462 /* If we already have same option, override it */
6463 if (strwicmp(opt->key, opt_name) == 0) {
6464 if ((opt->priority & FLAG_CMDLINE) &&
6465 !(priority & FLAG_CMDLINE)) {
6466 /* it's been marked as not to be
6470 string_free(&opt->value);
6471 TALLOC_FREE(opt->list);
6472 opt->value = SMB_STRDUP(opt_value);
6473 opt->priority = priority;
6480 new_opt = SMB_XMALLOC_P(struct parmlist_entry);
6481 new_opt->key = SMB_STRDUP(opt_name);
6482 new_opt->value = SMB_STRDUP(opt_value);
6483 new_opt->list = NULL;
6484 new_opt->priority = priority;
6485 DLIST_ADD(*opt_list, new_opt);
6489 static void copy_service(struct loadparm_service *pserviceDest, struct loadparm_service *pserviceSource,
6490 struct bitmap *pcopymapDest)
6493 bool bcopyall = (pcopymapDest == NULL);
6494 struct parmlist_entry *data;
6496 for (i = 0; parm_table[i].label; i++)
6497 if (parm_table[i].p_class == P_LOCAL &&
6498 (bcopyall || bitmap_query(pcopymapDest,i))) {
6499 void *src_ptr = lp_parm_ptr(pserviceSource, &parm_table[i]);
6500 void *dest_ptr = lp_parm_ptr(pserviceDest, &parm_table[i]);
6502 switch (parm_table[i].type) {
6505 *(bool *)dest_ptr = *(bool *)src_ptr;
6511 *(int *)dest_ptr = *(int *)src_ptr;
6515 *(char *)dest_ptr = *(char *)src_ptr;
6519 string_set((char **)dest_ptr,
6525 char *upper_string = strupper_talloc(talloc_tos(),
6527 string_set((char **)dest_ptr,
6529 TALLOC_FREE(upper_string);
6533 TALLOC_FREE(*((char ***)dest_ptr));
6534 *((char ***)dest_ptr) = str_list_copy(NULL,
6535 *(const char ***)src_ptr);
6543 init_copymap(pserviceDest);
6544 if (pserviceSource->copymap)
6545 bitmap_copy(pserviceDest->copymap,
6546 pserviceSource->copymap);
6549 data = pserviceSource->param_opt;
6551 set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->priority);
6556 /***************************************************************************
6557 Check a service for consistency. Return false if the service is in any way
6558 incomplete or faulty, else true.
6559 ***************************************************************************/
6561 bool service_ok(int iService)
6566 if (ServicePtrs[iService]->szService[0] == '\0') {
6567 DEBUG(0, ("The following message indicates an internal error:\n"));
6568 DEBUG(0, ("No service name in service entry.\n"));
6572 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6573 /* I can't see why you'd want a non-printable printer service... */
6574 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6575 if (!ServicePtrs[iService]->bPrint_ok) {
6576 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6577 ServicePtrs[iService]->szService));
6578 ServicePtrs[iService]->bPrint_ok = true;
6580 /* [printers] service must also be non-browsable. */
6581 if (ServicePtrs[iService]->bBrowseable)
6582 ServicePtrs[iService]->bBrowseable = false;
6585 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6586 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6587 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6589 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6590 ServicePtrs[iService]->szService));
6591 ServicePtrs[iService]->bAvailable = false;
6594 /* If a service is flagged unavailable, log the fact at level 1. */
6595 if (!ServicePtrs[iService]->bAvailable)
6596 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6597 ServicePtrs[iService]->szService));
6602 static struct smbconf_ctx *lp_smbconf_ctx(void)
6605 static struct smbconf_ctx *conf_ctx = NULL;
6607 if (conf_ctx == NULL) {
6608 err = smbconf_init(NULL, &conf_ctx, "registry:");
6609 if (!SBC_ERROR_IS_OK(err)) {
6610 DEBUG(1, ("error initializing registry configuration: "
6611 "%s\n", sbcErrorString(err)));
6619 static bool process_smbconf_service(struct smbconf_service *service)
6624 if (service == NULL) {
6628 ret = do_section(service->name, NULL);
6632 for (count = 0; count < service->num_params; count++) {
6633 ret = do_parameter(service->param_names[count],
6634 service->param_values[count],
6640 if (iServiceIndex >= 0) {
6641 return service_ok(iServiceIndex);
6647 * load a service from registry and activate it
6649 bool process_registry_service(const char *service_name)
6652 struct smbconf_service *service = NULL;
6653 TALLOC_CTX *mem_ctx = talloc_stackframe();
6654 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6657 if (conf_ctx == NULL) {
6661 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6663 if (!smbconf_share_exists(conf_ctx, service_name)) {
6665 * Registry does not contain data for this service (yet),
6666 * but make sure lp_load doesn't return false.
6672 err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6673 if (!SBC_ERROR_IS_OK(err)) {
6677 ret = process_smbconf_service(service);
6683 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6686 TALLOC_FREE(mem_ctx);
6691 * process_registry_globals
6693 static bool process_registry_globals(void)
6697 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6699 ret = do_parameter("registry shares", "yes", NULL);
6704 return process_registry_service(GLOBAL_NAME);
6707 bool process_registry_shares(void)
6711 struct smbconf_service **service = NULL;
6712 uint32_t num_shares = 0;
6713 TALLOC_CTX *mem_ctx = talloc_stackframe();
6714 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6717 if (conf_ctx == NULL) {
6721 err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6722 if (!SBC_ERROR_IS_OK(err)) {
6728 for (count = 0; count < num_shares; count++) {
6729 if (strequal(service[count]->name, GLOBAL_NAME)) {
6732 ret = process_smbconf_service(service[count]);
6739 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6742 TALLOC_FREE(mem_ctx);
6746 #define MAX_INCLUDE_DEPTH 100
6748 static uint8_t include_depth;
6750 static struct file_lists {
6751 struct file_lists *next;
6755 } *file_lists = NULL;
6757 /*******************************************************************
6758 Keep a linked list of all config files so we know when one has changed
6759 it's date and needs to be reloaded.
6760 ********************************************************************/
6762 static void add_to_file_list(const char *fname, const char *subfname)
6764 struct file_lists *f = file_lists;
6767 if (f->name && !strcmp(f->name, fname))
6773 f = SMB_MALLOC_P(struct file_lists);
6776 f->next = file_lists;
6777 f->name = SMB_STRDUP(fname);
6782 f->subfname = SMB_STRDUP(subfname);
6789 f->modtime = file_modtime(subfname);
6791 time_t t = file_modtime(subfname);
6799 * Free the file lists
6801 static void free_file_list(void)
6803 struct file_lists *f;
6804 struct file_lists *next;
6809 SAFE_FREE( f->name );
6810 SAFE_FREE( f->subfname );
6819 * Utility function for outsiders to check if we're running on registry.
6821 bool lp_config_backend_is_registry(void)
6823 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
6827 * Utility function to check if the config backend is FILE.
6829 bool lp_config_backend_is_file(void)
6831 return (lp_config_backend() == CONFIG_BACKEND_FILE);
6834 /*******************************************************************
6835 Check if a config file has changed date.
6836 ********************************************************************/
6838 bool lp_file_list_changed(void)
6840 struct file_lists *f = file_lists;
6842 DEBUG(6, ("lp_file_list_changed()\n"));
6847 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
6848 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6850 if (conf_ctx == NULL) {
6853 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
6856 DEBUGADD(6, ("registry config changed\n"));
6861 n2 = talloc_sub_basic(talloc_tos(),
6862 get_current_username(),
6863 current_user_info.domain,
6868 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
6869 f->name, n2, ctime(&f->modtime)));
6871 mod_time = file_modtime(n2);
6874 ((f->modtime != mod_time) ||
6875 (f->subfname == NULL) ||
6876 (strcmp(n2, f->subfname) != 0)))
6879 ("file %s modified: %s\n", n2,
6881 f->modtime = mod_time;
6882 SAFE_FREE(f->subfname);
6883 f->subfname = SMB_STRDUP(n2);
6896 * Initialize iconv conversion descriptors.
6898 * This is called the first time it is needed, and also called again
6899 * every time the configuration is reloaded, because the charset or
6900 * codepage might have changed.
6902 static void init_iconv(void)
6904 global_iconv_handle = smb_iconv_handle_reinit(NULL, lp_dos_charset(),
6906 true, global_iconv_handle);
6909 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6911 if (strcmp(*ptr, pszParmValue) != 0) {
6912 string_set(ptr, pszParmValue);
6918 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6920 bool is_utf8 = false;
6921 size_t len = strlen(pszParmValue);
6923 if (len == 4 || len == 5) {
6924 /* Don't use StrCaseCmp here as we don't want to
6925 initialize iconv. */
6926 if ((toupper_m(pszParmValue[0]) == 'U') &&
6927 (toupper_m(pszParmValue[1]) == 'T') &&
6928 (toupper_m(pszParmValue[2]) == 'F')) {
6930 if (pszParmValue[3] == '8') {
6934 if (pszParmValue[3] == '-' &&
6935 pszParmValue[4] == '8') {
6942 if (strcmp(*ptr, pszParmValue) != 0) {
6944 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
6945 "be UTF8, using (default value) %s instead.\n",
6946 DEFAULT_DOS_CHARSET));
6947 pszParmValue = DEFAULT_DOS_CHARSET;
6949 string_set(ptr, pszParmValue);
6955 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6958 char *realm = strupper_talloc(talloc_tos(), pszParmValue);
6959 char *dnsdomain = strlower_talloc(talloc_tos(), pszParmValue);
6961 ret &= string_set(&Globals.szRealm, pszParmValue);
6962 ret &= string_set(&Globals.szRealmUpper, realm);
6963 ret &= string_set(&Globals.szDnsDomain, dnsdomain);
6965 TALLOC_FREE(dnsdomain);
6970 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6972 TALLOC_FREE(Globals.szNetbiosAliases);
6973 Globals.szNetbiosAliases = (const char **)str_list_make_v3(NULL, pszParmValue, NULL);
6974 return set_netbios_aliases(Globals.szNetbiosAliases);
6977 /***************************************************************************
6978 Handle the include operation.
6979 ***************************************************************************/
6980 static bool bAllowIncludeRegistry = true;
6982 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6986 if (include_depth >= MAX_INCLUDE_DEPTH) {
6987 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
6992 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
6993 if (!bAllowIncludeRegistry) {
6996 if (bInGlobalSection) {
6999 ret = process_registry_globals();
7003 DEBUG(1, ("\"include = registry\" only effective "
7004 "in %s section\n", GLOBAL_NAME));
7009 fname = talloc_sub_basic(talloc_tos(), get_current_username(),
7010 current_user_info.domain,
7013 add_to_file_list(pszParmValue, fname);
7015 string_set(ptr, fname);
7017 if (file_exist(fname)) {
7020 ret = pm_process(fname, do_section, do_parameter, NULL);
7026 DEBUG(2, ("Can't find include file %s\n", fname));
7031 /***************************************************************************
7032 Handle the interpretation of the copy parameter.
7033 ***************************************************************************/
7035 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7039 struct loadparm_service serviceTemp;
7041 string_set(ptr, pszParmValue);
7043 init_service(&serviceTemp);
7047 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7049 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7050 if (iTemp == iServiceIndex) {
7051 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7053 copy_service(ServicePtrs[iServiceIndex],
7055 ServicePtrs[iServiceIndex]->copymap);
7059 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7063 free_service(&serviceTemp);
7067 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7069 Globals.ldap_debug_level = lp_int(pszParmValue);
7070 init_ldap_debugging();
7074 /***************************************************************************
7075 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7080 idmap uid = 1000-1999
7083 We only do simple parsing checks here. The strings are parsed into useful
7084 structures in the idmap daemon code.
7086 ***************************************************************************/
7088 /* Some lp_ routines to return idmap [ug]id information */
7090 static uid_t idmap_uid_low, idmap_uid_high;
7091 static gid_t idmap_gid_low, idmap_gid_high;
7093 bool lp_idmap_uid(uid_t *low, uid_t *high)
7095 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7099 *low = idmap_uid_low;
7102 *high = idmap_uid_high;
7107 bool lp_idmap_gid(gid_t *low, gid_t *high)
7109 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7113 *low = idmap_gid_low;
7116 *high = idmap_gid_high;
7121 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7123 lp_do_parameter(snum, "idmap config * : backend", pszParmValue);
7128 /* Do some simple checks on "idmap [ug]id" parameter values */
7130 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7132 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7137 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7139 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7144 /***************************************************************************
7145 Handle the DEBUG level list.
7146 ***************************************************************************/
7148 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValueIn, char **ptr )
7150 string_set(ptr, pszParmValueIn);
7151 return debug_parse_levels(pszParmValueIn);
7154 /***************************************************************************
7155 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7156 ***************************************************************************/
7158 static const char *append_ldap_suffix( const char *str )
7160 const char *suffix_string;
7163 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7164 Globals.szLdapSuffix );
7165 if ( !suffix_string ) {
7166 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7170 return suffix_string;
7173 const char *lp_ldap_machine_suffix(void)
7175 if (Globals.szLdapMachineSuffix[0])
7176 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7178 return lp_string(Globals.szLdapSuffix);
7181 const char *lp_ldap_user_suffix(void)
7183 if (Globals.szLdapUserSuffix[0])
7184 return append_ldap_suffix(Globals.szLdapUserSuffix);
7186 return lp_string(Globals.szLdapSuffix);
7189 const char *lp_ldap_group_suffix(void)
7191 if (Globals.szLdapGroupSuffix[0])
7192 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7194 return lp_string(Globals.szLdapSuffix);
7197 const char *lp_ldap_idmap_suffix(void)
7199 if (Globals.szLdapIdmapSuffix[0])
7200 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7202 return lp_string(Globals.szLdapSuffix);
7205 /****************************************************************************
7206 set the value for a P_ENUM
7207 ***************************************************************************/
7209 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7214 for (i = 0; parm->enum_list[i].name; i++) {
7215 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7216 *ptr = parm->enum_list[i].value;
7220 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7221 pszParmValue, parm->label));
7224 /***************************************************************************
7225 ***************************************************************************/
7227 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7229 static int parm_num = -1;
7230 struct loadparm_service *s;
7232 if ( parm_num == -1 )
7233 parm_num = map_parameter( "printing" );
7235 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7240 s = ServicePtrs[snum];
7242 init_printer_values( s );
7248 /***************************************************************************
7249 Initialise a copymap.
7250 ***************************************************************************/
7252 static void init_copymap(struct loadparm_service *pservice)
7256 TALLOC_FREE(pservice->copymap);
7258 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
7259 if (!pservice->copymap)
7261 ("Couldn't allocate copymap!! (size %d)\n",
7262 (int)NUMPARAMETERS));
7264 for (i = 0; i < NUMPARAMETERS; i++)
7265 bitmap_set(pservice->copymap, i);
7269 return the parameter pointer for a parameter
7271 void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm)
7273 if (service == NULL) {
7274 if (parm->p_class == P_LOCAL)
7275 return (void *)(((char *)&sDefault)+parm->offset);
7276 else if (parm->p_class == P_GLOBAL)
7277 return (void *)(((char *)&Globals)+parm->offset);
7280 return (void *)(((char *)service) + parm->offset);
7284 /***************************************************************************
7285 Return the local pointer to a parameter given the service number and parameter
7286 ***************************************************************************/
7288 void *lp_local_ptr_by_snum(int snum, struct parm_struct *parm)
7290 return lp_parm_ptr(ServicePtrs[snum], parm);
7293 /***************************************************************************
7294 Process a parameter for a particular service number. If snum < 0
7295 then assume we are in the globals.
7296 ***************************************************************************/
7298 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7301 void *parm_ptr = NULL; /* where we are going to store the result */
7302 struct parmlist_entry **opt_list;
7304 parmnum = map_parameter(pszParmName);
7307 if (strchr(pszParmName, ':') == NULL) {
7308 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7314 * We've got a parametric option
7317 opt_list = (snum < 0)
7318 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7319 set_param_opt(opt_list, pszParmName, pszParmValue, 0);
7324 /* if it's already been set by the command line, then we don't
7326 if (parm_table[parmnum].flags & FLAG_CMDLINE) {
7330 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7331 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7335 /* we might point at a service, the default service or a global */
7337 parm_ptr = lp_parm_ptr(NULL, &parm_table[parmnum]);
7339 if (parm_table[parmnum].p_class == P_GLOBAL) {
7341 ("Global parameter %s found in service section!\n",
7345 parm_ptr = lp_local_ptr_by_snum(snum, &parm_table[parmnum]);
7349 if (!ServicePtrs[snum]->copymap)
7350 init_copymap(ServicePtrs[snum]);
7352 /* this handles the aliases - set the copymap for other entries with
7353 the same data pointer */
7354 for (i = 0; parm_table[i].label; i++) {
7355 if ((parm_table[i].offset == parm_table[parmnum].offset)
7356 && (parm_table[i].p_class == parm_table[parmnum].p_class)) {
7357 bitmap_clear(ServicePtrs[snum]->copymap, i);
7362 /* if it is a special case then go ahead */
7363 if (parm_table[parmnum].special) {
7364 return parm_table[parmnum].special(NULL, snum, pszParmValue,
7368 /* now switch on the type of variable it is */
7369 switch (parm_table[parmnum].type)
7372 *(bool *)parm_ptr = lp_bool(pszParmValue);
7376 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7380 *(int *)parm_ptr = lp_int(pszParmValue);
7384 *(char *)parm_ptr = *pszParmValue;
7388 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7390 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7395 TALLOC_FREE(*((char ***)parm_ptr));
7396 *(char ***)parm_ptr = str_list_make_v3(
7397 NULL, pszParmValue, NULL);
7401 string_set((char **)parm_ptr, pszParmValue);
7406 char *upper_string = strupper_talloc(talloc_tos(),
7408 string_set((char **)parm_ptr, upper_string);
7409 TALLOC_FREE(upper_string);
7413 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7422 /***************************************************************************
7423 set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
7424 FLAG_CMDLINE won't be overridden by loads from smb.conf.
7425 ***************************************************************************/
7427 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
7430 parmnum = map_parameter(pszParmName);
7432 parm_table[parmnum].flags &= ~FLAG_CMDLINE;
7433 if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
7436 parm_table[parmnum].flags |= FLAG_CMDLINE;
7438 /* we have to also set FLAG_CMDLINE on aliases. Aliases must
7439 * be grouped in the table, so we don't have to search the
7442 i>=0 && parm_table[i].offset == parm_table[parmnum].offset
7443 && parm_table[i].p_class == parm_table[parmnum].p_class;
7445 parm_table[i].flags |= FLAG_CMDLINE;
7447 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset
7448 && parm_table[i].p_class == parm_table[parmnum].p_class;i++) {
7449 parm_table[i].flags |= FLAG_CMDLINE;
7453 store_lp_set_cmdline(pszParmName, pszParmValue);
7458 /* it might be parametric */
7459 if (strchr(pszParmName, ':') != NULL) {
7460 set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
7462 store_lp_set_cmdline(pszParmName, pszParmValue);
7467 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
7471 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
7473 return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
7476 /***************************************************************************
7477 Process a parameter.
7478 ***************************************************************************/
7480 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7483 if (!bInGlobalSection && bGlobalOnly)
7486 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7488 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7489 pszParmName, pszParmValue));
7493 set a option from the commandline in 'a=b' format. Use to support --option
7495 bool lp_set_option(const char *option)
7500 s = talloc_strdup(NULL, option);
7513 /* skip white spaces after the = sign */
7516 } while (*p == ' ');
7518 ret = lp_set_cmdline(s, p);
7523 /**************************************************************************
7524 Print a parameter of the specified type.
7525 ***************************************************************************/
7527 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7529 /* For the seperation of lists values that we print below */
7530 const char *list_sep = ", ";
7535 for (i = 0; p->enum_list[i].name; i++) {
7536 if (*(int *)ptr == p->enum_list[i].value) {
7538 p->enum_list[i].name);
7545 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7549 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7554 fprintf(f, "%d", *(int *)ptr);
7558 fprintf(f, "%c", *(char *)ptr);
7562 char *o = octal_string(*(int *)ptr);
7563 fprintf(f, "%s", o);
7572 if ((char ***)ptr && *(char ***)ptr) {
7573 char **list = *(char ***)ptr;
7574 for (; *list; list++) {
7575 /* surround strings with whitespace in double quotes */
7576 if (*(list+1) == NULL) {
7577 /* last item, no extra separator */
7580 if ( strchr_m( *list, ' ' ) ) {
7581 fprintf(f, "\"%s\"%s", *list, list_sep);
7583 fprintf(f, "%s%s", *list, list_sep);
7591 if (*(char **)ptr) {
7592 fprintf(f, "%s", *(char **)ptr);
7600 /***************************************************************************
7601 Check if two parameters are equal.
7602 ***************************************************************************/
7604 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7609 return (*((bool *)ptr1) == *((bool *)ptr2));
7615 return (*((int *)ptr1) == *((int *)ptr2));
7618 return (*((char *)ptr1) == *((char *)ptr2));
7622 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7627 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7632 return (p1 == p2 || strequal(p1, p2));
7640 /***************************************************************************
7641 Initialize any local varients in the sDefault table.
7642 ***************************************************************************/
7644 void init_locals(void)
7649 /***************************************************************************
7650 Process a new section (service). At this stage all sections are services.
7651 Later we'll have special sections that permit server parameters to be set.
7652 Returns true on success, false on failure.
7653 ***************************************************************************/
7655 static bool do_section(const char *pszSectionName, void *userdata)
7658 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7659 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7662 /* if we were in a global section then do the local inits */
7663 if (bInGlobalSection && !isglobal)
7666 /* if we've just struck a global section, note the fact. */
7667 bInGlobalSection = isglobal;
7669 /* check for multiple global sections */
7670 if (bInGlobalSection) {
7671 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7675 if (!bInGlobalSection && bGlobalOnly)
7678 /* if we have a current service, tidy it up before moving on */
7681 if (iServiceIndex >= 0)
7682 bRetval = service_ok(iServiceIndex);
7684 /* if all is still well, move to the next record in the services array */
7686 /* We put this here to avoid an odd message order if messages are */
7687 /* issued by the post-processing of a previous section. */
7688 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7690 iServiceIndex = add_a_service(&sDefault, pszSectionName);
7691 if (iServiceIndex < 0) {
7692 DEBUG(0, ("Failed to add a new service\n"));
7695 /* Clean all parametric options for service */
7696 /* They will be added during parsing again */
7697 free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
7704 /***************************************************************************
7705 Determine if a partcular base parameter is currentl set to the default value.
7706 ***************************************************************************/
7708 static bool is_default(int i)
7710 if (!defaults_saved)
7712 switch (parm_table[i].type) {
7714 return str_list_equal((const char **)parm_table[i].def.lvalue,
7715 *(const char ***)lp_parm_ptr(NULL,
7719 return strequal(parm_table[i].def.svalue,
7720 *(char **)lp_parm_ptr(NULL,
7724 return parm_table[i].def.bvalue ==
7725 *(bool *)lp_parm_ptr(NULL,
7728 return parm_table[i].def.cvalue ==
7729 *(char *)lp_parm_ptr(NULL,
7735 return parm_table[i].def.ivalue ==
7736 *(int *)lp_parm_ptr(NULL,
7744 /***************************************************************************
7745 Display the contents of the global structure.
7746 ***************************************************************************/
7748 static void dump_globals(FILE *f)
7751 struct parmlist_entry *data;
7753 fprintf(f, "[global]\n");
7755 for (i = 0; parm_table[i].label; i++)
7756 if (parm_table[i].p_class == P_GLOBAL &&
7757 !(parm_table[i].flags & FLAG_META) &&
7758 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
7759 if (defaults_saved && is_default(i))
7761 fprintf(f, "\t%s = ", parm_table[i].label);
7762 print_parameter(&parm_table[i], lp_parm_ptr(NULL,
7767 if (Globals.param_opt != NULL) {
7768 data = Globals.param_opt;
7770 fprintf(f, "\t%s = %s\n", data->key, data->value);
7777 /***************************************************************************
7778 Return true if a local parameter is currently set to the global default.
7779 ***************************************************************************/
7781 bool lp_is_default(int snum, struct parm_struct *parm)
7783 return equal_parameter(parm->type,
7784 lp_parm_ptr(ServicePtrs[snum], parm),
7785 lp_parm_ptr(NULL, parm));
7788 /***************************************************************************
7789 Display the contents of a single services record.
7790 ***************************************************************************/
7792 static void dump_a_service(struct loadparm_service *pService, FILE * f)
7795 struct parmlist_entry *data;
7797 if (pService != &sDefault)
7798 fprintf(f, "[%s]\n", pService->szService);
7800 for (i = 0; parm_table[i].label; i++) {
7802 if (parm_table[i].p_class == P_LOCAL &&
7803 !(parm_table[i].flags & FLAG_META) &&
7804 (*parm_table[i].label != '-') &&
7805 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7807 if (pService == &sDefault) {
7808 if (defaults_saved && is_default(i))
7811 if (equal_parameter(parm_table[i].type,
7812 lp_parm_ptr(pService, &parm_table[i]),
7813 lp_parm_ptr(NULL, &parm_table[i])))
7817 fprintf(f, "\t%s = ", parm_table[i].label);
7818 print_parameter(&parm_table[i],
7819 lp_parm_ptr(pService, &parm_table[i]),
7825 if (pService->param_opt != NULL) {
7826 data = pService->param_opt;
7828 fprintf(f, "\t%s = %s\n", data->key, data->value);
7834 /***************************************************************************
7835 Display the contents of a parameter of a single services record.
7836 ***************************************************************************/
7838 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7841 bool result = false;
7844 fstring local_parm_name;
7846 const char *parm_opt_value;
7848 /* check for parametrical option */
7849 fstrcpy( local_parm_name, parm_name);
7850 parm_opt = strchr( local_parm_name, ':');
7855 if (strlen(parm_opt)) {
7856 parm_opt_value = lp_parm_const_string( snum,
7857 local_parm_name, parm_opt, NULL);
7858 if (parm_opt_value) {
7859 printf( "%s\n", parm_opt_value);
7866 /* check for a key and print the value */
7873 for (i = 0; parm_table[i].label; i++) {
7874 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7875 !(parm_table[i].flags & FLAG_META) &&
7876 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7877 (*parm_table[i].label != '-') &&
7878 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7883 ptr = lp_parm_ptr(NULL,
7886 ptr = lp_parm_ptr(ServicePtrs[snum],
7890 print_parameter(&parm_table[i],
7901 /***************************************************************************
7902 Return info about the requested parameter (given as a string).
7903 Return NULL when the string is not a valid parameter name.
7904 ***************************************************************************/
7906 struct parm_struct *lp_get_parameter(const char *param_name)
7908 int num = map_parameter(param_name);
7914 return &parm_table[num];
7917 /***************************************************************************
7918 Return info about the next parameter in a service.
7919 snum==GLOBAL_SECTION_SNUM gives the globals.
7920 Return NULL when out of parameters.
7921 ***************************************************************************/
7923 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
7926 /* do the globals */
7927 for (; parm_table[*i].label; (*i)++) {
7928 if (parm_table[*i].p_class == P_SEPARATOR)
7929 return &parm_table[(*i)++];
7931 if ((*parm_table[*i].label == '-'))
7935 && (parm_table[*i].offset ==
7936 parm_table[(*i) - 1].offset)
7937 && (parm_table[*i].p_class ==
7938 parm_table[(*i) - 1].p_class))
7941 if (is_default(*i) && !allparameters)
7944 return &parm_table[(*i)++];
7947 struct loadparm_service *pService = ServicePtrs[snum];
7949 for (; parm_table[*i].label; (*i)++) {
7950 if (parm_table[*i].p_class == P_SEPARATOR)
7951 return &parm_table[(*i)++];
7953 if (parm_table[*i].p_class == P_LOCAL &&
7954 (*parm_table[*i].label != '-') &&
7956 (parm_table[*i].offset !=
7957 parm_table[(*i) - 1].offset)))
7959 if (allparameters ||
7960 !equal_parameter(parm_table[*i].type,
7961 lp_parm_ptr(pService,
7966 return &parm_table[(*i)++];
7977 /***************************************************************************
7978 Display the contents of a single copy structure.
7979 ***************************************************************************/
7980 static void dump_copy_map(bool *pcopymap)
7986 printf("\n\tNon-Copied parameters:\n");
7988 for (i = 0; parm_table[i].label; i++)
7989 if (parm_table[i].p_class == P_LOCAL &&
7990 parm_table[i].ptr && !pcopymap[i] &&
7991 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7993 printf("\t\t%s\n", parm_table[i].label);
7998 /***************************************************************************
7999 Return TRUE if the passed service number is within range.
8000 ***************************************************************************/
8002 bool lp_snum_ok(int iService)
8004 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8007 /***************************************************************************
8008 Auto-load some home services.
8009 ***************************************************************************/
8011 static void lp_add_auto_services(char *str)
8021 s = SMB_STRDUP(str);
8025 homes = lp_servicenumber(HOMES_NAME);
8027 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8028 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8031 if (lp_servicenumber(p) >= 0)
8034 home = get_user_home_dir(talloc_tos(), p);
8036 if (home && home[0] && homes >= 0)
8037 lp_add_home(p, homes, p, home);
8044 /***************************************************************************
8045 Auto-load one printer.
8046 ***************************************************************************/
8048 void lp_add_one_printer(const char *name, const char *comment,
8049 const char *location, void *pdata)
8051 int printers = lp_servicenumber(PRINTERS_NAME);
8054 if (lp_servicenumber(name) < 0) {
8055 lp_add_printer(name, printers);
8056 if ((i = lp_servicenumber(name)) >= 0) {
8057 string_set(&ServicePtrs[i]->comment, comment);
8058 ServicePtrs[i]->autoloaded = true;
8063 /***************************************************************************
8064 Have we loaded a services file yet?
8065 ***************************************************************************/
8067 bool lp_loaded(void)
8072 /***************************************************************************
8073 Unload unused services.
8074 ***************************************************************************/
8076 void lp_killunused(struct smbd_server_connection *sconn,
8077 bool (*snumused) (struct smbd_server_connection *, int))
8080 for (i = 0; i < iNumServices; i++) {
8084 /* don't kill autoloaded or usershare services */
8085 if ( ServicePtrs[i]->autoloaded ||
8086 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8090 if (!snumused || !snumused(sconn, i)) {
8091 free_service_byindex(i);
8097 * Kill all except autoloaded and usershare services - convenience wrapper
8099 void lp_kill_all_services(void)
8101 lp_killunused(NULL, NULL);
8104 /***************************************************************************
8106 ***************************************************************************/
8108 void lp_killservice(int iServiceIn)
8110 if (VALID(iServiceIn)) {
8111 free_service_byindex(iServiceIn);
8115 /***************************************************************************
8116 Save the curent values of all global and sDefault parameters into the
8117 defaults union. This allows swat and testparm to show only the
8118 changed (ie. non-default) parameters.
8119 ***************************************************************************/
8121 static void lp_save_defaults(void)
8124 for (i = 0; parm_table[i].label; i++) {
8125 if (i > 0 && parm_table[i].offset == parm_table[i - 1].offset
8126 && parm_table[i].p_class == parm_table[i - 1].p_class)
8128 switch (parm_table[i].type) {
8130 parm_table[i].def.lvalue = str_list_copy(
8131 NULL, *(const char ***)lp_parm_ptr(NULL, &parm_table[i]));
8135 parm_table[i].def.svalue = SMB_STRDUP(*(char **)lp_parm_ptr(NULL, &parm_table[i]));
8139 parm_table[i].def.bvalue =
8140 *(bool *)lp_parm_ptr(NULL, &parm_table[i]);
8143 parm_table[i].def.cvalue =
8144 *(char *)lp_parm_ptr(NULL, &parm_table[i]);
8149 parm_table[i].def.ivalue =
8150 *(int *)lp_parm_ptr(NULL, &parm_table[i]);
8156 defaults_saved = true;
8159 /***********************************************************
8160 If we should send plaintext/LANMAN passwords in the clinet
8161 ************************************************************/
8163 static void set_allowed_client_auth(void)
8165 if (Globals.bClientNTLMv2Auth) {
8166 Globals.bClientLanManAuth = false;
8168 if (!Globals.bClientLanManAuth) {
8169 Globals.bClientPlaintextAuth = false;
8173 /***************************************************************************
8175 The following code allows smbd to read a user defined share file.
8176 Yes, this is my intent. Yes, I'm comfortable with that...
8178 THE FOLLOWING IS SECURITY CRITICAL CODE.
8180 It washes your clothes, it cleans your house, it guards you while you sleep...
8181 Do not f%^k with it....
8182 ***************************************************************************/
8184 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8186 /***************************************************************************
8187 Check allowed stat state of a usershare file.
8188 Ensure we print out who is dicking with us so the admin can
8189 get their sorry ass fired.
8190 ***************************************************************************/
8192 static bool check_usershare_stat(const char *fname,
8193 const SMB_STRUCT_STAT *psbuf)
8195 if (!S_ISREG(psbuf->st_ex_mode)) {
8196 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8197 "not a regular file\n",
8198 fname, (unsigned int)psbuf->st_ex_uid ));
8202 /* Ensure this doesn't have the other write bit set. */
8203 if (psbuf->st_ex_mode & S_IWOTH) {
8204 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8205 "public write. Refusing to allow as a usershare file.\n",
8206 fname, (unsigned int)psbuf->st_ex_uid ));
8210 /* Should be 10k or less. */
8211 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8212 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8213 "too large (%u) to be a user share file.\n",
8214 fname, (unsigned int)psbuf->st_ex_uid,
8215 (unsigned int)psbuf->st_ex_size ));
8222 /***************************************************************************
8223 Parse the contents of a usershare file.
8224 ***************************************************************************/
8226 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8227 SMB_STRUCT_STAT *psbuf,
8228 const char *servicename,
8232 char **pp_sharepath,
8234 char **pp_cp_servicename,
8235 struct security_descriptor **ppsd,
8238 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8239 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8242 SMB_STRUCT_STAT sbuf;
8243 char *sharepath = NULL;
8244 char *comment = NULL;
8246 *pp_sharepath = NULL;
8249 *pallow_guest = false;
8252 return USERSHARE_MALFORMED_FILE;
8255 if (strcmp(lines[0], "#VERSION 1") == 0) {
8257 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8260 return USERSHARE_MALFORMED_FILE;
8263 return USERSHARE_BAD_VERSION;
8266 if (strncmp(lines[1], "path=", 5) != 0) {
8267 return USERSHARE_MALFORMED_PATH;
8270 sharepath = talloc_strdup(ctx, &lines[1][5]);
8272 return USERSHARE_POSIX_ERR;
8274 trim_string(sharepath, " ", " ");
8276 if (strncmp(lines[2], "comment=", 8) != 0) {
8277 return USERSHARE_MALFORMED_COMMENT_DEF;
8280 comment = talloc_strdup(ctx, &lines[2][8]);
8282 return USERSHARE_POSIX_ERR;
8284 trim_string(comment, " ", " ");
8285 trim_char(comment, '"', '"');
8287 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8288 return USERSHARE_MALFORMED_ACL_DEF;
8291 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8292 return USERSHARE_ACL_ERR;
8296 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8297 return USERSHARE_MALFORMED_ACL_DEF;
8299 if (lines[4][9] == 'y') {
8300 *pallow_guest = true;
8303 /* Backwards compatible extension to file version #2. */
8305 if (strncmp(lines[5], "sharename=", 10) != 0) {
8306 return USERSHARE_MALFORMED_SHARENAME_DEF;
8308 if (!strequal(&lines[5][10], servicename)) {
8309 return USERSHARE_BAD_SHARENAME;
8311 *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
8312 if (!*pp_cp_servicename) {
8313 return USERSHARE_POSIX_ERR;
8318 if (*pp_cp_servicename == NULL) {
8319 *pp_cp_servicename = talloc_strdup(ctx, servicename);
8320 if (!*pp_cp_servicename) {
8321 return USERSHARE_POSIX_ERR;
8325 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8326 /* Path didn't change, no checks needed. */
8327 *pp_sharepath = sharepath;
8328 *pp_comment = comment;
8329 return USERSHARE_OK;
8332 /* The path *must* be absolute. */
8333 if (sharepath[0] != '/') {
8334 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8335 servicename, sharepath));
8336 return USERSHARE_PATH_NOT_ABSOLUTE;
8339 /* If there is a usershare prefix deny list ensure one of these paths
8340 doesn't match the start of the user given path. */
8341 if (prefixdenylist) {
8343 for ( i=0; prefixdenylist[i]; i++ ) {
8344 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8345 servicename, i, prefixdenylist[i], sharepath ));
8346 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8347 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8348 "usershare prefix deny list entries.\n",
8349 servicename, sharepath));
8350 return USERSHARE_PATH_IS_DENIED;
8355 /* If there is a usershare prefix allow list ensure one of these paths
8356 does match the start of the user given path. */
8358 if (prefixallowlist) {
8360 for ( i=0; prefixallowlist[i]; i++ ) {
8361 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8362 servicename, i, prefixallowlist[i], sharepath ));
8363 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8367 if (prefixallowlist[i] == NULL) {
8368 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8369 "usershare prefix allow list entries.\n",
8370 servicename, sharepath));
8371 return USERSHARE_PATH_NOT_ALLOWED;
8375 /* Ensure this is pointing to a directory. */
8376 dp = sys_opendir(sharepath);
8379 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8380 servicename, sharepath));
8381 return USERSHARE_PATH_NOT_DIRECTORY;
8384 /* Ensure the owner of the usershare file has permission to share
8387 if (sys_stat(sharepath, &sbuf, false) == -1) {
8388 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8389 servicename, sharepath, strerror(errno) ));
8391 return USERSHARE_POSIX_ERR;
8396 if (!S_ISDIR(sbuf.st_ex_mode)) {
8397 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8398 servicename, sharepath ));
8399 return USERSHARE_PATH_NOT_DIRECTORY;
8402 /* Check if sharing is restricted to owner-only. */
8403 /* psbuf is the stat of the usershare definition file,
8404 sbuf is the stat of the target directory to be shared. */
8406 if (lp_usershare_owner_only()) {
8407 /* root can share anything. */
8408 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8409 return USERSHARE_PATH_NOT_ALLOWED;
8413 *pp_sharepath = sharepath;
8414 *pp_comment = comment;
8415 return USERSHARE_OK;
8418 /***************************************************************************
8419 Deal with a usershare file.
8422 -1 - Bad name, invalid contents.
8423 - service name already existed and not a usershare, problem
8424 with permissions to share directory etc.
8425 ***************************************************************************/
8427 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8429 SMB_STRUCT_STAT sbuf;
8430 SMB_STRUCT_STAT lsbuf;
8432 char *sharepath = NULL;
8433 char *comment = NULL;
8434 char *cp_service_name = NULL;
8435 char **lines = NULL;
8439 TALLOC_CTX *ctx = talloc_stackframe();
8440 struct security_descriptor *psd = NULL;
8441 bool guest_ok = false;
8442 char *canon_name = NULL;
8443 bool added_service = false;
8446 /* Ensure share name doesn't contain invalid characters. */
8447 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8448 DEBUG(0,("process_usershare_file: share name %s contains "
8449 "invalid characters (any of %s)\n",
8450 file_name, INVALID_SHARENAME_CHARS ));
8454 canon_name = canonicalize_servicename(ctx, file_name);
8459 fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
8464 /* Minimize the race condition by doing an lstat before we
8465 open and fstat. Ensure this isn't a symlink link. */
8467 if (sys_lstat(fname, &lsbuf, false) != 0) {
8468 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8469 fname, strerror(errno) ));
8473 /* This must be a regular file, not a symlink, directory or
8474 other strange filetype. */
8475 if (!check_usershare_stat(fname, &lsbuf)) {
8480 TDB_DATA data = dbwrap_fetch_bystring(
8481 ServiceHash, canon_name, canon_name);
8485 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
8486 iService = *(int *)data.dptr;
8490 if (iService != -1 &&
8491 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8492 &lsbuf.st_ex_mtime) == 0) {
8493 /* Nothing changed - Mark valid and return. */
8494 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8496 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8501 /* Try and open the file read only - no symlinks allowed. */
8503 fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8505 fd = sys_open(fname, O_RDONLY, 0);
8509 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8510 fname, strerror(errno) ));
8514 /* Now fstat to be *SURE* it's a regular file. */
8515 if (sys_fstat(fd, &sbuf, false) != 0) {
8517 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8518 fname, strerror(errno) ));
8522 /* Is it the same dev/inode as was lstated ? */
8523 if (lsbuf.st_ex_dev != sbuf.st_ex_dev || lsbuf.st_ex_ino != sbuf.st_ex_ino) {
8525 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8526 "Symlink spoofing going on ?\n", fname ));
8530 /* This must be a regular file, not a symlink, directory or
8531 other strange filetype. */
8532 if (!check_usershare_stat(fname, &sbuf)) {
8536 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8539 if (lines == NULL) {
8540 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8541 fname, (unsigned int)sbuf.st_ex_uid ));
8545 if (parse_usershare_file(ctx, &sbuf, file_name,
8546 iService, lines, numlines, &sharepath,
8547 &comment, &cp_service_name,
8548 &psd, &guest_ok) != USERSHARE_OK) {
8552 /* Everything ok - add the service possibly using a template. */
8554 const struct loadparm_service *sp = &sDefault;
8555 if (snum_template != -1) {
8556 sp = ServicePtrs[snum_template];
8559 if ((iService = add_a_service(sp, cp_service_name)) < 0) {
8560 DEBUG(0, ("process_usershare_file: Failed to add "
8561 "new service %s\n", cp_service_name));
8565 added_service = true;
8567 /* Read only is controlled by usershare ACL below. */
8568 ServicePtrs[iService]->bRead_only = false;
8571 /* Write the ACL of the new/modified share. */
8572 if (!set_share_security(canon_name, psd)) {
8573 DEBUG(0, ("process_usershare_file: Failed to set share "
8574 "security for user share %s\n",
8579 /* If from a template it may be marked invalid. */
8580 ServicePtrs[iService]->valid = true;
8582 /* Set the service as a valid usershare. */
8583 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8585 /* Set guest access. */
8586 if (lp_usershare_allow_guests()) {
8587 ServicePtrs[iService]->bGuest_ok = guest_ok;
8590 /* And note when it was loaded. */
8591 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8592 string_set(&ServicePtrs[iService]->szPath, sharepath);
8593 string_set(&ServicePtrs[iService]->comment, comment);
8599 if (ret == -1 && iService != -1 && added_service) {
8600 lp_remove_service(iService);
8608 /***************************************************************************
8609 Checks if a usershare entry has been modified since last load.
8610 ***************************************************************************/
8612 static bool usershare_exists(int iService, struct timespec *last_mod)
8614 SMB_STRUCT_STAT lsbuf;
8615 const char *usersharepath = Globals.szUsersharePath;
8618 if (asprintf(&fname, "%s/%s",
8620 ServicePtrs[iService]->szService) < 0) {
8624 if (sys_lstat(fname, &lsbuf, false) != 0) {
8629 if (!S_ISREG(lsbuf.st_ex_mode)) {
8635 *last_mod = lsbuf.st_ex_mtime;
8639 /***************************************************************************
8640 Load a usershare service by name. Returns a valid servicenumber or -1.
8641 ***************************************************************************/
8643 int load_usershare_service(const char *servicename)
8645 SMB_STRUCT_STAT sbuf;
8646 const char *usersharepath = Globals.szUsersharePath;
8647 int max_user_shares = Globals.iUsershareMaxShares;
8648 int snum_template = -1;
8650 if (*usersharepath == 0 || max_user_shares == 0) {
8654 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8655 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8656 usersharepath, strerror(errno) ));
8660 if (!S_ISDIR(sbuf.st_ex_mode)) {
8661 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8667 * This directory must be owned by root, and have the 't' bit set.
8668 * It also must not be writable by "other".
8672 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8674 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8676 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8677 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8682 /* Ensure the template share exists if it's set. */
8683 if (Globals.szUsershareTemplateShare[0]) {
8684 /* We can't use lp_servicenumber here as we are recommending that
8685 template shares have -valid=false set. */
8686 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8687 if (ServicePtrs[snum_template]->szService &&
8688 strequal(ServicePtrs[snum_template]->szService,
8689 Globals.szUsershareTemplateShare)) {
8694 if (snum_template == -1) {
8695 DEBUG(0,("load_usershare_service: usershare template share %s "
8696 "does not exist.\n",
8697 Globals.szUsershareTemplateShare ));
8702 return process_usershare_file(usersharepath, servicename, snum_template);
8705 /***************************************************************************
8706 Load all user defined shares from the user share directory.
8707 We only do this if we're enumerating the share list.
8708 This is the function that can delete usershares that have
8710 ***************************************************************************/
8712 int load_usershare_shares(struct smbd_server_connection *sconn)
8715 SMB_STRUCT_STAT sbuf;
8716 SMB_STRUCT_DIRENT *de;
8717 int num_usershares = 0;
8718 int max_user_shares = Globals.iUsershareMaxShares;
8719 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8720 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8721 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8723 int snum_template = -1;
8724 const char *usersharepath = Globals.szUsersharePath;
8725 int ret = lp_numservices();
8727 if (max_user_shares == 0 || *usersharepath == '\0') {
8728 return lp_numservices();
8731 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8732 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8733 usersharepath, strerror(errno) ));
8738 * This directory must be owned by root, and have the 't' bit set.
8739 * It also must not be writable by "other".
8743 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8745 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8747 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8748 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8753 /* Ensure the template share exists if it's set. */
8754 if (Globals.szUsershareTemplateShare[0]) {
8755 /* We can't use lp_servicenumber here as we are recommending that
8756 template shares have -valid=false set. */
8757 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8758 if (ServicePtrs[snum_template]->szService &&
8759 strequal(ServicePtrs[snum_template]->szService,
8760 Globals.szUsershareTemplateShare)) {
8765 if (snum_template == -1) {
8766 DEBUG(0,("load_usershare_shares: usershare template share %s "
8767 "does not exist.\n",
8768 Globals.szUsershareTemplateShare ));
8773 /* Mark all existing usershares as pending delete. */
8774 for (iService = iNumServices - 1; iService >= 0; iService--) {
8775 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8776 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8780 dp = sys_opendir(usersharepath);
8782 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8783 usersharepath, strerror(errno) ));
8787 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8788 (de = sys_readdir(dp));
8789 num_dir_entries++ ) {
8791 const char *n = de->d_name;
8793 /* Ignore . and .. */
8795 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8801 /* Temporary file used when creating a share. */
8802 num_tmp_dir_entries++;
8805 /* Allow 20% tmp entries. */
8806 if (num_tmp_dir_entries > allowed_tmp_entries) {
8807 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8808 "in directory %s\n",
8809 num_tmp_dir_entries, usersharepath));
8813 r = process_usershare_file(usersharepath, n, snum_template);
8815 /* Update the services count. */
8817 if (num_usershares >= max_user_shares) {
8818 DEBUG(0,("load_usershare_shares: max user shares reached "
8819 "on file %s in directory %s\n",
8820 n, usersharepath ));
8823 } else if (r == -1) {
8824 num_bad_dir_entries++;
8827 /* Allow 20% bad entries. */
8828 if (num_bad_dir_entries > allowed_bad_entries) {
8829 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8830 "in directory %s\n",
8831 num_bad_dir_entries, usersharepath));
8835 /* Allow 20% bad entries. */
8836 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
8837 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8838 "in directory %s\n",
8839 num_dir_entries, usersharepath));
8846 /* Sweep through and delete any non-refreshed usershares that are
8847 not currently in use. */
8848 for (iService = iNumServices - 1; iService >= 0; iService--) {
8849 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
8850 if (conn_snum_used(sconn, iService)) {
8853 /* Remove from the share ACL db. */
8854 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8855 lp_servicename(iService) ));
8856 delete_share_security(lp_servicename(iService));
8857 free_service_byindex(iService);
8861 return lp_numservices();
8864 /********************************************************
8865 Destroy global resources allocated in this file
8866 ********************************************************/
8868 void gfree_loadparm(void)
8874 /* Free resources allocated to services */
8876 for ( i = 0; i < iNumServices; i++ ) {
8878 free_service_byindex(i);
8882 SAFE_FREE( ServicePtrs );
8885 /* Now release all resources allocated to global
8886 parameters and the default service */
8888 free_global_parameters();
8892 /***************************************************************************
8893 Allow client apps to specify that they are a client
8894 ***************************************************************************/
8895 void lp_set_in_client(bool b)
8901 /***************************************************************************
8902 Determine if we're running in a client app
8903 ***************************************************************************/
8904 bool lp_is_in_client(void)
8909 /***************************************************************************
8910 Load the services array from the services file. Return true on success,
8912 ***************************************************************************/
8914 static bool lp_load_ex(const char *pszFname,
8918 bool initialize_globals,
8919 bool allow_include_registry,
8920 bool allow_registry_shares)
8927 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
8929 bInGlobalSection = true;
8930 bGlobalOnly = global_only;
8931 bAllowIncludeRegistry = allow_include_registry;
8933 init_globals(initialize_globals);
8937 if (save_defaults) {
8942 free_param_opts(&Globals.param_opt);
8944 lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
8946 /* We get sections first, so have to start 'behind' to make up */
8949 if (lp_config_backend_is_file()) {
8950 n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
8951 current_user_info.domain,
8954 smb_panic("lp_load_ex: out of memory");
8957 add_to_file_list(pszFname, n2);
8959 bRetval = pm_process(n2, do_section, do_parameter, NULL);
8962 /* finish up the last section */
8963 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
8965 if (iServiceIndex >= 0) {
8966 bRetval = service_ok(iServiceIndex);
8970 if (lp_config_backend_is_registry()) {
8971 /* config backend changed to registry in config file */
8973 * We need to use this extra global variable here to
8974 * survive restart: init_globals uses this as a default
8975 * for ConfigBackend. Otherwise, init_globals would
8976 * send us into an endless loop here.
8978 config_backend = CONFIG_BACKEND_REGISTRY;
8980 DEBUG(1, ("lp_load_ex: changing to config backend "
8983 lp_kill_all_services();
8984 return lp_load_ex(pszFname, global_only, save_defaults,
8985 add_ipc, initialize_globals,
8986 allow_include_registry,
8987 allow_registry_shares);
8989 } else if (lp_config_backend_is_registry()) {
8990 bRetval = process_registry_globals();
8992 DEBUG(0, ("Illegal config backend given: %d\n",
8993 lp_config_backend()));
8997 if (bRetval && lp_registry_shares() && allow_registry_shares) {
8998 bRetval = process_registry_shares();
9001 lp_add_auto_services(lp_auto_services());
9004 /* When 'restrict anonymous = 2' guest connections to ipc$
9006 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9007 if ( lp_enable_asu_support() ) {
9008 lp_add_ipc("ADMIN$", false);
9013 set_allowed_client_auth();
9015 if (lp_security() == SEC_SHARE) {
9016 DEBUG(1, ("WARNING: The security=share option is deprecated\n"));
9017 } else if (lp_security() == SEC_SERVER) {
9018 DEBUG(1, ("WARNING: The security=server option is deprecated\n"));
9021 if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) {
9022 DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
9023 lp_passwordserver()));
9028 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9029 /* if bWINSsupport is true and we are in the client */
9030 if (lp_is_in_client() && Globals.bWINSsupport) {
9031 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9036 fault_configure(smb_panic_s3);
9038 bAllowIncludeRegistry = true;
9043 bool lp_load(const char *pszFname,
9047 bool initialize_globals)
9049 return lp_load_ex(pszFname,
9054 true, /* allow_include_registry */
9055 false); /* allow_registry_shares*/
9058 bool lp_load_initial_only(const char *pszFname)
9060 return lp_load_ex(pszFname,
9061 true, /* global only */
9062 false, /* save_defaults */
9063 false, /* add_ipc */
9064 true, /* initialize_globals */
9065 false, /* allow_include_registry */
9066 false); /* allow_registry_shares*/
9069 bool lp_load_with_registry_shares(const char *pszFname,
9073 bool initialize_globals)
9075 return lp_load_ex(pszFname,
9080 true, /* allow_include_registry */
9081 true); /* allow_registry_shares*/
9084 /***************************************************************************
9085 Return the max number of services.
9086 ***************************************************************************/
9088 int lp_numservices(void)
9090 return (iNumServices);
9093 /***************************************************************************
9094 Display the contents of the services array in human-readable form.
9095 ***************************************************************************/
9097 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9102 defaults_saved = false;
9106 dump_a_service(&sDefault, f);
9108 for (iService = 0; iService < maxtoprint; iService++) {
9110 lp_dump_one(f, show_defaults, iService);
9114 /***************************************************************************
9115 Display the contents of one service in human-readable form.
9116 ***************************************************************************/
9118 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9121 if (ServicePtrs[snum]->szService[0] == '\0')
9123 dump_a_service(ServicePtrs[snum], f);
9127 /***************************************************************************
9128 Return the number of the service with the given name, or -1 if it doesn't
9129 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9130 getservicebyname()! This works ONLY if all services have been loaded, and
9131 does not copy the found service.
9132 ***************************************************************************/
9134 int lp_servicenumber(const char *pszServiceName)
9137 fstring serviceName;
9139 if (!pszServiceName) {
9140 return GLOBAL_SECTION_SNUM;
9143 for (iService = iNumServices - 1; iService >= 0; iService--) {
9144 if (VALID(iService) && ServicePtrs[iService]->szService) {
9146 * The substitution here is used to support %U is
9149 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9150 standard_sub_basic(get_current_username(),
9151 current_user_info.domain,
9152 serviceName,sizeof(serviceName));
9153 if (strequal(serviceName, pszServiceName)) {
9159 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9160 struct timespec last_mod;
9162 if (!usershare_exists(iService, &last_mod)) {
9163 /* Remove the share security tdb entry for it. */
9164 delete_share_security(lp_servicename(iService));
9165 /* Remove it from the array. */
9166 free_service_byindex(iService);
9167 /* Doesn't exist anymore. */
9168 return GLOBAL_SECTION_SNUM;
9171 /* Has it been modified ? If so delete and reload. */
9172 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9174 /* Remove it from the array. */
9175 free_service_byindex(iService);
9176 /* and now reload it. */
9177 iService = load_usershare_service(pszServiceName);
9182 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9183 return GLOBAL_SECTION_SNUM;
9189 bool share_defined(const char *service_name)
9191 return (lp_servicenumber(service_name) != -1);
9194 /*******************************************************************
9195 A useful volume label function.
9196 ********************************************************************/
9198 const char *volume_label(int snum)
9201 const char *label = lp_volume(snum);
9203 label = lp_servicename(snum);
9206 /* This returns a 33 byte guarenteed null terminated string. */
9207 ret = talloc_strndup(talloc_tos(), label, 32);
9214 /*******************************************************************
9215 Get the default server type we will announce as via nmbd.
9216 ********************************************************************/
9218 int lp_default_server_announce(void)
9220 int default_server_announce = 0;
9221 default_server_announce |= SV_TYPE_WORKSTATION;
9222 default_server_announce |= SV_TYPE_SERVER;
9223 default_server_announce |= SV_TYPE_SERVER_UNIX;
9225 /* note that the flag should be set only if we have a
9226 printer service but nmbd doesn't actually load the
9227 services so we can't tell --jerry */
9229 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9231 default_server_announce |= SV_TYPE_SERVER_NT;
9232 default_server_announce |= SV_TYPE_NT;
9234 switch (lp_server_role()) {
9235 case ROLE_DOMAIN_MEMBER:
9236 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9238 case ROLE_DOMAIN_PDC:
9239 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9241 case ROLE_DOMAIN_BDC:
9242 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9244 case ROLE_STANDALONE:
9248 if (lp_time_server())
9249 default_server_announce |= SV_TYPE_TIME_SOURCE;
9251 if (lp_host_msdfs())
9252 default_server_announce |= SV_TYPE_DFS_SERVER;
9254 return default_server_announce;
9257 /***********************************************************
9258 If we are PDC then prefer us as DMB
9259 ************************************************************/
9261 bool lp_domain_master(void)
9263 if (Globals.iDomainMaster == Auto)
9264 return (lp_server_role() == ROLE_DOMAIN_PDC);
9266 return (bool)Globals.iDomainMaster;
9269 /***********************************************************
9270 If we are PDC then prefer us as DMB
9271 ************************************************************/
9273 bool lp_domain_master_true_or_auto(void)
9275 if (Globals.iDomainMaster) /* auto or yes */
9281 /***********************************************************
9282 If we are DMB then prefer us as LMB
9283 ************************************************************/
9285 bool lp_preferred_master(void)
9287 if (Globals.iPreferredMaster == Auto)
9288 return (lp_local_master() && lp_domain_master());
9290 return (bool)Globals.iPreferredMaster;
9293 /*******************************************************************
9295 ********************************************************************/
9297 void lp_remove_service(int snum)
9299 ServicePtrs[snum]->valid = false;
9300 invalid_services[num_invalid_services++] = snum;
9303 /*******************************************************************
9305 ********************************************************************/
9307 void lp_copy_service(int snum, const char *new_name)
9309 do_section(new_name, NULL);
9311 snum = lp_servicenumber(new_name);
9313 lp_do_parameter(snum, "copy", lp_servicename(snum));
9318 /***********************************************************
9319 Set the global name resolution order (used in smbclient).
9320 ************************************************************/
9322 void lp_set_name_resolve_order(const char *new_order)
9324 string_set(&Globals.szNameResolveOrder, new_order);
9327 const char *lp_printername(int snum)
9329 const char *ret = lp__printername(snum);
9330 if (ret == NULL || (ret != NULL && *ret == '\0'))
9331 ret = lp_const_servicename(snum);
9337 /***********************************************************
9338 Allow daemons such as winbindd to fix their logfile name.
9339 ************************************************************/
9341 void lp_set_logfile(const char *name)
9343 string_set(&Globals.szLogFile, name);
9344 debug_set_logfile(name);
9347 /*******************************************************************
9348 Return the max print jobs per queue.
9349 ********************************************************************/
9351 int lp_maxprintjobs(int snum)
9353 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9354 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9355 maxjobs = PRINT_MAX_JOBID - 1;
9360 const char *lp_printcapname(void)
9362 if ((Globals.szPrintcapname != NULL) &&
9363 (Globals.szPrintcapname[0] != '\0'))
9364 return Globals.szPrintcapname;
9366 if (sDefault.iPrinting == PRINT_CUPS) {
9374 if (sDefault.iPrinting == PRINT_BSD)
9375 return "/etc/printcap";
9377 return PRINTCAP_NAME;
9380 static uint32 spoolss_state;
9382 bool lp_disable_spoolss( void )
9384 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9385 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9387 return spoolss_state == SVCCTL_STOPPED ? true : false;
9390 void lp_set_spoolss_state( uint32 state )
9392 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9394 spoolss_state = state;
9397 uint32 lp_get_spoolss_state( void )
9399 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9402 /*******************************************************************
9403 Ensure we don't use sendfile if server smb signing is active.
9404 ********************************************************************/
9406 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9408 bool sign_active = false;
9410 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9411 if (get_Protocol() < PROTOCOL_NT1) {
9414 if (signing_state) {
9415 sign_active = smb_signing_is_active(signing_state);
9417 return (lp__use_sendfile(snum) &&
9418 (get_remote_arch() != RA_WIN95) &&
9422 /*******************************************************************
9423 Turn off sendfile if we find the underlying OS doesn't support it.
9424 ********************************************************************/
9426 void set_use_sendfile(int snum, bool val)
9428 if (LP_SNUM_OK(snum))
9429 ServicePtrs[snum]->bUseSendfile = val;
9431 sDefault.bUseSendfile = val;
9434 /*******************************************************************
9435 Turn off storing DOS attributes if this share doesn't support it.
9436 ********************************************************************/
9438 void set_store_dos_attributes(int snum, bool val)
9440 if (!LP_SNUM_OK(snum))
9442 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9445 void lp_set_mangling_method(const char *new_method)
9447 string_set(&Globals.szManglingMethod, new_method);
9450 /*******************************************************************
9451 Global state for POSIX pathname processing.
9452 ********************************************************************/
9454 static bool posix_pathnames;
9456 bool lp_posix_pathnames(void)
9458 return posix_pathnames;
9461 /*******************************************************************
9462 Change everything needed to ensure POSIX pathname processing (currently
9464 ********************************************************************/
9466 void lp_set_posix_pathnames(void)
9468 posix_pathnames = true;
9471 /*******************************************************************
9472 Global state for POSIX lock processing - CIFS unix extensions.
9473 ********************************************************************/
9475 bool posix_default_lock_was_set;
9476 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9478 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9480 if (posix_default_lock_was_set) {
9481 return posix_cifsx_locktype;
9483 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9487 /*******************************************************************
9488 ********************************************************************/
9490 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9492 posix_default_lock_was_set = true;
9493 posix_cifsx_locktype = val;
9496 int lp_min_receive_file_size(void)
9498 if (Globals.iminreceivefile < 0) {
9501 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9504 /*******************************************************************
9505 If socket address is an empty character string, it is necessary to
9506 define it as "0.0.0.0".
9507 ********************************************************************/
9509 const char *lp_socket_address(void)
9511 char *sock_addr = Globals.szSocketAddress;
9513 if (sock_addr[0] == '\0'){
9514 string_set(&Globals.szSocketAddress, "0.0.0.0");
9516 return Globals.szSocketAddress;
9519 /*******************************************************************
9520 Safe wide links checks.
9521 This helper function always verify the validity of wide links,
9522 even after a configuration file reload.
9523 ********************************************************************/
9525 static bool lp_widelinks_internal(int snum)
9527 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9528 sDefault.bWidelinks);
9531 void widelinks_warning(int snum)
9533 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9534 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9535 "These parameters are incompatible. "
9536 "Wide links will be disabled for this share.\n",
9537 lp_servicename(snum) ));
9541 bool lp_widelinks(int snum)
9543 /* wide links is always incompatible with unix extensions */
9544 if (lp_unix_extensions()) {
9548 return lp_widelinks_internal(snum);
9551 bool lp_writeraw(void)
9553 if (lp_async_smb_echo_handler()) {
9556 return _lp_writeraw();
9559 bool lp_readraw(void)
9561 if (lp_async_smb_echo_handler()) {
9564 return _lp_readraw();