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"
72 #ifdef HAVE_SYS_SYSCTL_H
73 #include <sys/sysctl.h>
76 #ifdef HAVE_HTTPCONNECTENCRYPT
77 #include <cups/http.h>
82 extern userdom_struct current_user_info;
84 /* the special value for the include parameter
85 * to be interpreted not as a file name but to
86 * trigger loading of the global smb.conf options
88 #ifndef INCLUDE_REGISTRY_NAME
89 #define INCLUDE_REGISTRY_NAME "registry"
92 static bool in_client = false; /* Not in the client by default */
93 static struct smbconf_csn conf_last_csn;
95 #define CONFIG_BACKEND_FILE 0
96 #define CONFIG_BACKEND_REGISTRY 1
98 static int config_backend = CONFIG_BACKEND_FILE;
100 /* some helpful bits */
101 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
102 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
104 #define USERSHARE_VALID 1
105 #define USERSHARE_PENDING_DELETE 2
107 static bool defaults_saved = false;
109 #define LOADPARM_EXTRA_GLOBALS \
110 struct parmlist_entry *param_opt; \
113 int iminreceivefile; \
114 char *szPrintcapname; \
116 int iPreferredMaster; \
118 char *szLdapMachineSuffix; \
119 char *szLdapUserSuffix; \
120 char *szLdapIdmapSuffix; \
121 char *szLdapGroupSuffix; \
124 char *szSocketAddress; \
125 char *szUsershareTemplateShare; \
128 int winbindMaxDomainConnections; \
129 int ismb2_max_credits;
131 #include "param/param_global.h"
133 static struct loadparm_global Globals;
135 /* This is a default service used to prime a services structure */
136 static struct loadparm_service sDefault =
141 .usershare_last_mod = {0, 0},
145 .szInvalidUsers = NULL,
146 .szValidUsers = NULL,
147 .szAdminUsers = NULL,
152 .szRootPreExec = NULL,
153 .szRootPostExec = NULL,
154 .szCupsOptions = NULL,
155 .szPrintcommand = NULL,
156 .szLpqcommand = NULL,
157 .szLprmcommand = NULL,
158 .szLppausecommand = NULL,
159 .szLpresumecommand = NULL,
160 .szQueuepausecommand = NULL,
161 .szQueueresumecommand = NULL,
162 .szPrintername = NULL,
163 .szPrintjobUsername = NULL,
164 .szDontdescend = NULL,
165 .szHostsallow = NULL,
167 .szMagicScript = NULL,
168 .szMagicOutput = NULL,
171 .szVetoOplockFiles = NULL,
177 .printer_admin = NULL,
180 .szVfsObjects = NULL,
181 .szMSDfsProxy = NULL,
182 .szAioWriteBehind = NULL,
185 .iMaxPrintJobs = 1000,
186 .iMaxReportedPrintJobs = 0,
187 .iWriteCacheSize = 0,
188 .iCreate_mask = 0744,
189 .iCreate_force_mode = 0,
190 .iSecurity_mask = 0777,
191 .iSecurity_force_mode = 0,
193 .iDir_force_mode = 0,
194 .iDir_Security_mask = 0777,
195 .iDir_Security_force_mode = 0,
196 .iMaxConnections = 0,
197 .iDefaultCase = CASE_LOWER,
198 .iPrinting = DEFAULT_PRINTING,
199 .iOplockContentionLimit = 2,
202 .iDfreeCacheTime = 0,
203 .bPreexecClose = false,
204 .bRootpreexecClose = false,
205 .iCaseSensitive = Auto,
206 .bCasePreserve = true,
207 .bShortCasePreserve = true,
208 .bHideDotFiles = true,
209 .bHideSpecialFiles = false,
210 .bHideUnReadable = false,
211 .bHideUnWriteableFiles = false,
213 .bAccessBasedShareEnum = false,
217 .bGuest_only = false,
218 .bAdministrative_share = false,
221 .bPrintNotifyBackchannel = true,
222 .bMap_system = false,
223 .bMap_hidden = false,
224 .bMap_archive = true,
225 .bStoreDosAttributes = false,
226 .bDmapiSupport = false,
228 .iStrictLocking = Auto,
229 .bPosixLocking = true,
232 .bLevel2OpLocks = true,
234 .bMangledNames = true,
237 .bSyncAlways = false,
238 .bStrictAllocate = false,
239 .bStrictSync = false,
242 .bDeleteReadonly = false,
243 .bFakeOplocks = false,
244 .bDeleteVetoFiles = false,
245 .bDosFilemode = false,
246 .bDosFiletimes = true,
247 .bDosFiletimeResolution = false,
248 .bFakeDirCreateTimes = false,
249 .bBlockingLocks = true,
250 .bInheritPerms = false,
251 .bInheritACLS = false,
252 .bInheritOwner = false,
254 .bUseClientDriver = false,
255 .bDefaultDevmode = true,
256 .bForcePrintername = false,
257 .bNTAclSupport = true,
258 .bForceUnknownAclUser = false,
259 .bUseSendfile = false,
260 .bProfileAcls = false,
261 .bMap_acl_inherit = false,
264 .bAclCheckPermissions = true,
265 .bAclMapFullControl = true,
266 .bAclGroupControl = false,
267 .bChangeNotify = true,
268 .bKernelChangeNotify = true,
269 .iallocation_roundup_size = SMB_ROUNDUP_ALLOCATION_SIZE,
272 .iMap_readonly = MAP_READONLY_YES,
273 #ifdef BROKEN_DIRECTORY_HANDLING
274 .iDirectoryNameCacheSize = 0,
276 .iDirectoryNameCacheSize = 100,
278 .ismb_encrypt = Auto,
283 /* local variables */
284 static struct loadparm_service **ServicePtrs = NULL;
285 static int iNumServices = 0;
286 static int iServiceIndex = 0;
287 static struct db_context *ServiceHash;
288 static int *invalid_services = NULL;
289 static int num_invalid_services = 0;
290 static bool bInGlobalSection = true;
291 static bool bGlobalOnly = false;
293 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
295 /* prototypes for the special type handlers */
296 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
297 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
298 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
299 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
300 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
301 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
302 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
303 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
304 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
305 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
306 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
307 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
309 static void set_allowed_client_auth(void);
311 static void add_to_file_list(const char *fname, const char *subfname);
312 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
313 static void free_param_opts(struct parmlist_entry **popts);
315 #include "lib/param/param_enums.c"
317 static const struct enum_list enum_printing[] = {
318 {PRINT_SYSV, "sysv"},
320 {PRINT_HPUX, "hpux"},
324 {PRINT_LPRNG, "lprng"},
325 {PRINT_CUPS, "cups"},
326 {PRINT_IPRINT, "iprint"},
328 {PRINT_LPROS2, "os2"},
329 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
330 {PRINT_TEST, "test"},
332 #endif /* DEVELOPER */
336 static const struct enum_list enum_ldap_sasl_wrapping[] = {
338 {ADS_AUTH_SASL_SIGN, "sign"},
339 {ADS_AUTH_SASL_SEAL, "seal"},
343 static const struct enum_list enum_ldap_ssl[] = {
344 {LDAP_SSL_OFF, "no"},
345 {LDAP_SSL_OFF, "off"},
346 {LDAP_SSL_START_TLS, "start tls"},
347 {LDAP_SSL_START_TLS, "start_tls"},
351 /* LDAP Dereferencing Alias types */
352 #define SAMBA_LDAP_DEREF_NEVER 0
353 #define SAMBA_LDAP_DEREF_SEARCHING 1
354 #define SAMBA_LDAP_DEREF_FINDING 2
355 #define SAMBA_LDAP_DEREF_ALWAYS 3
357 static const struct enum_list enum_ldap_deref[] = {
358 {SAMBA_LDAP_DEREF_NEVER, "never"},
359 {SAMBA_LDAP_DEREF_SEARCHING, "searching"},
360 {SAMBA_LDAP_DEREF_FINDING, "finding"},
361 {SAMBA_LDAP_DEREF_ALWAYS, "always"},
365 static const struct enum_list enum_ldap_passwd_sync[] = {
366 {LDAP_PASSWD_SYNC_OFF, "no"},
367 {LDAP_PASSWD_SYNC_OFF, "off"},
368 {LDAP_PASSWD_SYNC_ON, "yes"},
369 {LDAP_PASSWD_SYNC_ON, "on"},
370 {LDAP_PASSWD_SYNC_ONLY, "only"},
374 static const struct enum_list enum_map_readonly[] = {
375 {MAP_READONLY_NO, "no"},
376 {MAP_READONLY_NO, "false"},
377 {MAP_READONLY_NO, "0"},
378 {MAP_READONLY_YES, "yes"},
379 {MAP_READONLY_YES, "true"},
380 {MAP_READONLY_YES, "1"},
381 {MAP_READONLY_PERMISSIONS, "permissions"},
382 {MAP_READONLY_PERMISSIONS, "perms"},
386 static const struct enum_list enum_case[] = {
387 {CASE_LOWER, "lower"},
388 {CASE_UPPER, "upper"},
393 /* ACL compatibility options. */
394 static const struct enum_list enum_acl_compat_vals[] = {
395 { ACL_COMPAT_AUTO, "auto" },
396 { ACL_COMPAT_WINNT, "winnt" },
397 { ACL_COMPAT_WIN2K, "win2k" },
402 Do you want session setups at user level security with a invalid
403 password to be rejected or allowed in as guest? WinNT rejects them
404 but it can be a pain as it means "net view" needs to use a password
406 You have 3 choices in the setting of map_to_guest:
408 "Never" means session setups with an invalid password
409 are rejected. This is the default.
411 "Bad User" means session setups with an invalid password
412 are rejected, unless the username does not exist, in which case it
413 is treated as a guest login
415 "Bad Password" means session setups with an invalid password
416 are treated as a guest login
418 Note that map_to_guest only has an effect in user or server
422 static const struct enum_list enum_map_to_guest[] = {
423 {NEVER_MAP_TO_GUEST, "Never"},
424 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
425 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
426 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
430 /* Config backend options */
432 static const struct enum_list enum_config_backend[] = {
433 {CONFIG_BACKEND_FILE, "file"},
434 {CONFIG_BACKEND_REGISTRY, "registry"},
438 /* ADS kerberos ticket verification options */
440 static const struct enum_list enum_kerberos_method[] = {
441 {KERBEROS_VERIFY_SECRETS, "default"},
442 {KERBEROS_VERIFY_SECRETS, "secrets only"},
443 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
444 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
445 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
449 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
451 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
452 * screen in SWAT. This is used to exclude parameters as well as to squash all
453 * parameters that have been duplicated by pseudonyms.
455 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
456 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
457 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
460 * NOTE2: Handling of duplicated (synonym) parameters:
461 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
462 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
463 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
464 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
467 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
468 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
470 static struct parm_struct parm_table[] = {
471 {N_("Base Options"), P_SEP, P_SEPARATOR},
474 .label = "dos charset",
477 .offset = GLOBAL_VAR(dos_charset),
478 .special = handle_dos_charset,
480 .flags = FLAG_ADVANCED
483 .label = "unix charset",
486 .offset = GLOBAL_VAR(unix_charset),
487 .special = handle_charset,
489 .flags = FLAG_ADVANCED
495 .offset = LOCAL_VAR(comment),
498 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
504 .offset = LOCAL_VAR(szPath),
507 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
510 .label = "directory",
513 .offset = LOCAL_VAR(szPath),
519 .label = "workgroup",
522 .offset = GLOBAL_VAR(szWorkgroup),
525 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
531 .offset = GLOBAL_VAR(szRealm),
532 .special = handle_realm,
534 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
537 .label = "netbios name",
540 .offset = GLOBAL_VAR(szNetbiosName),
543 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
546 .label = "netbios aliases",
549 .offset = GLOBAL_VAR(szNetbiosAliases),
550 .special = handle_netbios_aliases,
552 .flags = FLAG_ADVANCED,
555 .label = "netbios scope",
558 .offset = GLOBAL_VAR(szNetbiosScope),
561 .flags = FLAG_ADVANCED,
564 .label = "server string",
567 .offset = GLOBAL_VAR(szServerString),
570 .flags = FLAG_BASIC | FLAG_ADVANCED,
573 .label = "interfaces",
576 .offset = GLOBAL_VAR(szInterfaces),
579 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
582 .label = "bind interfaces only",
585 .offset = GLOBAL_VAR(bBindInterfacesOnly),
588 .flags = FLAG_ADVANCED | FLAG_WIZARD,
591 .label = "config backend",
594 .offset = GLOBAL_VAR(ConfigBackend),
596 .enum_list = enum_config_backend,
597 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
600 .label = "server role",
603 .offset = GLOBAL_VAR(ServerRole),
605 .enum_list = enum_server_role,
606 .flags = FLAG_BASIC | FLAG_ADVANCED,
609 {N_("Security Options"), P_SEP, P_SEPARATOR},
615 .offset = GLOBAL_VAR(security),
617 .enum_list = enum_security,
618 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
621 .label = "auth methods",
624 .offset = GLOBAL_VAR(AuthMethods),
627 .flags = FLAG_ADVANCED,
630 .label = "encrypt passwords",
633 .offset = GLOBAL_VAR(bEncryptPasswords),
636 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
639 .label = "client schannel",
642 .offset = GLOBAL_VAR(clientSchannel),
644 .enum_list = enum_bool_auto,
645 .flags = FLAG_BASIC | FLAG_ADVANCED,
648 .label = "server schannel",
651 .offset = GLOBAL_VAR(serverSchannel),
653 .enum_list = enum_bool_auto,
654 .flags = FLAG_BASIC | FLAG_ADVANCED,
657 .label = "allow trusted domains",
660 .offset = GLOBAL_VAR(bAllowTrustedDomains),
663 .flags = FLAG_ADVANCED,
666 .label = "map to guest",
669 .offset = GLOBAL_VAR(map_to_guest),
671 .enum_list = enum_map_to_guest,
672 .flags = FLAG_ADVANCED,
675 .label = "null passwords",
678 .offset = GLOBAL_VAR(bNullPasswords),
681 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
684 .label = "obey pam restrictions",
687 .offset = GLOBAL_VAR(bObeyPamRestrictions),
690 .flags = FLAG_ADVANCED,
693 .label = "password server",
696 .offset = GLOBAL_VAR(szPasswordServer),
699 .flags = FLAG_ADVANCED | FLAG_WIZARD,
702 .label = "smb passwd file",
705 .offset = GLOBAL_VAR(szSMBPasswdFile),
708 .flags = FLAG_ADVANCED,
711 .label = "private dir",
714 .offset = GLOBAL_VAR(szPrivateDir),
717 .flags = FLAG_ADVANCED,
720 .label = "passdb backend",
723 .offset = GLOBAL_VAR(szPassdbBackend),
726 .flags = FLAG_ADVANCED | FLAG_WIZARD,
729 .label = "algorithmic rid base",
732 .offset = GLOBAL_VAR(AlgorithmicRidBase),
735 .flags = FLAG_ADVANCED,
738 .label = "root directory",
741 .offset = GLOBAL_VAR(szRootdir),
744 .flags = FLAG_ADVANCED,
750 .offset = GLOBAL_VAR(szRootdir),
759 .offset = GLOBAL_VAR(szRootdir),
765 .label = "guest account",
768 .offset = GLOBAL_VAR(szGuestaccount),
771 .flags = FLAG_BASIC | FLAG_ADVANCED,
774 .label = "enable privileges",
777 .offset = GLOBAL_VAR(bEnablePrivileges),
780 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
784 .label = "pam password change",
787 .offset = GLOBAL_VAR(bPamPasswordChange),
790 .flags = FLAG_ADVANCED,
793 .label = "passwd program",
796 .offset = GLOBAL_VAR(szPasswdProgram),
799 .flags = FLAG_ADVANCED,
802 .label = "passwd chat",
805 .offset = GLOBAL_VAR(szPasswdChat),
808 .flags = FLAG_ADVANCED,
811 .label = "passwd chat debug",
814 .offset = GLOBAL_VAR(bPasswdChatDebug),
817 .flags = FLAG_ADVANCED,
820 .label = "passwd chat timeout",
823 .offset = GLOBAL_VAR(iPasswdChatTimeout),
826 .flags = FLAG_ADVANCED,
829 .label = "check password script",
832 .offset = GLOBAL_VAR(szCheckPasswordScript),
835 .flags = FLAG_ADVANCED,
838 .label = "username map",
841 .offset = GLOBAL_VAR(szUsernameMap),
844 .flags = FLAG_ADVANCED,
847 .label = "password level",
850 .offset = GLOBAL_VAR(pwordlevel),
853 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
856 .label = "username level",
859 .offset = GLOBAL_VAR(unamelevel),
862 .flags = FLAG_ADVANCED,
865 .label = "unix password sync",
868 .offset = GLOBAL_VAR(bUnixPasswdSync),
871 .flags = FLAG_ADVANCED,
874 .label = "restrict anonymous",
877 .offset = GLOBAL_VAR(restrict_anonymous),
880 .flags = FLAG_ADVANCED,
883 .label = "lanman auth",
886 .offset = GLOBAL_VAR(bLanmanAuth),
889 .flags = FLAG_ADVANCED,
892 .label = "ntlm auth",
895 .offset = GLOBAL_VAR(bNTLMAuth),
898 .flags = FLAG_ADVANCED,
901 .label = "client NTLMv2 auth",
904 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
907 .flags = FLAG_ADVANCED,
910 .label = "client lanman auth",
913 .offset = GLOBAL_VAR(bClientLanManAuth),
916 .flags = FLAG_ADVANCED,
919 .label = "client plaintext auth",
922 .offset = GLOBAL_VAR(bClientPlaintextAuth),
925 .flags = FLAG_ADVANCED,
928 .label = "client use spnego principal",
931 .offset = GLOBAL_VAR(client_use_spnego_principal),
934 .flags = FLAG_ADVANCED,
937 .label = "send spnego principal",
940 .offset = GLOBAL_VAR(send_spnego_principal),
943 .flags = FLAG_ADVANCED,
949 .offset = LOCAL_VAR(szUsername),
952 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
958 .offset = LOCAL_VAR(szUsername),
967 .offset = LOCAL_VAR(szUsername),
973 .label = "invalid users",
976 .offset = LOCAL_VAR(szInvalidUsers),
979 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
982 .label = "valid users",
985 .offset = LOCAL_VAR(szValidUsers),
988 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
991 .label = "admin users",
994 .offset = LOCAL_VAR(szAdminUsers),
997 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1000 .label = "read list",
1003 .offset = LOCAL_VAR(readlist),
1006 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1009 .label = "write list",
1012 .offset = LOCAL_VAR(writelist),
1015 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1018 .label = "printer admin",
1021 .offset = LOCAL_VAR(printer_admin),
1024 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1027 .label = "force user",
1030 .offset = LOCAL_VAR(force_user),
1033 .flags = FLAG_ADVANCED | FLAG_SHARE,
1036 .label = "force group",
1039 .offset = LOCAL_VAR(force_group),
1042 .flags = FLAG_ADVANCED | FLAG_SHARE,
1048 .offset = LOCAL_VAR(force_group),
1051 .flags = FLAG_ADVANCED,
1054 .label = "read only",
1057 .offset = LOCAL_VAR(bRead_only),
1060 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1063 .label = "write ok",
1066 .offset = LOCAL_VAR(bRead_only),
1072 .label = "writeable",
1075 .offset = LOCAL_VAR(bRead_only),
1081 .label = "writable",
1084 .offset = LOCAL_VAR(bRead_only),
1090 .label = "acl check permissions",
1093 .offset = LOCAL_VAR(bAclCheckPermissions),
1096 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
1099 .label = "acl group control",
1102 .offset = LOCAL_VAR(bAclGroupControl),
1105 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1108 .label = "acl map full control",
1111 .offset = LOCAL_VAR(bAclMapFullControl),
1114 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1117 .label = "create mask",
1120 .offset = LOCAL_VAR(iCreate_mask),
1123 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1126 .label = "create mode",
1129 .offset = LOCAL_VAR(iCreate_mask),
1135 .label = "force create mode",
1138 .offset = LOCAL_VAR(iCreate_force_mode),
1141 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1144 .label = "security mask",
1147 .offset = LOCAL_VAR(iSecurity_mask),
1150 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1153 .label = "force security mode",
1156 .offset = LOCAL_VAR(iSecurity_force_mode),
1159 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1162 .label = "directory mask",
1165 .offset = LOCAL_VAR(iDir_mask),
1168 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1171 .label = "directory mode",
1174 .offset = LOCAL_VAR(iDir_mask),
1177 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1180 .label = "force directory mode",
1183 .offset = LOCAL_VAR(iDir_force_mode),
1186 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1189 .label = "directory security mask",
1192 .offset = LOCAL_VAR(iDir_Security_mask),
1195 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1198 .label = "force directory security mode",
1201 .offset = LOCAL_VAR(iDir_Security_force_mode),
1204 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1207 .label = "force unknown acl user",
1210 .offset = LOCAL_VAR(bForceUnknownAclUser),
1213 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1216 .label = "inherit permissions",
1219 .offset = LOCAL_VAR(bInheritPerms),
1222 .flags = FLAG_ADVANCED | FLAG_SHARE,
1225 .label = "inherit acls",
1228 .offset = LOCAL_VAR(bInheritACLS),
1231 .flags = FLAG_ADVANCED | FLAG_SHARE,
1234 .label = "inherit owner",
1237 .offset = LOCAL_VAR(bInheritOwner),
1240 .flags = FLAG_ADVANCED | FLAG_SHARE,
1243 .label = "guest only",
1246 .offset = LOCAL_VAR(bGuest_only),
1249 .flags = FLAG_ADVANCED | FLAG_SHARE,
1252 .label = "only guest",
1255 .offset = LOCAL_VAR(bGuest_only),
1261 .label = "administrative share",
1264 .offset = LOCAL_VAR(bAdministrative_share),
1267 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1271 .label = "guest ok",
1274 .offset = LOCAL_VAR(bGuest_ok),
1277 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1283 .offset = LOCAL_VAR(bGuest_ok),
1289 .label = "only user",
1292 .offset = LOCAL_VAR(bOnlyUser),
1295 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1298 .label = "hosts allow",
1301 .offset = LOCAL_VAR(szHostsallow),
1304 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1307 .label = "allow hosts",
1310 .offset = LOCAL_VAR(szHostsallow),
1316 .label = "hosts deny",
1319 .offset = LOCAL_VAR(szHostsdeny),
1322 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1325 .label = "deny hosts",
1328 .offset = LOCAL_VAR(szHostsdeny),
1334 .label = "preload modules",
1336 .p_class = P_GLOBAL,
1337 .offset = GLOBAL_VAR(szPreloadModules),
1340 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1343 .label = "dedicated keytab file",
1345 .p_class = P_GLOBAL,
1346 .offset = GLOBAL_VAR(szDedicatedKeytabFile),
1349 .flags = FLAG_ADVANCED,
1352 .label = "kerberos method",
1354 .p_class = P_GLOBAL,
1355 .offset = GLOBAL_VAR(iKerberosMethod),
1357 .enum_list = enum_kerberos_method,
1358 .flags = FLAG_ADVANCED,
1361 .label = "map untrusted to domain",
1363 .p_class = P_GLOBAL,
1364 .offset = GLOBAL_VAR(bMapUntrustedToDomain),
1367 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1371 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1374 .label = "log level",
1376 .p_class = P_GLOBAL,
1377 .offset = GLOBAL_VAR(szLogLevel),
1378 .special = handle_debug_list,
1380 .flags = FLAG_ADVANCED,
1383 .label = "debuglevel",
1385 .p_class = P_GLOBAL,
1386 .offset = GLOBAL_VAR(szLogLevel),
1387 .special = handle_debug_list,
1394 .p_class = P_GLOBAL,
1395 .offset = GLOBAL_VAR(syslog),
1398 .flags = FLAG_ADVANCED,
1401 .label = "syslog only",
1403 .p_class = P_GLOBAL,
1404 .offset = GLOBAL_VAR(bSyslogOnly),
1407 .flags = FLAG_ADVANCED,
1410 .label = "log file",
1412 .p_class = P_GLOBAL,
1413 .offset = GLOBAL_VAR(szLogFile),
1416 .flags = FLAG_ADVANCED,
1419 .label = "max log size",
1421 .p_class = P_GLOBAL,
1422 .offset = GLOBAL_VAR(max_log_size),
1425 .flags = FLAG_ADVANCED,
1428 .label = "debug timestamp",
1430 .p_class = P_GLOBAL,
1431 .offset = GLOBAL_VAR(bTimestampLogs),
1434 .flags = FLAG_ADVANCED,
1437 .label = "timestamp logs",
1439 .p_class = P_GLOBAL,
1440 .offset = GLOBAL_VAR(bTimestampLogs),
1443 .flags = FLAG_ADVANCED,
1446 .label = "debug prefix timestamp",
1448 .p_class = P_GLOBAL,
1449 .offset = GLOBAL_VAR(bDebugPrefixTimestamp),
1452 .flags = FLAG_ADVANCED,
1455 .label = "debug hires timestamp",
1457 .p_class = P_GLOBAL,
1458 .offset = GLOBAL_VAR(bDebugHiresTimestamp),
1461 .flags = FLAG_ADVANCED,
1464 .label = "debug pid",
1466 .p_class = P_GLOBAL,
1467 .offset = GLOBAL_VAR(bDebugPid),
1470 .flags = FLAG_ADVANCED,
1473 .label = "debug uid",
1475 .p_class = P_GLOBAL,
1476 .offset = GLOBAL_VAR(bDebugUid),
1479 .flags = FLAG_ADVANCED,
1482 .label = "debug class",
1484 .p_class = P_GLOBAL,
1485 .offset = GLOBAL_VAR(bDebugClass),
1488 .flags = FLAG_ADVANCED,
1491 .label = "enable core files",
1493 .p_class = P_GLOBAL,
1494 .offset = GLOBAL_VAR(bEnableCoreFiles),
1497 .flags = FLAG_ADVANCED,
1500 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1503 .label = "allocation roundup size",
1506 .offset = LOCAL_VAR(iallocation_roundup_size),
1509 .flags = FLAG_ADVANCED,
1512 .label = "aio read size",
1515 .offset = LOCAL_VAR(iAioReadSize),
1518 .flags = FLAG_ADVANCED,
1521 .label = "aio write size",
1524 .offset = LOCAL_VAR(iAioWriteSize),
1527 .flags = FLAG_ADVANCED,
1530 .label = "aio write behind",
1533 .offset = LOCAL_VAR(szAioWriteBehind),
1536 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1539 .label = "smb ports",
1541 .p_class = P_GLOBAL,
1542 .offset = GLOBAL_VAR(smb_ports),
1545 .flags = FLAG_ADVANCED,
1548 .label = "large readwrite",
1550 .p_class = P_GLOBAL,
1551 .offset = GLOBAL_VAR(bLargeReadwrite),
1554 .flags = FLAG_ADVANCED,
1557 .label = "max protocol",
1559 .p_class = P_GLOBAL,
1560 .offset = GLOBAL_VAR(maxprotocol),
1562 .enum_list = enum_protocol,
1563 .flags = FLAG_ADVANCED,
1566 .label = "protocol",
1568 .p_class = P_GLOBAL,
1569 .offset = GLOBAL_VAR(maxprotocol),
1571 .enum_list = enum_protocol,
1572 .flags = FLAG_ADVANCED,
1575 .label = "min protocol",
1577 .p_class = P_GLOBAL,
1578 .offset = GLOBAL_VAR(minprotocol),
1580 .enum_list = enum_protocol,
1581 .flags = FLAG_ADVANCED,
1584 .label = "min receivefile size",
1586 .p_class = P_GLOBAL,
1587 .offset = GLOBAL_VAR(iminreceivefile),
1590 .flags = FLAG_ADVANCED,
1593 .label = "read raw",
1595 .p_class = P_GLOBAL,
1596 .offset = GLOBAL_VAR(bReadRaw),
1599 .flags = FLAG_ADVANCED,
1602 .label = "write raw",
1604 .p_class = P_GLOBAL,
1605 .offset = GLOBAL_VAR(bWriteRaw),
1608 .flags = FLAG_ADVANCED,
1611 .label = "disable netbios",
1613 .p_class = P_GLOBAL,
1614 .offset = GLOBAL_VAR(bDisableNetbios),
1617 .flags = FLAG_ADVANCED,
1620 .label = "reset on zero vc",
1622 .p_class = P_GLOBAL,
1623 .offset = GLOBAL_VAR(bResetOnZeroVC),
1626 .flags = FLAG_ADVANCED,
1629 .label = "log writeable files on exit",
1631 .p_class = P_GLOBAL,
1632 .offset = GLOBAL_VAR(bLogWriteableFilesOnExit),
1635 .flags = FLAG_ADVANCED,
1638 .label = "acl compatibility",
1640 .p_class = P_GLOBAL,
1641 .offset = GLOBAL_VAR(iAclCompat),
1643 .enum_list = enum_acl_compat_vals,
1644 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1647 .label = "defer sharing violations",
1649 .p_class = P_GLOBAL,
1650 .offset = GLOBAL_VAR(bDeferSharingViolations),
1653 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1656 .label = "ea support",
1659 .offset = LOCAL_VAR(bEASupport),
1662 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1665 .label = "nt acl support",
1668 .offset = LOCAL_VAR(bNTAclSupport),
1671 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1674 .label = "nt pipe support",
1676 .p_class = P_GLOBAL,
1677 .offset = GLOBAL_VAR(bNTPipeSupport),
1680 .flags = FLAG_ADVANCED,
1683 .label = "nt status support",
1685 .p_class = P_GLOBAL,
1686 .offset = GLOBAL_VAR(bNTStatusSupport),
1689 .flags = FLAG_ADVANCED,
1692 .label = "profile acls",
1695 .offset = LOCAL_VAR(bProfileAcls),
1698 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1701 .label = "map acl inherit",
1704 .offset = LOCAL_VAR(bMap_acl_inherit),
1707 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1710 .label = "afs share",
1713 .offset = LOCAL_VAR(bAfs_Share),
1716 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1721 .p_class = P_GLOBAL,
1722 .offset = GLOBAL_VAR(max_mux),
1725 .flags = FLAG_ADVANCED,
1728 .label = "max xmit",
1730 .p_class = P_GLOBAL,
1731 .offset = GLOBAL_VAR(max_xmit),
1734 .flags = FLAG_ADVANCED,
1737 .label = "name resolve order",
1739 .p_class = P_GLOBAL,
1740 .offset = GLOBAL_VAR(szNameResolveOrder),
1743 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1748 .p_class = P_GLOBAL,
1749 .offset = GLOBAL_VAR(max_ttl),
1752 .flags = FLAG_ADVANCED,
1755 .label = "max wins ttl",
1757 .p_class = P_GLOBAL,
1758 .offset = GLOBAL_VAR(max_wins_ttl),
1761 .flags = FLAG_ADVANCED,
1764 .label = "min wins ttl",
1766 .p_class = P_GLOBAL,
1767 .offset = GLOBAL_VAR(min_wins_ttl),
1770 .flags = FLAG_ADVANCED,
1773 .label = "time server",
1775 .p_class = P_GLOBAL,
1776 .offset = GLOBAL_VAR(bTimeServer),
1779 .flags = FLAG_ADVANCED,
1782 .label = "unix extensions",
1784 .p_class = P_GLOBAL,
1785 .offset = GLOBAL_VAR(bUnixExtensions),
1788 .flags = FLAG_ADVANCED,
1791 .label = "use spnego",
1793 .p_class = P_GLOBAL,
1794 .offset = GLOBAL_VAR(bUseSpnego),
1797 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
1800 .label = "client signing",
1802 .p_class = P_GLOBAL,
1803 .offset = GLOBAL_VAR(client_signing),
1805 .enum_list = enum_smb_signing_vals,
1806 .flags = FLAG_ADVANCED,
1809 .label = "server signing",
1811 .p_class = P_GLOBAL,
1812 .offset = GLOBAL_VAR(server_signing),
1814 .enum_list = enum_smb_signing_vals,
1815 .flags = FLAG_ADVANCED,
1818 .label = "smb encrypt",
1821 .offset = LOCAL_VAR(ismb_encrypt),
1823 .enum_list = enum_smb_signing_vals,
1824 .flags = FLAG_ADVANCED,
1827 .label = "client use spnego",
1829 .p_class = P_GLOBAL,
1830 .offset = GLOBAL_VAR(bClientUseSpnego),
1833 .flags = FLAG_ADVANCED,
1836 .label = "client ldap sasl wrapping",
1838 .p_class = P_GLOBAL,
1839 .offset = GLOBAL_VAR(client_ldap_sasl_wrapping),
1841 .enum_list = enum_ldap_sasl_wrapping,
1842 .flags = FLAG_ADVANCED,
1845 .label = "enable asu support",
1847 .p_class = P_GLOBAL,
1848 .offset = GLOBAL_VAR(bASUSupport),
1851 .flags = FLAG_ADVANCED,
1854 .label = "svcctl list",
1856 .p_class = P_GLOBAL,
1857 .offset = GLOBAL_VAR(szServicesList),
1860 .flags = FLAG_ADVANCED,
1863 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
1866 .label = "block size",
1869 .offset = LOCAL_VAR(iBlock_size),
1872 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1875 .label = "deadtime",
1877 .p_class = P_GLOBAL,
1878 .offset = GLOBAL_VAR(deadtime),
1881 .flags = FLAG_ADVANCED,
1884 .label = "getwd cache",
1886 .p_class = P_GLOBAL,
1887 .offset = GLOBAL_VAR(getwd_cache),
1890 .flags = FLAG_ADVANCED,
1893 .label = "keepalive",
1895 .p_class = P_GLOBAL,
1896 .offset = GLOBAL_VAR(iKeepalive),
1899 .flags = FLAG_ADVANCED,
1902 .label = "change notify",
1905 .offset = LOCAL_VAR(bChangeNotify),
1908 .flags = FLAG_ADVANCED | FLAG_SHARE,
1911 .label = "directory name cache size",
1914 .offset = LOCAL_VAR(iDirectoryNameCacheSize),
1917 .flags = FLAG_ADVANCED | FLAG_SHARE,
1920 .label = "kernel change notify",
1923 .offset = LOCAL_VAR(bKernelChangeNotify),
1926 .flags = FLAG_ADVANCED | FLAG_SHARE,
1929 .label = "lpq cache time",
1931 .p_class = P_GLOBAL,
1932 .offset = GLOBAL_VAR(lpqcachetime),
1935 .flags = FLAG_ADVANCED,
1938 .label = "max smbd processes",
1940 .p_class = P_GLOBAL,
1941 .offset = GLOBAL_VAR(iMaxSmbdProcesses),
1944 .flags = FLAG_ADVANCED,
1947 .label = "max connections",
1950 .offset = LOCAL_VAR(iMaxConnections),
1953 .flags = FLAG_ADVANCED | FLAG_SHARE,
1956 .label = "paranoid server security",
1958 .p_class = P_GLOBAL,
1959 .offset = GLOBAL_VAR(paranoid_server_security),
1962 .flags = FLAG_ADVANCED,
1965 .label = "max disk size",
1967 .p_class = P_GLOBAL,
1968 .offset = GLOBAL_VAR(maxdisksize),
1971 .flags = FLAG_ADVANCED,
1974 .label = "max open files",
1976 .p_class = P_GLOBAL,
1977 .offset = GLOBAL_VAR(max_open_files),
1980 .flags = FLAG_ADVANCED,
1983 .label = "min print space",
1986 .offset = LOCAL_VAR(iMinPrintSpace),
1989 .flags = FLAG_ADVANCED | FLAG_PRINT,
1992 .label = "socket options",
1994 .p_class = P_GLOBAL,
1995 .offset = GLOBAL_VAR(szSocketOptions),
1998 .flags = FLAG_ADVANCED,
2001 .label = "strict allocate",
2004 .offset = LOCAL_VAR(bStrictAllocate),
2007 .flags = FLAG_ADVANCED | FLAG_SHARE,
2010 .label = "strict sync",
2013 .offset = LOCAL_VAR(bStrictSync),
2016 .flags = FLAG_ADVANCED | FLAG_SHARE,
2019 .label = "sync always",
2022 .offset = LOCAL_VAR(bSyncAlways),
2025 .flags = FLAG_ADVANCED | FLAG_SHARE,
2028 .label = "use mmap",
2030 .p_class = P_GLOBAL,
2031 .offset = GLOBAL_VAR(bUseMmap),
2034 .flags = FLAG_ADVANCED,
2037 .label = "use sendfile",
2040 .offset = LOCAL_VAR(bUseSendfile),
2043 .flags = FLAG_ADVANCED | FLAG_SHARE,
2046 .label = "hostname lookups",
2048 .p_class = P_GLOBAL,
2049 .offset = GLOBAL_VAR(bHostnameLookups),
2052 .flags = FLAG_ADVANCED,
2055 .label = "write cache size",
2058 .offset = LOCAL_VAR(iWriteCacheSize),
2061 .flags = FLAG_ADVANCED | FLAG_SHARE,
2064 .label = "name cache timeout",
2066 .p_class = P_GLOBAL,
2067 .offset = GLOBAL_VAR(name_cache_timeout),
2070 .flags = FLAG_ADVANCED,
2073 .label = "ctdbd socket",
2075 .p_class = P_GLOBAL,
2076 .offset = GLOBAL_VAR(ctdbdSocket),
2079 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2082 .label = "cluster addresses",
2084 .p_class = P_GLOBAL,
2085 .offset = GLOBAL_VAR(szClusterAddresses),
2088 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2091 .label = "clustering",
2093 .p_class = P_GLOBAL,
2094 .offset = GLOBAL_VAR(clustering),
2097 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2100 .label = "ctdb timeout",
2102 .p_class = P_GLOBAL,
2103 .offset = GLOBAL_VAR(ctdb_timeout),
2106 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2109 .label = "ctdb locktime warn threshold",
2111 .p_class = P_GLOBAL,
2112 .offset = GLOBAL_VAR(ctdb_locktime_warn_threshold),
2115 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2118 .label = "smb2 max read",
2120 .p_class = P_GLOBAL,
2121 .offset = GLOBAL_VAR(ismb2_max_read),
2124 .flags = FLAG_ADVANCED,
2127 .label = "smb2 max write",
2129 .p_class = P_GLOBAL,
2130 .offset = GLOBAL_VAR(ismb2_max_write),
2133 .flags = FLAG_ADVANCED,
2136 .label = "smb2 max trans",
2138 .p_class = P_GLOBAL,
2139 .offset = GLOBAL_VAR(ismb2_max_trans),
2142 .flags = FLAG_ADVANCED,
2145 .label = "smb2 max credits",
2147 .p_class = P_GLOBAL,
2148 .offset = GLOBAL_VAR(ismb2_max_credits),
2151 .flags = FLAG_ADVANCED,
2154 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2157 .label = "max reported print jobs",
2160 .offset = LOCAL_VAR(iMaxReportedPrintJobs),
2163 .flags = FLAG_ADVANCED | FLAG_PRINT,
2166 .label = "max print jobs",
2169 .offset = LOCAL_VAR(iMaxPrintJobs),
2172 .flags = FLAG_ADVANCED | FLAG_PRINT,
2175 .label = "load printers",
2177 .p_class = P_GLOBAL,
2178 .offset = GLOBAL_VAR(bLoadPrinters),
2181 .flags = FLAG_ADVANCED | FLAG_PRINT,
2184 .label = "printcap cache time",
2186 .p_class = P_GLOBAL,
2187 .offset = GLOBAL_VAR(PrintcapCacheTime),
2190 .flags = FLAG_ADVANCED | FLAG_PRINT,
2193 .label = "printcap name",
2195 .p_class = P_GLOBAL,
2196 .offset = GLOBAL_VAR(szPrintcapname),
2199 .flags = FLAG_ADVANCED | FLAG_PRINT,
2202 .label = "printcap",
2204 .p_class = P_GLOBAL,
2205 .offset = GLOBAL_VAR(szPrintcapname),
2211 .label = "printable",
2214 .offset = LOCAL_VAR(bPrint_ok),
2217 .flags = FLAG_ADVANCED | FLAG_PRINT,
2220 .label = "print notify backchannel",
2223 .offset = LOCAL_VAR(bPrintNotifyBackchannel),
2226 .flags = FLAG_ADVANCED,
2229 .label = "print ok",
2232 .offset = LOCAL_VAR(bPrint_ok),
2238 .label = "printing",
2241 .offset = LOCAL_VAR(iPrinting),
2242 .special = handle_printing,
2243 .enum_list = enum_printing,
2244 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2247 .label = "cups options",
2250 .offset = LOCAL_VAR(szCupsOptions),
2253 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2256 .label = "cups server",
2258 .p_class = P_GLOBAL,
2259 .offset = GLOBAL_VAR(szCupsServer),
2262 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2265 .label = "cups encrypt",
2267 .p_class = P_GLOBAL,
2268 .offset = GLOBAL_VAR(CupsEncrypt),
2270 .enum_list = enum_bool_auto,
2271 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2275 .label = "cups connection timeout",
2277 .p_class = P_GLOBAL,
2278 .offset = GLOBAL_VAR(cups_connection_timeout),
2281 .flags = FLAG_ADVANCED,
2284 .label = "iprint server",
2286 .p_class = P_GLOBAL,
2287 .offset = GLOBAL_VAR(szIPrintServer),
2290 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2293 .label = "print command",
2296 .offset = LOCAL_VAR(szPrintcommand),
2299 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2302 .label = "disable spoolss",
2304 .p_class = P_GLOBAL,
2305 .offset = GLOBAL_VAR(bDisableSpoolss),
2308 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2311 .label = "enable spoolss",
2313 .p_class = P_GLOBAL,
2314 .offset = GLOBAL_VAR(bDisableSpoolss),
2320 .label = "lpq command",
2323 .offset = LOCAL_VAR(szLpqcommand),
2326 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2329 .label = "lprm command",
2332 .offset = LOCAL_VAR(szLprmcommand),
2335 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2338 .label = "lppause command",
2341 .offset = LOCAL_VAR(szLppausecommand),
2344 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2347 .label = "lpresume command",
2350 .offset = LOCAL_VAR(szLpresumecommand),
2353 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2356 .label = "queuepause command",
2359 .offset = LOCAL_VAR(szQueuepausecommand),
2362 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2365 .label = "queueresume command",
2368 .offset = LOCAL_VAR(szQueueresumecommand),
2371 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2374 .label = "addport command",
2376 .p_class = P_GLOBAL,
2377 .offset = GLOBAL_VAR(szAddPortCommand),
2380 .flags = FLAG_ADVANCED,
2383 .label = "enumports command",
2385 .p_class = P_GLOBAL,
2386 .offset = GLOBAL_VAR(szEnumPortsCommand),
2389 .flags = FLAG_ADVANCED,
2392 .label = "addprinter command",
2394 .p_class = P_GLOBAL,
2395 .offset = GLOBAL_VAR(szAddPrinterCommand),
2398 .flags = FLAG_ADVANCED,
2401 .label = "deleteprinter command",
2403 .p_class = P_GLOBAL,
2404 .offset = GLOBAL_VAR(szDeletePrinterCommand),
2407 .flags = FLAG_ADVANCED,
2410 .label = "show add printer wizard",
2412 .p_class = P_GLOBAL,
2413 .offset = GLOBAL_VAR(bMsAddPrinterWizard),
2416 .flags = FLAG_ADVANCED,
2419 .label = "os2 driver map",
2421 .p_class = P_GLOBAL,
2422 .offset = GLOBAL_VAR(szOs2DriverMap),
2425 .flags = FLAG_ADVANCED,
2429 .label = "printer name",
2432 .offset = LOCAL_VAR(szPrintername),
2435 .flags = FLAG_ADVANCED | FLAG_PRINT,
2441 .offset = LOCAL_VAR(szPrintername),
2447 .label = "use client driver",
2450 .offset = LOCAL_VAR(bUseClientDriver),
2453 .flags = FLAG_ADVANCED | FLAG_PRINT,
2456 .label = "default devmode",
2459 .offset = LOCAL_VAR(bDefaultDevmode),
2462 .flags = FLAG_ADVANCED | FLAG_PRINT,
2465 .label = "force printername",
2468 .offset = LOCAL_VAR(bForcePrintername),
2471 .flags = FLAG_ADVANCED | FLAG_PRINT,
2474 .label = "printjob username",
2477 .offset = LOCAL_VAR(szPrintjobUsername),
2480 .flags = FLAG_ADVANCED | FLAG_PRINT,
2483 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2486 .label = "mangling method",
2488 .p_class = P_GLOBAL,
2489 .offset = GLOBAL_VAR(szManglingMethod),
2492 .flags = FLAG_ADVANCED,
2495 .label = "mangle prefix",
2497 .p_class = P_GLOBAL,
2498 .offset = GLOBAL_VAR(mangle_prefix),
2501 .flags = FLAG_ADVANCED,
2505 .label = "default case",
2508 .offset = LOCAL_VAR(iDefaultCase),
2510 .enum_list = enum_case,
2511 .flags = FLAG_ADVANCED | FLAG_SHARE,
2514 .label = "case sensitive",
2517 .offset = LOCAL_VAR(iCaseSensitive),
2519 .enum_list = enum_bool_auto,
2520 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2523 .label = "casesignames",
2526 .offset = LOCAL_VAR(iCaseSensitive),
2528 .enum_list = enum_bool_auto,
2529 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2532 .label = "preserve case",
2535 .offset = LOCAL_VAR(bCasePreserve),
2538 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2541 .label = "short preserve case",
2544 .offset = LOCAL_VAR(bShortCasePreserve),
2547 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2550 .label = "mangling char",
2553 .offset = LOCAL_VAR(magic_char),
2556 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2559 .label = "hide dot files",
2562 .offset = LOCAL_VAR(bHideDotFiles),
2565 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2568 .label = "hide special files",
2571 .offset = LOCAL_VAR(bHideSpecialFiles),
2574 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2577 .label = "hide unreadable",
2580 .offset = LOCAL_VAR(bHideUnReadable),
2583 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2586 .label = "hide unwriteable files",
2589 .offset = LOCAL_VAR(bHideUnWriteableFiles),
2592 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2595 .label = "delete veto files",
2598 .offset = LOCAL_VAR(bDeleteVetoFiles),
2601 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2604 .label = "veto files",
2607 .offset = LOCAL_VAR(szVetoFiles),
2610 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2613 .label = "hide files",
2616 .offset = LOCAL_VAR(szHideFiles),
2619 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2622 .label = "veto oplock files",
2625 .offset = LOCAL_VAR(szVetoOplockFiles),
2628 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2631 .label = "map archive",
2634 .offset = LOCAL_VAR(bMap_archive),
2637 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2640 .label = "map hidden",
2643 .offset = LOCAL_VAR(bMap_hidden),
2646 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2649 .label = "map system",
2652 .offset = LOCAL_VAR(bMap_system),
2655 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2658 .label = "map readonly",
2661 .offset = LOCAL_VAR(iMap_readonly),
2663 .enum_list = enum_map_readonly,
2664 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2667 .label = "mangled names",
2670 .offset = LOCAL_VAR(bMangledNames),
2673 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2676 .label = "max stat cache size",
2678 .p_class = P_GLOBAL,
2679 .offset = GLOBAL_VAR(iMaxStatCacheSize),
2682 .flags = FLAG_ADVANCED,
2685 .label = "stat cache",
2687 .p_class = P_GLOBAL,
2688 .offset = GLOBAL_VAR(bStatCache),
2691 .flags = FLAG_ADVANCED,
2694 .label = "store dos attributes",
2697 .offset = LOCAL_VAR(bStoreDosAttributes),
2700 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2703 .label = "dmapi support",
2706 .offset = LOCAL_VAR(bDmapiSupport),
2709 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2713 {N_("Domain Options"), P_SEP, P_SEPARATOR},
2716 .label = "machine password timeout",
2718 .p_class = P_GLOBAL,
2719 .offset = GLOBAL_VAR(machine_password_timeout),
2722 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2725 {N_("Logon Options"), P_SEP, P_SEPARATOR},
2728 .label = "add user script",
2730 .p_class = P_GLOBAL,
2731 .offset = GLOBAL_VAR(szAddUserScript),
2734 .flags = FLAG_ADVANCED,
2737 .label = "rename user script",
2739 .p_class = P_GLOBAL,
2740 .offset = GLOBAL_VAR(szRenameUserScript),
2743 .flags = FLAG_ADVANCED,
2746 .label = "delete user script",
2748 .p_class = P_GLOBAL,
2749 .offset = GLOBAL_VAR(szDelUserScript),
2752 .flags = FLAG_ADVANCED,
2755 .label = "add group script",
2757 .p_class = P_GLOBAL,
2758 .offset = GLOBAL_VAR(szAddGroupScript),
2761 .flags = FLAG_ADVANCED,
2764 .label = "delete group script",
2766 .p_class = P_GLOBAL,
2767 .offset = GLOBAL_VAR(szDelGroupScript),
2770 .flags = FLAG_ADVANCED,
2773 .label = "add user to group script",
2775 .p_class = P_GLOBAL,
2776 .offset = GLOBAL_VAR(szAddUserToGroupScript),
2779 .flags = FLAG_ADVANCED,
2782 .label = "delete user from group script",
2784 .p_class = P_GLOBAL,
2785 .offset = GLOBAL_VAR(szDelUserFromGroupScript),
2788 .flags = FLAG_ADVANCED,
2791 .label = "set primary group script",
2793 .p_class = P_GLOBAL,
2794 .offset = GLOBAL_VAR(szSetPrimaryGroupScript),
2797 .flags = FLAG_ADVANCED,
2800 .label = "add machine script",
2802 .p_class = P_GLOBAL,
2803 .offset = GLOBAL_VAR(szAddMachineScript),
2806 .flags = FLAG_ADVANCED,
2809 .label = "shutdown script",
2811 .p_class = P_GLOBAL,
2812 .offset = GLOBAL_VAR(szShutdownScript),
2815 .flags = FLAG_ADVANCED,
2818 .label = "abort shutdown script",
2820 .p_class = P_GLOBAL,
2821 .offset = GLOBAL_VAR(szAbortShutdownScript),
2824 .flags = FLAG_ADVANCED,
2827 .label = "username map script",
2829 .p_class = P_GLOBAL,
2830 .offset = GLOBAL_VAR(szUsernameMapScript),
2833 .flags = FLAG_ADVANCED,
2836 .label = "username map cache time",
2838 .p_class = P_GLOBAL,
2839 .offset = GLOBAL_VAR(iUsernameMapCacheTime),
2842 .flags = FLAG_ADVANCED,
2845 .label = "logon script",
2847 .p_class = P_GLOBAL,
2848 .offset = GLOBAL_VAR(szLogonScript),
2851 .flags = FLAG_ADVANCED,
2854 .label = "logon path",
2856 .p_class = P_GLOBAL,
2857 .offset = GLOBAL_VAR(szLogonPath),
2860 .flags = FLAG_ADVANCED,
2863 .label = "logon drive",
2865 .p_class = P_GLOBAL,
2866 .offset = GLOBAL_VAR(szLogonDrive),
2869 .flags = FLAG_ADVANCED,
2872 .label = "logon home",
2874 .p_class = P_GLOBAL,
2875 .offset = GLOBAL_VAR(szLogonHome),
2878 .flags = FLAG_ADVANCED,
2881 .label = "domain logons",
2883 .p_class = P_GLOBAL,
2884 .offset = GLOBAL_VAR(bDomainLogons),
2887 .flags = FLAG_ADVANCED,
2891 .label = "init logon delayed hosts",
2893 .p_class = P_GLOBAL,
2894 .offset = GLOBAL_VAR(szInitLogonDelayedHosts),
2897 .flags = FLAG_ADVANCED,
2901 .label = "init logon delay",
2903 .p_class = P_GLOBAL,
2904 .offset = GLOBAL_VAR(InitLogonDelay),
2907 .flags = FLAG_ADVANCED,
2911 {N_("Browse Options"), P_SEP, P_SEPARATOR},
2914 .label = "os level",
2916 .p_class = P_GLOBAL,
2917 .offset = GLOBAL_VAR(os_level),
2920 .flags = FLAG_BASIC | FLAG_ADVANCED,
2923 .label = "lm announce",
2925 .p_class = P_GLOBAL,
2926 .offset = GLOBAL_VAR(lm_announce),
2928 .enum_list = enum_bool_auto,
2929 .flags = FLAG_ADVANCED,
2932 .label = "lm interval",
2934 .p_class = P_GLOBAL,
2935 .offset = GLOBAL_VAR(lm_interval),
2938 .flags = FLAG_ADVANCED,
2941 .label = "preferred master",
2943 .p_class = P_GLOBAL,
2944 .offset = GLOBAL_VAR(iPreferredMaster),
2946 .enum_list = enum_bool_auto,
2947 .flags = FLAG_BASIC | FLAG_ADVANCED,
2950 .label = "prefered master",
2952 .p_class = P_GLOBAL,
2953 .offset = GLOBAL_VAR(iPreferredMaster),
2955 .enum_list = enum_bool_auto,
2959 .label = "local master",
2961 .p_class = P_GLOBAL,
2962 .offset = GLOBAL_VAR(bLocalMaster),
2965 .flags = FLAG_BASIC | FLAG_ADVANCED,
2968 .label = "domain master",
2970 .p_class = P_GLOBAL,
2971 .offset = GLOBAL_VAR(iDomainMaster),
2973 .enum_list = enum_bool_auto,
2974 .flags = FLAG_BASIC | FLAG_ADVANCED,
2977 .label = "browse list",
2979 .p_class = P_GLOBAL,
2980 .offset = GLOBAL_VAR(bBrowseList),
2983 .flags = FLAG_ADVANCED,
2986 .label = "browseable",
2989 .offset = LOCAL_VAR(bBrowseable),
2992 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
2995 .label = "browsable",
2998 .offset = LOCAL_VAR(bBrowseable),
3004 .label = "access based share enum",
3007 .offset = LOCAL_VAR(bAccessBasedShareEnum),
3010 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3013 .label = "enhanced browsing",
3015 .p_class = P_GLOBAL,
3016 .offset = GLOBAL_VAR(enhanced_browsing),
3019 .flags = FLAG_ADVANCED,
3022 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3025 .label = "dns proxy",
3027 .p_class = P_GLOBAL,
3028 .offset = GLOBAL_VAR(bDNSproxy),
3031 .flags = FLAG_ADVANCED,
3034 .label = "wins proxy",
3036 .p_class = P_GLOBAL,
3037 .offset = GLOBAL_VAR(bWINSproxy),
3040 .flags = FLAG_ADVANCED,
3043 .label = "wins server",
3045 .p_class = P_GLOBAL,
3046 .offset = GLOBAL_VAR(szWINSservers),
3049 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3052 .label = "wins support",
3054 .p_class = P_GLOBAL,
3055 .offset = GLOBAL_VAR(bWINSsupport),
3058 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3061 .label = "wins hook",
3063 .p_class = P_GLOBAL,
3064 .offset = GLOBAL_VAR(szWINSHook),
3067 .flags = FLAG_ADVANCED,
3070 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3073 .label = "blocking locks",
3076 .offset = LOCAL_VAR(bBlockingLocks),
3079 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3082 .label = "csc policy",
3085 .offset = LOCAL_VAR(iCSCPolicy),
3087 .enum_list = enum_csc_policy,
3088 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3091 .label = "fake oplocks",
3094 .offset = LOCAL_VAR(bFakeOplocks),
3097 .flags = FLAG_ADVANCED | FLAG_SHARE,
3100 .label = "kernel oplocks",
3102 .p_class = P_GLOBAL,
3103 .offset = GLOBAL_VAR(bKernelOplocks),
3106 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3112 .offset = LOCAL_VAR(bLocking),
3115 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3118 .label = "lock spin time",
3120 .p_class = P_GLOBAL,
3121 .offset = GLOBAL_VAR(iLockSpinTime),
3124 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3130 .offset = LOCAL_VAR(bOpLocks),
3133 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3136 .label = "level2 oplocks",
3139 .offset = LOCAL_VAR(bLevel2OpLocks),
3142 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3145 .label = "oplock break wait time",
3147 .p_class = P_GLOBAL,
3148 .offset = GLOBAL_VAR(oplock_break_wait_time),
3151 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3154 .label = "oplock contention limit",
3157 .offset = LOCAL_VAR(iOplockContentionLimit),
3160 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3163 .label = "posix locking",
3166 .offset = LOCAL_VAR(bPosixLocking),
3169 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3172 .label = "strict locking",
3175 .offset = LOCAL_VAR(iStrictLocking),
3177 .enum_list = enum_bool_auto,
3178 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3181 .label = "share modes",
3184 .offset = LOCAL_VAR(bShareModes),
3187 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3190 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3193 .label = "ldap admin dn",
3195 .p_class = P_GLOBAL,
3196 .offset = GLOBAL_VAR(szLdapAdminDn),
3199 .flags = FLAG_ADVANCED,
3202 .label = "ldap delete dn",
3204 .p_class = P_GLOBAL,
3205 .offset = GLOBAL_VAR(ldap_delete_dn),
3208 .flags = FLAG_ADVANCED,
3211 .label = "ldap group suffix",
3213 .p_class = P_GLOBAL,
3214 .offset = GLOBAL_VAR(szLdapGroupSuffix),
3217 .flags = FLAG_ADVANCED,
3220 .label = "ldap idmap suffix",
3222 .p_class = P_GLOBAL,
3223 .offset = GLOBAL_VAR(szLdapIdmapSuffix),
3226 .flags = FLAG_ADVANCED,
3229 .label = "ldap machine suffix",
3231 .p_class = P_GLOBAL,
3232 .offset = GLOBAL_VAR(szLdapMachineSuffix),
3235 .flags = FLAG_ADVANCED,
3238 .label = "ldap passwd sync",
3240 .p_class = P_GLOBAL,
3241 .offset = GLOBAL_VAR(ldap_passwd_sync),
3243 .enum_list = enum_ldap_passwd_sync,
3244 .flags = FLAG_ADVANCED,
3247 .label = "ldap password sync",
3249 .p_class = P_GLOBAL,
3250 .offset = GLOBAL_VAR(ldap_passwd_sync),
3252 .enum_list = enum_ldap_passwd_sync,
3256 .label = "ldap replication sleep",
3258 .p_class = P_GLOBAL,
3259 .offset = GLOBAL_VAR(ldap_replication_sleep),
3262 .flags = FLAG_ADVANCED,
3265 .label = "ldap suffix",
3267 .p_class = P_GLOBAL,
3268 .offset = GLOBAL_VAR(szLdapSuffix),
3271 .flags = FLAG_ADVANCED,
3274 .label = "ldap ssl",
3276 .p_class = P_GLOBAL,
3277 .offset = GLOBAL_VAR(ldap_ssl),
3279 .enum_list = enum_ldap_ssl,
3280 .flags = FLAG_ADVANCED,
3283 .label = "ldap ssl ads",
3285 .p_class = P_GLOBAL,
3286 .offset = GLOBAL_VAR(ldap_ssl_ads),
3289 .flags = FLAG_ADVANCED,
3292 .label = "ldap deref",
3294 .p_class = P_GLOBAL,
3295 .offset = GLOBAL_VAR(ldap_deref),
3297 .enum_list = enum_ldap_deref,
3298 .flags = FLAG_ADVANCED,
3301 .label = "ldap follow referral",
3303 .p_class = P_GLOBAL,
3304 .offset = GLOBAL_VAR(ldap_follow_referral),
3306 .enum_list = enum_bool_auto,
3307 .flags = FLAG_ADVANCED,
3310 .label = "ldap timeout",
3312 .p_class = P_GLOBAL,
3313 .offset = GLOBAL_VAR(ldap_timeout),
3316 .flags = FLAG_ADVANCED,
3319 .label = "ldap connection timeout",
3321 .p_class = P_GLOBAL,
3322 .offset = GLOBAL_VAR(ldap_connection_timeout),
3325 .flags = FLAG_ADVANCED,
3328 .label = "ldap page size",
3330 .p_class = P_GLOBAL,
3331 .offset = GLOBAL_VAR(ldap_page_size),
3334 .flags = FLAG_ADVANCED,
3337 .label = "ldap user suffix",
3339 .p_class = P_GLOBAL,
3340 .offset = GLOBAL_VAR(szLdapUserSuffix),
3343 .flags = FLAG_ADVANCED,
3346 .label = "ldap debug level",
3348 .p_class = P_GLOBAL,
3349 .offset = GLOBAL_VAR(ldap_debug_level),
3350 .special = handle_ldap_debug_level,
3352 .flags = FLAG_ADVANCED,
3355 .label = "ldap debug threshold",
3357 .p_class = P_GLOBAL,
3358 .offset = GLOBAL_VAR(ldap_debug_threshold),
3361 .flags = FLAG_ADVANCED,
3364 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3367 .label = "eventlog list",
3369 .p_class = P_GLOBAL,
3370 .offset = GLOBAL_VAR(szEventLogs),
3373 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3376 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3379 .label = "add share command",
3381 .p_class = P_GLOBAL,
3382 .offset = GLOBAL_VAR(szAddShareCommand),
3385 .flags = FLAG_ADVANCED,
3388 .label = "change share command",
3390 .p_class = P_GLOBAL,
3391 .offset = GLOBAL_VAR(szChangeShareCommand),
3394 .flags = FLAG_ADVANCED,
3397 .label = "delete share command",
3399 .p_class = P_GLOBAL,
3400 .offset = GLOBAL_VAR(szDeleteShareCommand),
3403 .flags = FLAG_ADVANCED,
3406 .label = "config file",
3408 .p_class = P_GLOBAL,
3409 .offset = GLOBAL_VAR(szConfigFile),
3412 .flags = FLAG_HIDE|FLAG_META,
3417 .p_class = P_GLOBAL,
3418 .offset = GLOBAL_VAR(szAutoServices),
3421 .flags = FLAG_ADVANCED,
3424 .label = "auto services",
3426 .p_class = P_GLOBAL,
3427 .offset = GLOBAL_VAR(szAutoServices),
3430 .flags = FLAG_ADVANCED,
3433 .label = "lock directory",
3435 .p_class = P_GLOBAL,
3436 .offset = GLOBAL_VAR(szLockDir),
3439 .flags = FLAG_ADVANCED,
3442 .label = "lock dir",
3444 .p_class = P_GLOBAL,
3445 .offset = GLOBAL_VAR(szLockDir),
3451 .label = "state directory",
3453 .p_class = P_GLOBAL,
3454 .offset = GLOBAL_VAR(szStateDir),
3457 .flags = FLAG_ADVANCED,
3460 .label = "cache directory",
3462 .p_class = P_GLOBAL,
3463 .offset = GLOBAL_VAR(szCacheDir),
3466 .flags = FLAG_ADVANCED,
3469 .label = "pid directory",
3471 .p_class = P_GLOBAL,
3472 .offset = GLOBAL_VAR(szPidDir),
3475 .flags = FLAG_ADVANCED,
3479 .label = "utmp directory",
3481 .p_class = P_GLOBAL,
3482 .offset = GLOBAL_VAR(szUtmpDir),
3485 .flags = FLAG_ADVANCED,
3488 .label = "wtmp directory",
3490 .p_class = P_GLOBAL,
3491 .offset = GLOBAL_VAR(szWtmpDir),
3494 .flags = FLAG_ADVANCED,
3499 .p_class = P_GLOBAL,
3500 .offset = GLOBAL_VAR(bUtmp),
3503 .flags = FLAG_ADVANCED,
3507 .label = "default service",
3509 .p_class = P_GLOBAL,
3510 .offset = GLOBAL_VAR(szDefaultService),
3513 .flags = FLAG_ADVANCED,
3518 .p_class = P_GLOBAL,
3519 .offset = GLOBAL_VAR(szDefaultService),
3522 .flags = FLAG_ADVANCED,
3525 .label = "message command",
3527 .p_class = P_GLOBAL,
3528 .offset = GLOBAL_VAR(szMsgCommand),
3531 .flags = FLAG_ADVANCED,
3534 .label = "dfree cache time",
3537 .offset = LOCAL_VAR(iDfreeCacheTime),
3540 .flags = FLAG_ADVANCED,
3543 .label = "dfree command",
3546 .offset = LOCAL_VAR(szDfree),
3549 .flags = FLAG_ADVANCED,
3552 .label = "get quota command",
3554 .p_class = P_GLOBAL,
3555 .offset = GLOBAL_VAR(szGetQuota),
3558 .flags = FLAG_ADVANCED,
3561 .label = "set quota command",
3563 .p_class = P_GLOBAL,
3564 .offset = GLOBAL_VAR(szSetQuota),
3567 .flags = FLAG_ADVANCED,
3570 .label = "remote announce",
3572 .p_class = P_GLOBAL,
3573 .offset = GLOBAL_VAR(szRemoteAnnounce),
3576 .flags = FLAG_ADVANCED,
3579 .label = "remote browse sync",
3581 .p_class = P_GLOBAL,
3582 .offset = GLOBAL_VAR(szRemoteBrowseSync),
3585 .flags = FLAG_ADVANCED,
3588 .label = "socket address",
3590 .p_class = P_GLOBAL,
3591 .offset = GLOBAL_VAR(szSocketAddress),
3594 .flags = FLAG_ADVANCED,
3597 .label = "nmbd bind explicit broadcast",
3599 .p_class = P_GLOBAL,
3600 .offset = GLOBAL_VAR(bNmbdBindExplicitBroadcast),
3603 .flags = FLAG_ADVANCED,
3606 .label = "homedir map",
3608 .p_class = P_GLOBAL,
3609 .offset = GLOBAL_VAR(szNISHomeMapName),
3612 .flags = FLAG_ADVANCED,
3615 .label = "afs username map",
3617 .p_class = P_GLOBAL,
3618 .offset = GLOBAL_VAR(szAfsUsernameMap),
3621 .flags = FLAG_ADVANCED,
3624 .label = "afs token lifetime",
3626 .p_class = P_GLOBAL,
3627 .offset = GLOBAL_VAR(iAfsTokenLifetime),
3630 .flags = FLAG_ADVANCED,
3633 .label = "log nt token command",
3635 .p_class = P_GLOBAL,
3636 .offset = GLOBAL_VAR(szLogNtTokenCommand),
3639 .flags = FLAG_ADVANCED,
3642 .label = "NIS homedir",
3644 .p_class = P_GLOBAL,
3645 .offset = GLOBAL_VAR(bNISHomeMap),
3648 .flags = FLAG_ADVANCED,
3654 .offset = LOCAL_VAR(valid),
3663 .offset = LOCAL_VAR(szCopy),
3664 .special = handle_copy,
3672 .offset = LOCAL_VAR(szInclude),
3673 .special = handle_include,
3675 .flags = FLAG_HIDE|FLAG_META,
3681 .offset = LOCAL_VAR(szPreExec),
3684 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3690 .offset = LOCAL_VAR(szPreExec),
3693 .flags = FLAG_ADVANCED,
3696 .label = "preexec close",
3699 .offset = LOCAL_VAR(bPreexecClose),
3702 .flags = FLAG_ADVANCED | FLAG_SHARE,
3705 .label = "postexec",
3708 .offset = LOCAL_VAR(szPostExec),
3711 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3714 .label = "root preexec",
3717 .offset = LOCAL_VAR(szRootPreExec),
3720 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3723 .label = "root preexec close",
3726 .offset = LOCAL_VAR(bRootpreexecClose),
3729 .flags = FLAG_ADVANCED | FLAG_SHARE,
3732 .label = "root postexec",
3735 .offset = LOCAL_VAR(szRootPostExec),
3738 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3741 .label = "available",
3744 .offset = LOCAL_VAR(bAvailable),
3747 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3750 .label = "registry shares",
3752 .p_class = P_GLOBAL,
3753 .offset = GLOBAL_VAR(bRegistryShares),
3756 .flags = FLAG_ADVANCED,
3759 .label = "usershare allow guests",
3761 .p_class = P_GLOBAL,
3762 .offset = GLOBAL_VAR(bUsershareAllowGuests),
3765 .flags = FLAG_ADVANCED,
3768 .label = "usershare max shares",
3770 .p_class = P_GLOBAL,
3771 .offset = GLOBAL_VAR(iUsershareMaxShares),
3774 .flags = FLAG_ADVANCED,
3777 .label = "usershare owner only",
3779 .p_class = P_GLOBAL,
3780 .offset = GLOBAL_VAR(bUsershareOwnerOnly),
3783 .flags = FLAG_ADVANCED,
3786 .label = "usershare path",
3788 .p_class = P_GLOBAL,
3789 .offset = GLOBAL_VAR(szUsersharePath),
3792 .flags = FLAG_ADVANCED,
3795 .label = "usershare prefix allow list",
3797 .p_class = P_GLOBAL,
3798 .offset = GLOBAL_VAR(szUsersharePrefixAllowList),
3801 .flags = FLAG_ADVANCED,
3804 .label = "usershare prefix deny list",
3806 .p_class = P_GLOBAL,
3807 .offset = GLOBAL_VAR(szUsersharePrefixDenyList),
3810 .flags = FLAG_ADVANCED,
3813 .label = "usershare template share",
3815 .p_class = P_GLOBAL,
3816 .offset = GLOBAL_VAR(szUsershareTemplateShare),
3819 .flags = FLAG_ADVANCED,
3825 .offset = LOCAL_VAR(volume),
3828 .flags = FLAG_ADVANCED | FLAG_SHARE,
3834 .offset = LOCAL_VAR(fstype),
3837 .flags = FLAG_ADVANCED | FLAG_SHARE,
3840 .label = "set directory",
3843 .offset = LOCAL_VAR(bNo_set_dir),
3846 .flags = FLAG_ADVANCED | FLAG_SHARE,
3849 .label = "allow insecure wide links",
3851 .p_class = P_GLOBAL,
3852 .offset = GLOBAL_VAR(bAllowInsecureWidelinks),
3855 .flags = FLAG_ADVANCED,
3858 .label = "wide links",
3861 .offset = LOCAL_VAR(bWidelinks),
3864 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3867 .label = "follow symlinks",
3870 .offset = LOCAL_VAR(bSymlinks),
3873 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3876 .label = "dont descend",
3879 .offset = LOCAL_VAR(szDontdescend),
3882 .flags = FLAG_ADVANCED | FLAG_SHARE,
3885 .label = "magic script",
3888 .offset = LOCAL_VAR(szMagicScript),
3891 .flags = FLAG_ADVANCED | FLAG_SHARE,
3894 .label = "magic output",
3897 .offset = LOCAL_VAR(szMagicOutput),
3900 .flags = FLAG_ADVANCED | FLAG_SHARE,
3903 .label = "delete readonly",
3906 .offset = LOCAL_VAR(bDeleteReadonly),
3909 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3912 .label = "dos filemode",
3915 .offset = LOCAL_VAR(bDosFilemode),
3918 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3921 .label = "dos filetimes",
3924 .offset = LOCAL_VAR(bDosFiletimes),
3927 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3930 .label = "dos filetime resolution",
3933 .offset = LOCAL_VAR(bDosFiletimeResolution),
3936 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3939 .label = "fake directory create times",
3942 .offset = LOCAL_VAR(bFakeDirCreateTimes),
3945 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3948 .label = "async smb echo handler",
3950 .p_class = P_GLOBAL,
3951 .offset = GLOBAL_VAR(bAsyncSMBEchoHandler),
3954 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3957 .label = "multicast dns register",
3959 .p_class = P_GLOBAL,
3960 .offset = GLOBAL_VAR(bMulticastDnsRegister),
3963 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3966 .label = "panic action",
3968 .p_class = P_GLOBAL,
3969 .offset = GLOBAL_VAR(szPanicAction),
3972 .flags = FLAG_ADVANCED,
3975 .label = "perfcount module",
3977 .p_class = P_GLOBAL,
3978 .offset = GLOBAL_VAR(szSMBPerfcountModule),
3981 .flags = FLAG_ADVANCED,
3984 {N_("VFS module options"), P_SEP, P_SEPARATOR},
3987 .label = "vfs objects",
3990 .offset = LOCAL_VAR(szVfsObjects),
3993 .flags = FLAG_ADVANCED | FLAG_SHARE,
3996 .label = "vfs object",
3999 .offset = LOCAL_VAR(szVfsObjects),
4006 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4009 .label = "msdfs root",
4012 .offset = LOCAL_VAR(bMSDfsRoot),
4015 .flags = FLAG_ADVANCED | FLAG_SHARE,
4018 .label = "msdfs proxy",
4021 .offset = LOCAL_VAR(szMSDfsProxy),
4024 .flags = FLAG_ADVANCED | FLAG_SHARE,
4027 .label = "host msdfs",
4029 .p_class = P_GLOBAL,
4030 .offset = GLOBAL_VAR(bHostMSDfs),
4033 .flags = FLAG_ADVANCED,
4036 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4039 .label = "passdb expand explicit",
4041 .p_class = P_GLOBAL,
4042 .offset = GLOBAL_VAR(bPassdbExpandExplicit),
4045 .flags = FLAG_ADVANCED,
4048 .label = "idmap backend",
4050 .p_class = P_GLOBAL,
4051 .offset = GLOBAL_VAR(szIdmapBackend),
4052 .special = handle_idmap_backend,
4054 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4057 .label = "idmap cache time",
4059 .p_class = P_GLOBAL,
4060 .offset = GLOBAL_VAR(iIdmapCacheTime),
4063 .flags = FLAG_ADVANCED,
4066 .label = "idmap negative cache time",
4068 .p_class = P_GLOBAL,
4069 .offset = GLOBAL_VAR(iIdmapNegativeCacheTime),
4072 .flags = FLAG_ADVANCED,
4075 .label = "idmap uid",
4077 .p_class = P_GLOBAL,
4078 .offset = GLOBAL_VAR(szIdmapUID),
4079 .special = handle_idmap_uid,
4081 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4084 .label = "winbind uid",
4086 .p_class = P_GLOBAL,
4087 .offset = GLOBAL_VAR(szIdmapUID),
4088 .special = handle_idmap_uid,
4093 .label = "idmap gid",
4095 .p_class = P_GLOBAL,
4096 .offset = GLOBAL_VAR(szIdmapGID),
4097 .special = handle_idmap_gid,
4099 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4102 .label = "winbind gid",
4104 .p_class = P_GLOBAL,
4105 .offset = GLOBAL_VAR(szIdmapGID),
4106 .special = handle_idmap_gid,
4111 .label = "template homedir",
4113 .p_class = P_GLOBAL,
4114 .offset = GLOBAL_VAR(szTemplateHomedir),
4117 .flags = FLAG_ADVANCED,
4120 .label = "template shell",
4122 .p_class = P_GLOBAL,
4123 .offset = GLOBAL_VAR(szTemplateShell),
4126 .flags = FLAG_ADVANCED,
4129 .label = "winbind separator",
4131 .p_class = P_GLOBAL,
4132 .offset = GLOBAL_VAR(szWinbindSeparator),
4135 .flags = FLAG_ADVANCED,
4138 .label = "winbind cache time",
4140 .p_class = P_GLOBAL,
4141 .offset = GLOBAL_VAR(winbind_cache_time),
4144 .flags = FLAG_ADVANCED,
4147 .label = "winbind reconnect delay",
4149 .p_class = P_GLOBAL,
4150 .offset = GLOBAL_VAR(winbind_reconnect_delay),
4153 .flags = FLAG_ADVANCED,
4156 .label = "winbind max clients",
4158 .p_class = P_GLOBAL,
4159 .offset = GLOBAL_VAR(winbind_max_clients),
4162 .flags = FLAG_ADVANCED,
4165 .label = "winbind enum users",
4167 .p_class = P_GLOBAL,
4168 .offset = GLOBAL_VAR(bWinbindEnumUsers),
4171 .flags = FLAG_ADVANCED,
4174 .label = "winbind enum groups",
4176 .p_class = P_GLOBAL,
4177 .offset = GLOBAL_VAR(bWinbindEnumGroups),
4180 .flags = FLAG_ADVANCED,
4183 .label = "winbind use default domain",
4185 .p_class = P_GLOBAL,
4186 .offset = GLOBAL_VAR(bWinbindUseDefaultDomain),
4189 .flags = FLAG_ADVANCED,
4192 .label = "winbind trusted domains only",
4194 .p_class = P_GLOBAL,
4195 .offset = GLOBAL_VAR(bWinbindTrustedDomainsOnly),
4198 .flags = FLAG_ADVANCED,
4201 .label = "winbind nested groups",
4203 .p_class = P_GLOBAL,
4204 .offset = GLOBAL_VAR(bWinbindNestedGroups),
4207 .flags = FLAG_ADVANCED,
4210 .label = "winbind expand groups",
4212 .p_class = P_GLOBAL,
4213 .offset = GLOBAL_VAR(winbind_expand_groups),
4216 .flags = FLAG_ADVANCED,
4219 .label = "winbind nss info",
4221 .p_class = P_GLOBAL,
4222 .offset = GLOBAL_VAR(szWinbindNssInfo),
4225 .flags = FLAG_ADVANCED,
4228 .label = "winbind refresh tickets",
4230 .p_class = P_GLOBAL,
4231 .offset = GLOBAL_VAR(bWinbindRefreshTickets),
4234 .flags = FLAG_ADVANCED,
4237 .label = "winbind offline logon",
4239 .p_class = P_GLOBAL,
4240 .offset = GLOBAL_VAR(bWinbindOfflineLogon),
4243 .flags = FLAG_ADVANCED,
4246 .label = "winbind normalize names",
4248 .p_class = P_GLOBAL,
4249 .offset = GLOBAL_VAR(bWinbindNormalizeNames),
4252 .flags = FLAG_ADVANCED,
4255 .label = "winbind rpc only",
4257 .p_class = P_GLOBAL,
4258 .offset = GLOBAL_VAR(bWinbindRpcOnly),
4261 .flags = FLAG_ADVANCED,
4264 .label = "create krb5 conf",
4266 .p_class = P_GLOBAL,
4267 .offset = GLOBAL_VAR(bCreateKrb5Conf),
4270 .flags = FLAG_ADVANCED,
4273 .label = "ncalrpc dir",
4275 .p_class = P_GLOBAL,
4276 .offset = GLOBAL_VAR(ncalrpc_dir),
4279 .flags = FLAG_ADVANCED,
4282 .label = "winbind max domain connections",
4284 .p_class = P_GLOBAL,
4285 .offset = GLOBAL_VAR(winbindMaxDomainConnections),
4288 .flags = FLAG_ADVANCED,
4291 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
4294 /***************************************************************************
4295 Initialise the sDefault parameter structure for the printer values.
4296 ***************************************************************************/
4298 static void init_printer_values(struct loadparm_service *pService)
4300 /* choose defaults depending on the type of printing */
4301 switch (pService->iPrinting) {
4306 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4307 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4308 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4313 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4314 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4315 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4316 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4317 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4318 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4319 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4325 /* set the lpq command to contain the destination printer
4326 name only. This is used by cups_queue_get() */
4327 string_set(&pService->szLpqcommand, "%p");
4328 string_set(&pService->szLprmcommand, "");
4329 string_set(&pService->szPrintcommand, "");
4330 string_set(&pService->szLppausecommand, "");
4331 string_set(&pService->szLpresumecommand, "");
4332 string_set(&pService->szQueuepausecommand, "");
4333 string_set(&pService->szQueueresumecommand, "");
4335 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4336 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4337 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4338 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4339 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4340 string_set(&pService->szQueuepausecommand, "disable '%p'");
4341 string_set(&pService->szQueueresumecommand, "enable '%p'");
4342 #endif /* HAVE_CUPS */
4347 string_set(&pService->szLpqcommand, "lpstat -o%p");
4348 string_set(&pService->szLprmcommand, "cancel %p-%j");
4349 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4350 string_set(&pService->szQueuepausecommand, "disable %p");
4351 string_set(&pService->szQueueresumecommand, "enable %p");
4353 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4354 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4359 string_set(&pService->szLpqcommand, "lpq -P%p");
4360 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4361 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4364 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
4368 const char *tdbfile;
4371 tdbfile = talloc_asprintf(
4372 talloc_tos(), "tdbfile=%s",
4373 lp_parm_const_string(-1, "vlp", "tdbfile",
4375 if (tdbfile == NULL) {
4376 tdbfile="tdbfile=/tmp/vlp.tdb";
4379 tmp = talloc_asprintf(talloc_tos(), "vlp %s print %%p %%s",
4381 string_set(&pService->szPrintcommand,
4382 tmp ? tmp : "vlp print %p %s");
4385 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpq %%p",
4387 string_set(&pService->szLpqcommand,
4388 tmp ? tmp : "vlp lpq %p");
4391 tmp = talloc_asprintf(talloc_tos(), "vlp %s lprm %%p %%j",
4393 string_set(&pService->szLprmcommand,
4394 tmp ? tmp : "vlp lprm %p %j");
4397 tmp = talloc_asprintf(talloc_tos(), "vlp %s lppause %%p %%j",
4399 string_set(&pService->szLppausecommand,
4400 tmp ? tmp : "vlp lppause %p %j");
4403 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpresume %%p %%j",
4405 string_set(&pService->szLpresumecommand,
4406 tmp ? tmp : "vlp lpresume %p %j");
4409 tmp = talloc_asprintf(talloc_tos(), "vlp %s queuepause %%p",
4411 string_set(&pService->szQueuepausecommand,
4412 tmp ? tmp : "vlp queuepause %p");
4415 tmp = talloc_asprintf(talloc_tos(), "vlp %s queueresume %%p",
4417 string_set(&pService->szQueueresumecommand,
4418 tmp ? tmp : "vlp queueresume %p");
4423 #endif /* DEVELOPER */
4428 * Function to return the default value for the maximum number of open
4429 * file descriptors permitted. This function tries to consult the
4430 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4431 * the smaller of those.
4433 static int max_open_files(void)
4435 int sysctl_max = MAX_OPEN_FILES;
4436 int rlimit_max = MAX_OPEN_FILES;
4438 #ifdef HAVE_SYSCTLBYNAME
4440 size_t size = sizeof(sysctl_max);
4441 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4446 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4452 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4453 rlimit_max = rl.rlim_cur;
4455 #if defined(RLIM_INFINITY)
4456 if(rl.rlim_cur == RLIM_INFINITY)
4457 rlimit_max = MAX_OPEN_FILES;
4462 if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4463 DEBUG(2,("max_open_files: increasing sysctl_max (%d) to "
4464 "minimum Windows limit (%d)\n",
4466 MIN_OPEN_FILES_WINDOWS));
4467 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4470 if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4471 DEBUG(2,("rlimit_max: increasing rlimit_max (%d) to "
4472 "minimum Windows limit (%d)\n",
4474 MIN_OPEN_FILES_WINDOWS));
4475 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4478 return MIN(sysctl_max, rlimit_max);
4482 * Common part of freeing allocated data for one parameter.
4484 static void free_one_parameter_common(void *parm_ptr,
4485 struct parm_struct parm)
4487 if ((parm.type == P_STRING) ||
4488 (parm.type == P_USTRING))
4490 string_free((char**)parm_ptr);
4491 } else if (parm.type == P_LIST) {
4492 TALLOC_FREE(*((char***)parm_ptr));
4497 * Free the allocated data for one parameter for a share
4498 * given as a service struct.
4500 static void free_one_parameter(struct loadparm_service *service,
4501 struct parm_struct parm)
4505 if (parm.p_class != P_LOCAL) {
4509 parm_ptr = lp_parm_ptr(service, &parm);
4511 free_one_parameter_common(parm_ptr, parm);
4515 * Free the allocated parameter data of a share given
4516 * as a service struct.
4518 static void free_parameters(struct loadparm_service *service)
4522 for (i=0; parm_table[i].label; i++) {
4523 free_one_parameter(service, parm_table[i]);
4528 * Free the allocated data for one parameter for a given share
4529 * specified by an snum.
4531 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4536 parm_ptr = lp_parm_ptr(NULL, &parm);
4537 } else if (parm.p_class != P_LOCAL) {
4540 parm_ptr = lp_local_ptr_by_snum(snum, &parm);
4543 free_one_parameter_common(parm_ptr, parm);
4547 * Free the allocated parameter data for a share specified
4550 static void free_parameters_by_snum(int snum)
4554 for (i=0; parm_table[i].label; i++) {
4555 free_one_parameter_by_snum(snum, parm_table[i]);
4560 * Free the allocated global parameters.
4562 static void free_global_parameters(void)
4564 free_param_opts(&Globals.param_opt);
4565 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4568 static int map_parameter(const char *pszParmName);
4570 struct lp_stored_option {
4571 struct lp_stored_option *prev, *next;
4576 static struct lp_stored_option *stored_options;
4579 save options set by lp_set_cmdline() into a list. This list is
4580 re-applied when we do a globals reset, so that cmdline set options
4581 are sticky across reloads of smb.conf
4583 static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
4585 struct lp_stored_option *entry, *entry_next;
4586 for (entry = stored_options; entry != NULL; entry = entry_next) {
4587 entry_next = entry->next;
4588 if (strcmp(pszParmName, entry->label) == 0) {
4589 DLIST_REMOVE(stored_options, entry);
4595 entry = talloc(NULL, struct lp_stored_option);
4600 entry->label = talloc_strdup(entry, pszParmName);
4601 if (!entry->label) {
4606 entry->value = talloc_strdup(entry, pszParmValue);
4607 if (!entry->value) {
4612 DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
4617 static bool apply_lp_set_cmdline(void)
4619 struct lp_stored_option *entry = NULL;
4620 for (entry = stored_options; entry != NULL; entry = entry->next) {
4621 if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
4622 DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
4623 entry->label, entry->value));
4630 /***************************************************************************
4631 Initialise the global parameter structure.
4632 ***************************************************************************/
4634 static void init_globals(bool reinit_globals)
4636 static bool done_init = false;
4640 /* If requested to initialize only once and we've already done it... */
4641 if (!reinit_globals && done_init) {
4642 /* ... then we have nothing more to do */
4647 /* The logfile can be set before this is invoked. Free it if so. */
4648 if (Globals.szLogFile != NULL) {
4649 string_free(&Globals.szLogFile);
4650 Globals.szLogFile = NULL;
4654 free_global_parameters();
4657 /* This memset and the free_global_parameters() above will
4658 * wipe out smb.conf options set with lp_set_cmdline(). The
4659 * apply_lp_set_cmdline() call puts these values back in the
4660 * table once the defaults are set */
4661 ZERO_STRUCT(Globals);
4663 for (i = 0; parm_table[i].label; i++) {
4664 if ((parm_table[i].type == P_STRING ||
4665 parm_table[i].type == P_USTRING))
4667 string_set((char **)lp_parm_ptr(NULL, &parm_table[i]), "");
4672 string_set(&sDefault.fstype, FSTYPE_STRING);
4673 string_set(&sDefault.szPrintjobUsername, "%U");
4675 init_printer_values(&sDefault);
4678 DEBUG(3, ("Initialising global parameters\n"));
4680 /* Must manually force to upper case here, as this does not go via the handler */
4681 string_set(&Globals.szNetbiosName, myhostname_upper());
4683 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4684 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4686 /* use the new 'hash2' method by default, with a prefix of 1 */
4687 string_set(&Globals.szManglingMethod, "hash2");
4688 Globals.mangle_prefix = 1;
4690 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4692 /* using UTF8 by default allows us to support all chars */
4693 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4695 /* Use codepage 850 as a default for the dos character set */
4696 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4699 * Allow the default PASSWD_CHAT to be overridden in local.h.
4701 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4703 string_set(&Globals.szWorkgroup, DEFAULT_WORKGROUP);
4705 string_set(&Globals.szPasswdProgram, "");
4706 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4707 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4708 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4709 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4710 string_set(&Globals.szSocketAddress, "0.0.0.0");
4712 * By default support explicit binding to broadcast
4715 Globals.bNmbdBindExplicitBroadcast = true;
4717 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4718 smb_panic("init_globals: ENOMEM");
4720 string_set(&Globals.szServerString, s);
4723 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4726 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
4728 string_set(&Globals.szLogonDrive, "");
4729 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4730 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4731 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4733 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
4734 string_set(&Globals.szPasswordServer, "*");
4736 Globals.AlgorithmicRidBase = BASE_RID;
4738 Globals.bLoadPrinters = true;
4739 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4741 Globals.ConfigBackend = config_backend;
4742 Globals.ServerRole = ROLE_AUTO;
4744 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4745 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4746 Globals.max_xmit = 0x4104;
4747 Globals.max_mux = 50; /* This is *needed* for profile support. */
4748 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4749 Globals.bDisableSpoolss = false;
4750 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4751 Globals.pwordlevel = 0;
4752 Globals.unamelevel = 0;
4753 Globals.deadtime = 0;
4754 Globals.getwd_cache = true;
4755 Globals.bLargeReadwrite = true;
4756 Globals.max_log_size = 5000;
4757 Globals.max_open_files = max_open_files();
4758 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4759 Globals.maxprotocol = PROTOCOL_NT1;
4760 Globals.minprotocol = PROTOCOL_CORE;
4761 Globals.security = SEC_USER;
4762 Globals.paranoid_server_security = true;
4763 Globals.bEncryptPasswords = true;
4764 Globals.clientSchannel = Auto;
4765 Globals.serverSchannel = Auto;
4766 Globals.bReadRaw = true;
4767 Globals.bWriteRaw = true;
4768 Globals.bNullPasswords = false;
4769 Globals.bObeyPamRestrictions = false;
4771 Globals.bSyslogOnly = false;
4772 Globals.bTimestampLogs = true;
4773 string_set(&Globals.szLogLevel, "0");
4774 Globals.bDebugPrefixTimestamp = false;
4775 Globals.bDebugHiresTimestamp = true;
4776 Globals.bDebugPid = false;
4777 Globals.bDebugUid = false;
4778 Globals.bDebugClass = false;
4779 Globals.bEnableCoreFiles = true;
4780 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4781 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4782 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4783 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4784 Globals.lm_announce = Auto; /* = Auto: send only if LM clients found */
4785 Globals.lm_interval = 60;
4786 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4787 Globals.bNISHomeMap = false;
4788 #ifdef WITH_NISPLUS_HOME
4789 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4791 string_set(&Globals.szNISHomeMapName, "auto.home");
4794 Globals.bTimeServer = false;
4795 Globals.bBindInterfacesOnly = false;
4796 Globals.bUnixPasswdSync = false;
4797 Globals.bPamPasswordChange = false;
4798 Globals.bPasswdChatDebug = false;
4799 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4800 Globals.bNTPipeSupport = true; /* Do NT pipes by default. */
4801 Globals.bNTStatusSupport = true; /* Use NT status by default. */
4802 Globals.bStatCache = true; /* use stat cache by default */
4803 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4804 Globals.restrict_anonymous = 0;
4805 Globals.bClientLanManAuth = false; /* Do NOT use the LanMan hash if it is available */
4806 Globals.bClientPlaintextAuth = false; /* Do NOT use a plaintext password even if is requested by the server */
4807 Globals.bLanmanAuth = false; /* Do NOT use the LanMan hash, even if it is supplied */
4808 Globals.bNTLMAuth = true; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4809 Globals.bClientNTLMv2Auth = true; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
4810 /* Note, that we will also use NTLM2 session security (which is different), if it is available */
4812 Globals.map_to_guest = 0; /* By Default, "Never" */
4813 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4814 Globals.enhanced_browsing = true;
4815 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4816 #ifdef MMAP_BLACKLIST
4817 Globals.bUseMmap = false;
4819 Globals.bUseMmap = true;
4821 Globals.bUnixExtensions = true;
4822 Globals.bResetOnZeroVC = false;
4823 Globals.bLogWriteableFilesOnExit = false;
4824 Globals.bCreateKrb5Conf = true;
4825 Globals.winbindMaxDomainConnections = 1;
4827 /* hostname lookups can be very expensive and are broken on
4828 a large number of sites (tridge) */
4829 Globals.bHostnameLookups = false;
4831 string_set(&Globals.szPassdbBackend, "tdbsam");
4832 string_set(&Globals.szLdapSuffix, "");
4833 string_set(&Globals.szLdapMachineSuffix, "");
4834 string_set(&Globals.szLdapUserSuffix, "");
4835 string_set(&Globals.szLdapGroupSuffix, "");
4836 string_set(&Globals.szLdapIdmapSuffix, "");
4838 string_set(&Globals.szLdapAdminDn, "");
4839 Globals.ldap_ssl = LDAP_SSL_START_TLS;
4840 Globals.ldap_ssl_ads = false;
4841 Globals.ldap_deref = -1;
4842 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
4843 Globals.ldap_delete_dn = false;
4844 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
4845 Globals.ldap_follow_referral = Auto;
4846 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
4847 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
4848 Globals.ldap_page_size = LDAP_PAGE_SIZE;
4850 Globals.ldap_debug_level = 0;
4851 Globals.ldap_debug_threshold = 10;
4853 /* This is what we tell the afs client. in reality we set the token
4854 * to never expire, though, when this runs out the afs client will
4855 * forget the token. Set to 0 to get NEVERDATE.*/
4856 Globals.iAfsTokenLifetime = 604800;
4857 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
4859 /* these parameters are set to defaults that are more appropriate
4860 for the increasing samba install base:
4862 as a member of the workgroup, that will possibly become a
4863 _local_ master browser (lm = true). this is opposed to a forced
4864 local master browser startup (pm = true).
4866 doesn't provide WINS server service by default (wsupp = false),
4867 and doesn't provide domain master browser services by default, either.
4871 Globals.bMsAddPrinterWizard = true;
4872 Globals.os_level = 20;
4873 Globals.bLocalMaster = true;
4874 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
4875 Globals.bDomainLogons = false;
4876 Globals.bBrowseList = true;
4877 Globals.bWINSsupport = false;
4878 Globals.bWINSproxy = false;
4880 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
4881 Globals.InitLogonDelay = 100; /* 100 ms default delay */
4883 Globals.bDNSproxy = true;
4885 /* this just means to use them if they exist */
4886 Globals.bKernelOplocks = true;
4888 Globals.bAllowTrustedDomains = true;
4889 string_set(&Globals.szIdmapBackend, "tdb");
4891 string_set(&Globals.szTemplateShell, "/bin/false");
4892 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
4893 string_set(&Globals.szWinbindSeparator, "\\");
4895 string_set(&Globals.szCupsServer, "");
4896 string_set(&Globals.szIPrintServer, "");
4898 string_set(&Globals.ctdbdSocket, "");
4899 Globals.szClusterAddresses = NULL;
4900 Globals.clustering = false;
4901 Globals.ctdb_timeout = 0;
4902 Globals.ctdb_locktime_warn_threshold = 0;
4904 Globals.winbind_cache_time = 300; /* 5 minutes */
4905 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
4906 Globals.winbind_max_clients = 200;
4907 Globals.bWinbindEnumUsers = false;
4908 Globals.bWinbindEnumGroups = false;
4909 Globals.bWinbindUseDefaultDomain = false;
4910 Globals.bWinbindTrustedDomainsOnly = false;
4911 Globals.bWinbindNestedGroups = true;
4912 Globals.winbind_expand_groups = 1;
4913 Globals.szWinbindNssInfo = (const char **)str_list_make_v3(NULL, "template", NULL);
4914 Globals.bWinbindRefreshTickets = false;
4915 Globals.bWinbindOfflineLogon = false;
4917 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
4918 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
4920 Globals.bPassdbExpandExplicit = false;
4922 Globals.name_cache_timeout = 660; /* In seconds */
4924 Globals.bUseSpnego = true;
4925 Globals.bClientUseSpnego = true;
4927 Globals.client_signing = SMB_SIGNING_DEFAULT;
4928 Globals.server_signing = SMB_SIGNING_DEFAULT;
4930 Globals.bDeferSharingViolations = true;
4931 string_set(&Globals.smb_ports, SMB_PORTS);
4933 Globals.bEnablePrivileges = true;
4934 Globals.bHostMSDfs = true;
4935 Globals.bASUSupport = false;
4937 /* User defined shares. */
4938 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
4939 smb_panic("init_globals: ENOMEM");
4941 string_set(&Globals.szUsersharePath, s);
4943 string_set(&Globals.szUsershareTemplateShare, "");
4944 Globals.iUsershareMaxShares = 0;
4945 /* By default disallow sharing of directories not owned by the sharer. */
4946 Globals.bUsershareOwnerOnly = true;
4947 /* By default disallow guest access to usershares. */
4948 Globals.bUsershareAllowGuests = false;
4950 Globals.iKeepalive = DEFAULT_KEEPALIVE;
4952 /* By default no shares out of the registry */
4953 Globals.bRegistryShares = false;
4955 Globals.iminreceivefile = 0;
4957 Globals.bMapUntrustedToDomain = false;
4958 Globals.bMulticastDnsRegister = true;
4960 Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ;
4961 Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE;
4962 Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT;
4963 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
4965 string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
4967 /* Now put back the settings that were set with lp_set_cmdline() */
4968 apply_lp_set_cmdline();
4971 /*******************************************************************
4972 Convenience routine to grab string parameters into temporary memory
4973 and run standard_sub_basic on them. The buffers can be written to by
4974 callers without affecting the source string.
4975 ********************************************************************/
4977 static char *lp_string(const char *s)
4980 TALLOC_CTX *ctx = talloc_tos();
4982 /* The follow debug is useful for tracking down memory problems
4983 especially if you have an inner loop that is calling a lp_*()
4984 function that returns a string. Perhaps this debug should be
4985 present all the time? */
4988 DEBUG(10, ("lp_string(%s)\n", s));
4994 ret = talloc_sub_basic(ctx,
4995 get_current_username(),
4996 current_user_info.domain,
4998 if (trim_char(ret, '\"', '\"')) {
4999 if (strchr(ret,'\"') != NULL) {
5001 ret = talloc_sub_basic(ctx,
5002 get_current_username(),
5003 current_user_info.domain,
5011 In this section all the functions that are used to access the
5012 parameters from the rest of the program are defined
5015 #define FN_GLOBAL_STRING(fn_name,ptr) \
5016 char *fn_name(void) {return(lp_string(*(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : ""));}
5017 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5018 const char *fn_name(void) {return(*(const char **)(&Globals.ptr) ? *(const char **)(&Globals.ptr) : "");}
5019 #define FN_GLOBAL_LIST(fn_name,ptr) \
5020 const char **fn_name(void) {return(*(const char ***)(&Globals.ptr));}
5021 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5022 bool fn_name(void) {return(*(bool *)(&Globals.ptr));}
5023 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5024 char fn_name(void) {return(*(char *)(&Globals.ptr));}
5025 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5026 int fn_name(void) {return(*(int *)(&Globals.ptr));}
5028 #define FN_LOCAL_STRING(fn_name,val) \
5029 char *lp_ ## fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5030 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5031 const char *lp_ ## fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5032 #define FN_LOCAL_LIST(fn_name,val) \
5033 const char **lp_ ## fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5034 #define FN_LOCAL_BOOL(fn_name,val) \
5035 bool lp_ ## fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5036 #define FN_LOCAL_INTEGER(fn_name,val) \
5037 int lp_ ## fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5039 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5040 bool lp_ ## fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5041 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5042 int lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5043 #define FN_LOCAL_CHAR(fn_name,val) \
5044 char lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5046 FN_GLOBAL_CONST_STRING(lp_smb_ports, smb_ports)
5047 FN_GLOBAL_CONST_STRING(lp_dos_charset, dos_charset)
5048 FN_GLOBAL_CONST_STRING(lp_unix_charset, unix_charset)
5049 FN_GLOBAL_STRING(lp_logfile, szLogFile)
5050 FN_GLOBAL_STRING(lp_configfile, szConfigFile)
5051 FN_GLOBAL_CONST_STRING(lp_smb_passwd_file, szSMBPasswdFile)
5052 FN_GLOBAL_CONST_STRING(lp_private_dir, szPrivateDir)
5053 FN_GLOBAL_STRING(lp_serverstring, szServerString)
5054 FN_GLOBAL_INTEGER(lp_printcap_cache_time, PrintcapCacheTime)
5055 FN_GLOBAL_STRING(lp_addport_cmd, szAddPortCommand)
5056 FN_GLOBAL_STRING(lp_enumports_cmd, szEnumPortsCommand)
5057 FN_GLOBAL_STRING(lp_addprinter_cmd, szAddPrinterCommand)
5058 FN_GLOBAL_STRING(lp_deleteprinter_cmd, szDeletePrinterCommand)
5059 FN_GLOBAL_STRING(lp_os2_driver_map, szOs2DriverMap)
5060 FN_GLOBAL_CONST_STRING(lp_lockdir, szLockDir)
5061 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5062 * build process or in smb.conf, we use that value. Otherwise they
5063 * default to the value of lp_lockdir(). */
5064 const char *lp_statedir(void) {
5065 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5066 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5067 return(*(char **)(&Globals.szStateDir) ?
5068 *(char **)(&Globals.szStateDir) : "");
5070 return(*(char **)(&Globals.szLockDir) ?
5071 *(char **)(&Globals.szLockDir) : "");
5073 const char *lp_cachedir(void) {
5074 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5075 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5076 return(*(char **)(&Globals.szCacheDir) ?
5077 *(char **)(&Globals.szCacheDir) : "");
5079 return(*(char **)(&Globals.szLockDir) ?
5080 *(char **)(&Globals.szLockDir) : "");
5082 FN_GLOBAL_CONST_STRING(lp_piddir, szPidDir)
5083 FN_GLOBAL_STRING(lp_mangling_method, szManglingMethod)
5084 FN_GLOBAL_INTEGER(lp_mangle_prefix, mangle_prefix)
5085 FN_GLOBAL_CONST_STRING(lp_utmpdir, szUtmpDir)
5086 FN_GLOBAL_CONST_STRING(lp_wtmpdir, szWtmpDir)
5087 FN_GLOBAL_BOOL(lp_utmp, bUtmp)
5088 FN_GLOBAL_STRING(lp_rootdir, szRootdir)
5089 FN_GLOBAL_STRING(lp_perfcount_module, szSMBPerfcountModule)
5090 FN_GLOBAL_STRING(lp_defaultservice, szDefaultService)
5091 FN_GLOBAL_STRING(lp_msg_command, szMsgCommand)
5092 FN_GLOBAL_STRING(lp_get_quota_command, szGetQuota)
5093 FN_GLOBAL_STRING(lp_set_quota_command, szSetQuota)
5094 FN_GLOBAL_STRING(lp_auto_services, szAutoServices)
5095 FN_GLOBAL_STRING(lp_passwd_program, szPasswdProgram)
5096 FN_GLOBAL_STRING(lp_passwd_chat, szPasswdChat)
5097 FN_GLOBAL_CONST_STRING(lp_passwordserver, szPasswordServer)
5098 FN_GLOBAL_CONST_STRING(lp_name_resolve_order, szNameResolveOrder)
5099 FN_GLOBAL_CONST_STRING(lp_workgroup, szWorkgroup)
5100 FN_GLOBAL_CONST_STRING(lp_netbios_name, szNetbiosName)
5101 FN_GLOBAL_CONST_STRING(lp_netbios_scope, szNetbiosScope)
5102 FN_GLOBAL_CONST_STRING(lp_realm, szRealmUpper)
5103 FN_GLOBAL_CONST_STRING(lp_dnsdomain, szDnsDomain)
5104 FN_GLOBAL_CONST_STRING(lp_afs_username_map, szAfsUsernameMap)
5105 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, iAfsTokenLifetime)
5106 FN_GLOBAL_STRING(lp_log_nt_token_command, szLogNtTokenCommand)
5107 FN_GLOBAL_STRING(lp_username_map, szUsernameMap)
5108 FN_GLOBAL_CONST_STRING(lp_logon_script, szLogonScript)
5109 FN_GLOBAL_CONST_STRING(lp_logon_path, szLogonPath)
5110 FN_GLOBAL_CONST_STRING(lp_logon_drive, szLogonDrive)
5111 FN_GLOBAL_CONST_STRING(lp_logon_home, szLogonHome)
5112 FN_GLOBAL_STRING(lp_remote_announce, szRemoteAnnounce)
5113 FN_GLOBAL_STRING(lp_remote_browse_sync, szRemoteBrowseSync)
5114 FN_GLOBAL_BOOL(lp_nmbd_bind_explicit_broadcast, bNmbdBindExplicitBroadcast)
5115 FN_GLOBAL_LIST(lp_wins_server_list, szWINSservers)
5116 FN_GLOBAL_LIST(lp_interfaces, szInterfaces)
5117 FN_GLOBAL_STRING(lp_nis_home_map_name, szNISHomeMapName)
5118 FN_GLOBAL_LIST(lp_netbios_aliases, szNetbiosAliases)
5119 FN_GLOBAL_CONST_STRING(lp_passdb_backend, szPassdbBackend)
5120 FN_GLOBAL_LIST(lp_preload_modules, szPreloadModules)
5121 FN_GLOBAL_STRING(lp_panic_action, szPanicAction)
5122 FN_GLOBAL_STRING(lp_adduser_script, szAddUserScript)
5123 FN_GLOBAL_STRING(lp_renameuser_script, szRenameUserScript)
5124 FN_GLOBAL_STRING(lp_deluser_script, szDelUserScript)
5126 FN_GLOBAL_CONST_STRING(lp_guestaccount, szGuestaccount)
5127 FN_GLOBAL_STRING(lp_addgroup_script, szAddGroupScript)
5128 FN_GLOBAL_STRING(lp_delgroup_script, szDelGroupScript)
5129 FN_GLOBAL_STRING(lp_addusertogroup_script, szAddUserToGroupScript)
5130 FN_GLOBAL_STRING(lp_deluserfromgroup_script, szDelUserFromGroupScript)
5131 FN_GLOBAL_STRING(lp_setprimarygroup_script, szSetPrimaryGroupScript)
5133 FN_GLOBAL_STRING(lp_addmachine_script, szAddMachineScript)
5135 FN_GLOBAL_STRING(lp_shutdown_script, szShutdownScript)
5136 FN_GLOBAL_STRING(lp_abort_shutdown_script, szAbortShutdownScript)
5137 FN_GLOBAL_STRING(lp_username_map_script, szUsernameMapScript)
5138 FN_GLOBAL_INTEGER(lp_username_map_cache_time, iUsernameMapCacheTime)
5140 FN_GLOBAL_STRING(lp_check_password_script, szCheckPasswordScript)
5142 FN_GLOBAL_STRING(lp_wins_hook, szWINSHook)
5143 FN_GLOBAL_CONST_STRING(lp_template_homedir, szTemplateHomedir)
5144 FN_GLOBAL_CONST_STRING(lp_template_shell, szTemplateShell)
5145 FN_GLOBAL_CONST_STRING(lp_winbind_separator, szWinbindSeparator)
5146 FN_GLOBAL_INTEGER(lp_acl_compatibility, iAclCompat)
5147 FN_GLOBAL_BOOL(lp_winbind_enum_users, bWinbindEnumUsers)
5148 FN_GLOBAL_BOOL(lp_winbind_enum_groups, bWinbindEnumGroups)
5149 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, bWinbindUseDefaultDomain)
5150 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, bWinbindTrustedDomainsOnly)
5151 FN_GLOBAL_BOOL(lp_winbind_nested_groups, bWinbindNestedGroups)
5152 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, winbind_expand_groups)
5153 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, bWinbindRefreshTickets)
5154 FN_GLOBAL_BOOL(lp_winbind_offline_logon, bWinbindOfflineLogon)
5155 FN_GLOBAL_BOOL(lp_winbind_normalize_names, bWinbindNormalizeNames)
5156 FN_GLOBAL_BOOL(lp_winbind_rpc_only, bWinbindRpcOnly)
5157 FN_GLOBAL_BOOL(lp_create_krb5_conf, bCreateKrb5Conf)
5158 static FN_GLOBAL_INTEGER(lp_winbind_max_domain_connections_int,
5159 winbindMaxDomainConnections)
5161 int lp_winbind_max_domain_connections(void)
5163 if (lp_winbind_offline_logon() &&
5164 lp_winbind_max_domain_connections_int() > 1) {
5165 DEBUG(1, ("offline logons active, restricting max domain "
5166 "connections to 1\n"));
5169 return MAX(1, lp_winbind_max_domain_connections_int());
5172 FN_GLOBAL_CONST_STRING(lp_idmap_backend, szIdmapBackend)
5173 FN_GLOBAL_INTEGER(lp_idmap_cache_time, iIdmapCacheTime)
5174 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, iIdmapNegativeCacheTime)
5175 FN_GLOBAL_INTEGER(lp_keepalive, iKeepalive)
5176 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, bPassdbExpandExplicit)
5178 FN_GLOBAL_STRING(lp_ldap_suffix, szLdapSuffix)
5179 FN_GLOBAL_STRING(lp_ldap_admin_dn, szLdapAdminDn)
5180 FN_GLOBAL_INTEGER(lp_ldap_ssl, ldap_ssl)
5181 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, ldap_ssl_ads)
5182 FN_GLOBAL_INTEGER(lp_ldap_deref, ldap_deref)
5183 FN_GLOBAL_INTEGER(lp_ldap_follow_referral, ldap_follow_referral)
5184 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, ldap_passwd_sync)
5185 FN_GLOBAL_BOOL(lp_ldap_delete_dn, ldap_delete_dn)
5186 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, ldap_replication_sleep)
5187 FN_GLOBAL_INTEGER(lp_ldap_timeout, ldap_timeout)
5188 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, ldap_connection_timeout)
5189 FN_GLOBAL_INTEGER(lp_ldap_page_size, ldap_page_size)
5190 FN_GLOBAL_INTEGER(lp_ldap_debug_level, ldap_debug_level)
5191 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, ldap_debug_threshold)
5192 FN_GLOBAL_STRING(lp_add_share_cmd, szAddShareCommand)
5193 FN_GLOBAL_STRING(lp_change_share_cmd, szChangeShareCommand)
5194 FN_GLOBAL_STRING(lp_delete_share_cmd, szDeleteShareCommand)
5195 FN_GLOBAL_STRING(lp_usershare_path, szUsersharePath)
5196 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, szUsersharePrefixAllowList)
5197 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, szUsersharePrefixDenyList)
5199 FN_GLOBAL_LIST(lp_eventlog_list, szEventLogs)
5201 FN_GLOBAL_BOOL(lp_registry_shares, bRegistryShares)
5202 FN_GLOBAL_BOOL(lp_usershare_allow_guests, bUsershareAllowGuests)
5203 FN_GLOBAL_BOOL(lp_usershare_owner_only, bUsershareOwnerOnly)
5204 FN_GLOBAL_BOOL(lp_disable_netbios, bDisableNetbios)
5205 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, bResetOnZeroVC)
5206 FN_GLOBAL_BOOL(lp_log_writeable_files_on_exit, bLogWriteableFilesOnExit)
5207 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, bMsAddPrinterWizard)
5208 FN_GLOBAL_BOOL(lp_dns_proxy, bDNSproxy)
5209 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, bWINSsupport)
5210 FN_GLOBAL_BOOL(lp_wins_proxy, bWINSproxy)
5211 FN_GLOBAL_BOOL(lp_local_master, bLocalMaster)
5212 static FN_GLOBAL_BOOL(lp_domain_logons, bDomainLogons)
5213 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, szInitLogonDelayedHosts)
5214 FN_GLOBAL_INTEGER(lp_init_logon_delay, InitLogonDelay)
5215 FN_GLOBAL_BOOL(lp_load_printers, bLoadPrinters)
5216 FN_GLOBAL_BOOL(_lp_readraw, bReadRaw)
5217 FN_GLOBAL_BOOL(lp_large_readwrite, bLargeReadwrite)
5218 FN_GLOBAL_BOOL(_lp_writeraw, bWriteRaw)
5219 FN_GLOBAL_BOOL(lp_null_passwords, bNullPasswords)
5220 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, bObeyPamRestrictions)
5221 FN_GLOBAL_BOOL(lp_encrypted_passwords, bEncryptPasswords)
5222 FN_GLOBAL_INTEGER(lp_client_schannel, clientSchannel)
5223 FN_GLOBAL_INTEGER(lp_server_schannel, serverSchannel)
5224 FN_GLOBAL_BOOL(lp_syslog_only, bSyslogOnly)
5225 FN_GLOBAL_BOOL(lp_timestamp_logs, bTimestampLogs)
5226 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, bDebugPrefixTimestamp)
5227 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, bDebugHiresTimestamp)
5228 FN_GLOBAL_BOOL(lp_debug_pid, bDebugPid)
5229 FN_GLOBAL_BOOL(lp_debug_uid, bDebugUid)
5230 FN_GLOBAL_BOOL(lp_debug_class, bDebugClass)
5231 FN_GLOBAL_BOOL(lp_enable_core_files, bEnableCoreFiles)
5232 FN_GLOBAL_BOOL(lp_browse_list, bBrowseList)
5233 FN_GLOBAL_BOOL(lp_nis_home_map, bNISHomeMap)
5234 static FN_GLOBAL_BOOL(lp_time_server, bTimeServer)
5235 FN_GLOBAL_BOOL(lp_bind_interfaces_only, bBindInterfacesOnly)
5236 FN_GLOBAL_BOOL(lp_pam_password_change, bPamPasswordChange)
5237 FN_GLOBAL_BOOL(lp_unix_password_sync, bUnixPasswdSync)
5238 FN_GLOBAL_BOOL(lp_passwd_chat_debug, bPasswdChatDebug)
5239 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, iPasswdChatTimeout)
5240 FN_GLOBAL_BOOL(lp_nt_pipe_support, bNTPipeSupport)
5241 FN_GLOBAL_BOOL(lp_nt_status_support, bNTStatusSupport)
5242 FN_GLOBAL_BOOL(lp_stat_cache, bStatCache)
5243 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, iMaxStatCacheSize)
5244 FN_GLOBAL_BOOL(lp_allow_trusted_domains, bAllowTrustedDomains)
5245 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, bMapUntrustedToDomain)
5246 FN_GLOBAL_INTEGER(lp_restrict_anonymous, restrict_anonymous)
5247 FN_GLOBAL_BOOL(lp_lanman_auth, bLanmanAuth)
5248 FN_GLOBAL_BOOL(lp_ntlm_auth, bNTLMAuth)
5249 FN_GLOBAL_BOOL(lp_client_plaintext_auth, bClientPlaintextAuth)
5250 FN_GLOBAL_BOOL(lp_client_lanman_auth, bClientLanManAuth)
5251 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, bClientNTLMv2Auth)
5252 FN_GLOBAL_BOOL(lp_host_msdfs, bHostMSDfs)
5253 FN_GLOBAL_BOOL(lp_kernel_oplocks, bKernelOplocks)
5254 FN_GLOBAL_BOOL(lp_enhanced_browsing, enhanced_browsing)
5255 FN_GLOBAL_BOOL(lp_use_mmap, bUseMmap)
5256 FN_GLOBAL_BOOL(lp_unix_extensions, bUnixExtensions)
5257 FN_GLOBAL_BOOL(lp_use_spnego, bUseSpnego)
5258 FN_GLOBAL_BOOL(lp_client_use_spnego, bClientUseSpnego)
5259 FN_GLOBAL_BOOL(lp_client_use_spnego_principal, client_use_spnego_principal)
5260 FN_GLOBAL_BOOL(lp_send_spnego_principal, send_spnego_principal)
5261 FN_GLOBAL_BOOL(lp_hostname_lookups, bHostnameLookups)
5262 FN_GLOBAL_CONST_STRING(lp_dedicated_keytab_file, szDedicatedKeytabFile)
5263 FN_GLOBAL_INTEGER(lp_kerberos_method, iKerberosMethod)
5264 FN_GLOBAL_BOOL(lp_defer_sharing_violations, bDeferSharingViolations)
5265 FN_GLOBAL_BOOL(lp_enable_privileges, bEnablePrivileges)
5266 FN_GLOBAL_BOOL(lp_enable_asu_support, bASUSupport)
5267 FN_GLOBAL_INTEGER(lp_os_level, os_level)
5268 FN_GLOBAL_INTEGER(lp_max_ttl, max_ttl)
5269 FN_GLOBAL_INTEGER(lp_max_wins_ttl, max_wins_ttl)
5270 FN_GLOBAL_INTEGER(lp_min_wins_ttl, min_wins_ttl)
5271 FN_GLOBAL_INTEGER(lp_max_log_size, max_log_size)
5272 FN_GLOBAL_INTEGER(lp_max_open_files, max_open_files)
5273 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, open_files_db_hash_size)
5274 FN_GLOBAL_INTEGER(lp_maxxmit, max_xmit)
5275 FN_GLOBAL_INTEGER(lp_maxmux, max_mux)
5276 FN_GLOBAL_INTEGER(lp_passwordlevel, pwordlevel)
5277 FN_GLOBAL_INTEGER(lp_usernamelevel, unamelevel)
5278 FN_GLOBAL_INTEGER(lp_deadtime, deadtime)
5279 FN_GLOBAL_BOOL(lp_getwd_cache, getwd_cache)
5280 static FN_GLOBAL_INTEGER(_lp_maxprotocol, maxprotocol)
5281 int lp_maxprotocol(void)
5283 int ret = _lp_maxprotocol();
5284 if ((ret >= PROTOCOL_SMB2_02) && (lp_security() == SEC_SHARE)) {
5285 DEBUG(2,("WARNING!!: \"security = share\" is incompatible "
5286 "with the SMB2 protocol. Resetting to SMB1.\n" ));
5287 lp_do_parameter(-1, "max protocol", "NT1");
5288 return PROTOCOL_NT1;
5292 FN_GLOBAL_INTEGER(lp_minprotocol, minprotocol)
5293 FN_GLOBAL_INTEGER(lp_security, security)
5294 FN_GLOBAL_LIST(lp_auth_methods, AuthMethods)
5295 FN_GLOBAL_BOOL(lp_paranoid_server_security, paranoid_server_security)
5296 FN_GLOBAL_INTEGER(lp_maxdisksize, maxdisksize)
5297 FN_GLOBAL_INTEGER(lp_lpqcachetime, lpqcachetime)
5298 FN_GLOBAL_INTEGER(lp_max_smbd_processes, iMaxSmbdProcesses)
5299 FN_GLOBAL_BOOL(_lp_disable_spoolss, bDisableSpoolss)
5300 FN_GLOBAL_INTEGER(lp_syslog, syslog)
5301 FN_GLOBAL_INTEGER(lp_lm_announce, lm_announce)
5302 FN_GLOBAL_INTEGER(lp_lm_interval, lm_interval)
5303 FN_GLOBAL_INTEGER(lp_machine_password_timeout, machine_password_timeout)
5304 FN_GLOBAL_INTEGER(lp_map_to_guest, map_to_guest)
5305 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, oplock_break_wait_time)
5306 FN_GLOBAL_INTEGER(lp_lock_spin_time, iLockSpinTime)
5307 FN_GLOBAL_INTEGER(lp_usershare_max_shares, iUsershareMaxShares)
5308 FN_GLOBAL_CONST_STRING(lp_socket_options, szSocketOptions)
5309 FN_GLOBAL_INTEGER(lp_config_backend, ConfigBackend)
5310 static FN_GLOBAL_INTEGER(lp__server_role, ServerRole)
5311 FN_GLOBAL_INTEGER(lp_smb2_max_read, ismb2_max_read)
5312 FN_GLOBAL_INTEGER(lp_smb2_max_write, ismb2_max_write)
5313 FN_GLOBAL_INTEGER(lp_smb2_max_trans, ismb2_max_trans)
5314 int lp_smb2_max_credits(void)
5316 if (Globals.ismb2_max_credits == 0) {
5317 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5319 return Globals.ismb2_max_credits;
5321 FN_GLOBAL_LIST(lp_svcctl_list, szServicesList)
5322 FN_GLOBAL_STRING(lp_cups_server, szCupsServer)
5323 int lp_cups_encrypt(void)
5326 #ifdef HAVE_HTTPCONNECTENCRYPT
5327 switch (Globals.CupsEncrypt) {
5329 result = HTTP_ENCRYPT_REQUIRED;
5332 result = HTTP_ENCRYPT_ALWAYS;
5335 result = HTTP_ENCRYPT_NEVER;
5341 FN_GLOBAL_STRING(lp_iprint_server, szIPrintServer)
5342 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, cups_connection_timeout)
5343 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, ctdbdSocket)
5344 FN_GLOBAL_LIST(lp_cluster_addresses, szClusterAddresses)
5345 FN_GLOBAL_BOOL(lp_clustering, clustering)
5346 FN_GLOBAL_INTEGER(lp_ctdb_timeout, ctdb_timeout)
5347 FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, ctdb_locktime_warn_threshold)
5348 FN_GLOBAL_BOOL(lp_async_smb_echo_handler, bAsyncSMBEchoHandler)
5349 FN_GLOBAL_BOOL(lp_multicast_dns_register, bMulticastDnsRegister)
5350 FN_GLOBAL_BOOL(lp_allow_insecure_widelinks, bAllowInsecureWidelinks)
5351 FN_GLOBAL_INTEGER(lp_winbind_cache_time, winbind_cache_time)
5352 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, winbind_reconnect_delay)
5353 FN_GLOBAL_INTEGER(lp_winbind_max_clients, winbind_max_clients)
5354 FN_GLOBAL_LIST(lp_winbind_nss_info, szWinbindNssInfo)
5355 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, AlgorithmicRidBase)
5356 FN_GLOBAL_INTEGER(lp_name_cache_timeout, name_cache_timeout)
5357 FN_GLOBAL_INTEGER(lp_client_signing, client_signing)
5358 FN_GLOBAL_INTEGER(lp_server_signing, server_signing)
5359 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, client_ldap_sasl_wrapping)
5361 FN_GLOBAL_CONST_STRING(lp_ncalrpc_dir, ncalrpc_dir)
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;
6476 *(int *)dest_ptr = *(int *)src_ptr;
6480 *(char *)dest_ptr = *(char *)src_ptr;
6484 string_set((char **)dest_ptr,
6490 char *upper_string = strupper_talloc(talloc_tos(),
6492 string_set((char **)dest_ptr,
6494 TALLOC_FREE(upper_string);
6498 TALLOC_FREE(*((char ***)dest_ptr));
6499 *((char ***)dest_ptr) = str_list_copy(NULL,
6500 *(const char ***)src_ptr);
6508 init_copymap(pserviceDest);
6509 if (pserviceSource->copymap)
6510 bitmap_copy(pserviceDest->copymap,
6511 pserviceSource->copymap);
6514 data = pserviceSource->param_opt;
6516 set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->priority);
6521 /***************************************************************************
6522 Check a service for consistency. Return false if the service is in any way
6523 incomplete or faulty, else true.
6524 ***************************************************************************/
6526 bool service_ok(int iService)
6531 if (ServicePtrs[iService]->szService[0] == '\0') {
6532 DEBUG(0, ("The following message indicates an internal error:\n"));
6533 DEBUG(0, ("No service name in service entry.\n"));
6537 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6538 /* I can't see why you'd want a non-printable printer service... */
6539 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6540 if (!ServicePtrs[iService]->bPrint_ok) {
6541 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6542 ServicePtrs[iService]->szService));
6543 ServicePtrs[iService]->bPrint_ok = true;
6545 /* [printers] service must also be non-browsable. */
6546 if (ServicePtrs[iService]->bBrowseable)
6547 ServicePtrs[iService]->bBrowseable = false;
6550 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6551 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6552 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6554 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6555 ServicePtrs[iService]->szService));
6556 ServicePtrs[iService]->bAvailable = false;
6559 /* If a service is flagged unavailable, log the fact at level 1. */
6560 if (!ServicePtrs[iService]->bAvailable)
6561 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6562 ServicePtrs[iService]->szService));
6567 static struct smbconf_ctx *lp_smbconf_ctx(void)
6570 static struct smbconf_ctx *conf_ctx = NULL;
6572 if (conf_ctx == NULL) {
6573 err = smbconf_init(NULL, &conf_ctx, "registry:");
6574 if (!SBC_ERROR_IS_OK(err)) {
6575 DEBUG(1, ("error initializing registry configuration: "
6576 "%s\n", sbcErrorString(err)));
6584 static bool process_smbconf_service(struct smbconf_service *service)
6589 if (service == NULL) {
6593 ret = do_section(service->name, NULL);
6597 for (count = 0; count < service->num_params; count++) {
6598 ret = do_parameter(service->param_names[count],
6599 service->param_values[count],
6605 if (iServiceIndex >= 0) {
6606 return service_ok(iServiceIndex);
6612 * load a service from registry and activate it
6614 bool process_registry_service(const char *service_name)
6617 struct smbconf_service *service = NULL;
6618 TALLOC_CTX *mem_ctx = talloc_stackframe();
6619 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6622 if (conf_ctx == NULL) {
6626 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6628 if (!smbconf_share_exists(conf_ctx, service_name)) {
6630 * Registry does not contain data for this service (yet),
6631 * but make sure lp_load doesn't return false.
6637 err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6638 if (!SBC_ERROR_IS_OK(err)) {
6642 ret = process_smbconf_service(service);
6648 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6651 TALLOC_FREE(mem_ctx);
6656 * process_registry_globals
6658 static bool process_registry_globals(void)
6662 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6664 ret = do_parameter("registry shares", "yes", NULL);
6669 return process_registry_service(GLOBAL_NAME);
6672 bool process_registry_shares(void)
6676 struct smbconf_service **service = NULL;
6677 uint32_t num_shares = 0;
6678 TALLOC_CTX *mem_ctx = talloc_stackframe();
6679 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6682 if (conf_ctx == NULL) {
6686 err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6687 if (!SBC_ERROR_IS_OK(err)) {
6693 for (count = 0; count < num_shares; count++) {
6694 if (strequal(service[count]->name, GLOBAL_NAME)) {
6697 ret = process_smbconf_service(service[count]);
6704 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6707 TALLOC_FREE(mem_ctx);
6712 * reload those shares from registry that are already
6713 * activated in the services array.
6715 static bool reload_registry_shares(void)
6720 for (i = 0; i < iNumServices; i++) {
6725 if (ServicePtrs[i]->usershare == USERSHARE_VALID) {
6729 ret = process_registry_service(ServicePtrs[i]->szService);
6740 #define MAX_INCLUDE_DEPTH 100
6742 static uint8_t include_depth;
6744 static struct file_lists {
6745 struct file_lists *next;
6749 } *file_lists = NULL;
6751 /*******************************************************************
6752 Keep a linked list of all config files so we know when one has changed
6753 it's date and needs to be reloaded.
6754 ********************************************************************/
6756 static void add_to_file_list(const char *fname, const char *subfname)
6758 struct file_lists *f = file_lists;
6761 if (f->name && !strcmp(f->name, fname))
6767 f = SMB_MALLOC_P(struct file_lists);
6770 f->next = file_lists;
6771 f->name = SMB_STRDUP(fname);
6776 f->subfname = SMB_STRDUP(subfname);
6783 f->modtime = file_modtime(subfname);
6785 time_t t = file_modtime(subfname);
6793 * Free the file lists
6795 static void free_file_list(void)
6797 struct file_lists *f;
6798 struct file_lists *next;
6803 SAFE_FREE( f->name );
6804 SAFE_FREE( f->subfname );
6813 * Utility function for outsiders to check if we're running on registry.
6815 bool lp_config_backend_is_registry(void)
6817 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
6821 * Utility function to check if the config backend is FILE.
6823 bool lp_config_backend_is_file(void)
6825 return (lp_config_backend() == CONFIG_BACKEND_FILE);
6828 /*******************************************************************
6829 Check if a config file has changed date.
6830 ********************************************************************/
6832 bool lp_file_list_changed(void)
6834 struct file_lists *f = file_lists;
6836 DEBUG(6, ("lp_file_list_changed()\n"));
6841 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
6842 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6844 if (conf_ctx == NULL) {
6847 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
6850 DEBUGADD(6, ("registry config changed\n"));
6855 n2 = talloc_sub_basic(talloc_tos(),
6856 get_current_username(),
6857 current_user_info.domain,
6862 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
6863 f->name, n2, ctime(&f->modtime)));
6865 mod_time = file_modtime(n2);
6868 ((f->modtime != mod_time) ||
6869 (f->subfname == NULL) ||
6870 (strcmp(n2, f->subfname) != 0)))
6873 ("file %s modified: %s\n", n2,
6875 f->modtime = mod_time;
6876 SAFE_FREE(f->subfname);
6877 f->subfname = SMB_STRDUP(n2);
6890 * Initialize iconv conversion descriptors.
6892 * This is called the first time it is needed, and also called again
6893 * every time the configuration is reloaded, because the charset or
6894 * codepage might have changed.
6896 static void init_iconv(void)
6898 global_iconv_handle = smb_iconv_handle_reinit(NULL, lp_dos_charset(),
6900 true, global_iconv_handle);
6903 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6905 if (strcmp(*ptr, pszParmValue) != 0) {
6906 string_set(ptr, pszParmValue);
6912 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6914 bool is_utf8 = false;
6915 size_t len = strlen(pszParmValue);
6917 if (len == 4 || len == 5) {
6918 /* Don't use StrCaseCmp here as we don't want to
6919 initialize iconv. */
6920 if ((toupper_m(pszParmValue[0]) == 'U') &&
6921 (toupper_m(pszParmValue[1]) == 'T') &&
6922 (toupper_m(pszParmValue[2]) == 'F')) {
6924 if (pszParmValue[3] == '8') {
6928 if (pszParmValue[3] == '-' &&
6929 pszParmValue[4] == '8') {
6936 if (strcmp(*ptr, pszParmValue) != 0) {
6938 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
6939 "be UTF8, using (default value) %s instead.\n",
6940 DEFAULT_DOS_CHARSET));
6941 pszParmValue = DEFAULT_DOS_CHARSET;
6943 string_set(ptr, pszParmValue);
6949 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6952 char *realm = strupper_talloc(talloc_tos(), pszParmValue);
6953 char *dnsdomain = strlower_talloc(talloc_tos(), pszParmValue);
6955 ret &= string_set(&Globals.szRealm, pszParmValue);
6956 ret &= string_set(&Globals.szRealmUpper, realm);
6957 ret &= string_set(&Globals.szDnsDomain, dnsdomain);
6959 TALLOC_FREE(dnsdomain);
6964 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6966 TALLOC_FREE(Globals.szNetbiosAliases);
6967 Globals.szNetbiosAliases = (const char **)str_list_make_v3(NULL, pszParmValue, NULL);
6968 return set_netbios_aliases(Globals.szNetbiosAliases);
6971 /***************************************************************************
6972 Handle the include operation.
6973 ***************************************************************************/
6974 static bool bAllowIncludeRegistry = true;
6976 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6980 if (include_depth >= MAX_INCLUDE_DEPTH) {
6981 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
6986 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
6987 if (!bAllowIncludeRegistry) {
6990 if (bInGlobalSection) {
6993 ret = process_registry_globals();
6997 DEBUG(1, ("\"include = registry\" only effective "
6998 "in %s section\n", GLOBAL_NAME));
7003 fname = talloc_sub_basic(talloc_tos(), get_current_username(),
7004 current_user_info.domain,
7007 add_to_file_list(pszParmValue, fname);
7009 string_set(ptr, fname);
7011 if (file_exist(fname)) {
7014 ret = pm_process(fname, do_section, do_parameter, NULL);
7020 DEBUG(2, ("Can't find include file %s\n", fname));
7025 /***************************************************************************
7026 Handle the interpretation of the copy parameter.
7027 ***************************************************************************/
7029 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7033 struct loadparm_service serviceTemp;
7035 string_set(ptr, pszParmValue);
7037 init_service(&serviceTemp);
7041 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7043 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7044 if (iTemp == iServiceIndex) {
7045 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7047 copy_service(ServicePtrs[iServiceIndex],
7049 ServicePtrs[iServiceIndex]->copymap);
7053 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7057 free_service(&serviceTemp);
7061 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7063 Globals.ldap_debug_level = lp_int(pszParmValue);
7064 init_ldap_debugging();
7068 /***************************************************************************
7069 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7074 idmap uid = 1000-1999
7077 We only do simple parsing checks here. The strings are parsed into useful
7078 structures in the idmap daemon code.
7080 ***************************************************************************/
7082 /* Some lp_ routines to return idmap [ug]id information */
7084 static uid_t idmap_uid_low, idmap_uid_high;
7085 static gid_t idmap_gid_low, idmap_gid_high;
7087 bool lp_idmap_uid(uid_t *low, uid_t *high)
7089 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7093 *low = idmap_uid_low;
7096 *high = idmap_uid_high;
7101 bool lp_idmap_gid(gid_t *low, gid_t *high)
7103 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7107 *low = idmap_gid_low;
7110 *high = idmap_gid_high;
7115 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7117 lp_do_parameter(snum, "idmap config * : backend", pszParmValue);
7122 /* Do some simple checks on "idmap [ug]id" parameter values */
7124 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7126 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7131 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7133 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7138 /***************************************************************************
7139 Handle the DEBUG level list.
7140 ***************************************************************************/
7142 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValueIn, char **ptr )
7144 string_set(ptr, pszParmValueIn);
7145 return debug_parse_levels(pszParmValueIn);
7148 /***************************************************************************
7149 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7150 ***************************************************************************/
7152 static const char *append_ldap_suffix( const char *str )
7154 const char *suffix_string;
7157 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7158 Globals.szLdapSuffix );
7159 if ( !suffix_string ) {
7160 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7164 return suffix_string;
7167 const char *lp_ldap_machine_suffix(void)
7169 if (Globals.szLdapMachineSuffix[0])
7170 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7172 return lp_string(Globals.szLdapSuffix);
7175 const char *lp_ldap_user_suffix(void)
7177 if (Globals.szLdapUserSuffix[0])
7178 return append_ldap_suffix(Globals.szLdapUserSuffix);
7180 return lp_string(Globals.szLdapSuffix);
7183 const char *lp_ldap_group_suffix(void)
7185 if (Globals.szLdapGroupSuffix[0])
7186 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7188 return lp_string(Globals.szLdapSuffix);
7191 const char *lp_ldap_idmap_suffix(void)
7193 if (Globals.szLdapIdmapSuffix[0])
7194 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7196 return lp_string(Globals.szLdapSuffix);
7199 /****************************************************************************
7200 set the value for a P_ENUM
7201 ***************************************************************************/
7203 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7208 for (i = 0; parm->enum_list[i].name; i++) {
7209 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7210 *ptr = parm->enum_list[i].value;
7214 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7215 pszParmValue, parm->label));
7218 /***************************************************************************
7219 ***************************************************************************/
7221 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7223 static int parm_num = -1;
7224 struct loadparm_service *s;
7226 if ( parm_num == -1 )
7227 parm_num = map_parameter( "printing" );
7229 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7234 s = ServicePtrs[snum];
7236 init_printer_values( s );
7242 /***************************************************************************
7243 Initialise a copymap.
7244 ***************************************************************************/
7246 static void init_copymap(struct loadparm_service *pservice)
7250 TALLOC_FREE(pservice->copymap);
7252 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
7253 if (!pservice->copymap)
7255 ("Couldn't allocate copymap!! (size %d)\n",
7256 (int)NUMPARAMETERS));
7258 for (i = 0; i < NUMPARAMETERS; i++)
7259 bitmap_set(pservice->copymap, i);
7263 return the parameter pointer for a parameter
7265 void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm)
7267 if (service == NULL) {
7268 if (parm->p_class == P_LOCAL)
7269 return (void *)(((char *)&sDefault)+parm->offset);
7270 else if (parm->p_class == P_GLOBAL)
7271 return (void *)(((char *)&Globals)+parm->offset);
7274 return (void *)(((char *)service) + parm->offset);
7278 /***************************************************************************
7279 Return the local pointer to a parameter given the service number and parameter
7280 ***************************************************************************/
7282 void *lp_local_ptr_by_snum(int snum, struct parm_struct *parm)
7284 return lp_parm_ptr(ServicePtrs[snum], parm);
7287 /***************************************************************************
7288 Process a parameter for a particular service number. If snum < 0
7289 then assume we are in the globals.
7290 ***************************************************************************/
7292 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7295 void *parm_ptr = NULL; /* where we are going to store the result */
7296 struct parmlist_entry **opt_list;
7298 parmnum = map_parameter(pszParmName);
7301 if (strchr(pszParmName, ':') == NULL) {
7302 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7308 * We've got a parametric option
7311 opt_list = (snum < 0)
7312 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7313 set_param_opt(opt_list, pszParmName, pszParmValue, 0);
7318 /* if it's already been set by the command line, then we don't
7320 if (parm_table[parmnum].flags & FLAG_CMDLINE) {
7324 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7325 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7329 /* we might point at a service, the default service or a global */
7331 parm_ptr = lp_parm_ptr(NULL, &parm_table[parmnum]);
7333 if (parm_table[parmnum].p_class == P_GLOBAL) {
7335 ("Global parameter %s found in service section!\n",
7339 parm_ptr = lp_local_ptr_by_snum(snum, &parm_table[parmnum]);
7343 if (!ServicePtrs[snum]->copymap)
7344 init_copymap(ServicePtrs[snum]);
7346 /* this handles the aliases - set the copymap for other entries with
7347 the same data pointer */
7348 for (i = 0; parm_table[i].label; i++) {
7349 if ((parm_table[i].offset == parm_table[parmnum].offset)
7350 && (parm_table[i].p_class == parm_table[parmnum].p_class)) {
7351 bitmap_clear(ServicePtrs[snum]->copymap, i);
7356 /* if it is a special case then go ahead */
7357 if (parm_table[parmnum].special) {
7358 return parm_table[parmnum].special(NULL, snum, pszParmValue,
7362 /* now switch on the type of variable it is */
7363 switch (parm_table[parmnum].type)
7366 *(bool *)parm_ptr = lp_bool(pszParmValue);
7370 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7374 *(int *)parm_ptr = lp_int(pszParmValue);
7378 *(char *)parm_ptr = *pszParmValue;
7382 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7384 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7391 if (conv_str_size_error(pszParmValue, &val)) {
7392 if (val <= INT_MAX) {
7393 *(int *)parm_ptr = (int)val;
7398 DEBUG(0,("lp_do_parameter(%s): value is not "
7399 "a valid size specifier!\n", pszParmValue));
7405 TALLOC_FREE(*((char ***)parm_ptr));
7406 *(char ***)parm_ptr = str_list_make_v3(
7407 NULL, pszParmValue, NULL);
7411 string_set((char **)parm_ptr, pszParmValue);
7416 char *upper_string = strupper_talloc(talloc_tos(),
7418 string_set((char **)parm_ptr, upper_string);
7419 TALLOC_FREE(upper_string);
7423 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7432 /***************************************************************************
7433 set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
7434 FLAG_CMDLINE won't be overridden by loads from smb.conf.
7435 ***************************************************************************/
7437 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
7440 parmnum = map_parameter(pszParmName);
7442 parm_table[parmnum].flags &= ~FLAG_CMDLINE;
7443 if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
7446 parm_table[parmnum].flags |= FLAG_CMDLINE;
7448 /* we have to also set FLAG_CMDLINE on aliases. Aliases must
7449 * be grouped in the table, so we don't have to search the
7452 i>=0 && parm_table[i].offset == parm_table[parmnum].offset
7453 && parm_table[i].p_class == parm_table[parmnum].p_class;
7455 parm_table[i].flags |= FLAG_CMDLINE;
7457 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset
7458 && parm_table[i].p_class == parm_table[parmnum].p_class;i++) {
7459 parm_table[i].flags |= FLAG_CMDLINE;
7463 store_lp_set_cmdline(pszParmName, pszParmValue);
7468 /* it might be parametric */
7469 if (strchr(pszParmName, ':') != NULL) {
7470 set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
7472 store_lp_set_cmdline(pszParmName, pszParmValue);
7477 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
7481 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
7483 return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
7486 /***************************************************************************
7487 Process a parameter.
7488 ***************************************************************************/
7490 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7493 if (!bInGlobalSection && bGlobalOnly)
7496 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7498 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7499 pszParmName, pszParmValue));
7503 set a option from the commandline in 'a=b' format. Use to support --option
7505 bool lp_set_option(const char *option)
7510 s = talloc_strdup(NULL, option);
7523 /* skip white spaces after the = sign */
7526 } while (*p == ' ');
7528 ret = lp_set_cmdline(s, p);
7533 /**************************************************************************
7534 Print a parameter of the specified type.
7535 ***************************************************************************/
7537 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7539 /* For the seperation of lists values that we print below */
7540 const char *list_sep = ", ";
7545 for (i = 0; p->enum_list[i].name; i++) {
7546 if (*(int *)ptr == p->enum_list[i].value) {
7548 p->enum_list[i].name);
7555 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7559 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7564 fprintf(f, "%d", *(int *)ptr);
7568 fprintf(f, "%c", *(char *)ptr);
7572 int val = *(int *)ptr;
7576 fprintf(f, "0%o", val);
7585 if ((char ***)ptr && *(char ***)ptr) {
7586 char **list = *(char ***)ptr;
7587 for (; *list; list++) {
7588 /* surround strings with whitespace in double quotes */
7589 if (*(list+1) == NULL) {
7590 /* last item, no extra separator */
7593 if ( strchr_m( *list, ' ' ) ) {
7594 fprintf(f, "\"%s\"%s", *list, list_sep);
7596 fprintf(f, "%s%s", *list, list_sep);
7604 if (*(char **)ptr) {
7605 fprintf(f, "%s", *(char **)ptr);
7613 /***************************************************************************
7614 Check if two parameters are equal.
7615 ***************************************************************************/
7617 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7622 return (*((bool *)ptr1) == *((bool *)ptr2));
7628 return (*((int *)ptr1) == *((int *)ptr2));
7631 return (*((char *)ptr1) == *((char *)ptr2));
7635 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7640 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7645 return (p1 == p2 || strequal(p1, p2));
7653 /***************************************************************************
7654 Initialize any local varients in the sDefault table.
7655 ***************************************************************************/
7657 void init_locals(void)
7662 /***************************************************************************
7663 Process a new section (service). At this stage all sections are services.
7664 Later we'll have special sections that permit server parameters to be set.
7665 Returns true on success, false on failure.
7666 ***************************************************************************/
7668 static bool do_section(const char *pszSectionName, void *userdata)
7671 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7672 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7675 /* if we were in a global section then do the local inits */
7676 if (bInGlobalSection && !isglobal)
7679 /* if we've just struck a global section, note the fact. */
7680 bInGlobalSection = isglobal;
7682 /* check for multiple global sections */
7683 if (bInGlobalSection) {
7684 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7688 if (!bInGlobalSection && bGlobalOnly)
7691 /* if we have a current service, tidy it up before moving on */
7694 if (iServiceIndex >= 0)
7695 bRetval = service_ok(iServiceIndex);
7697 /* if all is still well, move to the next record in the services array */
7699 /* We put this here to avoid an odd message order if messages are */
7700 /* issued by the post-processing of a previous section. */
7701 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7703 iServiceIndex = add_a_service(&sDefault, pszSectionName);
7704 if (iServiceIndex < 0) {
7705 DEBUG(0, ("Failed to add a new service\n"));
7708 /* Clean all parametric options for service */
7709 /* They will be added during parsing again */
7710 free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
7717 /***************************************************************************
7718 Determine if a partcular base parameter is currentl set to the default value.
7719 ***************************************************************************/
7721 static bool is_default(int i)
7723 if (!defaults_saved)
7725 switch (parm_table[i].type) {
7728 return str_list_equal((const char **)parm_table[i].def.lvalue,
7729 *(const char ***)lp_parm_ptr(NULL,
7733 return strequal(parm_table[i].def.svalue,
7734 *(char **)lp_parm_ptr(NULL,
7738 return parm_table[i].def.bvalue ==
7739 *(bool *)lp_parm_ptr(NULL,
7742 return parm_table[i].def.cvalue ==
7743 *(char *)lp_parm_ptr(NULL,
7749 return parm_table[i].def.ivalue ==
7750 *(int *)lp_parm_ptr(NULL,
7758 /***************************************************************************
7759 Display the contents of the global structure.
7760 ***************************************************************************/
7762 static void dump_globals(FILE *f)
7765 struct parmlist_entry *data;
7767 fprintf(f, "[global]\n");
7769 for (i = 0; parm_table[i].label; i++)
7770 if (parm_table[i].p_class == P_GLOBAL &&
7771 !(parm_table[i].flags & FLAG_META) &&
7772 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
7773 if (defaults_saved && is_default(i))
7775 fprintf(f, "\t%s = ", parm_table[i].label);
7776 print_parameter(&parm_table[i], lp_parm_ptr(NULL,
7781 if (Globals.param_opt != NULL) {
7782 data = Globals.param_opt;
7784 fprintf(f, "\t%s = %s\n", data->key, data->value);
7791 /***************************************************************************
7792 Return true if a local parameter is currently set to the global default.
7793 ***************************************************************************/
7795 bool lp_is_default(int snum, struct parm_struct *parm)
7797 return equal_parameter(parm->type,
7798 lp_parm_ptr(ServicePtrs[snum], parm),
7799 lp_parm_ptr(NULL, parm));
7802 /***************************************************************************
7803 Display the contents of a single services record.
7804 ***************************************************************************/
7806 static void dump_a_service(struct loadparm_service *pService, FILE * f)
7809 struct parmlist_entry *data;
7811 if (pService != &sDefault)
7812 fprintf(f, "[%s]\n", pService->szService);
7814 for (i = 0; parm_table[i].label; i++) {
7816 if (parm_table[i].p_class == P_LOCAL &&
7817 !(parm_table[i].flags & FLAG_META) &&
7818 (*parm_table[i].label != '-') &&
7819 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7821 if (pService == &sDefault) {
7822 if (defaults_saved && is_default(i))
7825 if (equal_parameter(parm_table[i].type,
7826 lp_parm_ptr(pService, &parm_table[i]),
7827 lp_parm_ptr(NULL, &parm_table[i])))
7831 fprintf(f, "\t%s = ", parm_table[i].label);
7832 print_parameter(&parm_table[i],
7833 lp_parm_ptr(pService, &parm_table[i]),
7839 if (pService->param_opt != NULL) {
7840 data = pService->param_opt;
7842 fprintf(f, "\t%s = %s\n", data->key, data->value);
7848 /***************************************************************************
7849 Display the contents of a parameter of a single services record.
7850 ***************************************************************************/
7852 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7855 bool result = false;
7858 fstring local_parm_name;
7860 const char *parm_opt_value;
7862 /* check for parametrical option */
7863 fstrcpy( local_parm_name, parm_name);
7864 parm_opt = strchr( local_parm_name, ':');
7869 if (strlen(parm_opt)) {
7870 parm_opt_value = lp_parm_const_string( snum,
7871 local_parm_name, parm_opt, NULL);
7872 if (parm_opt_value) {
7873 printf( "%s\n", parm_opt_value);
7880 /* check for a key and print the value */
7887 for (i = 0; parm_table[i].label; i++) {
7888 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7889 !(parm_table[i].flags & FLAG_META) &&
7890 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7891 (*parm_table[i].label != '-') &&
7892 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7897 ptr = lp_parm_ptr(NULL,
7900 ptr = lp_parm_ptr(ServicePtrs[snum],
7904 print_parameter(&parm_table[i],
7915 /***************************************************************************
7916 Return info about the requested parameter (given as a string).
7917 Return NULL when the string is not a valid parameter name.
7918 ***************************************************************************/
7920 struct parm_struct *lp_get_parameter(const char *param_name)
7922 int num = map_parameter(param_name);
7928 return &parm_table[num];
7931 /***************************************************************************
7932 Return info about the next parameter in a service.
7933 snum==GLOBAL_SECTION_SNUM gives the globals.
7934 Return NULL when out of parameters.
7935 ***************************************************************************/
7937 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
7940 /* do the globals */
7941 for (; parm_table[*i].label; (*i)++) {
7942 if (parm_table[*i].p_class == P_SEPARATOR)
7943 return &parm_table[(*i)++];
7945 if ((*parm_table[*i].label == '-'))
7949 && (parm_table[*i].offset ==
7950 parm_table[(*i) - 1].offset)
7951 && (parm_table[*i].p_class ==
7952 parm_table[(*i) - 1].p_class))
7955 if (is_default(*i) && !allparameters)
7958 return &parm_table[(*i)++];
7961 struct loadparm_service *pService = ServicePtrs[snum];
7963 for (; parm_table[*i].label; (*i)++) {
7964 if (parm_table[*i].p_class == P_SEPARATOR)
7965 return &parm_table[(*i)++];
7967 if (parm_table[*i].p_class == P_LOCAL &&
7968 (*parm_table[*i].label != '-') &&
7970 (parm_table[*i].offset !=
7971 parm_table[(*i) - 1].offset)))
7973 if (allparameters ||
7974 !equal_parameter(parm_table[*i].type,
7975 lp_parm_ptr(pService,
7980 return &parm_table[(*i)++];
7991 /***************************************************************************
7992 Display the contents of a single copy structure.
7993 ***************************************************************************/
7994 static void dump_copy_map(bool *pcopymap)
8000 printf("\n\tNon-Copied parameters:\n");
8002 for (i = 0; parm_table[i].label; i++)
8003 if (parm_table[i].p_class == P_LOCAL &&
8004 parm_table[i].ptr && !pcopymap[i] &&
8005 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8007 printf("\t\t%s\n", parm_table[i].label);
8012 /***************************************************************************
8013 Return TRUE if the passed service number is within range.
8014 ***************************************************************************/
8016 bool lp_snum_ok(int iService)
8018 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8021 /***************************************************************************
8022 Auto-load some home services.
8023 ***************************************************************************/
8025 static void lp_add_auto_services(char *str)
8035 s = SMB_STRDUP(str);
8039 homes = lp_servicenumber(HOMES_NAME);
8041 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8042 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8045 if (lp_servicenumber(p) >= 0)
8048 home = get_user_home_dir(talloc_tos(), p);
8050 if (home && home[0] && homes >= 0)
8051 lp_add_home(p, homes, p, home);
8058 /***************************************************************************
8059 Auto-load one printer.
8060 ***************************************************************************/
8062 void lp_add_one_printer(const char *name, const char *comment,
8063 const char *location, void *pdata)
8065 int printers = lp_servicenumber(PRINTERS_NAME);
8068 if (lp_servicenumber(name) < 0) {
8069 lp_add_printer(name, printers);
8070 if ((i = lp_servicenumber(name)) >= 0) {
8071 string_set(&ServicePtrs[i]->comment, comment);
8072 ServicePtrs[i]->autoloaded = true;
8077 /***************************************************************************
8078 Have we loaded a services file yet?
8079 ***************************************************************************/
8081 bool lp_loaded(void)
8086 /***************************************************************************
8087 Unload unused services.
8088 ***************************************************************************/
8090 void lp_killunused(struct smbd_server_connection *sconn,
8091 bool (*snumused) (struct smbd_server_connection *, int))
8094 for (i = 0; i < iNumServices; i++) {
8098 /* don't kill autoloaded or usershare services */
8099 if ( ServicePtrs[i]->autoloaded ||
8100 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8104 if (!snumused || !snumused(sconn, i)) {
8105 free_service_byindex(i);
8111 * Kill all except autoloaded and usershare services - convenience wrapper
8113 void lp_kill_all_services(void)
8115 lp_killunused(NULL, NULL);
8118 /***************************************************************************
8120 ***************************************************************************/
8122 void lp_killservice(int iServiceIn)
8124 if (VALID(iServiceIn)) {
8125 free_service_byindex(iServiceIn);
8129 /***************************************************************************
8130 Save the curent values of all global and sDefault parameters into the
8131 defaults union. This allows swat and testparm to show only the
8132 changed (ie. non-default) parameters.
8133 ***************************************************************************/
8135 static void lp_save_defaults(void)
8138 for (i = 0; parm_table[i].label; i++) {
8139 if (i > 0 && parm_table[i].offset == parm_table[i - 1].offset
8140 && parm_table[i].p_class == parm_table[i - 1].p_class)
8142 switch (parm_table[i].type) {
8145 parm_table[i].def.lvalue = str_list_copy(
8146 NULL, *(const char ***)lp_parm_ptr(NULL, &parm_table[i]));
8150 parm_table[i].def.svalue = SMB_STRDUP(*(char **)lp_parm_ptr(NULL, &parm_table[i]));
8154 parm_table[i].def.bvalue =
8155 *(bool *)lp_parm_ptr(NULL, &parm_table[i]);
8158 parm_table[i].def.cvalue =
8159 *(char *)lp_parm_ptr(NULL, &parm_table[i]);
8165 parm_table[i].def.ivalue =
8166 *(int *)lp_parm_ptr(NULL, &parm_table[i]);
8172 defaults_saved = true;
8175 /***********************************************************
8176 If we should send plaintext/LANMAN passwords in the clinet
8177 ************************************************************/
8179 static void set_allowed_client_auth(void)
8181 if (Globals.bClientNTLMv2Auth) {
8182 Globals.bClientLanManAuth = false;
8184 if (!Globals.bClientLanManAuth) {
8185 Globals.bClientPlaintextAuth = false;
8189 /***************************************************************************
8191 The following code allows smbd to read a user defined share file.
8192 Yes, this is my intent. Yes, I'm comfortable with that...
8194 THE FOLLOWING IS SECURITY CRITICAL CODE.
8196 It washes your clothes, it cleans your house, it guards you while you sleep...
8197 Do not f%^k with it....
8198 ***************************************************************************/
8200 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8202 /***************************************************************************
8203 Check allowed stat state of a usershare file.
8204 Ensure we print out who is dicking with us so the admin can
8205 get their sorry ass fired.
8206 ***************************************************************************/
8208 static bool check_usershare_stat(const char *fname,
8209 const SMB_STRUCT_STAT *psbuf)
8211 if (!S_ISREG(psbuf->st_ex_mode)) {
8212 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8213 "not a regular file\n",
8214 fname, (unsigned int)psbuf->st_ex_uid ));
8218 /* Ensure this doesn't have the other write bit set. */
8219 if (psbuf->st_ex_mode & S_IWOTH) {
8220 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8221 "public write. Refusing to allow as a usershare file.\n",
8222 fname, (unsigned int)psbuf->st_ex_uid ));
8226 /* Should be 10k or less. */
8227 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8228 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8229 "too large (%u) to be a user share file.\n",
8230 fname, (unsigned int)psbuf->st_ex_uid,
8231 (unsigned int)psbuf->st_ex_size ));
8238 /***************************************************************************
8239 Parse the contents of a usershare file.
8240 ***************************************************************************/
8242 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8243 SMB_STRUCT_STAT *psbuf,
8244 const char *servicename,
8248 char **pp_sharepath,
8250 char **pp_cp_servicename,
8251 struct security_descriptor **ppsd,
8254 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8255 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8258 SMB_STRUCT_STAT sbuf;
8259 char *sharepath = NULL;
8260 char *comment = NULL;
8262 *pp_sharepath = NULL;
8265 *pallow_guest = false;
8268 return USERSHARE_MALFORMED_FILE;
8271 if (strcmp(lines[0], "#VERSION 1") == 0) {
8273 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8276 return USERSHARE_MALFORMED_FILE;
8279 return USERSHARE_BAD_VERSION;
8282 if (strncmp(lines[1], "path=", 5) != 0) {
8283 return USERSHARE_MALFORMED_PATH;
8286 sharepath = talloc_strdup(ctx, &lines[1][5]);
8288 return USERSHARE_POSIX_ERR;
8290 trim_string(sharepath, " ", " ");
8292 if (strncmp(lines[2], "comment=", 8) != 0) {
8293 return USERSHARE_MALFORMED_COMMENT_DEF;
8296 comment = talloc_strdup(ctx, &lines[2][8]);
8298 return USERSHARE_POSIX_ERR;
8300 trim_string(comment, " ", " ");
8301 trim_char(comment, '"', '"');
8303 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8304 return USERSHARE_MALFORMED_ACL_DEF;
8307 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8308 return USERSHARE_ACL_ERR;
8312 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8313 return USERSHARE_MALFORMED_ACL_DEF;
8315 if (lines[4][9] == 'y') {
8316 *pallow_guest = true;
8319 /* Backwards compatible extension to file version #2. */
8321 if (strncmp(lines[5], "sharename=", 10) != 0) {
8322 return USERSHARE_MALFORMED_SHARENAME_DEF;
8324 if (!strequal(&lines[5][10], servicename)) {
8325 return USERSHARE_BAD_SHARENAME;
8327 *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
8328 if (!*pp_cp_servicename) {
8329 return USERSHARE_POSIX_ERR;
8334 if (*pp_cp_servicename == NULL) {
8335 *pp_cp_servicename = talloc_strdup(ctx, servicename);
8336 if (!*pp_cp_servicename) {
8337 return USERSHARE_POSIX_ERR;
8341 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8342 /* Path didn't change, no checks needed. */
8343 *pp_sharepath = sharepath;
8344 *pp_comment = comment;
8345 return USERSHARE_OK;
8348 /* The path *must* be absolute. */
8349 if (sharepath[0] != '/') {
8350 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8351 servicename, sharepath));
8352 return USERSHARE_PATH_NOT_ABSOLUTE;
8355 /* If there is a usershare prefix deny list ensure one of these paths
8356 doesn't match the start of the user given path. */
8357 if (prefixdenylist) {
8359 for ( i=0; prefixdenylist[i]; i++ ) {
8360 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8361 servicename, i, prefixdenylist[i], sharepath ));
8362 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8363 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8364 "usershare prefix deny list entries.\n",
8365 servicename, sharepath));
8366 return USERSHARE_PATH_IS_DENIED;
8371 /* If there is a usershare prefix allow list ensure one of these paths
8372 does match the start of the user given path. */
8374 if (prefixallowlist) {
8376 for ( i=0; prefixallowlist[i]; i++ ) {
8377 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8378 servicename, i, prefixallowlist[i], sharepath ));
8379 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8383 if (prefixallowlist[i] == NULL) {
8384 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8385 "usershare prefix allow list entries.\n",
8386 servicename, sharepath));
8387 return USERSHARE_PATH_NOT_ALLOWED;
8391 /* Ensure this is pointing to a directory. */
8392 dp = sys_opendir(sharepath);
8395 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8396 servicename, sharepath));
8397 return USERSHARE_PATH_NOT_DIRECTORY;
8400 /* Ensure the owner of the usershare file has permission to share
8403 if (sys_stat(sharepath, &sbuf, false) == -1) {
8404 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8405 servicename, sharepath, strerror(errno) ));
8407 return USERSHARE_POSIX_ERR;
8412 if (!S_ISDIR(sbuf.st_ex_mode)) {
8413 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8414 servicename, sharepath ));
8415 return USERSHARE_PATH_NOT_DIRECTORY;
8418 /* Check if sharing is restricted to owner-only. */
8419 /* psbuf is the stat of the usershare definition file,
8420 sbuf is the stat of the target directory to be shared. */
8422 if (lp_usershare_owner_only()) {
8423 /* root can share anything. */
8424 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8425 return USERSHARE_PATH_NOT_ALLOWED;
8429 *pp_sharepath = sharepath;
8430 *pp_comment = comment;
8431 return USERSHARE_OK;
8434 /***************************************************************************
8435 Deal with a usershare file.
8438 -1 - Bad name, invalid contents.
8439 - service name already existed and not a usershare, problem
8440 with permissions to share directory etc.
8441 ***************************************************************************/
8443 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8445 SMB_STRUCT_STAT sbuf;
8446 SMB_STRUCT_STAT lsbuf;
8448 char *sharepath = NULL;
8449 char *comment = NULL;
8450 char *cp_service_name = NULL;
8451 char **lines = NULL;
8455 TALLOC_CTX *ctx = talloc_stackframe();
8456 struct security_descriptor *psd = NULL;
8457 bool guest_ok = false;
8458 char *canon_name = NULL;
8459 bool added_service = false;
8462 /* Ensure share name doesn't contain invalid characters. */
8463 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8464 DEBUG(0,("process_usershare_file: share name %s contains "
8465 "invalid characters (any of %s)\n",
8466 file_name, INVALID_SHARENAME_CHARS ));
8470 canon_name = canonicalize_servicename(ctx, file_name);
8475 fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
8480 /* Minimize the race condition by doing an lstat before we
8481 open and fstat. Ensure this isn't a symlink link. */
8483 if (sys_lstat(fname, &lsbuf, false) != 0) {
8484 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8485 fname, strerror(errno) ));
8489 /* This must be a regular file, not a symlink, directory or
8490 other strange filetype. */
8491 if (!check_usershare_stat(fname, &lsbuf)) {
8499 status = dbwrap_fetch_bystring(ServiceHash, canon_name,
8504 if (NT_STATUS_IS_OK(status) &&
8505 (data.dptr != NULL) &&
8506 (data.dsize == sizeof(iService)))
8508 iService = *(int *)data.dptr;
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 = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8527 fd = sys_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;
8739 SMB_STRUCT_DIRENT *de;
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 = sys_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;
8811 (de = sys_readdir(dp));
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_SHARE) {
9045 DEBUG(1, ("WARNING: The security=share option is deprecated\n"));
9046 } else if (lp_security() == SEC_SERVER) {
9047 DEBUG(1, ("WARNING: The security=server option is deprecated\n"));
9050 if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) {
9051 DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
9052 lp_passwordserver()));
9057 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9058 /* if bWINSsupport is true and we are in the client */
9059 if (lp_is_in_client() && Globals.bWINSsupport) {
9060 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9065 fault_configure(smb_panic_s3);
9067 bAllowIncludeRegistry = true;
9072 bool lp_load(const char *pszFname,
9076 bool initialize_globals)
9078 return lp_load_ex(pszFname,
9083 true, /* allow_include_registry */
9084 false); /* load_all_shares*/
9087 bool lp_load_initial_only(const char *pszFname)
9089 return lp_load_ex(pszFname,
9090 true, /* global only */
9091 false, /* save_defaults */
9092 false, /* add_ipc */
9093 true, /* initialize_globals */
9094 false, /* allow_include_registry */
9095 false); /* load_all_shares*/
9099 * most common lp_load wrapper, loading only the globals
9101 bool lp_load_global(const char *file_name)
9103 return lp_load_ex(file_name,
9104 true, /* global_only */
9105 false, /* save_defaults */
9106 false, /* add_ipc */
9107 true, /* initialize_globals */
9108 true, /* allow_include_registry */
9109 false); /* load_all_shares*/
9113 * lp_load wrapper, especially for clients
9115 bool lp_load_client(const char *file_name)
9117 lp_set_in_client(true);
9119 return lp_load_global(file_name);
9123 * lp_load wrapper, loading only globals, but intended
9124 * for subsequent calls, not reinitializing the globals
9127 bool lp_load_global_no_reinit(const char *file_name)
9129 return lp_load_ex(file_name,
9130 true, /* global_only */
9131 false, /* save_defaults */
9132 false, /* add_ipc */
9133 false, /* initialize_globals */
9134 true, /* allow_include_registry */
9135 false); /* load_all_shares*/
9139 * lp_load wrapper, especially for clients, no reinitialization
9141 bool lp_load_client_no_reinit(const char *file_name)
9143 lp_set_in_client(true);
9145 return lp_load_global_no_reinit(file_name);
9148 bool lp_load_with_registry_shares(const char *pszFname,
9152 bool initialize_globals)
9154 return lp_load_ex(pszFname,
9159 true, /* allow_include_registry */
9160 true); /* load_all_shares*/
9163 /***************************************************************************
9164 Return the max number of services.
9165 ***************************************************************************/
9167 int lp_numservices(void)
9169 return (iNumServices);
9172 /***************************************************************************
9173 Display the contents of the services array in human-readable form.
9174 ***************************************************************************/
9176 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9181 defaults_saved = false;
9185 dump_a_service(&sDefault, f);
9187 for (iService = 0; iService < maxtoprint; iService++) {
9189 lp_dump_one(f, show_defaults, iService);
9193 /***************************************************************************
9194 Display the contents of one service in human-readable form.
9195 ***************************************************************************/
9197 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9200 if (ServicePtrs[snum]->szService[0] == '\0')
9202 dump_a_service(ServicePtrs[snum], f);
9206 /***************************************************************************
9207 Return the number of the service with the given name, or -1 if it doesn't
9208 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9209 getservicebyname()! This works ONLY if all services have been loaded, and
9210 does not copy the found service.
9211 ***************************************************************************/
9213 int lp_servicenumber(const char *pszServiceName)
9216 fstring serviceName;
9218 if (!pszServiceName) {
9219 return GLOBAL_SECTION_SNUM;
9222 for (iService = iNumServices - 1; iService >= 0; iService--) {
9223 if (VALID(iService) && ServicePtrs[iService]->szService) {
9225 * The substitution here is used to support %U is
9228 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9229 standard_sub_basic(get_current_username(),
9230 current_user_info.domain,
9231 serviceName,sizeof(serviceName));
9232 if (strequal(serviceName, pszServiceName)) {
9238 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9239 struct timespec last_mod;
9241 if (!usershare_exists(iService, &last_mod)) {
9242 /* Remove the share security tdb entry for it. */
9243 delete_share_security(lp_servicename(iService));
9244 /* Remove it from the array. */
9245 free_service_byindex(iService);
9246 /* Doesn't exist anymore. */
9247 return GLOBAL_SECTION_SNUM;
9250 /* Has it been modified ? If so delete and reload. */
9251 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9253 /* Remove it from the array. */
9254 free_service_byindex(iService);
9255 /* and now reload it. */
9256 iService = load_usershare_service(pszServiceName);
9261 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9262 return GLOBAL_SECTION_SNUM;
9268 bool share_defined(const char *service_name)
9270 return (lp_servicenumber(service_name) != -1);
9273 /*******************************************************************
9274 A useful volume label function.
9275 ********************************************************************/
9277 const char *volume_label(int snum)
9280 const char *label = lp_volume(snum);
9282 label = lp_servicename(snum);
9285 /* This returns a 33 byte guarenteed null terminated string. */
9286 ret = talloc_strndup(talloc_tos(), label, 32);
9293 /*******************************************************************
9294 Get the default server type we will announce as via nmbd.
9295 ********************************************************************/
9297 int lp_default_server_announce(void)
9299 int default_server_announce = 0;
9300 default_server_announce |= SV_TYPE_WORKSTATION;
9301 default_server_announce |= SV_TYPE_SERVER;
9302 default_server_announce |= SV_TYPE_SERVER_UNIX;
9304 /* note that the flag should be set only if we have a
9305 printer service but nmbd doesn't actually load the
9306 services so we can't tell --jerry */
9308 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9310 default_server_announce |= SV_TYPE_SERVER_NT;
9311 default_server_announce |= SV_TYPE_NT;
9313 switch (lp_server_role()) {
9314 case ROLE_DOMAIN_MEMBER:
9315 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9317 case ROLE_DOMAIN_PDC:
9318 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9320 case ROLE_DOMAIN_BDC:
9321 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9323 case ROLE_STANDALONE:
9327 if (lp_time_server())
9328 default_server_announce |= SV_TYPE_TIME_SOURCE;
9330 if (lp_host_msdfs())
9331 default_server_announce |= SV_TYPE_DFS_SERVER;
9333 return default_server_announce;
9336 /***********************************************************
9337 If we are PDC then prefer us as DMB
9338 ************************************************************/
9340 bool lp_domain_master(void)
9342 if (Globals.iDomainMaster == Auto)
9343 return (lp_server_role() == ROLE_DOMAIN_PDC);
9345 return (bool)Globals.iDomainMaster;
9348 /***********************************************************
9349 If we are PDC then prefer us as DMB
9350 ************************************************************/
9352 static bool lp_domain_master_true_or_auto(void)
9354 if (Globals.iDomainMaster) /* auto or yes */
9360 /***********************************************************
9361 If we are DMB then prefer us as LMB
9362 ************************************************************/
9364 bool lp_preferred_master(void)
9366 if (Globals.iPreferredMaster == Auto)
9367 return (lp_local_master() && lp_domain_master());
9369 return (bool)Globals.iPreferredMaster;
9372 /*******************************************************************
9374 ********************************************************************/
9376 void lp_remove_service(int snum)
9378 ServicePtrs[snum]->valid = false;
9379 invalid_services[num_invalid_services++] = snum;
9382 /*******************************************************************
9384 ********************************************************************/
9386 void lp_copy_service(int snum, const char *new_name)
9388 do_section(new_name, NULL);
9390 snum = lp_servicenumber(new_name);
9392 lp_do_parameter(snum, "copy", lp_servicename(snum));
9397 /***********************************************************
9398 Set the global name resolution order (used in smbclient).
9399 ************************************************************/
9401 void lp_set_name_resolve_order(const char *new_order)
9403 string_set(&Globals.szNameResolveOrder, new_order);
9406 const char *lp_printername(int snum)
9408 const char *ret = lp__printername(snum);
9409 if (ret == NULL || (ret != NULL && *ret == '\0'))
9410 ret = lp_const_servicename(snum);
9416 /***********************************************************
9417 Allow daemons such as winbindd to fix their logfile name.
9418 ************************************************************/
9420 void lp_set_logfile(const char *name)
9422 string_set(&Globals.szLogFile, name);
9423 debug_set_logfile(name);
9426 /*******************************************************************
9427 Return the max print jobs per queue.
9428 ********************************************************************/
9430 int lp_maxprintjobs(int snum)
9432 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9433 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9434 maxjobs = PRINT_MAX_JOBID - 1;
9439 const char *lp_printcapname(void)
9441 if ((Globals.szPrintcapname != NULL) &&
9442 (Globals.szPrintcapname[0] != '\0'))
9443 return Globals.szPrintcapname;
9445 if (sDefault.iPrinting == PRINT_CUPS) {
9453 if (sDefault.iPrinting == PRINT_BSD)
9454 return "/etc/printcap";
9456 return PRINTCAP_NAME;
9459 static uint32 spoolss_state;
9461 bool lp_disable_spoolss( void )
9463 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9464 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9466 return spoolss_state == SVCCTL_STOPPED ? true : false;
9469 void lp_set_spoolss_state( uint32 state )
9471 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9473 spoolss_state = state;
9476 uint32 lp_get_spoolss_state( void )
9478 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9481 /*******************************************************************
9482 Ensure we don't use sendfile if server smb signing is active.
9483 ********************************************************************/
9485 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9487 bool sign_active = false;
9489 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9490 if (get_Protocol() < PROTOCOL_NT1) {
9493 if (signing_state) {
9494 sign_active = smb_signing_is_active(signing_state);
9496 return (lp__use_sendfile(snum) &&
9497 (get_remote_arch() != RA_WIN95) &&
9501 /*******************************************************************
9502 Turn off sendfile if we find the underlying OS doesn't support it.
9503 ********************************************************************/
9505 void set_use_sendfile(int snum, bool val)
9507 if (LP_SNUM_OK(snum))
9508 ServicePtrs[snum]->bUseSendfile = val;
9510 sDefault.bUseSendfile = val;
9513 /*******************************************************************
9514 Turn off storing DOS attributes if this share doesn't support it.
9515 ********************************************************************/
9517 void set_store_dos_attributes(int snum, bool val)
9519 if (!LP_SNUM_OK(snum))
9521 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9524 void lp_set_mangling_method(const char *new_method)
9526 string_set(&Globals.szManglingMethod, new_method);
9529 /*******************************************************************
9530 Global state for POSIX pathname processing.
9531 ********************************************************************/
9533 static bool posix_pathnames;
9535 bool lp_posix_pathnames(void)
9537 return posix_pathnames;
9540 /*******************************************************************
9541 Change everything needed to ensure POSIX pathname processing (currently
9543 ********************************************************************/
9545 void lp_set_posix_pathnames(void)
9547 posix_pathnames = true;
9550 /*******************************************************************
9551 Global state for POSIX lock processing - CIFS unix extensions.
9552 ********************************************************************/
9554 bool posix_default_lock_was_set;
9555 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9557 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9559 if (posix_default_lock_was_set) {
9560 return posix_cifsx_locktype;
9562 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9566 /*******************************************************************
9567 ********************************************************************/
9569 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9571 posix_default_lock_was_set = true;
9572 posix_cifsx_locktype = val;
9575 int lp_min_receive_file_size(void)
9577 if (Globals.iminreceivefile < 0) {
9580 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9583 /*******************************************************************
9584 If socket address is an empty character string, it is necessary to
9585 define it as "0.0.0.0".
9586 ********************************************************************/
9588 const char *lp_socket_address(void)
9590 char *sock_addr = Globals.szSocketAddress;
9592 if (sock_addr[0] == '\0'){
9593 string_set(&Globals.szSocketAddress, "0.0.0.0");
9595 return Globals.szSocketAddress;
9598 /*******************************************************************
9599 Safe wide links checks.
9600 This helper function always verify the validity of wide links,
9601 even after a configuration file reload.
9602 ********************************************************************/
9604 static bool lp_widelinks_internal(int snum)
9606 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9607 sDefault.bWidelinks);
9610 void widelinks_warning(int snum)
9612 if (lp_allow_insecure_widelinks()) {
9616 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9617 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9618 "These parameters are incompatible. "
9619 "Wide links will be disabled for this share.\n",
9620 lp_servicename(snum) ));
9624 bool lp_widelinks(int snum)
9626 /* wide links is always incompatible with unix extensions */
9627 if (lp_unix_extensions()) {
9629 * Unless we have "allow insecure widelinks"
9632 if (!lp_allow_insecure_widelinks()) {
9637 return lp_widelinks_internal(snum);
9640 bool lp_writeraw(void)
9642 if (lp_async_smb_echo_handler()) {
9645 return _lp_writeraw();
9648 bool lp_readraw(void)
9650 if (lp_async_smb_echo_handler()) {
9653 return _lp_readraw();
9656 int lp_server_role(void)
9658 return lp_find_server_role(lp__server_role(),
9661 lp_domain_master_true_or_auto());