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
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 3 of the License, or
17 (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>.
31 * This module provides suitable callback functions for the params
32 * module. It builds the internal table of service details which is
33 * then used by the rest of the server.
37 * 1) add it to the global or service structure definition
38 * 2) add it to the parm_table
39 * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
40 * 4) If it's a global then initialise it in init_globals. If a local
41 * (ie. service) parameter then initialise it in the sDefault structure
45 * The configuration file is processed sequentially for speed. It is NOT
46 * accessed randomly as happens in 'real' Windows. For this reason, there
47 * is a fair bit of sequence-dependent code here - ie., code which assumes
48 * that certain things happen before others. In particular, the code which
49 * happens at the boundary between sections is delicately poised, so be
56 #include "lib/smbconf/smbconf.h"
57 #include "lib/smbconf/smbconf_init.h"
58 #include "lib/smbconf/smbconf_reg.h"
61 #include "../librpc/gen_ndr/svcctl.h"
63 #ifdef HAVE_SYS_SYSCTL_H
64 #include <sys/sysctl.h>
67 #ifdef HAVE_HTTPCONNECTENCRYPT
68 #include <cups/http.h>
73 extern userdom_struct current_user_info;
76 #define GLOBAL_NAME "global"
80 #define PRINTERS_NAME "printers"
84 #define HOMES_NAME "homes"
87 /* the special value for the include parameter
88 * to be interpreted not as a file name but to
89 * trigger loading of the global smb.conf options
91 #ifndef INCLUDE_REGISTRY_NAME
92 #define INCLUDE_REGISTRY_NAME "registry"
95 static bool in_client = False; /* Not in the client by default */
96 static struct smbconf_csn conf_last_csn;
98 #define CONFIG_BACKEND_FILE 0
99 #define CONFIG_BACKEND_REGISTRY 1
101 static int config_backend = CONFIG_BACKEND_FILE;
103 /* some helpful bits */
104 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
105 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
107 #define USERSHARE_VALID 1
108 #define USERSHARE_PENDING_DELETE 2
110 static bool defaults_saved = False;
112 struct param_opt_struct {
113 struct param_opt_struct *prev, *next;
120 * This structure describes global (ie., server-wide) parameters.
127 char *display_charset;
128 char *szPrintcapname;
129 char *szAddPortCommand;
130 char *szEnumPortsCommand;
131 char *szAddPrinterCommand;
132 char *szDeletePrinterCommand;
133 char *szOs2DriverMap;
139 char *szDefaultService;
143 char *szServerString;
144 char *szAutoServices;
145 char *szPasswdProgram;
149 char *szSMBPasswdFile;
151 char *szPassdbBackend;
152 char **szPreloadModules;
153 char *szPasswordServer;
154 char *szSocketOptions;
156 char *szAfsUsernameMap;
157 int iAfsTokenLifetime;
158 char *szLogNtTokenCommand;
164 char **szWINSservers;
166 char *szRemoteAnnounce;
167 char *szRemoteBrowseSync;
168 char *szSocketAddress;
169 bool bNmbdBindExplicitBroadcast;
170 char *szNISHomeMapName;
171 char *szAnnounceVersion; /* This is initialised in init_globals */
174 char **szNetbiosAliases;
175 char *szNetbiosScope;
176 char *szNameResolveOrder;
178 char *szAddUserScript;
179 char *szRenameUserScript;
180 char *szDelUserScript;
181 char *szAddGroupScript;
182 char *szDelGroupScript;
183 char *szAddUserToGroupScript;
184 char *szDelUserFromGroupScript;
185 char *szSetPrimaryGroupScript;
186 char *szAddMachineScript;
187 char *szShutdownScript;
188 char *szAbortShutdownScript;
189 char *szUsernameMapScript;
190 int iUsernameMapCacheTime;
191 char *szCheckPasswordScript;
198 bool bPassdbExpandExplicit;
199 int AlgorithmicRidBase;
200 char *szTemplateHomedir;
201 char *szTemplateShell;
202 char *szWinbindSeparator;
203 bool bWinbindEnumUsers;
204 bool bWinbindEnumGroups;
205 bool bWinbindUseDefaultDomain;
206 bool bWinbindTrustedDomainsOnly;
207 bool bWinbindNestedGroups;
208 int winbind_expand_groups;
209 bool bWinbindRefreshTickets;
210 bool bWinbindOfflineLogon;
211 bool bWinbindNormalizeNames;
212 bool bWinbindRpcOnly;
213 bool bCreateKrb5Conf;
214 char *szIdmapBackend;
215 char *szIdmapAllocBackend;
216 char *szAddShareCommand;
217 char *szChangeShareCommand;
218 char *szDeleteShareCommand;
220 char *szGuestaccount;
221 char *szManglingMethod;
222 char **szServicesList;
223 char *szUsersharePath;
224 char *szUsershareTemplateShare;
225 char **szUsersharePrefixAllowList;
226 char **szUsersharePrefixDenyList;
233 int open_files_db_hash_size;
242 bool paranoid_server_security;
245 int iMaxSmbdProcesses;
246 bool bDisableSpoolss;
249 bool enhanced_browsing;
255 int announce_as; /* This is initialised in init_globals */
256 int machine_password_timeout;
258 int oplock_break_wait_time;
259 int winbind_cache_time;
260 int winbind_reconnect_delay;
261 int winbind_max_idle_children;
262 char **szWinbindNssInfo;
264 char *szLdapMachineSuffix;
265 char *szLdapUserSuffix;
266 char *szLdapIdmapSuffix;
267 char *szLdapGroupSuffix;
271 int ldap_follow_referral;
274 int ldap_debug_level;
275 int ldap_debug_threshold;
279 char *szIPrintServer;
281 char **szClusterAddresses;
284 int ctdb_locktime_warn_threshold;
285 int ldap_passwd_sync;
286 int ldap_replication_sleep;
287 int ldap_timeout; /* This is initialised in init_globals */
288 int ldap_connection_timeout;
291 bool bMsAddPrinterWizard;
296 int iPreferredMaster;
299 char **szInitLogonDelayedHosts;
301 bool bEncryptPasswords;
306 bool bObeyPamRestrictions;
308 int PrintcapCacheTime;
309 bool bLargeReadwrite;
316 bool bBindInterfacesOnly;
317 bool bPamPasswordChange;
318 bool bUnixPasswdSync;
319 bool bPasswdChatDebug;
320 int iPasswdChatTimeout;
324 bool bNTStatusSupport;
326 int iMaxStatCacheSize;
328 bool bAllowTrustedDomains;
332 bool bClientLanManAuth;
333 bool bClientNTLMv2Auth;
334 bool bClientPlaintextAuth;
335 bool bClientUseSpnego;
336 bool bDebugPrefixTimestamp;
337 bool bDebugHiresTimestamp;
341 bool bEnableCoreFiles;
344 bool bHostnameLookups;
345 bool bUnixExtensions;
346 bool bDisableNetbios;
347 char * szDedicatedKeytabFile;
349 bool bDeferSharingViolations;
350 bool bEnablePrivileges;
352 bool bUsershareOwnerOnly;
353 bool bUsershareAllowGuests;
354 bool bRegistryShares;
355 int restrict_anonymous;
356 int name_cache_timeout;
359 int client_ldap_sasl_wrapping;
360 int iUsershareMaxShares;
362 int iIdmapNegativeCacheTime;
364 bool bLogWriteableFilesOnExit;
367 struct param_opt_struct *param_opt;
368 int cups_connection_timeout;
369 char *szSMBPerfcountModule;
370 bool bMapUntrustedToDomain;
371 bool bAsyncSMBEchoHandler;
377 static struct global Globals;
380 * This structure describes a single service.
386 struct timespec usershare_last_mod;
390 char **szInvalidUsers;
398 char *szRootPostExec;
400 char *szPrintcommand;
403 char *szLppausecommand;
404 char *szLpresumecommand;
405 char *szQueuepausecommand;
406 char *szQueueresumecommand;
408 char *szPrintjobUsername;
416 char *szVetoOplockFiles;
422 char **printer_admin;
427 char *szAioWriteBehind;
431 int iMaxReportedPrintJobs;
434 int iCreate_force_mode;
436 int iSecurity_force_mode;
439 int iDir_Security_mask;
440 int iDir_Security_force_mode;
444 int iOplockContentionLimit;
449 bool bRootpreexecClose;
452 bool bShortCasePreserve;
454 bool bHideSpecialFiles;
455 bool bHideUnReadable;
456 bool bHideUnWriteableFiles;
458 bool bAccessBasedShareEnum;
463 bool bAdministrative_share;
469 bool bStoreDosAttributes;
482 bool bStrictAllocate;
485 struct bitmap *copymap;
486 bool bDeleteReadonly;
488 bool bDeleteVetoFiles;
491 bool bDosFiletimeResolution;
492 bool bFakeDirCreateTimes;
498 bool bUseClientDriver;
499 bool bDefaultDevmode;
500 bool bForcePrintername;
502 bool bForceUnknownAclUser;
505 bool bMap_acl_inherit;
508 bool bAclCheckPermissions;
509 bool bAclMapFullControl;
510 bool bAclGroupControl;
512 bool bKernelChangeNotify;
513 int iallocation_roundup_size;
517 int iDirectoryNameCacheSize;
519 struct param_opt_struct *param_opt;
521 char dummy[3]; /* for alignment */
525 /* This is a default service used to prime a services structure */
526 static struct service sDefault = {
528 False, /* not autoloaded */
529 0, /* not a usershare */
530 {0, }, /* No last mod time */
531 NULL, /* szService */
533 NULL, /* szUsername */
534 NULL, /* szInvalidUsers */
535 NULL, /* szValidUsers */
536 NULL, /* szAdminUsers */
538 NULL, /* szInclude */
539 NULL, /* szPreExec */
540 NULL, /* szPostExec */
541 NULL, /* szRootPreExec */
542 NULL, /* szRootPostExec */
543 NULL, /* szCupsOptions */
544 NULL, /* szPrintcommand */
545 NULL, /* szLpqcommand */
546 NULL, /* szLprmcommand */
547 NULL, /* szLppausecommand */
548 NULL, /* szLpresumecommand */
549 NULL, /* szQueuepausecommand */
550 NULL, /* szQueueresumecommand */
551 NULL, /* szPrintername */
552 NULL, /* szPrintjobUsername */
553 NULL, /* szDontdescend */
554 NULL, /* szHostsallow */
555 NULL, /* szHostsdeny */
556 NULL, /* szMagicScript */
557 NULL, /* szMagicOutput */
558 NULL, /* szVetoFiles */
559 NULL, /* szHideFiles */
560 NULL, /* szVetoOplockFiles */
562 NULL, /* force user */
563 NULL, /* force group */
565 NULL, /* writelist */
566 NULL, /* printer admin */
569 NULL, /* vfs objects */
570 NULL, /* szMSDfsProxy */
571 NULL, /* szAioWriteBehind */
573 0, /* iMinPrintSpace */
574 1000, /* iMaxPrintJobs */
575 0, /* iMaxReportedPrintJobs */
576 0, /* iWriteCacheSize */
577 0744, /* iCreate_mask */
578 0000, /* iCreate_force_mode */
579 0777, /* iSecurity_mask */
580 0, /* iSecurity_force_mode */
581 0755, /* iDir_mask */
582 0000, /* iDir_force_mode */
583 0777, /* iDir_Security_mask */
584 0, /* iDir_Security_force_mode */
585 0, /* iMaxConnections */
586 CASE_LOWER, /* iDefaultCase */
587 DEFAULT_PRINTING, /* iPrinting */
588 2, /* iOplockContentionLimit */
590 1024, /* iBlock_size */
591 0, /* iDfreeCacheTime */
592 False, /* bPreexecClose */
593 False, /* bRootpreexecClose */
594 Auto, /* case sensitive */
595 True, /* case preserve */
596 True, /* short case preserve */
597 True, /* bHideDotFiles */
598 False, /* bHideSpecialFiles */
599 False, /* bHideUnReadable */
600 False, /* bHideUnWriteableFiles */
601 True, /* bBrowseable */
602 False, /* bAccessBasedShareEnum */
603 True, /* bAvailable */
604 True, /* bRead_only */
605 True, /* bNo_set_dir */
606 False, /* bGuest_only */
607 False, /* bAdministrative_share */
608 False, /* bGuest_ok */
609 False, /* bPrint_ok */
610 False, /* bMap_system */
611 False, /* bMap_hidden */
612 True, /* bMap_archive */
613 False, /* bStoreDosAttributes */
614 False, /* bDmapiSupport */
616 Auto, /* iStrictLocking */
617 True, /* bPosixLocking */
618 True, /* bShareModes */
620 True, /* bLevel2OpLocks */
621 False, /* bOnlyUser */
622 True, /* bMangledNames */
623 false, /* bWidelinks */
624 True, /* bSymlinks */
625 False, /* bSyncAlways */
626 False, /* bStrictAllocate */
627 False, /* bStrictSync */
628 '~', /* magic char */
630 False, /* bDeleteReadonly */
631 False, /* bFakeOplocks */
632 False, /* bDeleteVetoFiles */
633 False, /* bDosFilemode */
634 True, /* bDosFiletimes */
635 False, /* bDosFiletimeResolution */
636 False, /* bFakeDirCreateTimes */
637 True, /* bBlockingLocks */
638 False, /* bInheritPerms */
639 False, /* bInheritACLS */
640 False, /* bInheritOwner */
641 False, /* bMSDfsRoot */
642 False, /* bUseClientDriver */
643 True, /* bDefaultDevmode */
644 False, /* bForcePrintername */
645 True, /* bNTAclSupport */
646 False, /* bForceUnknownAclUser */
647 False, /* bUseSendfile */
648 False, /* bProfileAcls */
649 False, /* bMap_acl_inherit */
650 False, /* bAfs_Share */
651 False, /* bEASupport */
652 True, /* bAclCheckPermissions */
653 True, /* bAclMapFullControl */
654 False, /* bAclGroupControl */
655 True, /* bChangeNotify */
656 True, /* bKernelChangeNotify */
657 SMB_ROUNDUP_ALLOCATION_SIZE, /* iallocation_roundup_size */
658 0, /* iAioReadSize */
659 0, /* iAioWriteSize */
660 MAP_READONLY_YES, /* iMap_readonly */
661 #ifdef BROKEN_DIRECTORY_HANDLING
662 0, /* iDirectoryNameCacheSize */
664 100, /* iDirectoryNameCacheSize */
666 Auto, /* ismb_encrypt */
667 NULL, /* Parametric options */
672 /* local variables */
673 static struct service **ServicePtrs = NULL;
674 static int iNumServices = 0;
675 static int iServiceIndex = 0;
676 static struct db_context *ServiceHash;
677 static int *invalid_services = NULL;
678 static int num_invalid_services = 0;
679 static bool bInGlobalSection = True;
680 static bool bGlobalOnly = False;
681 static int default_server_announce;
683 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
685 /* prototypes for the special type handlers */
686 static bool handle_include( int snum, const char *pszParmValue, char **ptr);
687 static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
688 static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
689 static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
690 static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
691 static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
692 static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
693 static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
694 static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
695 static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
696 static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
697 static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
699 static void set_default_server_announce_type(void);
700 static void set_allowed_client_auth(void);
702 static void *lp_local_ptr(struct service *service, void *ptr);
704 static void add_to_file_list(const char *fname, const char *subfname);
706 static const struct enum_list enum_protocol[] = {
707 {PROTOCOL_SMB2, "SMB2"},
708 {PROTOCOL_NT1, "NT1"},
709 {PROTOCOL_LANMAN2, "LANMAN2"},
710 {PROTOCOL_LANMAN1, "LANMAN1"},
711 {PROTOCOL_CORE, "CORE"},
712 {PROTOCOL_COREPLUS, "COREPLUS"},
713 {PROTOCOL_COREPLUS, "CORE+"},
717 static const struct enum_list enum_security[] = {
718 {SEC_SHARE, "SHARE"},
720 {SEC_SERVER, "SERVER"},
721 {SEC_DOMAIN, "DOMAIN"},
728 static const struct enum_list enum_printing[] = {
729 {PRINT_SYSV, "sysv"},
731 {PRINT_HPUX, "hpux"},
735 {PRINT_LPRNG, "lprng"},
736 {PRINT_CUPS, "cups"},
737 {PRINT_IPRINT, "iprint"},
739 {PRINT_LPROS2, "os2"},
741 {PRINT_TEST, "test"},
743 #endif /* DEVELOPER */
747 static const struct enum_list enum_ldap_sasl_wrapping[] = {
749 {ADS_AUTH_SASL_SIGN, "sign"},
750 {ADS_AUTH_SASL_SEAL, "seal"},
754 static const struct enum_list enum_ldap_ssl[] = {
755 {LDAP_SSL_OFF, "no"},
756 {LDAP_SSL_OFF, "off"},
757 {LDAP_SSL_START_TLS, "start tls"},
758 {LDAP_SSL_START_TLS, "start_tls"},
762 /* LDAP Dereferencing Alias types */
763 #define SAMBA_LDAP_DEREF_NEVER 0
764 #define SAMBA_LDAP_DEREF_SEARCHING 1
765 #define SAMBA_LDAP_DEREF_FINDING 2
766 #define SAMBA_LDAP_DEREF_ALWAYS 3
768 static const struct enum_list enum_ldap_deref[] = {
769 {SAMBA_LDAP_DEREF_NEVER, "never"},
770 {SAMBA_LDAP_DEREF_SEARCHING, "searching"},
771 {SAMBA_LDAP_DEREF_FINDING, "finding"},
772 {SAMBA_LDAP_DEREF_ALWAYS, "always"},
776 static const struct enum_list enum_ldap_passwd_sync[] = {
777 {LDAP_PASSWD_SYNC_OFF, "no"},
778 {LDAP_PASSWD_SYNC_OFF, "off"},
779 {LDAP_PASSWD_SYNC_ON, "yes"},
780 {LDAP_PASSWD_SYNC_ON, "on"},
781 {LDAP_PASSWD_SYNC_ONLY, "only"},
785 /* Types of machine we can announce as. */
786 #define ANNOUNCE_AS_NT_SERVER 1
787 #define ANNOUNCE_AS_WIN95 2
788 #define ANNOUNCE_AS_WFW 3
789 #define ANNOUNCE_AS_NT_WORKSTATION 4
791 static const struct enum_list enum_announce_as[] = {
792 {ANNOUNCE_AS_NT_SERVER, "NT"},
793 {ANNOUNCE_AS_NT_SERVER, "NT Server"},
794 {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
795 {ANNOUNCE_AS_WIN95, "win95"},
796 {ANNOUNCE_AS_WFW, "WfW"},
800 static const struct enum_list enum_map_readonly[] = {
801 {MAP_READONLY_NO, "no"},
802 {MAP_READONLY_NO, "false"},
803 {MAP_READONLY_NO, "0"},
804 {MAP_READONLY_YES, "yes"},
805 {MAP_READONLY_YES, "true"},
806 {MAP_READONLY_YES, "1"},
807 {MAP_READONLY_PERMISSIONS, "permissions"},
808 {MAP_READONLY_PERMISSIONS, "perms"},
812 static const struct enum_list enum_case[] = {
813 {CASE_LOWER, "lower"},
814 {CASE_UPPER, "upper"},
820 static const struct enum_list enum_bool_auto[] = {
831 static const struct enum_list enum_csc_policy[] = {
832 {CSC_POLICY_MANUAL, "manual"},
833 {CSC_POLICY_DOCUMENTS, "documents"},
834 {CSC_POLICY_PROGRAMS, "programs"},
835 {CSC_POLICY_DISABLE, "disable"},
839 /* SMB signing types. */
840 static const struct enum_list enum_smb_signing_vals[] = {
852 {Required, "required"},
853 {Required, "mandatory"},
855 {Required, "forced"},
856 {Required, "enforced"},
860 /* ACL compatibility options. */
861 static const struct enum_list enum_acl_compat_vals[] = {
862 { ACL_COMPAT_AUTO, "auto" },
863 { ACL_COMPAT_WINNT, "winnt" },
864 { ACL_COMPAT_WIN2K, "win2k" },
869 Do you want session setups at user level security with a invalid
870 password to be rejected or allowed in as guest? WinNT rejects them
871 but it can be a pain as it means "net view" needs to use a password
873 You have 3 choices in the setting of map_to_guest:
875 "Never" means session setups with an invalid password
876 are rejected. This is the default.
878 "Bad User" means session setups with an invalid password
879 are rejected, unless the username does not exist, in which case it
880 is treated as a guest login
882 "Bad Password" means session setups with an invalid password
883 are treated as a guest login
885 Note that map_to_guest only has an effect in user or server
889 static const struct enum_list enum_map_to_guest[] = {
890 {NEVER_MAP_TO_GUEST, "Never"},
891 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
892 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
893 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
897 /* Config backend options */
899 static const struct enum_list enum_config_backend[] = {
900 {CONFIG_BACKEND_FILE, "file"},
901 {CONFIG_BACKEND_REGISTRY, "registry"},
905 /* ADS kerberos ticket verification options */
907 static const struct enum_list enum_kerberos_method[] = {
908 {KERBEROS_VERIFY_SECRETS, "default"},
909 {KERBEROS_VERIFY_SECRETS, "secrets only"},
910 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
911 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
912 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
916 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
918 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
919 * screen in SWAT. This is used to exclude parameters as well as to squash all
920 * parameters that have been duplicated by pseudonyms.
922 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
923 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
924 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
927 * NOTE2: Handling of duplicated (synonym) parameters:
928 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
929 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
930 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
931 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
934 static struct parm_struct parm_table[] = {
935 {N_("Base Options"), P_SEP, P_SEPARATOR},
938 .label = "dos charset",
941 .ptr = &Globals.dos_charset,
942 .special = handle_charset,
944 .flags = FLAG_ADVANCED
947 .label = "unix charset",
950 .ptr = &Globals.unix_charset,
951 .special = handle_charset,
953 .flags = FLAG_ADVANCED
956 .label = "display charset",
959 .ptr = &Globals.display_charset,
960 .special = handle_charset,
962 .flags = FLAG_ADVANCED
968 .ptr = &sDefault.comment,
971 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
977 .ptr = &sDefault.szPath,
980 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
983 .label = "directory",
986 .ptr = &sDefault.szPath,
992 .label = "workgroup",
995 .ptr = &Globals.szWorkgroup,
996 .special = handle_workgroup,
998 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1004 .p_class = P_GLOBAL,
1005 .ptr = &Globals.szRealm,
1008 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1012 .label = "netbios name",
1014 .p_class = P_GLOBAL,
1015 .ptr = &Globals.szNetbiosName,
1016 .special = handle_netbios_name,
1018 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1021 .label = "netbios aliases",
1023 .p_class = P_GLOBAL,
1024 .ptr = &Globals.szNetbiosAliases,
1025 .special = handle_netbios_aliases,
1027 .flags = FLAG_ADVANCED,
1030 .label = "netbios scope",
1032 .p_class = P_GLOBAL,
1033 .ptr = &Globals.szNetbiosScope,
1034 .special = handle_netbios_scope,
1036 .flags = FLAG_ADVANCED,
1039 .label = "server string",
1041 .p_class = P_GLOBAL,
1042 .ptr = &Globals.szServerString,
1045 .flags = FLAG_BASIC | FLAG_ADVANCED,
1048 .label = "interfaces",
1050 .p_class = P_GLOBAL,
1051 .ptr = &Globals.szInterfaces,
1054 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1057 .label = "bind interfaces only",
1059 .p_class = P_GLOBAL,
1060 .ptr = &Globals.bBindInterfacesOnly,
1063 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1066 .label = "config backend",
1068 .p_class = P_GLOBAL,
1069 .ptr = &Globals.ConfigBackend,
1071 .enum_list = enum_config_backend,
1072 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
1075 {N_("Security Options"), P_SEP, P_SEPARATOR},
1078 .label = "security",
1080 .p_class = P_GLOBAL,
1081 .ptr = &Globals.security,
1083 .enum_list = enum_security,
1084 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1087 .label = "auth methods",
1089 .p_class = P_GLOBAL,
1090 .ptr = &Globals.AuthMethods,
1093 .flags = FLAG_ADVANCED,
1096 .label = "encrypt passwords",
1098 .p_class = P_GLOBAL,
1099 .ptr = &Globals.bEncryptPasswords,
1102 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1105 .label = "update encrypted",
1107 .p_class = P_GLOBAL,
1108 .ptr = &Globals.bUpdateEncrypt,
1111 .flags = FLAG_ADVANCED,
1114 .label = "client schannel",
1116 .p_class = P_GLOBAL,
1117 .ptr = &Globals.clientSchannel,
1119 .enum_list = enum_bool_auto,
1120 .flags = FLAG_BASIC | FLAG_ADVANCED,
1123 .label = "server schannel",
1125 .p_class = P_GLOBAL,
1126 .ptr = &Globals.serverSchannel,
1128 .enum_list = enum_bool_auto,
1129 .flags = FLAG_BASIC | FLAG_ADVANCED,
1132 .label = "allow trusted domains",
1134 .p_class = P_GLOBAL,
1135 .ptr = &Globals.bAllowTrustedDomains,
1138 .flags = FLAG_ADVANCED,
1141 .label = "map to guest",
1143 .p_class = P_GLOBAL,
1144 .ptr = &Globals.map_to_guest,
1146 .enum_list = enum_map_to_guest,
1147 .flags = FLAG_ADVANCED,
1150 .label = "null passwords",
1152 .p_class = P_GLOBAL,
1153 .ptr = &Globals.bNullPasswords,
1156 .flags = FLAG_ADVANCED,
1159 .label = "obey pam restrictions",
1161 .p_class = P_GLOBAL,
1162 .ptr = &Globals.bObeyPamRestrictions,
1165 .flags = FLAG_ADVANCED,
1168 .label = "password server",
1170 .p_class = P_GLOBAL,
1171 .ptr = &Globals.szPasswordServer,
1174 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1177 .label = "smb passwd file",
1179 .p_class = P_GLOBAL,
1180 .ptr = &Globals.szSMBPasswdFile,
1183 .flags = FLAG_ADVANCED,
1186 .label = "private dir",
1188 .p_class = P_GLOBAL,
1189 .ptr = &Globals.szPrivateDir,
1192 .flags = FLAG_ADVANCED,
1195 .label = "passdb backend",
1197 .p_class = P_GLOBAL,
1198 .ptr = &Globals.szPassdbBackend,
1201 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1204 .label = "algorithmic rid base",
1206 .p_class = P_GLOBAL,
1207 .ptr = &Globals.AlgorithmicRidBase,
1210 .flags = FLAG_ADVANCED,
1213 .label = "root directory",
1215 .p_class = P_GLOBAL,
1216 .ptr = &Globals.szRootdir,
1219 .flags = FLAG_ADVANCED,
1222 .label = "root dir",
1224 .p_class = P_GLOBAL,
1225 .ptr = &Globals.szRootdir,
1233 .p_class = P_GLOBAL,
1234 .ptr = &Globals.szRootdir,
1240 .label = "guest account",
1242 .p_class = P_GLOBAL,
1243 .ptr = &Globals.szGuestaccount,
1246 .flags = FLAG_BASIC | FLAG_ADVANCED,
1249 .label = "enable privileges",
1251 .p_class = P_GLOBAL,
1252 .ptr = &Globals.bEnablePrivileges,
1255 .flags = FLAG_ADVANCED,
1259 .label = "pam password change",
1261 .p_class = P_GLOBAL,
1262 .ptr = &Globals.bPamPasswordChange,
1265 .flags = FLAG_ADVANCED,
1268 .label = "passwd program",
1270 .p_class = P_GLOBAL,
1271 .ptr = &Globals.szPasswdProgram,
1274 .flags = FLAG_ADVANCED,
1277 .label = "passwd chat",
1279 .p_class = P_GLOBAL,
1280 .ptr = &Globals.szPasswdChat,
1283 .flags = FLAG_ADVANCED,
1286 .label = "passwd chat debug",
1288 .p_class = P_GLOBAL,
1289 .ptr = &Globals.bPasswdChatDebug,
1292 .flags = FLAG_ADVANCED,
1295 .label = "passwd chat timeout",
1297 .p_class = P_GLOBAL,
1298 .ptr = &Globals.iPasswdChatTimeout,
1301 .flags = FLAG_ADVANCED,
1304 .label = "check password script",
1306 .p_class = P_GLOBAL,
1307 .ptr = &Globals.szCheckPasswordScript,
1310 .flags = FLAG_ADVANCED,
1313 .label = "username map",
1315 .p_class = P_GLOBAL,
1316 .ptr = &Globals.szUsernameMap,
1319 .flags = FLAG_ADVANCED,
1322 .label = "password level",
1324 .p_class = P_GLOBAL,
1325 .ptr = &Globals.pwordlevel,
1328 .flags = FLAG_ADVANCED,
1331 .label = "username level",
1333 .p_class = P_GLOBAL,
1334 .ptr = &Globals.unamelevel,
1337 .flags = FLAG_ADVANCED,
1340 .label = "unix password sync",
1342 .p_class = P_GLOBAL,
1343 .ptr = &Globals.bUnixPasswdSync,
1346 .flags = FLAG_ADVANCED,
1349 .label = "restrict anonymous",
1351 .p_class = P_GLOBAL,
1352 .ptr = &Globals.restrict_anonymous,
1355 .flags = FLAG_ADVANCED,
1358 .label = "lanman auth",
1360 .p_class = P_GLOBAL,
1361 .ptr = &Globals.bLanmanAuth,
1364 .flags = FLAG_ADVANCED,
1367 .label = "ntlm auth",
1369 .p_class = P_GLOBAL,
1370 .ptr = &Globals.bNTLMAuth,
1373 .flags = FLAG_ADVANCED,
1376 .label = "client NTLMv2 auth",
1378 .p_class = P_GLOBAL,
1379 .ptr = &Globals.bClientNTLMv2Auth,
1382 .flags = FLAG_ADVANCED,
1385 .label = "client lanman auth",
1387 .p_class = P_GLOBAL,
1388 .ptr = &Globals.bClientLanManAuth,
1391 .flags = FLAG_ADVANCED,
1394 .label = "client plaintext auth",
1396 .p_class = P_GLOBAL,
1397 .ptr = &Globals.bClientPlaintextAuth,
1400 .flags = FLAG_ADVANCED,
1403 .label = "username",
1406 .ptr = &sDefault.szUsername,
1409 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1415 .ptr = &sDefault.szUsername,
1424 .ptr = &sDefault.szUsername,
1430 .label = "invalid users",
1433 .ptr = &sDefault.szInvalidUsers,
1436 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1439 .label = "valid users",
1442 .ptr = &sDefault.szValidUsers,
1445 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1448 .label = "admin users",
1451 .ptr = &sDefault.szAdminUsers,
1454 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1457 .label = "read list",
1460 .ptr = &sDefault.readlist,
1463 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1466 .label = "write list",
1469 .ptr = &sDefault.writelist,
1472 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1475 .label = "printer admin",
1478 .ptr = &sDefault.printer_admin,
1481 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1484 .label = "force user",
1487 .ptr = &sDefault.force_user,
1490 .flags = FLAG_ADVANCED | FLAG_SHARE,
1493 .label = "force group",
1496 .ptr = &sDefault.force_group,
1499 .flags = FLAG_ADVANCED | FLAG_SHARE,
1505 .ptr = &sDefault.force_group,
1508 .flags = FLAG_ADVANCED,
1511 .label = "read only",
1514 .ptr = &sDefault.bRead_only,
1517 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1520 .label = "write ok",
1523 .ptr = &sDefault.bRead_only,
1529 .label = "writeable",
1532 .ptr = &sDefault.bRead_only,
1538 .label = "writable",
1541 .ptr = &sDefault.bRead_only,
1547 .label = "acl check permissions",
1550 .ptr = &sDefault.bAclCheckPermissions,
1553 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1556 .label = "acl group control",
1559 .ptr = &sDefault.bAclGroupControl,
1562 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1565 .label = "acl map full control",
1568 .ptr = &sDefault.bAclMapFullControl,
1571 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1574 .label = "create mask",
1577 .ptr = &sDefault.iCreate_mask,
1580 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1583 .label = "create mode",
1586 .ptr = &sDefault.iCreate_mask,
1592 .label = "force create mode",
1595 .ptr = &sDefault.iCreate_force_mode,
1598 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1601 .label = "security mask",
1604 .ptr = &sDefault.iSecurity_mask,
1607 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1610 .label = "force security mode",
1613 .ptr = &sDefault.iSecurity_force_mode,
1616 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1619 .label = "directory mask",
1622 .ptr = &sDefault.iDir_mask,
1625 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1628 .label = "directory mode",
1631 .ptr = &sDefault.iDir_mask,
1634 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1637 .label = "force directory mode",
1640 .ptr = &sDefault.iDir_force_mode,
1643 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1646 .label = "directory security mask",
1649 .ptr = &sDefault.iDir_Security_mask,
1652 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1655 .label = "force directory security mode",
1658 .ptr = &sDefault.iDir_Security_force_mode,
1661 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1664 .label = "force unknown acl user",
1667 .ptr = &sDefault.bForceUnknownAclUser,
1670 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1673 .label = "inherit permissions",
1676 .ptr = &sDefault.bInheritPerms,
1679 .flags = FLAG_ADVANCED | FLAG_SHARE,
1682 .label = "inherit acls",
1685 .ptr = &sDefault.bInheritACLS,
1688 .flags = FLAG_ADVANCED | FLAG_SHARE,
1691 .label = "inherit owner",
1694 .ptr = &sDefault.bInheritOwner,
1697 .flags = FLAG_ADVANCED | FLAG_SHARE,
1700 .label = "guest only",
1703 .ptr = &sDefault.bGuest_only,
1706 .flags = FLAG_ADVANCED | FLAG_SHARE,
1709 .label = "only guest",
1712 .ptr = &sDefault.bGuest_only,
1718 .label = "administrative share",
1721 .ptr = &sDefault.bAdministrative_share,
1724 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1728 .label = "guest ok",
1731 .ptr = &sDefault.bGuest_ok,
1734 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1740 .ptr = &sDefault.bGuest_ok,
1746 .label = "only user",
1749 .ptr = &sDefault.bOnlyUser,
1752 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1755 .label = "hosts allow",
1758 .ptr = &sDefault.szHostsallow,
1761 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1764 .label = "allow hosts",
1767 .ptr = &sDefault.szHostsallow,
1773 .label = "hosts deny",
1776 .ptr = &sDefault.szHostsdeny,
1779 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1782 .label = "deny hosts",
1785 .ptr = &sDefault.szHostsdeny,
1791 .label = "preload modules",
1793 .p_class = P_GLOBAL,
1794 .ptr = &Globals.szPreloadModules,
1797 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1800 .label = "dedicated keytab file",
1802 .p_class = P_GLOBAL,
1803 .ptr = &Globals.szDedicatedKeytabFile,
1806 .flags = FLAG_ADVANCED,
1809 .label = "kerberos method",
1811 .p_class = P_GLOBAL,
1812 .ptr = &Globals.iKerberosMethod,
1814 .enum_list = enum_kerberos_method,
1815 .flags = FLAG_ADVANCED,
1818 .label = "map untrusted to domain",
1820 .p_class = P_GLOBAL,
1821 .ptr = &Globals.bMapUntrustedToDomain,
1824 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1828 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1831 .label = "log level",
1833 .p_class = P_GLOBAL,
1834 .ptr = &Globals.szLogLevel,
1835 .special = handle_debug_list,
1837 .flags = FLAG_ADVANCED,
1840 .label = "debuglevel",
1842 .p_class = P_GLOBAL,
1843 .ptr = &Globals.szLogLevel,
1844 .special = handle_debug_list,
1851 .p_class = P_GLOBAL,
1852 .ptr = &Globals.syslog,
1855 .flags = FLAG_ADVANCED,
1858 .label = "syslog only",
1860 .p_class = P_GLOBAL,
1861 .ptr = &Globals.bSyslogOnly,
1864 .flags = FLAG_ADVANCED,
1867 .label = "log file",
1869 .p_class = P_GLOBAL,
1870 .ptr = &Globals.szLogFile,
1873 .flags = FLAG_ADVANCED,
1876 .label = "max log size",
1878 .p_class = P_GLOBAL,
1879 .ptr = &Globals.max_log_size,
1882 .flags = FLAG_ADVANCED,
1885 .label = "debug timestamp",
1887 .p_class = P_GLOBAL,
1888 .ptr = &Globals.bTimestampLogs,
1891 .flags = FLAG_ADVANCED,
1894 .label = "timestamp logs",
1896 .p_class = P_GLOBAL,
1897 .ptr = &Globals.bTimestampLogs,
1900 .flags = FLAG_ADVANCED,
1903 .label = "debug prefix timestamp",
1905 .p_class = P_GLOBAL,
1906 .ptr = &Globals.bDebugPrefixTimestamp,
1909 .flags = FLAG_ADVANCED,
1912 .label = "debug hires timestamp",
1914 .p_class = P_GLOBAL,
1915 .ptr = &Globals.bDebugHiresTimestamp,
1918 .flags = FLAG_ADVANCED,
1921 .label = "debug pid",
1923 .p_class = P_GLOBAL,
1924 .ptr = &Globals.bDebugPid,
1927 .flags = FLAG_ADVANCED,
1930 .label = "debug uid",
1932 .p_class = P_GLOBAL,
1933 .ptr = &Globals.bDebugUid,
1936 .flags = FLAG_ADVANCED,
1939 .label = "debug class",
1941 .p_class = P_GLOBAL,
1942 .ptr = &Globals.bDebugClass,
1945 .flags = FLAG_ADVANCED,
1948 .label = "enable core files",
1950 .p_class = P_GLOBAL,
1951 .ptr = &Globals.bEnableCoreFiles,
1954 .flags = FLAG_ADVANCED,
1957 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1960 .label = "allocation roundup size",
1963 .ptr = &sDefault.iallocation_roundup_size,
1966 .flags = FLAG_ADVANCED,
1969 .label = "aio read size",
1972 .ptr = &sDefault.iAioReadSize,
1975 .flags = FLAG_ADVANCED,
1978 .label = "aio write size",
1981 .ptr = &sDefault.iAioWriteSize,
1984 .flags = FLAG_ADVANCED,
1987 .label = "aio write behind",
1990 .ptr = &sDefault.szAioWriteBehind,
1993 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1996 .label = "smb ports",
1998 .p_class = P_GLOBAL,
1999 .ptr = &Globals.smb_ports,
2002 .flags = FLAG_ADVANCED,
2005 .label = "large readwrite",
2007 .p_class = P_GLOBAL,
2008 .ptr = &Globals.bLargeReadwrite,
2011 .flags = FLAG_ADVANCED,
2014 .label = "max protocol",
2016 .p_class = P_GLOBAL,
2017 .ptr = &Globals.maxprotocol,
2019 .enum_list = enum_protocol,
2020 .flags = FLAG_ADVANCED,
2023 .label = "protocol",
2025 .p_class = P_GLOBAL,
2026 .ptr = &Globals.maxprotocol,
2028 .enum_list = enum_protocol,
2029 .flags = FLAG_ADVANCED,
2032 .label = "min protocol",
2034 .p_class = P_GLOBAL,
2035 .ptr = &Globals.minprotocol,
2037 .enum_list = enum_protocol,
2038 .flags = FLAG_ADVANCED,
2041 .label = "min receivefile size",
2043 .p_class = P_GLOBAL,
2044 .ptr = &Globals.iminreceivefile,
2047 .flags = FLAG_ADVANCED,
2050 .label = "read raw",
2052 .p_class = P_GLOBAL,
2053 .ptr = &Globals.bReadRaw,
2056 .flags = FLAG_ADVANCED,
2059 .label = "write raw",
2061 .p_class = P_GLOBAL,
2062 .ptr = &Globals.bWriteRaw,
2065 .flags = FLAG_ADVANCED,
2068 .label = "disable netbios",
2070 .p_class = P_GLOBAL,
2071 .ptr = &Globals.bDisableNetbios,
2074 .flags = FLAG_ADVANCED,
2077 .label = "reset on zero vc",
2079 .p_class = P_GLOBAL,
2080 .ptr = &Globals.bResetOnZeroVC,
2083 .flags = FLAG_ADVANCED,
2086 .label = "log writeable files on exit",
2088 .p_class = P_GLOBAL,
2089 .ptr = &Globals.bLogWriteableFilesOnExit,
2092 .flags = FLAG_ADVANCED,
2095 .label = "acl compatibility",
2097 .p_class = P_GLOBAL,
2098 .ptr = &Globals.iAclCompat,
2100 .enum_list = enum_acl_compat_vals,
2101 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2104 .label = "defer sharing violations",
2106 .p_class = P_GLOBAL,
2107 .ptr = &Globals.bDeferSharingViolations,
2110 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2113 .label = "ea support",
2116 .ptr = &sDefault.bEASupport,
2119 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2122 .label = "nt acl support",
2125 .ptr = &sDefault.bNTAclSupport,
2128 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2131 .label = "nt pipe support",
2133 .p_class = P_GLOBAL,
2134 .ptr = &Globals.bNTPipeSupport,
2137 .flags = FLAG_ADVANCED,
2140 .label = "nt status support",
2142 .p_class = P_GLOBAL,
2143 .ptr = &Globals.bNTStatusSupport,
2146 .flags = FLAG_ADVANCED,
2149 .label = "profile acls",
2152 .ptr = &sDefault.bProfileAcls,
2155 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
2158 .label = "announce version",
2160 .p_class = P_GLOBAL,
2161 .ptr = &Globals.szAnnounceVersion,
2164 .flags = FLAG_ADVANCED,
2167 .label = "announce as",
2169 .p_class = P_GLOBAL,
2170 .ptr = &Globals.announce_as,
2172 .enum_list = enum_announce_as,
2173 .flags = FLAG_ADVANCED,
2176 .label = "map acl inherit",
2179 .ptr = &sDefault.bMap_acl_inherit,
2182 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2185 .label = "afs share",
2188 .ptr = &sDefault.bAfs_Share,
2191 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2196 .p_class = P_GLOBAL,
2197 .ptr = &Globals.max_mux,
2200 .flags = FLAG_ADVANCED,
2203 .label = "max xmit",
2205 .p_class = P_GLOBAL,
2206 .ptr = &Globals.max_xmit,
2209 .flags = FLAG_ADVANCED,
2212 .label = "name resolve order",
2214 .p_class = P_GLOBAL,
2215 .ptr = &Globals.szNameResolveOrder,
2218 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2223 .p_class = P_GLOBAL,
2224 .ptr = &Globals.max_ttl,
2227 .flags = FLAG_ADVANCED,
2230 .label = "max wins ttl",
2232 .p_class = P_GLOBAL,
2233 .ptr = &Globals.max_wins_ttl,
2236 .flags = FLAG_ADVANCED,
2239 .label = "min wins ttl",
2241 .p_class = P_GLOBAL,
2242 .ptr = &Globals.min_wins_ttl,
2245 .flags = FLAG_ADVANCED,
2248 .label = "time server",
2250 .p_class = P_GLOBAL,
2251 .ptr = &Globals.bTimeServer,
2254 .flags = FLAG_ADVANCED,
2257 .label = "unix extensions",
2259 .p_class = P_GLOBAL,
2260 .ptr = &Globals.bUnixExtensions,
2263 .flags = FLAG_ADVANCED,
2266 .label = "use spnego",
2268 .p_class = P_GLOBAL,
2269 .ptr = &Globals.bUseSpnego,
2272 .flags = FLAG_ADVANCED,
2275 .label = "client signing",
2277 .p_class = P_GLOBAL,
2278 .ptr = &Globals.client_signing,
2280 .enum_list = enum_smb_signing_vals,
2281 .flags = FLAG_ADVANCED,
2284 .label = "server signing",
2286 .p_class = P_GLOBAL,
2287 .ptr = &Globals.server_signing,
2289 .enum_list = enum_smb_signing_vals,
2290 .flags = FLAG_ADVANCED,
2293 .label = "smb encrypt",
2296 .ptr = &sDefault.ismb_encrypt,
2298 .enum_list = enum_smb_signing_vals,
2299 .flags = FLAG_ADVANCED,
2302 .label = "client use spnego",
2304 .p_class = P_GLOBAL,
2305 .ptr = &Globals.bClientUseSpnego,
2308 .flags = FLAG_ADVANCED,
2311 .label = "client ldap sasl wrapping",
2313 .p_class = P_GLOBAL,
2314 .ptr = &Globals.client_ldap_sasl_wrapping,
2316 .enum_list = enum_ldap_sasl_wrapping,
2317 .flags = FLAG_ADVANCED,
2320 .label = "enable asu support",
2322 .p_class = P_GLOBAL,
2323 .ptr = &Globals.bASUSupport,
2326 .flags = FLAG_ADVANCED,
2329 .label = "svcctl list",
2331 .p_class = P_GLOBAL,
2332 .ptr = &Globals.szServicesList,
2335 .flags = FLAG_ADVANCED,
2338 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
2341 .label = "block size",
2344 .ptr = &sDefault.iBlock_size,
2347 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2350 .label = "deadtime",
2352 .p_class = P_GLOBAL,
2353 .ptr = &Globals.deadtime,
2356 .flags = FLAG_ADVANCED,
2359 .label = "getwd cache",
2361 .p_class = P_GLOBAL,
2362 .ptr = &Globals.getwd_cache,
2365 .flags = FLAG_ADVANCED,
2368 .label = "keepalive",
2370 .p_class = P_GLOBAL,
2371 .ptr = &Globals.iKeepalive,
2374 .flags = FLAG_ADVANCED,
2377 .label = "change notify",
2380 .ptr = &sDefault.bChangeNotify,
2383 .flags = FLAG_ADVANCED | FLAG_SHARE,
2386 .label = "directory name cache size",
2389 .ptr = &sDefault.iDirectoryNameCacheSize,
2392 .flags = FLAG_ADVANCED | FLAG_SHARE,
2395 .label = "kernel change notify",
2398 .ptr = &sDefault.bKernelChangeNotify,
2401 .flags = FLAG_ADVANCED | FLAG_SHARE,
2404 .label = "lpq cache time",
2406 .p_class = P_GLOBAL,
2407 .ptr = &Globals.lpqcachetime,
2410 .flags = FLAG_ADVANCED,
2413 .label = "max smbd processes",
2415 .p_class = P_GLOBAL,
2416 .ptr = &Globals.iMaxSmbdProcesses,
2419 .flags = FLAG_ADVANCED,
2422 .label = "max connections",
2425 .ptr = &sDefault.iMaxConnections,
2428 .flags = FLAG_ADVANCED | FLAG_SHARE,
2431 .label = "paranoid server security",
2433 .p_class = P_GLOBAL,
2434 .ptr = &Globals.paranoid_server_security,
2437 .flags = FLAG_ADVANCED,
2440 .label = "max disk size",
2442 .p_class = P_GLOBAL,
2443 .ptr = &Globals.maxdisksize,
2446 .flags = FLAG_ADVANCED,
2449 .label = "max open files",
2451 .p_class = P_GLOBAL,
2452 .ptr = &Globals.max_open_files,
2455 .flags = FLAG_ADVANCED,
2458 .label = "min print space",
2461 .ptr = &sDefault.iMinPrintSpace,
2464 .flags = FLAG_ADVANCED | FLAG_PRINT,
2467 .label = "socket options",
2469 .p_class = P_GLOBAL,
2470 .ptr = &Globals.szSocketOptions,
2473 .flags = FLAG_ADVANCED,
2476 .label = "strict allocate",
2479 .ptr = &sDefault.bStrictAllocate,
2482 .flags = FLAG_ADVANCED | FLAG_SHARE,
2485 .label = "strict sync",
2488 .ptr = &sDefault.bStrictSync,
2491 .flags = FLAG_ADVANCED | FLAG_SHARE,
2494 .label = "sync always",
2497 .ptr = &sDefault.bSyncAlways,
2500 .flags = FLAG_ADVANCED | FLAG_SHARE,
2503 .label = "use mmap",
2505 .p_class = P_GLOBAL,
2506 .ptr = &Globals.bUseMmap,
2509 .flags = FLAG_ADVANCED,
2512 .label = "use sendfile",
2515 .ptr = &sDefault.bUseSendfile,
2518 .flags = FLAG_ADVANCED | FLAG_SHARE,
2521 .label = "hostname lookups",
2523 .p_class = P_GLOBAL,
2524 .ptr = &Globals.bHostnameLookups,
2527 .flags = FLAG_ADVANCED,
2530 .label = "write cache size",
2533 .ptr = &sDefault.iWriteCacheSize,
2536 .flags = FLAG_ADVANCED | FLAG_SHARE,
2539 .label = "name cache timeout",
2541 .p_class = P_GLOBAL,
2542 .ptr = &Globals.name_cache_timeout,
2545 .flags = FLAG_ADVANCED,
2548 .label = "ctdbd socket",
2550 .p_class = P_GLOBAL,
2551 .ptr = &Globals.ctdbdSocket,
2554 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2557 .label = "cluster addresses",
2559 .p_class = P_GLOBAL,
2560 .ptr = &Globals.szClusterAddresses,
2563 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2566 .label = "clustering",
2568 .p_class = P_GLOBAL,
2569 .ptr = &Globals.clustering,
2572 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2575 .label = "ctdb timeout",
2577 .p_class = P_GLOBAL,
2578 .ptr = &Globals.ctdb_timeout,
2581 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2584 .label = "ctdb locktime warn threshold",
2586 .p_class = P_GLOBAL,
2587 .ptr = &Globals.ctdb_locktime_warn_threshold,
2590 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2593 .label = "smb2 max read",
2595 .p_class = P_GLOBAL,
2596 .ptr = &Globals.ismb2_max_read,
2599 .flags = FLAG_ADVANCED,
2602 .label = "smb2 max write",
2604 .p_class = P_GLOBAL,
2605 .ptr = &Globals.ismb2_max_write,
2608 .flags = FLAG_ADVANCED,
2611 .label = "smb2 max trans",
2613 .p_class = P_GLOBAL,
2614 .ptr = &Globals.ismb2_max_trans,
2617 .flags = FLAG_ADVANCED,
2620 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2623 .label = "max reported print jobs",
2626 .ptr = &sDefault.iMaxReportedPrintJobs,
2629 .flags = FLAG_ADVANCED | FLAG_PRINT,
2632 .label = "max print jobs",
2635 .ptr = &sDefault.iMaxPrintJobs,
2638 .flags = FLAG_ADVANCED | FLAG_PRINT,
2641 .label = "load printers",
2643 .p_class = P_GLOBAL,
2644 .ptr = &Globals.bLoadPrinters,
2647 .flags = FLAG_ADVANCED | FLAG_PRINT,
2650 .label = "printcap cache time",
2652 .p_class = P_GLOBAL,
2653 .ptr = &Globals.PrintcapCacheTime,
2656 .flags = FLAG_ADVANCED | FLAG_PRINT,
2659 .label = "printcap name",
2661 .p_class = P_GLOBAL,
2662 .ptr = &Globals.szPrintcapname,
2665 .flags = FLAG_ADVANCED | FLAG_PRINT,
2668 .label = "printcap",
2670 .p_class = P_GLOBAL,
2671 .ptr = &Globals.szPrintcapname,
2677 .label = "printable",
2680 .ptr = &sDefault.bPrint_ok,
2683 .flags = FLAG_ADVANCED | FLAG_PRINT,
2686 .label = "print ok",
2689 .ptr = &sDefault.bPrint_ok,
2695 .label = "printing",
2698 .ptr = &sDefault.iPrinting,
2699 .special = handle_printing,
2700 .enum_list = enum_printing,
2701 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2704 .label = "cups options",
2707 .ptr = &sDefault.szCupsOptions,
2710 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2713 .label = "cups server",
2715 .p_class = P_GLOBAL,
2716 .ptr = &Globals.szCupsServer,
2719 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2722 .label = "cups encrypt",
2724 .p_class = P_GLOBAL,
2725 .ptr = &Globals.CupsEncrypt,
2727 .enum_list = enum_bool_auto,
2728 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2732 .label = "cups connection timeout",
2734 .p_class = P_GLOBAL,
2735 .ptr = &Globals.cups_connection_timeout,
2738 .flags = FLAG_ADVANCED,
2741 .label = "iprint server",
2743 .p_class = P_GLOBAL,
2744 .ptr = &Globals.szIPrintServer,
2747 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2750 .label = "print command",
2753 .ptr = &sDefault.szPrintcommand,
2756 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2759 .label = "disable spoolss",
2761 .p_class = P_GLOBAL,
2762 .ptr = &Globals.bDisableSpoolss,
2765 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2768 .label = "enable spoolss",
2770 .p_class = P_GLOBAL,
2771 .ptr = &Globals.bDisableSpoolss,
2777 .label = "lpq command",
2780 .ptr = &sDefault.szLpqcommand,
2783 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2786 .label = "lprm command",
2789 .ptr = &sDefault.szLprmcommand,
2792 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2795 .label = "lppause command",
2798 .ptr = &sDefault.szLppausecommand,
2801 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2804 .label = "lpresume command",
2807 .ptr = &sDefault.szLpresumecommand,
2810 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2813 .label = "queuepause command",
2816 .ptr = &sDefault.szQueuepausecommand,
2819 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2822 .label = "queueresume command",
2825 .ptr = &sDefault.szQueueresumecommand,
2828 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2831 .label = "addport command",
2833 .p_class = P_GLOBAL,
2834 .ptr = &Globals.szAddPortCommand,
2837 .flags = FLAG_ADVANCED,
2840 .label = "enumports command",
2842 .p_class = P_GLOBAL,
2843 .ptr = &Globals.szEnumPortsCommand,
2846 .flags = FLAG_ADVANCED,
2849 .label = "addprinter command",
2851 .p_class = P_GLOBAL,
2852 .ptr = &Globals.szAddPrinterCommand,
2855 .flags = FLAG_ADVANCED,
2858 .label = "deleteprinter command",
2860 .p_class = P_GLOBAL,
2861 .ptr = &Globals.szDeletePrinterCommand,
2864 .flags = FLAG_ADVANCED,
2867 .label = "show add printer wizard",
2869 .p_class = P_GLOBAL,
2870 .ptr = &Globals.bMsAddPrinterWizard,
2873 .flags = FLAG_ADVANCED,
2876 .label = "os2 driver map",
2878 .p_class = P_GLOBAL,
2879 .ptr = &Globals.szOs2DriverMap,
2882 .flags = FLAG_ADVANCED,
2886 .label = "printer name",
2889 .ptr = &sDefault.szPrintername,
2892 .flags = FLAG_ADVANCED | FLAG_PRINT,
2898 .ptr = &sDefault.szPrintername,
2904 .label = "use client driver",
2907 .ptr = &sDefault.bUseClientDriver,
2910 .flags = FLAG_ADVANCED | FLAG_PRINT,
2913 .label = "default devmode",
2916 .ptr = &sDefault.bDefaultDevmode,
2919 .flags = FLAG_ADVANCED | FLAG_PRINT,
2922 .label = "force printername",
2925 .ptr = &sDefault.bForcePrintername,
2928 .flags = FLAG_ADVANCED | FLAG_PRINT,
2931 .label = "printjob username",
2934 .ptr = &sDefault.szPrintjobUsername,
2937 .flags = FLAG_ADVANCED | FLAG_PRINT,
2940 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2943 .label = "mangling method",
2945 .p_class = P_GLOBAL,
2946 .ptr = &Globals.szManglingMethod,
2949 .flags = FLAG_ADVANCED,
2952 .label = "mangle prefix",
2954 .p_class = P_GLOBAL,
2955 .ptr = &Globals.mangle_prefix,
2958 .flags = FLAG_ADVANCED,
2962 .label = "default case",
2965 .ptr = &sDefault.iDefaultCase,
2967 .enum_list = enum_case,
2968 .flags = FLAG_ADVANCED | FLAG_SHARE,
2971 .label = "case sensitive",
2974 .ptr = &sDefault.iCaseSensitive,
2976 .enum_list = enum_bool_auto,
2977 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2980 .label = "casesignames",
2983 .ptr = &sDefault.iCaseSensitive,
2985 .enum_list = enum_bool_auto,
2986 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2989 .label = "preserve case",
2992 .ptr = &sDefault.bCasePreserve,
2995 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2998 .label = "short preserve case",
3001 .ptr = &sDefault.bShortCasePreserve,
3004 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3007 .label = "mangling char",
3010 .ptr = &sDefault.magic_char,
3013 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3016 .label = "hide dot files",
3019 .ptr = &sDefault.bHideDotFiles,
3022 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3025 .label = "hide special files",
3028 .ptr = &sDefault.bHideSpecialFiles,
3031 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3034 .label = "hide unreadable",
3037 .ptr = &sDefault.bHideUnReadable,
3040 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3043 .label = "hide unwriteable files",
3046 .ptr = &sDefault.bHideUnWriteableFiles,
3049 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3052 .label = "delete veto files",
3055 .ptr = &sDefault.bDeleteVetoFiles,
3058 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3061 .label = "veto files",
3064 .ptr = &sDefault.szVetoFiles,
3067 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3070 .label = "hide files",
3073 .ptr = &sDefault.szHideFiles,
3076 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3079 .label = "veto oplock files",
3082 .ptr = &sDefault.szVetoOplockFiles,
3085 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3088 .label = "map archive",
3091 .ptr = &sDefault.bMap_archive,
3094 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3097 .label = "map hidden",
3100 .ptr = &sDefault.bMap_hidden,
3103 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3106 .label = "map system",
3109 .ptr = &sDefault.bMap_system,
3112 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3115 .label = "map readonly",
3118 .ptr = &sDefault.iMap_readonly,
3120 .enum_list = enum_map_readonly,
3121 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3124 .label = "mangled names",
3127 .ptr = &sDefault.bMangledNames,
3130 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3133 .label = "max stat cache size",
3135 .p_class = P_GLOBAL,
3136 .ptr = &Globals.iMaxStatCacheSize,
3139 .flags = FLAG_ADVANCED,
3142 .label = "stat cache",
3144 .p_class = P_GLOBAL,
3145 .ptr = &Globals.bStatCache,
3148 .flags = FLAG_ADVANCED,
3151 .label = "store dos attributes",
3154 .ptr = &sDefault.bStoreDosAttributes,
3157 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3160 .label = "dmapi support",
3163 .ptr = &sDefault.bDmapiSupport,
3166 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3170 {N_("Domain Options"), P_SEP, P_SEPARATOR},
3173 .label = "machine password timeout",
3175 .p_class = P_GLOBAL,
3176 .ptr = &Globals.machine_password_timeout,
3179 .flags = FLAG_ADVANCED | FLAG_WIZARD,
3182 {N_("Logon Options"), P_SEP, P_SEPARATOR},
3185 .label = "add user script",
3187 .p_class = P_GLOBAL,
3188 .ptr = &Globals.szAddUserScript,
3191 .flags = FLAG_ADVANCED,
3194 .label = "rename user script",
3196 .p_class = P_GLOBAL,
3197 .ptr = &Globals.szRenameUserScript,
3200 .flags = FLAG_ADVANCED,
3203 .label = "delete user script",
3205 .p_class = P_GLOBAL,
3206 .ptr = &Globals.szDelUserScript,
3209 .flags = FLAG_ADVANCED,
3212 .label = "add group script",
3214 .p_class = P_GLOBAL,
3215 .ptr = &Globals.szAddGroupScript,
3218 .flags = FLAG_ADVANCED,
3221 .label = "delete group script",
3223 .p_class = P_GLOBAL,
3224 .ptr = &Globals.szDelGroupScript,
3227 .flags = FLAG_ADVANCED,
3230 .label = "add user to group script",
3232 .p_class = P_GLOBAL,
3233 .ptr = &Globals.szAddUserToGroupScript,
3236 .flags = FLAG_ADVANCED,
3239 .label = "delete user from group script",
3241 .p_class = P_GLOBAL,
3242 .ptr = &Globals.szDelUserFromGroupScript,
3245 .flags = FLAG_ADVANCED,
3248 .label = "set primary group script",
3250 .p_class = P_GLOBAL,
3251 .ptr = &Globals.szSetPrimaryGroupScript,
3254 .flags = FLAG_ADVANCED,
3257 .label = "add machine script",
3259 .p_class = P_GLOBAL,
3260 .ptr = &Globals.szAddMachineScript,
3263 .flags = FLAG_ADVANCED,
3266 .label = "shutdown script",
3268 .p_class = P_GLOBAL,
3269 .ptr = &Globals.szShutdownScript,
3272 .flags = FLAG_ADVANCED,
3275 .label = "abort shutdown script",
3277 .p_class = P_GLOBAL,
3278 .ptr = &Globals.szAbortShutdownScript,
3281 .flags = FLAG_ADVANCED,
3284 .label = "username map script",
3286 .p_class = P_GLOBAL,
3287 .ptr = &Globals.szUsernameMapScript,
3290 .flags = FLAG_ADVANCED,
3293 .label = "username map cache time",
3295 .p_class = P_GLOBAL,
3296 .ptr = &Globals.iUsernameMapCacheTime,
3299 .flags = FLAG_ADVANCED,
3302 .label = "logon script",
3304 .p_class = P_GLOBAL,
3305 .ptr = &Globals.szLogonScript,
3308 .flags = FLAG_ADVANCED,
3311 .label = "logon path",
3313 .p_class = P_GLOBAL,
3314 .ptr = &Globals.szLogonPath,
3317 .flags = FLAG_ADVANCED,
3320 .label = "logon drive",
3322 .p_class = P_GLOBAL,
3323 .ptr = &Globals.szLogonDrive,
3326 .flags = FLAG_ADVANCED,
3329 .label = "logon home",
3331 .p_class = P_GLOBAL,
3332 .ptr = &Globals.szLogonHome,
3335 .flags = FLAG_ADVANCED,
3338 .label = "domain logons",
3340 .p_class = P_GLOBAL,
3341 .ptr = &Globals.bDomainLogons,
3344 .flags = FLAG_ADVANCED,
3348 .label = "init logon delayed hosts",
3350 .p_class = P_GLOBAL,
3351 .ptr = &Globals.szInitLogonDelayedHosts,
3354 .flags = FLAG_ADVANCED,
3358 .label = "init logon delay",
3360 .p_class = P_GLOBAL,
3361 .ptr = &Globals.InitLogonDelay,
3364 .flags = FLAG_ADVANCED,
3368 {N_("Browse Options"), P_SEP, P_SEPARATOR},
3371 .label = "os level",
3373 .p_class = P_GLOBAL,
3374 .ptr = &Globals.os_level,
3377 .flags = FLAG_BASIC | FLAG_ADVANCED,
3380 .label = "lm announce",
3382 .p_class = P_GLOBAL,
3383 .ptr = &Globals.lm_announce,
3385 .enum_list = enum_bool_auto,
3386 .flags = FLAG_ADVANCED,
3389 .label = "lm interval",
3391 .p_class = P_GLOBAL,
3392 .ptr = &Globals.lm_interval,
3395 .flags = FLAG_ADVANCED,
3398 .label = "preferred master",
3400 .p_class = P_GLOBAL,
3401 .ptr = &Globals.iPreferredMaster,
3403 .enum_list = enum_bool_auto,
3404 .flags = FLAG_BASIC | FLAG_ADVANCED,
3407 .label = "prefered master",
3409 .p_class = P_GLOBAL,
3410 .ptr = &Globals.iPreferredMaster,
3412 .enum_list = enum_bool_auto,
3416 .label = "local master",
3418 .p_class = P_GLOBAL,
3419 .ptr = &Globals.bLocalMaster,
3422 .flags = FLAG_BASIC | FLAG_ADVANCED,
3425 .label = "domain master",
3427 .p_class = P_GLOBAL,
3428 .ptr = &Globals.iDomainMaster,
3430 .enum_list = enum_bool_auto,
3431 .flags = FLAG_BASIC | FLAG_ADVANCED,
3434 .label = "browse list",
3436 .p_class = P_GLOBAL,
3437 .ptr = &Globals.bBrowseList,
3440 .flags = FLAG_ADVANCED,
3443 .label = "browseable",
3446 .ptr = &sDefault.bBrowseable,
3449 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3452 .label = "browsable",
3455 .ptr = &sDefault.bBrowseable,
3461 .label = "access based share enum",
3464 .ptr = &sDefault.bAccessBasedShareEnum,
3467 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3470 .label = "enhanced browsing",
3472 .p_class = P_GLOBAL,
3473 .ptr = &Globals.enhanced_browsing,
3476 .flags = FLAG_ADVANCED,
3479 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3482 .label = "dns proxy",
3484 .p_class = P_GLOBAL,
3485 .ptr = &Globals.bDNSproxy,
3488 .flags = FLAG_ADVANCED,
3491 .label = "wins proxy",
3493 .p_class = P_GLOBAL,
3494 .ptr = &Globals.bWINSproxy,
3497 .flags = FLAG_ADVANCED,
3500 .label = "wins server",
3502 .p_class = P_GLOBAL,
3503 .ptr = &Globals.szWINSservers,
3506 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3509 .label = "wins support",
3511 .p_class = P_GLOBAL,
3512 .ptr = &Globals.bWINSsupport,
3515 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3518 .label = "wins hook",
3520 .p_class = P_GLOBAL,
3521 .ptr = &Globals.szWINSHook,
3524 .flags = FLAG_ADVANCED,
3527 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3530 .label = "blocking locks",
3533 .ptr = &sDefault.bBlockingLocks,
3536 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3539 .label = "csc policy",
3542 .ptr = &sDefault.iCSCPolicy,
3544 .enum_list = enum_csc_policy,
3545 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3548 .label = "fake oplocks",
3551 .ptr = &sDefault.bFakeOplocks,
3554 .flags = FLAG_ADVANCED | FLAG_SHARE,
3557 .label = "kernel oplocks",
3559 .p_class = P_GLOBAL,
3560 .ptr = &Globals.bKernelOplocks,
3563 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3569 .ptr = &sDefault.bLocking,
3572 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3575 .label = "lock spin time",
3577 .p_class = P_GLOBAL,
3578 .ptr = &Globals.iLockSpinTime,
3581 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3587 .ptr = &sDefault.bOpLocks,
3590 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3593 .label = "level2 oplocks",
3596 .ptr = &sDefault.bLevel2OpLocks,
3599 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3602 .label = "oplock break wait time",
3604 .p_class = P_GLOBAL,
3605 .ptr = &Globals.oplock_break_wait_time,
3608 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3611 .label = "oplock contention limit",
3614 .ptr = &sDefault.iOplockContentionLimit,
3617 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3620 .label = "posix locking",
3623 .ptr = &sDefault.bPosixLocking,
3626 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3629 .label = "strict locking",
3632 .ptr = &sDefault.iStrictLocking,
3634 .enum_list = enum_bool_auto,
3635 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3638 .label = "share modes",
3641 .ptr = &sDefault.bShareModes,
3644 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3647 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3650 .label = "ldap admin dn",
3652 .p_class = P_GLOBAL,
3653 .ptr = &Globals.szLdapAdminDn,
3656 .flags = FLAG_ADVANCED,
3659 .label = "ldap delete dn",
3661 .p_class = P_GLOBAL,
3662 .ptr = &Globals.ldap_delete_dn,
3665 .flags = FLAG_ADVANCED,
3668 .label = "ldap group suffix",
3670 .p_class = P_GLOBAL,
3671 .ptr = &Globals.szLdapGroupSuffix,
3674 .flags = FLAG_ADVANCED,
3677 .label = "ldap idmap suffix",
3679 .p_class = P_GLOBAL,
3680 .ptr = &Globals.szLdapIdmapSuffix,
3683 .flags = FLAG_ADVANCED,
3686 .label = "ldap machine suffix",
3688 .p_class = P_GLOBAL,
3689 .ptr = &Globals.szLdapMachineSuffix,
3692 .flags = FLAG_ADVANCED,
3695 .label = "ldap passwd sync",
3697 .p_class = P_GLOBAL,
3698 .ptr = &Globals.ldap_passwd_sync,
3700 .enum_list = enum_ldap_passwd_sync,
3701 .flags = FLAG_ADVANCED,
3704 .label = "ldap password sync",
3706 .p_class = P_GLOBAL,
3707 .ptr = &Globals.ldap_passwd_sync,
3709 .enum_list = enum_ldap_passwd_sync,
3713 .label = "ldap replication sleep",
3715 .p_class = P_GLOBAL,
3716 .ptr = &Globals.ldap_replication_sleep,
3719 .flags = FLAG_ADVANCED,
3722 .label = "ldap suffix",
3724 .p_class = P_GLOBAL,
3725 .ptr = &Globals.szLdapSuffix,
3728 .flags = FLAG_ADVANCED,
3731 .label = "ldap ssl",
3733 .p_class = P_GLOBAL,
3734 .ptr = &Globals.ldap_ssl,
3736 .enum_list = enum_ldap_ssl,
3737 .flags = FLAG_ADVANCED,
3740 .label = "ldap ssl ads",
3742 .p_class = P_GLOBAL,
3743 .ptr = &Globals.ldap_ssl_ads,
3746 .flags = FLAG_ADVANCED,
3749 .label = "ldap deref",
3751 .p_class = P_GLOBAL,
3752 .ptr = &Globals.ldap_deref,
3754 .enum_list = enum_ldap_deref,
3755 .flags = FLAG_ADVANCED,
3758 .label = "ldap follow referral",
3760 .p_class = P_GLOBAL,
3761 .ptr = &Globals.ldap_follow_referral,
3763 .enum_list = enum_bool_auto,
3764 .flags = FLAG_ADVANCED,
3767 .label = "ldap timeout",
3769 .p_class = P_GLOBAL,
3770 .ptr = &Globals.ldap_timeout,
3773 .flags = FLAG_ADVANCED,
3776 .label = "ldap connection timeout",
3778 .p_class = P_GLOBAL,
3779 .ptr = &Globals.ldap_connection_timeout,
3782 .flags = FLAG_ADVANCED,
3785 .label = "ldap page size",
3787 .p_class = P_GLOBAL,
3788 .ptr = &Globals.ldap_page_size,
3791 .flags = FLAG_ADVANCED,
3794 .label = "ldap user suffix",
3796 .p_class = P_GLOBAL,
3797 .ptr = &Globals.szLdapUserSuffix,
3800 .flags = FLAG_ADVANCED,
3803 .label = "ldap debug level",
3805 .p_class = P_GLOBAL,
3806 .ptr = &Globals.ldap_debug_level,
3807 .special = handle_ldap_debug_level,
3809 .flags = FLAG_ADVANCED,
3812 .label = "ldap debug threshold",
3814 .p_class = P_GLOBAL,
3815 .ptr = &Globals.ldap_debug_threshold,
3818 .flags = FLAG_ADVANCED,
3821 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3824 .label = "eventlog list",
3826 .p_class = P_GLOBAL,
3827 .ptr = &Globals.szEventLogs,
3830 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3833 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3836 .label = "add share command",
3838 .p_class = P_GLOBAL,
3839 .ptr = &Globals.szAddShareCommand,
3842 .flags = FLAG_ADVANCED,
3845 .label = "change share command",
3847 .p_class = P_GLOBAL,
3848 .ptr = &Globals.szChangeShareCommand,
3851 .flags = FLAG_ADVANCED,
3854 .label = "delete share command",
3856 .p_class = P_GLOBAL,
3857 .ptr = &Globals.szDeleteShareCommand,
3860 .flags = FLAG_ADVANCED,
3863 .label = "config file",
3865 .p_class = P_GLOBAL,
3866 .ptr = &Globals.szConfigFile,
3869 .flags = FLAG_HIDE|FLAG_META,
3874 .p_class = P_GLOBAL,
3875 .ptr = &Globals.szAutoServices,
3878 .flags = FLAG_ADVANCED,
3881 .label = "auto services",
3883 .p_class = P_GLOBAL,
3884 .ptr = &Globals.szAutoServices,
3887 .flags = FLAG_ADVANCED,
3890 .label = "lock directory",
3892 .p_class = P_GLOBAL,
3893 .ptr = &Globals.szLockDir,
3896 .flags = FLAG_ADVANCED,
3899 .label = "lock dir",
3901 .p_class = P_GLOBAL,
3902 .ptr = &Globals.szLockDir,
3908 .label = "state directory",
3910 .p_class = P_GLOBAL,
3911 .ptr = &Globals.szStateDir,
3914 .flags = FLAG_ADVANCED,
3917 .label = "cache directory",
3919 .p_class = P_GLOBAL,
3920 .ptr = &Globals.szCacheDir,
3923 .flags = FLAG_ADVANCED,
3926 .label = "pid directory",
3928 .p_class = P_GLOBAL,
3929 .ptr = &Globals.szPidDir,
3932 .flags = FLAG_ADVANCED,
3936 .label = "utmp directory",
3938 .p_class = P_GLOBAL,
3939 .ptr = &Globals.szUtmpDir,
3942 .flags = FLAG_ADVANCED,
3945 .label = "wtmp directory",
3947 .p_class = P_GLOBAL,
3948 .ptr = &Globals.szWtmpDir,
3951 .flags = FLAG_ADVANCED,
3956 .p_class = P_GLOBAL,
3957 .ptr = &Globals.bUtmp,
3960 .flags = FLAG_ADVANCED,
3964 .label = "default service",
3966 .p_class = P_GLOBAL,
3967 .ptr = &Globals.szDefaultService,
3970 .flags = FLAG_ADVANCED,
3975 .p_class = P_GLOBAL,
3976 .ptr = &Globals.szDefaultService,
3979 .flags = FLAG_ADVANCED,
3982 .label = "message command",
3984 .p_class = P_GLOBAL,
3985 .ptr = &Globals.szMsgCommand,
3988 .flags = FLAG_ADVANCED,
3991 .label = "dfree cache time",
3994 .ptr = &sDefault.iDfreeCacheTime,
3997 .flags = FLAG_ADVANCED,
4000 .label = "dfree command",
4003 .ptr = &sDefault.szDfree,
4006 .flags = FLAG_ADVANCED,
4009 .label = "get quota command",
4011 .p_class = P_GLOBAL,
4012 .ptr = &Globals.szGetQuota,
4015 .flags = FLAG_ADVANCED,
4018 .label = "set quota command",
4020 .p_class = P_GLOBAL,
4021 .ptr = &Globals.szSetQuota,
4024 .flags = FLAG_ADVANCED,
4027 .label = "remote announce",
4029 .p_class = P_GLOBAL,
4030 .ptr = &Globals.szRemoteAnnounce,
4033 .flags = FLAG_ADVANCED,
4036 .label = "remote browse sync",
4038 .p_class = P_GLOBAL,
4039 .ptr = &Globals.szRemoteBrowseSync,
4042 .flags = FLAG_ADVANCED,
4045 .label = "socket address",
4047 .p_class = P_GLOBAL,
4048 .ptr = &Globals.szSocketAddress,
4051 .flags = FLAG_ADVANCED,
4054 .label = "nmbd bind explicit broadcast",
4056 .p_class = P_GLOBAL,
4057 .ptr = &Globals.bNmbdBindExplicitBroadcast,
4060 .flags = FLAG_ADVANCED,
4063 .label = "homedir map",
4065 .p_class = P_GLOBAL,
4066 .ptr = &Globals.szNISHomeMapName,
4069 .flags = FLAG_ADVANCED,
4072 .label = "afs username map",
4074 .p_class = P_GLOBAL,
4075 .ptr = &Globals.szAfsUsernameMap,
4078 .flags = FLAG_ADVANCED,
4081 .label = "afs token lifetime",
4083 .p_class = P_GLOBAL,
4084 .ptr = &Globals.iAfsTokenLifetime,
4087 .flags = FLAG_ADVANCED,
4090 .label = "log nt token command",
4092 .p_class = P_GLOBAL,
4093 .ptr = &Globals.szLogNtTokenCommand,
4096 .flags = FLAG_ADVANCED,
4099 .label = "time offset",
4101 .p_class = P_GLOBAL,
4102 .ptr = &extra_time_offset,
4105 .flags = FLAG_ADVANCED,
4108 .label = "NIS homedir",
4110 .p_class = P_GLOBAL,
4111 .ptr = &Globals.bNISHomeMap,
4114 .flags = FLAG_ADVANCED,
4120 .ptr = &sDefault.valid,
4129 .ptr = &sDefault.szCopy,
4130 .special = handle_copy,
4138 .ptr = &sDefault.szInclude,
4139 .special = handle_include,
4141 .flags = FLAG_HIDE|FLAG_META,
4147 .ptr = &sDefault.szPreExec,
4150 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4156 .ptr = &sDefault.szPreExec,
4159 .flags = FLAG_ADVANCED,
4162 .label = "preexec close",
4165 .ptr = &sDefault.bPreexecClose,
4168 .flags = FLAG_ADVANCED | FLAG_SHARE,
4171 .label = "postexec",
4174 .ptr = &sDefault.szPostExec,
4177 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4180 .label = "root preexec",
4183 .ptr = &sDefault.szRootPreExec,
4186 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4189 .label = "root preexec close",
4192 .ptr = &sDefault.bRootpreexecClose,
4195 .flags = FLAG_ADVANCED | FLAG_SHARE,
4198 .label = "root postexec",
4201 .ptr = &sDefault.szRootPostExec,
4204 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4207 .label = "available",
4210 .ptr = &sDefault.bAvailable,
4213 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4216 .label = "registry shares",
4218 .p_class = P_GLOBAL,
4219 .ptr = &Globals.bRegistryShares,
4222 .flags = FLAG_ADVANCED,
4225 .label = "usershare allow guests",
4227 .p_class = P_GLOBAL,
4228 .ptr = &Globals.bUsershareAllowGuests,
4231 .flags = FLAG_ADVANCED,
4234 .label = "usershare max shares",
4236 .p_class = P_GLOBAL,
4237 .ptr = &Globals.iUsershareMaxShares,
4240 .flags = FLAG_ADVANCED,
4243 .label = "usershare owner only",
4245 .p_class = P_GLOBAL,
4246 .ptr = &Globals.bUsershareOwnerOnly,
4249 .flags = FLAG_ADVANCED,
4252 .label = "usershare path",
4254 .p_class = P_GLOBAL,
4255 .ptr = &Globals.szUsersharePath,
4258 .flags = FLAG_ADVANCED,
4261 .label = "usershare prefix allow list",
4263 .p_class = P_GLOBAL,
4264 .ptr = &Globals.szUsersharePrefixAllowList,
4267 .flags = FLAG_ADVANCED,
4270 .label = "usershare prefix deny list",
4272 .p_class = P_GLOBAL,
4273 .ptr = &Globals.szUsersharePrefixDenyList,
4276 .flags = FLAG_ADVANCED,
4279 .label = "usershare template share",
4281 .p_class = P_GLOBAL,
4282 .ptr = &Globals.szUsershareTemplateShare,
4285 .flags = FLAG_ADVANCED,
4291 .ptr = &sDefault.volume,
4294 .flags = FLAG_ADVANCED | FLAG_SHARE,
4300 .ptr = &sDefault.fstype,
4303 .flags = FLAG_ADVANCED | FLAG_SHARE,
4306 .label = "set directory",
4309 .ptr = &sDefault.bNo_set_dir,
4312 .flags = FLAG_ADVANCED | FLAG_SHARE,
4315 .label = "wide links",
4318 .ptr = &sDefault.bWidelinks,
4321 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4324 .label = "follow symlinks",
4327 .ptr = &sDefault.bSymlinks,
4330 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4333 .label = "dont descend",
4336 .ptr = &sDefault.szDontdescend,
4339 .flags = FLAG_ADVANCED | FLAG_SHARE,
4342 .label = "magic script",
4345 .ptr = &sDefault.szMagicScript,
4348 .flags = FLAG_ADVANCED | FLAG_SHARE,
4351 .label = "magic output",
4354 .ptr = &sDefault.szMagicOutput,
4357 .flags = FLAG_ADVANCED | FLAG_SHARE,
4360 .label = "delete readonly",
4363 .ptr = &sDefault.bDeleteReadonly,
4366 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4369 .label = "dos filemode",
4372 .ptr = &sDefault.bDosFilemode,
4375 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4378 .label = "dos filetimes",
4381 .ptr = &sDefault.bDosFiletimes,
4384 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4387 .label = "dos filetime resolution",
4390 .ptr = &sDefault.bDosFiletimeResolution,
4393 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4396 .label = "fake directory create times",
4399 .ptr = &sDefault.bFakeDirCreateTimes,
4402 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4405 .label = "async smb echo handler",
4407 .p_class = P_GLOBAL,
4408 .ptr = &Globals.bAsyncSMBEchoHandler,
4411 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4414 .label = "panic action",
4416 .p_class = P_GLOBAL,
4417 .ptr = &Globals.szPanicAction,
4420 .flags = FLAG_ADVANCED,
4423 .label = "perfcount module",
4425 .p_class = P_GLOBAL,
4426 .ptr = &Globals.szSMBPerfcountModule,
4429 .flags = FLAG_ADVANCED,
4432 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4435 .label = "vfs objects",
4438 .ptr = &sDefault.szVfsObjects,
4441 .flags = FLAG_ADVANCED | FLAG_SHARE,
4444 .label = "vfs object",
4447 .ptr = &sDefault.szVfsObjects,
4454 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4457 .label = "msdfs root",
4460 .ptr = &sDefault.bMSDfsRoot,
4463 .flags = FLAG_ADVANCED | FLAG_SHARE,
4466 .label = "msdfs proxy",
4469 .ptr = &sDefault.szMSDfsProxy,
4472 .flags = FLAG_ADVANCED | FLAG_SHARE,
4475 .label = "host msdfs",
4477 .p_class = P_GLOBAL,
4478 .ptr = &Globals.bHostMSDfs,
4481 .flags = FLAG_ADVANCED,
4484 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4487 .label = "passdb expand explicit",
4489 .p_class = P_GLOBAL,
4490 .ptr = &Globals.bPassdbExpandExplicit,
4493 .flags = FLAG_ADVANCED,
4496 .label = "idmap backend",
4498 .p_class = P_GLOBAL,
4499 .ptr = &Globals.szIdmapBackend,
4502 .flags = FLAG_ADVANCED,
4505 .label = "idmap alloc backend",
4507 .p_class = P_GLOBAL,
4508 .ptr = &Globals.szIdmapAllocBackend,
4511 .flags = FLAG_ADVANCED,
4514 .label = "idmap cache time",
4516 .p_class = P_GLOBAL,
4517 .ptr = &Globals.iIdmapCacheTime,
4520 .flags = FLAG_ADVANCED,
4523 .label = "idmap negative cache time",
4525 .p_class = P_GLOBAL,
4526 .ptr = &Globals.iIdmapNegativeCacheTime,
4529 .flags = FLAG_ADVANCED,
4532 .label = "idmap uid",
4534 .p_class = P_GLOBAL,
4535 .ptr = &Globals.szIdmapUID,
4536 .special = handle_idmap_uid,
4538 .flags = FLAG_ADVANCED,
4541 .label = "winbind uid",
4543 .p_class = P_GLOBAL,
4544 .ptr = &Globals.szIdmapUID,
4545 .special = handle_idmap_uid,
4550 .label = "idmap gid",
4552 .p_class = P_GLOBAL,
4553 .ptr = &Globals.szIdmapGID,
4554 .special = handle_idmap_gid,
4556 .flags = FLAG_ADVANCED,
4559 .label = "winbind gid",
4561 .p_class = P_GLOBAL,
4562 .ptr = &Globals.szIdmapGID,
4563 .special = handle_idmap_gid,
4568 .label = "template homedir",
4570 .p_class = P_GLOBAL,
4571 .ptr = &Globals.szTemplateHomedir,
4574 .flags = FLAG_ADVANCED,
4577 .label = "template shell",
4579 .p_class = P_GLOBAL,
4580 .ptr = &Globals.szTemplateShell,
4583 .flags = FLAG_ADVANCED,
4586 .label = "winbind separator",
4588 .p_class = P_GLOBAL,
4589 .ptr = &Globals.szWinbindSeparator,
4592 .flags = FLAG_ADVANCED,
4595 .label = "winbind cache time",
4597 .p_class = P_GLOBAL,
4598 .ptr = &Globals.winbind_cache_time,
4601 .flags = FLAG_ADVANCED,
4604 .label = "winbind reconnect delay",
4606 .p_class = P_GLOBAL,
4607 .ptr = &Globals.winbind_reconnect_delay,
4610 .flags = FLAG_ADVANCED,
4613 .label = "winbind enum users",
4615 .p_class = P_GLOBAL,
4616 .ptr = &Globals.bWinbindEnumUsers,
4619 .flags = FLAG_ADVANCED,
4622 .label = "winbind enum groups",
4624 .p_class = P_GLOBAL,
4625 .ptr = &Globals.bWinbindEnumGroups,
4628 .flags = FLAG_ADVANCED,
4631 .label = "winbind use default domain",
4633 .p_class = P_GLOBAL,
4634 .ptr = &Globals.bWinbindUseDefaultDomain,
4637 .flags = FLAG_ADVANCED,
4640 .label = "winbind trusted domains only",
4642 .p_class = P_GLOBAL,
4643 .ptr = &Globals.bWinbindTrustedDomainsOnly,
4646 .flags = FLAG_ADVANCED,
4649 .label = "winbind nested groups",
4651 .p_class = P_GLOBAL,
4652 .ptr = &Globals.bWinbindNestedGroups,
4655 .flags = FLAG_ADVANCED,
4658 .label = "winbind expand groups",
4660 .p_class = P_GLOBAL,
4661 .ptr = &Globals.winbind_expand_groups,
4664 .flags = FLAG_ADVANCED,
4667 .label = "winbind nss info",
4669 .p_class = P_GLOBAL,
4670 .ptr = &Globals.szWinbindNssInfo,
4673 .flags = FLAG_ADVANCED,
4676 .label = "winbind refresh tickets",
4678 .p_class = P_GLOBAL,
4679 .ptr = &Globals.bWinbindRefreshTickets,
4682 .flags = FLAG_ADVANCED,
4685 .label = "winbind offline logon",
4687 .p_class = P_GLOBAL,
4688 .ptr = &Globals.bWinbindOfflineLogon,
4691 .flags = FLAG_ADVANCED,
4694 .label = "winbind normalize names",
4696 .p_class = P_GLOBAL,
4697 .ptr = &Globals.bWinbindNormalizeNames,
4700 .flags = FLAG_ADVANCED,
4703 .label = "winbind rpc only",
4705 .p_class = P_GLOBAL,
4706 .ptr = &Globals.bWinbindRpcOnly,
4709 .flags = FLAG_ADVANCED,
4712 .label = "create krb5 conf",
4714 .p_class = P_GLOBAL,
4715 .ptr = &Globals.bCreateKrb5Conf,
4718 .flags = FLAG_ADVANCED,
4721 {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
4724 /***************************************************************************
4725 Initialise the sDefault parameter structure for the printer values.
4726 ***************************************************************************/
4728 static void init_printer_values(struct service *pService)
4730 /* choose defaults depending on the type of printing */
4731 switch (pService->iPrinting) {
4736 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4737 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4738 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4743 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4744 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4745 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4746 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4747 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4748 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4749 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4755 /* set the lpq command to contain the destination printer
4756 name only. This is used by cups_queue_get() */
4757 string_set(&pService->szLpqcommand, "%p");
4758 string_set(&pService->szLprmcommand, "");
4759 string_set(&pService->szPrintcommand, "");
4760 string_set(&pService->szLppausecommand, "");
4761 string_set(&pService->szLpresumecommand, "");
4762 string_set(&pService->szQueuepausecommand, "");
4763 string_set(&pService->szQueueresumecommand, "");
4765 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4766 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4767 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4768 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4769 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4770 string_set(&pService->szQueuepausecommand, "disable '%p'");
4771 string_set(&pService->szQueueresumecommand, "enable '%p'");
4772 #endif /* HAVE_CUPS */
4777 string_set(&pService->szLpqcommand, "lpstat -o%p");
4778 string_set(&pService->szLprmcommand, "cancel %p-%j");
4779 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4780 string_set(&pService->szQueuepausecommand, "disable %p");
4781 string_set(&pService->szQueueresumecommand, "enable %p");
4783 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4784 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4789 string_set(&pService->szLpqcommand, "lpq -P%p");
4790 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4791 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4797 string_set(&pService->szPrintcommand, "vlp print %p %s");
4798 string_set(&pService->szLpqcommand, "vlp lpq %p");
4799 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
4800 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
4801 string_set(&pService->szLpresumecommand, "vlp lpresume %p %j");
4802 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
4803 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
4805 #endif /* DEVELOPER */
4810 * Function to return the default value for the maximum number of open
4811 * file descriptors permitted. This function tries to consult the
4812 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4813 * the smaller of those.
4815 static int max_open_files(void)
4817 int sysctl_max = MAX_OPEN_FILES;
4818 int rlimit_max = MAX_OPEN_FILES;
4820 #ifdef HAVE_SYSCTLBYNAME
4822 size_t size = sizeof(sysctl_max);
4823 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4828 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4834 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4835 rlimit_max = rl.rlim_cur;
4837 #if defined(RLIM_INFINITY)
4838 if(rl.rlim_cur == RLIM_INFINITY)
4839 rlimit_max = MAX_OPEN_FILES;
4844 if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4845 DEBUG(2,("max_open_files: sysctl_max (%d) below "
4846 "minimum Windows limit (%d)\n",
4848 MIN_OPEN_FILES_WINDOWS));
4849 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4852 if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4853 DEBUG(2,("rlimit_max: rlimit_max (%d) below "
4854 "minimum Windows limit (%d)\n",
4856 MIN_OPEN_FILES_WINDOWS));
4857 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4860 return MIN(sysctl_max, rlimit_max);
4864 * Common part of freeing allocated data for one parameter.
4866 static void free_one_parameter_common(void *parm_ptr,
4867 struct parm_struct parm)
4869 if ((parm.type == P_STRING) ||
4870 (parm.type == P_USTRING))
4872 string_free((char**)parm_ptr);
4873 } else if (parm.type == P_LIST) {
4874 TALLOC_FREE(*((char***)parm_ptr));
4879 * Free the allocated data for one parameter for a share
4880 * given as a service struct.
4882 static void free_one_parameter(struct service *service,
4883 struct parm_struct parm)
4887 if (parm.p_class != P_LOCAL) {
4891 parm_ptr = lp_local_ptr(service, parm.ptr);
4893 free_one_parameter_common(parm_ptr, parm);
4897 * Free the allocated parameter data of a share given
4898 * as a service struct.
4900 static void free_parameters(struct service *service)
4904 for (i=0; parm_table[i].label; i++) {
4905 free_one_parameter(service, parm_table[i]);
4910 * Free the allocated data for one parameter for a given share
4911 * specified by an snum.
4913 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4917 if (parm.ptr == NULL) {
4922 parm_ptr = parm.ptr;
4923 } else if (parm.p_class != P_LOCAL) {
4926 parm_ptr = lp_local_ptr_by_snum(snum, parm.ptr);
4929 free_one_parameter_common(parm_ptr, parm);
4933 * Free the allocated parameter data for a share specified
4936 static void free_parameters_by_snum(int snum)
4940 for (i=0; parm_table[i].label; i++) {
4941 free_one_parameter_by_snum(snum, parm_table[i]);
4946 * Free the allocated global parameters.
4948 static void free_global_parameters(void)
4950 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4953 /***************************************************************************
4954 Initialise the global parameter structure.
4955 ***************************************************************************/
4957 static void init_globals(bool first_time_only)
4959 static bool done_init = False;
4963 /* If requested to initialize only once and we've already done it... */
4964 if (first_time_only && done_init) {
4965 /* ... then we have nothing more to do */
4970 /* The logfile can be set before this is invoked. Free it if so. */
4971 if (Globals.szLogFile != NULL) {
4972 string_free(&Globals.szLogFile);
4973 Globals.szLogFile = NULL;
4977 free_global_parameters();
4980 memset((void *)&Globals, '\0', sizeof(Globals));
4982 for (i = 0; parm_table[i].label; i++) {
4983 if ((parm_table[i].type == P_STRING ||
4984 parm_table[i].type == P_USTRING) &&
4987 string_set((char **)parm_table[i].ptr, "");
4991 string_set(&sDefault.fstype, FSTYPE_STRING);
4992 string_set(&sDefault.szPrintjobUsername, "%U");
4994 init_printer_values(&sDefault);
4997 DEBUG(3, ("Initialising global parameters\n"));
4999 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
5000 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
5002 /* use the new 'hash2' method by default, with a prefix of 1 */
5003 string_set(&Globals.szManglingMethod, "hash2");
5004 Globals.mangle_prefix = 1;
5006 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
5008 /* using UTF8 by default allows us to support all chars */
5009 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
5011 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
5012 /* If the system supports nl_langinfo(), try to grab the value
5013 from the user's locale */
5014 string_set(&Globals.display_charset, "LOCALE");
5016 string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
5019 /* Use codepage 850 as a default for the dos character set */
5020 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
5023 * Allow the default PASSWD_CHAT to be overridden in local.h.
5025 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
5027 set_global_myname(myhostname());
5028 string_set(&Globals.szNetbiosName,global_myname());
5030 set_global_myworkgroup(WORKGROUP);
5031 string_set(&Globals.szWorkgroup, lp_workgroup());
5033 string_set(&Globals.szPasswdProgram, "");
5034 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
5035 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
5036 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
5037 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
5038 string_set(&Globals.szSocketAddress, "0.0.0.0");
5040 * By default support explicit binding to broadcast
5043 Globals.bNmbdBindExplicitBroadcast = true;
5045 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
5046 smb_panic("init_globals: ENOMEM");
5048 string_set(&Globals.szServerString, s);
5050 if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
5051 DEFAULT_MINOR_VERSION) < 0) {
5052 smb_panic("init_globals: ENOMEM");
5054 string_set(&Globals.szAnnounceVersion, s);
5057 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
5060 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
5062 string_set(&Globals.szLogonDrive, "");
5063 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
5064 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
5065 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
5067 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
5068 string_set(&Globals.szPasswordServer, "*");
5070 Globals.AlgorithmicRidBase = BASE_RID;
5072 Globals.bLoadPrinters = True;
5073 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
5075 Globals.ConfigBackend = config_backend;
5077 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
5078 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
5079 Globals.max_xmit = 0x4104;
5080 Globals.max_mux = 50; /* This is *needed* for profile support. */
5081 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
5082 Globals.bDisableSpoolss = False;
5083 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
5084 Globals.pwordlevel = 0;
5085 Globals.unamelevel = 0;
5086 Globals.deadtime = 0;
5087 Globals.getwd_cache = true;
5088 Globals.bLargeReadwrite = True;
5089 Globals.max_log_size = 5000;
5090 Globals.max_open_files = max_open_files();
5091 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
5092 Globals.maxprotocol = PROTOCOL_NT1;
5093 Globals.minprotocol = PROTOCOL_CORE;
5094 Globals.security = SEC_USER;
5095 Globals.paranoid_server_security = True;
5096 Globals.bEncryptPasswords = True;
5097 Globals.bUpdateEncrypt = False;
5098 Globals.clientSchannel = Auto;
5099 Globals.serverSchannel = Auto;
5100 Globals.bReadRaw = True;
5101 Globals.bWriteRaw = True;
5102 Globals.bNullPasswords = False;
5103 Globals.bObeyPamRestrictions = False;
5105 Globals.bSyslogOnly = False;
5106 Globals.bTimestampLogs = True;
5107 string_set(&Globals.szLogLevel, "0");
5108 Globals.bDebugPrefixTimestamp = False;
5109 Globals.bDebugHiresTimestamp = true;
5110 Globals.bDebugPid = False;
5111 Globals.bDebugUid = False;
5112 Globals.bDebugClass = False;
5113 Globals.bEnableCoreFiles = True;
5114 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
5115 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
5116 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
5117 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
5118 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
5119 Globals.lm_interval = 60;
5120 Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
5121 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
5122 Globals.bNISHomeMap = False;
5123 #ifdef WITH_NISPLUS_HOME
5124 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
5126 string_set(&Globals.szNISHomeMapName, "auto.home");
5129 Globals.bTimeServer = False;
5130 Globals.bBindInterfacesOnly = False;
5131 Globals.bUnixPasswdSync = False;
5132 Globals.bPamPasswordChange = False;
5133 Globals.bPasswdChatDebug = False;
5134 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
5135 Globals.bNTPipeSupport = True; /* Do NT pipes by default. */
5136 Globals.bNTStatusSupport = True; /* Use NT status by default. */
5137 Globals.bStatCache = True; /* use stat cache by default */
5138 Globals.iMaxStatCacheSize = 256; /* 256k by default */
5139 Globals.restrict_anonymous = 0;
5140 Globals.bClientLanManAuth = False; /* Do NOT use the LanMan hash if it is available */
5141 Globals.bClientPlaintextAuth = False; /* Do NOT use a plaintext password even if is requested by the server */
5142 Globals.bLanmanAuth = False; /* Do NOT use the LanMan hash, even if it is supplied */
5143 Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
5144 Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
5145 /* Note, that we will use NTLM2 session security (which is different), if it is available */
5147 Globals.map_to_guest = 0; /* By Default, "Never" */
5148 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
5149 Globals.enhanced_browsing = true;
5150 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
5151 #ifdef MMAP_BLACKLIST
5152 Globals.bUseMmap = False;
5154 Globals.bUseMmap = True;
5156 Globals.bUnixExtensions = True;
5157 Globals.bResetOnZeroVC = False;
5158 Globals.bLogWriteableFilesOnExit = False;
5159 Globals.bCreateKrb5Conf = true;
5161 /* hostname lookups can be very expensive and are broken on
5162 a large number of sites (tridge) */
5163 Globals.bHostnameLookups = False;
5165 string_set(&Globals.szPassdbBackend, "tdbsam");
5166 string_set(&Globals.szLdapSuffix, "");
5167 string_set(&Globals.szLdapMachineSuffix, "");
5168 string_set(&Globals.szLdapUserSuffix, "");
5169 string_set(&Globals.szLdapGroupSuffix, "");
5170 string_set(&Globals.szLdapIdmapSuffix, "");
5172 string_set(&Globals.szLdapAdminDn, "");
5173 Globals.ldap_ssl = LDAP_SSL_START_TLS;
5174 Globals.ldap_ssl_ads = False;
5175 Globals.ldap_deref = -1;
5176 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
5177 Globals.ldap_delete_dn = False;
5178 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
5179 Globals.ldap_follow_referral = Auto;
5180 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
5181 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
5182 Globals.ldap_page_size = LDAP_PAGE_SIZE;
5184 Globals.ldap_debug_level = 0;
5185 Globals.ldap_debug_threshold = 10;
5187 /* This is what we tell the afs client. in reality we set the token
5188 * to never expire, though, when this runs out the afs client will
5189 * forget the token. Set to 0 to get NEVERDATE.*/
5190 Globals.iAfsTokenLifetime = 604800;
5191 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
5193 /* these parameters are set to defaults that are more appropriate
5194 for the increasing samba install base:
5196 as a member of the workgroup, that will possibly become a
5197 _local_ master browser (lm = True). this is opposed to a forced
5198 local master browser startup (pm = True).
5200 doesn't provide WINS server service by default (wsupp = False),
5201 and doesn't provide domain master browser services by default, either.
5205 Globals.bMsAddPrinterWizard = True;
5206 Globals.os_level = 20;
5207 Globals.bLocalMaster = True;
5208 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
5209 Globals.bDomainLogons = False;
5210 Globals.bBrowseList = True;
5211 Globals.bWINSsupport = False;
5212 Globals.bWINSproxy = False;
5214 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
5215 Globals.InitLogonDelay = 100; /* 100 ms default delay */
5217 Globals.bDNSproxy = True;
5219 /* this just means to use them if they exist */
5220 Globals.bKernelOplocks = True;
5222 Globals.bAllowTrustedDomains = True;
5223 string_set(&Globals.szIdmapBackend, "tdb");
5225 string_set(&Globals.szTemplateShell, "/bin/false");
5226 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
5227 string_set(&Globals.szWinbindSeparator, "\\");
5229 string_set(&Globals.szCupsServer, "");
5230 string_set(&Globals.szIPrintServer, "");
5232 string_set(&Globals.ctdbdSocket, "");
5233 Globals.szClusterAddresses = NULL;
5234 Globals.clustering = False;
5235 Globals.ctdb_timeout = 0;
5236 Globals.ctdb_locktime_warn_threshold = 0;
5238 Globals.winbind_cache_time = 300; /* 5 minutes */
5239 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
5240 Globals.bWinbindEnumUsers = False;
5241 Globals.bWinbindEnumGroups = False;
5242 Globals.bWinbindUseDefaultDomain = False;
5243 Globals.bWinbindTrustedDomainsOnly = False;
5244 Globals.bWinbindNestedGroups = True;
5245 Globals.winbind_expand_groups = 1;
5246 Globals.szWinbindNssInfo = str_list_make_v3(talloc_autofree_context(), "template", NULL);
5247 Globals.bWinbindRefreshTickets = False;
5248 Globals.bWinbindOfflineLogon = False;
5250 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
5251 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
5253 Globals.bPassdbExpandExplicit = False;
5255 Globals.name_cache_timeout = 660; /* In seconds */
5257 Globals.bUseSpnego = True;
5258 Globals.bClientUseSpnego = True;
5260 Globals.client_signing = Auto;
5261 Globals.server_signing = False;
5263 Globals.bDeferSharingViolations = True;
5264 string_set(&Globals.smb_ports, SMB_PORTS);
5266 Globals.bEnablePrivileges = True;
5267 Globals.bHostMSDfs = True;
5268 Globals.bASUSupport = False;
5270 /* User defined shares. */
5271 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5272 smb_panic("init_globals: ENOMEM");
5274 string_set(&Globals.szUsersharePath, s);
5276 string_set(&Globals.szUsershareTemplateShare, "");
5277 Globals.iUsershareMaxShares = 0;
5278 /* By default disallow sharing of directories not owned by the sharer. */
5279 Globals.bUsershareOwnerOnly = True;
5280 /* By default disallow guest access to usershares. */
5281 Globals.bUsershareAllowGuests = False;
5283 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5285 /* By default no shares out of the registry */
5286 Globals.bRegistryShares = False;
5288 Globals.iminreceivefile = 0;
5290 Globals.bMapUntrustedToDomain = false;
5292 Globals.ismb2_max_read = 1024*1024;
5293 Globals.ismb2_max_write = 1024*1024;
5294 Globals.ismb2_max_trans = 1024*1024;
5297 /*******************************************************************
5298 Convenience routine to grab string parameters into temporary memory
5299 and run standard_sub_basic on them. The buffers can be written to by
5300 callers without affecting the source string.
5301 ********************************************************************/
5303 static char *lp_string(const char *s)
5306 TALLOC_CTX *ctx = talloc_tos();
5308 /* The follow debug is useful for tracking down memory problems
5309 especially if you have an inner loop that is calling a lp_*()
5310 function that returns a string. Perhaps this debug should be
5311 present all the time? */
5314 DEBUG(10, ("lp_string(%s)\n", s));
5320 ret = talloc_sub_basic(ctx,
5321 get_current_username(),
5322 current_user_info.domain,
5324 if (trim_char(ret, '\"', '\"')) {
5325 if (strchr(ret,'\"') != NULL) {
5327 ret = talloc_sub_basic(ctx,
5328 get_current_username(),
5329 current_user_info.domain,
5337 In this section all the functions that are used to access the
5338 parameters from the rest of the program are defined
5341 #define FN_GLOBAL_STRING(fn_name,ptr) \
5342 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
5343 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5344 const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
5345 #define FN_GLOBAL_LIST(fn_name,ptr) \
5346 const char **fn_name(void) {return(*(const char ***)(ptr));}
5347 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5348 bool fn_name(void) {return(*(bool *)(ptr));}
5349 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5350 char fn_name(void) {return(*(char *)(ptr));}
5351 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5352 int fn_name(void) {return(*(int *)(ptr));}
5354 #define FN_LOCAL_STRING(fn_name,val) \
5355 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5356 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5357 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5358 #define FN_LOCAL_LIST(fn_name,val) \
5359 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5360 #define FN_LOCAL_BOOL(fn_name,val) \
5361 bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5362 #define FN_LOCAL_INTEGER(fn_name,val) \
5363 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5365 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5366 bool fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5367 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5368 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5369 #define FN_LOCAL_PARM_STRING(fn_name,val) \
5370 char *fn_name(const struct share_params *p) {return(lp_string((LP_SNUM_OK(p->service) && ServicePtrs[(p->service)]->val) ? ServicePtrs[(p->service)]->val : sDefault.val));}
5371 #define FN_LOCAL_CHAR(fn_name,val) \
5372 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5374 FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
5375 FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
5376 FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
5377 FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
5378 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
5379 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
5380 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
5381 FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
5382 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
5383 FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
5384 FN_GLOBAL_STRING(lp_addport_cmd, &Globals.szAddPortCommand)
5385 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
5386 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
5387 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
5388 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
5389 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
5390 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5391 * build process or in smb.conf, we use that value. Otherwise they
5392 * default to the value of lp_lockdir(). */
5393 char *lp_statedir(void) {
5394 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5395 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5396 return(lp_string(*(char **)(&Globals.szStateDir) ?
5397 *(char **)(&Globals.szStateDir) : ""));
5399 return(lp_string(*(char **)(&Globals.szLockDir) ?
5400 *(char **)(&Globals.szLockDir) : ""));
5402 char *lp_cachedir(void) {
5403 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5404 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5405 return(lp_string(*(char **)(&Globals.szCacheDir) ?
5406 *(char **)(&Globals.szCacheDir) : ""));
5408 return(lp_string(*(char **)(&Globals.szLockDir) ?
5409 *(char **)(&Globals.szLockDir) : ""));
5411 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
5412 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
5413 FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
5414 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
5415 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
5416 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
5417 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
5418 FN_GLOBAL_STRING(lp_perfcount_module, &Globals.szSMBPerfcountModule)
5419 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
5420 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
5421 FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
5422 FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
5423 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
5424 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
5425 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
5426 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
5427 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
5428 FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
5429 FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
5430 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
5431 FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
5432 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
5433 FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
5434 FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
5435 FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
5436 FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
5437 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
5438 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
5439 FN_GLOBAL_BOOL(lp_nmbd_bind_explicit_broadcast, &Globals.bNmbdBindExplicitBroadcast)
5440 FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
5441 FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
5442 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
5443 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
5444 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
5445 /* FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
5446 * lp_passdb_backend() should be replace by the this macro again after
5449 const char *lp_passdb_backend(void)
5451 char *delim, *quote;
5453 delim = strchr( Globals.szPassdbBackend, ' ');
5454 /* no space at all */
5455 if (delim == NULL) {
5459 quote = strchr(Globals.szPassdbBackend, '"');
5460 /* no quote char or non in the first part */
5461 if (quote == NULL || quote > delim) {
5466 quote = strchr(quote+1, '"');
5467 if (quote == NULL) {
5468 DEBUG(0, ("WARNING: Your 'passdb backend' configuration is invalid due to a missing second \" char.\n"));
5470 } else if (*(quote+1) == '\0') {
5471 /* space, fitting quote char, and one backend only */
5474 /* terminate string after the fitting quote char */
5479 DEBUG(0, ("WARNING: Your 'passdb backend' configuration includes multiple backends. This\n"
5480 "is deprecated since Samba 3.0.23. Please check WHATSNEW.txt or the section 'Passdb\n"
5481 "Changes' from the ChangeNotes as part of the Samba HOWTO collection. Only the first\n"
5482 "backend (%s) is used. The rest is ignored.\n", Globals.szPassdbBackend));
5485 return Globals.szPassdbBackend;
5487 FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
5488 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
5489 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
5490 FN_GLOBAL_STRING(lp_renameuser_script, &Globals.szRenameUserScript)
5491 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
5493 FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
5494 FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
5495 FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
5496 FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
5497 FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
5498 FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
5500 FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
5502 FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
5503 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
5504 FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
5505 FN_GLOBAL_INTEGER(lp_username_map_cache_time, &Globals.iUsernameMapCacheTime)
5507 FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
5509 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
5510 FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
5511 FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
5512 FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
5513 FN_GLOBAL_INTEGER(lp_acl_compatibility, &Globals.iAclCompat)
5514 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
5515 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
5516 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
5517 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
5518 FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
5519 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups)
5520 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets)
5521 FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon)
5522 FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames)
5523 FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
5524 FN_GLOBAL_BOOL(lp_create_krb5_conf, &Globals.bCreateKrb5Conf)
5526 FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
5527 FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)
5528 FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
5529 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
5530 FN_GLOBAL_INTEGER(lp_keepalive, &Globals.iKeepalive)
5531 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit)
5533 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
5534 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
5535 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
5536 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, &Globals.ldap_ssl_ads)
5537 FN_GLOBAL_INTEGER(lp_ldap_deref, &Globals.ldap_deref)
5538 FN_GLOBAL_INTEGER(lp_ldap_follow_referral, &Globals.ldap_follow_referral)
5539 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
5540 FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
5541 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
5542 FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
5543 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, &Globals.ldap_connection_timeout)
5544 FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
5545 FN_GLOBAL_INTEGER(lp_ldap_debug_level, &Globals.ldap_debug_level)
5546 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, &Globals.ldap_debug_threshold)
5547 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
5548 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
5549 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
5550 FN_GLOBAL_STRING(lp_usershare_path, &Globals.szUsersharePath)
5551 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, &Globals.szUsersharePrefixAllowList)
5552 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, &Globals.szUsersharePrefixDenyList)
5554 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
5556 FN_GLOBAL_BOOL(lp_registry_shares, &Globals.bRegistryShares)
5557 FN_GLOBAL_BOOL(lp_usershare_allow_guests, &Globals.bUsershareAllowGuests)
5558 FN_GLOBAL_BOOL(lp_usershare_owner_only, &Globals.bUsershareOwnerOnly)
5559 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
5560 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
5561 FN_GLOBAL_BOOL(lp_log_writeable_files_on_exit,
5562 &Globals.bLogWriteableFilesOnExit)
5563 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
5564 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
5565 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
5566 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
5567 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
5568 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
5569 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
5570 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, &Globals.szInitLogonDelayedHosts)
5571 FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
5572 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
5573 FN_GLOBAL_BOOL(_lp_readraw, &Globals.bReadRaw)
5574 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
5575 FN_GLOBAL_BOOL(_lp_writeraw, &Globals.bWriteRaw)
5576 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
5577 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
5578 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
5579 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
5580 FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
5581 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
5582 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
5583 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
5584 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
5585 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
5586 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
5587 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
5588 FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
5589 FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
5590 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
5591 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
5592 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
5593 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
5594 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
5595 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
5596 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
5597 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
5598 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
5599 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
5600 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
5601 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
5602 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
5603 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, &Globals.bMapUntrustedToDomain)
5604 FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
5605 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
5606 FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
5607 FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
5608 FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
5609 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
5610 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
5611 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
5612 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
5613 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
5614 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
5615 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
5616 FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
5617 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
5618 FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
5619 FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
5620 FN_GLOBAL_STRING(lp_dedicated_keytab_file, &Globals.szDedicatedKeytabFile)
5621 FN_GLOBAL_INTEGER(lp_kerberos_method, &Globals.iKerberosMethod)
5622 FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
5623 FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
5624 FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport)
5625 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
5626 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
5627 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
5628 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
5629 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
5630 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
5631 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, &Globals.open_files_db_hash_size)
5632 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
5633 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
5634 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
5635 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
5636 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
5637 FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
5638 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
5639 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
5640 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
5641 FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
5642 FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
5643 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
5644 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
5645 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
5646 FN_GLOBAL_BOOL(_lp_disable_spoolss, &Globals.bDisableSpoolss)
5647 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
5648 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
5649 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
5650 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
5651 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
5652 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
5653 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
5654 FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
5655 FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
5656 FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
5657 FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
5658 FN_GLOBAL_INTEGER(lp_smb2_max_read, &Globals.ismb2_max_read)
5659 FN_GLOBAL_INTEGER(lp_smb2_max_write, &Globals.ismb2_max_write)
5660 FN_GLOBAL_INTEGER(lp_smb2_max_trans, &Globals.ismb2_max_trans)
5662 FN_LOCAL_STRING(lp_preexec, szPreExec)
5663 FN_LOCAL_STRING(lp_postexec, szPostExec)
5664 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
5665 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
5666 FN_LOCAL_STRING(lp_servicename, szService)
5667 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
5668 FN_LOCAL_STRING(lp_pathname, szPath)
5669 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
5670 FN_LOCAL_STRING(lp_username, szUsername)
5671 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
5672 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
5673 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
5674 FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
5675 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
5676 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
5677 int lp_cups_encrypt(void)
5680 #ifdef HAVE_HTTPCONNECTENCRYPT
5681 switch (Globals.CupsEncrypt) {
5683 result = HTTP_ENCRYPT_REQUIRED;
5686 result = HTTP_ENCRYPT_ALWAYS;
5689 result = HTTP_ENCRYPT_NEVER;
5695 FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
5696 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
5697 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
5698 FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
5699 FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
5700 FN_GLOBAL_INTEGER(lp_ctdb_timeout, &Globals.ctdb_timeout)
5701 FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, &Globals.ctdb_locktime_warn_threshold)
5702 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
5703 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
5704 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
5705 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
5706 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
5707 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
5708 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
5709 static FN_LOCAL_STRING(_lp_printername, szPrintername)
5710 FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
5711 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
5712 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
5713 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
5714 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
5715 FN_LOCAL_STRING(lp_comment, comment)
5716 FN_LOCAL_STRING(lp_force_user, force_user)
5717 FN_LOCAL_STRING(lp_force_group, force_group)
5718 FN_LOCAL_LIST(lp_readlist, readlist)
5719 FN_LOCAL_LIST(lp_writelist, writelist)
5720 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
5721 FN_LOCAL_STRING(lp_fstype, fstype)
5722 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
5723 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
5724 static FN_LOCAL_STRING(lp_volume, volume)
5725 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
5726 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
5727 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
5728 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
5729 FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
5730 FN_LOCAL_STRING(lp_dfree_command, szDfree)
5731 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
5732 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
5733 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
5734 FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
5735 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
5736 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
5737 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
5738 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
5739 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
5740 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
5741 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
5742 FN_LOCAL_BOOL(lp_access_based_share_enum, bAccessBasedShareEnum)
5743 FN_LOCAL_BOOL(lp_readonly, bRead_only)
5744 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
5745 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
5746 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
5747 FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
5748 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
5749 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
5750 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
5751 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
5752 FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
5753 FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
5754 FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
5755 FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
5756 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
5757 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
5758 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
5759 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
5760 FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames)
5761 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
5762 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
5763 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
5764 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
5765 FN_LOCAL_BOOL(lp_map_system, bMap_system)
5766 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
5767 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
5768 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
5769 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
5770 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
5771 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
5772 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
5773 FN_GLOBAL_BOOL(lp_async_smb_echo_handler, &Globals.bAsyncSMBEchoHandler)
5774 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
5775 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
5776 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
5777 FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
5778 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
5779 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
5780 FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
5781 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
5782 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
5783 FN_LOCAL_BOOL(lp_ea_support, bEASupport)
5784 FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
5785 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
5786 FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
5787 FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
5788 FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
5789 FN_LOCAL_BOOL(lp_acl_group_control, bAclGroupControl)
5790 FN_LOCAL_BOOL(lp_acl_map_full_control, bAclMapFullControl)
5791 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
5792 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
5793 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
5794 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
5795 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
5796 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
5797 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
5798 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
5799 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
5800 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
5801 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
5802 FN_LOCAL_INTEGER(lp_printing, iPrinting)
5803 FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
5804 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
5805 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
5806 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
5807 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
5808 FN_LOCAL_INTEGER(lp_dfree_cache_time, iDfreeCacheTime)
5809 FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
5810 FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
5811 FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
5812 FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
5813 FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
5814 FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
5815 FN_LOCAL_CHAR(lp_magicchar, magic_char)
5816 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
5817 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
5818 FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
5819 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
5820 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
5821 FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
5822 FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
5823 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
5825 /* local prototypes */
5827 static int map_parameter(const char *pszParmName);
5828 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5829 static const char *get_boolean(bool bool_value);
5830 static int getservicebyname(const char *pszServiceName,
5831 struct service *pserviceDest);
5832 static void copy_service(struct service *pserviceDest,
5833 struct service *pserviceSource,
5834 struct bitmap *pcopymapDest);
5835 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5837 static bool do_section(const char *pszSectionName, void *userdata);
5838 static void init_copymap(struct service *pservice);
5839 static bool hash_a_service(const char *name, int number);
5840 static void free_service_byindex(int iService);
5841 static void free_param_opts(struct param_opt_struct **popts);
5842 static void show_parameter(int parmIndex);
5843 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5846 * This is a helper function for parametrical options support. It returns a
5847 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5848 * parametrical functions are quite simple
5850 static struct param_opt_struct *get_parametrics(int snum, const char *type,
5853 bool global_section = False;
5855 struct param_opt_struct *data;
5857 if (snum >= iNumServices) return NULL;
5860 data = Globals.param_opt;
5861 global_section = True;
5863 data = ServicePtrs[snum]->param_opt;
5866 if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
5867 DEBUG(0,("asprintf failed!\n"));
5872 if (strwicmp(data->key, param_key) == 0) {
5873 string_free(¶m_key);
5879 if (!global_section) {
5880 /* Try to fetch the same option but from globals */
5881 /* but only if we are not already working with Globals */
5882 data = Globals.param_opt;
5884 if (strwicmp(data->key, param_key) == 0) {
5885 string_free(¶m_key);
5892 string_free(¶m_key);
5898 #define MISSING_PARAMETER(name) \
5899 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5901 /*******************************************************************
5902 convenience routine to return int parameters.
5903 ********************************************************************/
5904 static int lp_int(const char *s)
5908 MISSING_PARAMETER(lp_int);
5912 return (int)strtol(s, NULL, 0);
5915 /*******************************************************************
5916 convenience routine to return unsigned long parameters.
5917 ********************************************************************/
5918 static unsigned long lp_ulong(const char *s)
5922 MISSING_PARAMETER(lp_ulong);
5926 return strtoul(s, NULL, 0);
5929 /*******************************************************************
5930 convenience routine to return boolean parameters.
5931 ********************************************************************/
5932 static bool lp_bool(const char *s)
5937 MISSING_PARAMETER(lp_bool);
5941 if (!set_boolean(s, &ret)) {
5942 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5949 /*******************************************************************
5950 convenience routine to return enum parameters.
5951 ********************************************************************/
5952 static int lp_enum(const char *s,const struct enum_list *_enum)
5956 if (!s || !*s || !_enum) {
5957 MISSING_PARAMETER(lp_enum);
5961 for (i=0; _enum[i].name; i++) {
5962 if (strequal(_enum[i].name,s))
5963 return _enum[i].value;
5966 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5970 #undef MISSING_PARAMETER
5972 /* DO NOT USE lp_parm_string ANYMORE!!!!
5973 * use lp_parm_const_string or lp_parm_talloc_string
5975 * lp_parm_string is only used to let old modules find this symbol
5977 #undef lp_parm_string
5978 char *lp_parm_string(const char *servicename, const char *type, const char *option);
5979 char *lp_parm_string(const char *servicename, const char *type, const char *option)
5981 return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
5984 /* Return parametric option from a given service. Type is a part of option before ':' */
5985 /* Parametric option has following syntax: 'Type: option = value' */
5986 /* the returned value is talloced on the talloc_tos() */
5987 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5989 struct param_opt_struct *data = get_parametrics(snum, type, option);
5991 if (data == NULL||data->value==NULL) {
5993 return lp_string(def);
5999 return lp_string(data->value);
6002 /* Return parametric option from a given service. Type is a part of option before ':' */
6003 /* Parametric option has following syntax: 'Type: option = value' */
6004 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
6006 struct param_opt_struct *data = get_parametrics(snum, type, option);
6008 if (data == NULL||data->value==NULL)
6014 /* Return parametric option from a given service. Type is a part of option before ':' */
6015 /* Parametric option has following syntax: 'Type: option = value' */
6017 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
6019 struct param_opt_struct *data = get_parametrics(snum, type, option);
6021 if (data == NULL||data->value==NULL)
6022 return (const char **)def;
6024 if (data->list==NULL) {
6025 data->list = str_list_make_v3(talloc_autofree_context(), data->value, NULL);
6028 return (const char **)data->list;
6031 /* Return parametric option from a given service. Type is a part of option before ':' */
6032 /* Parametric option has following syntax: 'Type: option = value' */
6034 int lp_parm_int(int snum, const char *type, const char *option, int def)
6036 struct param_opt_struct *data = get_parametrics(snum, type, option);
6038 if (data && data->value && *data->value)
6039 return lp_int(data->value);
6044 /* Return parametric option from a given service. Type is a part of option before ':' */
6045 /* Parametric option has following syntax: 'Type: option = value' */
6047 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
6049 struct param_opt_struct *data = get_parametrics(snum, type, option);
6051 if (data && data->value && *data->value)
6052 return lp_ulong(data->value);
6057 /* Return parametric option from a given service. Type is a part of option before ':' */
6058 /* Parametric option has following syntax: 'Type: option = value' */
6060 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
6062 struct param_opt_struct *data = get_parametrics(snum, type, option);
6064 if (data && data->value && *data->value)
6065 return lp_bool(data->value);
6070 /* Return parametric option from a given service. Type is a part of option before ':' */
6071 /* Parametric option has following syntax: 'Type: option = value' */
6073 int lp_parm_enum(int snum, const char *type, const char *option,
6074 const struct enum_list *_enum, int def)
6076 struct param_opt_struct *data = get_parametrics(snum, type, option);
6078 if (data && data->value && *data->value && _enum)
6079 return lp_enum(data->value, _enum);
6085 /***************************************************************************
6086 Initialise a service to the defaults.
6087 ***************************************************************************/
6089 static void init_service(struct service *pservice)
6091 memset((char *)pservice, '\0', sizeof(struct service));
6092 copy_service(pservice, &sDefault, NULL);
6097 * free a param_opts structure.
6098 * param_opts handling should be moved to talloc;
6099 * then this whole functions reduces to a TALLOC_FREE().
6102 static void free_param_opts(struct param_opt_struct **popts)
6104 struct param_opt_struct *opt, *next_opt;
6106 if (popts == NULL) {
6110 if (*popts != NULL) {
6111 DEBUG(5, ("Freeing parametrics:\n"));
6114 while (opt != NULL) {
6115 string_free(&opt->key);
6116 string_free(&opt->value);
6117 TALLOC_FREE(opt->list);
6118 next_opt = opt->next;
6125 /***************************************************************************
6126 Free the dynamically allocated parts of a service struct.
6127 ***************************************************************************/
6129 static void free_service(struct service *pservice)
6134 if (pservice->szService)
6135 DEBUG(5, ("free_service: Freeing service %s\n",
6136 pservice->szService));
6138 free_parameters(pservice);
6140 string_free(&pservice->szService);
6141 TALLOC_FREE(pservice->copymap);
6143 free_param_opts(&pservice->param_opt);
6145 ZERO_STRUCTP(pservice);
6149 /***************************************************************************
6150 remove a service indexed in the ServicePtrs array from the ServiceHash
6151 and free the dynamically allocated parts
6152 ***************************************************************************/
6154 static void free_service_byindex(int idx)
6156 if ( !LP_SNUM_OK(idx) )
6159 ServicePtrs[idx]->valid = False;
6160 invalid_services[num_invalid_services++] = idx;
6162 /* we have to cleanup the hash record */
6164 if (ServicePtrs[idx]->szService) {
6165 char *canon_name = canonicalize_servicename(
6167 ServicePtrs[idx]->szService );
6169 dbwrap_delete_bystring(ServiceHash, canon_name );
6170 TALLOC_FREE(canon_name);
6173 free_service(ServicePtrs[idx]);
6176 /***************************************************************************
6177 Add a new service to the services array initialising it with the given
6179 ***************************************************************************/
6181 static int add_a_service(const struct service *pservice, const char *name)
6184 struct service tservice;
6185 int num_to_alloc = iNumServices + 1;
6187 tservice = *pservice;
6189 /* it might already exist */
6191 i = getservicebyname(name, NULL);
6193 /* Clean all parametric options for service */
6194 /* They will be added during parsing again */
6195 free_param_opts(&ServicePtrs[i]->param_opt);
6200 /* find an invalid one */
6202 if (num_invalid_services > 0) {
6203 i = invalid_services[--num_invalid_services];
6206 /* if not, then create one */
6207 if (i == iNumServices) {
6208 struct service **tsp;
6211 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
6213 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
6217 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct service);
6218 if (!ServicePtrs[iNumServices]) {
6219 DEBUG(0,("add_a_service: out of memory!\n"));
6224 /* enlarge invalid_services here for now... */
6225 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
6227 if (tinvalid == NULL) {
6228 DEBUG(0,("add_a_service: failed to enlarge "
6229 "invalid_services!\n"));
6232 invalid_services = tinvalid;
6234 free_service_byindex(i);
6237 ServicePtrs[i]->valid = True;
6239 init_service(ServicePtrs[i]);
6240 copy_service(ServicePtrs[i], &tservice, NULL);
6242 string_set(&ServicePtrs[i]->szService, name);
6244 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
6245 i, ServicePtrs[i]->szService));
6247 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
6254 /***************************************************************************
6255 Convert a string to uppercase and remove whitespaces.
6256 ***************************************************************************/
6258 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
6263 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
6267 result = talloc_strdup(ctx, src);
6268 SMB_ASSERT(result != NULL);
6274 /***************************************************************************
6275 Add a name/index pair for the services array to the hash table.
6276 ***************************************************************************/
6278 static bool hash_a_service(const char *name, int idx)
6282 if ( !ServiceHash ) {
6283 DEBUG(10,("hash_a_service: creating servicehash\n"));
6284 ServiceHash = db_open_rbt(NULL);
6285 if ( !ServiceHash ) {
6286 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
6291 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
6294 canon_name = canonicalize_servicename(talloc_tos(), name );
6296 dbwrap_store_bystring(ServiceHash, canon_name,
6297 make_tdb_data((uint8 *)&idx, sizeof(idx)),
6300 TALLOC_FREE(canon_name);
6305 /***************************************************************************
6306 Add a new home service, with the specified home directory, defaults coming
6308 ***************************************************************************/
6310 bool lp_add_home(const char *pszHomename, int iDefaultService,
6311 const char *user, const char *pszHomedir)
6315 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
6316 pszHomedir[0] == '\0') {
6320 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
6325 if (!(*(ServicePtrs[iDefaultService]->szPath))
6326 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
6327 string_set(&ServicePtrs[i]->szPath, pszHomedir);
6330 if (!(*(ServicePtrs[i]->comment))) {
6331 char *comment = NULL;
6332 if (asprintf(&comment, "Home directory of %s", user) < 0) {
6335 string_set(&ServicePtrs[i]->comment, comment);
6339 /* set the browseable flag from the global default */
6341 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6342 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
6344 ServicePtrs[i]->autoloaded = True;
6346 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
6347 user, ServicePtrs[i]->szPath ));
6352 /***************************************************************************
6353 Add a new service, based on an old one.
6354 ***************************************************************************/
6356 int lp_add_service(const char *pszService, int iDefaultService)
6358 if (iDefaultService < 0) {
6359 return add_a_service(&sDefault, pszService);
6362 return (add_a_service(ServicePtrs[iDefaultService], pszService));
6365 /***************************************************************************
6366 Add the IPC service.
6367 ***************************************************************************/
6369 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
6371 char *comment = NULL;
6372 int i = add_a_service(&sDefault, ipc_name);
6377 if (asprintf(&comment, "IPC Service (%s)",
6378 Globals.szServerString) < 0) {
6382 string_set(&ServicePtrs[i]->szPath, tmpdir());
6383 string_set(&ServicePtrs[i]->szUsername, "");
6384 string_set(&ServicePtrs[i]->comment, comment);
6385 string_set(&ServicePtrs[i]->fstype, "IPC");
6386 ServicePtrs[i]->iMaxConnections = 0;
6387 ServicePtrs[i]->bAvailable = True;
6388 ServicePtrs[i]->bRead_only = True;
6389 ServicePtrs[i]->bGuest_only = False;
6390 ServicePtrs[i]->bAdministrative_share = True;
6391 ServicePtrs[i]->bGuest_ok = guest_ok;
6392 ServicePtrs[i]->bPrint_ok = False;
6393 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6395 DEBUG(3, ("adding IPC service\n"));
6401 /***************************************************************************
6402 Add a new printer service, with defaults coming from service iFrom.
6403 ***************************************************************************/
6405 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
6407 const char *comment = "From Printcap";
6408 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6413 /* note that we do NOT default the availability flag to True - */
6414 /* we take it from the default service passed. This allows all */
6415 /* dynamic printers to be disabled by disabling the [printers] */
6416 /* entry (if/when the 'available' keyword is implemented!). */
6418 /* the printer name is set to the service name. */
6419 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6420 string_set(&ServicePtrs[i]->comment, comment);
6422 /* set the browseable flag from the gloabl default */
6423 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6425 /* Printers cannot be read_only. */
6426 ServicePtrs[i]->bRead_only = False;
6427 /* No share modes on printer services. */
6428 ServicePtrs[i]->bShareModes = False;
6429 /* No oplocks on printer services. */
6430 ServicePtrs[i]->bOpLocks = False;
6431 /* Printer services must be printable. */
6432 ServicePtrs[i]->bPrint_ok = True;
6434 DEBUG(3, ("adding printer service %s\n", pszPrintername));
6440 /***************************************************************************
6441 Check whether the given parameter name is valid.
6442 Parametric options (names containing a colon) are considered valid.
6443 ***************************************************************************/
6445 bool lp_parameter_is_valid(const char *pszParmName)
6447 return ((map_parameter(pszParmName) != -1) ||
6448 (strchr(pszParmName, ':') != NULL));
6451 /***************************************************************************
6452 Check whether the given name is the name of a global parameter.
6453 Returns True for strings belonging to parameters of class
6454 P_GLOBAL, False for all other strings, also for parametric options
6455 and strings not belonging to any option.
6456 ***************************************************************************/
6458 bool lp_parameter_is_global(const char *pszParmName)
6460 int num = map_parameter(pszParmName);
6463 return (parm_table[num].p_class == P_GLOBAL);
6469 /**************************************************************************
6470 Check whether the given name is the canonical name of a parameter.
6471 Returns False if it is not a valid parameter Name.
6472 For parametric options, True is returned.
6473 **************************************************************************/
6475 bool lp_parameter_is_canonical(const char *parm_name)
6477 if (!lp_parameter_is_valid(parm_name)) {
6481 return (map_parameter(parm_name) ==
6482 map_parameter_canonical(parm_name, NULL));
6485 /**************************************************************************
6486 Determine the canonical name for a parameter.
6487 Indicate when it is an inverse (boolean) synonym instead of a
6489 **************************************************************************/
6491 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6496 if (!lp_parameter_is_valid(parm_name)) {
6501 num = map_parameter_canonical(parm_name, inverse);
6503 /* parametric option */
6504 *canon_parm = parm_name;
6506 *canon_parm = parm_table[num].label;
6513 /**************************************************************************
6514 Determine the canonical name for a parameter.
6515 Turn the value given into the inverse boolean expression when
6516 the synonym is an invers boolean synonym.
6518 Return True if parm_name is a valid parameter name and
6519 in case it is an invers boolean synonym, if the val string could
6520 successfully be converted to the reverse bool.
6521 Return false in all other cases.
6522 **************************************************************************/
6524 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6526 const char **canon_parm,
6527 const char **canon_val)
6532 if (!lp_parameter_is_valid(parm_name)) {
6538 num = map_parameter_canonical(parm_name, &inverse);
6540 /* parametric option */
6541 *canon_parm = parm_name;
6544 *canon_parm = parm_table[num].label;
6546 if (!lp_invert_boolean(val, canon_val)) {
6558 /***************************************************************************
6559 Map a parameter's string representation to something we can use.
6560 Returns False if the parameter string is not recognised, else TRUE.
6561 ***************************************************************************/
6563 static int map_parameter(const char *pszParmName)
6567 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6570 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6571 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6574 /* Warn only if it isn't parametric option */
6575 if (strchr(pszParmName, ':') == NULL)
6576 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6577 /* We do return 'fail' for parametric options as well because they are
6578 stored in different storage
6583 /***************************************************************************
6584 Map a parameter's string representation to the index of the canonical
6585 form of the parameter (it might be a synonym).
6586 Returns -1 if the parameter string is not recognised.
6587 ***************************************************************************/
6589 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6591 int parm_num, canon_num;
6592 bool loc_inverse = False;
6594 parm_num = map_parameter(pszParmName);
6595 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6596 /* invalid, parametric or no canidate for synonyms ... */
6600 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6601 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6602 parm_num = canon_num;
6608 if (inverse != NULL) {
6609 *inverse = loc_inverse;
6614 /***************************************************************************
6615 return true if parameter number parm1 is a synonym of parameter
6616 number parm2 (parm2 being the principal name).
6617 set inverse to True if parm1 is P_BOOLREV and parm2 is P_BOOL,
6619 ***************************************************************************/
6621 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6623 if ((parm_table[parm1].ptr == parm_table[parm2].ptr) &&
6624 (parm_table[parm1].flags & FLAG_HIDE) &&
6625 !(parm_table[parm2].flags & FLAG_HIDE))
6627 if (inverse != NULL) {
6628 if ((parm_table[parm1].type == P_BOOLREV) &&
6629 (parm_table[parm2].type == P_BOOL))
6641 /***************************************************************************
6642 Show one parameter's name, type, [values,] and flags.
6643 (helper functions for show_parameter_list)
6644 ***************************************************************************/
6646 static void show_parameter(int parmIndex)
6648 int enumIndex, flagIndex;
6653 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6654 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6656 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6657 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6658 FLAG_HIDE, FLAG_DOS_STRING};
6659 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6660 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6661 "FLAG_DEPRECATED", "FLAG_HIDE", "FLAG_DOS_STRING", NULL};
6663 printf("%s=%s", parm_table[parmIndex].label,
6664 type[parm_table[parmIndex].type]);
6665 if (parm_table[parmIndex].type == P_ENUM) {
6668 parm_table[parmIndex].enum_list[enumIndex].name;
6672 enumIndex ? "|" : "",
6673 parm_table[parmIndex].enum_list[enumIndex].name);
6678 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6679 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6682 flag_names[flagIndex]);
6687 /* output synonyms */
6689 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6690 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6691 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6692 parm_table[parmIndex2].label);
6693 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6695 printf(" (synonyms: ");
6700 printf("%s%s", parm_table[parmIndex2].label,
6701 inverse ? "[i]" : "");
6711 /***************************************************************************
6712 Show all parameter's name, type, [values,] and flags.
6713 ***************************************************************************/
6715 void show_parameter_list(void)
6717 int classIndex, parmIndex;
6718 const char *section_names[] = { "local", "global", NULL};
6720 for (classIndex=0; section_names[classIndex]; classIndex++) {
6721 printf("[%s]\n", section_names[classIndex]);
6722 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6723 if (parm_table[parmIndex].p_class == classIndex) {
6724 show_parameter(parmIndex);
6730 /***************************************************************************
6731 Check if a given string correctly represents a boolean value.
6732 ***************************************************************************/
6734 bool lp_string_is_valid_boolean(const char *parm_value)
6736 return set_boolean(parm_value, NULL);
6739 /***************************************************************************
6740 Get the standard string representation of a boolean value ("yes" or "no")
6741 ***************************************************************************/
6743 static const char *get_boolean(bool bool_value)
6745 static const char *yes_str = "yes";
6746 static const char *no_str = "no";
6748 return (bool_value ? yes_str : no_str);
6751 /***************************************************************************
6752 Provide the string of the negated boolean value associated to the boolean
6753 given as a string. Returns False if the passed string does not correctly
6754 represent a boolean.
6755 ***************************************************************************/
6757 bool lp_invert_boolean(const char *str, const char **inverse_str)
6761 if (!set_boolean(str, &val)) {
6765 *inverse_str = get_boolean(!val);
6769 /***************************************************************************
6770 Provide the canonical string representation of a boolean value given
6771 as a string. Return True on success, False if the string given does
6772 not correctly represent a boolean.
6773 ***************************************************************************/
6775 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6779 if (!set_boolean(str, &val)) {
6783 *canon_str = get_boolean(val);
6787 /***************************************************************************
6788 Find a service by name. Otherwise works like get_service.
6789 ***************************************************************************/
6791 static int getservicebyname(const char *pszServiceName, struct service *pserviceDest)
6797 if (ServiceHash == NULL) {
6801 canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
6803 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
6805 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
6806 iService = *(int *)data.dptr;
6809 TALLOC_FREE(canon_name);
6811 if ((iService != -1) && (LP_SNUM_OK(iService))
6812 && (pserviceDest != NULL)) {
6813 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6819 /***************************************************************************
6820 Copy a service structure to another.
6821 If pcopymapDest is NULL then copy all fields
6822 ***************************************************************************/
6825 * Add a parametric option to a param_opt_struct,
6826 * replacing old value, if already present.
6828 static void set_param_opt(struct param_opt_struct **opt_list,
6829 const char *opt_name,
6830 const char *opt_value)
6832 struct param_opt_struct *new_opt, *opt;
6835 if (opt_list == NULL) {
6842 /* Traverse destination */
6844 /* If we already have same option, override it */
6845 if (strwicmp(opt->key, opt_name) == 0) {
6846 string_free(&opt->value);
6847 TALLOC_FREE(opt->list);
6848 opt->value = SMB_STRDUP(opt_value);
6855 new_opt = SMB_XMALLOC_P(struct param_opt_struct);
6856 new_opt->key = SMB_STRDUP(opt_name);
6857 new_opt->value = SMB_STRDUP(opt_value);
6858 new_opt->list = NULL;
6859 DLIST_ADD(*opt_list, new_opt);
6863 static void copy_service(struct service *pserviceDest, struct service *pserviceSource,
6864 struct bitmap *pcopymapDest)
6867 bool bcopyall = (pcopymapDest == NULL);
6868 struct param_opt_struct *data;
6870 for (i = 0; parm_table[i].label; i++)
6871 if (parm_table[i].ptr && parm_table[i].p_class == P_LOCAL &&
6872 (bcopyall || bitmap_query(pcopymapDest,i))) {
6873 void *def_ptr = parm_table[i].ptr;
6875 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
6878 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
6881 switch (parm_table[i].type) {
6884 *(bool *)dest_ptr = *(bool *)src_ptr;
6890 *(int *)dest_ptr = *(int *)src_ptr;
6894 *(char *)dest_ptr = *(char *)src_ptr;
6898 string_set((char **)dest_ptr,
6903 string_set((char **)dest_ptr,
6905 strupper_m(*(char **)dest_ptr);
6908 TALLOC_FREE(*((char ***)dest_ptr));
6909 *((char ***)dest_ptr) = str_list_copy(NULL,
6910 *(const char ***)src_ptr);
6918 init_copymap(pserviceDest);
6919 if (pserviceSource->copymap)
6920 bitmap_copy(pserviceDest->copymap,
6921 pserviceSource->copymap);
6924 data = pserviceSource->param_opt;
6926 set_param_opt(&pserviceDest->param_opt, data->key, data->value);
6931 /***************************************************************************
6932 Check a service for consistency. Return False if the service is in any way
6933 incomplete or faulty, else True.
6934 ***************************************************************************/
6936 bool service_ok(int iService)
6941 if (ServicePtrs[iService]->szService[0] == '\0') {
6942 DEBUG(0, ("The following message indicates an internal error:\n"));
6943 DEBUG(0, ("No service name in service entry.\n"));
6947 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6948 /* I can't see why you'd want a non-printable printer service... */
6949 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6950 if (!ServicePtrs[iService]->bPrint_ok) {
6951 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6952 ServicePtrs[iService]->szService));
6953 ServicePtrs[iService]->bPrint_ok = True;
6955 /* [printers] service must also be non-browsable. */
6956 if (ServicePtrs[iService]->bBrowseable)
6957 ServicePtrs[iService]->bBrowseable = False;
6960 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6961 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6962 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6964 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6965 ServicePtrs[iService]->szService));
6966 ServicePtrs[iService]->bAvailable = False;
6969 /* If a service is flagged unavailable, log the fact at level 1. */
6970 if (!ServicePtrs[iService]->bAvailable)
6971 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6972 ServicePtrs[iService]->szService));
6977 static struct smbconf_ctx *lp_smbconf_ctx(void)
6980 static struct smbconf_ctx *conf_ctx = NULL;
6982 if (conf_ctx == NULL) {
6983 werr = smbconf_init(NULL, &conf_ctx, "registry:");
6984 if (!W_ERROR_IS_OK(werr)) {
6985 DEBUG(1, ("error initializing registry configuration: "
6986 "%s\n", win_errstr(werr)));
6994 static bool process_smbconf_service(struct smbconf_service *service)
6999 if (service == NULL) {
7003 ret = do_section(service->name, NULL);
7007 for (count = 0; count < service->num_params; count++) {
7008 ret = do_parameter(service->param_names[count],
7009 service->param_values[count],
7015 if (iServiceIndex >= 0) {
7016 return service_ok(iServiceIndex);
7022 * load a service from registry and activate it
7024 bool process_registry_service(const char *service_name)
7027 struct smbconf_service *service = NULL;
7028 TALLOC_CTX *mem_ctx = talloc_stackframe();
7029 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7032 if (conf_ctx == NULL) {
7036 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
7038 if (!smbconf_share_exists(conf_ctx, service_name)) {
7040 * Registry does not contain data for this service (yet),
7041 * but make sure lp_load doesn't return false.
7047 werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
7048 if (!W_ERROR_IS_OK(werr)) {
7052 ret = process_smbconf_service(service);
7058 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
7061 TALLOC_FREE(mem_ctx);
7066 * process_registry_globals
7068 static bool process_registry_globals(void)
7072 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
7074 ret = do_parameter("registry shares", "yes", NULL);
7079 return process_registry_service(GLOBAL_NAME);
7082 bool process_registry_shares(void)
7086 struct smbconf_service **service = NULL;
7087 uint32_t num_shares = 0;
7088 TALLOC_CTX *mem_ctx = talloc_stackframe();
7089 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7092 if (conf_ctx == NULL) {
7096 werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
7097 if (!W_ERROR_IS_OK(werr)) {
7103 for (count = 0; count < num_shares; count++) {
7104 if (strequal(service[count]->name, GLOBAL_NAME)) {
7107 ret = process_smbconf_service(service[count]);
7114 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
7117 TALLOC_FREE(mem_ctx);
7121 #define MAX_INCLUDE_DEPTH 100
7123 static uint8_t include_depth;
7125 static struct file_lists {
7126 struct file_lists *next;
7130 } *file_lists = NULL;
7132 /*******************************************************************
7133 Keep a linked list of all config files so we know when one has changed
7134 it's date and needs to be reloaded.
7135 ********************************************************************/
7137 static void add_to_file_list(const char *fname, const char *subfname)
7139 struct file_lists *f = file_lists;
7142 if (f->name && !strcmp(f->name, fname))
7148 f = SMB_MALLOC_P(struct file_lists);
7151 f->next = file_lists;
7152 f->name = SMB_STRDUP(fname);
7157 f->subfname = SMB_STRDUP(subfname);
7164 f->modtime = file_modtime(subfname);
7166 time_t t = file_modtime(subfname);
7174 * Free the file lists
7176 static void free_file_list(void)
7178 struct file_lists *f;
7179 struct file_lists *next;
7184 SAFE_FREE( f->name );
7185 SAFE_FREE( f->subfname );
7194 * Utility function for outsiders to check if we're running on registry.
7196 bool lp_config_backend_is_registry(void)
7198 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
7202 * Utility function to check if the config backend is FILE.
7204 bool lp_config_backend_is_file(void)
7206 return (lp_config_backend() == CONFIG_BACKEND_FILE);
7209 /*******************************************************************
7210 Check if a config file has changed date.
7211 ********************************************************************/
7213 bool lp_file_list_changed(void)
7215 struct file_lists *f = file_lists;
7217 DEBUG(6, ("lp_file_list_changed()\n"));
7222 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
7223 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7225 if (conf_ctx == NULL) {
7228 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
7231 DEBUGADD(6, ("registry config changed\n"));
7236 n2 = talloc_sub_basic(talloc_tos(),
7237 get_current_username(),
7238 current_user_info.domain,
7243 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
7244 f->name, n2, ctime(&f->modtime)));
7246 mod_time = file_modtime(n2);
7249 ((f->modtime != mod_time) ||
7250 (f->subfname == NULL) ||
7251 (strcmp(n2, f->subfname) != 0)))
7254 ("file %s modified: %s\n", n2,
7256 f->modtime = mod_time;
7257 SAFE_FREE(f->subfname);
7258 f->subfname = SMB_STRDUP(n2);
7270 /***************************************************************************
7271 Run standard_sub_basic on netbios name... needed because global_myname
7272 is not accessed through any lp_ macro.
7273 Note: We must *NOT* use string_set() here as ptr points to global_myname.
7274 ***************************************************************************/
7276 static bool handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
7279 char *netbios_name = talloc_sub_basic(
7280 talloc_tos(), get_current_username(), current_user_info.domain,
7283 ret = set_global_myname(netbios_name);
7284 TALLOC_FREE(netbios_name);
7285 string_set(&Globals.szNetbiosName,global_myname());
7287 DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
7293 static bool handle_charset(int snum, const char *pszParmValue, char **ptr)
7295 if (strcmp(*ptr, pszParmValue) != 0) {
7296 string_set(ptr, pszParmValue);
7304 static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
7308 ret = set_global_myworkgroup(pszParmValue);
7309 string_set(&Globals.szWorkgroup,lp_workgroup());
7314 static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
7318 ret = set_global_scope(pszParmValue);
7319 string_set(&Globals.szNetbiosScope,global_scope());
7324 static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
7326 TALLOC_FREE(Globals.szNetbiosAliases);
7327 Globals.szNetbiosAliases = str_list_make_v3(talloc_autofree_context(), pszParmValue, NULL);
7328 return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
7331 /***************************************************************************
7332 Handle the include operation.
7333 ***************************************************************************/
7334 static bool bAllowIncludeRegistry = true;
7336 static bool handle_include(int snum, const char *pszParmValue, char **ptr)
7340 if (include_depth >= MAX_INCLUDE_DEPTH) {
7341 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
7346 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
7347 if (!bAllowIncludeRegistry) {
7350 if (bInGlobalSection) {
7353 ret = process_registry_globals();
7357 DEBUG(1, ("\"include = registry\" only effective "
7358 "in %s section\n", GLOBAL_NAME));
7363 fname = talloc_sub_basic(talloc_tos(), get_current_username(),
7364 current_user_info.domain,
7367 add_to_file_list(pszParmValue, fname);
7369 string_set(ptr, fname);
7371 if (file_exist(fname)) {
7374 ret = pm_process(fname, do_section, do_parameter, NULL);
7380 DEBUG(2, ("Can't find include file %s\n", fname));
7385 /***************************************************************************
7386 Handle the interpretation of the copy parameter.
7387 ***************************************************************************/
7389 static bool handle_copy(int snum, const char *pszParmValue, char **ptr)
7393 struct service serviceTemp;
7395 string_set(ptr, pszParmValue);
7397 init_service(&serviceTemp);
7401 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7403 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7404 if (iTemp == iServiceIndex) {
7405 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7407 copy_service(ServicePtrs[iServiceIndex],
7409 ServicePtrs[iServiceIndex]->copymap);
7413 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7417 free_service(&serviceTemp);
7421 static bool handle_ldap_debug_level(int snum, const char *pszParmValue, char **ptr)
7423 Globals.ldap_debug_level = lp_int(pszParmValue);
7424 init_ldap_debugging();
7428 /***************************************************************************
7429 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7434 idmap uid = 1000-1999
7437 We only do simple parsing checks here. The strings are parsed into useful
7438 structures in the idmap daemon code.
7440 ***************************************************************************/
7442 /* Some lp_ routines to return idmap [ug]id information */
7444 static uid_t idmap_uid_low, idmap_uid_high;
7445 static gid_t idmap_gid_low, idmap_gid_high;
7447 bool lp_idmap_uid(uid_t *low, uid_t *high)
7449 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7453 *low = idmap_uid_low;
7456 *high = idmap_uid_high;
7461 bool lp_idmap_gid(gid_t *low, gid_t *high)
7463 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7467 *low = idmap_gid_low;
7470 *high = idmap_gid_high;
7475 /* Do some simple checks on "idmap [ug]id" parameter values */
7477 static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
7481 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7486 string_set(ptr, pszParmValue);
7488 idmap_uid_low = low;
7489 idmap_uid_high = high;
7494 static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
7498 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7503 string_set(ptr, pszParmValue);
7505 idmap_gid_low = low;
7506 idmap_gid_high = high;
7511 /***************************************************************************
7512 Handle the DEBUG level list.
7513 ***************************************************************************/
7515 static bool handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
7517 string_set(ptr, pszParmValueIn);
7518 return debug_parse_levels(pszParmValueIn);
7521 /***************************************************************************
7522 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7523 ***************************************************************************/
7525 static const char *append_ldap_suffix( const char *str )
7527 const char *suffix_string;
7530 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7531 Globals.szLdapSuffix );
7532 if ( !suffix_string ) {
7533 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7537 return suffix_string;
7540 const char *lp_ldap_machine_suffix(void)
7542 if (Globals.szLdapMachineSuffix[0])
7543 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7545 return lp_string(Globals.szLdapSuffix);
7548 const char *lp_ldap_user_suffix(void)
7550 if (Globals.szLdapUserSuffix[0])
7551 return append_ldap_suffix(Globals.szLdapUserSuffix);
7553 return lp_string(Globals.szLdapSuffix);
7556 const char *lp_ldap_group_suffix(void)
7558 if (Globals.szLdapGroupSuffix[0])
7559 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7561 return lp_string(Globals.szLdapSuffix);
7564 const char *lp_ldap_idmap_suffix(void)
7566 if (Globals.szLdapIdmapSuffix[0])
7567 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7569 return lp_string(Globals.szLdapSuffix);
7572 /****************************************************************************
7573 set the value for a P_ENUM
7574 ***************************************************************************/
7576 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7581 for (i = 0; parm->enum_list[i].name; i++) {
7582 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7583 *ptr = parm->enum_list[i].value;
7587 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7588 pszParmValue, parm->label));
7591 /***************************************************************************
7592 ***************************************************************************/
7594 static bool handle_printing(int snum, const char *pszParmValue, char **ptr)
7596 static int parm_num = -1;
7599 if ( parm_num == -1 )
7600 parm_num = map_parameter( "printing" );
7602 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7607 s = ServicePtrs[snum];
7609 init_printer_values( s );
7615 /***************************************************************************
7616 Initialise a copymap.
7617 ***************************************************************************/
7619 static void init_copymap(struct service *pservice)
7623 TALLOC_FREE(pservice->copymap);
7625 pservice->copymap = bitmap_talloc(talloc_autofree_context(),
7627 if (!pservice->copymap)
7629 ("Couldn't allocate copymap!! (size %d)\n",
7630 (int)NUMPARAMETERS));
7632 for (i = 0; i < NUMPARAMETERS; i++)
7633 bitmap_set(pservice->copymap, i);
7636 /***************************************************************************
7637 Return the local pointer to a parameter given a service struct and the
7638 pointer into the default structure.
7639 ***************************************************************************/
7641 static void *lp_local_ptr(struct service *service, void *ptr)
7643 return (void *)(((char *)service) + PTR_DIFF(ptr, &sDefault));
7646 /***************************************************************************
7647 Return the local pointer to a parameter given the service number and the
7648 pointer into the default structure.
7649 ***************************************************************************/
7651 void *lp_local_ptr_by_snum(int snum, void *ptr)
7653 return lp_local_ptr(ServicePtrs[snum], ptr);
7656 /***************************************************************************
7657 Process a parameter for a particular service number. If snum < 0
7658 then assume we are in the globals.
7659 ***************************************************************************/
7661 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7664 void *parm_ptr = NULL; /* where we are going to store the result */
7665 void *def_ptr = NULL;
7666 struct param_opt_struct **opt_list;
7668 parmnum = map_parameter(pszParmName);
7671 if (strchr(pszParmName, ':') == NULL) {
7672 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7678 * We've got a parametric option
7681 opt_list = (snum < 0)
7682 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7683 set_param_opt(opt_list, pszParmName, pszParmValue);
7688 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7689 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7693 def_ptr = parm_table[parmnum].ptr;
7695 /* we might point at a service, the default service or a global */
7699 if (parm_table[parmnum].p_class == P_GLOBAL) {
7701 ("Global parameter %s found in service section!\n",
7705 parm_ptr = lp_local_ptr_by_snum(snum, def_ptr);
7709 if (!ServicePtrs[snum]->copymap)
7710 init_copymap(ServicePtrs[snum]);
7712 /* this handles the aliases - set the copymap for other entries with
7713 the same data pointer */
7714 for (i = 0; parm_table[i].label; i++)
7715 if (parm_table[i].ptr == parm_table[parmnum].ptr)
7716 bitmap_clear(ServicePtrs[snum]->copymap, i);
7719 /* if it is a special case then go ahead */
7720 if (parm_table[parmnum].special) {
7721 return parm_table[parmnum].special(snum, pszParmValue,
7725 /* now switch on the type of variable it is */
7726 switch (parm_table[parmnum].type)
7729 *(bool *)parm_ptr = lp_bool(pszParmValue);
7733 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7737 *(int *)parm_ptr = lp_int(pszParmValue);
7741 *(char *)parm_ptr = *pszParmValue;
7745 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7747 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7752 TALLOC_FREE(*((char ***)parm_ptr));
7753 *(char ***)parm_ptr = str_list_make_v3(
7754 talloc_autofree_context(), pszParmValue, NULL);
7758 string_set((char **)parm_ptr, pszParmValue);
7762 string_set((char **)parm_ptr, pszParmValue);
7763 strupper_m(*(char **)parm_ptr);
7767 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7776 /***************************************************************************
7777 Process a parameter.
7778 ***************************************************************************/
7780 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7783 if (!bInGlobalSection && bGlobalOnly)
7786 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7788 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7789 pszParmName, pszParmValue));
7792 /***************************************************************************
7793 Print a parameter of the specified type.
7794 ***************************************************************************/
7796 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7802 for (i = 0; p->enum_list[i].name; i++) {
7803 if (*(int *)ptr == p->enum_list[i].value) {
7805 p->enum_list[i].name);
7812 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7816 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7820 fprintf(f, "%d", *(int *)ptr);
7824 fprintf(f, "%c", *(char *)ptr);
7828 char *o = octal_string(*(int *)ptr);
7829 fprintf(f, "%s", o);
7835 if ((char ***)ptr && *(char ***)ptr) {
7836 char **list = *(char ***)ptr;
7837 for (; *list; list++) {
7838 /* surround strings with whitespace in double quotes */
7839 if ( strchr_m( *list, ' ' ) )
7840 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
7842 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
7849 if (*(char **)ptr) {
7850 fprintf(f, "%s", *(char **)ptr);
7858 /***************************************************************************
7859 Check if two parameters are equal.
7860 ***************************************************************************/
7862 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7867 return (*((bool *)ptr1) == *((bool *)ptr2));
7872 return (*((int *)ptr1) == *((int *)ptr2));
7875 return (*((char *)ptr1) == *((char *)ptr2));
7878 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7883 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7888 return (p1 == p2 || strequal(p1, p2));
7896 /***************************************************************************
7897 Initialize any local varients in the sDefault table.
7898 ***************************************************************************/
7900 void init_locals(void)
7905 /***************************************************************************
7906 Process a new section (service). At this stage all sections are services.
7907 Later we'll have special sections that permit server parameters to be set.
7908 Returns True on success, False on failure.
7909 ***************************************************************************/
7911 static bool do_section(const char *pszSectionName, void *userdata)
7914 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7915 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7918 /* if we were in a global section then do the local inits */
7919 if (bInGlobalSection && !isglobal)
7922 /* if we've just struck a global section, note the fact. */
7923 bInGlobalSection = isglobal;
7925 /* check for multiple global sections */
7926 if (bInGlobalSection) {
7927 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7931 if (!bInGlobalSection && bGlobalOnly)
7934 /* if we have a current service, tidy it up before moving on */
7937 if (iServiceIndex >= 0)
7938 bRetval = service_ok(iServiceIndex);
7940 /* if all is still well, move to the next record in the services array */
7942 /* We put this here to avoid an odd message order if messages are */
7943 /* issued by the post-processing of a previous section. */
7944 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7946 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
7948 DEBUG(0, ("Failed to add a new service\n"));
7957 /***************************************************************************
7958 Determine if a partcular base parameter is currentl set to the default value.
7959 ***************************************************************************/
7961 static bool is_default(int i)
7963 if (!defaults_saved)
7965 switch (parm_table[i].type) {
7967 return str_list_equal((const char **)parm_table[i].def.lvalue,
7968 *(const char ***)parm_table[i].ptr);
7971 return strequal(parm_table[i].def.svalue,
7972 *(char **)parm_table[i].ptr);
7975 return parm_table[i].def.bvalue ==
7976 *(bool *)parm_table[i].ptr;
7978 return parm_table[i].def.cvalue ==
7979 *(char *)parm_table[i].ptr;
7983 return parm_table[i].def.ivalue ==
7984 *(int *)parm_table[i].ptr;
7991 /***************************************************************************
7992 Display the contents of the global structure.
7993 ***************************************************************************/
7995 static void dump_globals(FILE *f)
7998 struct param_opt_struct *data;
8000 fprintf(f, "[global]\n");
8002 for (i = 0; parm_table[i].label; i++)
8003 if (parm_table[i].p_class == P_GLOBAL &&
8004 !(parm_table[i].flags & FLAG_META) &&
8005 parm_table[i].ptr &&
8006 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
8007 if (defaults_saved && is_default(i))
8009 fprintf(f, "\t%s = ", parm_table[i].label);
8010 print_parameter(&parm_table[i], parm_table[i].ptr, f);
8013 if (Globals.param_opt != NULL) {
8014 data = Globals.param_opt;
8016 fprintf(f, "\t%s = %s\n", data->key, data->value);
8023 /***************************************************************************
8024 Return True if a local parameter is currently set to the global default.
8025 ***************************************************************************/
8027 bool lp_is_default(int snum, struct parm_struct *parm)
8029 int pdiff = PTR_DIFF(parm->ptr, &sDefault);
8031 return equal_parameter(parm->type,
8032 ((char *)ServicePtrs[snum]) + pdiff,
8033 ((char *)&sDefault) + pdiff);
8036 /***************************************************************************
8037 Display the contents of a single services record.
8038 ***************************************************************************/
8040 static void dump_a_service(struct service *pService, FILE * f)
8043 struct param_opt_struct *data;
8045 if (pService != &sDefault)
8046 fprintf(f, "[%s]\n", pService->szService);
8048 for (i = 0; parm_table[i].label; i++) {
8050 if (parm_table[i].p_class == P_LOCAL &&
8051 !(parm_table[i].flags & FLAG_META) &&
8052 parm_table[i].ptr &&
8053 (*parm_table[i].label != '-') &&
8054 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8056 int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
8058 if (pService == &sDefault) {
8059 if (defaults_saved && is_default(i))
8062 if (equal_parameter(parm_table[i].type,
8063 ((char *)pService) +
8065 ((char *)&sDefault) +
8070 fprintf(f, "\t%s = ", parm_table[i].label);
8071 print_parameter(&parm_table[i],
8072 ((char *)pService) + pdiff, f);
8077 if (pService->param_opt != NULL) {
8078 data = pService->param_opt;
8080 fprintf(f, "\t%s = %s\n", data->key, data->value);
8086 /***************************************************************************
8087 Display the contents of a parameter of a single services record.
8088 ***************************************************************************/
8090 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
8093 bool result = False;
8096 fstring local_parm_name;
8098 const char *parm_opt_value;
8100 /* check for parametrical option */
8101 fstrcpy( local_parm_name, parm_name);
8102 parm_opt = strchr( local_parm_name, ':');
8107 if (strlen(parm_opt)) {
8108 parm_opt_value = lp_parm_const_string( snum,
8109 local_parm_name, parm_opt, NULL);
8110 if (parm_opt_value) {
8111 printf( "%s\n", parm_opt_value);
8118 /* check for a key and print the value */
8125 for (i = 0; parm_table[i].label; i++) {
8126 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
8127 !(parm_table[i].flags & FLAG_META) &&
8128 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
8129 parm_table[i].ptr &&
8130 (*parm_table[i].label != '-') &&
8131 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8136 ptr = parm_table[i].ptr;
8138 struct service *pService = ServicePtrs[snum];
8139 ptr = ((char *)pService) +
8140 PTR_DIFF(parm_table[i].ptr, &sDefault);
8143 print_parameter(&parm_table[i],
8154 /***************************************************************************
8155 Return info about the requested parameter (given as a string).
8156 Return NULL when the string is not a valid parameter name.
8157 ***************************************************************************/
8159 struct parm_struct *lp_get_parameter(const char *param_name)
8161 int num = map_parameter(param_name);
8167 return &parm_table[num];
8170 /***************************************************************************
8171 Return info about the next parameter in a service.
8172 snum==GLOBAL_SECTION_SNUM gives the globals.
8173 Return NULL when out of parameters.
8174 ***************************************************************************/
8176 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
8179 /* do the globals */
8180 for (; parm_table[*i].label; (*i)++) {
8181 if (parm_table[*i].p_class == P_SEPARATOR)
8182 return &parm_table[(*i)++];
8184 if (!parm_table[*i].ptr
8185 || (*parm_table[*i].label == '-'))
8189 && (parm_table[*i].ptr ==
8190 parm_table[(*i) - 1].ptr))
8193 if (is_default(*i) && !allparameters)
8196 return &parm_table[(*i)++];
8199 struct service *pService = ServicePtrs[snum];
8201 for (; parm_table[*i].label; (*i)++) {
8202 if (parm_table[*i].p_class == P_SEPARATOR)
8203 return &parm_table[(*i)++];
8205 if (parm_table[*i].p_class == P_LOCAL &&
8206 parm_table[*i].ptr &&
8207 (*parm_table[*i].label != '-') &&
8209 (parm_table[*i].ptr !=
8210 parm_table[(*i) - 1].ptr)))
8213 PTR_DIFF(parm_table[*i].ptr,
8216 if (allparameters ||
8217 !equal_parameter(parm_table[*i].type,
8218 ((char *)pService) +
8220 ((char *)&sDefault) +
8223 return &parm_table[(*i)++];
8234 /***************************************************************************
8235 Display the contents of a single copy structure.
8236 ***************************************************************************/
8237 static void dump_copy_map(bool *pcopymap)
8243 printf("\n\tNon-Copied parameters:\n");
8245 for (i = 0; parm_table[i].label; i++)
8246 if (parm_table[i].p_class == P_LOCAL &&
8247 parm_table[i].ptr && !pcopymap[i] &&
8248 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8250 printf("\t\t%s\n", parm_table[i].label);
8255 /***************************************************************************
8256 Return TRUE if the passed service number is within range.
8257 ***************************************************************************/
8259 bool lp_snum_ok(int iService)
8261 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8264 /***************************************************************************
8265 Auto-load some home services.
8266 ***************************************************************************/
8268 static void lp_add_auto_services(char *str)
8278 s = SMB_STRDUP(str);
8282 homes = lp_servicenumber(HOMES_NAME);
8284 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8285 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8288 if (lp_servicenumber(p) >= 0)
8291 home = get_user_home_dir(talloc_tos(), p);
8293 if (home && home[0] && homes >= 0)
8294 lp_add_home(p, homes, p, home);
8301 /***************************************************************************
8302 Auto-load one printer.
8303 ***************************************************************************/
8305 void lp_add_one_printer(const char *name, const char *comment, void *pdata)
8307 int printers = lp_servicenumber(PRINTERS_NAME);
8310 if (lp_servicenumber(name) < 0) {
8311 lp_add_printer(name, printers);
8312 if ((i = lp_servicenumber(name)) >= 0) {
8313 string_set(&ServicePtrs[i]->comment, comment);
8314 ServicePtrs[i]->autoloaded = True;
8319 /***************************************************************************
8320 Have we loaded a services file yet?
8321 ***************************************************************************/
8323 bool lp_loaded(void)
8328 /***************************************************************************
8329 Unload unused services.
8330 ***************************************************************************/
8332 void lp_killunused(bool (*snumused) (int))
8335 for (i = 0; i < iNumServices; i++) {
8339 /* don't kill autoloaded or usershare services */
8340 if ( ServicePtrs[i]->autoloaded ||
8341 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8345 if (!snumused || !snumused(i)) {
8346 free_service_byindex(i);
8352 * Kill all except autoloaded and usershare services - convenience wrapper
8354 void lp_kill_all_services(void)
8356 lp_killunused(NULL);
8359 /***************************************************************************
8361 ***************************************************************************/
8363 void lp_killservice(int iServiceIn)
8365 if (VALID(iServiceIn)) {
8366 free_service_byindex(iServiceIn);
8370 /***************************************************************************
8371 Save the curent values of all global and sDefault parameters into the
8372 defaults union. This allows swat and testparm to show only the
8373 changed (ie. non-default) parameters.
8374 ***************************************************************************/
8376 static void lp_save_defaults(void)
8379 for (i = 0; parm_table[i].label; i++) {
8380 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
8382 switch (parm_table[i].type) {
8384 parm_table[i].def.lvalue = str_list_copy(
8385 NULL, *(const char ***)parm_table[i].ptr);
8389 if (parm_table[i].ptr) {
8390 parm_table[i].def.svalue = SMB_STRDUP(*(char **)parm_table[i].ptr);
8392 parm_table[i].def.svalue = NULL;
8397 parm_table[i].def.bvalue =
8398 *(bool *)parm_table[i].ptr;
8401 parm_table[i].def.cvalue =
8402 *(char *)parm_table[i].ptr;
8407 parm_table[i].def.ivalue =
8408 *(int *)parm_table[i].ptr;
8414 defaults_saved = True;
8417 /***********************************************************
8418 If we should send plaintext/LANMAN passwords in the clinet
8419 ************************************************************/
8421 static void set_allowed_client_auth(void)
8423 if (Globals.bClientNTLMv2Auth) {
8424 Globals.bClientLanManAuth = False;
8426 if (!Globals.bClientLanManAuth) {
8427 Globals.bClientPlaintextAuth = False;
8431 /***************************************************************************
8433 The following code allows smbd to read a user defined share file.
8434 Yes, this is my intent. Yes, I'm comfortable with that...
8436 THE FOLLOWING IS SECURITY CRITICAL CODE.
8438 It washes your clothes, it cleans your house, it guards you while you sleep...
8439 Do not f%^k with it....
8440 ***************************************************************************/
8442 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8444 /***************************************************************************
8445 Check allowed stat state of a usershare file.
8446 Ensure we print out who is dicking with us so the admin can
8447 get their sorry ass fired.
8448 ***************************************************************************/
8450 static bool check_usershare_stat(const char *fname,
8451 const SMB_STRUCT_STAT *psbuf)
8453 if (!S_ISREG(psbuf->st_ex_mode)) {
8454 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8455 "not a regular file\n",
8456 fname, (unsigned int)psbuf->st_ex_uid ));
8460 /* Ensure this doesn't have the other write bit set. */
8461 if (psbuf->st_ex_mode & S_IWOTH) {
8462 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8463 "public write. Refusing to allow as a usershare file.\n",
8464 fname, (unsigned int)psbuf->st_ex_uid ));
8468 /* Should be 10k or less. */
8469 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8470 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8471 "too large (%u) to be a user share file.\n",
8472 fname, (unsigned int)psbuf->st_ex_uid,
8473 (unsigned int)psbuf->st_ex_size ));
8480 /***************************************************************************
8481 Parse the contents of a usershare file.
8482 ***************************************************************************/
8484 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8485 SMB_STRUCT_STAT *psbuf,
8486 const char *servicename,
8490 char **pp_sharepath,
8492 char **pp_cp_servicename,
8493 struct security_descriptor **ppsd,
8496 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8497 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8500 SMB_STRUCT_STAT sbuf;
8501 char *sharepath = NULL;
8502 char *comment = NULL;
8504 *pp_sharepath = NULL;
8507 *pallow_guest = False;
8510 return USERSHARE_MALFORMED_FILE;
8513 if (strcmp(lines[0], "#VERSION 1") == 0) {
8515 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8518 return USERSHARE_MALFORMED_FILE;
8521 return USERSHARE_BAD_VERSION;
8524 if (strncmp(lines[1], "path=", 5) != 0) {
8525 return USERSHARE_MALFORMED_PATH;
8528 sharepath = talloc_strdup(ctx, &lines[1][5]);
8530 return USERSHARE_POSIX_ERR;
8532 trim_string(sharepath, " ", " ");
8534 if (strncmp(lines[2], "comment=", 8) != 0) {
8535 return USERSHARE_MALFORMED_COMMENT_DEF;
8538 comment = talloc_strdup(ctx, &lines[2][8]);
8540 return USERSHARE_POSIX_ERR;
8542 trim_string(comment, " ", " ");
8543 trim_char(comment, '"', '"');
8545 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8546 return USERSHARE_MALFORMED_ACL_DEF;
8549 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8550 return USERSHARE_ACL_ERR;
8554 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8555 return USERSHARE_MALFORMED_ACL_DEF;
8557 if (lines[4][9] == 'y') {
8558 *pallow_guest = True;
8561 /* Backwards compatible extension to file version #2. */
8563 if (strncmp(lines[5], "sharename=", 10) != 0) {
8564 return USERSHARE_MALFORMED_SHARENAME_DEF;
8566 if (!strequal(&lines[5][10], servicename)) {
8567 return USERSHARE_BAD_SHARENAME;
8569 *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
8570 if (!*pp_cp_servicename) {
8571 return USERSHARE_POSIX_ERR;
8576 if (*pp_cp_servicename == NULL) {
8577 *pp_cp_servicename = talloc_strdup(ctx, servicename);
8578 if (!*pp_cp_servicename) {
8579 return USERSHARE_POSIX_ERR;
8583 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8584 /* Path didn't change, no checks needed. */
8585 *pp_sharepath = sharepath;
8586 *pp_comment = comment;
8587 return USERSHARE_OK;
8590 /* The path *must* be absolute. */
8591 if (sharepath[0] != '/') {
8592 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8593 servicename, sharepath));
8594 return USERSHARE_PATH_NOT_ABSOLUTE;
8597 /* If there is a usershare prefix deny list ensure one of these paths
8598 doesn't match the start of the user given path. */
8599 if (prefixdenylist) {
8601 for ( i=0; prefixdenylist[i]; i++ ) {
8602 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8603 servicename, i, prefixdenylist[i], sharepath ));
8604 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8605 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8606 "usershare prefix deny list entries.\n",
8607 servicename, sharepath));
8608 return USERSHARE_PATH_IS_DENIED;
8613 /* If there is a usershare prefix allow list ensure one of these paths
8614 does match the start of the user given path. */
8616 if (prefixallowlist) {
8618 for ( i=0; prefixallowlist[i]; i++ ) {
8619 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8620 servicename, i, prefixallowlist[i], sharepath ));
8621 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8625 if (prefixallowlist[i] == NULL) {
8626 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8627 "usershare prefix allow list entries.\n",
8628 servicename, sharepath));
8629 return USERSHARE_PATH_NOT_ALLOWED;
8633 /* Ensure this is pointing to a directory. */
8634 dp = sys_opendir(sharepath);
8637 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8638 servicename, sharepath));
8639 return USERSHARE_PATH_NOT_DIRECTORY;
8642 /* Ensure the owner of the usershare file has permission to share
8645 if (sys_stat(sharepath, &sbuf, false) == -1) {
8646 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8647 servicename, sharepath, strerror(errno) ));
8649 return USERSHARE_POSIX_ERR;
8654 if (!S_ISDIR(sbuf.st_ex_mode)) {
8655 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8656 servicename, sharepath ));
8657 return USERSHARE_PATH_NOT_DIRECTORY;
8660 /* Check if sharing is restricted to owner-only. */
8661 /* psbuf is the stat of the usershare definition file,
8662 sbuf is the stat of the target directory to be shared. */
8664 if (lp_usershare_owner_only()) {
8665 /* root can share anything. */
8666 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8667 return USERSHARE_PATH_NOT_ALLOWED;
8671 *pp_sharepath = sharepath;
8672 *pp_comment = comment;
8673 return USERSHARE_OK;
8676 /***************************************************************************
8677 Deal with a usershare file.
8680 -1 - Bad name, invalid contents.
8681 - service name already existed and not a usershare, problem
8682 with permissions to share directory etc.
8683 ***************************************************************************/
8685 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8687 SMB_STRUCT_STAT sbuf;
8688 SMB_STRUCT_STAT lsbuf;
8690 char *sharepath = NULL;
8691 char *comment = NULL;
8692 char *cp_service_name = NULL;
8693 char **lines = NULL;
8697 TALLOC_CTX *ctx = talloc_stackframe();
8698 struct security_descriptor *psd = NULL;
8699 bool guest_ok = False;
8700 char *canon_name = NULL;
8701 bool added_service = false;
8704 /* Ensure share name doesn't contain invalid characters. */
8705 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8706 DEBUG(0,("process_usershare_file: share name %s contains "
8707 "invalid characters (any of %s)\n",
8708 file_name, INVALID_SHARENAME_CHARS ));
8712 canon_name = canonicalize_servicename(ctx, file_name);
8717 fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
8722 /* Minimize the race condition by doing an lstat before we
8723 open and fstat. Ensure this isn't a symlink link. */
8725 if (sys_lstat(fname, &lsbuf, false) != 0) {
8726 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8727 fname, strerror(errno) ));
8731 /* This must be a regular file, not a symlink, directory or
8732 other strange filetype. */
8733 if (!check_usershare_stat(fname, &lsbuf)) {
8738 TDB_DATA data = dbwrap_fetch_bystring(
8739 ServiceHash, canon_name, canon_name);
8743 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
8744 iService = *(int *)data.dptr;
8748 if (iService != -1 &&
8749 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8750 &lsbuf.st_ex_mtime) == 0) {
8751 /* Nothing changed - Mark valid and return. */
8752 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8754 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8759 /* Try and open the file read only - no symlinks allowed. */
8761 fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8763 fd = sys_open(fname, O_RDONLY, 0);
8767 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8768 fname, strerror(errno) ));
8772 /* Now fstat to be *SURE* it's a regular file. */
8773 if (sys_fstat(fd, &sbuf, false) != 0) {
8775 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8776 fname, strerror(errno) ));
8780 /* Is it the same dev/inode as was lstated ? */
8781 if (lsbuf.st_ex_dev != sbuf.st_ex_dev || lsbuf.st_ex_ino != sbuf.st_ex_ino) {
8783 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8784 "Symlink spoofing going on ?\n", fname ));
8788 /* This must be a regular file, not a symlink, directory or
8789 other strange filetype. */
8790 if (!check_usershare_stat(fname, &sbuf)) {
8794 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8797 if (lines == NULL) {
8798 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8799 fname, (unsigned int)sbuf.st_ex_uid ));
8803 if (parse_usershare_file(ctx, &sbuf, file_name,
8804 iService, lines, numlines, &sharepath,
8805 &comment, &cp_service_name,
8806 &psd, &guest_ok) != USERSHARE_OK) {
8810 /* Everything ok - add the service possibly using a template. */
8812 const struct service *sp = &sDefault;
8813 if (snum_template != -1) {
8814 sp = ServicePtrs[snum_template];
8817 if ((iService = add_a_service(sp, cp_service_name)) < 0) {
8818 DEBUG(0, ("process_usershare_file: Failed to add "
8819 "new service %s\n", cp_service_name));
8823 added_service = true;
8825 /* Read only is controlled by usershare ACL below. */
8826 ServicePtrs[iService]->bRead_only = False;
8829 /* Write the ACL of the new/modified share. */
8830 if (!set_share_security(canon_name, psd)) {
8831 DEBUG(0, ("process_usershare_file: Failed to set share "
8832 "security for user share %s\n",
8837 /* If from a template it may be marked invalid. */
8838 ServicePtrs[iService]->valid = True;
8840 /* Set the service as a valid usershare. */
8841 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8843 /* Set guest access. */
8844 if (lp_usershare_allow_guests()) {
8845 ServicePtrs[iService]->bGuest_ok = guest_ok;
8848 /* And note when it was loaded. */
8849 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8850 string_set(&ServicePtrs[iService]->szPath, sharepath);
8851 string_set(&ServicePtrs[iService]->comment, comment);
8857 if (ret == -1 && iService != -1 && added_service) {
8858 lp_remove_service(iService);
8866 /***************************************************************************
8867 Checks if a usershare entry has been modified since last load.
8868 ***************************************************************************/
8870 static bool usershare_exists(int iService, struct timespec *last_mod)
8872 SMB_STRUCT_STAT lsbuf;
8873 const char *usersharepath = Globals.szUsersharePath;
8876 if (asprintf(&fname, "%s/%s",
8878 ServicePtrs[iService]->szService) < 0) {
8882 if (sys_lstat(fname, &lsbuf, false) != 0) {
8887 if (!S_ISREG(lsbuf.st_ex_mode)) {
8893 *last_mod = lsbuf.st_ex_mtime;
8897 /***************************************************************************
8898 Load a usershare service by name. Returns a valid servicenumber or -1.
8899 ***************************************************************************/
8901 int load_usershare_service(const char *servicename)
8903 SMB_STRUCT_STAT sbuf;
8904 const char *usersharepath = Globals.szUsersharePath;
8905 int max_user_shares = Globals.iUsershareMaxShares;
8906 int snum_template = -1;
8908 if (*usersharepath == 0 || max_user_shares == 0) {
8912 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8913 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8914 usersharepath, strerror(errno) ));
8918 if (!S_ISDIR(sbuf.st_ex_mode)) {
8919 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8925 * This directory must be owned by root, and have the 't' bit set.
8926 * It also must not be writable by "other".
8930 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8932 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8934 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8935 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8940 /* Ensure the template share exists if it's set. */
8941 if (Globals.szUsershareTemplateShare[0]) {
8942 /* We can't use lp_servicenumber here as we are recommending that
8943 template shares have -valid=False set. */
8944 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8945 if (ServicePtrs[snum_template]->szService &&
8946 strequal(ServicePtrs[snum_template]->szService,
8947 Globals.szUsershareTemplateShare)) {
8952 if (snum_template == -1) {
8953 DEBUG(0,("load_usershare_service: usershare template share %s "
8954 "does not exist.\n",
8955 Globals.szUsershareTemplateShare ));
8960 return process_usershare_file(usersharepath, servicename, snum_template);
8963 /***************************************************************************
8964 Load all user defined shares from the user share directory.
8965 We only do this if we're enumerating the share list.
8966 This is the function that can delete usershares that have
8968 ***************************************************************************/
8970 int load_usershare_shares(void)
8973 SMB_STRUCT_STAT sbuf;
8974 SMB_STRUCT_DIRENT *de;
8975 int num_usershares = 0;
8976 int max_user_shares = Globals.iUsershareMaxShares;
8977 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8978 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8979 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8981 int snum_template = -1;
8982 const char *usersharepath = Globals.szUsersharePath;
8983 int ret = lp_numservices();
8985 if (max_user_shares == 0 || *usersharepath == '\0') {
8986 return lp_numservices();
8989 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8990 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8991 usersharepath, strerror(errno) ));
8996 * This directory must be owned by root, and have the 't' bit set.
8997 * It also must not be writable by "other".
9001 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
9003 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
9005 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
9006 "or does not have the sticky bit 't' set or is writable by anyone.\n",
9011 /* Ensure the template share exists if it's set. */
9012 if (Globals.szUsershareTemplateShare[0]) {
9013 /* We can't use lp_servicenumber here as we are recommending that
9014 template shares have -valid=False set. */
9015 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
9016 if (ServicePtrs[snum_template]->szService &&
9017 strequal(ServicePtrs[snum_template]->szService,
9018 Globals.szUsershareTemplateShare)) {
9023 if (snum_template == -1) {
9024 DEBUG(0,("load_usershare_shares: usershare template share %s "
9025 "does not exist.\n",
9026 Globals.szUsershareTemplateShare ));
9031 /* Mark all existing usershares as pending delete. */
9032 for (iService = iNumServices - 1; iService >= 0; iService--) {
9033 if (VALID(iService) && ServicePtrs[iService]->usershare) {
9034 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
9038 dp = sys_opendir(usersharepath);
9040 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
9041 usersharepath, strerror(errno) ));
9045 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
9046 (de = sys_readdir(dp));
9047 num_dir_entries++ ) {
9049 const char *n = de->d_name;
9051 /* Ignore . and .. */
9053 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
9059 /* Temporary file used when creating a share. */
9060 num_tmp_dir_entries++;
9063 /* Allow 20% tmp entries. */
9064 if (num_tmp_dir_entries > allowed_tmp_entries) {
9065 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
9066 "in directory %s\n",
9067 num_tmp_dir_entries, usersharepath));
9071 r = process_usershare_file(usersharepath, n, snum_template);
9073 /* Update the services count. */
9075 if (num_usershares >= max_user_shares) {
9076 DEBUG(0,("load_usershare_shares: max user shares reached "
9077 "on file %s in directory %s\n",
9078 n, usersharepath ));
9081 } else if (r == -1) {
9082 num_bad_dir_entries++;
9085 /* Allow 20% bad entries. */
9086 if (num_bad_dir_entries > allowed_bad_entries) {
9087 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
9088 "in directory %s\n",
9089 num_bad_dir_entries, usersharepath));
9093 /* Allow 20% bad entries. */
9094 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
9095 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
9096 "in directory %s\n",
9097 num_dir_entries, usersharepath));
9104 /* Sweep through and delete any non-refreshed usershares that are
9105 not currently in use. */
9106 for (iService = iNumServices - 1; iService >= 0; iService--) {
9107 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
9108 if (conn_snum_used(iService)) {
9111 /* Remove from the share ACL db. */
9112 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
9113 lp_servicename(iService) ));
9114 delete_share_security(lp_servicename(iService));
9115 free_service_byindex(iService);
9119 return lp_numservices();
9122 /********************************************************
9123 Destroy global resources allocated in this file
9124 ********************************************************/
9126 void gfree_loadparm(void)
9132 /* Free resources allocated to services */
9134 for ( i = 0; i < iNumServices; i++ ) {
9136 free_service_byindex(i);
9140 SAFE_FREE( ServicePtrs );
9143 /* Now release all resources allocated to global
9144 parameters and the default service */
9146 free_global_parameters();
9150 /***************************************************************************
9151 Allow client apps to specify that they are a client
9152 ***************************************************************************/
9153 void lp_set_in_client(bool b)
9159 /***************************************************************************
9160 Determine if we're running in a client app
9161 ***************************************************************************/
9162 bool lp_is_in_client(void)
9167 /***************************************************************************
9168 Load the services array from the services file. Return True on success,
9170 ***************************************************************************/
9172 bool lp_load_ex(const char *pszFname,
9176 bool initialize_globals,
9177 bool allow_include_registry,
9178 bool allow_registry_shares)
9185 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
9187 bInGlobalSection = True;
9188 bGlobalOnly = global_only;
9189 bAllowIncludeRegistry = allow_include_registry;
9191 init_globals(! initialize_globals);
9196 if (save_defaults) {
9201 free_param_opts(&Globals.param_opt);
9203 /* We get sections first, so have to start 'behind' to make up */
9206 if (lp_config_backend_is_file()) {
9207 n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
9208 current_user_info.domain,
9211 smb_panic("lp_load_ex: out of memory");
9214 add_to_file_list(pszFname, n2);
9216 bRetval = pm_process(n2, do_section, do_parameter, NULL);
9219 /* finish up the last section */
9220 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
9222 if (iServiceIndex >= 0) {
9223 bRetval = service_ok(iServiceIndex);
9227 if (lp_config_backend_is_registry()) {
9228 /* config backend changed to registry in config file */
9230 * We need to use this extra global variable here to
9231 * survive restart: init_globals uses this as a default
9232 * for ConfigBackend. Otherwise, init_globals would
9233 * send us into an endless loop here.
9235 config_backend = CONFIG_BACKEND_REGISTRY;
9237 DEBUG(1, ("lp_load_ex: changing to config backend "
9239 init_globals(false);
9240 lp_kill_all_services();
9241 return lp_load_ex(pszFname, global_only, save_defaults,
9242 add_ipc, initialize_globals,
9243 allow_include_registry,
9244 allow_registry_shares);
9246 } else if (lp_config_backend_is_registry()) {
9247 bRetval = process_registry_globals();
9249 DEBUG(0, ("Illegal config backend given: %d\n",
9250 lp_config_backend()));
9254 if (bRetval && lp_registry_shares() && allow_registry_shares) {
9255 bRetval = process_registry_shares();
9258 lp_add_auto_services(lp_auto_services());
9261 /* When 'restrict anonymous = 2' guest connections to ipc$
9263 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9264 if ( lp_enable_asu_support() ) {
9265 lp_add_ipc("ADMIN$", false);
9270 set_default_server_announce_type();
9271 set_allowed_client_auth();
9275 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9276 /* if bWINSsupport is true and we are in the client */
9277 if (lp_is_in_client() && Globals.bWINSsupport) {
9278 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9283 bAllowIncludeRegistry = true;
9288 bool lp_load(const char *pszFname,
9292 bool initialize_globals)
9294 return lp_load_ex(pszFname,
9299 true, /* allow_include_registry */
9300 false); /* allow_registry_shares*/
9303 bool lp_load_initial_only(const char *pszFname)
9305 return lp_load_ex(pszFname,
9306 true, /* global only */
9307 false, /* save_defaults */
9308 false, /* add_ipc */
9309 true, /* initialize_globals */
9310 false, /* allow_include_registry */
9311 false); /* allow_registry_shares*/
9314 bool lp_load_with_registry_shares(const char *pszFname,
9318 bool initialize_globals)
9320 return lp_load_ex(pszFname,
9325 true, /* allow_include_registry */
9326 true); /* allow_registry_shares*/
9329 /***************************************************************************
9330 Return the max number of services.
9331 ***************************************************************************/
9333 int lp_numservices(void)
9335 return (iNumServices);
9338 /***************************************************************************
9339 Display the contents of the services array in human-readable form.
9340 ***************************************************************************/
9342 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9347 defaults_saved = False;
9351 dump_a_service(&sDefault, f);
9353 for (iService = 0; iService < maxtoprint; iService++) {
9355 lp_dump_one(f, show_defaults, iService);
9359 /***************************************************************************
9360 Display the contents of one service in human-readable form.
9361 ***************************************************************************/
9363 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9366 if (ServicePtrs[snum]->szService[0] == '\0')
9368 dump_a_service(ServicePtrs[snum], f);
9372 /***************************************************************************
9373 Return the number of the service with the given name, or -1 if it doesn't
9374 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9375 getservicebyname()! This works ONLY if all services have been loaded, and
9376 does not copy the found service.
9377 ***************************************************************************/
9379 int lp_servicenumber(const char *pszServiceName)
9382 fstring serviceName;
9384 if (!pszServiceName) {
9385 return GLOBAL_SECTION_SNUM;
9388 for (iService = iNumServices - 1; iService >= 0; iService--) {
9389 if (VALID(iService) && ServicePtrs[iService]->szService) {
9391 * The substitution here is used to support %U is
9394 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9395 standard_sub_basic(get_current_username(),
9396 current_user_info.domain,
9397 serviceName,sizeof(serviceName));
9398 if (strequal(serviceName, pszServiceName)) {
9404 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9405 struct timespec last_mod;
9407 if (!usershare_exists(iService, &last_mod)) {
9408 /* Remove the share security tdb entry for it. */
9409 delete_share_security(lp_servicename(iService));
9410 /* Remove it from the array. */
9411 free_service_byindex(iService);
9412 /* Doesn't exist anymore. */
9413 return GLOBAL_SECTION_SNUM;
9416 /* Has it been modified ? If so delete and reload. */
9417 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9419 /* Remove it from the array. */
9420 free_service_byindex(iService);
9421 /* and now reload it. */
9422 iService = load_usershare_service(pszServiceName);
9427 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9428 return GLOBAL_SECTION_SNUM;
9434 bool share_defined(const char *service_name)
9436 return (lp_servicenumber(service_name) != -1);
9439 struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
9440 const char *sharename)
9442 struct share_params *result;
9446 if (!(sname = SMB_STRDUP(sharename))) {
9450 snum = find_service(sname);
9457 if (!(result = TALLOC_P(mem_ctx, struct share_params))) {
9458 DEBUG(0, ("talloc failed\n"));
9462 result->service = snum;
9466 struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx)
9468 struct share_iterator *result;
9470 if (!(result = TALLOC_P(mem_ctx, struct share_iterator))) {
9471 DEBUG(0, ("talloc failed\n"));
9475 result->next_id = 0;
9479 struct share_params *next_share(struct share_iterator *list)
9481 struct share_params *result;
9483 while (!lp_snum_ok(list->next_id) &&
9484 (list->next_id < lp_numservices())) {
9488 if (list->next_id >= lp_numservices()) {
9492 if (!(result = TALLOC_P(list, struct share_params))) {
9493 DEBUG(0, ("talloc failed\n"));
9497 result->service = list->next_id;
9502 struct share_params *next_printer(struct share_iterator *list)
9504 struct share_params *result;
9506 while ((result = next_share(list)) != NULL) {
9507 if (lp_print_ok(result->service)) {
9515 * This is a hack for a transition period until we transformed all code from
9516 * service numbers to struct share_params.
9519 struct share_params *snum2params_static(int snum)
9521 static struct share_params result;
9522 result.service = snum;
9526 /*******************************************************************
9527 A useful volume label function.
9528 ********************************************************************/
9530 const char *volume_label(int snum)
9533 const char *label = lp_volume(snum);
9535 label = lp_servicename(snum);
9538 /* This returns a 33 byte guarenteed null terminated string. */
9539 ret = talloc_strndup(talloc_tos(), label, 32);
9546 /*******************************************************************
9547 Set the server type we will announce as via nmbd.
9548 ********************************************************************/
9550 static void set_default_server_announce_type(void)
9552 default_server_announce = 0;
9553 default_server_announce |= SV_TYPE_WORKSTATION;
9554 default_server_announce |= SV_TYPE_SERVER;
9555 default_server_announce |= SV_TYPE_SERVER_UNIX;
9557 /* note that the flag should be set only if we have a
9558 printer service but nmbd doesn't actually load the
9559 services so we can't tell --jerry */
9561 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9563 switch (lp_announce_as()) {
9564 case ANNOUNCE_AS_NT_SERVER:
9565 default_server_announce |= SV_TYPE_SERVER_NT;
9566 /* fall through... */
9567 case ANNOUNCE_AS_NT_WORKSTATION:
9568 default_server_announce |= SV_TYPE_NT;
9570 case ANNOUNCE_AS_WIN95:
9571 default_server_announce |= SV_TYPE_WIN95_PLUS;
9573 case ANNOUNCE_AS_WFW:
9574 default_server_announce |= SV_TYPE_WFW;
9580 switch (lp_server_role()) {
9581 case ROLE_DOMAIN_MEMBER:
9582 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9584 case ROLE_DOMAIN_PDC:
9585 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9587 case ROLE_DOMAIN_BDC:
9588 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9590 case ROLE_STANDALONE:
9594 if (lp_time_server())
9595 default_server_announce |= SV_TYPE_TIME_SOURCE;
9597 if (lp_host_msdfs())
9598 default_server_announce |= SV_TYPE_DFS_SERVER;
9601 /***********************************************************
9602 If we are PDC then prefer us as DMB
9603 ************************************************************/
9605 bool lp_domain_master(void)
9607 if (Globals.iDomainMaster == Auto)
9608 return (lp_server_role() == ROLE_DOMAIN_PDC);
9610 return (bool)Globals.iDomainMaster;
9613 /***********************************************************
9614 If we are PDC then prefer us as DMB
9615 ************************************************************/
9617 bool lp_domain_master_true_or_auto(void)
9619 if (Globals.iDomainMaster) /* auto or yes */
9625 /***********************************************************
9626 If we are DMB then prefer us as LMB
9627 ************************************************************/
9629 bool lp_preferred_master(void)
9631 if (Globals.iPreferredMaster == Auto)
9632 return (lp_local_master() && lp_domain_master());
9634 return (bool)Globals.iPreferredMaster;
9637 /*******************************************************************
9639 ********************************************************************/
9641 void lp_remove_service(int snum)
9643 ServicePtrs[snum]->valid = False;
9644 invalid_services[num_invalid_services++] = snum;
9647 /*******************************************************************
9649 ********************************************************************/
9651 void lp_copy_service(int snum, const char *new_name)
9653 do_section(new_name, NULL);
9655 snum = lp_servicenumber(new_name);
9657 lp_do_parameter(snum, "copy", lp_servicename(snum));
9662 /*******************************************************************
9663 Get the default server type we will announce as via nmbd.
9664 ********************************************************************/
9666 int lp_default_server_announce(void)
9668 return default_server_announce;
9671 /*******************************************************************
9672 Split the announce version into major and minor numbers.
9673 ********************************************************************/
9675 int lp_major_announce_version(void)
9677 static bool got_major = False;
9678 static int major_version = DEFAULT_MAJOR_VERSION;
9683 return major_version;
9686 if ((vers = lp_announce_version()) == NULL)
9687 return major_version;
9689 if ((p = strchr_m(vers, '.')) == 0)
9690 return major_version;
9693 major_version = atoi(vers);
9694 return major_version;
9697 int lp_minor_announce_version(void)
9699 static bool got_minor = False;
9700 static int minor_version = DEFAULT_MINOR_VERSION;
9705 return minor_version;
9708 if ((vers = lp_announce_version()) == NULL)
9709 return minor_version;
9711 if ((p = strchr_m(vers, '.')) == 0)
9712 return minor_version;
9715 minor_version = atoi(p);
9716 return minor_version;
9719 /***********************************************************
9720 Set the global name resolution order (used in smbclient).
9721 ************************************************************/
9723 void lp_set_name_resolve_order(const char *new_order)
9725 string_set(&Globals.szNameResolveOrder, new_order);
9728 const char *lp_printername(int snum)
9730 const char *ret = _lp_printername(snum);
9731 if (ret == NULL || (ret != NULL && *ret == '\0'))
9732 ret = lp_const_servicename(snum);
9738 /***********************************************************
9739 Allow daemons such as winbindd to fix their logfile name.
9740 ************************************************************/
9742 void lp_set_logfile(const char *name)
9744 string_set(&Globals.szLogFile, name);
9745 debug_set_logfile(name);
9748 /*******************************************************************
9749 Return the max print jobs per queue.
9750 ********************************************************************/
9752 int lp_maxprintjobs(int snum)
9754 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9755 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9756 maxjobs = PRINT_MAX_JOBID - 1;
9761 const char *lp_printcapname(void)
9763 if ((Globals.szPrintcapname != NULL) &&
9764 (Globals.szPrintcapname[0] != '\0'))
9765 return Globals.szPrintcapname;
9767 if (sDefault.iPrinting == PRINT_CUPS) {
9775 if (sDefault.iPrinting == PRINT_BSD)
9776 return "/etc/printcap";
9778 return PRINTCAP_NAME;
9781 static uint32 spoolss_state;
9783 bool lp_disable_spoolss( void )
9785 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9786 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9788 return spoolss_state == SVCCTL_STOPPED ? True : False;
9791 void lp_set_spoolss_state( uint32 state )
9793 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9795 spoolss_state = state;
9798 uint32 lp_get_spoolss_state( void )
9800 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9803 /*******************************************************************
9804 Ensure we don't use sendfile if server smb signing is active.
9805 ********************************************************************/
9807 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9809 bool sign_active = false;
9811 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9812 if (get_Protocol() < PROTOCOL_NT1) {
9815 if (signing_state) {
9816 sign_active = smb_signing_is_active(signing_state);
9818 return (_lp_use_sendfile(snum) &&
9819 (get_remote_arch() != RA_WIN95) &&
9823 /*******************************************************************
9824 Turn off sendfile if we find the underlying OS doesn't support it.
9825 ********************************************************************/
9827 void set_use_sendfile(int snum, bool val)
9829 if (LP_SNUM_OK(snum))
9830 ServicePtrs[snum]->bUseSendfile = val;
9832 sDefault.bUseSendfile = val;
9835 /*******************************************************************
9836 Turn off storing DOS attributes if this share doesn't support it.
9837 ********************************************************************/
9839 void set_store_dos_attributes(int snum, bool val)
9841 if (!LP_SNUM_OK(snum))
9843 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9846 void lp_set_mangling_method(const char *new_method)
9848 string_set(&Globals.szManglingMethod, new_method);
9851 /*******************************************************************
9852 Global state for POSIX pathname processing.
9853 ********************************************************************/
9855 static bool posix_pathnames;
9857 bool lp_posix_pathnames(void)
9859 return posix_pathnames;
9862 /*******************************************************************
9863 Change everything needed to ensure POSIX pathname processing (currently
9865 ********************************************************************/
9867 void lp_set_posix_pathnames(void)
9869 posix_pathnames = True;
9872 /*******************************************************************
9873 Global state for POSIX lock processing - CIFS unix extensions.
9874 ********************************************************************/
9876 bool posix_default_lock_was_set;
9877 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9879 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9881 if (posix_default_lock_was_set) {
9882 return posix_cifsx_locktype;
9884 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9888 /*******************************************************************
9889 ********************************************************************/
9891 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9893 posix_default_lock_was_set = True;
9894 posix_cifsx_locktype = val;
9897 int lp_min_receive_file_size(void)
9899 if (Globals.iminreceivefile < 0) {
9902 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9905 /*******************************************************************
9906 If socket address is an empty character string, it is necessary to
9907 define it as "0.0.0.0".
9908 ********************************************************************/
9910 const char *lp_socket_address(void)
9912 char *sock_addr = Globals.szSocketAddress;
9914 if (sock_addr[0] == '\0'){
9915 string_set(&Globals.szSocketAddress, "0.0.0.0");
9917 return Globals.szSocketAddress;
9920 void lp_set_passdb_backend(const char *backend)
9922 string_set(&Globals.szPassdbBackend, backend);
9925 /*******************************************************************
9926 Safe wide links checks.
9927 This helper function always verify the validity of wide links,
9928 even after a configuration file reload.
9929 ********************************************************************/
9931 static bool lp_widelinks_internal(int snum)
9933 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9934 sDefault.bWidelinks);
9937 void widelinks_warning(int snum)
9939 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9940 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9941 "These parameters are incompatible. "
9942 "Wide links will be disabled for this share.\n",
9943 lp_servicename(snum) ));
9947 bool lp_widelinks(int snum)
9949 /* wide links is always incompatible with unix extensions */
9950 if (lp_unix_extensions()) {
9954 return lp_widelinks_internal(snum);
9957 bool lp_writeraw(void)
9959 if (lp_async_smb_echo_handler()) {
9962 return _lp_writeraw();
9965 bool lp_readraw(void)
9967 if (lp_async_smb_echo_handler()) {
9970 return _lp_readraw();