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 "../libcli/smb/smb_signing.h"
68 #include "dbwrap/dbwrap.h"
69 #include "dbwrap/dbwrap_rbt.h"
70 #include "../lib/util/bitmap.h"
71 #include "../source4/dns_server/dns_update.h"
73 #ifdef HAVE_SYS_SYSCTL_H
74 #include <sys/sysctl.h>
77 #ifdef HAVE_HTTPCONNECTENCRYPT
78 #include <cups/http.h>
81 #ifdef CLUSTER_SUPPORT
82 #include "ctdb_private.h"
87 extern userdom_struct current_user_info;
89 /* the special value for the include parameter
90 * to be interpreted not as a file name but to
91 * trigger loading of the global smb.conf options
93 #ifndef INCLUDE_REGISTRY_NAME
94 #define INCLUDE_REGISTRY_NAME "registry"
97 static bool in_client = false; /* Not in the client by default */
98 static struct smbconf_csn conf_last_csn;
100 #define CONFIG_BACKEND_FILE 0
101 #define CONFIG_BACKEND_REGISTRY 1
103 static int config_backend = CONFIG_BACKEND_FILE;
105 /* some helpful bits */
106 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
107 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
109 #define USERSHARE_VALID 1
110 #define USERSHARE_PENDING_DELETE 2
112 static bool defaults_saved = false;
114 #define LOADPARM_EXTRA_GLOBALS \
115 struct parmlist_entry *param_opt; \
118 int iminreceivefile; \
119 char *szPrintcapname; \
121 int iPreferredMaster; \
123 char *szLdapMachineSuffix; \
124 char *szLdapUserSuffix; \
125 char *szLdapIdmapSuffix; \
126 char *szLdapGroupSuffix; \
129 char *szSocketAddress; \
130 char *szUsershareTemplateShare; \
133 int winbindMaxDomainConnections; \
134 int ismb2_max_credits;
136 #include "param/param_global.h"
138 static struct loadparm_global Globals;
140 /* This is a default service used to prime a services structure */
141 static struct loadparm_service sDefault =
146 .usershare_last_mod = {0, 0},
150 .szInvalidUsers = NULL,
151 .szValidUsers = NULL,
152 .szAdminUsers = NULL,
157 .szRootPreExec = NULL,
158 .szRootPostExec = NULL,
159 .szCupsOptions = NULL,
160 .szPrintcommand = NULL,
161 .szLpqcommand = NULL,
162 .szLprmcommand = NULL,
163 .szLppausecommand = NULL,
164 .szLpresumecommand = NULL,
165 .szQueuepausecommand = NULL,
166 .szQueueresumecommand = NULL,
167 .szPrintername = NULL,
168 .szPrintjobUsername = NULL,
169 .szDontdescend = NULL,
170 .szHostsallow = NULL,
172 .szMagicScript = NULL,
173 .szMagicOutput = NULL,
176 .szVetoOplockFiles = NULL,
182 .printer_admin = NULL,
185 .szVfsObjects = NULL,
186 .szMSDfsProxy = NULL,
187 .szAioWriteBehind = NULL,
190 .iMaxPrintJobs = 1000,
191 .iMaxReportedPrintJobs = 0,
192 .iWriteCacheSize = 0,
193 .iCreate_mask = 0744,
194 .iCreate_force_mode = 0,
195 .iSecurity_mask = 0777,
196 .iSecurity_force_mode = 0,
198 .iDir_force_mode = 0,
199 .iDir_Security_mask = 0777,
200 .iDir_Security_force_mode = 0,
201 .iMaxConnections = 0,
202 .iDefaultCase = CASE_LOWER,
203 .iPrinting = DEFAULT_PRINTING,
204 .iOplockContentionLimit = 2,
207 .iDfreeCacheTime = 0,
208 .bPreexecClose = false,
209 .bRootpreexecClose = false,
210 .iCaseSensitive = Auto,
211 .bCasePreserve = true,
212 .bShortCasePreserve = true,
213 .bHideDotFiles = true,
214 .bHideSpecialFiles = false,
215 .bHideUnReadable = false,
216 .bHideUnWriteableFiles = false,
218 .bAccessBasedShareEnum = false,
222 .bGuest_only = false,
223 .bAdministrative_share = false,
226 .bPrintNotifyBackchannel = true,
227 .bMap_system = false,
228 .bMap_hidden = false,
229 .bMap_archive = true,
230 .bStoreDosAttributes = false,
231 .bDmapiSupport = false,
233 .iStrictLocking = Auto,
234 .bPosixLocking = true,
237 .bKernelOplocks = false,
238 .bLevel2OpLocks = true,
240 .bMangledNames = true,
243 .bSyncAlways = false,
244 .bStrictAllocate = false,
245 .bStrictSync = false,
248 .bDeleteReadonly = false,
249 .bFakeOplocks = false,
250 .bDeleteVetoFiles = false,
251 .bDosFilemode = false,
252 .bDosFiletimes = true,
253 .bDosFiletimeResolution = false,
254 .bFakeDirCreateTimes = false,
255 .bBlockingLocks = true,
256 .bInheritPerms = false,
257 .bInheritACLS = false,
258 .bInheritOwner = false,
260 .bUseClientDriver = false,
261 .bDefaultDevmode = true,
262 .bForcePrintername = false,
263 .bNTAclSupport = true,
264 .bForceUnknownAclUser = false,
265 .bUseSendfile = false,
266 .bProfileAcls = false,
267 .bMap_acl_inherit = false,
270 .bAclCheckPermissions = true,
271 .bAclMapFullControl = true,
272 .bAclGroupControl = false,
273 .bChangeNotify = true,
274 .bKernelChangeNotify = true,
275 .iallocation_roundup_size = SMB_ROUNDUP_ALLOCATION_SIZE,
278 .iMap_readonly = MAP_READONLY_YES,
279 #ifdef BROKEN_DIRECTORY_HANDLING
280 .iDirectoryNameCacheSize = 0,
282 .iDirectoryNameCacheSize = 100,
284 .ismb_encrypt = Auto,
289 /* local variables */
290 static struct loadparm_service **ServicePtrs = NULL;
291 static int iNumServices = 0;
292 static int iServiceIndex = 0;
293 static struct db_context *ServiceHash;
294 static int *invalid_services = NULL;
295 static int num_invalid_services = 0;
296 static bool bInGlobalSection = true;
297 static bool bGlobalOnly = false;
299 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
301 /* prototypes for the special type handlers */
302 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
303 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
304 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
305 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
306 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
307 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
308 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
309 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
310 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
311 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
312 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
313 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
315 static void set_allowed_client_auth(void);
317 static void add_to_file_list(const char *fname, const char *subfname);
318 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
319 static void free_param_opts(struct parmlist_entry **popts);
321 #include "lib/param/param_enums.c"
323 static const struct enum_list enum_printing[] = {
324 {PRINT_SYSV, "sysv"},
326 {PRINT_HPUX, "hpux"},
330 {PRINT_LPRNG, "lprng"},
331 {PRINT_CUPS, "cups"},
332 {PRINT_IPRINT, "iprint"},
334 {PRINT_LPROS2, "os2"},
335 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
336 {PRINT_TEST, "test"},
338 #endif /* DEVELOPER */
342 static const struct enum_list enum_ldap_sasl_wrapping[] = {
344 {ADS_AUTH_SASL_SIGN, "sign"},
345 {ADS_AUTH_SASL_SEAL, "seal"},
349 static const struct enum_list enum_ldap_ssl[] = {
350 {LDAP_SSL_OFF, "no"},
351 {LDAP_SSL_OFF, "off"},
352 {LDAP_SSL_START_TLS, "start tls"},
353 {LDAP_SSL_START_TLS, "start_tls"},
357 /* LDAP Dereferencing Alias types */
358 #define SAMBA_LDAP_DEREF_NEVER 0
359 #define SAMBA_LDAP_DEREF_SEARCHING 1
360 #define SAMBA_LDAP_DEREF_FINDING 2
361 #define SAMBA_LDAP_DEREF_ALWAYS 3
363 static const struct enum_list enum_ldap_deref[] = {
364 {SAMBA_LDAP_DEREF_NEVER, "never"},
365 {SAMBA_LDAP_DEREF_SEARCHING, "searching"},
366 {SAMBA_LDAP_DEREF_FINDING, "finding"},
367 {SAMBA_LDAP_DEREF_ALWAYS, "always"},
371 static const struct enum_list enum_ldap_passwd_sync[] = {
372 {LDAP_PASSWD_SYNC_OFF, "no"},
373 {LDAP_PASSWD_SYNC_OFF, "off"},
374 {LDAP_PASSWD_SYNC_ON, "yes"},
375 {LDAP_PASSWD_SYNC_ON, "on"},
376 {LDAP_PASSWD_SYNC_ONLY, "only"},
380 static const struct enum_list enum_map_readonly[] = {
381 {MAP_READONLY_NO, "no"},
382 {MAP_READONLY_NO, "false"},
383 {MAP_READONLY_NO, "0"},
384 {MAP_READONLY_YES, "yes"},
385 {MAP_READONLY_YES, "true"},
386 {MAP_READONLY_YES, "1"},
387 {MAP_READONLY_PERMISSIONS, "permissions"},
388 {MAP_READONLY_PERMISSIONS, "perms"},
392 static const struct enum_list enum_case[] = {
393 {CASE_LOWER, "lower"},
394 {CASE_UPPER, "upper"},
399 /* ACL compatibility options. */
400 static const struct enum_list enum_acl_compat_vals[] = {
401 { ACL_COMPAT_AUTO, "auto" },
402 { ACL_COMPAT_WINNT, "winnt" },
403 { ACL_COMPAT_WIN2K, "win2k" },
408 Do you want session setups at user level security with a invalid
409 password to be rejected or allowed in as guest? WinNT rejects them
410 but it can be a pain as it means "net view" needs to use a password
412 You have 3 choices in the setting of map_to_guest:
414 "Never" means session setups with an invalid password
415 are rejected. This is the default.
417 "Bad User" means session setups with an invalid password
418 are rejected, unless the username does not exist, in which case it
419 is treated as a guest login
421 "Bad Password" means session setups with an invalid password
422 are treated as a guest login
424 Note that map_to_guest only has an effect in user or server
428 static const struct enum_list enum_map_to_guest[] = {
429 {NEVER_MAP_TO_GUEST, "Never"},
430 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
431 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
432 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
436 /* Config backend options */
438 static const struct enum_list enum_config_backend[] = {
439 {CONFIG_BACKEND_FILE, "file"},
440 {CONFIG_BACKEND_REGISTRY, "registry"},
444 /* ADS kerberos ticket verification options */
446 static const struct enum_list enum_kerberos_method[] = {
447 {KERBEROS_VERIFY_SECRETS, "default"},
448 {KERBEROS_VERIFY_SECRETS, "secrets only"},
449 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
450 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
451 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
455 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
457 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
458 * screen in SWAT. This is used to exclude parameters as well as to squash all
459 * parameters that have been duplicated by pseudonyms.
461 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
462 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
463 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
466 * NOTE2: Handling of duplicated (synonym) parameters:
467 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
468 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
469 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
470 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
473 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
474 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
476 static struct parm_struct parm_table[] = {
477 {N_("Base Options"), P_SEP, P_SEPARATOR},
480 .label = "dos charset",
483 .offset = GLOBAL_VAR(dos_charset),
484 .special = handle_dos_charset,
486 .flags = FLAG_ADVANCED
489 .label = "unix charset",
492 .offset = GLOBAL_VAR(unix_charset),
493 .special = handle_charset,
495 .flags = FLAG_ADVANCED
501 .offset = LOCAL_VAR(comment),
504 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
510 .offset = LOCAL_VAR(szPath),
513 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
516 .label = "directory",
519 .offset = LOCAL_VAR(szPath),
525 .label = "workgroup",
528 .offset = GLOBAL_VAR(szWorkgroup),
531 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
537 .offset = GLOBAL_VAR(szRealm),
538 .special = handle_realm,
540 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
543 .label = "netbios name",
546 .offset = GLOBAL_VAR(szNetbiosName),
549 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
552 .label = "netbios aliases",
555 .offset = GLOBAL_VAR(szNetbiosAliases),
556 .special = handle_netbios_aliases,
558 .flags = FLAG_ADVANCED,
561 .label = "netbios scope",
564 .offset = GLOBAL_VAR(szNetbiosScope),
567 .flags = FLAG_ADVANCED,
570 .label = "server string",
573 .offset = GLOBAL_VAR(szServerString),
576 .flags = FLAG_BASIC | FLAG_ADVANCED,
579 .label = "interfaces",
582 .offset = GLOBAL_VAR(szInterfaces),
585 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
588 .label = "bind interfaces only",
591 .offset = GLOBAL_VAR(bBindInterfacesOnly),
594 .flags = FLAG_ADVANCED | FLAG_WIZARD,
597 .label = "config backend",
600 .offset = GLOBAL_VAR(ConfigBackend),
602 .enum_list = enum_config_backend,
603 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
606 .label = "server role",
609 .offset = GLOBAL_VAR(ServerRole),
611 .enum_list = enum_server_role,
612 .flags = FLAG_BASIC | FLAG_ADVANCED,
615 {N_("Security Options"), P_SEP, P_SEPARATOR},
621 .offset = GLOBAL_VAR(security),
623 .enum_list = enum_security,
624 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
627 .label = "auth methods",
630 .offset = GLOBAL_VAR(AuthMethods),
633 .flags = FLAG_ADVANCED,
636 .label = "encrypt passwords",
639 .offset = GLOBAL_VAR(bEncryptPasswords),
642 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
645 .label = "client schannel",
648 .offset = GLOBAL_VAR(clientSchannel),
650 .enum_list = enum_bool_auto,
651 .flags = FLAG_BASIC | FLAG_ADVANCED,
654 .label = "server schannel",
657 .offset = GLOBAL_VAR(serverSchannel),
659 .enum_list = enum_bool_auto,
660 .flags = FLAG_BASIC | FLAG_ADVANCED,
663 .label = "allow trusted domains",
666 .offset = GLOBAL_VAR(bAllowTrustedDomains),
669 .flags = FLAG_ADVANCED,
672 .label = "map to guest",
675 .offset = GLOBAL_VAR(map_to_guest),
677 .enum_list = enum_map_to_guest,
678 .flags = FLAG_ADVANCED,
681 .label = "null passwords",
684 .offset = GLOBAL_VAR(bNullPasswords),
687 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
690 .label = "obey pam restrictions",
693 .offset = GLOBAL_VAR(bObeyPamRestrictions),
696 .flags = FLAG_ADVANCED,
699 .label = "password server",
702 .offset = GLOBAL_VAR(szPasswordServer),
705 .flags = FLAG_ADVANCED | FLAG_WIZARD,
708 .label = "smb passwd file",
711 .offset = GLOBAL_VAR(szSMBPasswdFile),
714 .flags = FLAG_ADVANCED,
717 .label = "private dir",
720 .offset = GLOBAL_VAR(szPrivateDir),
723 .flags = FLAG_ADVANCED,
726 .label = "private directory",
729 .offset = GLOBAL_VAR(szPrivateDir),
735 .label = "passdb backend",
738 .offset = GLOBAL_VAR(szPassdbBackend),
741 .flags = FLAG_ADVANCED | FLAG_WIZARD,
744 .label = "algorithmic rid base",
747 .offset = GLOBAL_VAR(AlgorithmicRidBase),
750 .flags = FLAG_ADVANCED,
753 .label = "root directory",
756 .offset = GLOBAL_VAR(szRootdir),
759 .flags = FLAG_ADVANCED,
765 .offset = GLOBAL_VAR(szRootdir),
774 .offset = GLOBAL_VAR(szRootdir),
780 .label = "guest account",
783 .offset = GLOBAL_VAR(szGuestaccount),
786 .flags = FLAG_BASIC | FLAG_ADVANCED,
789 .label = "enable privileges",
792 .offset = GLOBAL_VAR(bEnablePrivileges),
795 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
799 .label = "pam password change",
802 .offset = GLOBAL_VAR(bPamPasswordChange),
805 .flags = FLAG_ADVANCED,
808 .label = "passwd program",
811 .offset = GLOBAL_VAR(szPasswdProgram),
814 .flags = FLAG_ADVANCED,
817 .label = "passwd chat",
820 .offset = GLOBAL_VAR(szPasswdChat),
823 .flags = FLAG_ADVANCED,
826 .label = "passwd chat debug",
829 .offset = GLOBAL_VAR(bPasswdChatDebug),
832 .flags = FLAG_ADVANCED,
835 .label = "passwd chat timeout",
838 .offset = GLOBAL_VAR(iPasswdChatTimeout),
841 .flags = FLAG_ADVANCED,
844 .label = "check password script",
847 .offset = GLOBAL_VAR(szCheckPasswordScript),
850 .flags = FLAG_ADVANCED,
853 .label = "username map",
856 .offset = GLOBAL_VAR(szUsernameMap),
859 .flags = FLAG_ADVANCED,
862 .label = "password level",
865 .offset = GLOBAL_VAR(pwordlevel),
868 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
871 .label = "username level",
874 .offset = GLOBAL_VAR(unamelevel),
877 .flags = FLAG_ADVANCED,
880 .label = "unix password sync",
883 .offset = GLOBAL_VAR(bUnixPasswdSync),
886 .flags = FLAG_ADVANCED,
889 .label = "restrict anonymous",
892 .offset = GLOBAL_VAR(restrict_anonymous),
895 .flags = FLAG_ADVANCED,
898 .label = "lanman auth",
901 .offset = GLOBAL_VAR(bLanmanAuth),
904 .flags = FLAG_ADVANCED,
907 .label = "ntlm auth",
910 .offset = GLOBAL_VAR(bNTLMAuth),
913 .flags = FLAG_ADVANCED,
916 .label = "client NTLMv2 auth",
919 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
922 .flags = FLAG_ADVANCED,
925 .label = "client lanman auth",
928 .offset = GLOBAL_VAR(bClientLanManAuth),
931 .flags = FLAG_ADVANCED,
934 .label = "client plaintext auth",
937 .offset = GLOBAL_VAR(bClientPlaintextAuth),
940 .flags = FLAG_ADVANCED,
943 .label = "client use spnego principal",
946 .offset = GLOBAL_VAR(client_use_spnego_principal),
949 .flags = FLAG_ADVANCED,
955 .offset = LOCAL_VAR(szUsername),
958 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
964 .offset = LOCAL_VAR(szUsername),
973 .offset = LOCAL_VAR(szUsername),
979 .label = "invalid users",
982 .offset = LOCAL_VAR(szInvalidUsers),
985 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
988 .label = "valid users",
991 .offset = LOCAL_VAR(szValidUsers),
994 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
997 .label = "admin users",
1000 .offset = LOCAL_VAR(szAdminUsers),
1003 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1006 .label = "read list",
1009 .offset = LOCAL_VAR(readlist),
1012 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1015 .label = "write list",
1018 .offset = LOCAL_VAR(writelist),
1021 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1024 .label = "printer admin",
1027 .offset = LOCAL_VAR(printer_admin),
1030 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1033 .label = "force user",
1036 .offset = LOCAL_VAR(force_user),
1039 .flags = FLAG_ADVANCED | FLAG_SHARE,
1042 .label = "force group",
1045 .offset = LOCAL_VAR(force_group),
1048 .flags = FLAG_ADVANCED | FLAG_SHARE,
1054 .offset = LOCAL_VAR(force_group),
1057 .flags = FLAG_ADVANCED,
1060 .label = "read only",
1063 .offset = LOCAL_VAR(bRead_only),
1066 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1069 .label = "write ok",
1072 .offset = LOCAL_VAR(bRead_only),
1078 .label = "writeable",
1081 .offset = LOCAL_VAR(bRead_only),
1087 .label = "writable",
1090 .offset = LOCAL_VAR(bRead_only),
1096 .label = "acl check permissions",
1099 .offset = LOCAL_VAR(bAclCheckPermissions),
1102 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
1105 .label = "acl group control",
1108 .offset = LOCAL_VAR(bAclGroupControl),
1111 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1114 .label = "acl map full control",
1117 .offset = LOCAL_VAR(bAclMapFullControl),
1120 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1123 .label = "create mask",
1126 .offset = LOCAL_VAR(iCreate_mask),
1129 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1132 .label = "create mode",
1135 .offset = LOCAL_VAR(iCreate_mask),
1141 .label = "force create mode",
1144 .offset = LOCAL_VAR(iCreate_force_mode),
1147 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1150 .label = "security mask",
1153 .offset = LOCAL_VAR(iSecurity_mask),
1156 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1159 .label = "force security mode",
1162 .offset = LOCAL_VAR(iSecurity_force_mode),
1165 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1168 .label = "directory mask",
1171 .offset = LOCAL_VAR(iDir_mask),
1174 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1177 .label = "directory mode",
1180 .offset = LOCAL_VAR(iDir_mask),
1183 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1186 .label = "force directory mode",
1189 .offset = LOCAL_VAR(iDir_force_mode),
1192 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1195 .label = "directory security mask",
1198 .offset = LOCAL_VAR(iDir_Security_mask),
1201 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1204 .label = "force directory security mode",
1207 .offset = LOCAL_VAR(iDir_Security_force_mode),
1210 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1213 .label = "force unknown acl user",
1216 .offset = LOCAL_VAR(bForceUnknownAclUser),
1219 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1222 .label = "inherit permissions",
1225 .offset = LOCAL_VAR(bInheritPerms),
1228 .flags = FLAG_ADVANCED | FLAG_SHARE,
1231 .label = "inherit acls",
1234 .offset = LOCAL_VAR(bInheritACLS),
1237 .flags = FLAG_ADVANCED | FLAG_SHARE,
1240 .label = "inherit owner",
1243 .offset = LOCAL_VAR(bInheritOwner),
1246 .flags = FLAG_ADVANCED | FLAG_SHARE,
1249 .label = "guest only",
1252 .offset = LOCAL_VAR(bGuest_only),
1255 .flags = FLAG_ADVANCED | FLAG_SHARE,
1258 .label = "only guest",
1261 .offset = LOCAL_VAR(bGuest_only),
1267 .label = "administrative share",
1270 .offset = LOCAL_VAR(bAdministrative_share),
1273 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1277 .label = "guest ok",
1280 .offset = LOCAL_VAR(bGuest_ok),
1283 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1289 .offset = LOCAL_VAR(bGuest_ok),
1295 .label = "only user",
1298 .offset = LOCAL_VAR(bOnlyUser),
1301 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1304 .label = "hosts allow",
1307 .offset = LOCAL_VAR(szHostsallow),
1310 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1313 .label = "allow hosts",
1316 .offset = LOCAL_VAR(szHostsallow),
1322 .label = "hosts deny",
1325 .offset = LOCAL_VAR(szHostsdeny),
1328 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1331 .label = "deny hosts",
1334 .offset = LOCAL_VAR(szHostsdeny),
1340 .label = "preload modules",
1342 .p_class = P_GLOBAL,
1343 .offset = GLOBAL_VAR(szPreloadModules),
1346 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1349 .label = "dedicated keytab file",
1351 .p_class = P_GLOBAL,
1352 .offset = GLOBAL_VAR(szDedicatedKeytabFile),
1355 .flags = FLAG_ADVANCED,
1358 .label = "kerberos method",
1360 .p_class = P_GLOBAL,
1361 .offset = GLOBAL_VAR(iKerberosMethod),
1363 .enum_list = enum_kerberos_method,
1364 .flags = FLAG_ADVANCED,
1367 .label = "map untrusted to domain",
1369 .p_class = P_GLOBAL,
1370 .offset = GLOBAL_VAR(bMapUntrustedToDomain),
1373 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1377 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1380 .label = "log level",
1382 .p_class = P_GLOBAL,
1383 .offset = GLOBAL_VAR(szLogLevel),
1384 .special = handle_debug_list,
1386 .flags = FLAG_ADVANCED,
1389 .label = "debuglevel",
1391 .p_class = P_GLOBAL,
1392 .offset = GLOBAL_VAR(szLogLevel),
1393 .special = handle_debug_list,
1400 .p_class = P_GLOBAL,
1401 .offset = GLOBAL_VAR(syslog),
1404 .flags = FLAG_ADVANCED,
1407 .label = "syslog only",
1409 .p_class = P_GLOBAL,
1410 .offset = GLOBAL_VAR(bSyslogOnly),
1413 .flags = FLAG_ADVANCED,
1416 .label = "log file",
1418 .p_class = P_GLOBAL,
1419 .offset = GLOBAL_VAR(logfile),
1422 .flags = FLAG_ADVANCED,
1425 .label = "max log size",
1427 .p_class = P_GLOBAL,
1428 .offset = GLOBAL_VAR(max_log_size),
1431 .flags = FLAG_ADVANCED,
1434 .label = "debug timestamp",
1436 .p_class = P_GLOBAL,
1437 .offset = GLOBAL_VAR(bTimestampLogs),
1440 .flags = FLAG_ADVANCED,
1443 .label = "timestamp logs",
1445 .p_class = P_GLOBAL,
1446 .offset = GLOBAL_VAR(bTimestampLogs),
1449 .flags = FLAG_ADVANCED,
1452 .label = "debug prefix timestamp",
1454 .p_class = P_GLOBAL,
1455 .offset = GLOBAL_VAR(bDebugPrefixTimestamp),
1458 .flags = FLAG_ADVANCED,
1461 .label = "debug hires timestamp",
1463 .p_class = P_GLOBAL,
1464 .offset = GLOBAL_VAR(bDebugHiresTimestamp),
1467 .flags = FLAG_ADVANCED,
1470 .label = "debug pid",
1472 .p_class = P_GLOBAL,
1473 .offset = GLOBAL_VAR(bDebugPid),
1476 .flags = FLAG_ADVANCED,
1479 .label = "debug uid",
1481 .p_class = P_GLOBAL,
1482 .offset = GLOBAL_VAR(bDebugUid),
1485 .flags = FLAG_ADVANCED,
1488 .label = "debug class",
1490 .p_class = P_GLOBAL,
1491 .offset = GLOBAL_VAR(bDebugClass),
1494 .flags = FLAG_ADVANCED,
1497 .label = "enable core files",
1499 .p_class = P_GLOBAL,
1500 .offset = GLOBAL_VAR(bEnableCoreFiles),
1503 .flags = FLAG_ADVANCED,
1506 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1509 .label = "allocation roundup size",
1512 .offset = LOCAL_VAR(iallocation_roundup_size),
1515 .flags = FLAG_ADVANCED,
1518 .label = "aio read size",
1521 .offset = LOCAL_VAR(iAioReadSize),
1524 .flags = FLAG_ADVANCED,
1527 .label = "aio write size",
1530 .offset = LOCAL_VAR(iAioWriteSize),
1533 .flags = FLAG_ADVANCED,
1536 .label = "aio write behind",
1539 .offset = LOCAL_VAR(szAioWriteBehind),
1542 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1545 .label = "smb ports",
1547 .p_class = P_GLOBAL,
1548 .offset = GLOBAL_VAR(smb_ports),
1551 .flags = FLAG_ADVANCED,
1554 .label = "large readwrite",
1556 .p_class = P_GLOBAL,
1557 .offset = GLOBAL_VAR(bLargeReadwrite),
1560 .flags = FLAG_ADVANCED,
1563 .label = "max protocol",
1565 .p_class = P_GLOBAL,
1566 .offset = GLOBAL_VAR(srv_maxprotocol),
1568 .enum_list = enum_protocol,
1569 .flags = FLAG_ADVANCED,
1572 .label = "server max protocol",
1574 .p_class = P_GLOBAL,
1575 .offset = GLOBAL_VAR(srv_maxprotocol),
1577 .enum_list = enum_protocol,
1578 .flags = FLAG_ADVANCED,
1581 .label = "protocol",
1583 .p_class = P_GLOBAL,
1584 .offset = GLOBAL_VAR(srv_maxprotocol),
1586 .enum_list = enum_protocol,
1587 .flags = FLAG_ADVANCED,
1590 .label = "min protocol",
1592 .p_class = P_GLOBAL,
1593 .offset = GLOBAL_VAR(srv_minprotocol),
1595 .enum_list = enum_protocol,
1596 .flags = FLAG_ADVANCED,
1599 .label = "server min protocol",
1601 .p_class = P_GLOBAL,
1602 .offset = GLOBAL_VAR(srv_minprotocol),
1604 .enum_list = enum_protocol,
1605 .flags = FLAG_ADVANCED,
1608 .label = "min receivefile size",
1610 .p_class = P_GLOBAL,
1611 .offset = GLOBAL_VAR(iminreceivefile),
1614 .flags = FLAG_ADVANCED,
1617 .label = "read raw",
1619 .p_class = P_GLOBAL,
1620 .offset = GLOBAL_VAR(bReadRaw),
1623 .flags = FLAG_ADVANCED,
1626 .label = "write raw",
1628 .p_class = P_GLOBAL,
1629 .offset = GLOBAL_VAR(bWriteRaw),
1632 .flags = FLAG_ADVANCED,
1635 .label = "disable netbios",
1637 .p_class = P_GLOBAL,
1638 .offset = GLOBAL_VAR(bDisableNetbios),
1641 .flags = FLAG_ADVANCED,
1644 .label = "reset on zero vc",
1646 .p_class = P_GLOBAL,
1647 .offset = GLOBAL_VAR(bResetOnZeroVC),
1650 .flags = FLAG_ADVANCED,
1653 .label = "log writeable files on exit",
1655 .p_class = P_GLOBAL,
1656 .offset = GLOBAL_VAR(bLogWriteableFilesOnExit),
1659 .flags = FLAG_ADVANCED,
1662 .label = "acl compatibility",
1664 .p_class = P_GLOBAL,
1665 .offset = GLOBAL_VAR(iAclCompat),
1667 .enum_list = enum_acl_compat_vals,
1668 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1671 .label = "defer sharing violations",
1673 .p_class = P_GLOBAL,
1674 .offset = GLOBAL_VAR(bDeferSharingViolations),
1677 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1680 .label = "ea support",
1683 .offset = LOCAL_VAR(bEASupport),
1686 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1689 .label = "nt acl support",
1692 .offset = LOCAL_VAR(bNTAclSupport),
1695 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1698 .label = "nt pipe support",
1700 .p_class = P_GLOBAL,
1701 .offset = GLOBAL_VAR(bNTPipeSupport),
1704 .flags = FLAG_ADVANCED,
1707 .label = "nt status support",
1709 .p_class = P_GLOBAL,
1710 .offset = GLOBAL_VAR(bNTStatusSupport),
1713 .flags = FLAG_ADVANCED,
1716 .label = "profile acls",
1719 .offset = LOCAL_VAR(bProfileAcls),
1722 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1725 .label = "map acl inherit",
1728 .offset = LOCAL_VAR(bMap_acl_inherit),
1731 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1734 .label = "afs share",
1737 .offset = LOCAL_VAR(bAfs_Share),
1740 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1745 .p_class = P_GLOBAL,
1746 .offset = GLOBAL_VAR(max_mux),
1749 .flags = FLAG_ADVANCED,
1752 .label = "max xmit",
1754 .p_class = P_GLOBAL,
1755 .offset = GLOBAL_VAR(max_xmit),
1758 .flags = FLAG_ADVANCED,
1761 .label = "name resolve order",
1763 .p_class = P_GLOBAL,
1764 .offset = GLOBAL_VAR(szNameResolveOrder),
1767 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1772 .p_class = P_GLOBAL,
1773 .offset = GLOBAL_VAR(max_ttl),
1776 .flags = FLAG_ADVANCED,
1779 .label = "max wins ttl",
1781 .p_class = P_GLOBAL,
1782 .offset = GLOBAL_VAR(max_wins_ttl),
1785 .flags = FLAG_ADVANCED,
1788 .label = "min wins ttl",
1790 .p_class = P_GLOBAL,
1791 .offset = GLOBAL_VAR(min_wins_ttl),
1794 .flags = FLAG_ADVANCED,
1797 .label = "time server",
1799 .p_class = P_GLOBAL,
1800 .offset = GLOBAL_VAR(bTimeServer),
1803 .flags = FLAG_ADVANCED,
1806 .label = "unix extensions",
1808 .p_class = P_GLOBAL,
1809 .offset = GLOBAL_VAR(bUnixExtensions),
1812 .flags = FLAG_ADVANCED,
1815 .label = "use spnego",
1817 .p_class = P_GLOBAL,
1818 .offset = GLOBAL_VAR(bUseSpnego),
1821 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
1824 .label = "client signing",
1826 .p_class = P_GLOBAL,
1827 .offset = GLOBAL_VAR(client_signing),
1829 .enum_list = enum_smb_signing_vals,
1830 .flags = FLAG_ADVANCED,
1833 .label = "server signing",
1835 .p_class = P_GLOBAL,
1836 .offset = GLOBAL_VAR(server_signing),
1838 .enum_list = enum_smb_signing_vals,
1839 .flags = FLAG_ADVANCED,
1842 .label = "smb encrypt",
1845 .offset = LOCAL_VAR(ismb_encrypt),
1847 .enum_list = enum_smb_signing_vals,
1848 .flags = FLAG_ADVANCED,
1851 .label = "client use spnego",
1853 .p_class = P_GLOBAL,
1854 .offset = GLOBAL_VAR(bClientUseSpnego),
1857 .flags = FLAG_ADVANCED,
1860 .label = "client ldap sasl wrapping",
1862 .p_class = P_GLOBAL,
1863 .offset = GLOBAL_VAR(client_ldap_sasl_wrapping),
1865 .enum_list = enum_ldap_sasl_wrapping,
1866 .flags = FLAG_ADVANCED,
1869 .label = "enable asu support",
1871 .p_class = P_GLOBAL,
1872 .offset = GLOBAL_VAR(bASUSupport),
1875 .flags = FLAG_ADVANCED,
1878 .label = "svcctl list",
1880 .p_class = P_GLOBAL,
1881 .offset = GLOBAL_VAR(szServicesList),
1884 .flags = FLAG_ADVANCED,
1887 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
1890 .label = "block size",
1893 .offset = LOCAL_VAR(iBlock_size),
1896 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1899 .label = "deadtime",
1901 .p_class = P_GLOBAL,
1902 .offset = GLOBAL_VAR(deadtime),
1905 .flags = FLAG_ADVANCED,
1908 .label = "getwd cache",
1910 .p_class = P_GLOBAL,
1911 .offset = GLOBAL_VAR(getwd_cache),
1914 .flags = FLAG_ADVANCED,
1917 .label = "keepalive",
1919 .p_class = P_GLOBAL,
1920 .offset = GLOBAL_VAR(iKeepalive),
1923 .flags = FLAG_ADVANCED,
1926 .label = "change notify",
1929 .offset = LOCAL_VAR(bChangeNotify),
1932 .flags = FLAG_ADVANCED | FLAG_SHARE,
1935 .label = "directory name cache size",
1938 .offset = LOCAL_VAR(iDirectoryNameCacheSize),
1941 .flags = FLAG_ADVANCED | FLAG_SHARE,
1944 .label = "kernel change notify",
1947 .offset = LOCAL_VAR(bKernelChangeNotify),
1950 .flags = FLAG_ADVANCED | FLAG_SHARE,
1953 .label = "lpq cache time",
1955 .p_class = P_GLOBAL,
1956 .offset = GLOBAL_VAR(lpqcachetime),
1959 .flags = FLAG_ADVANCED,
1962 .label = "max smbd processes",
1964 .p_class = P_GLOBAL,
1965 .offset = GLOBAL_VAR(iMaxSmbdProcesses),
1968 .flags = FLAG_ADVANCED,
1971 .label = "max connections",
1974 .offset = LOCAL_VAR(iMaxConnections),
1977 .flags = FLAG_ADVANCED | FLAG_SHARE,
1980 .label = "paranoid server security",
1982 .p_class = P_GLOBAL,
1983 .offset = GLOBAL_VAR(paranoid_server_security),
1986 .flags = FLAG_ADVANCED,
1989 .label = "max disk size",
1991 .p_class = P_GLOBAL,
1992 .offset = GLOBAL_VAR(maxdisksize),
1995 .flags = FLAG_ADVANCED,
1998 .label = "max open files",
2000 .p_class = P_GLOBAL,
2001 .offset = GLOBAL_VAR(max_open_files),
2004 .flags = FLAG_ADVANCED,
2007 .label = "min print space",
2010 .offset = LOCAL_VAR(iMinPrintSpace),
2013 .flags = FLAG_ADVANCED | FLAG_PRINT,
2016 .label = "socket options",
2018 .p_class = P_GLOBAL,
2019 .offset = GLOBAL_VAR(szSocketOptions),
2022 .flags = FLAG_ADVANCED,
2025 .label = "strict allocate",
2028 .offset = LOCAL_VAR(bStrictAllocate),
2031 .flags = FLAG_ADVANCED | FLAG_SHARE,
2034 .label = "strict sync",
2037 .offset = LOCAL_VAR(bStrictSync),
2040 .flags = FLAG_ADVANCED | FLAG_SHARE,
2043 .label = "sync always",
2046 .offset = LOCAL_VAR(bSyncAlways),
2049 .flags = FLAG_ADVANCED | FLAG_SHARE,
2052 .label = "use mmap",
2054 .p_class = P_GLOBAL,
2055 .offset = GLOBAL_VAR(bUseMmap),
2058 .flags = FLAG_ADVANCED,
2061 .label = "use sendfile",
2064 .offset = LOCAL_VAR(bUseSendfile),
2067 .flags = FLAG_ADVANCED | FLAG_SHARE,
2070 .label = "hostname lookups",
2072 .p_class = P_GLOBAL,
2073 .offset = GLOBAL_VAR(bHostnameLookups),
2076 .flags = FLAG_ADVANCED,
2079 .label = "write cache size",
2082 .offset = LOCAL_VAR(iWriteCacheSize),
2085 .flags = FLAG_ADVANCED | FLAG_SHARE,
2088 .label = "name cache timeout",
2090 .p_class = P_GLOBAL,
2091 .offset = GLOBAL_VAR(name_cache_timeout),
2094 .flags = FLAG_ADVANCED,
2097 .label = "ctdbd socket",
2099 .p_class = P_GLOBAL,
2100 .offset = GLOBAL_VAR(ctdbdSocket),
2103 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2106 .label = "cluster addresses",
2108 .p_class = P_GLOBAL,
2109 .offset = GLOBAL_VAR(szClusterAddresses),
2112 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2115 .label = "clustering",
2117 .p_class = P_GLOBAL,
2118 .offset = GLOBAL_VAR(clustering),
2121 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2124 .label = "ctdb timeout",
2126 .p_class = P_GLOBAL,
2127 .offset = GLOBAL_VAR(ctdb_timeout),
2130 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2133 .label = "ctdb locktime warn threshold",
2135 .p_class = P_GLOBAL,
2136 .offset = GLOBAL_VAR(ctdb_locktime_warn_threshold),
2139 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2142 .label = "smb2 max read",
2144 .p_class = P_GLOBAL,
2145 .offset = GLOBAL_VAR(ismb2_max_read),
2148 .flags = FLAG_ADVANCED,
2151 .label = "smb2 max write",
2153 .p_class = P_GLOBAL,
2154 .offset = GLOBAL_VAR(ismb2_max_write),
2157 .flags = FLAG_ADVANCED,
2160 .label = "smb2 max trans",
2162 .p_class = P_GLOBAL,
2163 .offset = GLOBAL_VAR(ismb2_max_trans),
2166 .flags = FLAG_ADVANCED,
2169 .label = "smb2 max credits",
2171 .p_class = P_GLOBAL,
2172 .offset = GLOBAL_VAR(ismb2_max_credits),
2175 .flags = FLAG_ADVANCED,
2178 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2181 .label = "max reported print jobs",
2184 .offset = LOCAL_VAR(iMaxReportedPrintJobs),
2187 .flags = FLAG_ADVANCED | FLAG_PRINT,
2190 .label = "max print jobs",
2193 .offset = LOCAL_VAR(iMaxPrintJobs),
2196 .flags = FLAG_ADVANCED | FLAG_PRINT,
2199 .label = "load printers",
2201 .p_class = P_GLOBAL,
2202 .offset = GLOBAL_VAR(bLoadPrinters),
2205 .flags = FLAG_ADVANCED | FLAG_PRINT,
2208 .label = "printcap cache time",
2210 .p_class = P_GLOBAL,
2211 .offset = GLOBAL_VAR(PrintcapCacheTime),
2214 .flags = FLAG_ADVANCED | FLAG_PRINT,
2217 .label = "printcap name",
2219 .p_class = P_GLOBAL,
2220 .offset = GLOBAL_VAR(szPrintcapname),
2223 .flags = FLAG_ADVANCED | FLAG_PRINT,
2226 .label = "printcap",
2228 .p_class = P_GLOBAL,
2229 .offset = GLOBAL_VAR(szPrintcapname),
2235 .label = "printable",
2238 .offset = LOCAL_VAR(bPrint_ok),
2241 .flags = FLAG_ADVANCED | FLAG_PRINT,
2244 .label = "print notify backchannel",
2247 .offset = LOCAL_VAR(bPrintNotifyBackchannel),
2250 .flags = FLAG_ADVANCED,
2253 .label = "print ok",
2256 .offset = LOCAL_VAR(bPrint_ok),
2262 .label = "printing",
2265 .offset = LOCAL_VAR(iPrinting),
2266 .special = handle_printing,
2267 .enum_list = enum_printing,
2268 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2271 .label = "cups options",
2274 .offset = LOCAL_VAR(szCupsOptions),
2277 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2280 .label = "cups server",
2282 .p_class = P_GLOBAL,
2283 .offset = GLOBAL_VAR(szCupsServer),
2286 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2289 .label = "cups encrypt",
2291 .p_class = P_GLOBAL,
2292 .offset = GLOBAL_VAR(CupsEncrypt),
2294 .enum_list = enum_bool_auto,
2295 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2299 .label = "cups connection timeout",
2301 .p_class = P_GLOBAL,
2302 .offset = GLOBAL_VAR(cups_connection_timeout),
2305 .flags = FLAG_ADVANCED,
2308 .label = "iprint server",
2310 .p_class = P_GLOBAL,
2311 .offset = GLOBAL_VAR(szIPrintServer),
2314 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2317 .label = "print command",
2320 .offset = LOCAL_VAR(szPrintcommand),
2323 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2326 .label = "disable spoolss",
2328 .p_class = P_GLOBAL,
2329 .offset = GLOBAL_VAR(bDisableSpoolss),
2332 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2335 .label = "enable spoolss",
2337 .p_class = P_GLOBAL,
2338 .offset = GLOBAL_VAR(bDisableSpoolss),
2344 .label = "lpq command",
2347 .offset = LOCAL_VAR(szLpqcommand),
2350 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2353 .label = "lprm command",
2356 .offset = LOCAL_VAR(szLprmcommand),
2359 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2362 .label = "lppause command",
2365 .offset = LOCAL_VAR(szLppausecommand),
2368 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2371 .label = "lpresume command",
2374 .offset = LOCAL_VAR(szLpresumecommand),
2377 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2380 .label = "queuepause command",
2383 .offset = LOCAL_VAR(szQueuepausecommand),
2386 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2389 .label = "queueresume command",
2392 .offset = LOCAL_VAR(szQueueresumecommand),
2395 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2398 .label = "addport command",
2400 .p_class = P_GLOBAL,
2401 .offset = GLOBAL_VAR(szAddPortCommand),
2404 .flags = FLAG_ADVANCED,
2407 .label = "enumports command",
2409 .p_class = P_GLOBAL,
2410 .offset = GLOBAL_VAR(szEnumPortsCommand),
2413 .flags = FLAG_ADVANCED,
2416 .label = "addprinter command",
2418 .p_class = P_GLOBAL,
2419 .offset = GLOBAL_VAR(szAddPrinterCommand),
2422 .flags = FLAG_ADVANCED,
2425 .label = "deleteprinter command",
2427 .p_class = P_GLOBAL,
2428 .offset = GLOBAL_VAR(szDeletePrinterCommand),
2431 .flags = FLAG_ADVANCED,
2434 .label = "show add printer wizard",
2436 .p_class = P_GLOBAL,
2437 .offset = GLOBAL_VAR(bMsAddPrinterWizard),
2440 .flags = FLAG_ADVANCED,
2443 .label = "os2 driver map",
2445 .p_class = P_GLOBAL,
2446 .offset = GLOBAL_VAR(szOs2DriverMap),
2449 .flags = FLAG_ADVANCED,
2453 .label = "printer name",
2456 .offset = LOCAL_VAR(szPrintername),
2459 .flags = FLAG_ADVANCED | FLAG_PRINT,
2465 .offset = LOCAL_VAR(szPrintername),
2471 .label = "use client driver",
2474 .offset = LOCAL_VAR(bUseClientDriver),
2477 .flags = FLAG_ADVANCED | FLAG_PRINT,
2480 .label = "default devmode",
2483 .offset = LOCAL_VAR(bDefaultDevmode),
2486 .flags = FLAG_ADVANCED | FLAG_PRINT,
2489 .label = "force printername",
2492 .offset = LOCAL_VAR(bForcePrintername),
2495 .flags = FLAG_ADVANCED | FLAG_PRINT,
2498 .label = "printjob username",
2501 .offset = LOCAL_VAR(szPrintjobUsername),
2504 .flags = FLAG_ADVANCED | FLAG_PRINT,
2507 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2510 .label = "mangling method",
2512 .p_class = P_GLOBAL,
2513 .offset = GLOBAL_VAR(szManglingMethod),
2516 .flags = FLAG_ADVANCED,
2519 .label = "mangle prefix",
2521 .p_class = P_GLOBAL,
2522 .offset = GLOBAL_VAR(mangle_prefix),
2525 .flags = FLAG_ADVANCED,
2529 .label = "default case",
2532 .offset = LOCAL_VAR(iDefaultCase),
2534 .enum_list = enum_case,
2535 .flags = FLAG_ADVANCED | FLAG_SHARE,
2538 .label = "case sensitive",
2541 .offset = LOCAL_VAR(iCaseSensitive),
2543 .enum_list = enum_bool_auto,
2544 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2547 .label = "casesignames",
2550 .offset = LOCAL_VAR(iCaseSensitive),
2552 .enum_list = enum_bool_auto,
2553 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2556 .label = "preserve case",
2559 .offset = LOCAL_VAR(bCasePreserve),
2562 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2565 .label = "short preserve case",
2568 .offset = LOCAL_VAR(bShortCasePreserve),
2571 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2574 .label = "mangling char",
2577 .offset = LOCAL_VAR(magic_char),
2580 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2583 .label = "hide dot files",
2586 .offset = LOCAL_VAR(bHideDotFiles),
2589 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2592 .label = "hide special files",
2595 .offset = LOCAL_VAR(bHideSpecialFiles),
2598 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2601 .label = "hide unreadable",
2604 .offset = LOCAL_VAR(bHideUnReadable),
2607 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2610 .label = "hide unwriteable files",
2613 .offset = LOCAL_VAR(bHideUnWriteableFiles),
2616 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2619 .label = "delete veto files",
2622 .offset = LOCAL_VAR(bDeleteVetoFiles),
2625 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2628 .label = "veto files",
2631 .offset = LOCAL_VAR(szVetoFiles),
2634 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2637 .label = "hide files",
2640 .offset = LOCAL_VAR(szHideFiles),
2643 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2646 .label = "veto oplock files",
2649 .offset = LOCAL_VAR(szVetoOplockFiles),
2652 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2655 .label = "map archive",
2658 .offset = LOCAL_VAR(bMap_archive),
2661 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2664 .label = "map hidden",
2667 .offset = LOCAL_VAR(bMap_hidden),
2670 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2673 .label = "map system",
2676 .offset = LOCAL_VAR(bMap_system),
2679 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2682 .label = "map readonly",
2685 .offset = LOCAL_VAR(iMap_readonly),
2687 .enum_list = enum_map_readonly,
2688 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2691 .label = "mangled names",
2694 .offset = LOCAL_VAR(bMangledNames),
2697 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2700 .label = "max stat cache size",
2702 .p_class = P_GLOBAL,
2703 .offset = GLOBAL_VAR(iMaxStatCacheSize),
2706 .flags = FLAG_ADVANCED,
2709 .label = "stat cache",
2711 .p_class = P_GLOBAL,
2712 .offset = GLOBAL_VAR(bStatCache),
2715 .flags = FLAG_ADVANCED,
2718 .label = "store dos attributes",
2721 .offset = LOCAL_VAR(bStoreDosAttributes),
2724 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2727 .label = "dmapi support",
2730 .offset = LOCAL_VAR(bDmapiSupport),
2733 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2737 {N_("Domain Options"), P_SEP, P_SEPARATOR},
2740 .label = "machine password timeout",
2742 .p_class = P_GLOBAL,
2743 .offset = GLOBAL_VAR(machine_password_timeout),
2746 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2749 {N_("Logon Options"), P_SEP, P_SEPARATOR},
2752 .label = "add user script",
2754 .p_class = P_GLOBAL,
2755 .offset = GLOBAL_VAR(szAddUserScript),
2758 .flags = FLAG_ADVANCED,
2761 .label = "rename user script",
2763 .p_class = P_GLOBAL,
2764 .offset = GLOBAL_VAR(szRenameUserScript),
2767 .flags = FLAG_ADVANCED,
2770 .label = "delete user script",
2772 .p_class = P_GLOBAL,
2773 .offset = GLOBAL_VAR(szDelUserScript),
2776 .flags = FLAG_ADVANCED,
2779 .label = "add group script",
2781 .p_class = P_GLOBAL,
2782 .offset = GLOBAL_VAR(szAddGroupScript),
2785 .flags = FLAG_ADVANCED,
2788 .label = "delete group script",
2790 .p_class = P_GLOBAL,
2791 .offset = GLOBAL_VAR(szDelGroupScript),
2794 .flags = FLAG_ADVANCED,
2797 .label = "add user to group script",
2799 .p_class = P_GLOBAL,
2800 .offset = GLOBAL_VAR(szAddUserToGroupScript),
2803 .flags = FLAG_ADVANCED,
2806 .label = "delete user from group script",
2808 .p_class = P_GLOBAL,
2809 .offset = GLOBAL_VAR(szDelUserFromGroupScript),
2812 .flags = FLAG_ADVANCED,
2815 .label = "set primary group script",
2817 .p_class = P_GLOBAL,
2818 .offset = GLOBAL_VAR(szSetPrimaryGroupScript),
2821 .flags = FLAG_ADVANCED,
2824 .label = "add machine script",
2826 .p_class = P_GLOBAL,
2827 .offset = GLOBAL_VAR(szAddMachineScript),
2830 .flags = FLAG_ADVANCED,
2833 .label = "shutdown script",
2835 .p_class = P_GLOBAL,
2836 .offset = GLOBAL_VAR(szShutdownScript),
2839 .flags = FLAG_ADVANCED,
2842 .label = "abort shutdown script",
2844 .p_class = P_GLOBAL,
2845 .offset = GLOBAL_VAR(szAbortShutdownScript),
2848 .flags = FLAG_ADVANCED,
2851 .label = "username map script",
2853 .p_class = P_GLOBAL,
2854 .offset = GLOBAL_VAR(szUsernameMapScript),
2857 .flags = FLAG_ADVANCED,
2860 .label = "username map cache time",
2862 .p_class = P_GLOBAL,
2863 .offset = GLOBAL_VAR(iUsernameMapCacheTime),
2866 .flags = FLAG_ADVANCED,
2869 .label = "logon script",
2871 .p_class = P_GLOBAL,
2872 .offset = GLOBAL_VAR(szLogonScript),
2875 .flags = FLAG_ADVANCED,
2878 .label = "logon path",
2880 .p_class = P_GLOBAL,
2881 .offset = GLOBAL_VAR(szLogonPath),
2884 .flags = FLAG_ADVANCED,
2887 .label = "logon drive",
2889 .p_class = P_GLOBAL,
2890 .offset = GLOBAL_VAR(szLogonDrive),
2893 .flags = FLAG_ADVANCED,
2896 .label = "logon home",
2898 .p_class = P_GLOBAL,
2899 .offset = GLOBAL_VAR(szLogonHome),
2902 .flags = FLAG_ADVANCED,
2905 .label = "domain logons",
2907 .p_class = P_GLOBAL,
2908 .offset = GLOBAL_VAR(bDomainLogons),
2911 .flags = FLAG_ADVANCED,
2915 .label = "init logon delayed hosts",
2917 .p_class = P_GLOBAL,
2918 .offset = GLOBAL_VAR(szInitLogonDelayedHosts),
2921 .flags = FLAG_ADVANCED,
2925 .label = "init logon delay",
2927 .p_class = P_GLOBAL,
2928 .offset = GLOBAL_VAR(InitLogonDelay),
2931 .flags = FLAG_ADVANCED,
2935 {N_("Browse Options"), P_SEP, P_SEPARATOR},
2938 .label = "os level",
2940 .p_class = P_GLOBAL,
2941 .offset = GLOBAL_VAR(os_level),
2944 .flags = FLAG_BASIC | FLAG_ADVANCED,
2947 .label = "lm announce",
2949 .p_class = P_GLOBAL,
2950 .offset = GLOBAL_VAR(lm_announce),
2952 .enum_list = enum_bool_auto,
2953 .flags = FLAG_ADVANCED,
2956 .label = "lm interval",
2958 .p_class = P_GLOBAL,
2959 .offset = GLOBAL_VAR(lm_interval),
2962 .flags = FLAG_ADVANCED,
2965 .label = "preferred master",
2967 .p_class = P_GLOBAL,
2968 .offset = GLOBAL_VAR(iPreferredMaster),
2970 .enum_list = enum_bool_auto,
2971 .flags = FLAG_BASIC | FLAG_ADVANCED,
2974 .label = "prefered master",
2976 .p_class = P_GLOBAL,
2977 .offset = GLOBAL_VAR(iPreferredMaster),
2979 .enum_list = enum_bool_auto,
2983 .label = "local master",
2985 .p_class = P_GLOBAL,
2986 .offset = GLOBAL_VAR(bLocalMaster),
2989 .flags = FLAG_BASIC | FLAG_ADVANCED,
2992 .label = "domain master",
2994 .p_class = P_GLOBAL,
2995 .offset = GLOBAL_VAR(iDomainMaster),
2997 .enum_list = enum_bool_auto,
2998 .flags = FLAG_BASIC | FLAG_ADVANCED,
3001 .label = "browse list",
3003 .p_class = P_GLOBAL,
3004 .offset = GLOBAL_VAR(bBrowseList),
3007 .flags = FLAG_ADVANCED,
3010 .label = "browseable",
3013 .offset = LOCAL_VAR(bBrowseable),
3016 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3019 .label = "browsable",
3022 .offset = LOCAL_VAR(bBrowseable),
3028 .label = "access based share enum",
3031 .offset = LOCAL_VAR(bAccessBasedShareEnum),
3034 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3037 .label = "enhanced browsing",
3039 .p_class = P_GLOBAL,
3040 .offset = GLOBAL_VAR(enhanced_browsing),
3043 .flags = FLAG_ADVANCED,
3046 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3049 .label = "dns proxy",
3051 .p_class = P_GLOBAL,
3052 .offset = GLOBAL_VAR(bWINSdnsProxy),
3055 .flags = FLAG_ADVANCED,
3058 .label = "wins proxy",
3060 .p_class = P_GLOBAL,
3061 .offset = GLOBAL_VAR(bWINSproxy),
3064 .flags = FLAG_ADVANCED,
3067 .label = "wins server",
3069 .p_class = P_GLOBAL,
3070 .offset = GLOBAL_VAR(szWINSservers),
3073 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3076 .label = "wins support",
3078 .p_class = P_GLOBAL,
3079 .offset = GLOBAL_VAR(bWINSsupport),
3082 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3085 .label = "wins hook",
3087 .p_class = P_GLOBAL,
3088 .offset = GLOBAL_VAR(szWINSHook),
3091 .flags = FLAG_ADVANCED,
3094 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3097 .label = "blocking locks",
3100 .offset = LOCAL_VAR(bBlockingLocks),
3103 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3106 .label = "csc policy",
3109 .offset = LOCAL_VAR(iCSCPolicy),
3111 .enum_list = enum_csc_policy,
3112 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3115 .label = "fake oplocks",
3118 .offset = LOCAL_VAR(bFakeOplocks),
3121 .flags = FLAG_ADVANCED | FLAG_SHARE,
3124 .label = "kernel oplocks",
3127 .offset = LOCAL_VAR(bKernelOplocks),
3130 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3136 .offset = LOCAL_VAR(bLocking),
3139 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3142 .label = "lock spin time",
3144 .p_class = P_GLOBAL,
3145 .offset = GLOBAL_VAR(iLockSpinTime),
3148 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3154 .offset = LOCAL_VAR(bOpLocks),
3157 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3160 .label = "level2 oplocks",
3163 .offset = LOCAL_VAR(bLevel2OpLocks),
3166 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3169 .label = "oplock break wait time",
3171 .p_class = P_GLOBAL,
3172 .offset = GLOBAL_VAR(oplock_break_wait_time),
3175 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3178 .label = "oplock contention limit",
3181 .offset = LOCAL_VAR(iOplockContentionLimit),
3184 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3187 .label = "posix locking",
3190 .offset = LOCAL_VAR(bPosixLocking),
3193 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3196 .label = "strict locking",
3199 .offset = LOCAL_VAR(iStrictLocking),
3201 .enum_list = enum_bool_auto,
3202 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3205 .label = "share modes",
3208 .offset = LOCAL_VAR(bShareModes),
3211 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3214 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3217 .label = "ldap admin dn",
3219 .p_class = P_GLOBAL,
3220 .offset = GLOBAL_VAR(szLdapAdminDn),
3223 .flags = FLAG_ADVANCED,
3226 .label = "ldap delete dn",
3228 .p_class = P_GLOBAL,
3229 .offset = GLOBAL_VAR(ldap_delete_dn),
3232 .flags = FLAG_ADVANCED,
3235 .label = "ldap group suffix",
3237 .p_class = P_GLOBAL,
3238 .offset = GLOBAL_VAR(szLdapGroupSuffix),
3241 .flags = FLAG_ADVANCED,
3244 .label = "ldap idmap suffix",
3246 .p_class = P_GLOBAL,
3247 .offset = GLOBAL_VAR(szLdapIdmapSuffix),
3250 .flags = FLAG_ADVANCED,
3253 .label = "ldap machine suffix",
3255 .p_class = P_GLOBAL,
3256 .offset = GLOBAL_VAR(szLdapMachineSuffix),
3259 .flags = FLAG_ADVANCED,
3262 .label = "ldap passwd sync",
3264 .p_class = P_GLOBAL,
3265 .offset = GLOBAL_VAR(ldap_passwd_sync),
3267 .enum_list = enum_ldap_passwd_sync,
3268 .flags = FLAG_ADVANCED,
3271 .label = "ldap password sync",
3273 .p_class = P_GLOBAL,
3274 .offset = GLOBAL_VAR(ldap_passwd_sync),
3276 .enum_list = enum_ldap_passwd_sync,
3280 .label = "ldap replication sleep",
3282 .p_class = P_GLOBAL,
3283 .offset = GLOBAL_VAR(ldap_replication_sleep),
3286 .flags = FLAG_ADVANCED,
3289 .label = "ldap suffix",
3291 .p_class = P_GLOBAL,
3292 .offset = GLOBAL_VAR(szLdapSuffix),
3295 .flags = FLAG_ADVANCED,
3298 .label = "ldap ssl",
3300 .p_class = P_GLOBAL,
3301 .offset = GLOBAL_VAR(ldap_ssl),
3303 .enum_list = enum_ldap_ssl,
3304 .flags = FLAG_ADVANCED,
3307 .label = "ldap ssl ads",
3309 .p_class = P_GLOBAL,
3310 .offset = GLOBAL_VAR(ldap_ssl_ads),
3313 .flags = FLAG_ADVANCED,
3316 .label = "ldap deref",
3318 .p_class = P_GLOBAL,
3319 .offset = GLOBAL_VAR(ldap_deref),
3321 .enum_list = enum_ldap_deref,
3322 .flags = FLAG_ADVANCED,
3325 .label = "ldap follow referral",
3327 .p_class = P_GLOBAL,
3328 .offset = GLOBAL_VAR(ldap_follow_referral),
3330 .enum_list = enum_bool_auto,
3331 .flags = FLAG_ADVANCED,
3334 .label = "ldap timeout",
3336 .p_class = P_GLOBAL,
3337 .offset = GLOBAL_VAR(ldap_timeout),
3340 .flags = FLAG_ADVANCED,
3343 .label = "ldap connection timeout",
3345 .p_class = P_GLOBAL,
3346 .offset = GLOBAL_VAR(ldap_connection_timeout),
3349 .flags = FLAG_ADVANCED,
3352 .label = "ldap page size",
3354 .p_class = P_GLOBAL,
3355 .offset = GLOBAL_VAR(ldap_page_size),
3358 .flags = FLAG_ADVANCED,
3361 .label = "ldap user suffix",
3363 .p_class = P_GLOBAL,
3364 .offset = GLOBAL_VAR(szLdapUserSuffix),
3367 .flags = FLAG_ADVANCED,
3370 .label = "ldap debug level",
3372 .p_class = P_GLOBAL,
3373 .offset = GLOBAL_VAR(ldap_debug_level),
3374 .special = handle_ldap_debug_level,
3376 .flags = FLAG_ADVANCED,
3379 .label = "ldap debug threshold",
3381 .p_class = P_GLOBAL,
3382 .offset = GLOBAL_VAR(ldap_debug_threshold),
3385 .flags = FLAG_ADVANCED,
3388 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3391 .label = "eventlog list",
3393 .p_class = P_GLOBAL,
3394 .offset = GLOBAL_VAR(szEventLogs),
3397 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3400 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3403 .label = "add share command",
3405 .p_class = P_GLOBAL,
3406 .offset = GLOBAL_VAR(szAddShareCommand),
3409 .flags = FLAG_ADVANCED,
3412 .label = "change share command",
3414 .p_class = P_GLOBAL,
3415 .offset = GLOBAL_VAR(szChangeShareCommand),
3418 .flags = FLAG_ADVANCED,
3421 .label = "delete share command",
3423 .p_class = P_GLOBAL,
3424 .offset = GLOBAL_VAR(szDeleteShareCommand),
3427 .flags = FLAG_ADVANCED,
3430 .label = "config file",
3432 .p_class = P_GLOBAL,
3433 .offset = GLOBAL_VAR(szConfigFile),
3436 .flags = FLAG_HIDE|FLAG_META,
3441 .p_class = P_GLOBAL,
3442 .offset = GLOBAL_VAR(szAutoServices),
3445 .flags = FLAG_ADVANCED,
3448 .label = "auto services",
3450 .p_class = P_GLOBAL,
3451 .offset = GLOBAL_VAR(szAutoServices),
3454 .flags = FLAG_ADVANCED,
3457 .label = "lock directory",
3459 .p_class = P_GLOBAL,
3460 .offset = GLOBAL_VAR(szLockDir),
3463 .flags = FLAG_ADVANCED,
3466 .label = "lock dir",
3468 .p_class = P_GLOBAL,
3469 .offset = GLOBAL_VAR(szLockDir),
3475 .label = "state directory",
3477 .p_class = P_GLOBAL,
3478 .offset = GLOBAL_VAR(szStateDir),
3481 .flags = FLAG_ADVANCED,
3484 .label = "cache directory",
3486 .p_class = P_GLOBAL,
3487 .offset = GLOBAL_VAR(szCacheDir),
3490 .flags = FLAG_ADVANCED,
3493 .label = "pid directory",
3495 .p_class = P_GLOBAL,
3496 .offset = GLOBAL_VAR(szPidDir),
3499 .flags = FLAG_ADVANCED,
3503 .label = "utmp directory",
3505 .p_class = P_GLOBAL,
3506 .offset = GLOBAL_VAR(szUtmpDir),
3509 .flags = FLAG_ADVANCED,
3512 .label = "wtmp directory",
3514 .p_class = P_GLOBAL,
3515 .offset = GLOBAL_VAR(szWtmpDir),
3518 .flags = FLAG_ADVANCED,
3523 .p_class = P_GLOBAL,
3524 .offset = GLOBAL_VAR(bUtmp),
3527 .flags = FLAG_ADVANCED,
3531 .label = "default service",
3533 .p_class = P_GLOBAL,
3534 .offset = GLOBAL_VAR(szDefaultService),
3537 .flags = FLAG_ADVANCED,
3542 .p_class = P_GLOBAL,
3543 .offset = GLOBAL_VAR(szDefaultService),
3546 .flags = FLAG_ADVANCED,
3549 .label = "message command",
3551 .p_class = P_GLOBAL,
3552 .offset = GLOBAL_VAR(szMsgCommand),
3555 .flags = FLAG_ADVANCED,
3558 .label = "dfree cache time",
3561 .offset = LOCAL_VAR(iDfreeCacheTime),
3564 .flags = FLAG_ADVANCED,
3567 .label = "dfree command",
3570 .offset = LOCAL_VAR(szDfree),
3573 .flags = FLAG_ADVANCED,
3576 .label = "get quota command",
3578 .p_class = P_GLOBAL,
3579 .offset = GLOBAL_VAR(szGetQuota),
3582 .flags = FLAG_ADVANCED,
3585 .label = "set quota command",
3587 .p_class = P_GLOBAL,
3588 .offset = GLOBAL_VAR(szSetQuota),
3591 .flags = FLAG_ADVANCED,
3594 .label = "remote announce",
3596 .p_class = P_GLOBAL,
3597 .offset = GLOBAL_VAR(szRemoteAnnounce),
3600 .flags = FLAG_ADVANCED,
3603 .label = "remote browse sync",
3605 .p_class = P_GLOBAL,
3606 .offset = GLOBAL_VAR(szRemoteBrowseSync),
3609 .flags = FLAG_ADVANCED,
3612 .label = "socket address",
3614 .p_class = P_GLOBAL,
3615 .offset = GLOBAL_VAR(szSocketAddress),
3618 .flags = FLAG_ADVANCED,
3621 .label = "nmbd bind explicit broadcast",
3623 .p_class = P_GLOBAL,
3624 .offset = GLOBAL_VAR(bNmbdBindExplicitBroadcast),
3627 .flags = FLAG_ADVANCED,
3630 .label = "homedir map",
3632 .p_class = P_GLOBAL,
3633 .offset = GLOBAL_VAR(szNISHomeMapName),
3636 .flags = FLAG_ADVANCED,
3639 .label = "afs username map",
3641 .p_class = P_GLOBAL,
3642 .offset = GLOBAL_VAR(szAfsUsernameMap),
3645 .flags = FLAG_ADVANCED,
3648 .label = "afs token lifetime",
3650 .p_class = P_GLOBAL,
3651 .offset = GLOBAL_VAR(iAfsTokenLifetime),
3654 .flags = FLAG_ADVANCED,
3657 .label = "log nt token command",
3659 .p_class = P_GLOBAL,
3660 .offset = GLOBAL_VAR(szLogNtTokenCommand),
3663 .flags = FLAG_ADVANCED,
3666 .label = "NIS homedir",
3668 .p_class = P_GLOBAL,
3669 .offset = GLOBAL_VAR(bNISHomeMap),
3672 .flags = FLAG_ADVANCED,
3678 .offset = LOCAL_VAR(valid),
3687 .offset = LOCAL_VAR(szCopy),
3688 .special = handle_copy,
3696 .offset = LOCAL_VAR(szInclude),
3697 .special = handle_include,
3699 .flags = FLAG_HIDE|FLAG_META,
3705 .offset = LOCAL_VAR(szPreExec),
3708 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3714 .offset = LOCAL_VAR(szPreExec),
3717 .flags = FLAG_ADVANCED,
3720 .label = "preexec close",
3723 .offset = LOCAL_VAR(bPreexecClose),
3726 .flags = FLAG_ADVANCED | FLAG_SHARE,
3729 .label = "postexec",
3732 .offset = LOCAL_VAR(szPostExec),
3735 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3738 .label = "root preexec",
3741 .offset = LOCAL_VAR(szRootPreExec),
3744 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3747 .label = "root preexec close",
3750 .offset = LOCAL_VAR(bRootpreexecClose),
3753 .flags = FLAG_ADVANCED | FLAG_SHARE,
3756 .label = "root postexec",
3759 .offset = LOCAL_VAR(szRootPostExec),
3762 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3765 .label = "available",
3768 .offset = LOCAL_VAR(bAvailable),
3771 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3774 .label = "registry shares",
3776 .p_class = P_GLOBAL,
3777 .offset = GLOBAL_VAR(bRegistryShares),
3780 .flags = FLAG_ADVANCED,
3783 .label = "usershare allow guests",
3785 .p_class = P_GLOBAL,
3786 .offset = GLOBAL_VAR(bUsershareAllowGuests),
3789 .flags = FLAG_ADVANCED,
3792 .label = "usershare max shares",
3794 .p_class = P_GLOBAL,
3795 .offset = GLOBAL_VAR(iUsershareMaxShares),
3798 .flags = FLAG_ADVANCED,
3801 .label = "usershare owner only",
3803 .p_class = P_GLOBAL,
3804 .offset = GLOBAL_VAR(bUsershareOwnerOnly),
3807 .flags = FLAG_ADVANCED,
3810 .label = "usershare path",
3812 .p_class = P_GLOBAL,
3813 .offset = GLOBAL_VAR(szUsersharePath),
3816 .flags = FLAG_ADVANCED,
3819 .label = "usershare prefix allow list",
3821 .p_class = P_GLOBAL,
3822 .offset = GLOBAL_VAR(szUsersharePrefixAllowList),
3825 .flags = FLAG_ADVANCED,
3828 .label = "usershare prefix deny list",
3830 .p_class = P_GLOBAL,
3831 .offset = GLOBAL_VAR(szUsersharePrefixDenyList),
3834 .flags = FLAG_ADVANCED,
3837 .label = "usershare template share",
3839 .p_class = P_GLOBAL,
3840 .offset = GLOBAL_VAR(szUsershareTemplateShare),
3843 .flags = FLAG_ADVANCED,
3849 .offset = LOCAL_VAR(volume),
3852 .flags = FLAG_ADVANCED | FLAG_SHARE,
3858 .offset = LOCAL_VAR(fstype),
3861 .flags = FLAG_ADVANCED | FLAG_SHARE,
3864 .label = "set directory",
3867 .offset = LOCAL_VAR(bNo_set_dir),
3870 .flags = FLAG_ADVANCED | FLAG_SHARE,
3873 .label = "allow insecure wide links",
3875 .p_class = P_GLOBAL,
3876 .offset = GLOBAL_VAR(bAllowInsecureWidelinks),
3879 .flags = FLAG_ADVANCED,
3882 .label = "wide links",
3885 .offset = LOCAL_VAR(bWidelinks),
3888 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3891 .label = "follow symlinks",
3894 .offset = LOCAL_VAR(bSymlinks),
3897 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3900 .label = "dont descend",
3903 .offset = LOCAL_VAR(szDontdescend),
3906 .flags = FLAG_ADVANCED | FLAG_SHARE,
3909 .label = "magic script",
3912 .offset = LOCAL_VAR(szMagicScript),
3915 .flags = FLAG_ADVANCED | FLAG_SHARE,
3918 .label = "magic output",
3921 .offset = LOCAL_VAR(szMagicOutput),
3924 .flags = FLAG_ADVANCED | FLAG_SHARE,
3927 .label = "delete readonly",
3930 .offset = LOCAL_VAR(bDeleteReadonly),
3933 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3936 .label = "dos filemode",
3939 .offset = LOCAL_VAR(bDosFilemode),
3942 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3945 .label = "dos filetimes",
3948 .offset = LOCAL_VAR(bDosFiletimes),
3951 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3954 .label = "dos filetime resolution",
3957 .offset = LOCAL_VAR(bDosFiletimeResolution),
3960 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3963 .label = "fake directory create times",
3966 .offset = LOCAL_VAR(bFakeDirCreateTimes),
3969 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3972 .label = "async smb echo handler",
3974 .p_class = P_GLOBAL,
3975 .offset = GLOBAL_VAR(bAsyncSMBEchoHandler),
3978 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3981 .label = "multicast dns register",
3983 .p_class = P_GLOBAL,
3984 .offset = GLOBAL_VAR(bMulticastDnsRegister),
3987 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3990 .label = "panic action",
3992 .p_class = P_GLOBAL,
3993 .offset = GLOBAL_VAR(szPanicAction),
3996 .flags = FLAG_ADVANCED,
3999 .label = "perfcount module",
4001 .p_class = P_GLOBAL,
4002 .offset = GLOBAL_VAR(szSMBPerfcountModule),
4005 .flags = FLAG_ADVANCED,
4008 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4011 .label = "vfs objects",
4014 .offset = LOCAL_VAR(szVfsObjects),
4017 .flags = FLAG_ADVANCED | FLAG_SHARE,
4020 .label = "vfs object",
4023 .offset = LOCAL_VAR(szVfsObjects),
4030 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4033 .label = "msdfs root",
4036 .offset = LOCAL_VAR(bMSDfsRoot),
4039 .flags = FLAG_ADVANCED | FLAG_SHARE,
4042 .label = "msdfs proxy",
4045 .offset = LOCAL_VAR(szMSDfsProxy),
4048 .flags = FLAG_ADVANCED | FLAG_SHARE,
4051 .label = "host msdfs",
4053 .p_class = P_GLOBAL,
4054 .offset = GLOBAL_VAR(bHostMSDfs),
4057 .flags = FLAG_ADVANCED,
4060 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4063 .label = "passdb expand explicit",
4065 .p_class = P_GLOBAL,
4066 .offset = GLOBAL_VAR(bPassdbExpandExplicit),
4069 .flags = FLAG_ADVANCED,
4072 .label = "idmap backend",
4074 .p_class = P_GLOBAL,
4075 .offset = GLOBAL_VAR(szIdmapBackend),
4076 .special = handle_idmap_backend,
4078 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4081 .label = "idmap cache time",
4083 .p_class = P_GLOBAL,
4084 .offset = GLOBAL_VAR(iIdmapCacheTime),
4087 .flags = FLAG_ADVANCED,
4090 .label = "idmap negative cache time",
4092 .p_class = P_GLOBAL,
4093 .offset = GLOBAL_VAR(iIdmapNegativeCacheTime),
4096 .flags = FLAG_ADVANCED,
4099 .label = "idmap uid",
4101 .p_class = P_GLOBAL,
4102 .offset = GLOBAL_VAR(szIdmapUID),
4103 .special = handle_idmap_uid,
4105 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4108 .label = "winbind uid",
4110 .p_class = P_GLOBAL,
4111 .offset = GLOBAL_VAR(szIdmapUID),
4112 .special = handle_idmap_uid,
4117 .label = "idmap gid",
4119 .p_class = P_GLOBAL,
4120 .offset = GLOBAL_VAR(szIdmapGID),
4121 .special = handle_idmap_gid,
4123 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4126 .label = "winbind gid",
4128 .p_class = P_GLOBAL,
4129 .offset = GLOBAL_VAR(szIdmapGID),
4130 .special = handle_idmap_gid,
4135 .label = "template homedir",
4137 .p_class = P_GLOBAL,
4138 .offset = GLOBAL_VAR(szTemplateHomedir),
4141 .flags = FLAG_ADVANCED,
4144 .label = "template shell",
4146 .p_class = P_GLOBAL,
4147 .offset = GLOBAL_VAR(szTemplateShell),
4150 .flags = FLAG_ADVANCED,
4153 .label = "winbind separator",
4155 .p_class = P_GLOBAL,
4156 .offset = GLOBAL_VAR(szWinbindSeparator),
4159 .flags = FLAG_ADVANCED,
4162 .label = "winbind cache time",
4164 .p_class = P_GLOBAL,
4165 .offset = GLOBAL_VAR(winbind_cache_time),
4168 .flags = FLAG_ADVANCED,
4171 .label = "winbind reconnect delay",
4173 .p_class = P_GLOBAL,
4174 .offset = GLOBAL_VAR(winbind_reconnect_delay),
4177 .flags = FLAG_ADVANCED,
4180 .label = "winbind max clients",
4182 .p_class = P_GLOBAL,
4183 .offset = GLOBAL_VAR(winbind_max_clients),
4186 .flags = FLAG_ADVANCED,
4189 .label = "winbind enum users",
4191 .p_class = P_GLOBAL,
4192 .offset = GLOBAL_VAR(bWinbindEnumUsers),
4195 .flags = FLAG_ADVANCED,
4198 .label = "winbind enum groups",
4200 .p_class = P_GLOBAL,
4201 .offset = GLOBAL_VAR(bWinbindEnumGroups),
4204 .flags = FLAG_ADVANCED,
4207 .label = "winbind use default domain",
4209 .p_class = P_GLOBAL,
4210 .offset = GLOBAL_VAR(bWinbindUseDefaultDomain),
4213 .flags = FLAG_ADVANCED,
4216 .label = "winbind trusted domains only",
4218 .p_class = P_GLOBAL,
4219 .offset = GLOBAL_VAR(bWinbindTrustedDomainsOnly),
4222 .flags = FLAG_ADVANCED,
4225 .label = "winbind nested groups",
4227 .p_class = P_GLOBAL,
4228 .offset = GLOBAL_VAR(bWinbindNestedGroups),
4231 .flags = FLAG_ADVANCED,
4234 .label = "winbind expand groups",
4236 .p_class = P_GLOBAL,
4237 .offset = GLOBAL_VAR(winbind_expand_groups),
4240 .flags = FLAG_ADVANCED,
4243 .label = "winbind nss info",
4245 .p_class = P_GLOBAL,
4246 .offset = GLOBAL_VAR(szWinbindNssInfo),
4249 .flags = FLAG_ADVANCED,
4252 .label = "winbind refresh tickets",
4254 .p_class = P_GLOBAL,
4255 .offset = GLOBAL_VAR(bWinbindRefreshTickets),
4258 .flags = FLAG_ADVANCED,
4261 .label = "winbind offline logon",
4263 .p_class = P_GLOBAL,
4264 .offset = GLOBAL_VAR(bWinbindOfflineLogon),
4267 .flags = FLAG_ADVANCED,
4270 .label = "winbind normalize names",
4272 .p_class = P_GLOBAL,
4273 .offset = GLOBAL_VAR(bWinbindNormalizeNames),
4276 .flags = FLAG_ADVANCED,
4279 .label = "winbind rpc only",
4281 .p_class = P_GLOBAL,
4282 .offset = GLOBAL_VAR(bWinbindRpcOnly),
4285 .flags = FLAG_ADVANCED,
4288 .label = "create krb5 conf",
4290 .p_class = P_GLOBAL,
4291 .offset = GLOBAL_VAR(bCreateKrb5Conf),
4294 .flags = FLAG_ADVANCED,
4297 .label = "ncalrpc dir",
4299 .p_class = P_GLOBAL,
4300 .offset = GLOBAL_VAR(ncalrpc_dir),
4303 .flags = FLAG_ADVANCED,
4306 .label = "winbind max domain connections",
4308 .p_class = P_GLOBAL,
4309 .offset = GLOBAL_VAR(winbindMaxDomainConnections),
4312 .flags = FLAG_ADVANCED,
4315 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
4318 /***************************************************************************
4319 Initialise the sDefault parameter structure for the printer values.
4320 ***************************************************************************/
4322 static void init_printer_values(struct loadparm_service *pService)
4324 /* choose defaults depending on the type of printing */
4325 switch (pService->iPrinting) {
4330 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4331 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4332 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4337 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4338 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4339 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4340 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4341 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4342 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4343 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4349 /* set the lpq command to contain the destination printer
4350 name only. This is used by cups_queue_get() */
4351 string_set(&pService->szLpqcommand, "%p");
4352 string_set(&pService->szLprmcommand, "");
4353 string_set(&pService->szPrintcommand, "");
4354 string_set(&pService->szLppausecommand, "");
4355 string_set(&pService->szLpresumecommand, "");
4356 string_set(&pService->szQueuepausecommand, "");
4357 string_set(&pService->szQueueresumecommand, "");
4359 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4360 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4361 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4362 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4363 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4364 string_set(&pService->szQueuepausecommand, "disable '%p'");
4365 string_set(&pService->szQueueresumecommand, "enable '%p'");
4366 #endif /* HAVE_CUPS */
4371 string_set(&pService->szLpqcommand, "lpstat -o%p");
4372 string_set(&pService->szLprmcommand, "cancel %p-%j");
4373 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4374 string_set(&pService->szQueuepausecommand, "disable %p");
4375 string_set(&pService->szQueueresumecommand, "enable %p");
4377 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4378 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4383 string_set(&pService->szLpqcommand, "lpq -P%p");
4384 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4385 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4388 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
4392 const char *tdbfile;
4395 tdbfile = talloc_asprintf(
4396 talloc_tos(), "tdbfile=%s",
4397 lp_parm_const_string(-1, "vlp", "tdbfile",
4399 if (tdbfile == NULL) {
4400 tdbfile="tdbfile=/tmp/vlp.tdb";
4403 tmp = talloc_asprintf(talloc_tos(), "vlp %s print %%p %%s",
4405 string_set(&pService->szPrintcommand,
4406 tmp ? tmp : "vlp print %p %s");
4409 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpq %%p",
4411 string_set(&pService->szLpqcommand,
4412 tmp ? tmp : "vlp lpq %p");
4415 tmp = talloc_asprintf(talloc_tos(), "vlp %s lprm %%p %%j",
4417 string_set(&pService->szLprmcommand,
4418 tmp ? tmp : "vlp lprm %p %j");
4421 tmp = talloc_asprintf(talloc_tos(), "vlp %s lppause %%p %%j",
4423 string_set(&pService->szLppausecommand,
4424 tmp ? tmp : "vlp lppause %p %j");
4427 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpresume %%p %%j",
4429 string_set(&pService->szLpresumecommand,
4430 tmp ? tmp : "vlp lpresume %p %j");
4433 tmp = talloc_asprintf(talloc_tos(), "vlp %s queuepause %%p",
4435 string_set(&pService->szQueuepausecommand,
4436 tmp ? tmp : "vlp queuepause %p");
4439 tmp = talloc_asprintf(talloc_tos(), "vlp %s queueresume %%p",
4441 string_set(&pService->szQueueresumecommand,
4442 tmp ? tmp : "vlp queueresume %p");
4447 #endif /* DEVELOPER */
4452 * Function to return the default value for the maximum number of open
4453 * file descriptors permitted. This function tries to consult the
4454 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4455 * the smaller of those.
4457 static int max_open_files(void)
4459 int sysctl_max = MAX_OPEN_FILES;
4460 int rlimit_max = MAX_OPEN_FILES;
4462 #ifdef HAVE_SYSCTLBYNAME
4464 size_t size = sizeof(sysctl_max);
4465 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4470 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4476 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4477 rlimit_max = rl.rlim_cur;
4479 #if defined(RLIM_INFINITY)
4480 if(rl.rlim_cur == RLIM_INFINITY)
4481 rlimit_max = MAX_OPEN_FILES;
4486 if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4487 DEBUG(2,("max_open_files: increasing sysctl_max (%d) to "
4488 "minimum Windows limit (%d)\n",
4490 MIN_OPEN_FILES_WINDOWS));
4491 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4494 if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4495 DEBUG(2,("rlimit_max: increasing rlimit_max (%d) to "
4496 "minimum Windows limit (%d)\n",
4498 MIN_OPEN_FILES_WINDOWS));
4499 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4502 return MIN(sysctl_max, rlimit_max);
4506 * Common part of freeing allocated data for one parameter.
4508 static void free_one_parameter_common(void *parm_ptr,
4509 struct parm_struct parm)
4511 if ((parm.type == P_STRING) ||
4512 (parm.type == P_USTRING))
4514 string_free((char**)parm_ptr);
4515 } else if (parm.type == P_LIST) {
4516 TALLOC_FREE(*((char***)parm_ptr));
4521 * Free the allocated data for one parameter for a share
4522 * given as a service struct.
4524 static void free_one_parameter(struct loadparm_service *service,
4525 struct parm_struct parm)
4529 if (parm.p_class != P_LOCAL) {
4533 parm_ptr = lp_parm_ptr(service, &parm);
4535 free_one_parameter_common(parm_ptr, parm);
4539 * Free the allocated parameter data of a share given
4540 * as a service struct.
4542 static void free_parameters(struct loadparm_service *service)
4546 for (i=0; parm_table[i].label; i++) {
4547 free_one_parameter(service, parm_table[i]);
4552 * Free the allocated data for one parameter for a given share
4553 * specified by an snum.
4555 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4560 parm_ptr = lp_parm_ptr(NULL, &parm);
4561 } else if (parm.p_class != P_LOCAL) {
4564 parm_ptr = lp_local_ptr_by_snum(snum, &parm);
4567 free_one_parameter_common(parm_ptr, parm);
4571 * Free the allocated parameter data for a share specified
4574 static void free_parameters_by_snum(int snum)
4578 for (i=0; parm_table[i].label; i++) {
4579 free_one_parameter_by_snum(snum, parm_table[i]);
4584 * Free the allocated global parameters.
4586 static void free_global_parameters(void)
4588 free_param_opts(&Globals.param_opt);
4589 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4592 static int map_parameter(const char *pszParmName);
4594 struct lp_stored_option {
4595 struct lp_stored_option *prev, *next;
4600 static struct lp_stored_option *stored_options;
4603 save options set by lp_set_cmdline() into a list. This list is
4604 re-applied when we do a globals reset, so that cmdline set options
4605 are sticky across reloads of smb.conf
4607 static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
4609 struct lp_stored_option *entry, *entry_next;
4610 for (entry = stored_options; entry != NULL; entry = entry_next) {
4611 entry_next = entry->next;
4612 if (strcmp(pszParmName, entry->label) == 0) {
4613 DLIST_REMOVE(stored_options, entry);
4619 entry = talloc(NULL, struct lp_stored_option);
4624 entry->label = talloc_strdup(entry, pszParmName);
4625 if (!entry->label) {
4630 entry->value = talloc_strdup(entry, pszParmValue);
4631 if (!entry->value) {
4636 DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
4641 static bool apply_lp_set_cmdline(void)
4643 struct lp_stored_option *entry = NULL;
4644 for (entry = stored_options; entry != NULL; entry = entry->next) {
4645 if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
4646 DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
4647 entry->label, entry->value));
4654 /***************************************************************************
4655 Initialise the global parameter structure.
4656 ***************************************************************************/
4658 static void init_globals(bool reinit_globals)
4660 static bool done_init = false;
4664 /* If requested to initialize only once and we've already done it... */
4665 if (!reinit_globals && done_init) {
4666 /* ... then we have nothing more to do */
4671 /* The logfile can be set before this is invoked. Free it if so. */
4672 if (Globals.logfile != NULL) {
4673 string_free(&Globals.logfile);
4674 Globals.logfile = NULL;
4678 free_global_parameters();
4681 /* This memset and the free_global_parameters() above will
4682 * wipe out smb.conf options set with lp_set_cmdline(). The
4683 * apply_lp_set_cmdline() call puts these values back in the
4684 * table once the defaults are set */
4685 ZERO_STRUCT(Globals);
4687 for (i = 0; parm_table[i].label; i++) {
4688 if ((parm_table[i].type == P_STRING ||
4689 parm_table[i].type == P_USTRING))
4691 string_set((char **)lp_parm_ptr(NULL, &parm_table[i]), "");
4696 string_set(&sDefault.fstype, FSTYPE_STRING);
4697 string_set(&sDefault.szPrintjobUsername, "%U");
4699 init_printer_values(&sDefault);
4702 DEBUG(3, ("Initialising global parameters\n"));
4704 /* Must manually force to upper case here, as this does not go via the handler */
4705 string_set(&Globals.szNetbiosName, myhostname_upper());
4707 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4708 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4710 /* use the new 'hash2' method by default, with a prefix of 1 */
4711 string_set(&Globals.szManglingMethod, "hash2");
4712 Globals.mangle_prefix = 1;
4714 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4716 /* using UTF8 by default allows us to support all chars */
4717 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4719 /* Use codepage 850 as a default for the dos character set */
4720 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4723 * Allow the default PASSWD_CHAT to be overridden in local.h.
4725 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4727 string_set(&Globals.szWorkgroup, DEFAULT_WORKGROUP);
4729 string_set(&Globals.szPasswdProgram, "");
4730 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4731 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4732 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4733 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4734 string_set(&Globals.szSocketAddress, "0.0.0.0");
4736 * By default support explicit binding to broadcast
4739 Globals.bNmbdBindExplicitBroadcast = true;
4741 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4742 smb_panic("init_globals: ENOMEM");
4744 string_set(&Globals.szServerString, s);
4747 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4750 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
4752 string_set(&Globals.szLogonDrive, "");
4753 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4754 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4755 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4757 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
4758 string_set(&Globals.szPasswordServer, "*");
4760 Globals.AlgorithmicRidBase = BASE_RID;
4762 Globals.bLoadPrinters = true;
4763 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4765 Globals.ConfigBackend = config_backend;
4766 Globals.ServerRole = ROLE_AUTO;
4768 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4769 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4770 Globals.max_xmit = 0x4104;
4771 Globals.max_mux = 50; /* This is *needed* for profile support. */
4772 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4773 Globals.bDisableSpoolss = false;
4774 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4775 Globals.pwordlevel = 0;
4776 Globals.unamelevel = 0;
4777 Globals.deadtime = 0;
4778 Globals.getwd_cache = true;
4779 Globals.bLargeReadwrite = true;
4780 Globals.max_log_size = 5000;
4781 Globals.max_open_files = max_open_files();
4782 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4783 Globals.srv_maxprotocol = PROTOCOL_SMB2_02;
4784 Globals.srv_minprotocol = PROTOCOL_CORE;
4785 Globals.security = SEC_USER;
4786 Globals.paranoid_server_security = true;
4787 Globals.bEncryptPasswords = true;
4788 Globals.clientSchannel = Auto;
4789 Globals.serverSchannel = Auto;
4790 Globals.bReadRaw = true;
4791 Globals.bWriteRaw = true;
4792 Globals.bNullPasswords = false;
4793 Globals.bObeyPamRestrictions = false;
4795 Globals.bSyslogOnly = false;
4796 Globals.bTimestampLogs = true;
4797 string_set(&Globals.szLogLevel, "0");
4798 Globals.bDebugPrefixTimestamp = false;
4799 Globals.bDebugHiresTimestamp = true;
4800 Globals.bDebugPid = false;
4801 Globals.bDebugUid = false;
4802 Globals.bDebugClass = false;
4803 Globals.bEnableCoreFiles = true;
4804 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4805 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4806 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4807 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4808 Globals.lm_announce = Auto; /* = Auto: send only if LM clients found */
4809 Globals.lm_interval = 60;
4810 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4811 Globals.bNISHomeMap = false;
4812 #ifdef WITH_NISPLUS_HOME
4813 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4815 string_set(&Globals.szNISHomeMapName, "auto.home");
4818 Globals.bTimeServer = false;
4819 Globals.bBindInterfacesOnly = false;
4820 Globals.bUnixPasswdSync = false;
4821 Globals.bPamPasswordChange = false;
4822 Globals.bPasswdChatDebug = false;
4823 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4824 Globals.bNTPipeSupport = true; /* Do NT pipes by default. */
4825 Globals.bNTStatusSupport = true; /* Use NT status by default. */
4826 Globals.bStatCache = true; /* use stat cache by default */
4827 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4828 Globals.restrict_anonymous = 0;
4829 Globals.bClientLanManAuth = false; /* Do NOT use the LanMan hash if it is available */
4830 Globals.bClientPlaintextAuth = false; /* Do NOT use a plaintext password even if is requested by the server */
4831 Globals.bLanmanAuth = false; /* Do NOT use the LanMan hash, even if it is supplied */
4832 Globals.bNTLMAuth = true; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4833 Globals.bClientNTLMv2Auth = true; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
4834 /* Note, that we will also use NTLM2 session security (which is different), if it is available */
4836 Globals.map_to_guest = 0; /* By Default, "Never" */
4837 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4838 Globals.enhanced_browsing = true;
4839 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4840 #ifdef MMAP_BLACKLIST
4841 Globals.bUseMmap = false;
4843 Globals.bUseMmap = true;
4845 Globals.bUnixExtensions = true;
4846 Globals.bResetOnZeroVC = false;
4847 Globals.bLogWriteableFilesOnExit = false;
4848 Globals.bCreateKrb5Conf = true;
4849 Globals.winbindMaxDomainConnections = 1;
4851 /* hostname lookups can be very expensive and are broken on
4852 a large number of sites (tridge) */
4853 Globals.bHostnameLookups = false;
4855 string_set(&Globals.szPassdbBackend, "tdbsam");
4856 string_set(&Globals.szLdapSuffix, "");
4857 string_set(&Globals.szLdapMachineSuffix, "");
4858 string_set(&Globals.szLdapUserSuffix, "");
4859 string_set(&Globals.szLdapGroupSuffix, "");
4860 string_set(&Globals.szLdapIdmapSuffix, "");
4862 string_set(&Globals.szLdapAdminDn, "");
4863 Globals.ldap_ssl = LDAP_SSL_START_TLS;
4864 Globals.ldap_ssl_ads = false;
4865 Globals.ldap_deref = -1;
4866 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
4867 Globals.ldap_delete_dn = false;
4868 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
4869 Globals.ldap_follow_referral = Auto;
4870 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
4871 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
4872 Globals.ldap_page_size = LDAP_PAGE_SIZE;
4874 Globals.ldap_debug_level = 0;
4875 Globals.ldap_debug_threshold = 10;
4877 /* This is what we tell the afs client. in reality we set the token
4878 * to never expire, though, when this runs out the afs client will
4879 * forget the token. Set to 0 to get NEVERDATE.*/
4880 Globals.iAfsTokenLifetime = 604800;
4881 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
4883 /* these parameters are set to defaults that are more appropriate
4884 for the increasing samba install base:
4886 as a member of the workgroup, that will possibly become a
4887 _local_ master browser (lm = true). this is opposed to a forced
4888 local master browser startup (pm = true).
4890 doesn't provide WINS server service by default (wsupp = false),
4891 and doesn't provide domain master browser services by default, either.
4895 Globals.bMsAddPrinterWizard = true;
4896 Globals.os_level = 20;
4897 Globals.bLocalMaster = true;
4898 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
4899 Globals.bDomainLogons = false;
4900 Globals.bBrowseList = true;
4901 Globals.bWINSsupport = false;
4902 Globals.bWINSproxy = false;
4904 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
4905 Globals.InitLogonDelay = 100; /* 100 ms default delay */
4907 Globals.bWINSdnsProxy = true;
4909 Globals.bAllowTrustedDomains = true;
4910 string_set(&Globals.szIdmapBackend, "tdb");
4912 string_set(&Globals.szTemplateShell, "/bin/false");
4913 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
4914 string_set(&Globals.szWinbindSeparator, "\\");
4916 string_set(&Globals.szCupsServer, "");
4917 string_set(&Globals.szIPrintServer, "");
4919 string_set(&Globals.ctdbdSocket, "");
4920 Globals.szClusterAddresses = NULL;
4921 Globals.clustering = false;
4922 Globals.ctdb_timeout = 0;
4923 Globals.ctdb_locktime_warn_threshold = 0;
4925 Globals.winbind_cache_time = 300; /* 5 minutes */
4926 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
4927 Globals.winbind_max_clients = 200;
4928 Globals.bWinbindEnumUsers = false;
4929 Globals.bWinbindEnumGroups = false;
4930 Globals.bWinbindUseDefaultDomain = false;
4931 Globals.bWinbindTrustedDomainsOnly = false;
4932 Globals.bWinbindNestedGroups = true;
4933 Globals.winbind_expand_groups = 1;
4934 Globals.szWinbindNssInfo = (const char **)str_list_make_v3(NULL, "template", NULL);
4935 Globals.bWinbindRefreshTickets = false;
4936 Globals.bWinbindOfflineLogon = false;
4938 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
4939 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
4941 Globals.bPassdbExpandExplicit = false;
4943 Globals.name_cache_timeout = 660; /* In seconds */
4945 Globals.bUseSpnego = true;
4946 Globals.bClientUseSpnego = true;
4948 Globals.client_signing = SMB_SIGNING_DEFAULT;
4949 Globals.server_signing = SMB_SIGNING_DEFAULT;
4951 Globals.bDeferSharingViolations = true;
4952 string_set(&Globals.smb_ports, SMB_PORTS);
4954 Globals.bEnablePrivileges = true;
4955 Globals.bHostMSDfs = true;
4956 Globals.bASUSupport = false;
4958 /* User defined shares. */
4959 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
4960 smb_panic("init_globals: ENOMEM");
4962 string_set(&Globals.szUsersharePath, s);
4964 string_set(&Globals.szUsershareTemplateShare, "");
4965 Globals.iUsershareMaxShares = 0;
4966 /* By default disallow sharing of directories not owned by the sharer. */
4967 Globals.bUsershareOwnerOnly = true;
4968 /* By default disallow guest access to usershares. */
4969 Globals.bUsershareAllowGuests = false;
4971 Globals.iKeepalive = DEFAULT_KEEPALIVE;
4973 /* By default no shares out of the registry */
4974 Globals.bRegistryShares = false;
4976 Globals.iminreceivefile = 0;
4978 Globals.bMapUntrustedToDomain = false;
4979 Globals.bMulticastDnsRegister = true;
4981 Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ;
4982 Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE;
4983 Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT;
4984 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
4986 string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
4988 /* Now put back the settings that were set with lp_set_cmdline() */
4989 apply_lp_set_cmdline();
4992 /*******************************************************************
4993 Convenience routine to grab string parameters into temporary memory
4994 and run standard_sub_basic on them. The buffers can be written to by
4995 callers without affecting the source string.
4996 ********************************************************************/
4998 static char *lp_string(const char *s)
5001 TALLOC_CTX *ctx = talloc_tos();
5003 /* The follow debug is useful for tracking down memory problems
5004 especially if you have an inner loop that is calling a lp_*()
5005 function that returns a string. Perhaps this debug should be
5006 present all the time? */
5009 DEBUG(10, ("lp_string(%s)\n", s));
5015 ret = talloc_sub_basic(ctx,
5016 get_current_username(),
5017 current_user_info.domain,
5019 if (trim_char(ret, '\"', '\"')) {
5020 if (strchr(ret,'\"') != NULL) {
5022 ret = talloc_sub_basic(ctx,
5023 get_current_username(),
5024 current_user_info.domain,
5032 In this section all the functions that are used to access the
5033 parameters from the rest of the program are defined
5036 #define FN_GLOBAL_STRING(fn_name,ptr) \
5037 char *lp_ ## fn_name(void) {return(lp_string(*(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : ""));}
5038 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5039 const char *lp_ ## fn_name(void) {return(*(const char **)(&Globals.ptr) ? *(const char **)(&Globals.ptr) : "");}
5040 #define FN_GLOBAL_LIST(fn_name,ptr) \
5041 const char **lp_ ## fn_name(void) {return(*(const char ***)(&Globals.ptr));}
5042 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5043 bool lp_ ## fn_name(void) {return(*(bool *)(&Globals.ptr));}
5044 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5045 char lp_ ## fn_name(void) {return(*(char *)(&Globals.ptr));}
5046 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5047 int lp_ ## fn_name(void) {return(*(int *)(&Globals.ptr));}
5049 #define FN_LOCAL_STRING(fn_name,val) \
5050 char *lp_ ## fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5051 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5052 const char *lp_ ## fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5053 #define FN_LOCAL_LIST(fn_name,val) \
5054 const char **lp_ ## fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5055 #define FN_LOCAL_BOOL(fn_name,val) \
5056 bool lp_ ## fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5057 #define FN_LOCAL_INTEGER(fn_name,val) \
5058 int lp_ ## fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5060 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5061 bool lp_ ## fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5062 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5063 int lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5064 #define FN_LOCAL_CHAR(fn_name,val) \
5065 char lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5067 FN_GLOBAL_BOOL(allow_insecure_widelinks, bAllowInsecureWidelinks)
5068 FN_GLOBAL_BOOL(allow_trusted_domains, bAllowTrustedDomains)
5069 FN_GLOBAL_BOOL(async_smb_echo_handler, bAsyncSMBEchoHandler)
5070 FN_GLOBAL_BOOL(bind_interfaces_only, bBindInterfacesOnly)
5071 FN_GLOBAL_BOOL(browse_list, bBrowseList)
5072 FN_GLOBAL_BOOL(client_lanman_auth, bClientLanManAuth)
5073 FN_GLOBAL_BOOL(client_ntlmv2_auth, bClientNTLMv2Auth)
5074 FN_GLOBAL_BOOL(client_plaintext_auth, bClientPlaintextAuth)
5075 FN_GLOBAL_BOOL(client_use_spnego, bClientUseSpnego)
5076 FN_GLOBAL_BOOL(client_use_spnego_principal, client_use_spnego_principal)
5077 FN_GLOBAL_BOOL(clustering, clustering)
5078 FN_GLOBAL_BOOL(create_krb5_conf, bCreateKrb5Conf)
5079 FN_GLOBAL_BOOL(debug_class, bDebugClass)
5080 FN_GLOBAL_BOOL(debug_hires_timestamp, bDebugHiresTimestamp)
5081 FN_GLOBAL_BOOL(debug_pid, bDebugPid)
5082 FN_GLOBAL_BOOL(debug_prefix_timestamp, bDebugPrefixTimestamp)
5083 FN_GLOBAL_BOOL(debug_uid, bDebugUid)
5084 FN_GLOBAL_BOOL(defer_sharing_violations, bDeferSharingViolations)
5085 FN_GLOBAL_BOOL(disable_netbios, bDisableNetbios)
5086 FN_GLOBAL_BOOL(_disable_spoolss, bDisableSpoolss)
5087 FN_GLOBAL_BOOL(dns_proxy, bWINSdnsProxy)
5088 FN_GLOBAL_BOOL(enable_asu_support, bASUSupport)
5089 FN_GLOBAL_BOOL(enable_core_files, bEnableCoreFiles)
5090 FN_GLOBAL_BOOL(enable_privileges, bEnablePrivileges)
5091 FN_GLOBAL_BOOL(encrypted_passwords, bEncryptPasswords)
5092 FN_GLOBAL_BOOL(enhanced_browsing, enhanced_browsing)
5093 FN_GLOBAL_BOOL(getwd_cache, getwd_cache)
5094 FN_GLOBAL_BOOL(host_msdfs, bHostMSDfs)
5095 FN_GLOBAL_BOOL(hostname_lookups, bHostnameLookups)
5096 FN_GLOBAL_BOOL(lanman_auth, bLanmanAuth)
5097 FN_GLOBAL_BOOL(large_readwrite, bLargeReadwrite)
5098 FN_GLOBAL_BOOL(ldap_delete_dn, ldap_delete_dn)
5099 FN_GLOBAL_BOOL(ldap_ssl_ads, ldap_ssl_ads)
5100 FN_GLOBAL_BOOL(load_printers, bLoadPrinters)
5101 FN_GLOBAL_BOOL(local_master, bLocalMaster)
5102 FN_GLOBAL_BOOL(log_writeable_files_on_exit, bLogWriteableFilesOnExit)
5103 FN_GLOBAL_BOOL(map_untrusted_to_domain, bMapUntrustedToDomain)
5104 FN_GLOBAL_BOOL(ms_add_printer_wizard, bMsAddPrinterWizard)
5105 FN_GLOBAL_BOOL(multicast_dns_register, bMulticastDnsRegister)
5106 FN_GLOBAL_BOOL(nis_home_map, bNISHomeMap)
5107 FN_GLOBAL_BOOL(nmbd_bind_explicit_broadcast, bNmbdBindExplicitBroadcast)
5108 FN_GLOBAL_BOOL(ntlm_auth, bNTLMAuth)
5109 FN_GLOBAL_BOOL(nt_pipe_support, bNTPipeSupport)
5110 FN_GLOBAL_BOOL(nt_status_support, bNTStatusSupport)
5111 FN_GLOBAL_BOOL(null_passwords, bNullPasswords)
5112 FN_GLOBAL_BOOL(obey_pam_restrictions, bObeyPamRestrictions)
5113 FN_GLOBAL_BOOL(pam_password_change, bPamPasswordChange)
5114 FN_GLOBAL_BOOL(paranoid_server_security, paranoid_server_security)
5115 FN_GLOBAL_BOOL(passdb_expand_explicit, bPassdbExpandExplicit)
5116 FN_GLOBAL_BOOL(passwd_chat_debug, bPasswdChatDebug)
5117 FN_GLOBAL_BOOL(registry_shares, bRegistryShares)
5118 FN_GLOBAL_BOOL(reset_on_zero_vc, bResetOnZeroVC)
5119 FN_GLOBAL_BOOL(stat_cache, bStatCache)
5120 FN_GLOBAL_BOOL(syslog_only, bSyslogOnly)
5121 FN_GLOBAL_BOOL(timestamp_logs, bTimestampLogs)
5122 FN_GLOBAL_BOOL(unix_extensions, bUnixExtensions)
5123 FN_GLOBAL_BOOL(unix_password_sync, bUnixPasswdSync)
5124 FN_GLOBAL_BOOL(use_mmap, bUseMmap)
5125 FN_GLOBAL_BOOL(usershare_allow_guests, bUsershareAllowGuests)
5126 FN_GLOBAL_BOOL(usershare_owner_only, bUsershareOwnerOnly)
5127 FN_GLOBAL_BOOL(use_spnego, bUseSpnego)
5128 FN_GLOBAL_BOOL(utmp, bUtmp)
5129 FN_GLOBAL_BOOL(we_are_a_wins_server, bWINSsupport)
5130 FN_GLOBAL_BOOL(winbind_enum_groups, bWinbindEnumGroups)
5131 FN_GLOBAL_BOOL(winbind_enum_users, bWinbindEnumUsers)
5132 FN_GLOBAL_BOOL(winbind_nested_groups, bWinbindNestedGroups)
5133 FN_GLOBAL_BOOL(winbind_normalize_names, bWinbindNormalizeNames)
5134 FN_GLOBAL_BOOL(winbind_offline_logon, bWinbindOfflineLogon)
5135 FN_GLOBAL_BOOL(winbind_refresh_tickets, bWinbindRefreshTickets)
5136 FN_GLOBAL_BOOL(winbind_rpc_only, bWinbindRpcOnly)
5137 FN_GLOBAL_BOOL(winbind_trusted_domains_only, bWinbindTrustedDomainsOnly)
5138 FN_GLOBAL_BOOL(winbind_use_default_domain, bWinbindUseDefaultDomain)
5139 FN_GLOBAL_BOOL(wins_proxy, bWINSproxy)
5140 FN_GLOBAL_CONST_STRING(afs_username_map, szAfsUsernameMap)
5141 FN_GLOBAL_CONST_STRING(dedicated_keytab_file, szDedicatedKeytabFile)
5142 FN_GLOBAL_CONST_STRING(dnsdomain, szDnsDomain)
5143 FN_GLOBAL_CONST_STRING(dos_charset, dos_charset)
5144 FN_GLOBAL_CONST_STRING(guestaccount, szGuestaccount)
5145 FN_GLOBAL_CONST_STRING(idmap_backend, szIdmapBackend)
5146 FN_GLOBAL_CONST_STRING(lockdir, szLockDir)
5147 FN_GLOBAL_CONST_STRING(logon_drive, szLogonDrive)
5148 FN_GLOBAL_CONST_STRING(logon_home, szLogonHome)
5149 FN_GLOBAL_CONST_STRING(logon_path, szLogonPath)
5150 FN_GLOBAL_CONST_STRING(logon_script, szLogonScript)
5151 FN_GLOBAL_CONST_STRING(name_resolve_order, szNameResolveOrder)
5152 FN_GLOBAL_CONST_STRING(ncalrpc_dir, ncalrpc_dir)
5153 FN_GLOBAL_CONST_STRING(netbios_name, szNetbiosName)
5154 FN_GLOBAL_CONST_STRING(netbios_scope, szNetbiosScope)
5155 FN_GLOBAL_CONST_STRING(passdb_backend, szPassdbBackend)
5156 FN_GLOBAL_CONST_STRING(passwordserver, szPasswordServer)
5157 FN_GLOBAL_CONST_STRING(piddir, szPidDir)
5158 FN_GLOBAL_CONST_STRING(private_dir, szPrivateDir)
5159 FN_GLOBAL_CONST_STRING(realm, szRealmUpper)
5160 FN_GLOBAL_CONST_STRING(smb_passwd_file, szSMBPasswdFile)
5161 FN_GLOBAL_CONST_STRING(smb_ports, smb_ports)
5162 FN_GLOBAL_CONST_STRING(socket_options, szSocketOptions)
5163 FN_GLOBAL_CONST_STRING(template_homedir, szTemplateHomedir)
5164 FN_GLOBAL_CONST_STRING(template_shell, szTemplateShell)
5165 FN_GLOBAL_CONST_STRING(unix_charset, unix_charset)
5166 FN_GLOBAL_CONST_STRING(utmpdir, szUtmpDir)
5167 FN_GLOBAL_CONST_STRING(winbind_separator, szWinbindSeparator)
5168 FN_GLOBAL_CONST_STRING(workgroup, szWorkgroup)
5169 FN_GLOBAL_CONST_STRING(wtmpdir, szWtmpDir)
5170 FN_GLOBAL_INTEGER(acl_compatibility, iAclCompat)
5171 FN_GLOBAL_INTEGER(afs_token_lifetime, iAfsTokenLifetime)
5172 FN_GLOBAL_INTEGER(algorithmic_rid_base, AlgorithmicRidBase)
5173 FN_GLOBAL_INTEGER(client_ldap_sasl_wrapping, client_ldap_sasl_wrapping)
5174 FN_GLOBAL_INTEGER(client_schannel, clientSchannel)
5175 FN_GLOBAL_INTEGER(client_signing, client_signing)
5176 FN_GLOBAL_INTEGER(config_backend, ConfigBackend)
5177 FN_GLOBAL_INTEGER(ctdb_locktime_warn_threshold, ctdb_locktime_warn_threshold)
5178 FN_GLOBAL_INTEGER(ctdb_timeout, ctdb_timeout)
5179 FN_GLOBAL_INTEGER(cups_connection_timeout, cups_connection_timeout)
5180 FN_GLOBAL_INTEGER(deadtime, deadtime)
5181 FN_GLOBAL_INTEGER(idmap_cache_time, iIdmapCacheTime)
5182 FN_GLOBAL_INTEGER(idmap_negative_cache_time, iIdmapNegativeCacheTime)
5183 FN_GLOBAL_INTEGER(init_logon_delay, InitLogonDelay)
5184 FN_GLOBAL_INTEGER(keepalive, iKeepalive)
5185 FN_GLOBAL_INTEGER(kerberos_method, iKerberosMethod)
5186 FN_GLOBAL_INTEGER(ldap_connection_timeout, ldap_connection_timeout)
5187 FN_GLOBAL_INTEGER(ldap_debug_level, ldap_debug_level)
5188 FN_GLOBAL_INTEGER(ldap_debug_threshold, ldap_debug_threshold)
5189 FN_GLOBAL_INTEGER(ldap_deref, ldap_deref)
5190 FN_GLOBAL_INTEGER(ldap_follow_referral, ldap_follow_referral)
5191 FN_GLOBAL_INTEGER(ldap_page_size, ldap_page_size)
5192 FN_GLOBAL_INTEGER(ldap_passwd_sync, ldap_passwd_sync)
5193 FN_GLOBAL_INTEGER(ldap_replication_sleep, ldap_replication_sleep)
5194 FN_GLOBAL_INTEGER(ldap_ssl, ldap_ssl)
5195 FN_GLOBAL_INTEGER(ldap_timeout, ldap_timeout)
5196 FN_GLOBAL_INTEGER(lm_announce, lm_announce)
5197 FN_GLOBAL_INTEGER(lm_interval, lm_interval)
5198 FN_GLOBAL_INTEGER(lock_spin_time, iLockSpinTime)
5199 FN_GLOBAL_INTEGER(lpqcachetime, lpqcachetime)
5200 FN_GLOBAL_INTEGER(machine_password_timeout, machine_password_timeout)
5201 FN_GLOBAL_INTEGER(mangle_prefix, mangle_prefix)
5202 FN_GLOBAL_INTEGER(map_to_guest, map_to_guest)
5203 FN_GLOBAL_INTEGER(maxdisksize, maxdisksize)
5204 FN_GLOBAL_INTEGER(max_log_size, max_log_size)
5205 FN_GLOBAL_INTEGER(maxmux, max_mux)
5206 FN_GLOBAL_INTEGER(max_open_files, max_open_files)
5207 FN_GLOBAL_INTEGER(max_smbd_processes, iMaxSmbdProcesses)
5208 FN_GLOBAL_INTEGER(max_stat_cache_size, iMaxStatCacheSize)
5209 FN_GLOBAL_INTEGER(max_ttl, max_ttl)
5210 FN_GLOBAL_INTEGER(max_wins_ttl, max_wins_ttl)
5211 FN_GLOBAL_INTEGER(maxxmit, max_xmit)
5212 FN_GLOBAL_INTEGER(min_wins_ttl, min_wins_ttl)
5213 FN_GLOBAL_INTEGER(name_cache_timeout, name_cache_timeout)
5214 FN_GLOBAL_INTEGER(open_files_db_hash_size, open_files_db_hash_size)
5215 FN_GLOBAL_INTEGER(oplock_break_wait_time, oplock_break_wait_time)
5216 FN_GLOBAL_INTEGER(os_level, os_level)
5217 FN_GLOBAL_INTEGER(passwd_chat_timeout, iPasswdChatTimeout)
5218 FN_GLOBAL_INTEGER(passwordlevel, pwordlevel)
5219 FN_GLOBAL_INTEGER(printcap_cache_time, PrintcapCacheTime)
5220 FN_GLOBAL_INTEGER(restrict_anonymous, restrict_anonymous)
5221 FN_GLOBAL_INTEGER(security, security)
5222 FN_GLOBAL_INTEGER(server_schannel, serverSchannel)
5223 FN_GLOBAL_INTEGER(server_signing, server_signing)
5224 FN_GLOBAL_INTEGER(smb2_max_read, ismb2_max_read)
5225 FN_GLOBAL_INTEGER(smb2_max_trans, ismb2_max_trans)
5226 FN_GLOBAL_INTEGER(smb2_max_write, ismb2_max_write)
5227 FN_GLOBAL_INTEGER(srv_maxprotocol, srv_maxprotocol)
5228 FN_GLOBAL_INTEGER(srv_minprotocol, srv_minprotocol)
5229 FN_GLOBAL_INTEGER(syslog, syslog)
5230 FN_GLOBAL_INTEGER(usernamelevel, unamelevel)
5231 FN_GLOBAL_INTEGER(username_map_cache_time, iUsernameMapCacheTime)
5232 FN_GLOBAL_INTEGER(usershare_max_shares, iUsershareMaxShares)
5233 FN_GLOBAL_INTEGER(winbind_cache_time, winbind_cache_time)
5234 FN_GLOBAL_INTEGER(winbind_expand_groups, winbind_expand_groups)
5235 FN_GLOBAL_INTEGER(winbind_max_clients, winbind_max_clients)
5236 FN_GLOBAL_INTEGER(winbind_reconnect_delay, winbind_reconnect_delay)
5237 FN_GLOBAL_LIST(auth_methods, AuthMethods)
5238 FN_GLOBAL_LIST(cluster_addresses, szClusterAddresses)
5239 FN_GLOBAL_LIST(eventlog_list, szEventLogs)
5240 FN_GLOBAL_LIST(init_logon_delayed_hosts, szInitLogonDelayedHosts)
5241 FN_GLOBAL_LIST(interfaces, szInterfaces)
5242 FN_GLOBAL_LIST(netbios_aliases, szNetbiosAliases)
5243 FN_GLOBAL_LIST(preload_modules, szPreloadModules)
5244 FN_GLOBAL_LIST(svcctl_list, szServicesList)
5245 FN_GLOBAL_LIST(usershare_prefix_allow_list, szUsersharePrefixAllowList)
5246 FN_GLOBAL_LIST(usershare_prefix_deny_list, szUsersharePrefixDenyList)
5247 FN_GLOBAL_LIST(winbind_nss_info, szWinbindNssInfo)
5248 FN_GLOBAL_LIST(wins_server_list, szWINSservers)
5249 FN_GLOBAL_STRING(abort_shutdown_script, szAbortShutdownScript)
5250 FN_GLOBAL_STRING(addgroup_script, szAddGroupScript)
5251 FN_GLOBAL_STRING(addmachine_script, szAddMachineScript)
5252 FN_GLOBAL_STRING(addport_cmd, szAddPortCommand)
5253 FN_GLOBAL_STRING(addprinter_cmd, szAddPrinterCommand)
5254 FN_GLOBAL_STRING(add_share_cmd, szAddShareCommand)
5255 FN_GLOBAL_STRING(adduser_script, szAddUserScript)
5256 FN_GLOBAL_STRING(addusertogroup_script, szAddUserToGroupScript)
5257 FN_GLOBAL_STRING(auto_services, szAutoServices)
5258 FN_GLOBAL_STRING(change_share_cmd, szChangeShareCommand)
5259 FN_GLOBAL_STRING(check_password_script, szCheckPasswordScript)
5260 FN_GLOBAL_STRING(configfile, szConfigFile)
5261 FN_GLOBAL_STRING(cups_server, szCupsServer)
5262 FN_GLOBAL_STRING(defaultservice, szDefaultService)
5263 FN_GLOBAL_STRING(deleteprinter_cmd, szDeletePrinterCommand)
5264 FN_GLOBAL_STRING(delete_share_cmd, szDeleteShareCommand)
5265 FN_GLOBAL_STRING(delgroup_script, szDelGroupScript)
5266 FN_GLOBAL_STRING(deluserfromgroup_script, szDelUserFromGroupScript)
5267 FN_GLOBAL_STRING(deluser_script, szDelUserScript)
5268 FN_GLOBAL_STRING(enumports_cmd, szEnumPortsCommand)
5269 FN_GLOBAL_STRING(get_quota_command, szGetQuota)
5270 FN_GLOBAL_STRING(iprint_server, szIPrintServer)
5271 FN_GLOBAL_STRING(ldap_admin_dn, szLdapAdminDn)
5272 FN_GLOBAL_STRING(ldap_suffix, szLdapSuffix)
5273 FN_GLOBAL_STRING(logfile, logfile)
5274 FN_GLOBAL_STRING(log_nt_token_command, szLogNtTokenCommand)
5275 FN_GLOBAL_STRING(mangling_method, szManglingMethod)
5276 FN_GLOBAL_STRING(msg_command, szMsgCommand)
5277 FN_GLOBAL_STRING(nis_home_map_name, szNISHomeMapName)
5278 FN_GLOBAL_STRING(os2_driver_map, szOs2DriverMap)
5279 FN_GLOBAL_STRING(panic_action, szPanicAction)
5280 FN_GLOBAL_STRING(passwd_chat, szPasswdChat)
5281 FN_GLOBAL_STRING(passwd_program, szPasswdProgram)
5282 FN_GLOBAL_STRING(perfcount_module, szSMBPerfcountModule)
5283 FN_GLOBAL_STRING(remote_announce, szRemoteAnnounce)
5284 FN_GLOBAL_STRING(remote_browse_sync, szRemoteBrowseSync)
5285 FN_GLOBAL_STRING(renameuser_script, szRenameUserScript)
5286 FN_GLOBAL_STRING(rootdir, szRootdir)
5287 FN_GLOBAL_STRING(serverstring, szServerString)
5288 FN_GLOBAL_STRING(setprimarygroup_script, szSetPrimaryGroupScript)
5289 FN_GLOBAL_STRING(set_quota_command, szSetQuota)
5290 FN_GLOBAL_STRING(shutdown_script, szShutdownScript)
5291 FN_GLOBAL_STRING(username_map_script, szUsernameMapScript)
5292 FN_GLOBAL_STRING(username_map, szUsernameMap)
5293 FN_GLOBAL_STRING(usershare_path, szUsersharePath)
5294 FN_GLOBAL_STRING(wins_hook, szWINSHook)
5295 static FN_GLOBAL_BOOL(domain_logons, bDomainLogons)
5296 static FN_GLOBAL_BOOL(_readraw, bReadRaw)
5297 static FN_GLOBAL_BOOL(time_server, bTimeServer)
5298 static FN_GLOBAL_BOOL(_writeraw, bWriteRaw)
5299 static FN_GLOBAL_CONST_STRING(_ctdbd_socket, ctdbdSocket)
5300 static FN_GLOBAL_INTEGER(_server_role, ServerRole)
5302 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5303 * build process or in smb.conf, we use that value. Otherwise they
5304 * default to the value of lp_lockdir(). */
5305 const char *lp_statedir(void) {
5306 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5307 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5308 return(*(char **)(&Globals.szStateDir) ?
5309 *(char **)(&Globals.szStateDir) : "");
5311 return(*(char **)(&Globals.szLockDir) ?
5312 *(char **)(&Globals.szLockDir) : "");
5314 const char *lp_cachedir(void) {
5315 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5316 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5317 return(*(char **)(&Globals.szCacheDir) ?
5318 *(char **)(&Globals.szCacheDir) : "");
5320 return(*(char **)(&Globals.szLockDir) ?
5321 *(char **)(&Globals.szLockDir) : "");
5323 static FN_GLOBAL_INTEGER(winbind_max_domain_connections_int,
5324 winbindMaxDomainConnections)
5326 int lp_winbind_max_domain_connections(void)
5328 if (lp_winbind_offline_logon() &&
5329 lp_winbind_max_domain_connections_int() > 1) {
5330 DEBUG(1, ("offline logons active, restricting max domain "
5331 "connections to 1\n"));
5334 return MAX(1, lp_winbind_max_domain_connections_int());
5337 int lp_smb2_max_credits(void)
5339 if (Globals.ismb2_max_credits == 0) {
5340 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5342 return Globals.ismb2_max_credits;
5344 int lp_cups_encrypt(void)
5347 #ifdef HAVE_HTTPCONNECTENCRYPT
5348 switch (Globals.CupsEncrypt) {
5350 result = HTTP_ENCRYPT_REQUIRED;
5353 result = HTTP_ENCRYPT_ALWAYS;
5356 result = HTTP_ENCRYPT_NEVER;
5363 #include "lib/param/param_functions.c"
5365 FN_LOCAL_STRING(servicename, szService)
5366 FN_LOCAL_CONST_STRING(const_servicename, szService)
5368 /* local prototypes */
5370 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5371 static const char *get_boolean(bool bool_value);
5372 static int getservicebyname(const char *pszServiceName,
5373 struct loadparm_service *pserviceDest);
5374 static void copy_service(struct loadparm_service *pserviceDest,
5375 struct loadparm_service *pserviceSource,
5376 struct bitmap *pcopymapDest);
5377 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5379 static bool do_section(const char *pszSectionName, void *userdata);
5380 static void init_copymap(struct loadparm_service *pservice);
5381 static bool hash_a_service(const char *name, int number);
5382 static void free_service_byindex(int iService);
5383 static void show_parameter(int parmIndex);
5384 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5387 * This is a helper function for parametrical options support. It returns a
5388 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5389 * parametrical functions are quite simple
5391 static struct parmlist_entry *get_parametrics_by_service(struct loadparm_service *service, const char *type,
5394 bool global_section = false;
5396 struct parmlist_entry *data;
5398 if (service == NULL) {
5399 data = Globals.param_opt;
5400 global_section = true;
5402 data = service->param_opt;
5405 if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
5406 DEBUG(0,("asprintf failed!\n"));
5411 if (strwicmp(data->key, param_key) == 0) {
5412 string_free(¶m_key);
5418 if (!global_section) {
5419 /* Try to fetch the same option but from globals */
5420 /* but only if we are not already working with Globals */
5421 data = Globals.param_opt;
5423 if (strwicmp(data->key, param_key) == 0) {
5424 string_free(¶m_key);
5431 string_free(¶m_key);
5437 * This is a helper function for parametrical options support. It returns a
5438 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5439 * parametrical functions are quite simple
5441 static struct parmlist_entry *get_parametrics(int snum, const char *type,
5444 if (snum >= iNumServices) return NULL;
5447 return get_parametrics_by_service(NULL, type, option);
5449 return get_parametrics_by_service(ServicePtrs[snum], type, option);
5454 #define MISSING_PARAMETER(name) \
5455 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5457 /*******************************************************************
5458 convenience routine to return int parameters.
5459 ********************************************************************/
5460 static int lp_int(const char *s)
5464 MISSING_PARAMETER(lp_int);
5468 return (int)strtol(s, NULL, 0);
5471 /*******************************************************************
5472 convenience routine to return unsigned long parameters.
5473 ********************************************************************/
5474 static unsigned long lp_ulong(const char *s)
5478 MISSING_PARAMETER(lp_ulong);
5482 return strtoul(s, NULL, 0);
5485 /*******************************************************************
5486 convenience routine to return boolean parameters.
5487 ********************************************************************/
5488 static bool lp_bool(const char *s)
5493 MISSING_PARAMETER(lp_bool);
5497 if (!set_boolean(s, &ret)) {
5498 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5505 /*******************************************************************
5506 convenience routine to return enum parameters.
5507 ********************************************************************/
5508 static int lp_enum(const char *s,const struct enum_list *_enum)
5512 if (!s || !*s || !_enum) {
5513 MISSING_PARAMETER(lp_enum);
5517 for (i=0; _enum[i].name; i++) {
5518 if (strequal(_enum[i].name,s))
5519 return _enum[i].value;
5522 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5526 #undef MISSING_PARAMETER
5528 /* Return parametric option from a given service. Type is a part of option before ':' */
5529 /* Parametric option has following syntax: 'Type: option = value' */
5530 /* the returned value is talloced on the talloc_tos() */
5531 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5533 struct parmlist_entry *data = get_parametrics(snum, type, option);
5535 if (data == NULL||data->value==NULL) {
5537 return lp_string(def);
5543 return lp_string(data->value);
5546 /* Return parametric option from a given service. Type is a part of option before ':' */
5547 /* Parametric option has following syntax: 'Type: option = value' */
5548 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5550 struct parmlist_entry *data = get_parametrics(snum, type, option);
5552 if (data == NULL||data->value==NULL)
5558 const char *lp_parm_const_string_service(struct loadparm_service *service, const char *type, const char *option)
5560 struct parmlist_entry *data = get_parametrics_by_service(service, type, option);
5562 if (data == NULL||data->value==NULL)
5569 /* Return parametric option from a given service. Type is a part of option before ':' */
5570 /* Parametric option has following syntax: 'Type: option = value' */
5572 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5574 struct parmlist_entry *data = get_parametrics(snum, type, option);
5576 if (data == NULL||data->value==NULL)
5577 return (const char **)def;
5579 if (data->list==NULL) {
5580 data->list = str_list_make_v3(NULL, data->value, NULL);
5583 return (const char **)data->list;
5586 /* Return parametric option from a given service. Type is a part of option before ':' */
5587 /* Parametric option has following syntax: 'Type: option = value' */
5589 int lp_parm_int(int snum, const char *type, const char *option, int def)
5591 struct parmlist_entry *data = get_parametrics(snum, type, option);
5593 if (data && data->value && *data->value)
5594 return lp_int(data->value);
5599 /* Return parametric option from a given service. Type is a part of option before ':' */
5600 /* Parametric option has following syntax: 'Type: option = value' */
5602 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5604 struct parmlist_entry *data = get_parametrics(snum, type, option);
5606 if (data && data->value && *data->value)
5607 return lp_ulong(data->value);
5612 /* Return parametric option from a given service. Type is a part of option before ':' */
5613 /* Parametric option has following syntax: 'Type: option = value' */
5615 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5617 struct parmlist_entry *data = get_parametrics(snum, type, option);
5619 if (data && data->value && *data->value)
5620 return lp_bool(data->value);
5625 /* Return parametric option from a given service. Type is a part of option before ':' */
5626 /* Parametric option has following syntax: 'Type: option = value' */
5628 int lp_parm_enum(int snum, const char *type, const char *option,
5629 const struct enum_list *_enum, int def)
5631 struct parmlist_entry *data = get_parametrics(snum, type, option);
5633 if (data && data->value && *data->value && _enum)
5634 return lp_enum(data->value, _enum);
5640 /***************************************************************************
5641 Initialise a service to the defaults.
5642 ***************************************************************************/
5644 static void init_service(struct loadparm_service *pservice)
5646 memset((char *)pservice, '\0', sizeof(struct loadparm_service));
5647 copy_service(pservice, &sDefault, NULL);
5652 * free a param_opts structure.
5653 * param_opts handling should be moved to talloc;
5654 * then this whole functions reduces to a TALLOC_FREE().
5657 static void free_param_opts(struct parmlist_entry **popts)
5659 struct parmlist_entry *opt, *next_opt;
5661 if (popts == NULL) {
5665 if (*popts != NULL) {
5666 DEBUG(5, ("Freeing parametrics:\n"));
5669 while (opt != NULL) {
5670 string_free(&opt->key);
5671 string_free(&opt->value);
5672 TALLOC_FREE(opt->list);
5673 next_opt = opt->next;
5680 /***************************************************************************
5681 Free the dynamically allocated parts of a service struct.
5682 ***************************************************************************/
5684 static void free_service(struct loadparm_service *pservice)
5689 if (pservice->szService)
5690 DEBUG(5, ("free_service: Freeing service %s\n",
5691 pservice->szService));
5693 free_parameters(pservice);
5695 string_free(&pservice->szService);
5696 TALLOC_FREE(pservice->copymap);
5698 free_param_opts(&pservice->param_opt);
5700 ZERO_STRUCTP(pservice);
5704 /***************************************************************************
5705 remove a service indexed in the ServicePtrs array from the ServiceHash
5706 and free the dynamically allocated parts
5707 ***************************************************************************/
5709 static void free_service_byindex(int idx)
5711 if ( !LP_SNUM_OK(idx) )
5714 ServicePtrs[idx]->valid = false;
5715 invalid_services[num_invalid_services++] = idx;
5717 /* we have to cleanup the hash record */
5719 if (ServicePtrs[idx]->szService) {
5720 char *canon_name = canonicalize_servicename(
5722 ServicePtrs[idx]->szService );
5724 dbwrap_delete_bystring(ServiceHash, canon_name );
5725 TALLOC_FREE(canon_name);
5728 free_service(ServicePtrs[idx]);
5731 /***************************************************************************
5732 Add a new service to the services array initialising it with the given
5734 ***************************************************************************/
5736 static int add_a_service(const struct loadparm_service *pservice, const char *name)
5739 struct loadparm_service tservice;
5740 int num_to_alloc = iNumServices + 1;
5742 tservice = *pservice;
5744 /* it might already exist */
5746 i = getservicebyname(name, NULL);
5752 /* find an invalid one */
5754 if (num_invalid_services > 0) {
5755 i = invalid_services[--num_invalid_services];
5758 /* if not, then create one */
5759 if (i == iNumServices) {
5760 struct loadparm_service **tsp;
5763 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct loadparm_service *, num_to_alloc);
5765 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
5769 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct loadparm_service);
5770 if (!ServicePtrs[iNumServices]) {
5771 DEBUG(0,("add_a_service: out of memory!\n"));
5776 /* enlarge invalid_services here for now... */
5777 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
5779 if (tinvalid == NULL) {
5780 DEBUG(0,("add_a_service: failed to enlarge "
5781 "invalid_services!\n"));
5784 invalid_services = tinvalid;
5786 free_service_byindex(i);
5789 ServicePtrs[i]->valid = true;
5791 init_service(ServicePtrs[i]);
5792 copy_service(ServicePtrs[i], &tservice, NULL);
5794 string_set(&ServicePtrs[i]->szService, name);
5796 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
5797 i, ServicePtrs[i]->szService));
5799 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
5806 /***************************************************************************
5807 Convert a string to uppercase and remove whitespaces.
5808 ***************************************************************************/
5810 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
5815 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
5819 result = talloc_strdup(ctx, src);
5820 SMB_ASSERT(result != NULL);
5826 /***************************************************************************
5827 Add a name/index pair for the services array to the hash table.
5828 ***************************************************************************/
5830 static bool hash_a_service(const char *name, int idx)
5834 if ( !ServiceHash ) {
5835 DEBUG(10,("hash_a_service: creating servicehash\n"));
5836 ServiceHash = db_open_rbt(NULL);
5837 if ( !ServiceHash ) {
5838 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
5843 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
5846 canon_name = canonicalize_servicename(talloc_tos(), name );
5848 dbwrap_store_bystring(ServiceHash, canon_name,
5849 make_tdb_data((uint8 *)&idx, sizeof(idx)),
5852 TALLOC_FREE(canon_name);
5857 /***************************************************************************
5858 Add a new home service, with the specified home directory, defaults coming
5860 ***************************************************************************/
5862 bool lp_add_home(const char *pszHomename, int iDefaultService,
5863 const char *user, const char *pszHomedir)
5867 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
5868 pszHomedir[0] == '\0') {
5872 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
5877 if (!(*(ServicePtrs[iDefaultService]->szPath))
5878 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
5879 string_set(&ServicePtrs[i]->szPath, pszHomedir);
5882 if (!(*(ServicePtrs[i]->comment))) {
5883 char *comment = NULL;
5884 if (asprintf(&comment, "Home directory of %s", user) < 0) {
5887 string_set(&ServicePtrs[i]->comment, comment);
5891 /* set the browseable flag from the global default */
5893 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5894 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
5896 ServicePtrs[i]->autoloaded = true;
5898 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
5899 user, ServicePtrs[i]->szPath ));
5904 /***************************************************************************
5905 Add a new service, based on an old one.
5906 ***************************************************************************/
5908 int lp_add_service(const char *pszService, int iDefaultService)
5910 if (iDefaultService < 0) {
5911 return add_a_service(&sDefault, pszService);
5914 return (add_a_service(ServicePtrs[iDefaultService], pszService));
5917 /***************************************************************************
5918 Add the IPC service.
5919 ***************************************************************************/
5921 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
5923 char *comment = NULL;
5924 int i = add_a_service(&sDefault, ipc_name);
5929 if (asprintf(&comment, "IPC Service (%s)",
5930 Globals.szServerString) < 0) {
5934 string_set(&ServicePtrs[i]->szPath, tmpdir());
5935 string_set(&ServicePtrs[i]->szUsername, "");
5936 string_set(&ServicePtrs[i]->comment, comment);
5937 string_set(&ServicePtrs[i]->fstype, "IPC");
5938 ServicePtrs[i]->iMaxConnections = 0;
5939 ServicePtrs[i]->bAvailable = true;
5940 ServicePtrs[i]->bRead_only = true;
5941 ServicePtrs[i]->bGuest_only = false;
5942 ServicePtrs[i]->bAdministrative_share = true;
5943 ServicePtrs[i]->bGuest_ok = guest_ok;
5944 ServicePtrs[i]->bPrint_ok = false;
5945 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5947 DEBUG(3, ("adding IPC service\n"));
5953 /***************************************************************************
5954 Add a new printer service, with defaults coming from service iFrom.
5955 ***************************************************************************/
5957 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
5959 const char *comment = "From Printcap";
5960 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
5965 /* note that we do NOT default the availability flag to true - */
5966 /* we take it from the default service passed. This allows all */
5967 /* dynamic printers to be disabled by disabling the [printers] */
5968 /* entry (if/when the 'available' keyword is implemented!). */
5970 /* the printer name is set to the service name. */
5971 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
5972 string_set(&ServicePtrs[i]->comment, comment);
5974 /* set the browseable flag from the gloabl default */
5975 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5977 /* Printers cannot be read_only. */
5978 ServicePtrs[i]->bRead_only = false;
5979 /* No share modes on printer services. */
5980 ServicePtrs[i]->bShareModes = false;
5981 /* No oplocks on printer services. */
5982 ServicePtrs[i]->bOpLocks = false;
5983 /* Printer services must be printable. */
5984 ServicePtrs[i]->bPrint_ok = true;
5986 DEBUG(3, ("adding printer service %s\n", pszPrintername));
5992 /***************************************************************************
5993 Check whether the given parameter name is valid.
5994 Parametric options (names containing a colon) are considered valid.
5995 ***************************************************************************/
5997 bool lp_parameter_is_valid(const char *pszParmName)
5999 return ((map_parameter(pszParmName) != -1) ||
6000 (strchr(pszParmName, ':') != NULL));
6003 /***************************************************************************
6004 Check whether the given name is the name of a global parameter.
6005 Returns true for strings belonging to parameters of class
6006 P_GLOBAL, false for all other strings, also for parametric options
6007 and strings not belonging to any option.
6008 ***************************************************************************/
6010 bool lp_parameter_is_global(const char *pszParmName)
6012 int num = map_parameter(pszParmName);
6015 return (parm_table[num].p_class == P_GLOBAL);
6021 /**************************************************************************
6022 Check whether the given name is the canonical name of a parameter.
6023 Returns false if it is not a valid parameter Name.
6024 For parametric options, true is returned.
6025 **************************************************************************/
6027 bool lp_parameter_is_canonical(const char *parm_name)
6029 if (!lp_parameter_is_valid(parm_name)) {
6033 return (map_parameter(parm_name) ==
6034 map_parameter_canonical(parm_name, NULL));
6037 /**************************************************************************
6038 Determine the canonical name for a parameter.
6039 Indicate when it is an inverse (boolean) synonym instead of a
6041 **************************************************************************/
6043 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6048 if (!lp_parameter_is_valid(parm_name)) {
6053 num = map_parameter_canonical(parm_name, inverse);
6055 /* parametric option */
6056 *canon_parm = parm_name;
6058 *canon_parm = parm_table[num].label;
6065 /**************************************************************************
6066 Determine the canonical name for a parameter.
6067 Turn the value given into the inverse boolean expression when
6068 the synonym is an invers boolean synonym.
6070 Return true if parm_name is a valid parameter name and
6071 in case it is an invers boolean synonym, if the val string could
6072 successfully be converted to the reverse bool.
6073 Return false in all other cases.
6074 **************************************************************************/
6076 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6078 const char **canon_parm,
6079 const char **canon_val)
6084 if (!lp_parameter_is_valid(parm_name)) {
6090 num = map_parameter_canonical(parm_name, &inverse);
6092 /* parametric option */
6093 *canon_parm = parm_name;
6096 *canon_parm = parm_table[num].label;
6098 if (!lp_invert_boolean(val, canon_val)) {
6110 /***************************************************************************
6111 Map a parameter's string representation to something we can use.
6112 Returns false if the parameter string is not recognised, else TRUE.
6113 ***************************************************************************/
6115 static int map_parameter(const char *pszParmName)
6119 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6122 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6123 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6126 /* Warn only if it isn't parametric option */
6127 if (strchr(pszParmName, ':') == NULL)
6128 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6129 /* We do return 'fail' for parametric options as well because they are
6130 stored in different storage
6135 /***************************************************************************
6136 Map a parameter's string representation to the index of the canonical
6137 form of the parameter (it might be a synonym).
6138 Returns -1 if the parameter string is not recognised.
6139 ***************************************************************************/
6141 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6143 int parm_num, canon_num;
6144 bool loc_inverse = false;
6146 parm_num = map_parameter(pszParmName);
6147 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6148 /* invalid, parametric or no canidate for synonyms ... */
6152 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6153 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6154 parm_num = canon_num;
6160 if (inverse != NULL) {
6161 *inverse = loc_inverse;
6166 /***************************************************************************
6167 return true if parameter number parm1 is a synonym of parameter
6168 number parm2 (parm2 being the principal name).
6169 set inverse to true if parm1 is P_BOOLREV and parm2 is P_BOOL,
6171 ***************************************************************************/
6173 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6175 if ((parm_table[parm1].offset == parm_table[parm2].offset) &&
6176 (parm_table[parm1].p_class == parm_table[parm2].p_class) &&
6177 (parm_table[parm1].flags & FLAG_HIDE) &&
6178 !(parm_table[parm2].flags & FLAG_HIDE))
6180 if (inverse != NULL) {
6181 if ((parm_table[parm1].type == P_BOOLREV) &&
6182 (parm_table[parm2].type == P_BOOL))
6194 /***************************************************************************
6195 Show one parameter's name, type, [values,] and flags.
6196 (helper functions for show_parameter_list)
6197 ***************************************************************************/
6199 static void show_parameter(int parmIndex)
6201 int enumIndex, flagIndex;
6206 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6207 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6209 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6210 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6212 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6213 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6214 "FLAG_DEPRECATED", "FLAG_HIDE", NULL};
6216 printf("%s=%s", parm_table[parmIndex].label,
6217 type[parm_table[parmIndex].type]);
6218 if (parm_table[parmIndex].type == P_ENUM) {
6221 parm_table[parmIndex].enum_list[enumIndex].name;
6225 enumIndex ? "|" : "",
6226 parm_table[parmIndex].enum_list[enumIndex].name);
6231 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6232 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6235 flag_names[flagIndex]);
6240 /* output synonyms */
6242 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6243 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6244 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6245 parm_table[parmIndex2].label);
6246 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6248 printf(" (synonyms: ");
6253 printf("%s%s", parm_table[parmIndex2].label,
6254 inverse ? "[i]" : "");
6264 /***************************************************************************
6265 Show all parameter's name, type, [values,] and flags.
6266 ***************************************************************************/
6268 void show_parameter_list(void)
6270 int classIndex, parmIndex;
6271 const char *section_names[] = { "local", "global", NULL};
6273 for (classIndex=0; section_names[classIndex]; classIndex++) {
6274 printf("[%s]\n", section_names[classIndex]);
6275 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6276 if (parm_table[parmIndex].p_class == classIndex) {
6277 show_parameter(parmIndex);
6283 /***************************************************************************
6284 Check if a given string correctly represents a boolean value.
6285 ***************************************************************************/
6287 bool lp_string_is_valid_boolean(const char *parm_value)
6289 return set_boolean(parm_value, NULL);
6292 /***************************************************************************
6293 Get the standard string representation of a boolean value ("yes" or "no")
6294 ***************************************************************************/
6296 static const char *get_boolean(bool bool_value)
6298 static const char *yes_str = "yes";
6299 static const char *no_str = "no";
6301 return (bool_value ? yes_str : no_str);
6304 /***************************************************************************
6305 Provide the string of the negated boolean value associated to the boolean
6306 given as a string. Returns false if the passed string does not correctly
6307 represent a boolean.
6308 ***************************************************************************/
6310 bool lp_invert_boolean(const char *str, const char **inverse_str)
6314 if (!set_boolean(str, &val)) {
6318 *inverse_str = get_boolean(!val);
6322 /***************************************************************************
6323 Provide the canonical string representation of a boolean value given
6324 as a string. Return true on success, false if the string given does
6325 not correctly represent a boolean.
6326 ***************************************************************************/
6328 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6332 if (!set_boolean(str, &val)) {
6336 *canon_str = get_boolean(val);
6340 /***************************************************************************
6341 Find a service by name. Otherwise works like get_service.
6342 ***************************************************************************/
6344 static int getservicebyname(const char *pszServiceName, struct loadparm_service *pserviceDest)
6351 if (ServiceHash == NULL) {
6355 canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
6357 status = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name,
6360 if (NT_STATUS_IS_OK(status) &&
6361 (data.dptr != NULL) &&
6362 (data.dsize == sizeof(iService)))
6364 iService = *(int *)data.dptr;
6367 TALLOC_FREE(canon_name);
6369 if ((iService != -1) && (LP_SNUM_OK(iService))
6370 && (pserviceDest != NULL)) {
6371 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6377 /* Return a pointer to a service by name. Unlike getservicebyname, it does not copy the service */
6378 struct loadparm_service *lp_service(const char *pszServiceName)
6380 int iService = getservicebyname(pszServiceName, NULL);
6381 if (iService == -1 || !LP_SNUM_OK(iService)) {
6384 return ServicePtrs[iService];
6387 struct loadparm_service *lp_servicebynum(int snum)
6389 if ((snum == -1) || !LP_SNUM_OK(snum)) {
6392 return ServicePtrs[snum];
6395 struct loadparm_service *lp_default_loadparm_service()
6401 /***************************************************************************
6402 Copy a service structure to another.
6403 If pcopymapDest is NULL then copy all fields
6404 ***************************************************************************/
6407 * Add a parametric option to a parmlist_entry,
6408 * replacing old value, if already present.
6410 static void set_param_opt(struct parmlist_entry **opt_list,
6411 const char *opt_name,
6412 const char *opt_value,
6415 struct parmlist_entry *new_opt, *opt;
6418 if (opt_list == NULL) {
6425 /* Traverse destination */
6427 /* If we already have same option, override it */
6428 if (strwicmp(opt->key, opt_name) == 0) {
6429 if ((opt->priority & FLAG_CMDLINE) &&
6430 !(priority & FLAG_CMDLINE)) {
6431 /* it's been marked as not to be
6435 string_free(&opt->value);
6436 TALLOC_FREE(opt->list);
6437 opt->value = SMB_STRDUP(opt_value);
6438 opt->priority = priority;
6445 new_opt = SMB_XMALLOC_P(struct parmlist_entry);
6446 new_opt->key = SMB_STRDUP(opt_name);
6447 new_opt->value = SMB_STRDUP(opt_value);
6448 new_opt->list = NULL;
6449 new_opt->priority = priority;
6450 DLIST_ADD(*opt_list, new_opt);
6454 static void copy_service(struct loadparm_service *pserviceDest, struct loadparm_service *pserviceSource,
6455 struct bitmap *pcopymapDest)
6458 bool bcopyall = (pcopymapDest == NULL);
6459 struct parmlist_entry *data;
6461 for (i = 0; parm_table[i].label; i++)
6462 if (parm_table[i].p_class == P_LOCAL &&
6463 (bcopyall || bitmap_query(pcopymapDest,i))) {
6464 void *src_ptr = lp_parm_ptr(pserviceSource, &parm_table[i]);
6465 void *dest_ptr = lp_parm_ptr(pserviceDest, &parm_table[i]);
6467 switch (parm_table[i].type) {
6470 *(bool *)dest_ptr = *(bool *)src_ptr;
6477 *(int *)dest_ptr = *(int *)src_ptr;
6481 *(char *)dest_ptr = *(char *)src_ptr;
6485 string_set((char **)dest_ptr,
6491 char *upper_string = strupper_talloc(talloc_tos(),
6493 string_set((char **)dest_ptr,
6495 TALLOC_FREE(upper_string);
6499 TALLOC_FREE(*((char ***)dest_ptr));
6500 *((char ***)dest_ptr) = str_list_copy(NULL,
6501 *(const char ***)src_ptr);
6509 init_copymap(pserviceDest);
6510 if (pserviceSource->copymap)
6511 bitmap_copy(pserviceDest->copymap,
6512 pserviceSource->copymap);
6515 data = pserviceSource->param_opt;
6517 set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->priority);
6522 /***************************************************************************
6523 Check a service for consistency. Return false if the service is in any way
6524 incomplete or faulty, else true.
6525 ***************************************************************************/
6527 bool service_ok(int iService)
6532 if (ServicePtrs[iService]->szService[0] == '\0') {
6533 DEBUG(0, ("The following message indicates an internal error:\n"));
6534 DEBUG(0, ("No service name in service entry.\n"));
6538 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6539 /* I can't see why you'd want a non-printable printer service... */
6540 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6541 if (!ServicePtrs[iService]->bPrint_ok) {
6542 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6543 ServicePtrs[iService]->szService));
6544 ServicePtrs[iService]->bPrint_ok = true;
6546 /* [printers] service must also be non-browsable. */
6547 if (ServicePtrs[iService]->bBrowseable)
6548 ServicePtrs[iService]->bBrowseable = false;
6551 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6552 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6553 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6555 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6556 ServicePtrs[iService]->szService));
6557 ServicePtrs[iService]->bAvailable = false;
6560 /* If a service is flagged unavailable, log the fact at level 1. */
6561 if (!ServicePtrs[iService]->bAvailable)
6562 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6563 ServicePtrs[iService]->szService));
6568 static struct smbconf_ctx *lp_smbconf_ctx(void)
6571 static struct smbconf_ctx *conf_ctx = NULL;
6573 if (conf_ctx == NULL) {
6574 err = smbconf_init(NULL, &conf_ctx, "registry:");
6575 if (!SBC_ERROR_IS_OK(err)) {
6576 DEBUG(1, ("error initializing registry configuration: "
6577 "%s\n", sbcErrorString(err)));
6585 static bool process_smbconf_service(struct smbconf_service *service)
6590 if (service == NULL) {
6594 ret = do_section(service->name, NULL);
6598 for (count = 0; count < service->num_params; count++) {
6599 ret = do_parameter(service->param_names[count],
6600 service->param_values[count],
6606 if (iServiceIndex >= 0) {
6607 return service_ok(iServiceIndex);
6613 * load a service from registry and activate it
6615 bool process_registry_service(const char *service_name)
6618 struct smbconf_service *service = NULL;
6619 TALLOC_CTX *mem_ctx = talloc_stackframe();
6620 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6623 if (conf_ctx == NULL) {
6627 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6629 if (!smbconf_share_exists(conf_ctx, service_name)) {
6631 * Registry does not contain data for this service (yet),
6632 * but make sure lp_load doesn't return false.
6638 err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6639 if (!SBC_ERROR_IS_OK(err)) {
6643 ret = process_smbconf_service(service);
6649 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6652 TALLOC_FREE(mem_ctx);
6657 * process_registry_globals
6659 static bool process_registry_globals(void)
6663 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6665 ret = do_parameter("registry shares", "yes", NULL);
6670 return process_registry_service(GLOBAL_NAME);
6673 bool process_registry_shares(void)
6677 struct smbconf_service **service = NULL;
6678 uint32_t num_shares = 0;
6679 TALLOC_CTX *mem_ctx = talloc_stackframe();
6680 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6683 if (conf_ctx == NULL) {
6687 err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6688 if (!SBC_ERROR_IS_OK(err)) {
6694 for (count = 0; count < num_shares; count++) {
6695 if (strequal(service[count]->name, GLOBAL_NAME)) {
6698 ret = process_smbconf_service(service[count]);
6705 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6708 TALLOC_FREE(mem_ctx);
6713 * reload those shares from registry that are already
6714 * activated in the services array.
6716 static bool reload_registry_shares(void)
6721 for (i = 0; i < iNumServices; i++) {
6726 if (ServicePtrs[i]->usershare == USERSHARE_VALID) {
6730 ret = process_registry_service(ServicePtrs[i]->szService);
6741 #define MAX_INCLUDE_DEPTH 100
6743 static uint8_t include_depth;
6745 static struct file_lists {
6746 struct file_lists *next;
6750 } *file_lists = NULL;
6752 /*******************************************************************
6753 Keep a linked list of all config files so we know when one has changed
6754 it's date and needs to be reloaded.
6755 ********************************************************************/
6757 static void add_to_file_list(const char *fname, const char *subfname)
6759 struct file_lists *f = file_lists;
6762 if (f->name && !strcmp(f->name, fname))
6768 f = SMB_MALLOC_P(struct file_lists);
6771 f->next = file_lists;
6772 f->name = SMB_STRDUP(fname);
6777 f->subfname = SMB_STRDUP(subfname);
6784 f->modtime = file_modtime(subfname);
6786 time_t t = file_modtime(subfname);
6794 * Free the file lists
6796 static void free_file_list(void)
6798 struct file_lists *f;
6799 struct file_lists *next;
6804 SAFE_FREE( f->name );
6805 SAFE_FREE( f->subfname );
6814 * Utility function for outsiders to check if we're running on registry.
6816 bool lp_config_backend_is_registry(void)
6818 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
6822 * Utility function to check if the config backend is FILE.
6824 bool lp_config_backend_is_file(void)
6826 return (lp_config_backend() == CONFIG_BACKEND_FILE);
6829 /*******************************************************************
6830 Check if a config file has changed date.
6831 ********************************************************************/
6833 bool lp_file_list_changed(void)
6835 struct file_lists *f = file_lists;
6837 DEBUG(6, ("lp_file_list_changed()\n"));
6842 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
6843 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6845 if (conf_ctx == NULL) {
6848 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
6851 DEBUGADD(6, ("registry config changed\n"));
6856 n2 = talloc_sub_basic(talloc_tos(),
6857 get_current_username(),
6858 current_user_info.domain,
6863 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
6864 f->name, n2, ctime(&f->modtime)));
6866 mod_time = file_modtime(n2);
6869 ((f->modtime != mod_time) ||
6870 (f->subfname == NULL) ||
6871 (strcmp(n2, f->subfname) != 0)))
6874 ("file %s modified: %s\n", n2,
6876 f->modtime = mod_time;
6877 SAFE_FREE(f->subfname);
6878 f->subfname = SMB_STRDUP(n2);
6891 * Initialize iconv conversion descriptors.
6893 * This is called the first time it is needed, and also called again
6894 * every time the configuration is reloaded, because the charset or
6895 * codepage might have changed.
6897 static void init_iconv(void)
6899 global_iconv_handle = smb_iconv_handle_reinit(NULL, lp_dos_charset(),
6901 true, global_iconv_handle);
6904 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6906 if (strcmp(*ptr, pszParmValue) != 0) {
6907 string_set(ptr, pszParmValue);
6913 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6915 bool is_utf8 = false;
6916 size_t len = strlen(pszParmValue);
6918 if (len == 4 || len == 5) {
6919 /* Don't use StrCaseCmp here as we don't want to
6920 initialize iconv. */
6921 if ((toupper_m(pszParmValue[0]) == 'U') &&
6922 (toupper_m(pszParmValue[1]) == 'T') &&
6923 (toupper_m(pszParmValue[2]) == 'F')) {
6925 if (pszParmValue[3] == '8') {
6929 if (pszParmValue[3] == '-' &&
6930 pszParmValue[4] == '8') {
6937 if (strcmp(*ptr, pszParmValue) != 0) {
6939 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
6940 "be UTF8, using (default value) %s instead.\n",
6941 DEFAULT_DOS_CHARSET));
6942 pszParmValue = DEFAULT_DOS_CHARSET;
6944 string_set(ptr, pszParmValue);
6950 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6953 char *realm = strupper_talloc(talloc_tos(), pszParmValue);
6954 char *dnsdomain = strlower_talloc(talloc_tos(), pszParmValue);
6956 ret &= string_set(&Globals.szRealm, pszParmValue);
6957 ret &= string_set(&Globals.szRealmUpper, realm);
6958 ret &= string_set(&Globals.szDnsDomain, dnsdomain);
6960 TALLOC_FREE(dnsdomain);
6965 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6967 TALLOC_FREE(Globals.szNetbiosAliases);
6968 Globals.szNetbiosAliases = (const char **)str_list_make_v3(NULL, pszParmValue, NULL);
6969 return set_netbios_aliases(Globals.szNetbiosAliases);
6972 /***************************************************************************
6973 Handle the include operation.
6974 ***************************************************************************/
6975 static bool bAllowIncludeRegistry = true;
6977 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6981 if (include_depth >= MAX_INCLUDE_DEPTH) {
6982 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
6987 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
6988 if (!bAllowIncludeRegistry) {
6991 if (bInGlobalSection) {
6994 ret = process_registry_globals();
6998 DEBUG(1, ("\"include = registry\" only effective "
6999 "in %s section\n", GLOBAL_NAME));
7004 fname = talloc_sub_basic(talloc_tos(), get_current_username(),
7005 current_user_info.domain,
7008 add_to_file_list(pszParmValue, fname);
7010 string_set(ptr, fname);
7012 if (file_exist(fname)) {
7015 ret = pm_process(fname, do_section, do_parameter, NULL);
7021 DEBUG(2, ("Can't find include file %s\n", fname));
7026 /***************************************************************************
7027 Handle the interpretation of the copy parameter.
7028 ***************************************************************************/
7030 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7034 struct loadparm_service serviceTemp;
7036 string_set(ptr, pszParmValue);
7038 init_service(&serviceTemp);
7042 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7044 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7045 if (iTemp == iServiceIndex) {
7046 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7048 copy_service(ServicePtrs[iServiceIndex],
7050 ServicePtrs[iServiceIndex]->copymap);
7054 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7058 free_service(&serviceTemp);
7062 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7064 Globals.ldap_debug_level = lp_int(pszParmValue);
7065 init_ldap_debugging();
7069 /***************************************************************************
7070 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7075 idmap uid = 1000-1999
7078 We only do simple parsing checks here. The strings are parsed into useful
7079 structures in the idmap daemon code.
7081 ***************************************************************************/
7083 /* Some lp_ routines to return idmap [ug]id information */
7085 static uid_t idmap_uid_low, idmap_uid_high;
7086 static gid_t idmap_gid_low, idmap_gid_high;
7088 bool lp_idmap_uid(uid_t *low, uid_t *high)
7090 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7094 *low = idmap_uid_low;
7097 *high = idmap_uid_high;
7102 bool lp_idmap_gid(gid_t *low, gid_t *high)
7104 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7108 *low = idmap_gid_low;
7111 *high = idmap_gid_high;
7116 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7118 lp_do_parameter(snum, "idmap config * : backend", pszParmValue);
7123 /* Do some simple checks on "idmap [ug]id" parameter values */
7125 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7127 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7132 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7134 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7139 /***************************************************************************
7140 Handle the DEBUG level list.
7141 ***************************************************************************/
7143 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValueIn, char **ptr )
7145 string_set(ptr, pszParmValueIn);
7146 return debug_parse_levels(pszParmValueIn);
7149 /***************************************************************************
7150 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7151 ***************************************************************************/
7153 static const char *append_ldap_suffix( const char *str )
7155 const char *suffix_string;
7158 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7159 Globals.szLdapSuffix );
7160 if ( !suffix_string ) {
7161 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7165 return suffix_string;
7168 const char *lp_ldap_machine_suffix(void)
7170 if (Globals.szLdapMachineSuffix[0])
7171 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7173 return lp_string(Globals.szLdapSuffix);
7176 const char *lp_ldap_user_suffix(void)
7178 if (Globals.szLdapUserSuffix[0])
7179 return append_ldap_suffix(Globals.szLdapUserSuffix);
7181 return lp_string(Globals.szLdapSuffix);
7184 const char *lp_ldap_group_suffix(void)
7186 if (Globals.szLdapGroupSuffix[0])
7187 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7189 return lp_string(Globals.szLdapSuffix);
7192 const char *lp_ldap_idmap_suffix(void)
7194 if (Globals.szLdapIdmapSuffix[0])
7195 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7197 return lp_string(Globals.szLdapSuffix);
7200 /****************************************************************************
7201 set the value for a P_ENUM
7202 ***************************************************************************/
7204 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7209 for (i = 0; parm->enum_list[i].name; i++) {
7210 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7211 *ptr = parm->enum_list[i].value;
7215 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7216 pszParmValue, parm->label));
7219 /***************************************************************************
7220 ***************************************************************************/
7222 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7224 static int parm_num = -1;
7225 struct loadparm_service *s;
7227 if ( parm_num == -1 )
7228 parm_num = map_parameter( "printing" );
7230 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7235 s = ServicePtrs[snum];
7237 init_printer_values( s );
7243 /***************************************************************************
7244 Initialise a copymap.
7245 ***************************************************************************/
7247 static void init_copymap(struct loadparm_service *pservice)
7251 TALLOC_FREE(pservice->copymap);
7253 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
7254 if (!pservice->copymap)
7256 ("Couldn't allocate copymap!! (size %d)\n",
7257 (int)NUMPARAMETERS));
7259 for (i = 0; i < NUMPARAMETERS; i++)
7260 bitmap_set(pservice->copymap, i);
7264 return the parameter pointer for a parameter
7266 void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm)
7268 if (service == NULL) {
7269 if (parm->p_class == P_LOCAL)
7270 return (void *)(((char *)&sDefault)+parm->offset);
7271 else if (parm->p_class == P_GLOBAL)
7272 return (void *)(((char *)&Globals)+parm->offset);
7275 return (void *)(((char *)service) + parm->offset);
7279 /***************************************************************************
7280 Return the local pointer to a parameter given the service number and parameter
7281 ***************************************************************************/
7283 void *lp_local_ptr_by_snum(int snum, struct parm_struct *parm)
7285 return lp_parm_ptr(ServicePtrs[snum], parm);
7288 /***************************************************************************
7289 Process a parameter for a particular service number. If snum < 0
7290 then assume we are in the globals.
7291 ***************************************************************************/
7293 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7296 void *parm_ptr = NULL; /* where we are going to store the result */
7297 struct parmlist_entry **opt_list;
7299 parmnum = map_parameter(pszParmName);
7302 if (strchr(pszParmName, ':') == NULL) {
7303 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7309 * We've got a parametric option
7312 opt_list = (snum < 0)
7313 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7314 set_param_opt(opt_list, pszParmName, pszParmValue, 0);
7319 /* if it's already been set by the command line, then we don't
7321 if (parm_table[parmnum].flags & FLAG_CMDLINE) {
7325 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7326 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7330 /* we might point at a service, the default service or a global */
7332 parm_ptr = lp_parm_ptr(NULL, &parm_table[parmnum]);
7334 if (parm_table[parmnum].p_class == P_GLOBAL) {
7336 ("Global parameter %s found in service section!\n",
7340 parm_ptr = lp_local_ptr_by_snum(snum, &parm_table[parmnum]);
7344 if (!ServicePtrs[snum]->copymap)
7345 init_copymap(ServicePtrs[snum]);
7347 /* this handles the aliases - set the copymap for other entries with
7348 the same data pointer */
7349 for (i = 0; parm_table[i].label; i++) {
7350 if ((parm_table[i].offset == parm_table[parmnum].offset)
7351 && (parm_table[i].p_class == parm_table[parmnum].p_class)) {
7352 bitmap_clear(ServicePtrs[snum]->copymap, i);
7357 /* if it is a special case then go ahead */
7358 if (parm_table[parmnum].special) {
7359 return parm_table[parmnum].special(NULL, snum, pszParmValue,
7363 /* now switch on the type of variable it is */
7364 switch (parm_table[parmnum].type)
7367 *(bool *)parm_ptr = lp_bool(pszParmValue);
7371 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7375 *(int *)parm_ptr = lp_int(pszParmValue);
7379 *(char *)parm_ptr = *pszParmValue;
7383 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7385 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7392 if (conv_str_size_error(pszParmValue, &val)) {
7393 if (val <= INT_MAX) {
7394 *(int *)parm_ptr = (int)val;
7399 DEBUG(0,("lp_do_parameter(%s): value is not "
7400 "a valid size specifier!\n", pszParmValue));
7406 TALLOC_FREE(*((char ***)parm_ptr));
7407 *(char ***)parm_ptr = str_list_make_v3(
7408 NULL, pszParmValue, NULL);
7412 string_set((char **)parm_ptr, pszParmValue);
7417 char *upper_string = strupper_talloc(talloc_tos(),
7419 string_set((char **)parm_ptr, upper_string);
7420 TALLOC_FREE(upper_string);
7424 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7433 /***************************************************************************
7434 set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
7435 FLAG_CMDLINE won't be overridden by loads from smb.conf.
7436 ***************************************************************************/
7438 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
7441 parmnum = map_parameter(pszParmName);
7443 parm_table[parmnum].flags &= ~FLAG_CMDLINE;
7444 if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
7447 parm_table[parmnum].flags |= FLAG_CMDLINE;
7449 /* we have to also set FLAG_CMDLINE on aliases. Aliases must
7450 * be grouped in the table, so we don't have to search the
7453 i>=0 && parm_table[i].offset == parm_table[parmnum].offset
7454 && parm_table[i].p_class == parm_table[parmnum].p_class;
7456 parm_table[i].flags |= FLAG_CMDLINE;
7458 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset
7459 && parm_table[i].p_class == parm_table[parmnum].p_class;i++) {
7460 parm_table[i].flags |= FLAG_CMDLINE;
7464 store_lp_set_cmdline(pszParmName, pszParmValue);
7469 /* it might be parametric */
7470 if (strchr(pszParmName, ':') != NULL) {
7471 set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
7473 store_lp_set_cmdline(pszParmName, pszParmValue);
7478 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
7482 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
7484 return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
7487 /***************************************************************************
7488 Process a parameter.
7489 ***************************************************************************/
7491 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7494 if (!bInGlobalSection && bGlobalOnly)
7497 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7499 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7500 pszParmName, pszParmValue));
7504 set a option from the commandline in 'a=b' format. Use to support --option
7506 bool lp_set_option(const char *option)
7511 s = talloc_strdup(NULL, option);
7524 /* skip white spaces after the = sign */
7527 } while (*p == ' ');
7529 ret = lp_set_cmdline(s, p);
7534 /**************************************************************************
7535 Print a parameter of the specified type.
7536 ***************************************************************************/
7538 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7540 /* For the seperation of lists values that we print below */
7541 const char *list_sep = ", ";
7546 for (i = 0; p->enum_list[i].name; i++) {
7547 if (*(int *)ptr == p->enum_list[i].value) {
7549 p->enum_list[i].name);
7556 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7560 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7565 fprintf(f, "%d", *(int *)ptr);
7569 fprintf(f, "%c", *(char *)ptr);
7573 int val = *(int *)ptr;
7577 fprintf(f, "0%o", val);
7586 if ((char ***)ptr && *(char ***)ptr) {
7587 char **list = *(char ***)ptr;
7588 for (; *list; list++) {
7589 /* surround strings with whitespace in double quotes */
7590 if (*(list+1) == NULL) {
7591 /* last item, no extra separator */
7594 if ( strchr_m( *list, ' ' ) ) {
7595 fprintf(f, "\"%s\"%s", *list, list_sep);
7597 fprintf(f, "%s%s", *list, list_sep);
7605 if (*(char **)ptr) {
7606 fprintf(f, "%s", *(char **)ptr);
7614 /***************************************************************************
7615 Check if two parameters are equal.
7616 ***************************************************************************/
7618 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7623 return (*((bool *)ptr1) == *((bool *)ptr2));
7629 return (*((int *)ptr1) == *((int *)ptr2));
7632 return (*((char *)ptr1) == *((char *)ptr2));
7636 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7641 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7646 return (p1 == p2 || strequal(p1, p2));
7654 /***************************************************************************
7655 Initialize any local varients in the sDefault table.
7656 ***************************************************************************/
7658 void init_locals(void)
7663 /***************************************************************************
7664 Process a new section (service). At this stage all sections are services.
7665 Later we'll have special sections that permit server parameters to be set.
7666 Returns true on success, false on failure.
7667 ***************************************************************************/
7669 static bool do_section(const char *pszSectionName, void *userdata)
7672 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7673 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7676 /* if we were in a global section then do the local inits */
7677 if (bInGlobalSection && !isglobal)
7680 /* if we've just struck a global section, note the fact. */
7681 bInGlobalSection = isglobal;
7683 /* check for multiple global sections */
7684 if (bInGlobalSection) {
7685 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7689 if (!bInGlobalSection && bGlobalOnly)
7692 /* if we have a current service, tidy it up before moving on */
7695 if (iServiceIndex >= 0)
7696 bRetval = service_ok(iServiceIndex);
7698 /* if all is still well, move to the next record in the services array */
7700 /* We put this here to avoid an odd message order if messages are */
7701 /* issued by the post-processing of a previous section. */
7702 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7704 iServiceIndex = add_a_service(&sDefault, pszSectionName);
7705 if (iServiceIndex < 0) {
7706 DEBUG(0, ("Failed to add a new service\n"));
7709 /* Clean all parametric options for service */
7710 /* They will be added during parsing again */
7711 free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
7718 /***************************************************************************
7719 Determine if a partcular base parameter is currentl set to the default value.
7720 ***************************************************************************/
7722 static bool is_default(int i)
7724 if (!defaults_saved)
7726 switch (parm_table[i].type) {
7729 return str_list_equal((const char **)parm_table[i].def.lvalue,
7730 *(const char ***)lp_parm_ptr(NULL,
7734 return strequal(parm_table[i].def.svalue,
7735 *(char **)lp_parm_ptr(NULL,
7739 return parm_table[i].def.bvalue ==
7740 *(bool *)lp_parm_ptr(NULL,
7743 return parm_table[i].def.cvalue ==
7744 *(char *)lp_parm_ptr(NULL,
7750 return parm_table[i].def.ivalue ==
7751 *(int *)lp_parm_ptr(NULL,
7759 /***************************************************************************
7760 Display the contents of the global structure.
7761 ***************************************************************************/
7763 static void dump_globals(FILE *f)
7766 struct parmlist_entry *data;
7768 fprintf(f, "[global]\n");
7770 for (i = 0; parm_table[i].label; i++)
7771 if (parm_table[i].p_class == P_GLOBAL &&
7772 !(parm_table[i].flags & FLAG_META) &&
7773 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
7774 if (defaults_saved && is_default(i))
7776 fprintf(f, "\t%s = ", parm_table[i].label);
7777 print_parameter(&parm_table[i], lp_parm_ptr(NULL,
7782 if (Globals.param_opt != NULL) {
7783 data = Globals.param_opt;
7785 fprintf(f, "\t%s = %s\n", data->key, data->value);
7792 /***************************************************************************
7793 Return true if a local parameter is currently set to the global default.
7794 ***************************************************************************/
7796 bool lp_is_default(int snum, struct parm_struct *parm)
7798 return equal_parameter(parm->type,
7799 lp_parm_ptr(ServicePtrs[snum], parm),
7800 lp_parm_ptr(NULL, parm));
7803 /***************************************************************************
7804 Display the contents of a single services record.
7805 ***************************************************************************/
7807 static void dump_a_service(struct loadparm_service *pService, FILE * f)
7810 struct parmlist_entry *data;
7812 if (pService != &sDefault)
7813 fprintf(f, "[%s]\n", pService->szService);
7815 for (i = 0; parm_table[i].label; i++) {
7817 if (parm_table[i].p_class == P_LOCAL &&
7818 !(parm_table[i].flags & FLAG_META) &&
7819 (*parm_table[i].label != '-') &&
7820 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7822 if (pService == &sDefault) {
7823 if (defaults_saved && is_default(i))
7826 if (equal_parameter(parm_table[i].type,
7827 lp_parm_ptr(pService, &parm_table[i]),
7828 lp_parm_ptr(NULL, &parm_table[i])))
7832 fprintf(f, "\t%s = ", parm_table[i].label);
7833 print_parameter(&parm_table[i],
7834 lp_parm_ptr(pService, &parm_table[i]),
7840 if (pService->param_opt != NULL) {
7841 data = pService->param_opt;
7843 fprintf(f, "\t%s = %s\n", data->key, data->value);
7849 /***************************************************************************
7850 Display the contents of a parameter of a single services record.
7851 ***************************************************************************/
7853 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7856 bool result = false;
7859 fstring local_parm_name;
7861 const char *parm_opt_value;
7863 /* check for parametrical option */
7864 fstrcpy( local_parm_name, parm_name);
7865 parm_opt = strchr( local_parm_name, ':');
7870 if (strlen(parm_opt)) {
7871 parm_opt_value = lp_parm_const_string( snum,
7872 local_parm_name, parm_opt, NULL);
7873 if (parm_opt_value) {
7874 printf( "%s\n", parm_opt_value);
7881 /* check for a key and print the value */
7888 for (i = 0; parm_table[i].label; i++) {
7889 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7890 !(parm_table[i].flags & FLAG_META) &&
7891 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7892 (*parm_table[i].label != '-') &&
7893 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7898 ptr = lp_parm_ptr(NULL,
7901 ptr = lp_parm_ptr(ServicePtrs[snum],
7905 print_parameter(&parm_table[i],
7916 /***************************************************************************
7917 Return info about the requested parameter (given as a string).
7918 Return NULL when the string is not a valid parameter name.
7919 ***************************************************************************/
7921 struct parm_struct *lp_get_parameter(const char *param_name)
7923 int num = map_parameter(param_name);
7929 return &parm_table[num];
7932 /***************************************************************************
7933 Return info about the next parameter in a service.
7934 snum==GLOBAL_SECTION_SNUM gives the globals.
7935 Return NULL when out of parameters.
7936 ***************************************************************************/
7938 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
7941 /* do the globals */
7942 for (; parm_table[*i].label; (*i)++) {
7943 if (parm_table[*i].p_class == P_SEPARATOR)
7944 return &parm_table[(*i)++];
7946 if ((*parm_table[*i].label == '-'))
7950 && (parm_table[*i].offset ==
7951 parm_table[(*i) - 1].offset)
7952 && (parm_table[*i].p_class ==
7953 parm_table[(*i) - 1].p_class))
7956 if (is_default(*i) && !allparameters)
7959 return &parm_table[(*i)++];
7962 struct loadparm_service *pService = ServicePtrs[snum];
7964 for (; parm_table[*i].label; (*i)++) {
7965 if (parm_table[*i].p_class == P_SEPARATOR)
7966 return &parm_table[(*i)++];
7968 if (parm_table[*i].p_class == P_LOCAL &&
7969 (*parm_table[*i].label != '-') &&
7971 (parm_table[*i].offset !=
7972 parm_table[(*i) - 1].offset)))
7974 if (allparameters ||
7975 !equal_parameter(parm_table[*i].type,
7976 lp_parm_ptr(pService,
7981 return &parm_table[(*i)++];
7992 /***************************************************************************
7993 Display the contents of a single copy structure.
7994 ***************************************************************************/
7995 static void dump_copy_map(bool *pcopymap)
8001 printf("\n\tNon-Copied parameters:\n");
8003 for (i = 0; parm_table[i].label; i++)
8004 if (parm_table[i].p_class == P_LOCAL &&
8005 parm_table[i].ptr && !pcopymap[i] &&
8006 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8008 printf("\t\t%s\n", parm_table[i].label);
8013 /***************************************************************************
8014 Return TRUE if the passed service number is within range.
8015 ***************************************************************************/
8017 bool lp_snum_ok(int iService)
8019 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8022 /***************************************************************************
8023 Auto-load some home services.
8024 ***************************************************************************/
8026 static void lp_add_auto_services(char *str)
8036 s = SMB_STRDUP(str);
8040 homes = lp_servicenumber(HOMES_NAME);
8042 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8043 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8046 if (lp_servicenumber(p) >= 0)
8049 home = get_user_home_dir(talloc_tos(), p);
8051 if (home && home[0] && homes >= 0)
8052 lp_add_home(p, homes, p, home);
8059 /***************************************************************************
8060 Auto-load one printer.
8061 ***************************************************************************/
8063 void lp_add_one_printer(const char *name, const char *comment,
8064 const char *location, void *pdata)
8066 int printers = lp_servicenumber(PRINTERS_NAME);
8069 if (lp_servicenumber(name) < 0) {
8070 lp_add_printer(name, printers);
8071 if ((i = lp_servicenumber(name)) >= 0) {
8072 string_set(&ServicePtrs[i]->comment, comment);
8073 ServicePtrs[i]->autoloaded = true;
8078 /***************************************************************************
8079 Have we loaded a services file yet?
8080 ***************************************************************************/
8082 bool lp_loaded(void)
8087 /***************************************************************************
8088 Unload unused services.
8089 ***************************************************************************/
8091 void lp_killunused(struct smbd_server_connection *sconn,
8092 bool (*snumused) (struct smbd_server_connection *, int))
8095 for (i = 0; i < iNumServices; i++) {
8099 /* don't kill autoloaded or usershare services */
8100 if ( ServicePtrs[i]->autoloaded ||
8101 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8105 if (!snumused || !snumused(sconn, i)) {
8106 free_service_byindex(i);
8112 * Kill all except autoloaded and usershare services - convenience wrapper
8114 void lp_kill_all_services(void)
8116 lp_killunused(NULL, NULL);
8119 /***************************************************************************
8121 ***************************************************************************/
8123 void lp_killservice(int iServiceIn)
8125 if (VALID(iServiceIn)) {
8126 free_service_byindex(iServiceIn);
8130 /***************************************************************************
8131 Save the curent values of all global and sDefault parameters into the
8132 defaults union. This allows swat and testparm to show only the
8133 changed (ie. non-default) parameters.
8134 ***************************************************************************/
8136 static void lp_save_defaults(void)
8139 for (i = 0; parm_table[i].label; i++) {
8140 if (i > 0 && parm_table[i].offset == parm_table[i - 1].offset
8141 && parm_table[i].p_class == parm_table[i - 1].p_class)
8143 switch (parm_table[i].type) {
8146 parm_table[i].def.lvalue = str_list_copy(
8147 NULL, *(const char ***)lp_parm_ptr(NULL, &parm_table[i]));
8151 parm_table[i].def.svalue = SMB_STRDUP(*(char **)lp_parm_ptr(NULL, &parm_table[i]));
8155 parm_table[i].def.bvalue =
8156 *(bool *)lp_parm_ptr(NULL, &parm_table[i]);
8159 parm_table[i].def.cvalue =
8160 *(char *)lp_parm_ptr(NULL, &parm_table[i]);
8166 parm_table[i].def.ivalue =
8167 *(int *)lp_parm_ptr(NULL, &parm_table[i]);
8173 defaults_saved = true;
8176 /***********************************************************
8177 If we should send plaintext/LANMAN passwords in the clinet
8178 ************************************************************/
8180 static void set_allowed_client_auth(void)
8182 if (Globals.bClientNTLMv2Auth) {
8183 Globals.bClientLanManAuth = false;
8185 if (!Globals.bClientLanManAuth) {
8186 Globals.bClientPlaintextAuth = false;
8190 /***************************************************************************
8192 The following code allows smbd to read a user defined share file.
8193 Yes, this is my intent. Yes, I'm comfortable with that...
8195 THE FOLLOWING IS SECURITY CRITICAL CODE.
8197 It washes your clothes, it cleans your house, it guards you while you sleep...
8198 Do not f%^k with it....
8199 ***************************************************************************/
8201 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8203 /***************************************************************************
8204 Check allowed stat state of a usershare file.
8205 Ensure we print out who is dicking with us so the admin can
8206 get their sorry ass fired.
8207 ***************************************************************************/
8209 static bool check_usershare_stat(const char *fname,
8210 const SMB_STRUCT_STAT *psbuf)
8212 if (!S_ISREG(psbuf->st_ex_mode)) {
8213 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8214 "not a regular file\n",
8215 fname, (unsigned int)psbuf->st_ex_uid ));
8219 /* Ensure this doesn't have the other write bit set. */
8220 if (psbuf->st_ex_mode & S_IWOTH) {
8221 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8222 "public write. Refusing to allow as a usershare file.\n",
8223 fname, (unsigned int)psbuf->st_ex_uid ));
8227 /* Should be 10k or less. */
8228 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8229 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8230 "too large (%u) to be a user share file.\n",
8231 fname, (unsigned int)psbuf->st_ex_uid,
8232 (unsigned int)psbuf->st_ex_size ));
8239 /***************************************************************************
8240 Parse the contents of a usershare file.
8241 ***************************************************************************/
8243 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8244 SMB_STRUCT_STAT *psbuf,
8245 const char *servicename,
8249 char **pp_sharepath,
8251 char **pp_cp_servicename,
8252 struct security_descriptor **ppsd,
8255 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8256 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8259 SMB_STRUCT_STAT sbuf;
8260 char *sharepath = NULL;
8261 char *comment = NULL;
8263 *pp_sharepath = NULL;
8266 *pallow_guest = false;
8269 return USERSHARE_MALFORMED_FILE;
8272 if (strcmp(lines[0], "#VERSION 1") == 0) {
8274 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8277 return USERSHARE_MALFORMED_FILE;
8280 return USERSHARE_BAD_VERSION;
8283 if (strncmp(lines[1], "path=", 5) != 0) {
8284 return USERSHARE_MALFORMED_PATH;
8287 sharepath = talloc_strdup(ctx, &lines[1][5]);
8289 return USERSHARE_POSIX_ERR;
8291 trim_string(sharepath, " ", " ");
8293 if (strncmp(lines[2], "comment=", 8) != 0) {
8294 return USERSHARE_MALFORMED_COMMENT_DEF;
8297 comment = talloc_strdup(ctx, &lines[2][8]);
8299 return USERSHARE_POSIX_ERR;
8301 trim_string(comment, " ", " ");
8302 trim_char(comment, '"', '"');
8304 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8305 return USERSHARE_MALFORMED_ACL_DEF;
8308 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8309 return USERSHARE_ACL_ERR;
8313 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8314 return USERSHARE_MALFORMED_ACL_DEF;
8316 if (lines[4][9] == 'y') {
8317 *pallow_guest = true;
8320 /* Backwards compatible extension to file version #2. */
8322 if (strncmp(lines[5], "sharename=", 10) != 0) {
8323 return USERSHARE_MALFORMED_SHARENAME_DEF;
8325 if (!strequal(&lines[5][10], servicename)) {
8326 return USERSHARE_BAD_SHARENAME;
8328 *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
8329 if (!*pp_cp_servicename) {
8330 return USERSHARE_POSIX_ERR;
8335 if (*pp_cp_servicename == NULL) {
8336 *pp_cp_servicename = talloc_strdup(ctx, servicename);
8337 if (!*pp_cp_servicename) {
8338 return USERSHARE_POSIX_ERR;
8342 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8343 /* Path didn't change, no checks needed. */
8344 *pp_sharepath = sharepath;
8345 *pp_comment = comment;
8346 return USERSHARE_OK;
8349 /* The path *must* be absolute. */
8350 if (sharepath[0] != '/') {
8351 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8352 servicename, sharepath));
8353 return USERSHARE_PATH_NOT_ABSOLUTE;
8356 /* If there is a usershare prefix deny list ensure one of these paths
8357 doesn't match the start of the user given path. */
8358 if (prefixdenylist) {
8360 for ( i=0; prefixdenylist[i]; i++ ) {
8361 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8362 servicename, i, prefixdenylist[i], sharepath ));
8363 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8364 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8365 "usershare prefix deny list entries.\n",
8366 servicename, sharepath));
8367 return USERSHARE_PATH_IS_DENIED;
8372 /* If there is a usershare prefix allow list ensure one of these paths
8373 does match the start of the user given path. */
8375 if (prefixallowlist) {
8377 for ( i=0; prefixallowlist[i]; i++ ) {
8378 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8379 servicename, i, prefixallowlist[i], sharepath ));
8380 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8384 if (prefixallowlist[i] == NULL) {
8385 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8386 "usershare prefix allow list entries.\n",
8387 servicename, sharepath));
8388 return USERSHARE_PATH_NOT_ALLOWED;
8392 /* Ensure this is pointing to a directory. */
8393 dp = opendir(sharepath);
8396 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8397 servicename, sharepath));
8398 return USERSHARE_PATH_NOT_DIRECTORY;
8401 /* Ensure the owner of the usershare file has permission to share
8404 if (sys_stat(sharepath, &sbuf, false) == -1) {
8405 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8406 servicename, sharepath, strerror(errno) ));
8408 return USERSHARE_POSIX_ERR;
8413 if (!S_ISDIR(sbuf.st_ex_mode)) {
8414 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8415 servicename, sharepath ));
8416 return USERSHARE_PATH_NOT_DIRECTORY;
8419 /* Check if sharing is restricted to owner-only. */
8420 /* psbuf is the stat of the usershare definition file,
8421 sbuf is the stat of the target directory to be shared. */
8423 if (lp_usershare_owner_only()) {
8424 /* root can share anything. */
8425 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8426 return USERSHARE_PATH_NOT_ALLOWED;
8430 *pp_sharepath = sharepath;
8431 *pp_comment = comment;
8432 return USERSHARE_OK;
8435 /***************************************************************************
8436 Deal with a usershare file.
8439 -1 - Bad name, invalid contents.
8440 - service name already existed and not a usershare, problem
8441 with permissions to share directory etc.
8442 ***************************************************************************/
8444 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8446 SMB_STRUCT_STAT sbuf;
8447 SMB_STRUCT_STAT lsbuf;
8449 char *sharepath = NULL;
8450 char *comment = NULL;
8451 char *cp_service_name = NULL;
8452 char **lines = NULL;
8456 TALLOC_CTX *ctx = talloc_stackframe();
8457 struct security_descriptor *psd = NULL;
8458 bool guest_ok = false;
8459 char *canon_name = NULL;
8460 bool added_service = false;
8463 /* Ensure share name doesn't contain invalid characters. */
8464 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8465 DEBUG(0,("process_usershare_file: share name %s contains "
8466 "invalid characters (any of %s)\n",
8467 file_name, INVALID_SHARENAME_CHARS ));
8471 canon_name = canonicalize_servicename(ctx, file_name);
8476 fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
8481 /* Minimize the race condition by doing an lstat before we
8482 open and fstat. Ensure this isn't a symlink link. */
8484 if (sys_lstat(fname, &lsbuf, false) != 0) {
8485 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8486 fname, strerror(errno) ));
8490 /* This must be a regular file, not a symlink, directory or
8491 other strange filetype. */
8492 if (!check_usershare_stat(fname, &lsbuf)) {
8500 status = dbwrap_fetch_bystring(ServiceHash, canon_name,
8505 if (NT_STATUS_IS_OK(status) &&
8506 (data.dptr != NULL) &&
8507 (data.dsize == sizeof(iService))) {
8508 memcpy(&iService, data.dptr, sizeof(iService));
8512 if (iService != -1 &&
8513 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8514 &lsbuf.st_ex_mtime) == 0) {
8515 /* Nothing changed - Mark valid and return. */
8516 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8518 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8523 /* Try and open the file read only - no symlinks allowed. */
8525 fd = open(fname, O_RDONLY|O_NOFOLLOW, 0);
8527 fd = open(fname, O_RDONLY, 0);
8531 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8532 fname, strerror(errno) ));
8536 /* Now fstat to be *SURE* it's a regular file. */
8537 if (sys_fstat(fd, &sbuf, false) != 0) {
8539 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8540 fname, strerror(errno) ));
8544 /* Is it the same dev/inode as was lstated ? */
8545 if (lsbuf.st_ex_dev != sbuf.st_ex_dev || lsbuf.st_ex_ino != sbuf.st_ex_ino) {
8547 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8548 "Symlink spoofing going on ?\n", fname ));
8552 /* This must be a regular file, not a symlink, directory or
8553 other strange filetype. */
8554 if (!check_usershare_stat(fname, &sbuf)) {
8558 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8561 if (lines == NULL) {
8562 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8563 fname, (unsigned int)sbuf.st_ex_uid ));
8567 if (parse_usershare_file(ctx, &sbuf, file_name,
8568 iService, lines, numlines, &sharepath,
8569 &comment, &cp_service_name,
8570 &psd, &guest_ok) != USERSHARE_OK) {
8574 /* Everything ok - add the service possibly using a template. */
8576 const struct loadparm_service *sp = &sDefault;
8577 if (snum_template != -1) {
8578 sp = ServicePtrs[snum_template];
8581 if ((iService = add_a_service(sp, cp_service_name)) < 0) {
8582 DEBUG(0, ("process_usershare_file: Failed to add "
8583 "new service %s\n", cp_service_name));
8587 added_service = true;
8589 /* Read only is controlled by usershare ACL below. */
8590 ServicePtrs[iService]->bRead_only = false;
8593 /* Write the ACL of the new/modified share. */
8594 if (!set_share_security(canon_name, psd)) {
8595 DEBUG(0, ("process_usershare_file: Failed to set share "
8596 "security for user share %s\n",
8601 /* If from a template it may be marked invalid. */
8602 ServicePtrs[iService]->valid = true;
8604 /* Set the service as a valid usershare. */
8605 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8607 /* Set guest access. */
8608 if (lp_usershare_allow_guests()) {
8609 ServicePtrs[iService]->bGuest_ok = guest_ok;
8612 /* And note when it was loaded. */
8613 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8614 string_set(&ServicePtrs[iService]->szPath, sharepath);
8615 string_set(&ServicePtrs[iService]->comment, comment);
8621 if (ret == -1 && iService != -1 && added_service) {
8622 lp_remove_service(iService);
8630 /***************************************************************************
8631 Checks if a usershare entry has been modified since last load.
8632 ***************************************************************************/
8634 static bool usershare_exists(int iService, struct timespec *last_mod)
8636 SMB_STRUCT_STAT lsbuf;
8637 const char *usersharepath = Globals.szUsersharePath;
8640 if (asprintf(&fname, "%s/%s",
8642 ServicePtrs[iService]->szService) < 0) {
8646 if (sys_lstat(fname, &lsbuf, false) != 0) {
8651 if (!S_ISREG(lsbuf.st_ex_mode)) {
8657 *last_mod = lsbuf.st_ex_mtime;
8661 /***************************************************************************
8662 Load a usershare service by name. Returns a valid servicenumber or -1.
8663 ***************************************************************************/
8665 int load_usershare_service(const char *servicename)
8667 SMB_STRUCT_STAT sbuf;
8668 const char *usersharepath = Globals.szUsersharePath;
8669 int max_user_shares = Globals.iUsershareMaxShares;
8670 int snum_template = -1;
8672 if (*usersharepath == 0 || max_user_shares == 0) {
8676 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8677 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8678 usersharepath, strerror(errno) ));
8682 if (!S_ISDIR(sbuf.st_ex_mode)) {
8683 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8689 * This directory must be owned by root, and have the 't' bit set.
8690 * It also must not be writable by "other".
8694 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8696 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8698 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8699 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8704 /* Ensure the template share exists if it's set. */
8705 if (Globals.szUsershareTemplateShare[0]) {
8706 /* We can't use lp_servicenumber here as we are recommending that
8707 template shares have -valid=false set. */
8708 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8709 if (ServicePtrs[snum_template]->szService &&
8710 strequal(ServicePtrs[snum_template]->szService,
8711 Globals.szUsershareTemplateShare)) {
8716 if (snum_template == -1) {
8717 DEBUG(0,("load_usershare_service: usershare template share %s "
8718 "does not exist.\n",
8719 Globals.szUsershareTemplateShare ));
8724 return process_usershare_file(usersharepath, servicename, snum_template);
8727 /***************************************************************************
8728 Load all user defined shares from the user share directory.
8729 We only do this if we're enumerating the share list.
8730 This is the function that can delete usershares that have
8732 ***************************************************************************/
8734 int load_usershare_shares(struct smbd_server_connection *sconn,
8735 bool (*snumused) (struct smbd_server_connection *, int))
8738 SMB_STRUCT_STAT sbuf;
8740 int num_usershares = 0;
8741 int max_user_shares = Globals.iUsershareMaxShares;
8742 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8743 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8744 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8746 int snum_template = -1;
8747 const char *usersharepath = Globals.szUsersharePath;
8748 int ret = lp_numservices();
8750 if (max_user_shares == 0 || *usersharepath == '\0') {
8751 return lp_numservices();
8754 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8755 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8756 usersharepath, strerror(errno) ));
8761 * This directory must be owned by root, and have the 't' bit set.
8762 * It also must not be writable by "other".
8766 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8768 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8770 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8771 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8776 /* Ensure the template share exists if it's set. */
8777 if (Globals.szUsershareTemplateShare[0]) {
8778 /* We can't use lp_servicenumber here as we are recommending that
8779 template shares have -valid=false set. */
8780 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8781 if (ServicePtrs[snum_template]->szService &&
8782 strequal(ServicePtrs[snum_template]->szService,
8783 Globals.szUsershareTemplateShare)) {
8788 if (snum_template == -1) {
8789 DEBUG(0,("load_usershare_shares: usershare template share %s "
8790 "does not exist.\n",
8791 Globals.szUsershareTemplateShare ));
8796 /* Mark all existing usershares as pending delete. */
8797 for (iService = iNumServices - 1; iService >= 0; iService--) {
8798 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8799 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8803 dp = opendir(usersharepath);
8805 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8806 usersharepath, strerror(errno) ));
8810 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8812 num_dir_entries++ ) {
8814 const char *n = de->d_name;
8816 /* Ignore . and .. */
8818 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8824 /* Temporary file used when creating a share. */
8825 num_tmp_dir_entries++;
8828 /* Allow 20% tmp entries. */
8829 if (num_tmp_dir_entries > allowed_tmp_entries) {
8830 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8831 "in directory %s\n",
8832 num_tmp_dir_entries, usersharepath));
8836 r = process_usershare_file(usersharepath, n, snum_template);
8838 /* Update the services count. */
8840 if (num_usershares >= max_user_shares) {
8841 DEBUG(0,("load_usershare_shares: max user shares reached "
8842 "on file %s in directory %s\n",
8843 n, usersharepath ));
8846 } else if (r == -1) {
8847 num_bad_dir_entries++;
8850 /* Allow 20% bad entries. */
8851 if (num_bad_dir_entries > allowed_bad_entries) {
8852 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8853 "in directory %s\n",
8854 num_bad_dir_entries, usersharepath));
8858 /* Allow 20% bad entries. */
8859 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
8860 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8861 "in directory %s\n",
8862 num_dir_entries, usersharepath));
8869 /* Sweep through and delete any non-refreshed usershares that are
8870 not currently in use. */
8871 for (iService = iNumServices - 1; iService >= 0; iService--) {
8872 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
8873 if (snumused && snumused(sconn, iService)) {
8876 /* Remove from the share ACL db. */
8877 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8878 lp_servicename(iService) ));
8879 delete_share_security(lp_servicename(iService));
8880 free_service_byindex(iService);
8884 return lp_numservices();
8887 /********************************************************
8888 Destroy global resources allocated in this file
8889 ********************************************************/
8891 void gfree_loadparm(void)
8897 /* Free resources allocated to services */
8899 for ( i = 0; i < iNumServices; i++ ) {
8901 free_service_byindex(i);
8905 SAFE_FREE( ServicePtrs );
8908 /* Now release all resources allocated to global
8909 parameters and the default service */
8911 free_global_parameters();
8915 /***************************************************************************
8916 Allow client apps to specify that they are a client
8917 ***************************************************************************/
8918 static void lp_set_in_client(bool b)
8924 /***************************************************************************
8925 Determine if we're running in a client app
8926 ***************************************************************************/
8927 static bool lp_is_in_client(void)
8932 /***************************************************************************
8933 Load the services array from the services file. Return true on success,
8935 ***************************************************************************/
8937 static bool lp_load_ex(const char *pszFname,
8941 bool initialize_globals,
8942 bool allow_include_registry,
8943 bool load_all_shares)
8950 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
8952 bInGlobalSection = true;
8953 bGlobalOnly = global_only;
8954 bAllowIncludeRegistry = allow_include_registry;
8956 init_globals(initialize_globals);
8960 if (save_defaults) {
8965 if (!initialize_globals) {
8966 free_param_opts(&Globals.param_opt);
8967 apply_lp_set_cmdline();
8970 lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
8972 /* We get sections first, so have to start 'behind' to make up */
8975 if (lp_config_backend_is_file()) {
8976 n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
8977 current_user_info.domain,
8980 smb_panic("lp_load_ex: out of memory");
8983 add_to_file_list(pszFname, n2);
8985 bRetval = pm_process(n2, do_section, do_parameter, NULL);
8988 /* finish up the last section */
8989 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
8991 if (iServiceIndex >= 0) {
8992 bRetval = service_ok(iServiceIndex);
8996 if (lp_config_backend_is_registry()) {
8997 /* config backend changed to registry in config file */
8999 * We need to use this extra global variable here to
9000 * survive restart: init_globals uses this as a default
9001 * for ConfigBackend. Otherwise, init_globals would
9002 * send us into an endless loop here.
9004 config_backend = CONFIG_BACKEND_REGISTRY;
9006 DEBUG(1, ("lp_load_ex: changing to config backend "
9009 lp_kill_all_services();
9010 return lp_load_ex(pszFname, global_only, save_defaults,
9011 add_ipc, initialize_globals,
9012 allow_include_registry,
9015 } else if (lp_config_backend_is_registry()) {
9016 bRetval = process_registry_globals();
9018 DEBUG(0, ("Illegal config backend given: %d\n",
9019 lp_config_backend()));
9023 if (bRetval && lp_registry_shares()) {
9024 if (load_all_shares) {
9025 bRetval = process_registry_shares();
9027 bRetval = reload_registry_shares();
9031 lp_add_auto_services(lp_auto_services());
9034 /* When 'restrict anonymous = 2' guest connections to ipc$
9036 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9037 if ( lp_enable_asu_support() ) {
9038 lp_add_ipc("ADMIN$", false);
9042 set_allowed_client_auth();
9044 if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) {
9045 DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
9046 lp_passwordserver()));
9051 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9052 /* if bWINSsupport is true and we are in the client */
9053 if (lp_is_in_client() && Globals.bWINSsupport) {
9054 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9059 fault_configure(smb_panic_s3);
9061 bAllowIncludeRegistry = true;
9066 bool lp_load(const char *pszFname,
9070 bool initialize_globals)
9072 return lp_load_ex(pszFname,
9077 true, /* allow_include_registry */
9078 false); /* load_all_shares*/
9081 bool lp_load_initial_only(const char *pszFname)
9083 return lp_load_ex(pszFname,
9084 true, /* global only */
9085 false, /* save_defaults */
9086 false, /* add_ipc */
9087 true, /* initialize_globals */
9088 false, /* allow_include_registry */
9089 false); /* load_all_shares*/
9093 * most common lp_load wrapper, loading only the globals
9095 bool lp_load_global(const char *file_name)
9097 return lp_load_ex(file_name,
9098 true, /* global_only */
9099 false, /* save_defaults */
9100 false, /* add_ipc */
9101 true, /* initialize_globals */
9102 true, /* allow_include_registry */
9103 false); /* load_all_shares*/
9107 * lp_load wrapper, especially for clients
9109 bool lp_load_client(const char *file_name)
9111 lp_set_in_client(true);
9113 return lp_load_global(file_name);
9117 * lp_load wrapper, loading only globals, but intended
9118 * for subsequent calls, not reinitializing the globals
9121 bool lp_load_global_no_reinit(const char *file_name)
9123 return lp_load_ex(file_name,
9124 true, /* global_only */
9125 false, /* save_defaults */
9126 false, /* add_ipc */
9127 false, /* initialize_globals */
9128 true, /* allow_include_registry */
9129 false); /* load_all_shares*/
9133 * lp_load wrapper, especially for clients, no reinitialization
9135 bool lp_load_client_no_reinit(const char *file_name)
9137 lp_set_in_client(true);
9139 return lp_load_global_no_reinit(file_name);
9142 bool lp_load_with_registry_shares(const char *pszFname,
9146 bool initialize_globals)
9148 return lp_load_ex(pszFname,
9153 true, /* allow_include_registry */
9154 true); /* load_all_shares*/
9157 /***************************************************************************
9158 Return the max number of services.
9159 ***************************************************************************/
9161 int lp_numservices(void)
9163 return (iNumServices);
9166 /***************************************************************************
9167 Display the contents of the services array in human-readable form.
9168 ***************************************************************************/
9170 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9175 defaults_saved = false;
9179 dump_a_service(&sDefault, f);
9181 for (iService = 0; iService < maxtoprint; iService++) {
9183 lp_dump_one(f, show_defaults, iService);
9187 /***************************************************************************
9188 Display the contents of one service in human-readable form.
9189 ***************************************************************************/
9191 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9194 if (ServicePtrs[snum]->szService[0] == '\0')
9196 dump_a_service(ServicePtrs[snum], f);
9200 /***************************************************************************
9201 Return the number of the service with the given name, or -1 if it doesn't
9202 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9203 getservicebyname()! This works ONLY if all services have been loaded, and
9204 does not copy the found service.
9205 ***************************************************************************/
9207 int lp_servicenumber(const char *pszServiceName)
9210 fstring serviceName;
9212 if (!pszServiceName) {
9213 return GLOBAL_SECTION_SNUM;
9216 for (iService = iNumServices - 1; iService >= 0; iService--) {
9217 if (VALID(iService) && ServicePtrs[iService]->szService) {
9219 * The substitution here is used to support %U is
9222 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9223 standard_sub_basic(get_current_username(),
9224 current_user_info.domain,
9225 serviceName,sizeof(serviceName));
9226 if (strequal(serviceName, pszServiceName)) {
9232 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9233 struct timespec last_mod;
9235 if (!usershare_exists(iService, &last_mod)) {
9236 /* Remove the share security tdb entry for it. */
9237 delete_share_security(lp_servicename(iService));
9238 /* Remove it from the array. */
9239 free_service_byindex(iService);
9240 /* Doesn't exist anymore. */
9241 return GLOBAL_SECTION_SNUM;
9244 /* Has it been modified ? If so delete and reload. */
9245 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9247 /* Remove it from the array. */
9248 free_service_byindex(iService);
9249 /* and now reload it. */
9250 iService = load_usershare_service(pszServiceName);
9255 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9256 return GLOBAL_SECTION_SNUM;
9262 /*******************************************************************
9263 A useful volume label function.
9264 ********************************************************************/
9266 const char *volume_label(int snum)
9269 const char *label = lp_volume(snum);
9271 label = lp_servicename(snum);
9274 /* This returns a 33 byte guarenteed null terminated string. */
9275 ret = talloc_strndup(talloc_tos(), label, 32);
9282 /*******************************************************************
9283 Get the default server type we will announce as via nmbd.
9284 ********************************************************************/
9286 int lp_default_server_announce(void)
9288 int default_server_announce = 0;
9289 default_server_announce |= SV_TYPE_WORKSTATION;
9290 default_server_announce |= SV_TYPE_SERVER;
9291 default_server_announce |= SV_TYPE_SERVER_UNIX;
9293 /* note that the flag should be set only if we have a
9294 printer service but nmbd doesn't actually load the
9295 services so we can't tell --jerry */
9297 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9299 default_server_announce |= SV_TYPE_SERVER_NT;
9300 default_server_announce |= SV_TYPE_NT;
9302 switch (lp_server_role()) {
9303 case ROLE_DOMAIN_MEMBER:
9304 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9306 case ROLE_DOMAIN_PDC:
9307 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9309 case ROLE_DOMAIN_BDC:
9310 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9312 case ROLE_STANDALONE:
9316 if (lp_time_server())
9317 default_server_announce |= SV_TYPE_TIME_SOURCE;
9319 if (lp_host_msdfs())
9320 default_server_announce |= SV_TYPE_DFS_SERVER;
9322 return default_server_announce;
9325 /***********************************************************
9326 If we are PDC then prefer us as DMB
9327 ************************************************************/
9329 bool lp_domain_master(void)
9331 if (Globals.iDomainMaster == Auto)
9332 return (lp_server_role() == ROLE_DOMAIN_PDC);
9334 return (bool)Globals.iDomainMaster;
9337 /***********************************************************
9338 If we are PDC then prefer us as DMB
9339 ************************************************************/
9341 static bool lp_domain_master_true_or_auto(void)
9343 if (Globals.iDomainMaster) /* auto or yes */
9349 /***********************************************************
9350 If we are DMB then prefer us as LMB
9351 ************************************************************/
9353 bool lp_preferred_master(void)
9355 if (Globals.iPreferredMaster == Auto)
9356 return (lp_local_master() && lp_domain_master());
9358 return (bool)Globals.iPreferredMaster;
9361 /*******************************************************************
9363 ********************************************************************/
9365 void lp_remove_service(int snum)
9367 ServicePtrs[snum]->valid = false;
9368 invalid_services[num_invalid_services++] = snum;
9371 /*******************************************************************
9373 ********************************************************************/
9375 void lp_copy_service(int snum, const char *new_name)
9377 do_section(new_name, NULL);
9379 snum = lp_servicenumber(new_name);
9381 lp_do_parameter(snum, "copy", lp_servicename(snum));
9386 /***********************************************************
9387 Set the global name resolution order (used in smbclient).
9388 ************************************************************/
9390 void lp_set_name_resolve_order(const char *new_order)
9392 string_set(&Globals.szNameResolveOrder, new_order);
9395 const char *lp_printername(int snum)
9397 const char *ret = lp__printername(snum);
9398 if (ret == NULL || (ret != NULL && *ret == '\0'))
9399 ret = lp_const_servicename(snum);
9405 /***********************************************************
9406 Allow daemons such as winbindd to fix their logfile name.
9407 ************************************************************/
9409 void lp_set_logfile(const char *name)
9411 string_set(&Globals.logfile, name);
9412 debug_set_logfile(name);
9415 /*******************************************************************
9416 Return the max print jobs per queue.
9417 ********************************************************************/
9419 int lp_maxprintjobs(int snum)
9421 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9422 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9423 maxjobs = PRINT_MAX_JOBID - 1;
9428 const char *lp_printcapname(void)
9430 if ((Globals.szPrintcapname != NULL) &&
9431 (Globals.szPrintcapname[0] != '\0'))
9432 return Globals.szPrintcapname;
9434 if (sDefault.iPrinting == PRINT_CUPS) {
9442 if (sDefault.iPrinting == PRINT_BSD)
9443 return "/etc/printcap";
9445 return PRINTCAP_NAME;
9448 static uint32 spoolss_state;
9450 bool lp_disable_spoolss( void )
9452 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9453 spoolss_state = lp__disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9455 return spoolss_state == SVCCTL_STOPPED ? true : false;
9458 void lp_set_spoolss_state( uint32 state )
9460 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9462 spoolss_state = state;
9465 uint32 lp_get_spoolss_state( void )
9467 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9470 /*******************************************************************
9471 Ensure we don't use sendfile if server smb signing is active.
9472 ********************************************************************/
9474 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9476 bool sign_active = false;
9478 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9479 if (get_Protocol() < PROTOCOL_NT1) {
9482 if (signing_state) {
9483 sign_active = smb_signing_is_active(signing_state);
9485 return (lp__use_sendfile(snum) &&
9486 (get_remote_arch() != RA_WIN95) &&
9490 /*******************************************************************
9491 Turn off sendfile if we find the underlying OS doesn't support it.
9492 ********************************************************************/
9494 void set_use_sendfile(int snum, bool val)
9496 if (LP_SNUM_OK(snum))
9497 ServicePtrs[snum]->bUseSendfile = val;
9499 sDefault.bUseSendfile = val;
9502 /*******************************************************************
9503 Turn off storing DOS attributes if this share doesn't support it.
9504 ********************************************************************/
9506 void set_store_dos_attributes(int snum, bool val)
9508 if (!LP_SNUM_OK(snum))
9510 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9513 void lp_set_mangling_method(const char *new_method)
9515 string_set(&Globals.szManglingMethod, new_method);
9518 /*******************************************************************
9519 Global state for POSIX pathname processing.
9520 ********************************************************************/
9522 static bool posix_pathnames;
9524 bool lp_posix_pathnames(void)
9526 return posix_pathnames;
9529 /*******************************************************************
9530 Change everything needed to ensure POSIX pathname processing (currently
9532 ********************************************************************/
9534 void lp_set_posix_pathnames(void)
9536 posix_pathnames = true;
9539 /*******************************************************************
9540 Global state for POSIX lock processing - CIFS unix extensions.
9541 ********************************************************************/
9543 bool posix_default_lock_was_set;
9544 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9546 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9548 if (posix_default_lock_was_set) {
9549 return posix_cifsx_locktype;
9551 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9555 /*******************************************************************
9556 ********************************************************************/
9558 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9560 posix_default_lock_was_set = true;
9561 posix_cifsx_locktype = val;
9564 int lp_min_receive_file_size(void)
9566 if (Globals.iminreceivefile < 0) {
9569 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9572 /*******************************************************************
9573 If socket address is an empty character string, it is necessary to
9574 define it as "0.0.0.0".
9575 ********************************************************************/
9577 const char *lp_socket_address(void)
9579 char *sock_addr = Globals.szSocketAddress;
9581 if (sock_addr[0] == '\0'){
9582 string_set(&Globals.szSocketAddress, "0.0.0.0");
9584 return Globals.szSocketAddress;
9587 /*******************************************************************
9588 Safe wide links checks.
9589 This helper function always verify the validity of wide links,
9590 even after a configuration file reload.
9591 ********************************************************************/
9593 static bool lp_widelinks_internal(int snum)
9595 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9596 sDefault.bWidelinks);
9599 void widelinks_warning(int snum)
9601 if (lp_allow_insecure_widelinks()) {
9605 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9606 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9607 "These parameters are incompatible. "
9608 "Wide links will be disabled for this share.\n",
9609 lp_servicename(snum) ));
9613 bool lp_widelinks(int snum)
9615 /* wide links is always incompatible with unix extensions */
9616 if (lp_unix_extensions()) {
9618 * Unless we have "allow insecure widelinks"
9621 if (!lp_allow_insecure_widelinks()) {
9626 return lp_widelinks_internal(snum);
9629 bool lp_writeraw(void)
9631 if (lp_async_smb_echo_handler()) {
9634 return lp__writeraw();
9637 bool lp_readraw(void)
9639 if (lp_async_smb_echo_handler()) {
9642 return lp__readraw();
9645 int lp_server_role(void)
9647 return lp_find_server_role(lp__server_role(),
9650 lp_domain_master_true_or_auto());
9653 const char *lp_ctdbd_socket(void)
9655 const char *result = lp__ctdbd_socket();
9657 #ifdef CLUSTER_SUPPORT
9658 if ((result == NULL) || (*result == '\0')) {