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"
68 #include "dbwrap/dbwrap.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);
313 static void free_param_opts(struct parmlist_entry **popts);
315 static const struct enum_list enum_protocol[] = {
316 {PROTOCOL_SMB2_02, "SMB2"}, /* for now keep PROTOCOL_SMB2_02 */
317 {PROTOCOL_SMB2_10, "SMB2_10"},
318 {PROTOCOL_SMB2_02, "SMB2_02"},
319 {PROTOCOL_NT1, "NT1"},
320 {PROTOCOL_LANMAN2, "LANMAN2"},
321 {PROTOCOL_LANMAN1, "LANMAN1"},
322 {PROTOCOL_CORE, "CORE"},
323 {PROTOCOL_COREPLUS, "COREPLUS"},
324 {PROTOCOL_COREPLUS, "CORE+"},
328 static const struct enum_list enum_security[] = {
329 {SEC_SHARE, "SHARE"},
331 {SEC_SERVER, "SERVER"},
332 {SEC_DOMAIN, "DOMAIN"},
339 static const struct enum_list enum_printing[] = {
340 {PRINT_SYSV, "sysv"},
342 {PRINT_HPUX, "hpux"},
346 {PRINT_LPRNG, "lprng"},
347 {PRINT_CUPS, "cups"},
348 {PRINT_IPRINT, "iprint"},
350 {PRINT_LPROS2, "os2"},
351 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
352 {PRINT_TEST, "test"},
354 #endif /* DEVELOPER */
358 static const struct enum_list enum_ldap_sasl_wrapping[] = {
360 {ADS_AUTH_SASL_SIGN, "sign"},
361 {ADS_AUTH_SASL_SEAL, "seal"},
365 static const struct enum_list enum_ldap_ssl[] = {
366 {LDAP_SSL_OFF, "no"},
367 {LDAP_SSL_OFF, "off"},
368 {LDAP_SSL_START_TLS, "start tls"},
369 {LDAP_SSL_START_TLS, "start_tls"},
373 /* LDAP Dereferencing Alias types */
374 #define SAMBA_LDAP_DEREF_NEVER 0
375 #define SAMBA_LDAP_DEREF_SEARCHING 1
376 #define SAMBA_LDAP_DEREF_FINDING 2
377 #define SAMBA_LDAP_DEREF_ALWAYS 3
379 static const struct enum_list enum_ldap_deref[] = {
380 {SAMBA_LDAP_DEREF_NEVER, "never"},
381 {SAMBA_LDAP_DEREF_SEARCHING, "searching"},
382 {SAMBA_LDAP_DEREF_FINDING, "finding"},
383 {SAMBA_LDAP_DEREF_ALWAYS, "always"},
387 static const struct enum_list enum_ldap_passwd_sync[] = {
388 {LDAP_PASSWD_SYNC_OFF, "no"},
389 {LDAP_PASSWD_SYNC_OFF, "off"},
390 {LDAP_PASSWD_SYNC_ON, "yes"},
391 {LDAP_PASSWD_SYNC_ON, "on"},
392 {LDAP_PASSWD_SYNC_ONLY, "only"},
396 static const struct enum_list enum_map_readonly[] = {
397 {MAP_READONLY_NO, "no"},
398 {MAP_READONLY_NO, "false"},
399 {MAP_READONLY_NO, "0"},
400 {MAP_READONLY_YES, "yes"},
401 {MAP_READONLY_YES, "true"},
402 {MAP_READONLY_YES, "1"},
403 {MAP_READONLY_PERMISSIONS, "permissions"},
404 {MAP_READONLY_PERMISSIONS, "perms"},
408 static const struct enum_list enum_case[] = {
409 {CASE_LOWER, "lower"},
410 {CASE_UPPER, "upper"},
416 static const struct enum_list enum_bool_auto[] = {
427 static const struct enum_list enum_csc_policy[] = {
428 {CSC_POLICY_MANUAL, "manual"},
429 {CSC_POLICY_DOCUMENTS, "documents"},
430 {CSC_POLICY_PROGRAMS, "programs"},
431 {CSC_POLICY_DISABLE, "disable"},
435 /* SMB signing types. */
436 static const struct enum_list enum_smb_signing_vals[] = {
448 {Required, "required"},
449 {Required, "mandatory"},
451 {Required, "forced"},
452 {Required, "enforced"},
456 /* ACL compatibility options. */
457 static const struct enum_list enum_acl_compat_vals[] = {
458 { ACL_COMPAT_AUTO, "auto" },
459 { ACL_COMPAT_WINNT, "winnt" },
460 { ACL_COMPAT_WIN2K, "win2k" },
465 Do you want session setups at user level security with a invalid
466 password to be rejected or allowed in as guest? WinNT rejects them
467 but it can be a pain as it means "net view" needs to use a password
469 You have 3 choices in the setting of map_to_guest:
471 "Never" means session setups with an invalid password
472 are rejected. This is the default.
474 "Bad User" means session setups with an invalid password
475 are rejected, unless the username does not exist, in which case it
476 is treated as a guest login
478 "Bad Password" means session setups with an invalid password
479 are treated as a guest login
481 Note that map_to_guest only has an effect in user or server
485 static const struct enum_list enum_map_to_guest[] = {
486 {NEVER_MAP_TO_GUEST, "Never"},
487 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
488 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
489 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
493 /* Config backend options */
495 static const struct enum_list enum_config_backend[] = {
496 {CONFIG_BACKEND_FILE, "file"},
497 {CONFIG_BACKEND_REGISTRY, "registry"},
501 /* ADS kerberos ticket verification options */
503 static const struct enum_list enum_kerberos_method[] = {
504 {KERBEROS_VERIFY_SECRETS, "default"},
505 {KERBEROS_VERIFY_SECRETS, "secrets only"},
506 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
507 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
508 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
512 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
514 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
515 * screen in SWAT. This is used to exclude parameters as well as to squash all
516 * parameters that have been duplicated by pseudonyms.
518 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
519 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
520 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
523 * NOTE2: Handling of duplicated (synonym) parameters:
524 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
525 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
526 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
527 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
530 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
531 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
533 static struct parm_struct parm_table[] = {
534 {N_("Base Options"), P_SEP, P_SEPARATOR},
537 .label = "dos charset",
540 .offset = GLOBAL_VAR(dos_charset),
541 .special = handle_dos_charset,
543 .flags = FLAG_ADVANCED
546 .label = "unix charset",
549 .offset = GLOBAL_VAR(unix_charset),
550 .special = handle_charset,
552 .flags = FLAG_ADVANCED
558 .offset = LOCAL_VAR(comment),
561 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
567 .offset = LOCAL_VAR(szPath),
570 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
573 .label = "directory",
576 .offset = LOCAL_VAR(szPath),
582 .label = "workgroup",
585 .offset = GLOBAL_VAR(szWorkgroup),
588 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
594 .offset = GLOBAL_VAR(szRealm),
595 .special = handle_realm,
597 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
600 .label = "netbios name",
603 .offset = GLOBAL_VAR(szNetbiosName),
606 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
609 .label = "netbios aliases",
612 .offset = GLOBAL_VAR(szNetbiosAliases),
613 .special = handle_netbios_aliases,
615 .flags = FLAG_ADVANCED,
618 .label = "netbios scope",
621 .offset = GLOBAL_VAR(szNetbiosScope),
624 .flags = FLAG_ADVANCED,
627 .label = "server string",
630 .offset = GLOBAL_VAR(szServerString),
633 .flags = FLAG_BASIC | FLAG_ADVANCED,
636 .label = "interfaces",
639 .offset = GLOBAL_VAR(szInterfaces),
642 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
645 .label = "bind interfaces only",
648 .offset = GLOBAL_VAR(bBindInterfacesOnly),
651 .flags = FLAG_ADVANCED | FLAG_WIZARD,
654 .label = "config backend",
657 .offset = GLOBAL_VAR(ConfigBackend),
659 .enum_list = enum_config_backend,
660 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
663 {N_("Security Options"), P_SEP, P_SEPARATOR},
669 .offset = GLOBAL_VAR(security),
671 .enum_list = enum_security,
672 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
675 .label = "auth methods",
678 .offset = GLOBAL_VAR(AuthMethods),
681 .flags = FLAG_ADVANCED,
684 .label = "encrypt passwords",
687 .offset = GLOBAL_VAR(bEncryptPasswords),
690 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
693 .label = "client schannel",
696 .offset = GLOBAL_VAR(clientSchannel),
698 .enum_list = enum_bool_auto,
699 .flags = FLAG_BASIC | FLAG_ADVANCED,
702 .label = "server schannel",
705 .offset = GLOBAL_VAR(serverSchannel),
707 .enum_list = enum_bool_auto,
708 .flags = FLAG_BASIC | FLAG_ADVANCED,
711 .label = "allow trusted domains",
714 .offset = GLOBAL_VAR(bAllowTrustedDomains),
717 .flags = FLAG_ADVANCED,
720 .label = "map to guest",
723 .offset = GLOBAL_VAR(map_to_guest),
725 .enum_list = enum_map_to_guest,
726 .flags = FLAG_ADVANCED,
729 .label = "null passwords",
732 .offset = GLOBAL_VAR(bNullPasswords),
735 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
738 .label = "obey pam restrictions",
741 .offset = GLOBAL_VAR(bObeyPamRestrictions),
744 .flags = FLAG_ADVANCED,
747 .label = "password server",
750 .offset = GLOBAL_VAR(szPasswordServer),
753 .flags = FLAG_ADVANCED | FLAG_WIZARD,
756 .label = "smb passwd file",
759 .offset = GLOBAL_VAR(szSMBPasswdFile),
762 .flags = FLAG_ADVANCED,
765 .label = "private dir",
768 .offset = GLOBAL_VAR(szPrivateDir),
771 .flags = FLAG_ADVANCED,
774 .label = "passdb backend",
777 .offset = GLOBAL_VAR(szPassdbBackend),
780 .flags = FLAG_ADVANCED | FLAG_WIZARD,
783 .label = "algorithmic rid base",
786 .offset = GLOBAL_VAR(AlgorithmicRidBase),
789 .flags = FLAG_ADVANCED,
792 .label = "root directory",
795 .offset = GLOBAL_VAR(szRootdir),
798 .flags = FLAG_ADVANCED,
804 .offset = GLOBAL_VAR(szRootdir),
813 .offset = GLOBAL_VAR(szRootdir),
819 .label = "guest account",
822 .offset = GLOBAL_VAR(szGuestaccount),
825 .flags = FLAG_BASIC | FLAG_ADVANCED,
828 .label = "enable privileges",
831 .offset = GLOBAL_VAR(bEnablePrivileges),
834 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
838 .label = "pam password change",
841 .offset = GLOBAL_VAR(bPamPasswordChange),
844 .flags = FLAG_ADVANCED,
847 .label = "passwd program",
850 .offset = GLOBAL_VAR(szPasswdProgram),
853 .flags = FLAG_ADVANCED,
856 .label = "passwd chat",
859 .offset = GLOBAL_VAR(szPasswdChat),
862 .flags = FLAG_ADVANCED,
865 .label = "passwd chat debug",
868 .offset = GLOBAL_VAR(bPasswdChatDebug),
871 .flags = FLAG_ADVANCED,
874 .label = "passwd chat timeout",
877 .offset = GLOBAL_VAR(iPasswdChatTimeout),
880 .flags = FLAG_ADVANCED,
883 .label = "check password script",
886 .offset = GLOBAL_VAR(szCheckPasswordScript),
889 .flags = FLAG_ADVANCED,
892 .label = "username map",
895 .offset = GLOBAL_VAR(szUsernameMap),
898 .flags = FLAG_ADVANCED,
901 .label = "password level",
904 .offset = GLOBAL_VAR(pwordlevel),
907 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
910 .label = "username level",
913 .offset = GLOBAL_VAR(unamelevel),
916 .flags = FLAG_ADVANCED,
919 .label = "unix password sync",
922 .offset = GLOBAL_VAR(bUnixPasswdSync),
925 .flags = FLAG_ADVANCED,
928 .label = "restrict anonymous",
931 .offset = GLOBAL_VAR(restrict_anonymous),
934 .flags = FLAG_ADVANCED,
937 .label = "lanman auth",
940 .offset = GLOBAL_VAR(bLanmanAuth),
943 .flags = FLAG_ADVANCED,
946 .label = "ntlm auth",
949 .offset = GLOBAL_VAR(bNTLMAuth),
952 .flags = FLAG_ADVANCED,
955 .label = "client NTLMv2 auth",
958 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
961 .flags = FLAG_ADVANCED,
964 .label = "client lanman auth",
967 .offset = GLOBAL_VAR(bClientLanManAuth),
970 .flags = FLAG_ADVANCED,
973 .label = "client plaintext auth",
976 .offset = GLOBAL_VAR(bClientPlaintextAuth),
979 .flags = FLAG_ADVANCED,
982 .label = "client use spnego principal",
985 .offset = GLOBAL_VAR(client_use_spnego_principal),
988 .flags = FLAG_ADVANCED,
991 .label = "send spnego principal",
994 .offset = GLOBAL_VAR(send_spnego_principal),
997 .flags = FLAG_ADVANCED,
1000 .label = "username",
1003 .offset = LOCAL_VAR(szUsername),
1006 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
1012 .offset = LOCAL_VAR(szUsername),
1021 .offset = LOCAL_VAR(szUsername),
1027 .label = "invalid users",
1030 .offset = LOCAL_VAR(szInvalidUsers),
1033 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1036 .label = "valid users",
1039 .offset = LOCAL_VAR(szValidUsers),
1042 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1045 .label = "admin users",
1048 .offset = LOCAL_VAR(szAdminUsers),
1051 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1054 .label = "read list",
1057 .offset = LOCAL_VAR(readlist),
1060 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1063 .label = "write list",
1066 .offset = LOCAL_VAR(writelist),
1069 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1072 .label = "printer admin",
1075 .offset = LOCAL_VAR(printer_admin),
1078 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1081 .label = "force user",
1084 .offset = LOCAL_VAR(force_user),
1087 .flags = FLAG_ADVANCED | FLAG_SHARE,
1090 .label = "force group",
1093 .offset = LOCAL_VAR(force_group),
1096 .flags = FLAG_ADVANCED | FLAG_SHARE,
1102 .offset = LOCAL_VAR(force_group),
1105 .flags = FLAG_ADVANCED,
1108 .label = "read only",
1111 .offset = LOCAL_VAR(bRead_only),
1114 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1117 .label = "write ok",
1120 .offset = LOCAL_VAR(bRead_only),
1126 .label = "writeable",
1129 .offset = LOCAL_VAR(bRead_only),
1135 .label = "writable",
1138 .offset = LOCAL_VAR(bRead_only),
1144 .label = "acl check permissions",
1147 .offset = LOCAL_VAR(bAclCheckPermissions),
1150 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1153 .label = "acl group control",
1156 .offset = LOCAL_VAR(bAclGroupControl),
1159 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1162 .label = "acl map full control",
1165 .offset = LOCAL_VAR(bAclMapFullControl),
1168 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1171 .label = "create mask",
1174 .offset = LOCAL_VAR(iCreate_mask),
1177 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1180 .label = "create mode",
1183 .offset = LOCAL_VAR(iCreate_mask),
1189 .label = "force create mode",
1192 .offset = LOCAL_VAR(iCreate_force_mode),
1195 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1198 .label = "security mask",
1201 .offset = LOCAL_VAR(iSecurity_mask),
1204 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1207 .label = "force security mode",
1210 .offset = LOCAL_VAR(iSecurity_force_mode),
1213 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1216 .label = "directory mask",
1219 .offset = LOCAL_VAR(iDir_mask),
1222 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1225 .label = "directory mode",
1228 .offset = LOCAL_VAR(iDir_mask),
1231 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1234 .label = "force directory mode",
1237 .offset = LOCAL_VAR(iDir_force_mode),
1240 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1243 .label = "directory security mask",
1246 .offset = LOCAL_VAR(iDir_Security_mask),
1249 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1252 .label = "force directory security mode",
1255 .offset = LOCAL_VAR(iDir_Security_force_mode),
1258 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1261 .label = "force unknown acl user",
1264 .offset = LOCAL_VAR(bForceUnknownAclUser),
1267 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1270 .label = "inherit permissions",
1273 .offset = LOCAL_VAR(bInheritPerms),
1276 .flags = FLAG_ADVANCED | FLAG_SHARE,
1279 .label = "inherit acls",
1282 .offset = LOCAL_VAR(bInheritACLS),
1285 .flags = FLAG_ADVANCED | FLAG_SHARE,
1288 .label = "inherit owner",
1291 .offset = LOCAL_VAR(bInheritOwner),
1294 .flags = FLAG_ADVANCED | FLAG_SHARE,
1297 .label = "guest only",
1300 .offset = LOCAL_VAR(bGuest_only),
1303 .flags = FLAG_ADVANCED | FLAG_SHARE,
1306 .label = "only guest",
1309 .offset = LOCAL_VAR(bGuest_only),
1315 .label = "administrative share",
1318 .offset = LOCAL_VAR(bAdministrative_share),
1321 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1325 .label = "guest ok",
1328 .offset = LOCAL_VAR(bGuest_ok),
1331 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1337 .offset = LOCAL_VAR(bGuest_ok),
1343 .label = "only user",
1346 .offset = LOCAL_VAR(bOnlyUser),
1349 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1352 .label = "hosts allow",
1355 .offset = LOCAL_VAR(szHostsallow),
1358 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1361 .label = "allow hosts",
1364 .offset = LOCAL_VAR(szHostsallow),
1370 .label = "hosts deny",
1373 .offset = LOCAL_VAR(szHostsdeny),
1376 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1379 .label = "deny hosts",
1382 .offset = LOCAL_VAR(szHostsdeny),
1388 .label = "preload modules",
1390 .p_class = P_GLOBAL,
1391 .offset = GLOBAL_VAR(szPreloadModules),
1394 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1397 .label = "dedicated keytab file",
1399 .p_class = P_GLOBAL,
1400 .offset = GLOBAL_VAR(szDedicatedKeytabFile),
1403 .flags = FLAG_ADVANCED,
1406 .label = "kerberos method",
1408 .p_class = P_GLOBAL,
1409 .offset = GLOBAL_VAR(iKerberosMethod),
1411 .enum_list = enum_kerberos_method,
1412 .flags = FLAG_ADVANCED,
1415 .label = "map untrusted to domain",
1417 .p_class = P_GLOBAL,
1418 .offset = GLOBAL_VAR(bMapUntrustedToDomain),
1421 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1425 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1428 .label = "log level",
1430 .p_class = P_GLOBAL,
1431 .offset = GLOBAL_VAR(szLogLevel),
1432 .special = handle_debug_list,
1434 .flags = FLAG_ADVANCED,
1437 .label = "debuglevel",
1439 .p_class = P_GLOBAL,
1440 .offset = GLOBAL_VAR(szLogLevel),
1441 .special = handle_debug_list,
1448 .p_class = P_GLOBAL,
1449 .offset = GLOBAL_VAR(syslog),
1452 .flags = FLAG_ADVANCED,
1455 .label = "syslog only",
1457 .p_class = P_GLOBAL,
1458 .offset = GLOBAL_VAR(bSyslogOnly),
1461 .flags = FLAG_ADVANCED,
1464 .label = "log file",
1466 .p_class = P_GLOBAL,
1467 .offset = GLOBAL_VAR(szLogFile),
1470 .flags = FLAG_ADVANCED,
1473 .label = "max log size",
1475 .p_class = P_GLOBAL,
1476 .offset = GLOBAL_VAR(max_log_size),
1479 .flags = FLAG_ADVANCED,
1482 .label = "debug timestamp",
1484 .p_class = P_GLOBAL,
1485 .offset = GLOBAL_VAR(bTimestampLogs),
1488 .flags = FLAG_ADVANCED,
1491 .label = "timestamp logs",
1493 .p_class = P_GLOBAL,
1494 .offset = GLOBAL_VAR(bTimestampLogs),
1497 .flags = FLAG_ADVANCED,
1500 .label = "debug prefix timestamp",
1502 .p_class = P_GLOBAL,
1503 .offset = GLOBAL_VAR(bDebugPrefixTimestamp),
1506 .flags = FLAG_ADVANCED,
1509 .label = "debug hires timestamp",
1511 .p_class = P_GLOBAL,
1512 .offset = GLOBAL_VAR(bDebugHiresTimestamp),
1515 .flags = FLAG_ADVANCED,
1518 .label = "debug pid",
1520 .p_class = P_GLOBAL,
1521 .offset = GLOBAL_VAR(bDebugPid),
1524 .flags = FLAG_ADVANCED,
1527 .label = "debug uid",
1529 .p_class = P_GLOBAL,
1530 .offset = GLOBAL_VAR(bDebugUid),
1533 .flags = FLAG_ADVANCED,
1536 .label = "debug class",
1538 .p_class = P_GLOBAL,
1539 .offset = GLOBAL_VAR(bDebugClass),
1542 .flags = FLAG_ADVANCED,
1545 .label = "enable core files",
1547 .p_class = P_GLOBAL,
1548 .offset = GLOBAL_VAR(bEnableCoreFiles),
1551 .flags = FLAG_ADVANCED,
1554 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1557 .label = "allocation roundup size",
1560 .offset = LOCAL_VAR(iallocation_roundup_size),
1563 .flags = FLAG_ADVANCED,
1566 .label = "aio read size",
1569 .offset = LOCAL_VAR(iAioReadSize),
1572 .flags = FLAG_ADVANCED,
1575 .label = "aio write size",
1578 .offset = LOCAL_VAR(iAioWriteSize),
1581 .flags = FLAG_ADVANCED,
1584 .label = "aio write behind",
1587 .offset = LOCAL_VAR(szAioWriteBehind),
1590 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1593 .label = "smb ports",
1595 .p_class = P_GLOBAL,
1596 .offset = GLOBAL_VAR(smb_ports),
1599 .flags = FLAG_ADVANCED,
1602 .label = "large readwrite",
1604 .p_class = P_GLOBAL,
1605 .offset = GLOBAL_VAR(bLargeReadwrite),
1608 .flags = FLAG_ADVANCED,
1611 .label = "max protocol",
1613 .p_class = P_GLOBAL,
1614 .offset = GLOBAL_VAR(maxprotocol),
1616 .enum_list = enum_protocol,
1617 .flags = FLAG_ADVANCED,
1620 .label = "protocol",
1622 .p_class = P_GLOBAL,
1623 .offset = GLOBAL_VAR(maxprotocol),
1625 .enum_list = enum_protocol,
1626 .flags = FLAG_ADVANCED,
1629 .label = "min protocol",
1631 .p_class = P_GLOBAL,
1632 .offset = GLOBAL_VAR(minprotocol),
1634 .enum_list = enum_protocol,
1635 .flags = FLAG_ADVANCED,
1638 .label = "min receivefile size",
1640 .p_class = P_GLOBAL,
1641 .offset = GLOBAL_VAR(iminreceivefile),
1644 .flags = FLAG_ADVANCED,
1647 .label = "read raw",
1649 .p_class = P_GLOBAL,
1650 .offset = GLOBAL_VAR(bReadRaw),
1653 .flags = FLAG_ADVANCED,
1656 .label = "write raw",
1658 .p_class = P_GLOBAL,
1659 .offset = GLOBAL_VAR(bWriteRaw),
1662 .flags = FLAG_ADVANCED,
1665 .label = "disable netbios",
1667 .p_class = P_GLOBAL,
1668 .offset = GLOBAL_VAR(bDisableNetbios),
1671 .flags = FLAG_ADVANCED,
1674 .label = "reset on zero vc",
1676 .p_class = P_GLOBAL,
1677 .offset = GLOBAL_VAR(bResetOnZeroVC),
1680 .flags = FLAG_ADVANCED,
1683 .label = "log writeable files on exit",
1685 .p_class = P_GLOBAL,
1686 .offset = GLOBAL_VAR(bLogWriteableFilesOnExit),
1689 .flags = FLAG_ADVANCED,
1692 .label = "acl compatibility",
1694 .p_class = P_GLOBAL,
1695 .offset = GLOBAL_VAR(iAclCompat),
1697 .enum_list = enum_acl_compat_vals,
1698 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1701 .label = "defer sharing violations",
1703 .p_class = P_GLOBAL,
1704 .offset = GLOBAL_VAR(bDeferSharingViolations),
1707 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1710 .label = "ea support",
1713 .offset = LOCAL_VAR(bEASupport),
1716 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1719 .label = "nt acl support",
1722 .offset = LOCAL_VAR(bNTAclSupport),
1725 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1728 .label = "nt pipe support",
1730 .p_class = P_GLOBAL,
1731 .offset = GLOBAL_VAR(bNTPipeSupport),
1734 .flags = FLAG_ADVANCED,
1737 .label = "nt status support",
1739 .p_class = P_GLOBAL,
1740 .offset = GLOBAL_VAR(bNTStatusSupport),
1743 .flags = FLAG_ADVANCED,
1746 .label = "profile acls",
1749 .offset = LOCAL_VAR(bProfileAcls),
1752 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1755 .label = "map acl inherit",
1758 .offset = LOCAL_VAR(bMap_acl_inherit),
1761 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1764 .label = "afs share",
1767 .offset = LOCAL_VAR(bAfs_Share),
1770 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1775 .p_class = P_GLOBAL,
1776 .offset = GLOBAL_VAR(max_mux),
1779 .flags = FLAG_ADVANCED,
1782 .label = "max xmit",
1784 .p_class = P_GLOBAL,
1785 .offset = GLOBAL_VAR(max_xmit),
1788 .flags = FLAG_ADVANCED,
1791 .label = "name resolve order",
1793 .p_class = P_GLOBAL,
1794 .offset = GLOBAL_VAR(szNameResolveOrder),
1797 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1802 .p_class = P_GLOBAL,
1803 .offset = GLOBAL_VAR(max_ttl),
1806 .flags = FLAG_ADVANCED,
1809 .label = "max wins ttl",
1811 .p_class = P_GLOBAL,
1812 .offset = GLOBAL_VAR(max_wins_ttl),
1815 .flags = FLAG_ADVANCED,
1818 .label = "min wins ttl",
1820 .p_class = P_GLOBAL,
1821 .offset = GLOBAL_VAR(min_wins_ttl),
1824 .flags = FLAG_ADVANCED,
1827 .label = "time server",
1829 .p_class = P_GLOBAL,
1830 .offset = GLOBAL_VAR(bTimeServer),
1833 .flags = FLAG_ADVANCED,
1836 .label = "unix extensions",
1838 .p_class = P_GLOBAL,
1839 .offset = GLOBAL_VAR(bUnixExtensions),
1842 .flags = FLAG_ADVANCED,
1845 .label = "use spnego",
1847 .p_class = P_GLOBAL,
1848 .offset = GLOBAL_VAR(bUseSpnego),
1851 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
1854 .label = "client signing",
1856 .p_class = P_GLOBAL,
1857 .offset = GLOBAL_VAR(client_signing),
1859 .enum_list = enum_smb_signing_vals,
1860 .flags = FLAG_ADVANCED,
1863 .label = "server signing",
1865 .p_class = P_GLOBAL,
1866 .offset = GLOBAL_VAR(server_signing),
1868 .enum_list = enum_smb_signing_vals,
1869 .flags = FLAG_ADVANCED,
1872 .label = "smb encrypt",
1875 .offset = LOCAL_VAR(ismb_encrypt),
1877 .enum_list = enum_smb_signing_vals,
1878 .flags = FLAG_ADVANCED,
1881 .label = "client use spnego",
1883 .p_class = P_GLOBAL,
1884 .offset = GLOBAL_VAR(bClientUseSpnego),
1887 .flags = FLAG_ADVANCED,
1890 .label = "client ldap sasl wrapping",
1892 .p_class = P_GLOBAL,
1893 .offset = GLOBAL_VAR(client_ldap_sasl_wrapping),
1895 .enum_list = enum_ldap_sasl_wrapping,
1896 .flags = FLAG_ADVANCED,
1899 .label = "enable asu support",
1901 .p_class = P_GLOBAL,
1902 .offset = GLOBAL_VAR(bASUSupport),
1905 .flags = FLAG_ADVANCED,
1908 .label = "svcctl list",
1910 .p_class = P_GLOBAL,
1911 .offset = GLOBAL_VAR(szServicesList),
1914 .flags = FLAG_ADVANCED,
1917 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
1920 .label = "block size",
1923 .offset = LOCAL_VAR(iBlock_size),
1926 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1929 .label = "deadtime",
1931 .p_class = P_GLOBAL,
1932 .offset = GLOBAL_VAR(deadtime),
1935 .flags = FLAG_ADVANCED,
1938 .label = "getwd cache",
1940 .p_class = P_GLOBAL,
1941 .offset = GLOBAL_VAR(getwd_cache),
1944 .flags = FLAG_ADVANCED,
1947 .label = "keepalive",
1949 .p_class = P_GLOBAL,
1950 .offset = GLOBAL_VAR(iKeepalive),
1953 .flags = FLAG_ADVANCED,
1956 .label = "change notify",
1959 .offset = LOCAL_VAR(bChangeNotify),
1962 .flags = FLAG_ADVANCED | FLAG_SHARE,
1965 .label = "directory name cache size",
1968 .offset = LOCAL_VAR(iDirectoryNameCacheSize),
1971 .flags = FLAG_ADVANCED | FLAG_SHARE,
1974 .label = "kernel change notify",
1977 .offset = LOCAL_VAR(bKernelChangeNotify),
1980 .flags = FLAG_ADVANCED | FLAG_SHARE,
1983 .label = "lpq cache time",
1985 .p_class = P_GLOBAL,
1986 .offset = GLOBAL_VAR(lpqcachetime),
1989 .flags = FLAG_ADVANCED,
1992 .label = "max smbd processes",
1994 .p_class = P_GLOBAL,
1995 .offset = GLOBAL_VAR(iMaxSmbdProcesses),
1998 .flags = FLAG_ADVANCED,
2001 .label = "max connections",
2004 .offset = LOCAL_VAR(iMaxConnections),
2007 .flags = FLAG_ADVANCED | FLAG_SHARE,
2010 .label = "paranoid server security",
2012 .p_class = P_GLOBAL,
2013 .offset = GLOBAL_VAR(paranoid_server_security),
2016 .flags = FLAG_ADVANCED,
2019 .label = "max disk size",
2021 .p_class = P_GLOBAL,
2022 .offset = GLOBAL_VAR(maxdisksize),
2025 .flags = FLAG_ADVANCED,
2028 .label = "max open files",
2030 .p_class = P_GLOBAL,
2031 .offset = GLOBAL_VAR(max_open_files),
2034 .flags = FLAG_ADVANCED,
2037 .label = "min print space",
2040 .offset = LOCAL_VAR(iMinPrintSpace),
2043 .flags = FLAG_ADVANCED | FLAG_PRINT,
2046 .label = "socket options",
2048 .p_class = P_GLOBAL,
2049 .offset = GLOBAL_VAR(szSocketOptions),
2052 .flags = FLAG_ADVANCED,
2055 .label = "strict allocate",
2058 .offset = LOCAL_VAR(bStrictAllocate),
2061 .flags = FLAG_ADVANCED | FLAG_SHARE,
2064 .label = "strict sync",
2067 .offset = LOCAL_VAR(bStrictSync),
2070 .flags = FLAG_ADVANCED | FLAG_SHARE,
2073 .label = "sync always",
2076 .offset = LOCAL_VAR(bSyncAlways),
2079 .flags = FLAG_ADVANCED | FLAG_SHARE,
2082 .label = "use mmap",
2084 .p_class = P_GLOBAL,
2085 .offset = GLOBAL_VAR(bUseMmap),
2088 .flags = FLAG_ADVANCED,
2091 .label = "use sendfile",
2094 .offset = LOCAL_VAR(bUseSendfile),
2097 .flags = FLAG_ADVANCED | FLAG_SHARE,
2100 .label = "hostname lookups",
2102 .p_class = P_GLOBAL,
2103 .offset = GLOBAL_VAR(bHostnameLookups),
2106 .flags = FLAG_ADVANCED,
2109 .label = "write cache size",
2112 .offset = LOCAL_VAR(iWriteCacheSize),
2115 .flags = FLAG_ADVANCED | FLAG_SHARE,
2118 .label = "name cache timeout",
2120 .p_class = P_GLOBAL,
2121 .offset = GLOBAL_VAR(name_cache_timeout),
2124 .flags = FLAG_ADVANCED,
2127 .label = "ctdbd socket",
2129 .p_class = P_GLOBAL,
2130 .offset = GLOBAL_VAR(ctdbdSocket),
2133 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2136 .label = "cluster addresses",
2138 .p_class = P_GLOBAL,
2139 .offset = GLOBAL_VAR(szClusterAddresses),
2142 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2145 .label = "clustering",
2147 .p_class = P_GLOBAL,
2148 .offset = GLOBAL_VAR(clustering),
2151 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2154 .label = "ctdb timeout",
2156 .p_class = P_GLOBAL,
2157 .offset = GLOBAL_VAR(ctdb_timeout),
2160 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2163 .label = "ctdb locktime warn threshold",
2165 .p_class = P_GLOBAL,
2166 .offset = GLOBAL_VAR(ctdb_locktime_warn_threshold),
2169 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2172 .label = "smb2 max read",
2174 .p_class = P_GLOBAL,
2175 .offset = GLOBAL_VAR(ismb2_max_read),
2178 .flags = FLAG_ADVANCED,
2181 .label = "smb2 max write",
2183 .p_class = P_GLOBAL,
2184 .offset = GLOBAL_VAR(ismb2_max_write),
2187 .flags = FLAG_ADVANCED,
2190 .label = "smb2 max trans",
2192 .p_class = P_GLOBAL,
2193 .offset = GLOBAL_VAR(ismb2_max_trans),
2196 .flags = FLAG_ADVANCED,
2199 .label = "smb2 max credits",
2201 .p_class = P_GLOBAL,
2202 .offset = GLOBAL_VAR(ismb2_max_credits),
2205 .flags = FLAG_ADVANCED,
2208 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2211 .label = "max reported print jobs",
2214 .offset = LOCAL_VAR(iMaxReportedPrintJobs),
2217 .flags = FLAG_ADVANCED | FLAG_PRINT,
2220 .label = "max print jobs",
2223 .offset = LOCAL_VAR(iMaxPrintJobs),
2226 .flags = FLAG_ADVANCED | FLAG_PRINT,
2229 .label = "load printers",
2231 .p_class = P_GLOBAL,
2232 .offset = GLOBAL_VAR(bLoadPrinters),
2235 .flags = FLAG_ADVANCED | FLAG_PRINT,
2238 .label = "printcap cache time",
2240 .p_class = P_GLOBAL,
2241 .offset = GLOBAL_VAR(PrintcapCacheTime),
2244 .flags = FLAG_ADVANCED | FLAG_PRINT,
2247 .label = "printcap name",
2249 .p_class = P_GLOBAL,
2250 .offset = GLOBAL_VAR(szPrintcapname),
2253 .flags = FLAG_ADVANCED | FLAG_PRINT,
2256 .label = "printcap",
2258 .p_class = P_GLOBAL,
2259 .offset = GLOBAL_VAR(szPrintcapname),
2265 .label = "printable",
2268 .offset = LOCAL_VAR(bPrint_ok),
2271 .flags = FLAG_ADVANCED | FLAG_PRINT,
2274 .label = "print notify backchannel",
2277 .offset = LOCAL_VAR(bPrintNotifyBackchannel),
2280 .flags = FLAG_ADVANCED,
2283 .label = "print ok",
2286 .offset = LOCAL_VAR(bPrint_ok),
2292 .label = "printing",
2295 .offset = LOCAL_VAR(iPrinting),
2296 .special = handle_printing,
2297 .enum_list = enum_printing,
2298 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2301 .label = "cups options",
2304 .offset = LOCAL_VAR(szCupsOptions),
2307 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2310 .label = "cups server",
2312 .p_class = P_GLOBAL,
2313 .offset = GLOBAL_VAR(szCupsServer),
2316 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2319 .label = "cups encrypt",
2321 .p_class = P_GLOBAL,
2322 .offset = GLOBAL_VAR(CupsEncrypt),
2324 .enum_list = enum_bool_auto,
2325 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2329 .label = "cups connection timeout",
2331 .p_class = P_GLOBAL,
2332 .offset = GLOBAL_VAR(cups_connection_timeout),
2335 .flags = FLAG_ADVANCED,
2338 .label = "iprint server",
2340 .p_class = P_GLOBAL,
2341 .offset = GLOBAL_VAR(szIPrintServer),
2344 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2347 .label = "print command",
2350 .offset = LOCAL_VAR(szPrintcommand),
2353 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2356 .label = "disable spoolss",
2358 .p_class = P_GLOBAL,
2359 .offset = GLOBAL_VAR(bDisableSpoolss),
2362 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2365 .label = "enable spoolss",
2367 .p_class = P_GLOBAL,
2368 .offset = GLOBAL_VAR(bDisableSpoolss),
2374 .label = "lpq command",
2377 .offset = LOCAL_VAR(szLpqcommand),
2380 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2383 .label = "lprm command",
2386 .offset = LOCAL_VAR(szLprmcommand),
2389 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2392 .label = "lppause command",
2395 .offset = LOCAL_VAR(szLppausecommand),
2398 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2401 .label = "lpresume command",
2404 .offset = LOCAL_VAR(szLpresumecommand),
2407 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2410 .label = "queuepause command",
2413 .offset = LOCAL_VAR(szQueuepausecommand),
2416 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2419 .label = "queueresume command",
2422 .offset = LOCAL_VAR(szQueueresumecommand),
2425 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2428 .label = "addport command",
2430 .p_class = P_GLOBAL,
2431 .offset = GLOBAL_VAR(szAddPortCommand),
2434 .flags = FLAG_ADVANCED,
2437 .label = "enumports command",
2439 .p_class = P_GLOBAL,
2440 .offset = GLOBAL_VAR(szEnumPortsCommand),
2443 .flags = FLAG_ADVANCED,
2446 .label = "addprinter command",
2448 .p_class = P_GLOBAL,
2449 .offset = GLOBAL_VAR(szAddPrinterCommand),
2452 .flags = FLAG_ADVANCED,
2455 .label = "deleteprinter command",
2457 .p_class = P_GLOBAL,
2458 .offset = GLOBAL_VAR(szDeletePrinterCommand),
2461 .flags = FLAG_ADVANCED,
2464 .label = "show add printer wizard",
2466 .p_class = P_GLOBAL,
2467 .offset = GLOBAL_VAR(bMsAddPrinterWizard),
2470 .flags = FLAG_ADVANCED,
2473 .label = "os2 driver map",
2475 .p_class = P_GLOBAL,
2476 .offset = GLOBAL_VAR(szOs2DriverMap),
2479 .flags = FLAG_ADVANCED,
2483 .label = "printer name",
2486 .offset = LOCAL_VAR(szPrintername),
2489 .flags = FLAG_ADVANCED | FLAG_PRINT,
2495 .offset = LOCAL_VAR(szPrintername),
2501 .label = "use client driver",
2504 .offset = LOCAL_VAR(bUseClientDriver),
2507 .flags = FLAG_ADVANCED | FLAG_PRINT,
2510 .label = "default devmode",
2513 .offset = LOCAL_VAR(bDefaultDevmode),
2516 .flags = FLAG_ADVANCED | FLAG_PRINT,
2519 .label = "force printername",
2522 .offset = LOCAL_VAR(bForcePrintername),
2525 .flags = FLAG_ADVANCED | FLAG_PRINT,
2528 .label = "printjob username",
2531 .offset = LOCAL_VAR(szPrintjobUsername),
2534 .flags = FLAG_ADVANCED | FLAG_PRINT,
2537 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2540 .label = "mangling method",
2542 .p_class = P_GLOBAL,
2543 .offset = GLOBAL_VAR(szManglingMethod),
2546 .flags = FLAG_ADVANCED,
2549 .label = "mangle prefix",
2551 .p_class = P_GLOBAL,
2552 .offset = GLOBAL_VAR(mangle_prefix),
2555 .flags = FLAG_ADVANCED,
2559 .label = "default case",
2562 .offset = LOCAL_VAR(iDefaultCase),
2564 .enum_list = enum_case,
2565 .flags = FLAG_ADVANCED | FLAG_SHARE,
2568 .label = "case sensitive",
2571 .offset = LOCAL_VAR(iCaseSensitive),
2573 .enum_list = enum_bool_auto,
2574 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2577 .label = "casesignames",
2580 .offset = LOCAL_VAR(iCaseSensitive),
2582 .enum_list = enum_bool_auto,
2583 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2586 .label = "preserve case",
2589 .offset = LOCAL_VAR(bCasePreserve),
2592 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2595 .label = "short preserve case",
2598 .offset = LOCAL_VAR(bShortCasePreserve),
2601 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2604 .label = "mangling char",
2607 .offset = LOCAL_VAR(magic_char),
2610 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2613 .label = "hide dot files",
2616 .offset = LOCAL_VAR(bHideDotFiles),
2619 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2622 .label = "hide special files",
2625 .offset = LOCAL_VAR(bHideSpecialFiles),
2628 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2631 .label = "hide unreadable",
2634 .offset = LOCAL_VAR(bHideUnReadable),
2637 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2640 .label = "hide unwriteable files",
2643 .offset = LOCAL_VAR(bHideUnWriteableFiles),
2646 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2649 .label = "delete veto files",
2652 .offset = LOCAL_VAR(bDeleteVetoFiles),
2655 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2658 .label = "veto files",
2661 .offset = LOCAL_VAR(szVetoFiles),
2664 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2667 .label = "hide files",
2670 .offset = LOCAL_VAR(szHideFiles),
2673 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2676 .label = "veto oplock files",
2679 .offset = LOCAL_VAR(szVetoOplockFiles),
2682 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2685 .label = "map archive",
2688 .offset = LOCAL_VAR(bMap_archive),
2691 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2694 .label = "map hidden",
2697 .offset = LOCAL_VAR(bMap_hidden),
2700 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2703 .label = "map system",
2706 .offset = LOCAL_VAR(bMap_system),
2709 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2712 .label = "map readonly",
2715 .offset = LOCAL_VAR(iMap_readonly),
2717 .enum_list = enum_map_readonly,
2718 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2721 .label = "mangled names",
2724 .offset = LOCAL_VAR(bMangledNames),
2727 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2730 .label = "max stat cache size",
2732 .p_class = P_GLOBAL,
2733 .offset = GLOBAL_VAR(iMaxStatCacheSize),
2736 .flags = FLAG_ADVANCED,
2739 .label = "stat cache",
2741 .p_class = P_GLOBAL,
2742 .offset = GLOBAL_VAR(bStatCache),
2745 .flags = FLAG_ADVANCED,
2748 .label = "store dos attributes",
2751 .offset = LOCAL_VAR(bStoreDosAttributes),
2754 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2757 .label = "dmapi support",
2760 .offset = LOCAL_VAR(bDmapiSupport),
2763 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2767 {N_("Domain Options"), P_SEP, P_SEPARATOR},
2770 .label = "machine password timeout",
2772 .p_class = P_GLOBAL,
2773 .offset = GLOBAL_VAR(machine_password_timeout),
2776 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2779 {N_("Logon Options"), P_SEP, P_SEPARATOR},
2782 .label = "add user script",
2784 .p_class = P_GLOBAL,
2785 .offset = GLOBAL_VAR(szAddUserScript),
2788 .flags = FLAG_ADVANCED,
2791 .label = "rename user script",
2793 .p_class = P_GLOBAL,
2794 .offset = GLOBAL_VAR(szRenameUserScript),
2797 .flags = FLAG_ADVANCED,
2800 .label = "delete user script",
2802 .p_class = P_GLOBAL,
2803 .offset = GLOBAL_VAR(szDelUserScript),
2806 .flags = FLAG_ADVANCED,
2809 .label = "add group script",
2811 .p_class = P_GLOBAL,
2812 .offset = GLOBAL_VAR(szAddGroupScript),
2815 .flags = FLAG_ADVANCED,
2818 .label = "delete group script",
2820 .p_class = P_GLOBAL,
2821 .offset = GLOBAL_VAR(szDelGroupScript),
2824 .flags = FLAG_ADVANCED,
2827 .label = "add user to group script",
2829 .p_class = P_GLOBAL,
2830 .offset = GLOBAL_VAR(szAddUserToGroupScript),
2833 .flags = FLAG_ADVANCED,
2836 .label = "delete user from group script",
2838 .p_class = P_GLOBAL,
2839 .offset = GLOBAL_VAR(szDelUserFromGroupScript),
2842 .flags = FLAG_ADVANCED,
2845 .label = "set primary group script",
2847 .p_class = P_GLOBAL,
2848 .offset = GLOBAL_VAR(szSetPrimaryGroupScript),
2851 .flags = FLAG_ADVANCED,
2854 .label = "add machine script",
2856 .p_class = P_GLOBAL,
2857 .offset = GLOBAL_VAR(szAddMachineScript),
2860 .flags = FLAG_ADVANCED,
2863 .label = "shutdown script",
2865 .p_class = P_GLOBAL,
2866 .offset = GLOBAL_VAR(szShutdownScript),
2869 .flags = FLAG_ADVANCED,
2872 .label = "abort shutdown script",
2874 .p_class = P_GLOBAL,
2875 .offset = GLOBAL_VAR(szAbortShutdownScript),
2878 .flags = FLAG_ADVANCED,
2881 .label = "username map script",
2883 .p_class = P_GLOBAL,
2884 .offset = GLOBAL_VAR(szUsernameMapScript),
2887 .flags = FLAG_ADVANCED,
2890 .label = "username map cache time",
2892 .p_class = P_GLOBAL,
2893 .offset = GLOBAL_VAR(iUsernameMapCacheTime),
2896 .flags = FLAG_ADVANCED,
2899 .label = "logon script",
2901 .p_class = P_GLOBAL,
2902 .offset = GLOBAL_VAR(szLogonScript),
2905 .flags = FLAG_ADVANCED,
2908 .label = "logon path",
2910 .p_class = P_GLOBAL,
2911 .offset = GLOBAL_VAR(szLogonPath),
2914 .flags = FLAG_ADVANCED,
2917 .label = "logon drive",
2919 .p_class = P_GLOBAL,
2920 .offset = GLOBAL_VAR(szLogonDrive),
2923 .flags = FLAG_ADVANCED,
2926 .label = "logon home",
2928 .p_class = P_GLOBAL,
2929 .offset = GLOBAL_VAR(szLogonHome),
2932 .flags = FLAG_ADVANCED,
2935 .label = "domain logons",
2937 .p_class = P_GLOBAL,
2938 .offset = GLOBAL_VAR(bDomainLogons),
2941 .flags = FLAG_ADVANCED,
2945 .label = "init logon delayed hosts",
2947 .p_class = P_GLOBAL,
2948 .offset = GLOBAL_VAR(szInitLogonDelayedHosts),
2951 .flags = FLAG_ADVANCED,
2955 .label = "init logon delay",
2957 .p_class = P_GLOBAL,
2958 .offset = GLOBAL_VAR(InitLogonDelay),
2961 .flags = FLAG_ADVANCED,
2965 {N_("Browse Options"), P_SEP, P_SEPARATOR},
2968 .label = "os level",
2970 .p_class = P_GLOBAL,
2971 .offset = GLOBAL_VAR(os_level),
2974 .flags = FLAG_BASIC | FLAG_ADVANCED,
2977 .label = "lm announce",
2979 .p_class = P_GLOBAL,
2980 .offset = GLOBAL_VAR(lm_announce),
2982 .enum_list = enum_bool_auto,
2983 .flags = FLAG_ADVANCED,
2986 .label = "lm interval",
2988 .p_class = P_GLOBAL,
2989 .offset = GLOBAL_VAR(lm_interval),
2992 .flags = FLAG_ADVANCED,
2995 .label = "preferred master",
2997 .p_class = P_GLOBAL,
2998 .offset = GLOBAL_VAR(iPreferredMaster),
3000 .enum_list = enum_bool_auto,
3001 .flags = FLAG_BASIC | FLAG_ADVANCED,
3004 .label = "prefered master",
3006 .p_class = P_GLOBAL,
3007 .offset = GLOBAL_VAR(iPreferredMaster),
3009 .enum_list = enum_bool_auto,
3013 .label = "local master",
3015 .p_class = P_GLOBAL,
3016 .offset = GLOBAL_VAR(bLocalMaster),
3019 .flags = FLAG_BASIC | FLAG_ADVANCED,
3022 .label = "domain master",
3024 .p_class = P_GLOBAL,
3025 .offset = GLOBAL_VAR(iDomainMaster),
3027 .enum_list = enum_bool_auto,
3028 .flags = FLAG_BASIC | FLAG_ADVANCED,
3031 .label = "browse list",
3033 .p_class = P_GLOBAL,
3034 .offset = GLOBAL_VAR(bBrowseList),
3037 .flags = FLAG_ADVANCED,
3040 .label = "browseable",
3043 .offset = LOCAL_VAR(bBrowseable),
3046 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3049 .label = "browsable",
3052 .offset = LOCAL_VAR(bBrowseable),
3058 .label = "access based share enum",
3061 .offset = LOCAL_VAR(bAccessBasedShareEnum),
3064 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3067 .label = "enhanced browsing",
3069 .p_class = P_GLOBAL,
3070 .offset = GLOBAL_VAR(enhanced_browsing),
3073 .flags = FLAG_ADVANCED,
3076 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3079 .label = "dns proxy",
3081 .p_class = P_GLOBAL,
3082 .offset = GLOBAL_VAR(bDNSproxy),
3085 .flags = FLAG_ADVANCED,
3088 .label = "wins proxy",
3090 .p_class = P_GLOBAL,
3091 .offset = GLOBAL_VAR(bWINSproxy),
3094 .flags = FLAG_ADVANCED,
3097 .label = "wins server",
3099 .p_class = P_GLOBAL,
3100 .offset = GLOBAL_VAR(szWINSservers),
3103 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3106 .label = "wins support",
3108 .p_class = P_GLOBAL,
3109 .offset = GLOBAL_VAR(bWINSsupport),
3112 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3115 .label = "wins hook",
3117 .p_class = P_GLOBAL,
3118 .offset = GLOBAL_VAR(szWINSHook),
3121 .flags = FLAG_ADVANCED,
3124 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3127 .label = "blocking locks",
3130 .offset = LOCAL_VAR(bBlockingLocks),
3133 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3136 .label = "csc policy",
3139 .offset = LOCAL_VAR(iCSCPolicy),
3141 .enum_list = enum_csc_policy,
3142 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3145 .label = "fake oplocks",
3148 .offset = LOCAL_VAR(bFakeOplocks),
3151 .flags = FLAG_ADVANCED | FLAG_SHARE,
3154 .label = "kernel oplocks",
3156 .p_class = P_GLOBAL,
3157 .offset = GLOBAL_VAR(bKernelOplocks),
3160 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3166 .offset = LOCAL_VAR(bLocking),
3169 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3172 .label = "lock spin time",
3174 .p_class = P_GLOBAL,
3175 .offset = GLOBAL_VAR(iLockSpinTime),
3178 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3184 .offset = LOCAL_VAR(bOpLocks),
3187 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3190 .label = "level2 oplocks",
3193 .offset = LOCAL_VAR(bLevel2OpLocks),
3196 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3199 .label = "oplock break wait time",
3201 .p_class = P_GLOBAL,
3202 .offset = GLOBAL_VAR(oplock_break_wait_time),
3205 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3208 .label = "oplock contention limit",
3211 .offset = LOCAL_VAR(iOplockContentionLimit),
3214 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3217 .label = "posix locking",
3220 .offset = LOCAL_VAR(bPosixLocking),
3223 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3226 .label = "strict locking",
3229 .offset = LOCAL_VAR(iStrictLocking),
3231 .enum_list = enum_bool_auto,
3232 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3235 .label = "share modes",
3238 .offset = LOCAL_VAR(bShareModes),
3241 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3244 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3247 .label = "ldap admin dn",
3249 .p_class = P_GLOBAL,
3250 .offset = GLOBAL_VAR(szLdapAdminDn),
3253 .flags = FLAG_ADVANCED,
3256 .label = "ldap delete dn",
3258 .p_class = P_GLOBAL,
3259 .offset = GLOBAL_VAR(ldap_delete_dn),
3262 .flags = FLAG_ADVANCED,
3265 .label = "ldap group suffix",
3267 .p_class = P_GLOBAL,
3268 .offset = GLOBAL_VAR(szLdapGroupSuffix),
3271 .flags = FLAG_ADVANCED,
3274 .label = "ldap idmap suffix",
3276 .p_class = P_GLOBAL,
3277 .offset = GLOBAL_VAR(szLdapIdmapSuffix),
3280 .flags = FLAG_ADVANCED,
3283 .label = "ldap machine suffix",
3285 .p_class = P_GLOBAL,
3286 .offset = GLOBAL_VAR(szLdapMachineSuffix),
3289 .flags = FLAG_ADVANCED,
3292 .label = "ldap passwd sync",
3294 .p_class = P_GLOBAL,
3295 .offset = GLOBAL_VAR(ldap_passwd_sync),
3297 .enum_list = enum_ldap_passwd_sync,
3298 .flags = FLAG_ADVANCED,
3301 .label = "ldap password sync",
3303 .p_class = P_GLOBAL,
3304 .offset = GLOBAL_VAR(ldap_passwd_sync),
3306 .enum_list = enum_ldap_passwd_sync,
3310 .label = "ldap replication sleep",
3312 .p_class = P_GLOBAL,
3313 .offset = GLOBAL_VAR(ldap_replication_sleep),
3316 .flags = FLAG_ADVANCED,
3319 .label = "ldap suffix",
3321 .p_class = P_GLOBAL,
3322 .offset = GLOBAL_VAR(szLdapSuffix),
3325 .flags = FLAG_ADVANCED,
3328 .label = "ldap ssl",
3330 .p_class = P_GLOBAL,
3331 .offset = GLOBAL_VAR(ldap_ssl),
3333 .enum_list = enum_ldap_ssl,
3334 .flags = FLAG_ADVANCED,
3337 .label = "ldap ssl ads",
3339 .p_class = P_GLOBAL,
3340 .offset = GLOBAL_VAR(ldap_ssl_ads),
3343 .flags = FLAG_ADVANCED,
3346 .label = "ldap deref",
3348 .p_class = P_GLOBAL,
3349 .offset = GLOBAL_VAR(ldap_deref),
3351 .enum_list = enum_ldap_deref,
3352 .flags = FLAG_ADVANCED,
3355 .label = "ldap follow referral",
3357 .p_class = P_GLOBAL,
3358 .offset = GLOBAL_VAR(ldap_follow_referral),
3360 .enum_list = enum_bool_auto,
3361 .flags = FLAG_ADVANCED,
3364 .label = "ldap timeout",
3366 .p_class = P_GLOBAL,
3367 .offset = GLOBAL_VAR(ldap_timeout),
3370 .flags = FLAG_ADVANCED,
3373 .label = "ldap connection timeout",
3375 .p_class = P_GLOBAL,
3376 .offset = GLOBAL_VAR(ldap_connection_timeout),
3379 .flags = FLAG_ADVANCED,
3382 .label = "ldap page size",
3384 .p_class = P_GLOBAL,
3385 .offset = GLOBAL_VAR(ldap_page_size),
3388 .flags = FLAG_ADVANCED,
3391 .label = "ldap user suffix",
3393 .p_class = P_GLOBAL,
3394 .offset = GLOBAL_VAR(szLdapUserSuffix),
3397 .flags = FLAG_ADVANCED,
3400 .label = "ldap debug level",
3402 .p_class = P_GLOBAL,
3403 .offset = GLOBAL_VAR(ldap_debug_level),
3404 .special = handle_ldap_debug_level,
3406 .flags = FLAG_ADVANCED,
3409 .label = "ldap debug threshold",
3411 .p_class = P_GLOBAL,
3412 .offset = GLOBAL_VAR(ldap_debug_threshold),
3415 .flags = FLAG_ADVANCED,
3418 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3421 .label = "eventlog list",
3423 .p_class = P_GLOBAL,
3424 .offset = GLOBAL_VAR(szEventLogs),
3427 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3430 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3433 .label = "add share command",
3435 .p_class = P_GLOBAL,
3436 .offset = GLOBAL_VAR(szAddShareCommand),
3439 .flags = FLAG_ADVANCED,
3442 .label = "change share command",
3444 .p_class = P_GLOBAL,
3445 .offset = GLOBAL_VAR(szChangeShareCommand),
3448 .flags = FLAG_ADVANCED,
3451 .label = "delete share command",
3453 .p_class = P_GLOBAL,
3454 .offset = GLOBAL_VAR(szDeleteShareCommand),
3457 .flags = FLAG_ADVANCED,
3460 .label = "config file",
3462 .p_class = P_GLOBAL,
3463 .offset = GLOBAL_VAR(szConfigFile),
3466 .flags = FLAG_HIDE|FLAG_META,
3471 .p_class = P_GLOBAL,
3472 .offset = GLOBAL_VAR(szAutoServices),
3475 .flags = FLAG_ADVANCED,
3478 .label = "auto services",
3480 .p_class = P_GLOBAL,
3481 .offset = GLOBAL_VAR(szAutoServices),
3484 .flags = FLAG_ADVANCED,
3487 .label = "lock directory",
3489 .p_class = P_GLOBAL,
3490 .offset = GLOBAL_VAR(szLockDir),
3493 .flags = FLAG_ADVANCED,
3496 .label = "lock dir",
3498 .p_class = P_GLOBAL,
3499 .offset = GLOBAL_VAR(szLockDir),
3505 .label = "state directory",
3507 .p_class = P_GLOBAL,
3508 .offset = GLOBAL_VAR(szStateDir),
3511 .flags = FLAG_ADVANCED,
3514 .label = "cache directory",
3516 .p_class = P_GLOBAL,
3517 .offset = GLOBAL_VAR(szCacheDir),
3520 .flags = FLAG_ADVANCED,
3523 .label = "pid directory",
3525 .p_class = P_GLOBAL,
3526 .offset = GLOBAL_VAR(szPidDir),
3529 .flags = FLAG_ADVANCED,
3533 .label = "utmp directory",
3535 .p_class = P_GLOBAL,
3536 .offset = GLOBAL_VAR(szUtmpDir),
3539 .flags = FLAG_ADVANCED,
3542 .label = "wtmp directory",
3544 .p_class = P_GLOBAL,
3545 .offset = GLOBAL_VAR(szWtmpDir),
3548 .flags = FLAG_ADVANCED,
3553 .p_class = P_GLOBAL,
3554 .offset = GLOBAL_VAR(bUtmp),
3557 .flags = FLAG_ADVANCED,
3561 .label = "default service",
3563 .p_class = P_GLOBAL,
3564 .offset = GLOBAL_VAR(szDefaultService),
3567 .flags = FLAG_ADVANCED,
3572 .p_class = P_GLOBAL,
3573 .offset = GLOBAL_VAR(szDefaultService),
3576 .flags = FLAG_ADVANCED,
3579 .label = "message command",
3581 .p_class = P_GLOBAL,
3582 .offset = GLOBAL_VAR(szMsgCommand),
3585 .flags = FLAG_ADVANCED,
3588 .label = "dfree cache time",
3591 .offset = LOCAL_VAR(iDfreeCacheTime),
3594 .flags = FLAG_ADVANCED,
3597 .label = "dfree command",
3600 .offset = LOCAL_VAR(szDfree),
3603 .flags = FLAG_ADVANCED,
3606 .label = "get quota command",
3608 .p_class = P_GLOBAL,
3609 .offset = GLOBAL_VAR(szGetQuota),
3612 .flags = FLAG_ADVANCED,
3615 .label = "set quota command",
3617 .p_class = P_GLOBAL,
3618 .offset = GLOBAL_VAR(szSetQuota),
3621 .flags = FLAG_ADVANCED,
3624 .label = "remote announce",
3626 .p_class = P_GLOBAL,
3627 .offset = GLOBAL_VAR(szRemoteAnnounce),
3630 .flags = FLAG_ADVANCED,
3633 .label = "remote browse sync",
3635 .p_class = P_GLOBAL,
3636 .offset = GLOBAL_VAR(szRemoteBrowseSync),
3639 .flags = FLAG_ADVANCED,
3642 .label = "socket address",
3644 .p_class = P_GLOBAL,
3645 .offset = GLOBAL_VAR(szSocketAddress),
3648 .flags = FLAG_ADVANCED,
3651 .label = "nmbd bind explicit broadcast",
3653 .p_class = P_GLOBAL,
3654 .offset = GLOBAL_VAR(bNmbdBindExplicitBroadcast),
3657 .flags = FLAG_ADVANCED,
3660 .label = "homedir map",
3662 .p_class = P_GLOBAL,
3663 .offset = GLOBAL_VAR(szNISHomeMapName),
3666 .flags = FLAG_ADVANCED,
3669 .label = "afs username map",
3671 .p_class = P_GLOBAL,
3672 .offset = GLOBAL_VAR(szAfsUsernameMap),
3675 .flags = FLAG_ADVANCED,
3678 .label = "afs token lifetime",
3680 .p_class = P_GLOBAL,
3681 .offset = GLOBAL_VAR(iAfsTokenLifetime),
3684 .flags = FLAG_ADVANCED,
3687 .label = "log nt token command",
3689 .p_class = P_GLOBAL,
3690 .offset = GLOBAL_VAR(szLogNtTokenCommand),
3693 .flags = FLAG_ADVANCED,
3696 .label = "NIS homedir",
3698 .p_class = P_GLOBAL,
3699 .offset = GLOBAL_VAR(bNISHomeMap),
3702 .flags = FLAG_ADVANCED,
3708 .offset = LOCAL_VAR(valid),
3717 .offset = LOCAL_VAR(szCopy),
3718 .special = handle_copy,
3726 .offset = LOCAL_VAR(szInclude),
3727 .special = handle_include,
3729 .flags = FLAG_HIDE|FLAG_META,
3735 .offset = LOCAL_VAR(szPreExec),
3738 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3744 .offset = LOCAL_VAR(szPreExec),
3747 .flags = FLAG_ADVANCED,
3750 .label = "preexec close",
3753 .offset = LOCAL_VAR(bPreexecClose),
3756 .flags = FLAG_ADVANCED | FLAG_SHARE,
3759 .label = "postexec",
3762 .offset = LOCAL_VAR(szPostExec),
3765 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3768 .label = "root preexec",
3771 .offset = LOCAL_VAR(szRootPreExec),
3774 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3777 .label = "root preexec close",
3780 .offset = LOCAL_VAR(bRootpreexecClose),
3783 .flags = FLAG_ADVANCED | FLAG_SHARE,
3786 .label = "root postexec",
3789 .offset = LOCAL_VAR(szRootPostExec),
3792 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3795 .label = "available",
3798 .offset = LOCAL_VAR(bAvailable),
3801 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3804 .label = "registry shares",
3806 .p_class = P_GLOBAL,
3807 .offset = GLOBAL_VAR(bRegistryShares),
3810 .flags = FLAG_ADVANCED,
3813 .label = "usershare allow guests",
3815 .p_class = P_GLOBAL,
3816 .offset = GLOBAL_VAR(bUsershareAllowGuests),
3819 .flags = FLAG_ADVANCED,
3822 .label = "usershare max shares",
3824 .p_class = P_GLOBAL,
3825 .offset = GLOBAL_VAR(iUsershareMaxShares),
3828 .flags = FLAG_ADVANCED,
3831 .label = "usershare owner only",
3833 .p_class = P_GLOBAL,
3834 .offset = GLOBAL_VAR(bUsershareOwnerOnly),
3837 .flags = FLAG_ADVANCED,
3840 .label = "usershare path",
3842 .p_class = P_GLOBAL,
3843 .offset = GLOBAL_VAR(szUsersharePath),
3846 .flags = FLAG_ADVANCED,
3849 .label = "usershare prefix allow list",
3851 .p_class = P_GLOBAL,
3852 .offset = GLOBAL_VAR(szUsersharePrefixAllowList),
3855 .flags = FLAG_ADVANCED,
3858 .label = "usershare prefix deny list",
3860 .p_class = P_GLOBAL,
3861 .offset = GLOBAL_VAR(szUsersharePrefixDenyList),
3864 .flags = FLAG_ADVANCED,
3867 .label = "usershare template share",
3869 .p_class = P_GLOBAL,
3870 .offset = GLOBAL_VAR(szUsershareTemplateShare),
3873 .flags = FLAG_ADVANCED,
3879 .offset = LOCAL_VAR(volume),
3882 .flags = FLAG_ADVANCED | FLAG_SHARE,
3888 .offset = LOCAL_VAR(fstype),
3891 .flags = FLAG_ADVANCED | FLAG_SHARE,
3894 .label = "set directory",
3897 .offset = LOCAL_VAR(bNo_set_dir),
3900 .flags = FLAG_ADVANCED | FLAG_SHARE,
3903 .label = "allow insecure wide links",
3905 .p_class = P_GLOBAL,
3906 .offset = GLOBAL_VAR(bAllowInsecureWidelinks),
3909 .flags = FLAG_ADVANCED,
3912 .label = "wide links",
3915 .offset = LOCAL_VAR(bWidelinks),
3918 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3921 .label = "follow symlinks",
3924 .offset = LOCAL_VAR(bSymlinks),
3927 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3930 .label = "dont descend",
3933 .offset = LOCAL_VAR(szDontdescend),
3936 .flags = FLAG_ADVANCED | FLAG_SHARE,
3939 .label = "magic script",
3942 .offset = LOCAL_VAR(szMagicScript),
3945 .flags = FLAG_ADVANCED | FLAG_SHARE,
3948 .label = "magic output",
3951 .offset = LOCAL_VAR(szMagicOutput),
3954 .flags = FLAG_ADVANCED | FLAG_SHARE,
3957 .label = "delete readonly",
3960 .offset = LOCAL_VAR(bDeleteReadonly),
3963 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3966 .label = "dos filemode",
3969 .offset = LOCAL_VAR(bDosFilemode),
3972 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3975 .label = "dos filetimes",
3978 .offset = LOCAL_VAR(bDosFiletimes),
3981 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3984 .label = "dos filetime resolution",
3987 .offset = LOCAL_VAR(bDosFiletimeResolution),
3990 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3993 .label = "fake directory create times",
3996 .offset = LOCAL_VAR(bFakeDirCreateTimes),
3999 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4002 .label = "async smb echo handler",
4004 .p_class = P_GLOBAL,
4005 .offset = GLOBAL_VAR(bAsyncSMBEchoHandler),
4008 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4011 .label = "multicast dns register",
4013 .p_class = P_GLOBAL,
4014 .offset = GLOBAL_VAR(bMulticastDnsRegister),
4017 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4020 .label = "panic action",
4022 .p_class = P_GLOBAL,
4023 .offset = GLOBAL_VAR(szPanicAction),
4026 .flags = FLAG_ADVANCED,
4029 .label = "perfcount module",
4031 .p_class = P_GLOBAL,
4032 .offset = GLOBAL_VAR(szSMBPerfcountModule),
4035 .flags = FLAG_ADVANCED,
4038 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4041 .label = "vfs objects",
4044 .offset = LOCAL_VAR(szVfsObjects),
4047 .flags = FLAG_ADVANCED | FLAG_SHARE,
4050 .label = "vfs object",
4053 .offset = LOCAL_VAR(szVfsObjects),
4060 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4063 .label = "msdfs root",
4066 .offset = LOCAL_VAR(bMSDfsRoot),
4069 .flags = FLAG_ADVANCED | FLAG_SHARE,
4072 .label = "msdfs proxy",
4075 .offset = LOCAL_VAR(szMSDfsProxy),
4078 .flags = FLAG_ADVANCED | FLAG_SHARE,
4081 .label = "host msdfs",
4083 .p_class = P_GLOBAL,
4084 .offset = GLOBAL_VAR(bHostMSDfs),
4087 .flags = FLAG_ADVANCED,
4090 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4093 .label = "passdb expand explicit",
4095 .p_class = P_GLOBAL,
4096 .offset = GLOBAL_VAR(bPassdbExpandExplicit),
4099 .flags = FLAG_ADVANCED,
4102 .label = "idmap backend",
4104 .p_class = P_GLOBAL,
4105 .offset = GLOBAL_VAR(szIdmapBackend),
4106 .special = handle_idmap_backend,
4108 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4111 .label = "idmap cache time",
4113 .p_class = P_GLOBAL,
4114 .offset = GLOBAL_VAR(iIdmapCacheTime),
4117 .flags = FLAG_ADVANCED,
4120 .label = "idmap negative cache time",
4122 .p_class = P_GLOBAL,
4123 .offset = GLOBAL_VAR(iIdmapNegativeCacheTime),
4126 .flags = FLAG_ADVANCED,
4129 .label = "idmap uid",
4131 .p_class = P_GLOBAL,
4132 .offset = GLOBAL_VAR(szIdmapUID),
4133 .special = handle_idmap_uid,
4135 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4138 .label = "winbind uid",
4140 .p_class = P_GLOBAL,
4141 .offset = GLOBAL_VAR(szIdmapUID),
4142 .special = handle_idmap_uid,
4147 .label = "idmap gid",
4149 .p_class = P_GLOBAL,
4150 .offset = GLOBAL_VAR(szIdmapGID),
4151 .special = handle_idmap_gid,
4153 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4156 .label = "winbind gid",
4158 .p_class = P_GLOBAL,
4159 .offset = GLOBAL_VAR(szIdmapGID),
4160 .special = handle_idmap_gid,
4165 .label = "template homedir",
4167 .p_class = P_GLOBAL,
4168 .offset = GLOBAL_VAR(szTemplateHomedir),
4171 .flags = FLAG_ADVANCED,
4174 .label = "template shell",
4176 .p_class = P_GLOBAL,
4177 .offset = GLOBAL_VAR(szTemplateShell),
4180 .flags = FLAG_ADVANCED,
4183 .label = "winbind separator",
4185 .p_class = P_GLOBAL,
4186 .offset = GLOBAL_VAR(szWinbindSeparator),
4189 .flags = FLAG_ADVANCED,
4192 .label = "winbind cache time",
4194 .p_class = P_GLOBAL,
4195 .offset = GLOBAL_VAR(winbind_cache_time),
4198 .flags = FLAG_ADVANCED,
4201 .label = "winbind reconnect delay",
4203 .p_class = P_GLOBAL,
4204 .offset = GLOBAL_VAR(winbind_reconnect_delay),
4207 .flags = FLAG_ADVANCED,
4210 .label = "winbind max clients",
4212 .p_class = P_GLOBAL,
4213 .offset = GLOBAL_VAR(winbind_max_clients),
4216 .flags = FLAG_ADVANCED,
4219 .label = "winbind enum users",
4221 .p_class = P_GLOBAL,
4222 .offset = GLOBAL_VAR(bWinbindEnumUsers),
4225 .flags = FLAG_ADVANCED,
4228 .label = "winbind enum groups",
4230 .p_class = P_GLOBAL,
4231 .offset = GLOBAL_VAR(bWinbindEnumGroups),
4234 .flags = FLAG_ADVANCED,
4237 .label = "winbind use default domain",
4239 .p_class = P_GLOBAL,
4240 .offset = GLOBAL_VAR(bWinbindUseDefaultDomain),
4243 .flags = FLAG_ADVANCED,
4246 .label = "winbind trusted domains only",
4248 .p_class = P_GLOBAL,
4249 .offset = GLOBAL_VAR(bWinbindTrustedDomainsOnly),
4252 .flags = FLAG_ADVANCED,
4255 .label = "winbind nested groups",
4257 .p_class = P_GLOBAL,
4258 .offset = GLOBAL_VAR(bWinbindNestedGroups),
4261 .flags = FLAG_ADVANCED,
4264 .label = "winbind expand groups",
4266 .p_class = P_GLOBAL,
4267 .offset = GLOBAL_VAR(winbind_expand_groups),
4270 .flags = FLAG_ADVANCED,
4273 .label = "winbind nss info",
4275 .p_class = P_GLOBAL,
4276 .offset = GLOBAL_VAR(szWinbindNssInfo),
4279 .flags = FLAG_ADVANCED,
4282 .label = "winbind refresh tickets",
4284 .p_class = P_GLOBAL,
4285 .offset = GLOBAL_VAR(bWinbindRefreshTickets),
4288 .flags = FLAG_ADVANCED,
4291 .label = "winbind offline logon",
4293 .p_class = P_GLOBAL,
4294 .offset = GLOBAL_VAR(bWinbindOfflineLogon),
4297 .flags = FLAG_ADVANCED,
4300 .label = "winbind normalize names",
4302 .p_class = P_GLOBAL,
4303 .offset = GLOBAL_VAR(bWinbindNormalizeNames),
4306 .flags = FLAG_ADVANCED,
4309 .label = "winbind rpc only",
4311 .p_class = P_GLOBAL,
4312 .offset = GLOBAL_VAR(bWinbindRpcOnly),
4315 .flags = FLAG_ADVANCED,
4318 .label = "create krb5 conf",
4320 .p_class = P_GLOBAL,
4321 .offset = GLOBAL_VAR(bCreateKrb5Conf),
4324 .flags = FLAG_ADVANCED,
4327 .label = "ncalrpc dir",
4329 .p_class = P_GLOBAL,
4330 .offset = GLOBAL_VAR(ncalrpc_dir),
4333 .flags = FLAG_ADVANCED,
4336 .label = "winbind max domain connections",
4338 .p_class = P_GLOBAL,
4339 .offset = GLOBAL_VAR(winbindMaxDomainConnections),
4342 .flags = FLAG_ADVANCED,
4345 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
4348 /***************************************************************************
4349 Initialise the sDefault parameter structure for the printer values.
4350 ***************************************************************************/
4352 static void init_printer_values(struct loadparm_service *pService)
4354 /* choose defaults depending on the type of printing */
4355 switch (pService->iPrinting) {
4360 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4361 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4362 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4367 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4368 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4369 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4370 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4371 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4372 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4373 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4379 /* set the lpq command to contain the destination printer
4380 name only. This is used by cups_queue_get() */
4381 string_set(&pService->szLpqcommand, "%p");
4382 string_set(&pService->szLprmcommand, "");
4383 string_set(&pService->szPrintcommand, "");
4384 string_set(&pService->szLppausecommand, "");
4385 string_set(&pService->szLpresumecommand, "");
4386 string_set(&pService->szQueuepausecommand, "");
4387 string_set(&pService->szQueueresumecommand, "");
4389 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4390 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4391 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4392 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4393 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4394 string_set(&pService->szQueuepausecommand, "disable '%p'");
4395 string_set(&pService->szQueueresumecommand, "enable '%p'");
4396 #endif /* HAVE_CUPS */
4401 string_set(&pService->szLpqcommand, "lpstat -o%p");
4402 string_set(&pService->szLprmcommand, "cancel %p-%j");
4403 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4404 string_set(&pService->szQueuepausecommand, "disable %p");
4405 string_set(&pService->szQueueresumecommand, "enable %p");
4407 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4408 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4413 string_set(&pService->szLpqcommand, "lpq -P%p");
4414 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4415 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4418 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
4422 const char *tdbfile;
4425 tdbfile = talloc_asprintf(
4426 talloc_tos(), "tdbfile=%s",
4427 lp_parm_const_string(-1, "vlp", "tdbfile",
4429 if (tdbfile == NULL) {
4430 tdbfile="tdbfile=/tmp/vlp.tdb";
4433 tmp = talloc_asprintf(talloc_tos(), "vlp %s print %%p %%s",
4435 string_set(&pService->szPrintcommand,
4436 tmp ? tmp : "vlp print %p %s");
4439 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpq %%p",
4441 string_set(&pService->szLpqcommand,
4442 tmp ? tmp : "vlp lpq %p");
4445 tmp = talloc_asprintf(talloc_tos(), "vlp %s lprm %%p %%j",
4447 string_set(&pService->szLprmcommand,
4448 tmp ? tmp : "vlp lprm %p %j");
4451 tmp = talloc_asprintf(talloc_tos(), "vlp %s lppause %%p %%j",
4453 string_set(&pService->szLppausecommand,
4454 tmp ? tmp : "vlp lppause %p %j");
4457 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpresume %%p %%j",
4459 string_set(&pService->szLpresumecommand,
4460 tmp ? tmp : "vlp lpresume %p %j");
4463 tmp = talloc_asprintf(talloc_tos(), "vlp %s queuepause %%p",
4465 string_set(&pService->szQueuepausecommand,
4466 tmp ? tmp : "vlp queuepause %p");
4469 tmp = talloc_asprintf(talloc_tos(), "vlp %s queueresume %%p",
4471 string_set(&pService->szQueueresumecommand,
4472 tmp ? tmp : "vlp queueresume %p");
4477 #endif /* DEVELOPER */
4482 * Function to return the default value for the maximum number of open
4483 * file descriptors permitted. This function tries to consult the
4484 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4485 * the smaller of those.
4487 static int max_open_files(void)
4489 int sysctl_max = MAX_OPEN_FILES;
4490 int rlimit_max = MAX_OPEN_FILES;
4492 #ifdef HAVE_SYSCTLBYNAME
4494 size_t size = sizeof(sysctl_max);
4495 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4500 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4506 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4507 rlimit_max = rl.rlim_cur;
4509 #if defined(RLIM_INFINITY)
4510 if(rl.rlim_cur == RLIM_INFINITY)
4511 rlimit_max = MAX_OPEN_FILES;
4516 if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4517 DEBUG(2,("max_open_files: increasing sysctl_max (%d) to "
4518 "minimum Windows limit (%d)\n",
4520 MIN_OPEN_FILES_WINDOWS));
4521 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4524 if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4525 DEBUG(2,("rlimit_max: increasing rlimit_max (%d) to "
4526 "minimum Windows limit (%d)\n",
4528 MIN_OPEN_FILES_WINDOWS));
4529 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4532 return MIN(sysctl_max, rlimit_max);
4536 * Common part of freeing allocated data for one parameter.
4538 static void free_one_parameter_common(void *parm_ptr,
4539 struct parm_struct parm)
4541 if ((parm.type == P_STRING) ||
4542 (parm.type == P_USTRING))
4544 string_free((char**)parm_ptr);
4545 } else if (parm.type == P_LIST) {
4546 TALLOC_FREE(*((char***)parm_ptr));
4551 * Free the allocated data for one parameter for a share
4552 * given as a service struct.
4554 static void free_one_parameter(struct loadparm_service *service,
4555 struct parm_struct parm)
4559 if (parm.p_class != P_LOCAL) {
4563 parm_ptr = lp_parm_ptr(service, &parm);
4565 free_one_parameter_common(parm_ptr, parm);
4569 * Free the allocated parameter data of a share given
4570 * as a service struct.
4572 static void free_parameters(struct loadparm_service *service)
4576 for (i=0; parm_table[i].label; i++) {
4577 free_one_parameter(service, parm_table[i]);
4582 * Free the allocated data for one parameter for a given share
4583 * specified by an snum.
4585 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4590 parm_ptr = lp_parm_ptr(NULL, &parm);
4591 } else if (parm.p_class != P_LOCAL) {
4594 parm_ptr = lp_local_ptr_by_snum(snum, &parm);
4597 free_one_parameter_common(parm_ptr, parm);
4601 * Free the allocated parameter data for a share specified
4604 static void free_parameters_by_snum(int snum)
4608 for (i=0; parm_table[i].label; i++) {
4609 free_one_parameter_by_snum(snum, parm_table[i]);
4614 * Free the allocated global parameters.
4616 static void free_global_parameters(void)
4618 free_param_opts(&Globals.param_opt);
4619 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4622 static int map_parameter(const char *pszParmName);
4624 struct lp_stored_option {
4625 struct lp_stored_option *prev, *next;
4630 static struct lp_stored_option *stored_options;
4633 save options set by lp_set_cmdline() into a list. This list is
4634 re-applied when we do a globals reset, so that cmdline set options
4635 are sticky across reloads of smb.conf
4637 static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
4639 struct lp_stored_option *entry, *entry_next;
4640 for (entry = stored_options; entry != NULL; entry = entry_next) {
4641 entry_next = entry->next;
4642 if (strcmp(pszParmName, entry->label) == 0) {
4643 DLIST_REMOVE(stored_options, entry);
4649 entry = talloc(NULL, struct lp_stored_option);
4654 entry->label = talloc_strdup(entry, pszParmName);
4655 if (!entry->label) {
4660 entry->value = talloc_strdup(entry, pszParmValue);
4661 if (!entry->value) {
4666 DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
4671 static bool apply_lp_set_cmdline(void)
4673 struct lp_stored_option *entry = NULL;
4674 for (entry = stored_options; entry != NULL; entry = entry->next) {
4675 if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
4676 DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
4677 entry->label, entry->value));
4684 /***************************************************************************
4685 Initialise the global parameter structure.
4686 ***************************************************************************/
4688 static void init_globals(bool reinit_globals)
4690 static bool done_init = false;
4694 /* If requested to initialize only once and we've already done it... */
4695 if (!reinit_globals && done_init) {
4696 /* ... then we have nothing more to do */
4701 /* The logfile can be set before this is invoked. Free it if so. */
4702 if (Globals.szLogFile != NULL) {
4703 string_free(&Globals.szLogFile);
4704 Globals.szLogFile = NULL;
4708 free_global_parameters();
4711 /* This memset and the free_global_parameters() above will
4712 * wipe out smb.conf options set with lp_set_cmdline(). The
4713 * apply_lp_set_cmdline() call puts these values back in the
4714 * table once the defaults are set */
4715 ZERO_STRUCT(Globals);
4717 for (i = 0; parm_table[i].label; i++) {
4718 if ((parm_table[i].type == P_STRING ||
4719 parm_table[i].type == P_USTRING))
4721 string_set((char **)lp_parm_ptr(NULL, &parm_table[i]), "");
4726 string_set(&sDefault.fstype, FSTYPE_STRING);
4727 string_set(&sDefault.szPrintjobUsername, "%U");
4729 init_printer_values(&sDefault);
4732 DEBUG(3, ("Initialising global parameters\n"));
4734 /* Must manually force to upper case here, as this does not go via the handler */
4735 string_set(&Globals.szNetbiosName, myhostname_upper());
4737 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4738 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4740 /* use the new 'hash2' method by default, with a prefix of 1 */
4741 string_set(&Globals.szManglingMethod, "hash2");
4742 Globals.mangle_prefix = 1;
4744 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4746 /* using UTF8 by default allows us to support all chars */
4747 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4749 /* Use codepage 850 as a default for the dos character set */
4750 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4753 * Allow the default PASSWD_CHAT to be overridden in local.h.
4755 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4757 string_set(&Globals.szWorkgroup, DEFAULT_WORKGROUP);
4759 string_set(&Globals.szPasswdProgram, "");
4760 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4761 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4762 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4763 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4764 string_set(&Globals.szSocketAddress, "0.0.0.0");
4766 * By default support explicit binding to broadcast
4769 Globals.bNmbdBindExplicitBroadcast = true;
4771 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4772 smb_panic("init_globals: ENOMEM");
4774 string_set(&Globals.szServerString, s);
4777 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4780 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
4782 string_set(&Globals.szLogonDrive, "");
4783 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4784 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4785 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4787 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
4788 string_set(&Globals.szPasswordServer, "*");
4790 Globals.AlgorithmicRidBase = BASE_RID;
4792 Globals.bLoadPrinters = true;
4793 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4795 Globals.ConfigBackend = config_backend;
4797 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4798 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4799 Globals.max_xmit = 0x4104;
4800 Globals.max_mux = 50; /* This is *needed* for profile support. */
4801 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4802 Globals.bDisableSpoolss = false;
4803 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4804 Globals.pwordlevel = 0;
4805 Globals.unamelevel = 0;
4806 Globals.deadtime = 0;
4807 Globals.getwd_cache = true;
4808 Globals.bLargeReadwrite = true;
4809 Globals.max_log_size = 5000;
4810 Globals.max_open_files = max_open_files();
4811 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4812 Globals.maxprotocol = PROTOCOL_NT1;
4813 Globals.minprotocol = PROTOCOL_CORE;
4814 Globals.security = SEC_USER;
4815 Globals.paranoid_server_security = true;
4816 Globals.bEncryptPasswords = true;
4817 Globals.clientSchannel = Auto;
4818 Globals.serverSchannel = Auto;
4819 Globals.bReadRaw = true;
4820 Globals.bWriteRaw = true;
4821 Globals.bNullPasswords = false;
4822 Globals.bObeyPamRestrictions = false;
4824 Globals.bSyslogOnly = false;
4825 Globals.bTimestampLogs = true;
4826 string_set(&Globals.szLogLevel, "0");
4827 Globals.bDebugPrefixTimestamp = false;
4828 Globals.bDebugHiresTimestamp = true;
4829 Globals.bDebugPid = false;
4830 Globals.bDebugUid = false;
4831 Globals.bDebugClass = false;
4832 Globals.bEnableCoreFiles = true;
4833 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4834 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4835 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4836 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4837 Globals.lm_announce = Auto; /* = Auto: send only if LM clients found */
4838 Globals.lm_interval = 60;
4839 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4840 Globals.bNISHomeMap = false;
4841 #ifdef WITH_NISPLUS_HOME
4842 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4844 string_set(&Globals.szNISHomeMapName, "auto.home");
4847 Globals.bTimeServer = false;
4848 Globals.bBindInterfacesOnly = false;
4849 Globals.bUnixPasswdSync = false;
4850 Globals.bPamPasswordChange = false;
4851 Globals.bPasswdChatDebug = false;
4852 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4853 Globals.bNTPipeSupport = true; /* Do NT pipes by default. */
4854 Globals.bNTStatusSupport = true; /* Use NT status by default. */
4855 Globals.bStatCache = true; /* use stat cache by default */
4856 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4857 Globals.restrict_anonymous = 0;
4858 Globals.bClientLanManAuth = false; /* Do NOT use the LanMan hash if it is available */
4859 Globals.bClientPlaintextAuth = false; /* Do NOT use a plaintext password even if is requested by the server */
4860 Globals.bLanmanAuth = false; /* Do NOT use the LanMan hash, even if it is supplied */
4861 Globals.bNTLMAuth = true; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4862 Globals.bClientNTLMv2Auth = true; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
4863 /* Note, that we will also use NTLM2 session security (which is different), if it is available */
4865 Globals.map_to_guest = 0; /* By Default, "Never" */
4866 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4867 Globals.enhanced_browsing = true;
4868 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4869 #ifdef MMAP_BLACKLIST
4870 Globals.bUseMmap = false;
4872 Globals.bUseMmap = true;
4874 Globals.bUnixExtensions = true;
4875 Globals.bResetOnZeroVC = false;
4876 Globals.bLogWriteableFilesOnExit = false;
4877 Globals.bCreateKrb5Conf = true;
4878 Globals.winbindMaxDomainConnections = 1;
4880 /* hostname lookups can be very expensive and are broken on
4881 a large number of sites (tridge) */
4882 Globals.bHostnameLookups = false;
4884 string_set(&Globals.szPassdbBackend, "tdbsam");
4885 string_set(&Globals.szLdapSuffix, "");
4886 string_set(&Globals.szLdapMachineSuffix, "");
4887 string_set(&Globals.szLdapUserSuffix, "");
4888 string_set(&Globals.szLdapGroupSuffix, "");
4889 string_set(&Globals.szLdapIdmapSuffix, "");
4891 string_set(&Globals.szLdapAdminDn, "");
4892 Globals.ldap_ssl = LDAP_SSL_START_TLS;
4893 Globals.ldap_ssl_ads = false;
4894 Globals.ldap_deref = -1;
4895 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
4896 Globals.ldap_delete_dn = false;
4897 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
4898 Globals.ldap_follow_referral = Auto;
4899 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
4900 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
4901 Globals.ldap_page_size = LDAP_PAGE_SIZE;
4903 Globals.ldap_debug_level = 0;
4904 Globals.ldap_debug_threshold = 10;
4906 /* This is what we tell the afs client. in reality we set the token
4907 * to never expire, though, when this runs out the afs client will
4908 * forget the token. Set to 0 to get NEVERDATE.*/
4909 Globals.iAfsTokenLifetime = 604800;
4910 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
4912 /* these parameters are set to defaults that are more appropriate
4913 for the increasing samba install base:
4915 as a member of the workgroup, that will possibly become a
4916 _local_ master browser (lm = true). this is opposed to a forced
4917 local master browser startup (pm = true).
4919 doesn't provide WINS server service by default (wsupp = false),
4920 and doesn't provide domain master browser services by default, either.
4924 Globals.bMsAddPrinterWizard = true;
4925 Globals.os_level = 20;
4926 Globals.bLocalMaster = true;
4927 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
4928 Globals.bDomainLogons = false;
4929 Globals.bBrowseList = true;
4930 Globals.bWINSsupport = false;
4931 Globals.bWINSproxy = false;
4933 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
4934 Globals.InitLogonDelay = 100; /* 100 ms default delay */
4936 Globals.bDNSproxy = true;
4938 /* this just means to use them if they exist */
4939 Globals.bKernelOplocks = true;
4941 Globals.bAllowTrustedDomains = true;
4942 string_set(&Globals.szIdmapBackend, "tdb");
4944 string_set(&Globals.szTemplateShell, "/bin/false");
4945 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
4946 string_set(&Globals.szWinbindSeparator, "\\");
4948 string_set(&Globals.szCupsServer, "");
4949 string_set(&Globals.szIPrintServer, "");
4951 string_set(&Globals.ctdbdSocket, "");
4952 Globals.szClusterAddresses = NULL;
4953 Globals.clustering = false;
4954 Globals.ctdb_timeout = 0;
4955 Globals.ctdb_locktime_warn_threshold = 0;
4957 Globals.winbind_cache_time = 300; /* 5 minutes */
4958 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
4959 Globals.winbind_max_clients = 200;
4960 Globals.bWinbindEnumUsers = false;
4961 Globals.bWinbindEnumGroups = false;
4962 Globals.bWinbindUseDefaultDomain = false;
4963 Globals.bWinbindTrustedDomainsOnly = false;
4964 Globals.bWinbindNestedGroups = true;
4965 Globals.winbind_expand_groups = 1;
4966 Globals.szWinbindNssInfo = (const char **)str_list_make_v3(NULL, "template", NULL);
4967 Globals.bWinbindRefreshTickets = false;
4968 Globals.bWinbindOfflineLogon = false;
4970 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
4971 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
4973 Globals.bPassdbExpandExplicit = false;
4975 Globals.name_cache_timeout = 660; /* In seconds */
4977 Globals.bUseSpnego = true;
4978 Globals.bClientUseSpnego = true;
4980 Globals.client_signing = Auto;
4981 Globals.server_signing = false;
4983 Globals.bDeferSharingViolations = true;
4984 string_set(&Globals.smb_ports, SMB_PORTS);
4986 Globals.bEnablePrivileges = true;
4987 Globals.bHostMSDfs = true;
4988 Globals.bASUSupport = false;
4990 /* User defined shares. */
4991 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
4992 smb_panic("init_globals: ENOMEM");
4994 string_set(&Globals.szUsersharePath, s);
4996 string_set(&Globals.szUsershareTemplateShare, "");
4997 Globals.iUsershareMaxShares = 0;
4998 /* By default disallow sharing of directories not owned by the sharer. */
4999 Globals.bUsershareOwnerOnly = true;
5000 /* By default disallow guest access to usershares. */
5001 Globals.bUsershareAllowGuests = false;
5003 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5005 /* By default no shares out of the registry */
5006 Globals.bRegistryShares = false;
5008 Globals.iminreceivefile = 0;
5010 Globals.bMapUntrustedToDomain = false;
5011 Globals.bMulticastDnsRegister = true;
5013 Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ;
5014 Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE;
5015 Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT;
5016 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5018 string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
5020 /* Now put back the settings that were set with lp_set_cmdline() */
5021 apply_lp_set_cmdline();
5024 /*******************************************************************
5025 Convenience routine to grab string parameters into temporary memory
5026 and run standard_sub_basic on them. The buffers can be written to by
5027 callers without affecting the source string.
5028 ********************************************************************/
5030 static char *lp_string(const char *s)
5033 TALLOC_CTX *ctx = talloc_tos();
5035 /* The follow debug is useful for tracking down memory problems
5036 especially if you have an inner loop that is calling a lp_*()
5037 function that returns a string. Perhaps this debug should be
5038 present all the time? */
5041 DEBUG(10, ("lp_string(%s)\n", s));
5047 ret = talloc_sub_basic(ctx,
5048 get_current_username(),
5049 current_user_info.domain,
5051 if (trim_char(ret, '\"', '\"')) {
5052 if (strchr(ret,'\"') != NULL) {
5054 ret = talloc_sub_basic(ctx,
5055 get_current_username(),
5056 current_user_info.domain,
5064 In this section all the functions that are used to access the
5065 parameters from the rest of the program are defined
5068 #define FN_GLOBAL_STRING(fn_name,ptr) \
5069 char *fn_name(void) {return(lp_string(*(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : ""));}
5070 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5071 const char *fn_name(void) {return(*(const char **)(&Globals.ptr) ? *(const char **)(&Globals.ptr) : "");}
5072 #define FN_GLOBAL_LIST(fn_name,ptr) \
5073 const char **fn_name(void) {return(*(const char ***)(&Globals.ptr));}
5074 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5075 bool fn_name(void) {return(*(bool *)(&Globals.ptr));}
5076 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5077 char fn_name(void) {return(*(char *)(&Globals.ptr));}
5078 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5079 int fn_name(void) {return(*(int *)(&Globals.ptr));}
5081 #define FN_LOCAL_STRING(fn_name,val) \
5082 char *lp_ ## fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5083 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5084 const char *lp_ ## fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5085 #define FN_LOCAL_LIST(fn_name,val) \
5086 const char **lp_ ## fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5087 #define FN_LOCAL_BOOL(fn_name,val) \
5088 bool lp_ ## fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5089 #define FN_LOCAL_INTEGER(fn_name,val) \
5090 int lp_ ## fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5092 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5093 bool lp_ ## fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5094 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5095 int lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5096 #define FN_LOCAL_CHAR(fn_name,val) \
5097 char lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5099 FN_GLOBAL_CONST_STRING(lp_smb_ports, smb_ports)
5100 FN_GLOBAL_CONST_STRING(lp_dos_charset, dos_charset)
5101 FN_GLOBAL_CONST_STRING(lp_unix_charset, unix_charset)
5102 FN_GLOBAL_STRING(lp_logfile, szLogFile)
5103 FN_GLOBAL_STRING(lp_configfile, szConfigFile)
5104 FN_GLOBAL_CONST_STRING(lp_smb_passwd_file, szSMBPasswdFile)
5105 FN_GLOBAL_CONST_STRING(lp_private_dir, szPrivateDir)
5106 FN_GLOBAL_STRING(lp_serverstring, szServerString)
5107 FN_GLOBAL_INTEGER(lp_printcap_cache_time, PrintcapCacheTime)
5108 FN_GLOBAL_STRING(lp_addport_cmd, szAddPortCommand)
5109 FN_GLOBAL_STRING(lp_enumports_cmd, szEnumPortsCommand)
5110 FN_GLOBAL_STRING(lp_addprinter_cmd, szAddPrinterCommand)
5111 FN_GLOBAL_STRING(lp_deleteprinter_cmd, szDeletePrinterCommand)
5112 FN_GLOBAL_STRING(lp_os2_driver_map, szOs2DriverMap)
5113 FN_GLOBAL_CONST_STRING(lp_lockdir, szLockDir)
5114 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5115 * build process or in smb.conf, we use that value. Otherwise they
5116 * default to the value of lp_lockdir(). */
5117 const char *lp_statedir(void) {
5118 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5119 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5120 return(*(char **)(&Globals.szStateDir) ?
5121 *(char **)(&Globals.szStateDir) : "");
5123 return(*(char **)(&Globals.szLockDir) ?
5124 *(char **)(&Globals.szLockDir) : "");
5126 const char *lp_cachedir(void) {
5127 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5128 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5129 return(*(char **)(&Globals.szCacheDir) ?
5130 *(char **)(&Globals.szCacheDir) : "");
5132 return(*(char **)(&Globals.szLockDir) ?
5133 *(char **)(&Globals.szLockDir) : "");
5135 FN_GLOBAL_CONST_STRING(lp_piddir, szPidDir)
5136 FN_GLOBAL_STRING(lp_mangling_method, szManglingMethod)
5137 FN_GLOBAL_INTEGER(lp_mangle_prefix, mangle_prefix)
5138 FN_GLOBAL_CONST_STRING(lp_utmpdir, szUtmpDir)
5139 FN_GLOBAL_CONST_STRING(lp_wtmpdir, szWtmpDir)
5140 FN_GLOBAL_BOOL(lp_utmp, bUtmp)
5141 FN_GLOBAL_STRING(lp_rootdir, szRootdir)
5142 FN_GLOBAL_STRING(lp_perfcount_module, szSMBPerfcountModule)
5143 FN_GLOBAL_STRING(lp_defaultservice, szDefaultService)
5144 FN_GLOBAL_STRING(lp_msg_command, szMsgCommand)
5145 FN_GLOBAL_STRING(lp_get_quota_command, szGetQuota)
5146 FN_GLOBAL_STRING(lp_set_quota_command, szSetQuota)
5147 FN_GLOBAL_STRING(lp_auto_services, szAutoServices)
5148 FN_GLOBAL_STRING(lp_passwd_program, szPasswdProgram)
5149 FN_GLOBAL_STRING(lp_passwd_chat, szPasswdChat)
5150 FN_GLOBAL_CONST_STRING(lp_passwordserver, szPasswordServer)
5151 FN_GLOBAL_CONST_STRING(lp_name_resolve_order, szNameResolveOrder)
5152 FN_GLOBAL_CONST_STRING(lp_workgroup, szWorkgroup)
5153 FN_GLOBAL_CONST_STRING(lp_netbios_name, szNetbiosName)
5154 FN_GLOBAL_CONST_STRING(lp_netbios_scope, szNetbiosScope)
5155 FN_GLOBAL_CONST_STRING(lp_realm, szRealmUpper)
5156 FN_GLOBAL_CONST_STRING(lp_dnsdomain, szDnsDomain)
5157 FN_GLOBAL_CONST_STRING(lp_afs_username_map, szAfsUsernameMap)
5158 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, iAfsTokenLifetime)
5159 FN_GLOBAL_STRING(lp_log_nt_token_command, szLogNtTokenCommand)
5160 FN_GLOBAL_STRING(lp_username_map, szUsernameMap)
5161 FN_GLOBAL_CONST_STRING(lp_logon_script, szLogonScript)
5162 FN_GLOBAL_CONST_STRING(lp_logon_path, szLogonPath)
5163 FN_GLOBAL_CONST_STRING(lp_logon_drive, szLogonDrive)
5164 FN_GLOBAL_CONST_STRING(lp_logon_home, szLogonHome)
5165 FN_GLOBAL_STRING(lp_remote_announce, szRemoteAnnounce)
5166 FN_GLOBAL_STRING(lp_remote_browse_sync, szRemoteBrowseSync)
5167 FN_GLOBAL_BOOL(lp_nmbd_bind_explicit_broadcast, bNmbdBindExplicitBroadcast)
5168 FN_GLOBAL_LIST(lp_wins_server_list, szWINSservers)
5169 FN_GLOBAL_LIST(lp_interfaces, szInterfaces)
5170 FN_GLOBAL_STRING(lp_nis_home_map_name, szNISHomeMapName)
5171 FN_GLOBAL_LIST(lp_netbios_aliases, szNetbiosAliases)
5172 FN_GLOBAL_CONST_STRING(lp_passdb_backend, szPassdbBackend)
5173 FN_GLOBAL_LIST(lp_preload_modules, szPreloadModules)
5174 FN_GLOBAL_STRING(lp_panic_action, szPanicAction)
5175 FN_GLOBAL_STRING(lp_adduser_script, szAddUserScript)
5176 FN_GLOBAL_STRING(lp_renameuser_script, szRenameUserScript)
5177 FN_GLOBAL_STRING(lp_deluser_script, szDelUserScript)
5179 FN_GLOBAL_CONST_STRING(lp_guestaccount, szGuestaccount)
5180 FN_GLOBAL_STRING(lp_addgroup_script, szAddGroupScript)
5181 FN_GLOBAL_STRING(lp_delgroup_script, szDelGroupScript)
5182 FN_GLOBAL_STRING(lp_addusertogroup_script, szAddUserToGroupScript)
5183 FN_GLOBAL_STRING(lp_deluserfromgroup_script, szDelUserFromGroupScript)
5184 FN_GLOBAL_STRING(lp_setprimarygroup_script, szSetPrimaryGroupScript)
5186 FN_GLOBAL_STRING(lp_addmachine_script, szAddMachineScript)
5188 FN_GLOBAL_STRING(lp_shutdown_script, szShutdownScript)
5189 FN_GLOBAL_STRING(lp_abort_shutdown_script, szAbortShutdownScript)
5190 FN_GLOBAL_STRING(lp_username_map_script, szUsernameMapScript)
5191 FN_GLOBAL_INTEGER(lp_username_map_cache_time, iUsernameMapCacheTime)
5193 FN_GLOBAL_STRING(lp_check_password_script, szCheckPasswordScript)
5195 FN_GLOBAL_STRING(lp_wins_hook, szWINSHook)
5196 FN_GLOBAL_CONST_STRING(lp_template_homedir, szTemplateHomedir)
5197 FN_GLOBAL_CONST_STRING(lp_template_shell, szTemplateShell)
5198 FN_GLOBAL_CONST_STRING(lp_winbind_separator, szWinbindSeparator)
5199 FN_GLOBAL_INTEGER(lp_acl_compatibility, iAclCompat)
5200 FN_GLOBAL_BOOL(lp_winbind_enum_users, bWinbindEnumUsers)
5201 FN_GLOBAL_BOOL(lp_winbind_enum_groups, bWinbindEnumGroups)
5202 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, bWinbindUseDefaultDomain)
5203 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, bWinbindTrustedDomainsOnly)
5204 FN_GLOBAL_BOOL(lp_winbind_nested_groups, bWinbindNestedGroups)
5205 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, winbind_expand_groups)
5206 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, bWinbindRefreshTickets)
5207 FN_GLOBAL_BOOL(lp_winbind_offline_logon, bWinbindOfflineLogon)
5208 FN_GLOBAL_BOOL(lp_winbind_normalize_names, bWinbindNormalizeNames)
5209 FN_GLOBAL_BOOL(lp_winbind_rpc_only, bWinbindRpcOnly)
5210 FN_GLOBAL_BOOL(lp_create_krb5_conf, bCreateKrb5Conf)
5211 static FN_GLOBAL_INTEGER(lp_winbind_max_domain_connections_int,
5212 winbindMaxDomainConnections)
5214 int lp_winbind_max_domain_connections(void)
5216 if (lp_winbind_offline_logon() &&
5217 lp_winbind_max_domain_connections_int() > 1) {
5218 DEBUG(1, ("offline logons active, restricting max domain "
5219 "connections to 1\n"));
5222 return MAX(1, lp_winbind_max_domain_connections_int());
5225 FN_GLOBAL_CONST_STRING(lp_idmap_backend, szIdmapBackend)
5226 FN_GLOBAL_INTEGER(lp_idmap_cache_time, iIdmapCacheTime)
5227 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, iIdmapNegativeCacheTime)
5228 FN_GLOBAL_INTEGER(lp_keepalive, iKeepalive)
5229 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, bPassdbExpandExplicit)
5231 FN_GLOBAL_STRING(lp_ldap_suffix, szLdapSuffix)
5232 FN_GLOBAL_STRING(lp_ldap_admin_dn, szLdapAdminDn)
5233 FN_GLOBAL_INTEGER(lp_ldap_ssl, ldap_ssl)
5234 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, ldap_ssl_ads)
5235 FN_GLOBAL_INTEGER(lp_ldap_deref, ldap_deref)
5236 FN_GLOBAL_INTEGER(lp_ldap_follow_referral, ldap_follow_referral)
5237 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, ldap_passwd_sync)
5238 FN_GLOBAL_BOOL(lp_ldap_delete_dn, ldap_delete_dn)
5239 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, ldap_replication_sleep)
5240 FN_GLOBAL_INTEGER(lp_ldap_timeout, ldap_timeout)
5241 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, ldap_connection_timeout)
5242 FN_GLOBAL_INTEGER(lp_ldap_page_size, ldap_page_size)
5243 FN_GLOBAL_INTEGER(lp_ldap_debug_level, ldap_debug_level)
5244 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, ldap_debug_threshold)
5245 FN_GLOBAL_STRING(lp_add_share_cmd, szAddShareCommand)
5246 FN_GLOBAL_STRING(lp_change_share_cmd, szChangeShareCommand)
5247 FN_GLOBAL_STRING(lp_delete_share_cmd, szDeleteShareCommand)
5248 FN_GLOBAL_STRING(lp_usershare_path, szUsersharePath)
5249 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, szUsersharePrefixAllowList)
5250 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, szUsersharePrefixDenyList)
5252 FN_GLOBAL_LIST(lp_eventlog_list, szEventLogs)
5254 FN_GLOBAL_BOOL(lp_registry_shares, bRegistryShares)
5255 FN_GLOBAL_BOOL(lp_usershare_allow_guests, bUsershareAllowGuests)
5256 FN_GLOBAL_BOOL(lp_usershare_owner_only, bUsershareOwnerOnly)
5257 FN_GLOBAL_BOOL(lp_disable_netbios, bDisableNetbios)
5258 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, bResetOnZeroVC)
5259 FN_GLOBAL_BOOL(lp_log_writeable_files_on_exit, bLogWriteableFilesOnExit)
5260 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, bMsAddPrinterWizard)
5261 FN_GLOBAL_BOOL(lp_dns_proxy, bDNSproxy)
5262 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, bWINSsupport)
5263 FN_GLOBAL_BOOL(lp_wins_proxy, bWINSproxy)
5264 FN_GLOBAL_BOOL(lp_local_master, bLocalMaster)
5265 FN_GLOBAL_BOOL(lp_domain_logons, bDomainLogons)
5266 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, szInitLogonDelayedHosts)
5267 FN_GLOBAL_INTEGER(lp_init_logon_delay, InitLogonDelay)
5268 FN_GLOBAL_BOOL(lp_load_printers, bLoadPrinters)
5269 FN_GLOBAL_BOOL(_lp_readraw, bReadRaw)
5270 FN_GLOBAL_BOOL(lp_large_readwrite, bLargeReadwrite)
5271 FN_GLOBAL_BOOL(_lp_writeraw, bWriteRaw)
5272 FN_GLOBAL_BOOL(lp_null_passwords, bNullPasswords)
5273 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, bObeyPamRestrictions)
5274 FN_GLOBAL_BOOL(lp_encrypted_passwords, bEncryptPasswords)
5275 FN_GLOBAL_INTEGER(lp_client_schannel, clientSchannel)
5276 FN_GLOBAL_INTEGER(lp_server_schannel, serverSchannel)
5277 FN_GLOBAL_BOOL(lp_syslog_only, bSyslogOnly)
5278 FN_GLOBAL_BOOL(lp_timestamp_logs, bTimestampLogs)
5279 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, bDebugPrefixTimestamp)
5280 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, bDebugHiresTimestamp)
5281 FN_GLOBAL_BOOL(lp_debug_pid, bDebugPid)
5282 FN_GLOBAL_BOOL(lp_debug_uid, bDebugUid)
5283 FN_GLOBAL_BOOL(lp_debug_class, bDebugClass)
5284 FN_GLOBAL_BOOL(lp_enable_core_files, bEnableCoreFiles)
5285 FN_GLOBAL_BOOL(lp_browse_list, bBrowseList)
5286 FN_GLOBAL_BOOL(lp_nis_home_map, bNISHomeMap)
5287 static FN_GLOBAL_BOOL(lp_time_server, bTimeServer)
5288 FN_GLOBAL_BOOL(lp_bind_interfaces_only, bBindInterfacesOnly)
5289 FN_GLOBAL_BOOL(lp_pam_password_change, bPamPasswordChange)
5290 FN_GLOBAL_BOOL(lp_unix_password_sync, bUnixPasswdSync)
5291 FN_GLOBAL_BOOL(lp_passwd_chat_debug, bPasswdChatDebug)
5292 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, iPasswdChatTimeout)
5293 FN_GLOBAL_BOOL(lp_nt_pipe_support, bNTPipeSupport)
5294 FN_GLOBAL_BOOL(lp_nt_status_support, bNTStatusSupport)
5295 FN_GLOBAL_BOOL(lp_stat_cache, bStatCache)
5296 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, iMaxStatCacheSize)
5297 FN_GLOBAL_BOOL(lp_allow_trusted_domains, bAllowTrustedDomains)
5298 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, bMapUntrustedToDomain)
5299 FN_GLOBAL_INTEGER(lp_restrict_anonymous, restrict_anonymous)
5300 FN_GLOBAL_BOOL(lp_lanman_auth, bLanmanAuth)
5301 FN_GLOBAL_BOOL(lp_ntlm_auth, bNTLMAuth)
5302 FN_GLOBAL_BOOL(lp_client_plaintext_auth, bClientPlaintextAuth)
5303 FN_GLOBAL_BOOL(lp_client_lanman_auth, bClientLanManAuth)
5304 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, bClientNTLMv2Auth)
5305 FN_GLOBAL_BOOL(lp_host_msdfs, bHostMSDfs)
5306 FN_GLOBAL_BOOL(lp_kernel_oplocks, bKernelOplocks)
5307 FN_GLOBAL_BOOL(lp_enhanced_browsing, enhanced_browsing)
5308 FN_GLOBAL_BOOL(lp_use_mmap, bUseMmap)
5309 FN_GLOBAL_BOOL(lp_unix_extensions, bUnixExtensions)
5310 FN_GLOBAL_BOOL(lp_use_spnego, bUseSpnego)
5311 FN_GLOBAL_BOOL(lp_client_use_spnego, bClientUseSpnego)
5312 FN_GLOBAL_BOOL(lp_client_use_spnego_principal, client_use_spnego_principal)
5313 FN_GLOBAL_BOOL(lp_send_spnego_principal, send_spnego_principal)
5314 FN_GLOBAL_BOOL(lp_hostname_lookups, bHostnameLookups)
5315 FN_GLOBAL_CONST_STRING(lp_dedicated_keytab_file, szDedicatedKeytabFile)
5316 FN_GLOBAL_INTEGER(lp_kerberos_method, iKerberosMethod)
5317 FN_GLOBAL_BOOL(lp_defer_sharing_violations, bDeferSharingViolations)
5318 FN_GLOBAL_BOOL(lp_enable_privileges, bEnablePrivileges)
5319 FN_GLOBAL_BOOL(lp_enable_asu_support, bASUSupport)
5320 FN_GLOBAL_INTEGER(lp_os_level, os_level)
5321 FN_GLOBAL_INTEGER(lp_max_ttl, max_ttl)
5322 FN_GLOBAL_INTEGER(lp_max_wins_ttl, max_wins_ttl)
5323 FN_GLOBAL_INTEGER(lp_min_wins_ttl, min_wins_ttl)
5324 FN_GLOBAL_INTEGER(lp_max_log_size, max_log_size)
5325 FN_GLOBAL_INTEGER(lp_max_open_files, max_open_files)
5326 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, open_files_db_hash_size)
5327 FN_GLOBAL_INTEGER(lp_maxxmit, max_xmit)
5328 FN_GLOBAL_INTEGER(lp_maxmux, max_mux)
5329 FN_GLOBAL_INTEGER(lp_passwordlevel, pwordlevel)
5330 FN_GLOBAL_INTEGER(lp_usernamelevel, unamelevel)
5331 FN_GLOBAL_INTEGER(lp_deadtime, deadtime)
5332 FN_GLOBAL_BOOL(lp_getwd_cache, getwd_cache)
5333 static FN_GLOBAL_INTEGER(_lp_maxprotocol, maxprotocol)
5334 int lp_maxprotocol(void)
5336 int ret = _lp_maxprotocol();
5337 if ((ret >= PROTOCOL_SMB2_02) && (lp_security() == SEC_SHARE)) {
5338 DEBUG(2,("WARNING!!: \"security = share\" is incompatible "
5339 "with the SMB2 protocol. Resetting to SMB1.\n" ));
5340 lp_do_parameter(-1, "max protocol", "NT1");
5341 return PROTOCOL_NT1;
5345 FN_GLOBAL_INTEGER(lp_minprotocol, minprotocol)
5346 FN_GLOBAL_INTEGER(lp_security, security)
5347 FN_GLOBAL_LIST(lp_auth_methods, AuthMethods)
5348 FN_GLOBAL_BOOL(lp_paranoid_server_security, paranoid_server_security)
5349 FN_GLOBAL_INTEGER(lp_maxdisksize, maxdisksize)
5350 FN_GLOBAL_INTEGER(lp_lpqcachetime, lpqcachetime)
5351 FN_GLOBAL_INTEGER(lp_max_smbd_processes, iMaxSmbdProcesses)
5352 FN_GLOBAL_BOOL(_lp_disable_spoolss, bDisableSpoolss)
5353 FN_GLOBAL_INTEGER(lp_syslog, syslog)
5354 FN_GLOBAL_INTEGER(lp_lm_announce, lm_announce)
5355 FN_GLOBAL_INTEGER(lp_lm_interval, lm_interval)
5356 FN_GLOBAL_INTEGER(lp_machine_password_timeout, machine_password_timeout)
5357 FN_GLOBAL_INTEGER(lp_map_to_guest, map_to_guest)
5358 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, oplock_break_wait_time)
5359 FN_GLOBAL_INTEGER(lp_lock_spin_time, iLockSpinTime)
5360 FN_GLOBAL_INTEGER(lp_usershare_max_shares, iUsershareMaxShares)
5361 FN_GLOBAL_CONST_STRING(lp_socket_options, szSocketOptions)
5362 FN_GLOBAL_INTEGER(lp_config_backend, ConfigBackend)
5363 FN_GLOBAL_INTEGER(lp_smb2_max_read, ismb2_max_read)
5364 FN_GLOBAL_INTEGER(lp_smb2_max_write, ismb2_max_write)
5365 FN_GLOBAL_INTEGER(lp_smb2_max_trans, ismb2_max_trans)
5366 int lp_smb2_max_credits(void)
5368 if (Globals.ismb2_max_credits == 0) {
5369 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5371 return Globals.ismb2_max_credits;
5373 FN_GLOBAL_LIST(lp_svcctl_list, szServicesList)
5374 FN_GLOBAL_STRING(lp_cups_server, szCupsServer)
5375 int lp_cups_encrypt(void)
5378 #ifdef HAVE_HTTPCONNECTENCRYPT
5379 switch (Globals.CupsEncrypt) {
5381 result = HTTP_ENCRYPT_REQUIRED;
5384 result = HTTP_ENCRYPT_ALWAYS;
5387 result = HTTP_ENCRYPT_NEVER;
5393 FN_GLOBAL_STRING(lp_iprint_server, szIPrintServer)
5394 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, cups_connection_timeout)
5395 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, ctdbdSocket)
5396 FN_GLOBAL_LIST(lp_cluster_addresses, szClusterAddresses)
5397 FN_GLOBAL_BOOL(lp_clustering, clustering)
5398 FN_GLOBAL_INTEGER(lp_ctdb_timeout, ctdb_timeout)
5399 FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, ctdb_locktime_warn_threshold)
5400 FN_GLOBAL_BOOL(lp_async_smb_echo_handler, bAsyncSMBEchoHandler)
5401 FN_GLOBAL_BOOL(lp_multicast_dns_register, bMulticastDnsRegister)
5402 FN_GLOBAL_BOOL(lp_allow_insecure_widelinks, bAllowInsecureWidelinks)
5403 FN_GLOBAL_INTEGER(lp_winbind_cache_time, winbind_cache_time)
5404 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, winbind_reconnect_delay)
5405 FN_GLOBAL_INTEGER(lp_winbind_max_clients, winbind_max_clients)
5406 FN_GLOBAL_LIST(lp_winbind_nss_info, szWinbindNssInfo)
5407 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, AlgorithmicRidBase)
5408 FN_GLOBAL_INTEGER(lp_name_cache_timeout, name_cache_timeout)
5409 FN_GLOBAL_INTEGER(lp_client_signing, client_signing)
5410 FN_GLOBAL_INTEGER(lp_server_signing, server_signing)
5411 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, client_ldap_sasl_wrapping)
5413 FN_GLOBAL_CONST_STRING(lp_ncalrpc_dir, ncalrpc_dir)
5415 #include "lib/param/param_functions.c"
5417 FN_LOCAL_STRING(servicename, szService)
5418 FN_LOCAL_CONST_STRING(const_servicename, szService)
5420 /* local prototypes */
5422 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5423 static const char *get_boolean(bool bool_value);
5424 static int getservicebyname(const char *pszServiceName,
5425 struct loadparm_service *pserviceDest);
5426 static void copy_service(struct loadparm_service *pserviceDest,
5427 struct loadparm_service *pserviceSource,
5428 struct bitmap *pcopymapDest);
5429 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5431 static bool do_section(const char *pszSectionName, void *userdata);
5432 static void init_copymap(struct loadparm_service *pservice);
5433 static bool hash_a_service(const char *name, int number);
5434 static void free_service_byindex(int iService);
5435 static void show_parameter(int parmIndex);
5436 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5439 * This is a helper function for parametrical options support. It returns a
5440 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5441 * parametrical functions are quite simple
5443 static struct parmlist_entry *get_parametrics_by_service(struct loadparm_service *service, const char *type,
5446 bool global_section = false;
5448 struct parmlist_entry *data;
5450 if (service == NULL) {
5451 data = Globals.param_opt;
5452 global_section = true;
5454 data = service->param_opt;
5457 if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
5458 DEBUG(0,("asprintf failed!\n"));
5463 if (strwicmp(data->key, param_key) == 0) {
5464 string_free(¶m_key);
5470 if (!global_section) {
5471 /* Try to fetch the same option but from globals */
5472 /* but only if we are not already working with Globals */
5473 data = Globals.param_opt;
5475 if (strwicmp(data->key, param_key) == 0) {
5476 string_free(¶m_key);
5483 string_free(¶m_key);
5489 * This is a helper function for parametrical options support. It returns a
5490 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5491 * parametrical functions are quite simple
5493 static struct parmlist_entry *get_parametrics(int snum, const char *type,
5496 if (snum >= iNumServices) return NULL;
5499 return get_parametrics_by_service(NULL, type, option);
5501 return get_parametrics_by_service(ServicePtrs[snum], type, option);
5506 #define MISSING_PARAMETER(name) \
5507 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5509 /*******************************************************************
5510 convenience routine to return int parameters.
5511 ********************************************************************/
5512 static int lp_int(const char *s)
5516 MISSING_PARAMETER(lp_int);
5520 return (int)strtol(s, NULL, 0);
5523 /*******************************************************************
5524 convenience routine to return unsigned long parameters.
5525 ********************************************************************/
5526 static unsigned long lp_ulong(const char *s)
5530 MISSING_PARAMETER(lp_ulong);
5534 return strtoul(s, NULL, 0);
5537 /*******************************************************************
5538 convenience routine to return boolean parameters.
5539 ********************************************************************/
5540 static bool lp_bool(const char *s)
5545 MISSING_PARAMETER(lp_bool);
5549 if (!set_boolean(s, &ret)) {
5550 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5557 /*******************************************************************
5558 convenience routine to return enum parameters.
5559 ********************************************************************/
5560 static int lp_enum(const char *s,const struct enum_list *_enum)
5564 if (!s || !*s || !_enum) {
5565 MISSING_PARAMETER(lp_enum);
5569 for (i=0; _enum[i].name; i++) {
5570 if (strequal(_enum[i].name,s))
5571 return _enum[i].value;
5574 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5578 #undef MISSING_PARAMETER
5580 /* Return parametric option from a given service. Type is a part of option before ':' */
5581 /* Parametric option has following syntax: 'Type: option = value' */
5582 /* the returned value is talloced on the talloc_tos() */
5583 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5585 struct parmlist_entry *data = get_parametrics(snum, type, option);
5587 if (data == NULL||data->value==NULL) {
5589 return lp_string(def);
5595 return lp_string(data->value);
5598 /* Return parametric option from a given service. Type is a part of option before ':' */
5599 /* Parametric option has following syntax: 'Type: option = value' */
5600 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5602 struct parmlist_entry *data = get_parametrics(snum, type, option);
5604 if (data == NULL||data->value==NULL)
5610 const char *lp_parm_const_string_service(struct loadparm_service *service, const char *type, const char *option)
5612 struct parmlist_entry *data = get_parametrics_by_service(service, type, option);
5614 if (data == NULL||data->value==NULL)
5621 /* Return parametric option from a given service. Type is a part of option before ':' */
5622 /* Parametric option has following syntax: 'Type: option = value' */
5624 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5626 struct parmlist_entry *data = get_parametrics(snum, type, option);
5628 if (data == NULL||data->value==NULL)
5629 return (const char **)def;
5631 if (data->list==NULL) {
5632 data->list = str_list_make_v3(NULL, data->value, NULL);
5635 return (const char **)data->list;
5638 /* Return parametric option from a given service. Type is a part of option before ':' */
5639 /* Parametric option has following syntax: 'Type: option = value' */
5641 int lp_parm_int(int snum, const char *type, const char *option, int def)
5643 struct parmlist_entry *data = get_parametrics(snum, type, option);
5645 if (data && data->value && *data->value)
5646 return lp_int(data->value);
5651 /* Return parametric option from a given service. Type is a part of option before ':' */
5652 /* Parametric option has following syntax: 'Type: option = value' */
5654 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5656 struct parmlist_entry *data = get_parametrics(snum, type, option);
5658 if (data && data->value && *data->value)
5659 return lp_ulong(data->value);
5664 /* Return parametric option from a given service. Type is a part of option before ':' */
5665 /* Parametric option has following syntax: 'Type: option = value' */
5667 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5669 struct parmlist_entry *data = get_parametrics(snum, type, option);
5671 if (data && data->value && *data->value)
5672 return lp_bool(data->value);
5677 /* Return parametric option from a given service. Type is a part of option before ':' */
5678 /* Parametric option has following syntax: 'Type: option = value' */
5680 int lp_parm_enum(int snum, const char *type, const char *option,
5681 const struct enum_list *_enum, int def)
5683 struct parmlist_entry *data = get_parametrics(snum, type, option);
5685 if (data && data->value && *data->value && _enum)
5686 return lp_enum(data->value, _enum);
5692 /***************************************************************************
5693 Initialise a service to the defaults.
5694 ***************************************************************************/
5696 static void init_service(struct loadparm_service *pservice)
5698 memset((char *)pservice, '\0', sizeof(struct loadparm_service));
5699 copy_service(pservice, &sDefault, NULL);
5704 * free a param_opts structure.
5705 * param_opts handling should be moved to talloc;
5706 * then this whole functions reduces to a TALLOC_FREE().
5709 static void free_param_opts(struct parmlist_entry **popts)
5711 struct parmlist_entry *opt, *next_opt;
5713 if (popts == NULL) {
5717 if (*popts != NULL) {
5718 DEBUG(5, ("Freeing parametrics:\n"));
5721 while (opt != NULL) {
5722 string_free(&opt->key);
5723 string_free(&opt->value);
5724 TALLOC_FREE(opt->list);
5725 next_opt = opt->next;
5732 /***************************************************************************
5733 Free the dynamically allocated parts of a service struct.
5734 ***************************************************************************/
5736 static void free_service(struct loadparm_service *pservice)
5741 if (pservice->szService)
5742 DEBUG(5, ("free_service: Freeing service %s\n",
5743 pservice->szService));
5745 free_parameters(pservice);
5747 string_free(&pservice->szService);
5748 TALLOC_FREE(pservice->copymap);
5750 free_param_opts(&pservice->param_opt);
5752 ZERO_STRUCTP(pservice);
5756 /***************************************************************************
5757 remove a service indexed in the ServicePtrs array from the ServiceHash
5758 and free the dynamically allocated parts
5759 ***************************************************************************/
5761 static void free_service_byindex(int idx)
5763 if ( !LP_SNUM_OK(idx) )
5766 ServicePtrs[idx]->valid = false;
5767 invalid_services[num_invalid_services++] = idx;
5769 /* we have to cleanup the hash record */
5771 if (ServicePtrs[idx]->szService) {
5772 char *canon_name = canonicalize_servicename(
5774 ServicePtrs[idx]->szService );
5776 dbwrap_delete_bystring(ServiceHash, canon_name );
5777 TALLOC_FREE(canon_name);
5780 free_service(ServicePtrs[idx]);
5783 /***************************************************************************
5784 Add a new service to the services array initialising it with the given
5786 ***************************************************************************/
5788 static int add_a_service(const struct loadparm_service *pservice, const char *name)
5791 struct loadparm_service tservice;
5792 int num_to_alloc = iNumServices + 1;
5794 tservice = *pservice;
5796 /* it might already exist */
5798 i = getservicebyname(name, NULL);
5804 /* find an invalid one */
5806 if (num_invalid_services > 0) {
5807 i = invalid_services[--num_invalid_services];
5810 /* if not, then create one */
5811 if (i == iNumServices) {
5812 struct loadparm_service **tsp;
5815 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct loadparm_service *, num_to_alloc);
5817 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
5821 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct loadparm_service);
5822 if (!ServicePtrs[iNumServices]) {
5823 DEBUG(0,("add_a_service: out of memory!\n"));
5828 /* enlarge invalid_services here for now... */
5829 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
5831 if (tinvalid == NULL) {
5832 DEBUG(0,("add_a_service: failed to enlarge "
5833 "invalid_services!\n"));
5836 invalid_services = tinvalid;
5838 free_service_byindex(i);
5841 ServicePtrs[i]->valid = true;
5843 init_service(ServicePtrs[i]);
5844 copy_service(ServicePtrs[i], &tservice, NULL);
5846 string_set(&ServicePtrs[i]->szService, name);
5848 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
5849 i, ServicePtrs[i]->szService));
5851 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
5858 /***************************************************************************
5859 Convert a string to uppercase and remove whitespaces.
5860 ***************************************************************************/
5862 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
5867 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
5871 result = talloc_strdup(ctx, src);
5872 SMB_ASSERT(result != NULL);
5878 /***************************************************************************
5879 Add a name/index pair for the services array to the hash table.
5880 ***************************************************************************/
5882 static bool hash_a_service(const char *name, int idx)
5886 if ( !ServiceHash ) {
5887 DEBUG(10,("hash_a_service: creating servicehash\n"));
5888 ServiceHash = db_open_rbt(NULL);
5889 if ( !ServiceHash ) {
5890 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
5895 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
5898 canon_name = canonicalize_servicename(talloc_tos(), name );
5900 dbwrap_store_bystring(ServiceHash, canon_name,
5901 make_tdb_data((uint8 *)&idx, sizeof(idx)),
5904 TALLOC_FREE(canon_name);
5909 /***************************************************************************
5910 Add a new home service, with the specified home directory, defaults coming
5912 ***************************************************************************/
5914 bool lp_add_home(const char *pszHomename, int iDefaultService,
5915 const char *user, const char *pszHomedir)
5919 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
5920 pszHomedir[0] == '\0') {
5924 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
5929 if (!(*(ServicePtrs[iDefaultService]->szPath))
5930 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
5931 string_set(&ServicePtrs[i]->szPath, pszHomedir);
5934 if (!(*(ServicePtrs[i]->comment))) {
5935 char *comment = NULL;
5936 if (asprintf(&comment, "Home directory of %s", user) < 0) {
5939 string_set(&ServicePtrs[i]->comment, comment);
5943 /* set the browseable flag from the global default */
5945 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5946 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
5948 ServicePtrs[i]->autoloaded = true;
5950 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
5951 user, ServicePtrs[i]->szPath ));
5956 /***************************************************************************
5957 Add a new service, based on an old one.
5958 ***************************************************************************/
5960 int lp_add_service(const char *pszService, int iDefaultService)
5962 if (iDefaultService < 0) {
5963 return add_a_service(&sDefault, pszService);
5966 return (add_a_service(ServicePtrs[iDefaultService], pszService));
5969 /***************************************************************************
5970 Add the IPC service.
5971 ***************************************************************************/
5973 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
5975 char *comment = NULL;
5976 int i = add_a_service(&sDefault, ipc_name);
5981 if (asprintf(&comment, "IPC Service (%s)",
5982 Globals.szServerString) < 0) {
5986 string_set(&ServicePtrs[i]->szPath, tmpdir());
5987 string_set(&ServicePtrs[i]->szUsername, "");
5988 string_set(&ServicePtrs[i]->comment, comment);
5989 string_set(&ServicePtrs[i]->fstype, "IPC");
5990 ServicePtrs[i]->iMaxConnections = 0;
5991 ServicePtrs[i]->bAvailable = true;
5992 ServicePtrs[i]->bRead_only = true;
5993 ServicePtrs[i]->bGuest_only = false;
5994 ServicePtrs[i]->bAdministrative_share = true;
5995 ServicePtrs[i]->bGuest_ok = guest_ok;
5996 ServicePtrs[i]->bPrint_ok = false;
5997 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5999 DEBUG(3, ("adding IPC service\n"));
6005 /***************************************************************************
6006 Add a new printer service, with defaults coming from service iFrom.
6007 ***************************************************************************/
6009 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
6011 const char *comment = "From Printcap";
6012 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6017 /* note that we do NOT default the availability flag to true - */
6018 /* we take it from the default service passed. This allows all */
6019 /* dynamic printers to be disabled by disabling the [printers] */
6020 /* entry (if/when the 'available' keyword is implemented!). */
6022 /* the printer name is set to the service name. */
6023 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6024 string_set(&ServicePtrs[i]->comment, comment);
6026 /* set the browseable flag from the gloabl default */
6027 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6029 /* Printers cannot be read_only. */
6030 ServicePtrs[i]->bRead_only = false;
6031 /* No share modes on printer services. */
6032 ServicePtrs[i]->bShareModes = false;
6033 /* No oplocks on printer services. */
6034 ServicePtrs[i]->bOpLocks = false;
6035 /* Printer services must be printable. */
6036 ServicePtrs[i]->bPrint_ok = true;
6038 DEBUG(3, ("adding printer service %s\n", pszPrintername));
6044 /***************************************************************************
6045 Check whether the given parameter name is valid.
6046 Parametric options (names containing a colon) are considered valid.
6047 ***************************************************************************/
6049 bool lp_parameter_is_valid(const char *pszParmName)
6051 return ((map_parameter(pszParmName) != -1) ||
6052 (strchr(pszParmName, ':') != NULL));
6055 /***************************************************************************
6056 Check whether the given name is the name of a global parameter.
6057 Returns true for strings belonging to parameters of class
6058 P_GLOBAL, false for all other strings, also for parametric options
6059 and strings not belonging to any option.
6060 ***************************************************************************/
6062 bool lp_parameter_is_global(const char *pszParmName)
6064 int num = map_parameter(pszParmName);
6067 return (parm_table[num].p_class == P_GLOBAL);
6073 /**************************************************************************
6074 Check whether the given name is the canonical name of a parameter.
6075 Returns false if it is not a valid parameter Name.
6076 For parametric options, true is returned.
6077 **************************************************************************/
6079 bool lp_parameter_is_canonical(const char *parm_name)
6081 if (!lp_parameter_is_valid(parm_name)) {
6085 return (map_parameter(parm_name) ==
6086 map_parameter_canonical(parm_name, NULL));
6089 /**************************************************************************
6090 Determine the canonical name for a parameter.
6091 Indicate when it is an inverse (boolean) synonym instead of a
6093 **************************************************************************/
6095 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6100 if (!lp_parameter_is_valid(parm_name)) {
6105 num = map_parameter_canonical(parm_name, inverse);
6107 /* parametric option */
6108 *canon_parm = parm_name;
6110 *canon_parm = parm_table[num].label;
6117 /**************************************************************************
6118 Determine the canonical name for a parameter.
6119 Turn the value given into the inverse boolean expression when
6120 the synonym is an invers boolean synonym.
6122 Return true if parm_name is a valid parameter name and
6123 in case it is an invers boolean synonym, if the val string could
6124 successfully be converted to the reverse bool.
6125 Return false in all other cases.
6126 **************************************************************************/
6128 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6130 const char **canon_parm,
6131 const char **canon_val)
6136 if (!lp_parameter_is_valid(parm_name)) {
6142 num = map_parameter_canonical(parm_name, &inverse);
6144 /* parametric option */
6145 *canon_parm = parm_name;
6148 *canon_parm = parm_table[num].label;
6150 if (!lp_invert_boolean(val, canon_val)) {
6162 /***************************************************************************
6163 Map a parameter's string representation to something we can use.
6164 Returns false if the parameter string is not recognised, else TRUE.
6165 ***************************************************************************/
6167 static int map_parameter(const char *pszParmName)
6171 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6174 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6175 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6178 /* Warn only if it isn't parametric option */
6179 if (strchr(pszParmName, ':') == NULL)
6180 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6181 /* We do return 'fail' for parametric options as well because they are
6182 stored in different storage
6187 /***************************************************************************
6188 Map a parameter's string representation to the index of the canonical
6189 form of the parameter (it might be a synonym).
6190 Returns -1 if the parameter string is not recognised.
6191 ***************************************************************************/
6193 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6195 int parm_num, canon_num;
6196 bool loc_inverse = false;
6198 parm_num = map_parameter(pszParmName);
6199 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6200 /* invalid, parametric or no canidate for synonyms ... */
6204 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6205 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6206 parm_num = canon_num;
6212 if (inverse != NULL) {
6213 *inverse = loc_inverse;
6218 /***************************************************************************
6219 return true if parameter number parm1 is a synonym of parameter
6220 number parm2 (parm2 being the principal name).
6221 set inverse to true if parm1 is P_BOOLREV and parm2 is P_BOOL,
6223 ***************************************************************************/
6225 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6227 if ((parm_table[parm1].offset == parm_table[parm2].offset) &&
6228 (parm_table[parm1].p_class == parm_table[parm2].p_class) &&
6229 (parm_table[parm1].flags & FLAG_HIDE) &&
6230 !(parm_table[parm2].flags & FLAG_HIDE))
6232 if (inverse != NULL) {
6233 if ((parm_table[parm1].type == P_BOOLREV) &&
6234 (parm_table[parm2].type == P_BOOL))
6246 /***************************************************************************
6247 Show one parameter's name, type, [values,] and flags.
6248 (helper functions for show_parameter_list)
6249 ***************************************************************************/
6251 static void show_parameter(int parmIndex)
6253 int enumIndex, flagIndex;
6258 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6259 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6261 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6262 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6264 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6265 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6266 "FLAG_DEPRECATED", "FLAG_HIDE", NULL};
6268 printf("%s=%s", parm_table[parmIndex].label,
6269 type[parm_table[parmIndex].type]);
6270 if (parm_table[parmIndex].type == P_ENUM) {
6273 parm_table[parmIndex].enum_list[enumIndex].name;
6277 enumIndex ? "|" : "",
6278 parm_table[parmIndex].enum_list[enumIndex].name);
6283 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6284 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6287 flag_names[flagIndex]);
6292 /* output synonyms */
6294 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6295 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6296 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6297 parm_table[parmIndex2].label);
6298 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6300 printf(" (synonyms: ");
6305 printf("%s%s", parm_table[parmIndex2].label,
6306 inverse ? "[i]" : "");
6316 /***************************************************************************
6317 Show all parameter's name, type, [values,] and flags.
6318 ***************************************************************************/
6320 void show_parameter_list(void)
6322 int classIndex, parmIndex;
6323 const char *section_names[] = { "local", "global", NULL};
6325 for (classIndex=0; section_names[classIndex]; classIndex++) {
6326 printf("[%s]\n", section_names[classIndex]);
6327 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6328 if (parm_table[parmIndex].p_class == classIndex) {
6329 show_parameter(parmIndex);
6335 /***************************************************************************
6336 Check if a given string correctly represents a boolean value.
6337 ***************************************************************************/
6339 bool lp_string_is_valid_boolean(const char *parm_value)
6341 return set_boolean(parm_value, NULL);
6344 /***************************************************************************
6345 Get the standard string representation of a boolean value ("yes" or "no")
6346 ***************************************************************************/
6348 static const char *get_boolean(bool bool_value)
6350 static const char *yes_str = "yes";
6351 static const char *no_str = "no";
6353 return (bool_value ? yes_str : no_str);
6356 /***************************************************************************
6357 Provide the string of the negated boolean value associated to the boolean
6358 given as a string. Returns false if the passed string does not correctly
6359 represent a boolean.
6360 ***************************************************************************/
6362 bool lp_invert_boolean(const char *str, const char **inverse_str)
6366 if (!set_boolean(str, &val)) {
6370 *inverse_str = get_boolean(!val);
6374 /***************************************************************************
6375 Provide the canonical string representation of a boolean value given
6376 as a string. Return true on success, false if the string given does
6377 not correctly represent a boolean.
6378 ***************************************************************************/
6380 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6384 if (!set_boolean(str, &val)) {
6388 *canon_str = get_boolean(val);
6392 /***************************************************************************
6393 Find a service by name. Otherwise works like get_service.
6394 ***************************************************************************/
6396 static int getservicebyname(const char *pszServiceName, struct loadparm_service *pserviceDest)
6402 if (ServiceHash == NULL) {
6406 canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
6408 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
6410 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
6411 iService = *(int *)data.dptr;
6414 TALLOC_FREE(canon_name);
6416 if ((iService != -1) && (LP_SNUM_OK(iService))
6417 && (pserviceDest != NULL)) {
6418 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6424 /* Return a pointer to a service by name. Unlike getservicebyname, it does not copy the service */
6425 struct loadparm_service *lp_service(const char *pszServiceName)
6427 int iService = getservicebyname(pszServiceName, NULL);
6428 if (iService == -1 || !LP_SNUM_OK(iService)) {
6431 return ServicePtrs[iService];
6434 struct loadparm_service *lp_servicebynum(int snum)
6436 if ((snum == -1) || !LP_SNUM_OK(snum)) {
6439 return ServicePtrs[snum];
6442 struct loadparm_service *lp_default_loadparm_service()
6448 /***************************************************************************
6449 Copy a service structure to another.
6450 If pcopymapDest is NULL then copy all fields
6451 ***************************************************************************/
6454 * Add a parametric option to a parmlist_entry,
6455 * replacing old value, if already present.
6457 static void set_param_opt(struct parmlist_entry **opt_list,
6458 const char *opt_name,
6459 const char *opt_value,
6462 struct parmlist_entry *new_opt, *opt;
6465 if (opt_list == NULL) {
6472 /* Traverse destination */
6474 /* If we already have same option, override it */
6475 if (strwicmp(opt->key, opt_name) == 0) {
6476 if ((opt->priority & FLAG_CMDLINE) &&
6477 !(priority & FLAG_CMDLINE)) {
6478 /* it's been marked as not to be
6482 string_free(&opt->value);
6483 TALLOC_FREE(opt->list);
6484 opt->value = SMB_STRDUP(opt_value);
6485 opt->priority = priority;
6492 new_opt = SMB_XMALLOC_P(struct parmlist_entry);
6493 new_opt->key = SMB_STRDUP(opt_name);
6494 new_opt->value = SMB_STRDUP(opt_value);
6495 new_opt->list = NULL;
6496 new_opt->priority = priority;
6497 DLIST_ADD(*opt_list, new_opt);
6501 static void copy_service(struct loadparm_service *pserviceDest, struct loadparm_service *pserviceSource,
6502 struct bitmap *pcopymapDest)
6505 bool bcopyall = (pcopymapDest == NULL);
6506 struct parmlist_entry *data;
6508 for (i = 0; parm_table[i].label; i++)
6509 if (parm_table[i].p_class == P_LOCAL &&
6510 (bcopyall || bitmap_query(pcopymapDest,i))) {
6511 void *src_ptr = lp_parm_ptr(pserviceSource, &parm_table[i]);
6512 void *dest_ptr = lp_parm_ptr(pserviceDest, &parm_table[i]);
6514 switch (parm_table[i].type) {
6517 *(bool *)dest_ptr = *(bool *)src_ptr;
6523 *(int *)dest_ptr = *(int *)src_ptr;
6527 *(char *)dest_ptr = *(char *)src_ptr;
6531 string_set((char **)dest_ptr,
6537 char *upper_string = strupper_talloc(talloc_tos(),
6539 string_set((char **)dest_ptr,
6541 TALLOC_FREE(upper_string);
6545 TALLOC_FREE(*((char ***)dest_ptr));
6546 *((char ***)dest_ptr) = str_list_copy(NULL,
6547 *(const char ***)src_ptr);
6555 init_copymap(pserviceDest);
6556 if (pserviceSource->copymap)
6557 bitmap_copy(pserviceDest->copymap,
6558 pserviceSource->copymap);
6561 data = pserviceSource->param_opt;
6563 set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->priority);
6568 /***************************************************************************
6569 Check a service for consistency. Return false if the service is in any way
6570 incomplete or faulty, else true.
6571 ***************************************************************************/
6573 bool service_ok(int iService)
6578 if (ServicePtrs[iService]->szService[0] == '\0') {
6579 DEBUG(0, ("The following message indicates an internal error:\n"));
6580 DEBUG(0, ("No service name in service entry.\n"));
6584 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6585 /* I can't see why you'd want a non-printable printer service... */
6586 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6587 if (!ServicePtrs[iService]->bPrint_ok) {
6588 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6589 ServicePtrs[iService]->szService));
6590 ServicePtrs[iService]->bPrint_ok = true;
6592 /* [printers] service must also be non-browsable. */
6593 if (ServicePtrs[iService]->bBrowseable)
6594 ServicePtrs[iService]->bBrowseable = false;
6597 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6598 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6599 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6601 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6602 ServicePtrs[iService]->szService));
6603 ServicePtrs[iService]->bAvailable = false;
6606 /* If a service is flagged unavailable, log the fact at level 1. */
6607 if (!ServicePtrs[iService]->bAvailable)
6608 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6609 ServicePtrs[iService]->szService));
6614 static struct smbconf_ctx *lp_smbconf_ctx(void)
6617 static struct smbconf_ctx *conf_ctx = NULL;
6619 if (conf_ctx == NULL) {
6620 err = smbconf_init(NULL, &conf_ctx, "registry:");
6621 if (!SBC_ERROR_IS_OK(err)) {
6622 DEBUG(1, ("error initializing registry configuration: "
6623 "%s\n", sbcErrorString(err)));
6631 static bool process_smbconf_service(struct smbconf_service *service)
6636 if (service == NULL) {
6640 ret = do_section(service->name, NULL);
6644 for (count = 0; count < service->num_params; count++) {
6645 ret = do_parameter(service->param_names[count],
6646 service->param_values[count],
6652 if (iServiceIndex >= 0) {
6653 return service_ok(iServiceIndex);
6659 * load a service from registry and activate it
6661 bool process_registry_service(const char *service_name)
6664 struct smbconf_service *service = NULL;
6665 TALLOC_CTX *mem_ctx = talloc_stackframe();
6666 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6669 if (conf_ctx == NULL) {
6673 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6675 if (!smbconf_share_exists(conf_ctx, service_name)) {
6677 * Registry does not contain data for this service (yet),
6678 * but make sure lp_load doesn't return false.
6684 err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6685 if (!SBC_ERROR_IS_OK(err)) {
6689 ret = process_smbconf_service(service);
6695 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6698 TALLOC_FREE(mem_ctx);
6703 * process_registry_globals
6705 static bool process_registry_globals(void)
6709 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6711 ret = do_parameter("registry shares", "yes", NULL);
6716 return process_registry_service(GLOBAL_NAME);
6719 bool process_registry_shares(void)
6723 struct smbconf_service **service = NULL;
6724 uint32_t num_shares = 0;
6725 TALLOC_CTX *mem_ctx = talloc_stackframe();
6726 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6729 if (conf_ctx == NULL) {
6733 err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6734 if (!SBC_ERROR_IS_OK(err)) {
6740 for (count = 0; count < num_shares; count++) {
6741 if (strequal(service[count]->name, GLOBAL_NAME)) {
6744 ret = process_smbconf_service(service[count]);
6751 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6754 TALLOC_FREE(mem_ctx);
6759 * reload those shares from registry that are already
6760 * activated in the services array.
6762 static bool reload_registry_shares(void)
6767 for (i = 0; i < iNumServices; i++) {
6772 if (ServicePtrs[i]->usershare == USERSHARE_VALID) {
6776 ret = process_registry_service(ServicePtrs[i]->szService);
6787 #define MAX_INCLUDE_DEPTH 100
6789 static uint8_t include_depth;
6791 static struct file_lists {
6792 struct file_lists *next;
6796 } *file_lists = NULL;
6798 /*******************************************************************
6799 Keep a linked list of all config files so we know when one has changed
6800 it's date and needs to be reloaded.
6801 ********************************************************************/
6803 static void add_to_file_list(const char *fname, const char *subfname)
6805 struct file_lists *f = file_lists;
6808 if (f->name && !strcmp(f->name, fname))
6814 f = SMB_MALLOC_P(struct file_lists);
6817 f->next = file_lists;
6818 f->name = SMB_STRDUP(fname);
6823 f->subfname = SMB_STRDUP(subfname);
6830 f->modtime = file_modtime(subfname);
6832 time_t t = file_modtime(subfname);
6840 * Free the file lists
6842 static void free_file_list(void)
6844 struct file_lists *f;
6845 struct file_lists *next;
6850 SAFE_FREE( f->name );
6851 SAFE_FREE( f->subfname );
6860 * Utility function for outsiders to check if we're running on registry.
6862 bool lp_config_backend_is_registry(void)
6864 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
6868 * Utility function to check if the config backend is FILE.
6870 bool lp_config_backend_is_file(void)
6872 return (lp_config_backend() == CONFIG_BACKEND_FILE);
6875 /*******************************************************************
6876 Check if a config file has changed date.
6877 ********************************************************************/
6879 bool lp_file_list_changed(void)
6881 struct file_lists *f = file_lists;
6883 DEBUG(6, ("lp_file_list_changed()\n"));
6888 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
6889 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6891 if (conf_ctx == NULL) {
6894 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
6897 DEBUGADD(6, ("registry config changed\n"));
6902 n2 = talloc_sub_basic(talloc_tos(),
6903 get_current_username(),
6904 current_user_info.domain,
6909 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
6910 f->name, n2, ctime(&f->modtime)));
6912 mod_time = file_modtime(n2);
6915 ((f->modtime != mod_time) ||
6916 (f->subfname == NULL) ||
6917 (strcmp(n2, f->subfname) != 0)))
6920 ("file %s modified: %s\n", n2,
6922 f->modtime = mod_time;
6923 SAFE_FREE(f->subfname);
6924 f->subfname = SMB_STRDUP(n2);
6937 * Initialize iconv conversion descriptors.
6939 * This is called the first time it is needed, and also called again
6940 * every time the configuration is reloaded, because the charset or
6941 * codepage might have changed.
6943 static void init_iconv(void)
6945 global_iconv_handle = smb_iconv_handle_reinit(NULL, lp_dos_charset(),
6947 true, global_iconv_handle);
6950 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6952 if (strcmp(*ptr, pszParmValue) != 0) {
6953 string_set(ptr, pszParmValue);
6959 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6961 bool is_utf8 = false;
6962 size_t len = strlen(pszParmValue);
6964 if (len == 4 || len == 5) {
6965 /* Don't use StrCaseCmp here as we don't want to
6966 initialize iconv. */
6967 if ((toupper_m(pszParmValue[0]) == 'U') &&
6968 (toupper_m(pszParmValue[1]) == 'T') &&
6969 (toupper_m(pszParmValue[2]) == 'F')) {
6971 if (pszParmValue[3] == '8') {
6975 if (pszParmValue[3] == '-' &&
6976 pszParmValue[4] == '8') {
6983 if (strcmp(*ptr, pszParmValue) != 0) {
6985 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
6986 "be UTF8, using (default value) %s instead.\n",
6987 DEFAULT_DOS_CHARSET));
6988 pszParmValue = DEFAULT_DOS_CHARSET;
6990 string_set(ptr, pszParmValue);
6996 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6999 char *realm = strupper_talloc(talloc_tos(), pszParmValue);
7000 char *dnsdomain = strlower_talloc(talloc_tos(), pszParmValue);
7002 ret &= string_set(&Globals.szRealm, pszParmValue);
7003 ret &= string_set(&Globals.szRealmUpper, realm);
7004 ret &= string_set(&Globals.szDnsDomain, dnsdomain);
7006 TALLOC_FREE(dnsdomain);
7011 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7013 TALLOC_FREE(Globals.szNetbiosAliases);
7014 Globals.szNetbiosAliases = (const char **)str_list_make_v3(NULL, pszParmValue, NULL);
7015 return set_netbios_aliases(Globals.szNetbiosAliases);
7018 /***************************************************************************
7019 Handle the include operation.
7020 ***************************************************************************/
7021 static bool bAllowIncludeRegistry = true;
7023 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7027 if (include_depth >= MAX_INCLUDE_DEPTH) {
7028 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
7033 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
7034 if (!bAllowIncludeRegistry) {
7037 if (bInGlobalSection) {
7040 ret = process_registry_globals();
7044 DEBUG(1, ("\"include = registry\" only effective "
7045 "in %s section\n", GLOBAL_NAME));
7050 fname = talloc_sub_basic(talloc_tos(), get_current_username(),
7051 current_user_info.domain,
7054 add_to_file_list(pszParmValue, fname);
7056 string_set(ptr, fname);
7058 if (file_exist(fname)) {
7061 ret = pm_process(fname, do_section, do_parameter, NULL);
7067 DEBUG(2, ("Can't find include file %s\n", fname));
7072 /***************************************************************************
7073 Handle the interpretation of the copy parameter.
7074 ***************************************************************************/
7076 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7080 struct loadparm_service serviceTemp;
7082 string_set(ptr, pszParmValue);
7084 init_service(&serviceTemp);
7088 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7090 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7091 if (iTemp == iServiceIndex) {
7092 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7094 copy_service(ServicePtrs[iServiceIndex],
7096 ServicePtrs[iServiceIndex]->copymap);
7100 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7104 free_service(&serviceTemp);
7108 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7110 Globals.ldap_debug_level = lp_int(pszParmValue);
7111 init_ldap_debugging();
7115 /***************************************************************************
7116 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7121 idmap uid = 1000-1999
7124 We only do simple parsing checks here. The strings are parsed into useful
7125 structures in the idmap daemon code.
7127 ***************************************************************************/
7129 /* Some lp_ routines to return idmap [ug]id information */
7131 static uid_t idmap_uid_low, idmap_uid_high;
7132 static gid_t idmap_gid_low, idmap_gid_high;
7134 bool lp_idmap_uid(uid_t *low, uid_t *high)
7136 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7140 *low = idmap_uid_low;
7143 *high = idmap_uid_high;
7148 bool lp_idmap_gid(gid_t *low, gid_t *high)
7150 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7154 *low = idmap_gid_low;
7157 *high = idmap_gid_high;
7162 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7164 lp_do_parameter(snum, "idmap config * : backend", pszParmValue);
7169 /* Do some simple checks on "idmap [ug]id" parameter values */
7171 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7173 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7178 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7180 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7185 /***************************************************************************
7186 Handle the DEBUG level list.
7187 ***************************************************************************/
7189 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValueIn, char **ptr )
7191 string_set(ptr, pszParmValueIn);
7192 return debug_parse_levels(pszParmValueIn);
7195 /***************************************************************************
7196 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7197 ***************************************************************************/
7199 static const char *append_ldap_suffix( const char *str )
7201 const char *suffix_string;
7204 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7205 Globals.szLdapSuffix );
7206 if ( !suffix_string ) {
7207 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7211 return suffix_string;
7214 const char *lp_ldap_machine_suffix(void)
7216 if (Globals.szLdapMachineSuffix[0])
7217 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7219 return lp_string(Globals.szLdapSuffix);
7222 const char *lp_ldap_user_suffix(void)
7224 if (Globals.szLdapUserSuffix[0])
7225 return append_ldap_suffix(Globals.szLdapUserSuffix);
7227 return lp_string(Globals.szLdapSuffix);
7230 const char *lp_ldap_group_suffix(void)
7232 if (Globals.szLdapGroupSuffix[0])
7233 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7235 return lp_string(Globals.szLdapSuffix);
7238 const char *lp_ldap_idmap_suffix(void)
7240 if (Globals.szLdapIdmapSuffix[0])
7241 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7243 return lp_string(Globals.szLdapSuffix);
7246 /****************************************************************************
7247 set the value for a P_ENUM
7248 ***************************************************************************/
7250 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7255 for (i = 0; parm->enum_list[i].name; i++) {
7256 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7257 *ptr = parm->enum_list[i].value;
7261 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7262 pszParmValue, parm->label));
7265 /***************************************************************************
7266 ***************************************************************************/
7268 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7270 static int parm_num = -1;
7271 struct loadparm_service *s;
7273 if ( parm_num == -1 )
7274 parm_num = map_parameter( "printing" );
7276 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7281 s = ServicePtrs[snum];
7283 init_printer_values( s );
7289 /***************************************************************************
7290 Initialise a copymap.
7291 ***************************************************************************/
7293 static void init_copymap(struct loadparm_service *pservice)
7297 TALLOC_FREE(pservice->copymap);
7299 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
7300 if (!pservice->copymap)
7302 ("Couldn't allocate copymap!! (size %d)\n",
7303 (int)NUMPARAMETERS));
7305 for (i = 0; i < NUMPARAMETERS; i++)
7306 bitmap_set(pservice->copymap, i);
7310 return the parameter pointer for a parameter
7312 void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm)
7314 if (service == NULL) {
7315 if (parm->p_class == P_LOCAL)
7316 return (void *)(((char *)&sDefault)+parm->offset);
7317 else if (parm->p_class == P_GLOBAL)
7318 return (void *)(((char *)&Globals)+parm->offset);
7321 return (void *)(((char *)service) + parm->offset);
7325 /***************************************************************************
7326 Return the local pointer to a parameter given the service number and parameter
7327 ***************************************************************************/
7329 void *lp_local_ptr_by_snum(int snum, struct parm_struct *parm)
7331 return lp_parm_ptr(ServicePtrs[snum], parm);
7334 /***************************************************************************
7335 Process a parameter for a particular service number. If snum < 0
7336 then assume we are in the globals.
7337 ***************************************************************************/
7339 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7342 void *parm_ptr = NULL; /* where we are going to store the result */
7343 struct parmlist_entry **opt_list;
7345 parmnum = map_parameter(pszParmName);
7348 if (strchr(pszParmName, ':') == NULL) {
7349 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7355 * We've got a parametric option
7358 opt_list = (snum < 0)
7359 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7360 set_param_opt(opt_list, pszParmName, pszParmValue, 0);
7365 /* if it's already been set by the command line, then we don't
7367 if (parm_table[parmnum].flags & FLAG_CMDLINE) {
7371 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7372 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7376 /* we might point at a service, the default service or a global */
7378 parm_ptr = lp_parm_ptr(NULL, &parm_table[parmnum]);
7380 if (parm_table[parmnum].p_class == P_GLOBAL) {
7382 ("Global parameter %s found in service section!\n",
7386 parm_ptr = lp_local_ptr_by_snum(snum, &parm_table[parmnum]);
7390 if (!ServicePtrs[snum]->copymap)
7391 init_copymap(ServicePtrs[snum]);
7393 /* this handles the aliases - set the copymap for other entries with
7394 the same data pointer */
7395 for (i = 0; parm_table[i].label; i++) {
7396 if ((parm_table[i].offset == parm_table[parmnum].offset)
7397 && (parm_table[i].p_class == parm_table[parmnum].p_class)) {
7398 bitmap_clear(ServicePtrs[snum]->copymap, i);
7403 /* if it is a special case then go ahead */
7404 if (parm_table[parmnum].special) {
7405 return parm_table[parmnum].special(NULL, snum, pszParmValue,
7409 /* now switch on the type of variable it is */
7410 switch (parm_table[parmnum].type)
7413 *(bool *)parm_ptr = lp_bool(pszParmValue);
7417 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7421 *(int *)parm_ptr = lp_int(pszParmValue);
7425 *(char *)parm_ptr = *pszParmValue;
7429 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7431 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7438 if (conv_str_size_error(pszParmValue, &val)) {
7439 if (val <= INT_MAX) {
7440 *(int *)parm_ptr = (int)val;
7445 DEBUG(0,("lp_do_parameter(%s): value is not "
7446 "a valid size specifier!\n", pszParmValue));
7452 TALLOC_FREE(*((char ***)parm_ptr));
7453 *(char ***)parm_ptr = str_list_make_v3(
7454 NULL, pszParmValue, NULL);
7458 string_set((char **)parm_ptr, pszParmValue);
7463 char *upper_string = strupper_talloc(talloc_tos(),
7465 string_set((char **)parm_ptr, upper_string);
7466 TALLOC_FREE(upper_string);
7470 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7479 /***************************************************************************
7480 set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
7481 FLAG_CMDLINE won't be overridden by loads from smb.conf.
7482 ***************************************************************************/
7484 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
7487 parmnum = map_parameter(pszParmName);
7489 parm_table[parmnum].flags &= ~FLAG_CMDLINE;
7490 if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
7493 parm_table[parmnum].flags |= FLAG_CMDLINE;
7495 /* we have to also set FLAG_CMDLINE on aliases. Aliases must
7496 * be grouped in the table, so we don't have to search the
7499 i>=0 && parm_table[i].offset == parm_table[parmnum].offset
7500 && parm_table[i].p_class == parm_table[parmnum].p_class;
7502 parm_table[i].flags |= FLAG_CMDLINE;
7504 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset
7505 && parm_table[i].p_class == parm_table[parmnum].p_class;i++) {
7506 parm_table[i].flags |= FLAG_CMDLINE;
7510 store_lp_set_cmdline(pszParmName, pszParmValue);
7515 /* it might be parametric */
7516 if (strchr(pszParmName, ':') != NULL) {
7517 set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
7519 store_lp_set_cmdline(pszParmName, pszParmValue);
7524 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
7528 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
7530 return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
7533 /***************************************************************************
7534 Process a parameter.
7535 ***************************************************************************/
7537 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7540 if (!bInGlobalSection && bGlobalOnly)
7543 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7545 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7546 pszParmName, pszParmValue));
7550 set a option from the commandline in 'a=b' format. Use to support --option
7552 bool lp_set_option(const char *option)
7557 s = talloc_strdup(NULL, option);
7570 /* skip white spaces after the = sign */
7573 } while (*p == ' ');
7575 ret = lp_set_cmdline(s, p);
7580 /**************************************************************************
7581 Print a parameter of the specified type.
7582 ***************************************************************************/
7584 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7586 /* For the seperation of lists values that we print below */
7587 const char *list_sep = ", ";
7592 for (i = 0; p->enum_list[i].name; i++) {
7593 if (*(int *)ptr == p->enum_list[i].value) {
7595 p->enum_list[i].name);
7602 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7606 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7611 fprintf(f, "%d", *(int *)ptr);
7615 fprintf(f, "%c", *(char *)ptr);
7619 int val = *(int *)ptr;
7623 fprintf(f, "0%o", val);
7632 if ((char ***)ptr && *(char ***)ptr) {
7633 char **list = *(char ***)ptr;
7634 for (; *list; list++) {
7635 /* surround strings with whitespace in double quotes */
7636 if (*(list+1) == NULL) {
7637 /* last item, no extra separator */
7640 if ( strchr_m( *list, ' ' ) ) {
7641 fprintf(f, "\"%s\"%s", *list, list_sep);
7643 fprintf(f, "%s%s", *list, list_sep);
7651 if (*(char **)ptr) {
7652 fprintf(f, "%s", *(char **)ptr);
7660 /***************************************************************************
7661 Check if two parameters are equal.
7662 ***************************************************************************/
7664 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7669 return (*((bool *)ptr1) == *((bool *)ptr2));
7675 return (*((int *)ptr1) == *((int *)ptr2));
7678 return (*((char *)ptr1) == *((char *)ptr2));
7682 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7687 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7692 return (p1 == p2 || strequal(p1, p2));
7700 /***************************************************************************
7701 Initialize any local varients in the sDefault table.
7702 ***************************************************************************/
7704 void init_locals(void)
7709 /***************************************************************************
7710 Process a new section (service). At this stage all sections are services.
7711 Later we'll have special sections that permit server parameters to be set.
7712 Returns true on success, false on failure.
7713 ***************************************************************************/
7715 static bool do_section(const char *pszSectionName, void *userdata)
7718 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7719 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7722 /* if we were in a global section then do the local inits */
7723 if (bInGlobalSection && !isglobal)
7726 /* if we've just struck a global section, note the fact. */
7727 bInGlobalSection = isglobal;
7729 /* check for multiple global sections */
7730 if (bInGlobalSection) {
7731 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7735 if (!bInGlobalSection && bGlobalOnly)
7738 /* if we have a current service, tidy it up before moving on */
7741 if (iServiceIndex >= 0)
7742 bRetval = service_ok(iServiceIndex);
7744 /* if all is still well, move to the next record in the services array */
7746 /* We put this here to avoid an odd message order if messages are */
7747 /* issued by the post-processing of a previous section. */
7748 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7750 iServiceIndex = add_a_service(&sDefault, pszSectionName);
7751 if (iServiceIndex < 0) {
7752 DEBUG(0, ("Failed to add a new service\n"));
7755 /* Clean all parametric options for service */
7756 /* They will be added during parsing again */
7757 free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
7764 /***************************************************************************
7765 Determine if a partcular base parameter is currentl set to the default value.
7766 ***************************************************************************/
7768 static bool is_default(int i)
7770 if (!defaults_saved)
7772 switch (parm_table[i].type) {
7775 return str_list_equal((const char **)parm_table[i].def.lvalue,
7776 *(const char ***)lp_parm_ptr(NULL,
7780 return strequal(parm_table[i].def.svalue,
7781 *(char **)lp_parm_ptr(NULL,
7785 return parm_table[i].def.bvalue ==
7786 *(bool *)lp_parm_ptr(NULL,
7789 return parm_table[i].def.cvalue ==
7790 *(char *)lp_parm_ptr(NULL,
7796 return parm_table[i].def.ivalue ==
7797 *(int *)lp_parm_ptr(NULL,
7805 /***************************************************************************
7806 Display the contents of the global structure.
7807 ***************************************************************************/
7809 static void dump_globals(FILE *f)
7812 struct parmlist_entry *data;
7814 fprintf(f, "[global]\n");
7816 for (i = 0; parm_table[i].label; i++)
7817 if (parm_table[i].p_class == P_GLOBAL &&
7818 !(parm_table[i].flags & FLAG_META) &&
7819 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
7820 if (defaults_saved && is_default(i))
7822 fprintf(f, "\t%s = ", parm_table[i].label);
7823 print_parameter(&parm_table[i], lp_parm_ptr(NULL,
7828 if (Globals.param_opt != NULL) {
7829 data = Globals.param_opt;
7831 fprintf(f, "\t%s = %s\n", data->key, data->value);
7838 /***************************************************************************
7839 Return true if a local parameter is currently set to the global default.
7840 ***************************************************************************/
7842 bool lp_is_default(int snum, struct parm_struct *parm)
7844 return equal_parameter(parm->type,
7845 lp_parm_ptr(ServicePtrs[snum], parm),
7846 lp_parm_ptr(NULL, parm));
7849 /***************************************************************************
7850 Display the contents of a single services record.
7851 ***************************************************************************/
7853 static void dump_a_service(struct loadparm_service *pService, FILE * f)
7856 struct parmlist_entry *data;
7858 if (pService != &sDefault)
7859 fprintf(f, "[%s]\n", pService->szService);
7861 for (i = 0; parm_table[i].label; i++) {
7863 if (parm_table[i].p_class == P_LOCAL &&
7864 !(parm_table[i].flags & FLAG_META) &&
7865 (*parm_table[i].label != '-') &&
7866 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7868 if (pService == &sDefault) {
7869 if (defaults_saved && is_default(i))
7872 if (equal_parameter(parm_table[i].type,
7873 lp_parm_ptr(pService, &parm_table[i]),
7874 lp_parm_ptr(NULL, &parm_table[i])))
7878 fprintf(f, "\t%s = ", parm_table[i].label);
7879 print_parameter(&parm_table[i],
7880 lp_parm_ptr(pService, &parm_table[i]),
7886 if (pService->param_opt != NULL) {
7887 data = pService->param_opt;
7889 fprintf(f, "\t%s = %s\n", data->key, data->value);
7895 /***************************************************************************
7896 Display the contents of a parameter of a single services record.
7897 ***************************************************************************/
7899 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7902 bool result = false;
7905 fstring local_parm_name;
7907 const char *parm_opt_value;
7909 /* check for parametrical option */
7910 fstrcpy( local_parm_name, parm_name);
7911 parm_opt = strchr( local_parm_name, ':');
7916 if (strlen(parm_opt)) {
7917 parm_opt_value = lp_parm_const_string( snum,
7918 local_parm_name, parm_opt, NULL);
7919 if (parm_opt_value) {
7920 printf( "%s\n", parm_opt_value);
7927 /* check for a key and print the value */
7934 for (i = 0; parm_table[i].label; i++) {
7935 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7936 !(parm_table[i].flags & FLAG_META) &&
7937 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7938 (*parm_table[i].label != '-') &&
7939 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7944 ptr = lp_parm_ptr(NULL,
7947 ptr = lp_parm_ptr(ServicePtrs[snum],
7951 print_parameter(&parm_table[i],
7962 /***************************************************************************
7963 Return info about the requested parameter (given as a string).
7964 Return NULL when the string is not a valid parameter name.
7965 ***************************************************************************/
7967 struct parm_struct *lp_get_parameter(const char *param_name)
7969 int num = map_parameter(param_name);
7975 return &parm_table[num];
7978 /***************************************************************************
7979 Return info about the next parameter in a service.
7980 snum==GLOBAL_SECTION_SNUM gives the globals.
7981 Return NULL when out of parameters.
7982 ***************************************************************************/
7984 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
7987 /* do the globals */
7988 for (; parm_table[*i].label; (*i)++) {
7989 if (parm_table[*i].p_class == P_SEPARATOR)
7990 return &parm_table[(*i)++];
7992 if ((*parm_table[*i].label == '-'))
7996 && (parm_table[*i].offset ==
7997 parm_table[(*i) - 1].offset)
7998 && (parm_table[*i].p_class ==
7999 parm_table[(*i) - 1].p_class))
8002 if (is_default(*i) && !allparameters)
8005 return &parm_table[(*i)++];
8008 struct loadparm_service *pService = ServicePtrs[snum];
8010 for (; parm_table[*i].label; (*i)++) {
8011 if (parm_table[*i].p_class == P_SEPARATOR)
8012 return &parm_table[(*i)++];
8014 if (parm_table[*i].p_class == P_LOCAL &&
8015 (*parm_table[*i].label != '-') &&
8017 (parm_table[*i].offset !=
8018 parm_table[(*i) - 1].offset)))
8020 if (allparameters ||
8021 !equal_parameter(parm_table[*i].type,
8022 lp_parm_ptr(pService,
8027 return &parm_table[(*i)++];
8038 /***************************************************************************
8039 Display the contents of a single copy structure.
8040 ***************************************************************************/
8041 static void dump_copy_map(bool *pcopymap)
8047 printf("\n\tNon-Copied parameters:\n");
8049 for (i = 0; parm_table[i].label; i++)
8050 if (parm_table[i].p_class == P_LOCAL &&
8051 parm_table[i].ptr && !pcopymap[i] &&
8052 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8054 printf("\t\t%s\n", parm_table[i].label);
8059 /***************************************************************************
8060 Return TRUE if the passed service number is within range.
8061 ***************************************************************************/
8063 bool lp_snum_ok(int iService)
8065 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8068 /***************************************************************************
8069 Auto-load some home services.
8070 ***************************************************************************/
8072 static void lp_add_auto_services(char *str)
8082 s = SMB_STRDUP(str);
8086 homes = lp_servicenumber(HOMES_NAME);
8088 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8089 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8092 if (lp_servicenumber(p) >= 0)
8095 home = get_user_home_dir(talloc_tos(), p);
8097 if (home && home[0] && homes >= 0)
8098 lp_add_home(p, homes, p, home);
8105 /***************************************************************************
8106 Auto-load one printer.
8107 ***************************************************************************/
8109 void lp_add_one_printer(const char *name, const char *comment,
8110 const char *location, void *pdata)
8112 int printers = lp_servicenumber(PRINTERS_NAME);
8115 if (lp_servicenumber(name) < 0) {
8116 lp_add_printer(name, printers);
8117 if ((i = lp_servicenumber(name)) >= 0) {
8118 string_set(&ServicePtrs[i]->comment, comment);
8119 ServicePtrs[i]->autoloaded = true;
8124 /***************************************************************************
8125 Have we loaded a services file yet?
8126 ***************************************************************************/
8128 bool lp_loaded(void)
8133 /***************************************************************************
8134 Unload unused services.
8135 ***************************************************************************/
8137 void lp_killunused(struct smbd_server_connection *sconn,
8138 bool (*snumused) (struct smbd_server_connection *, int))
8141 for (i = 0; i < iNumServices; i++) {
8145 /* don't kill autoloaded or usershare services */
8146 if ( ServicePtrs[i]->autoloaded ||
8147 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8151 if (!snumused || !snumused(sconn, i)) {
8152 free_service_byindex(i);
8158 * Kill all except autoloaded and usershare services - convenience wrapper
8160 void lp_kill_all_services(void)
8162 lp_killunused(NULL, NULL);
8165 /***************************************************************************
8167 ***************************************************************************/
8169 void lp_killservice(int iServiceIn)
8171 if (VALID(iServiceIn)) {
8172 free_service_byindex(iServiceIn);
8176 /***************************************************************************
8177 Save the curent values of all global and sDefault parameters into the
8178 defaults union. This allows swat and testparm to show only the
8179 changed (ie. non-default) parameters.
8180 ***************************************************************************/
8182 static void lp_save_defaults(void)
8185 for (i = 0; parm_table[i].label; i++) {
8186 if (i > 0 && parm_table[i].offset == parm_table[i - 1].offset
8187 && parm_table[i].p_class == parm_table[i - 1].p_class)
8189 switch (parm_table[i].type) {
8192 parm_table[i].def.lvalue = str_list_copy(
8193 NULL, *(const char ***)lp_parm_ptr(NULL, &parm_table[i]));
8197 parm_table[i].def.svalue = SMB_STRDUP(*(char **)lp_parm_ptr(NULL, &parm_table[i]));
8201 parm_table[i].def.bvalue =
8202 *(bool *)lp_parm_ptr(NULL, &parm_table[i]);
8205 parm_table[i].def.cvalue =
8206 *(char *)lp_parm_ptr(NULL, &parm_table[i]);
8212 parm_table[i].def.ivalue =
8213 *(int *)lp_parm_ptr(NULL, &parm_table[i]);
8219 defaults_saved = true;
8222 /***********************************************************
8223 If we should send plaintext/LANMAN passwords in the clinet
8224 ************************************************************/
8226 static void set_allowed_client_auth(void)
8228 if (Globals.bClientNTLMv2Auth) {
8229 Globals.bClientLanManAuth = false;
8231 if (!Globals.bClientLanManAuth) {
8232 Globals.bClientPlaintextAuth = false;
8236 /***************************************************************************
8238 The following code allows smbd to read a user defined share file.
8239 Yes, this is my intent. Yes, I'm comfortable with that...
8241 THE FOLLOWING IS SECURITY CRITICAL CODE.
8243 It washes your clothes, it cleans your house, it guards you while you sleep...
8244 Do not f%^k with it....
8245 ***************************************************************************/
8247 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8249 /***************************************************************************
8250 Check allowed stat state of a usershare file.
8251 Ensure we print out who is dicking with us so the admin can
8252 get their sorry ass fired.
8253 ***************************************************************************/
8255 static bool check_usershare_stat(const char *fname,
8256 const SMB_STRUCT_STAT *psbuf)
8258 if (!S_ISREG(psbuf->st_ex_mode)) {
8259 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8260 "not a regular file\n",
8261 fname, (unsigned int)psbuf->st_ex_uid ));
8265 /* Ensure this doesn't have the other write bit set. */
8266 if (psbuf->st_ex_mode & S_IWOTH) {
8267 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8268 "public write. Refusing to allow as a usershare file.\n",
8269 fname, (unsigned int)psbuf->st_ex_uid ));
8273 /* Should be 10k or less. */
8274 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8275 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8276 "too large (%u) to be a user share file.\n",
8277 fname, (unsigned int)psbuf->st_ex_uid,
8278 (unsigned int)psbuf->st_ex_size ));
8285 /***************************************************************************
8286 Parse the contents of a usershare file.
8287 ***************************************************************************/
8289 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8290 SMB_STRUCT_STAT *psbuf,
8291 const char *servicename,
8295 char **pp_sharepath,
8297 char **pp_cp_servicename,
8298 struct security_descriptor **ppsd,
8301 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8302 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8305 SMB_STRUCT_STAT sbuf;
8306 char *sharepath = NULL;
8307 char *comment = NULL;
8309 *pp_sharepath = NULL;
8312 *pallow_guest = false;
8315 return USERSHARE_MALFORMED_FILE;
8318 if (strcmp(lines[0], "#VERSION 1") == 0) {
8320 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8323 return USERSHARE_MALFORMED_FILE;
8326 return USERSHARE_BAD_VERSION;
8329 if (strncmp(lines[1], "path=", 5) != 0) {
8330 return USERSHARE_MALFORMED_PATH;
8333 sharepath = talloc_strdup(ctx, &lines[1][5]);
8335 return USERSHARE_POSIX_ERR;
8337 trim_string(sharepath, " ", " ");
8339 if (strncmp(lines[2], "comment=", 8) != 0) {
8340 return USERSHARE_MALFORMED_COMMENT_DEF;
8343 comment = talloc_strdup(ctx, &lines[2][8]);
8345 return USERSHARE_POSIX_ERR;
8347 trim_string(comment, " ", " ");
8348 trim_char(comment, '"', '"');
8350 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8351 return USERSHARE_MALFORMED_ACL_DEF;
8354 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8355 return USERSHARE_ACL_ERR;
8359 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8360 return USERSHARE_MALFORMED_ACL_DEF;
8362 if (lines[4][9] == 'y') {
8363 *pallow_guest = true;
8366 /* Backwards compatible extension to file version #2. */
8368 if (strncmp(lines[5], "sharename=", 10) != 0) {
8369 return USERSHARE_MALFORMED_SHARENAME_DEF;
8371 if (!strequal(&lines[5][10], servicename)) {
8372 return USERSHARE_BAD_SHARENAME;
8374 *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
8375 if (!*pp_cp_servicename) {
8376 return USERSHARE_POSIX_ERR;
8381 if (*pp_cp_servicename == NULL) {
8382 *pp_cp_servicename = talloc_strdup(ctx, servicename);
8383 if (!*pp_cp_servicename) {
8384 return USERSHARE_POSIX_ERR;
8388 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8389 /* Path didn't change, no checks needed. */
8390 *pp_sharepath = sharepath;
8391 *pp_comment = comment;
8392 return USERSHARE_OK;
8395 /* The path *must* be absolute. */
8396 if (sharepath[0] != '/') {
8397 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8398 servicename, sharepath));
8399 return USERSHARE_PATH_NOT_ABSOLUTE;
8402 /* If there is a usershare prefix deny list ensure one of these paths
8403 doesn't match the start of the user given path. */
8404 if (prefixdenylist) {
8406 for ( i=0; prefixdenylist[i]; i++ ) {
8407 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8408 servicename, i, prefixdenylist[i], sharepath ));
8409 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8410 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8411 "usershare prefix deny list entries.\n",
8412 servicename, sharepath));
8413 return USERSHARE_PATH_IS_DENIED;
8418 /* If there is a usershare prefix allow list ensure one of these paths
8419 does match the start of the user given path. */
8421 if (prefixallowlist) {
8423 for ( i=0; prefixallowlist[i]; i++ ) {
8424 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8425 servicename, i, prefixallowlist[i], sharepath ));
8426 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8430 if (prefixallowlist[i] == NULL) {
8431 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8432 "usershare prefix allow list entries.\n",
8433 servicename, sharepath));
8434 return USERSHARE_PATH_NOT_ALLOWED;
8438 /* Ensure this is pointing to a directory. */
8439 dp = sys_opendir(sharepath);
8442 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8443 servicename, sharepath));
8444 return USERSHARE_PATH_NOT_DIRECTORY;
8447 /* Ensure the owner of the usershare file has permission to share
8450 if (sys_stat(sharepath, &sbuf, false) == -1) {
8451 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8452 servicename, sharepath, strerror(errno) ));
8454 return USERSHARE_POSIX_ERR;
8459 if (!S_ISDIR(sbuf.st_ex_mode)) {
8460 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8461 servicename, sharepath ));
8462 return USERSHARE_PATH_NOT_DIRECTORY;
8465 /* Check if sharing is restricted to owner-only. */
8466 /* psbuf is the stat of the usershare definition file,
8467 sbuf is the stat of the target directory to be shared. */
8469 if (lp_usershare_owner_only()) {
8470 /* root can share anything. */
8471 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8472 return USERSHARE_PATH_NOT_ALLOWED;
8476 *pp_sharepath = sharepath;
8477 *pp_comment = comment;
8478 return USERSHARE_OK;
8481 /***************************************************************************
8482 Deal with a usershare file.
8485 -1 - Bad name, invalid contents.
8486 - service name already existed and not a usershare, problem
8487 with permissions to share directory etc.
8488 ***************************************************************************/
8490 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8492 SMB_STRUCT_STAT sbuf;
8493 SMB_STRUCT_STAT lsbuf;
8495 char *sharepath = NULL;
8496 char *comment = NULL;
8497 char *cp_service_name = NULL;
8498 char **lines = NULL;
8502 TALLOC_CTX *ctx = talloc_stackframe();
8503 struct security_descriptor *psd = NULL;
8504 bool guest_ok = false;
8505 char *canon_name = NULL;
8506 bool added_service = false;
8509 /* Ensure share name doesn't contain invalid characters. */
8510 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8511 DEBUG(0,("process_usershare_file: share name %s contains "
8512 "invalid characters (any of %s)\n",
8513 file_name, INVALID_SHARENAME_CHARS ));
8517 canon_name = canonicalize_servicename(ctx, file_name);
8522 fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
8527 /* Minimize the race condition by doing an lstat before we
8528 open and fstat. Ensure this isn't a symlink link. */
8530 if (sys_lstat(fname, &lsbuf, false) != 0) {
8531 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8532 fname, strerror(errno) ));
8536 /* This must be a regular file, not a symlink, directory or
8537 other strange filetype. */
8538 if (!check_usershare_stat(fname, &lsbuf)) {
8543 TDB_DATA data = dbwrap_fetch_bystring(
8544 ServiceHash, canon_name, canon_name);
8548 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
8549 iService = *(int *)data.dptr;
8553 if (iService != -1 &&
8554 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8555 &lsbuf.st_ex_mtime) == 0) {
8556 /* Nothing changed - Mark valid and return. */
8557 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8559 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8564 /* Try and open the file read only - no symlinks allowed. */
8566 fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8568 fd = sys_open(fname, O_RDONLY, 0);
8572 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8573 fname, strerror(errno) ));
8577 /* Now fstat to be *SURE* it's a regular file. */
8578 if (sys_fstat(fd, &sbuf, false) != 0) {
8580 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8581 fname, strerror(errno) ));
8585 /* Is it the same dev/inode as was lstated ? */
8586 if (lsbuf.st_ex_dev != sbuf.st_ex_dev || lsbuf.st_ex_ino != sbuf.st_ex_ino) {
8588 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8589 "Symlink spoofing going on ?\n", fname ));
8593 /* This must be a regular file, not a symlink, directory or
8594 other strange filetype. */
8595 if (!check_usershare_stat(fname, &sbuf)) {
8599 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8602 if (lines == NULL) {
8603 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8604 fname, (unsigned int)sbuf.st_ex_uid ));
8608 if (parse_usershare_file(ctx, &sbuf, file_name,
8609 iService, lines, numlines, &sharepath,
8610 &comment, &cp_service_name,
8611 &psd, &guest_ok) != USERSHARE_OK) {
8615 /* Everything ok - add the service possibly using a template. */
8617 const struct loadparm_service *sp = &sDefault;
8618 if (snum_template != -1) {
8619 sp = ServicePtrs[snum_template];
8622 if ((iService = add_a_service(sp, cp_service_name)) < 0) {
8623 DEBUG(0, ("process_usershare_file: Failed to add "
8624 "new service %s\n", cp_service_name));
8628 added_service = true;
8630 /* Read only is controlled by usershare ACL below. */
8631 ServicePtrs[iService]->bRead_only = false;
8634 /* Write the ACL of the new/modified share. */
8635 if (!set_share_security(canon_name, psd)) {
8636 DEBUG(0, ("process_usershare_file: Failed to set share "
8637 "security for user share %s\n",
8642 /* If from a template it may be marked invalid. */
8643 ServicePtrs[iService]->valid = true;
8645 /* Set the service as a valid usershare. */
8646 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8648 /* Set guest access. */
8649 if (lp_usershare_allow_guests()) {
8650 ServicePtrs[iService]->bGuest_ok = guest_ok;
8653 /* And note when it was loaded. */
8654 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8655 string_set(&ServicePtrs[iService]->szPath, sharepath);
8656 string_set(&ServicePtrs[iService]->comment, comment);
8662 if (ret == -1 && iService != -1 && added_service) {
8663 lp_remove_service(iService);
8671 /***************************************************************************
8672 Checks if a usershare entry has been modified since last load.
8673 ***************************************************************************/
8675 static bool usershare_exists(int iService, struct timespec *last_mod)
8677 SMB_STRUCT_STAT lsbuf;
8678 const char *usersharepath = Globals.szUsersharePath;
8681 if (asprintf(&fname, "%s/%s",
8683 ServicePtrs[iService]->szService) < 0) {
8687 if (sys_lstat(fname, &lsbuf, false) != 0) {
8692 if (!S_ISREG(lsbuf.st_ex_mode)) {
8698 *last_mod = lsbuf.st_ex_mtime;
8702 /***************************************************************************
8703 Load a usershare service by name. Returns a valid servicenumber or -1.
8704 ***************************************************************************/
8706 int load_usershare_service(const char *servicename)
8708 SMB_STRUCT_STAT sbuf;
8709 const char *usersharepath = Globals.szUsersharePath;
8710 int max_user_shares = Globals.iUsershareMaxShares;
8711 int snum_template = -1;
8713 if (*usersharepath == 0 || max_user_shares == 0) {
8717 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8718 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8719 usersharepath, strerror(errno) ));
8723 if (!S_ISDIR(sbuf.st_ex_mode)) {
8724 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8730 * This directory must be owned by root, and have the 't' bit set.
8731 * It also must not be writable by "other".
8735 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8737 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8739 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8740 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8745 /* Ensure the template share exists if it's set. */
8746 if (Globals.szUsershareTemplateShare[0]) {
8747 /* We can't use lp_servicenumber here as we are recommending that
8748 template shares have -valid=false set. */
8749 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8750 if (ServicePtrs[snum_template]->szService &&
8751 strequal(ServicePtrs[snum_template]->szService,
8752 Globals.szUsershareTemplateShare)) {
8757 if (snum_template == -1) {
8758 DEBUG(0,("load_usershare_service: usershare template share %s "
8759 "does not exist.\n",
8760 Globals.szUsershareTemplateShare ));
8765 return process_usershare_file(usersharepath, servicename, snum_template);
8768 /***************************************************************************
8769 Load all user defined shares from the user share directory.
8770 We only do this if we're enumerating the share list.
8771 This is the function that can delete usershares that have
8773 ***************************************************************************/
8775 int load_usershare_shares(struct smbd_server_connection *sconn)
8778 SMB_STRUCT_STAT sbuf;
8779 SMB_STRUCT_DIRENT *de;
8780 int num_usershares = 0;
8781 int max_user_shares = Globals.iUsershareMaxShares;
8782 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8783 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8784 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8786 int snum_template = -1;
8787 const char *usersharepath = Globals.szUsersharePath;
8788 int ret = lp_numservices();
8790 if (max_user_shares == 0 || *usersharepath == '\0') {
8791 return lp_numservices();
8794 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8795 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8796 usersharepath, strerror(errno) ));
8801 * This directory must be owned by root, and have the 't' bit set.
8802 * It also must not be writable by "other".
8806 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8808 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8810 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8811 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8816 /* Ensure the template share exists if it's set. */
8817 if (Globals.szUsershareTemplateShare[0]) {
8818 /* We can't use lp_servicenumber here as we are recommending that
8819 template shares have -valid=false set. */
8820 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8821 if (ServicePtrs[snum_template]->szService &&
8822 strequal(ServicePtrs[snum_template]->szService,
8823 Globals.szUsershareTemplateShare)) {
8828 if (snum_template == -1) {
8829 DEBUG(0,("load_usershare_shares: usershare template share %s "
8830 "does not exist.\n",
8831 Globals.szUsershareTemplateShare ));
8836 /* Mark all existing usershares as pending delete. */
8837 for (iService = iNumServices - 1; iService >= 0; iService--) {
8838 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8839 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8843 dp = sys_opendir(usersharepath);
8845 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8846 usersharepath, strerror(errno) ));
8850 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8851 (de = sys_readdir(dp));
8852 num_dir_entries++ ) {
8854 const char *n = de->d_name;
8856 /* Ignore . and .. */
8858 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8864 /* Temporary file used when creating a share. */
8865 num_tmp_dir_entries++;
8868 /* Allow 20% tmp entries. */
8869 if (num_tmp_dir_entries > allowed_tmp_entries) {
8870 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8871 "in directory %s\n",
8872 num_tmp_dir_entries, usersharepath));
8876 r = process_usershare_file(usersharepath, n, snum_template);
8878 /* Update the services count. */
8880 if (num_usershares >= max_user_shares) {
8881 DEBUG(0,("load_usershare_shares: max user shares reached "
8882 "on file %s in directory %s\n",
8883 n, usersharepath ));
8886 } else if (r == -1) {
8887 num_bad_dir_entries++;
8890 /* Allow 20% bad entries. */
8891 if (num_bad_dir_entries > allowed_bad_entries) {
8892 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8893 "in directory %s\n",
8894 num_bad_dir_entries, usersharepath));
8898 /* Allow 20% bad entries. */
8899 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
8900 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8901 "in directory %s\n",
8902 num_dir_entries, usersharepath));
8909 /* Sweep through and delete any non-refreshed usershares that are
8910 not currently in use. */
8911 for (iService = iNumServices - 1; iService >= 0; iService--) {
8912 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
8913 if (conn_snum_used(sconn, iService)) {
8916 /* Remove from the share ACL db. */
8917 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8918 lp_servicename(iService) ));
8919 delete_share_security(lp_servicename(iService));
8920 free_service_byindex(iService);
8924 return lp_numservices();
8927 /********************************************************
8928 Destroy global resources allocated in this file
8929 ********************************************************/
8931 void gfree_loadparm(void)
8937 /* Free resources allocated to services */
8939 for ( i = 0; i < iNumServices; i++ ) {
8941 free_service_byindex(i);
8945 SAFE_FREE( ServicePtrs );
8948 /* Now release all resources allocated to global
8949 parameters and the default service */
8951 free_global_parameters();
8955 /***************************************************************************
8956 Allow client apps to specify that they are a client
8957 ***************************************************************************/
8958 static void lp_set_in_client(bool b)
8964 /***************************************************************************
8965 Determine if we're running in a client app
8966 ***************************************************************************/
8967 static bool lp_is_in_client(void)
8972 /***************************************************************************
8973 Load the services array from the services file. Return true on success,
8975 ***************************************************************************/
8977 static bool lp_load_ex(const char *pszFname,
8981 bool initialize_globals,
8982 bool allow_include_registry,
8983 bool load_all_shares)
8990 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
8992 bInGlobalSection = true;
8993 bGlobalOnly = global_only;
8994 bAllowIncludeRegistry = allow_include_registry;
8996 init_globals(initialize_globals);
9000 if (save_defaults) {
9005 if (!initialize_globals) {
9006 free_param_opts(&Globals.param_opt);
9007 apply_lp_set_cmdline();
9010 lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
9012 /* We get sections first, so have to start 'behind' to make up */
9015 if (lp_config_backend_is_file()) {
9016 n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
9017 current_user_info.domain,
9020 smb_panic("lp_load_ex: out of memory");
9023 add_to_file_list(pszFname, n2);
9025 bRetval = pm_process(n2, do_section, do_parameter, NULL);
9028 /* finish up the last section */
9029 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
9031 if (iServiceIndex >= 0) {
9032 bRetval = service_ok(iServiceIndex);
9036 if (lp_config_backend_is_registry()) {
9037 /* config backend changed to registry in config file */
9039 * We need to use this extra global variable here to
9040 * survive restart: init_globals uses this as a default
9041 * for ConfigBackend. Otherwise, init_globals would
9042 * send us into an endless loop here.
9044 config_backend = CONFIG_BACKEND_REGISTRY;
9046 DEBUG(1, ("lp_load_ex: changing to config backend "
9049 lp_kill_all_services();
9050 return lp_load_ex(pszFname, global_only, save_defaults,
9051 add_ipc, initialize_globals,
9052 allow_include_registry,
9055 } else if (lp_config_backend_is_registry()) {
9056 bRetval = process_registry_globals();
9058 DEBUG(0, ("Illegal config backend given: %d\n",
9059 lp_config_backend()));
9063 if (bRetval && lp_registry_shares()) {
9064 if (load_all_shares) {
9065 bRetval = process_registry_shares();
9067 bRetval = reload_registry_shares();
9071 lp_add_auto_services(lp_auto_services());
9074 /* When 'restrict anonymous = 2' guest connections to ipc$
9076 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9077 if ( lp_enable_asu_support() ) {
9078 lp_add_ipc("ADMIN$", false);
9083 set_allowed_client_auth();
9085 if (lp_security() == SEC_SHARE) {
9086 DEBUG(1, ("WARNING: The security=share option is deprecated\n"));
9087 } else if (lp_security() == SEC_SERVER) {
9088 DEBUG(1, ("WARNING: The security=server option is deprecated\n"));
9091 if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) {
9092 DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
9093 lp_passwordserver()));
9098 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9099 /* if bWINSsupport is true and we are in the client */
9100 if (lp_is_in_client() && Globals.bWINSsupport) {
9101 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9106 fault_configure(smb_panic_s3);
9108 bAllowIncludeRegistry = true;
9113 bool lp_load(const char *pszFname,
9117 bool initialize_globals)
9119 return lp_load_ex(pszFname,
9124 true, /* allow_include_registry */
9125 false); /* load_all_shares*/
9128 bool lp_load_initial_only(const char *pszFname)
9130 return lp_load_ex(pszFname,
9131 true, /* global only */
9132 false, /* save_defaults */
9133 false, /* add_ipc */
9134 true, /* initialize_globals */
9135 false, /* allow_include_registry */
9136 false); /* load_all_shares*/
9140 * most common lp_load wrapper, loading only the globals
9142 bool lp_load_global(const char *file_name)
9144 return lp_load_ex(file_name,
9145 true, /* global_only */
9146 false, /* save_defaults */
9147 false, /* add_ipc */
9148 true, /* initialize_globals */
9149 true, /* allow_include_registry */
9150 false); /* load_all_shares*/
9154 * lp_load wrapper, especially for clients
9156 bool lp_load_client(const char *file_name)
9158 lp_set_in_client(true);
9160 return lp_load_global(file_name);
9164 * lp_load wrapper, loading only globals, but intended
9165 * for subsequent calls, not reinitializing the globals
9168 bool lp_load_global_no_reinit(const char *file_name)
9170 return lp_load_ex(file_name,
9171 true, /* global_only */
9172 false, /* save_defaults */
9173 false, /* add_ipc */
9174 false, /* initialize_globals */
9175 true, /* allow_include_registry */
9176 false); /* load_all_shares*/
9180 * lp_load wrapper, especially for clients, no reinitialization
9182 bool lp_load_client_no_reinit(const char *file_name)
9184 lp_set_in_client(true);
9186 return lp_load_global_no_reinit(file_name);
9189 bool lp_load_with_registry_shares(const char *pszFname,
9193 bool initialize_globals)
9195 return lp_load_ex(pszFname,
9200 true, /* allow_include_registry */
9201 true); /* load_all_shares*/
9204 /***************************************************************************
9205 Return the max number of services.
9206 ***************************************************************************/
9208 int lp_numservices(void)
9210 return (iNumServices);
9213 /***************************************************************************
9214 Display the contents of the services array in human-readable form.
9215 ***************************************************************************/
9217 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9222 defaults_saved = false;
9226 dump_a_service(&sDefault, f);
9228 for (iService = 0; iService < maxtoprint; iService++) {
9230 lp_dump_one(f, show_defaults, iService);
9234 /***************************************************************************
9235 Display the contents of one service in human-readable form.
9236 ***************************************************************************/
9238 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9241 if (ServicePtrs[snum]->szService[0] == '\0')
9243 dump_a_service(ServicePtrs[snum], f);
9247 /***************************************************************************
9248 Return the number of the service with the given name, or -1 if it doesn't
9249 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9250 getservicebyname()! This works ONLY if all services have been loaded, and
9251 does not copy the found service.
9252 ***************************************************************************/
9254 int lp_servicenumber(const char *pszServiceName)
9257 fstring serviceName;
9259 if (!pszServiceName) {
9260 return GLOBAL_SECTION_SNUM;
9263 for (iService = iNumServices - 1; iService >= 0; iService--) {
9264 if (VALID(iService) && ServicePtrs[iService]->szService) {
9266 * The substitution here is used to support %U is
9269 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9270 standard_sub_basic(get_current_username(),
9271 current_user_info.domain,
9272 serviceName,sizeof(serviceName));
9273 if (strequal(serviceName, pszServiceName)) {
9279 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9280 struct timespec last_mod;
9282 if (!usershare_exists(iService, &last_mod)) {
9283 /* Remove the share security tdb entry for it. */
9284 delete_share_security(lp_servicename(iService));
9285 /* Remove it from the array. */
9286 free_service_byindex(iService);
9287 /* Doesn't exist anymore. */
9288 return GLOBAL_SECTION_SNUM;
9291 /* Has it been modified ? If so delete and reload. */
9292 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9294 /* Remove it from the array. */
9295 free_service_byindex(iService);
9296 /* and now reload it. */
9297 iService = load_usershare_service(pszServiceName);
9302 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9303 return GLOBAL_SECTION_SNUM;
9309 bool share_defined(const char *service_name)
9311 return (lp_servicenumber(service_name) != -1);
9314 /*******************************************************************
9315 A useful volume label function.
9316 ********************************************************************/
9318 const char *volume_label(int snum)
9321 const char *label = lp_volume(snum);
9323 label = lp_servicename(snum);
9326 /* This returns a 33 byte guarenteed null terminated string. */
9327 ret = talloc_strndup(talloc_tos(), label, 32);
9334 /*******************************************************************
9335 Get the default server type we will announce as via nmbd.
9336 ********************************************************************/
9338 int lp_default_server_announce(void)
9340 int default_server_announce = 0;
9341 default_server_announce |= SV_TYPE_WORKSTATION;
9342 default_server_announce |= SV_TYPE_SERVER;
9343 default_server_announce |= SV_TYPE_SERVER_UNIX;
9345 /* note that the flag should be set only if we have a
9346 printer service but nmbd doesn't actually load the
9347 services so we can't tell --jerry */
9349 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9351 default_server_announce |= SV_TYPE_SERVER_NT;
9352 default_server_announce |= SV_TYPE_NT;
9354 switch (lp_server_role()) {
9355 case ROLE_DOMAIN_MEMBER:
9356 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9358 case ROLE_DOMAIN_PDC:
9359 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9361 case ROLE_DOMAIN_BDC:
9362 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9364 case ROLE_STANDALONE:
9368 if (lp_time_server())
9369 default_server_announce |= SV_TYPE_TIME_SOURCE;
9371 if (lp_host_msdfs())
9372 default_server_announce |= SV_TYPE_DFS_SERVER;
9374 return default_server_announce;
9377 /***********************************************************
9378 If we are PDC then prefer us as DMB
9379 ************************************************************/
9381 bool lp_domain_master(void)
9383 if (Globals.iDomainMaster == Auto)
9384 return (lp_server_role() == ROLE_DOMAIN_PDC);
9386 return (bool)Globals.iDomainMaster;
9389 /***********************************************************
9390 If we are PDC then prefer us as DMB
9391 ************************************************************/
9393 bool lp_domain_master_true_or_auto(void)
9395 if (Globals.iDomainMaster) /* auto or yes */
9401 /***********************************************************
9402 If we are DMB then prefer us as LMB
9403 ************************************************************/
9405 bool lp_preferred_master(void)
9407 if (Globals.iPreferredMaster == Auto)
9408 return (lp_local_master() && lp_domain_master());
9410 return (bool)Globals.iPreferredMaster;
9413 /*******************************************************************
9415 ********************************************************************/
9417 void lp_remove_service(int snum)
9419 ServicePtrs[snum]->valid = false;
9420 invalid_services[num_invalid_services++] = snum;
9423 /*******************************************************************
9425 ********************************************************************/
9427 void lp_copy_service(int snum, const char *new_name)
9429 do_section(new_name, NULL);
9431 snum = lp_servicenumber(new_name);
9433 lp_do_parameter(snum, "copy", lp_servicename(snum));
9438 /***********************************************************
9439 Set the global name resolution order (used in smbclient).
9440 ************************************************************/
9442 void lp_set_name_resolve_order(const char *new_order)
9444 string_set(&Globals.szNameResolveOrder, new_order);
9447 const char *lp_printername(int snum)
9449 const char *ret = lp__printername(snum);
9450 if (ret == NULL || (ret != NULL && *ret == '\0'))
9451 ret = lp_const_servicename(snum);
9457 /***********************************************************
9458 Allow daemons such as winbindd to fix their logfile name.
9459 ************************************************************/
9461 void lp_set_logfile(const char *name)
9463 string_set(&Globals.szLogFile, name);
9464 debug_set_logfile(name);
9467 /*******************************************************************
9468 Return the max print jobs per queue.
9469 ********************************************************************/
9471 int lp_maxprintjobs(int snum)
9473 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9474 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9475 maxjobs = PRINT_MAX_JOBID - 1;
9480 const char *lp_printcapname(void)
9482 if ((Globals.szPrintcapname != NULL) &&
9483 (Globals.szPrintcapname[0] != '\0'))
9484 return Globals.szPrintcapname;
9486 if (sDefault.iPrinting == PRINT_CUPS) {
9494 if (sDefault.iPrinting == PRINT_BSD)
9495 return "/etc/printcap";
9497 return PRINTCAP_NAME;
9500 static uint32 spoolss_state;
9502 bool lp_disable_spoolss( void )
9504 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9505 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9507 return spoolss_state == SVCCTL_STOPPED ? true : false;
9510 void lp_set_spoolss_state( uint32 state )
9512 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9514 spoolss_state = state;
9517 uint32 lp_get_spoolss_state( void )
9519 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9522 /*******************************************************************
9523 Ensure we don't use sendfile if server smb signing is active.
9524 ********************************************************************/
9526 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9528 bool sign_active = false;
9530 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9531 if (get_Protocol() < PROTOCOL_NT1) {
9534 if (signing_state) {
9535 sign_active = smb_signing_is_active(signing_state);
9537 return (lp__use_sendfile(snum) &&
9538 (get_remote_arch() != RA_WIN95) &&
9542 /*******************************************************************
9543 Turn off sendfile if we find the underlying OS doesn't support it.
9544 ********************************************************************/
9546 void set_use_sendfile(int snum, bool val)
9548 if (LP_SNUM_OK(snum))
9549 ServicePtrs[snum]->bUseSendfile = val;
9551 sDefault.bUseSendfile = val;
9554 /*******************************************************************
9555 Turn off storing DOS attributes if this share doesn't support it.
9556 ********************************************************************/
9558 void set_store_dos_attributes(int snum, bool val)
9560 if (!LP_SNUM_OK(snum))
9562 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9565 void lp_set_mangling_method(const char *new_method)
9567 string_set(&Globals.szManglingMethod, new_method);
9570 /*******************************************************************
9571 Global state for POSIX pathname processing.
9572 ********************************************************************/
9574 static bool posix_pathnames;
9576 bool lp_posix_pathnames(void)
9578 return posix_pathnames;
9581 /*******************************************************************
9582 Change everything needed to ensure POSIX pathname processing (currently
9584 ********************************************************************/
9586 void lp_set_posix_pathnames(void)
9588 posix_pathnames = true;
9591 /*******************************************************************
9592 Global state for POSIX lock processing - CIFS unix extensions.
9593 ********************************************************************/
9595 bool posix_default_lock_was_set;
9596 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9598 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9600 if (posix_default_lock_was_set) {
9601 return posix_cifsx_locktype;
9603 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9607 /*******************************************************************
9608 ********************************************************************/
9610 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9612 posix_default_lock_was_set = true;
9613 posix_cifsx_locktype = val;
9616 int lp_min_receive_file_size(void)
9618 if (Globals.iminreceivefile < 0) {
9621 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9624 /*******************************************************************
9625 If socket address is an empty character string, it is necessary to
9626 define it as "0.0.0.0".
9627 ********************************************************************/
9629 const char *lp_socket_address(void)
9631 char *sock_addr = Globals.szSocketAddress;
9633 if (sock_addr[0] == '\0'){
9634 string_set(&Globals.szSocketAddress, "0.0.0.0");
9636 return Globals.szSocketAddress;
9639 /*******************************************************************
9640 Safe wide links checks.
9641 This helper function always verify the validity of wide links,
9642 even after a configuration file reload.
9643 ********************************************************************/
9645 static bool lp_widelinks_internal(int snum)
9647 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9648 sDefault.bWidelinks);
9651 void widelinks_warning(int snum)
9653 if (lp_allow_insecure_widelinks()) {
9657 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9658 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9659 "These parameters are incompatible. "
9660 "Wide links will be disabled for this share.\n",
9661 lp_servicename(snum) ));
9665 bool lp_widelinks(int snum)
9667 /* wide links is always incompatible with unix extensions */
9668 if (lp_unix_extensions()) {
9670 * Unless we have "allow insecure widelinks"
9673 if (!lp_allow_insecure_widelinks()) {
9678 return lp_widelinks_internal(snum);
9681 bool lp_writeraw(void)
9683 if (lp_async_smb_echo_handler()) {
9686 return _lp_writeraw();
9689 bool lp_readraw(void)
9691 if (lp_async_smb_echo_handler()) {
9694 return _lp_readraw();