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
57 #ifdef HAVE_HTTPCONNECTENCRYPT
58 #include <cups/http.h>
63 extern enum protocol_types Protocol;
64 extern userdom_struct current_user_info;
67 #define GLOBAL_NAME "global"
71 #define PRINTERS_NAME "printers"
75 #define HOMES_NAME "homes"
78 /* the special value for the include parameter
79 * to be interpreted not as a file name but to
80 * trigger loading of the global smb.conf options
82 #ifndef INCLUDE_REGISTRY_NAME
83 #define INCLUDE_REGISTRY_NAME "registry"
86 static bool in_client = False; /* Not in the client by default */
87 static struct smbconf_csn conf_last_csn;
89 #define CONFIG_BACKEND_FILE 0
90 #define CONFIG_BACKEND_REGISTRY 1
92 static int config_backend = CONFIG_BACKEND_FILE;
94 /* some helpful bits */
95 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
96 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
98 #define USERSHARE_VALID 1
99 #define USERSHARE_PENDING_DELETE 2
101 static bool defaults_saved = False;
103 struct param_opt_struct {
104 struct param_opt_struct *prev, *next;
111 * This structure describes global (ie., server-wide) parameters.
118 char *display_charset;
119 char *szPrintcapname;
120 char *szAddPortCommand;
121 char *szEnumPortsCommand;
122 char *szAddPrinterCommand;
123 char *szDeletePrinterCommand;
124 char *szOs2DriverMap;
130 char *szDefaultService;
134 char *szServerString;
135 char *szAutoServices;
136 char *szPasswdProgram;
140 char *szSMBPasswdFile;
142 char *szPassdbBackend;
143 char **szPreloadModules;
144 char *szPasswordServer;
145 char *szSocketOptions;
147 char *szAfsUsernameMap;
148 int iAfsTokenLifetime;
149 char *szLogNtTokenCommand;
155 char **szWINSservers;
157 char *szRemoteAnnounce;
158 char *szRemoteBrowseSync;
159 char *szSocketAddress;
160 char *szNISHomeMapName;
161 char *szAnnounceVersion; /* This is initialised in init_globals */
164 char **szNetbiosAliases;
165 char *szNetbiosScope;
166 char *szNameResolveOrder;
168 char *szAddUserScript;
169 char *szRenameUserScript;
170 char *szDelUserScript;
171 char *szAddGroupScript;
172 char *szDelGroupScript;
173 char *szAddUserToGroupScript;
174 char *szDelUserFromGroupScript;
175 char *szSetPrimaryGroupScript;
176 char *szAddMachineScript;
177 char *szShutdownScript;
178 char *szAbortShutdownScript;
179 char *szUsernameMapScript;
180 char *szCheckPasswordScript;
187 bool bPassdbExpandExplicit;
188 int AlgorithmicRidBase;
189 char *szTemplateHomedir;
190 char *szTemplateShell;
191 char *szWinbindSeparator;
192 bool bWinbindEnumUsers;
193 bool bWinbindEnumGroups;
194 bool bWinbindUseDefaultDomain;
195 bool bWinbindTrustedDomainsOnly;
196 bool bWinbindNestedGroups;
197 int winbind_expand_groups;
198 bool bWinbindRefreshTickets;
199 bool bWinbindOfflineLogon;
200 bool bWinbindNormalizeNames;
201 bool bWinbindRpcOnly;
202 char *szIdmapBackend;
203 char *szIdmapAllocBackend;
204 char *szAddShareCommand;
205 char *szChangeShareCommand;
206 char *szDeleteShareCommand;
208 char *szGuestaccount;
209 char *szManglingMethod;
210 char **szServicesList;
211 char *szUsersharePath;
212 char *szUsershareTemplateShare;
213 char **szUsersharePrefixAllowList;
214 char **szUsersharePrefixDenyList;
221 int open_files_db_hash_size;
230 bool paranoid_server_security;
233 int iMaxSmbdProcesses;
234 bool bDisableSpoolss;
237 bool enhanced_browsing;
243 int announce_as; /* This is initialised in init_globals */
244 int machine_password_timeout;
246 int oplock_break_wait_time;
247 int winbind_cache_time;
248 int winbind_reconnect_delay;
249 int winbind_max_idle_children;
250 char **szWinbindNssInfo;
252 char *szLdapMachineSuffix;
253 char *szLdapUserSuffix;
254 char *szLdapIdmapSuffix;
255 char *szLdapGroupSuffix;
260 int ldap_debug_level;
261 int ldap_debug_threshold;
265 char *szIPrintServer;
267 char **szClusterAddresses;
269 int ldap_passwd_sync;
270 int ldap_replication_sleep;
271 int ldap_timeout; /* This is initialised in init_globals */
272 int ldap_connection_timeout;
275 bool bMsAddPrinterWizard;
280 int iPreferredMaster;
283 char **szInitLogonDelayedHosts;
285 bool bEncryptPasswords;
290 bool bObeyPamRestrictions;
292 int PrintcapCacheTime;
293 bool bLargeReadwrite;
300 bool bBindInterfacesOnly;
301 bool bPamPasswordChange;
302 bool bUnixPasswdSync;
303 bool bPasswdChatDebug;
304 int iPasswdChatTimeout;
308 bool bNTStatusSupport;
310 int iMaxStatCacheSize;
312 bool bAllowTrustedDomains;
316 bool bClientLanManAuth;
317 bool bClientNTLMv2Auth;
318 bool bClientPlaintextAuth;
319 bool bClientUseSpnego;
320 bool bDebugPrefixTimestamp;
321 bool bDebugHiresTimestamp;
325 bool bEnableCoreFiles;
328 bool bHostnameLookups;
329 bool bUnixExtensions;
330 bool bDisableNetbios;
331 char * szDedicatedKeytabFile;
333 bool bDeferSharingViolations;
334 bool bEnablePrivileges;
336 bool bUsershareOwnerOnly;
337 bool bUsershareAllowGuests;
338 bool bRegistryShares;
339 int restrict_anonymous;
340 int name_cache_timeout;
343 int client_ldap_sasl_wrapping;
344 int iUsershareMaxShares;
346 int iIdmapNegativeCacheTime;
350 struct param_opt_struct *param_opt;
351 int cups_connection_timeout;
352 char *szSMBPerfcountModule;
353 bool bMapUntrustedToDomain;
356 static struct global Globals;
359 * This structure describes a single service.
365 time_t usershare_last_mod;
369 char **szInvalidUsers;
377 char *szRootPostExec;
379 char *szPrintcommand;
382 char *szLppausecommand;
383 char *szLpresumecommand;
384 char *szQueuepausecommand;
385 char *szQueueresumecommand;
387 char *szPrintjobUsername;
395 char *szVetoOplockFiles;
401 char **printer_admin;
406 char *szAioWriteBehind;
410 int iMaxReportedPrintJobs;
413 int iCreate_force_mode;
415 int iSecurity_force_mode;
418 int iDir_Security_mask;
419 int iDir_Security_force_mode;
423 int iOplockContentionLimit;
428 bool bRootpreexecClose;
431 bool bShortCasePreserve;
433 bool bHideSpecialFiles;
434 bool bHideUnReadable;
435 bool bHideUnWriteableFiles;
437 bool bAccessBasedShareEnum;
442 bool bAdministrative_share;
448 bool bStoreDosAttributes;
461 bool bStrictAllocate;
464 struct bitmap *copymap;
465 bool bDeleteReadonly;
467 bool bDeleteVetoFiles;
470 bool bDosFiletimeResolution;
471 bool bFakeDirCreateTimes;
477 bool bUseClientDriver;
478 bool bDefaultDevmode;
479 bool bForcePrintername;
481 bool bForceUnknownAclUser;
484 bool bMap_acl_inherit;
487 bool bAclCheckPermissions;
488 bool bAclMapFullControl;
489 bool bAclGroupControl;
491 bool bKernelChangeNotify;
492 int iallocation_roundup_size;
496 int iDirectoryNameCacheSize;
498 struct param_opt_struct *param_opt;
500 char dummy[3]; /* for alignment */
504 /* This is a default service used to prime a services structure */
505 static struct service sDefault = {
507 False, /* not autoloaded */
508 0, /* not a usershare */
509 (time_t)0, /* No last mod time */
510 NULL, /* szService */
512 NULL, /* szUsername */
513 NULL, /* szInvalidUsers */
514 NULL, /* szValidUsers */
515 NULL, /* szAdminUsers */
517 NULL, /* szInclude */
518 NULL, /* szPreExec */
519 NULL, /* szPostExec */
520 NULL, /* szRootPreExec */
521 NULL, /* szRootPostExec */
522 NULL, /* szCupsOptions */
523 NULL, /* szPrintcommand */
524 NULL, /* szLpqcommand */
525 NULL, /* szLprmcommand */
526 NULL, /* szLppausecommand */
527 NULL, /* szLpresumecommand */
528 NULL, /* szQueuepausecommand */
529 NULL, /* szQueueresumecommand */
530 NULL, /* szPrintername */
531 NULL, /* szPrintjobUsername */
532 NULL, /* szDontdescend */
533 NULL, /* szHostsallow */
534 NULL, /* szHostsdeny */
535 NULL, /* szMagicScript */
536 NULL, /* szMagicOutput */
537 NULL, /* szVetoFiles */
538 NULL, /* szHideFiles */
539 NULL, /* szVetoOplockFiles */
541 NULL, /* force user */
542 NULL, /* force group */
544 NULL, /* writelist */
545 NULL, /* printer admin */
548 NULL, /* vfs objects */
549 NULL, /* szMSDfsProxy */
550 NULL, /* szAioWriteBehind */
552 0, /* iMinPrintSpace */
553 1000, /* iMaxPrintJobs */
554 0, /* iMaxReportedPrintJobs */
555 0, /* iWriteCacheSize */
556 0744, /* iCreate_mask */
557 0000, /* iCreate_force_mode */
558 0777, /* iSecurity_mask */
559 0, /* iSecurity_force_mode */
560 0755, /* iDir_mask */
561 0000, /* iDir_force_mode */
562 0777, /* iDir_Security_mask */
563 0, /* iDir_Security_force_mode */
564 0, /* iMaxConnections */
565 CASE_LOWER, /* iDefaultCase */
566 DEFAULT_PRINTING, /* iPrinting */
567 2, /* iOplockContentionLimit */
569 1024, /* iBlock_size */
570 0, /* iDfreeCacheTime */
571 False, /* bPreexecClose */
572 False, /* bRootpreexecClose */
573 Auto, /* case sensitive */
574 True, /* case preserve */
575 True, /* short case preserve */
576 True, /* bHideDotFiles */
577 False, /* bHideSpecialFiles */
578 False, /* bHideUnReadable */
579 False, /* bHideUnWriteableFiles */
580 True, /* bBrowseable */
581 False, /* bAccessBasedShareEnum */
582 True, /* bAvailable */
583 True, /* bRead_only */
584 True, /* bNo_set_dir */
585 False, /* bGuest_only */
586 False, /* bAdministrative_share */
587 False, /* bGuest_ok */
588 False, /* bPrint_ok */
589 False, /* bMap_system */
590 False, /* bMap_hidden */
591 True, /* bMap_archive */
592 False, /* bStoreDosAttributes */
593 False, /* bDmapiSupport */
595 Auto, /* iStrictLocking */
596 True, /* bPosixLocking */
597 True, /* bShareModes */
599 True, /* bLevel2OpLocks */
600 False, /* bOnlyUser */
601 True, /* bMangledNames */
602 True, /* bWidelinks */
603 True, /* bSymlinks */
604 False, /* bSyncAlways */
605 False, /* bStrictAllocate */
606 False, /* bStrictSync */
607 '~', /* magic char */
609 False, /* bDeleteReadonly */
610 False, /* bFakeOplocks */
611 False, /* bDeleteVetoFiles */
612 False, /* bDosFilemode */
613 True, /* bDosFiletimes */
614 False, /* bDosFiletimeResolution */
615 False, /* bFakeDirCreateTimes */
616 True, /* bBlockingLocks */
617 False, /* bInheritPerms */
618 False, /* bInheritACLS */
619 False, /* bInheritOwner */
620 False, /* bMSDfsRoot */
621 False, /* bUseClientDriver */
622 True, /* bDefaultDevmode */
623 False, /* bForcePrintername */
624 True, /* bNTAclSupport */
625 False, /* bForceUnknownAclUser */
626 False, /* bUseSendfile */
627 False, /* bProfileAcls */
628 False, /* bMap_acl_inherit */
629 False, /* bAfs_Share */
630 False, /* bEASupport */
631 True, /* bAclCheckPermissions */
632 True, /* bAclMapFullControl */
633 False, /* bAclGroupControl */
634 True, /* bChangeNotify */
635 True, /* bKernelChangeNotify */
636 SMB_ROUNDUP_ALLOCATION_SIZE, /* iallocation_roundup_size */
637 0, /* iAioReadSize */
638 0, /* iAioWriteSize */
639 MAP_READONLY_YES, /* iMap_readonly */
640 #ifdef BROKEN_DIRECTORY_HANDLING
641 0, /* iDirectoryNameCacheSize */
643 100, /* iDirectoryNameCacheSize */
645 Auto, /* ismb_encrypt */
646 NULL, /* Parametric options */
651 /* local variables */
652 static struct service **ServicePtrs = NULL;
653 static int iNumServices = 0;
654 static int iServiceIndex = 0;
655 static struct db_context *ServiceHash;
656 static int *invalid_services = NULL;
657 static int num_invalid_services = 0;
658 static bool bInGlobalSection = True;
659 static bool bGlobalOnly = False;
660 static int server_role;
661 static int default_server_announce;
663 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
665 /* prototypes for the special type handlers */
666 static bool handle_include( int snum, const char *pszParmValue, char **ptr);
667 static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
668 static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
669 static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
670 static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
671 static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
672 static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
673 static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
674 static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
675 static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
676 static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
677 static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
679 static void set_server_role(void);
680 static void set_default_server_announce_type(void);
681 static void set_allowed_client_auth(void);
683 static void *lp_local_ptr(struct service *service, void *ptr);
685 static void add_to_file_list(const char *fname, const char *subfname);
687 static const struct enum_list enum_protocol[] = {
688 {PROTOCOL_SMB2, "SMB2"},
689 {PROTOCOL_NT1, "NT1"},
690 {PROTOCOL_LANMAN2, "LANMAN2"},
691 {PROTOCOL_LANMAN1, "LANMAN1"},
692 {PROTOCOL_CORE, "CORE"},
693 {PROTOCOL_COREPLUS, "COREPLUS"},
694 {PROTOCOL_COREPLUS, "CORE+"},
698 static const struct enum_list enum_security[] = {
699 {SEC_SHARE, "SHARE"},
701 {SEC_SERVER, "SERVER"},
702 {SEC_DOMAIN, "DOMAIN"},
709 static const struct enum_list enum_printing[] = {
710 {PRINT_SYSV, "sysv"},
712 {PRINT_HPUX, "hpux"},
716 {PRINT_LPRNG, "lprng"},
717 {PRINT_CUPS, "cups"},
718 {PRINT_IPRINT, "iprint"},
720 {PRINT_LPROS2, "os2"},
722 {PRINT_TEST, "test"},
724 #endif /* DEVELOPER */
728 static const struct enum_list enum_ldap_sasl_wrapping[] = {
730 {ADS_AUTH_SASL_SIGN, "sign"},
731 {ADS_AUTH_SASL_SEAL, "seal"},
735 static const struct enum_list enum_ldap_ssl[] = {
736 {LDAP_SSL_OFF, "no"},
737 {LDAP_SSL_OFF, "off"},
738 {LDAP_SSL_START_TLS, "start tls"},
739 {LDAP_SSL_START_TLS, "start_tls"},
743 static const struct enum_list enum_ldap_passwd_sync[] = {
744 {LDAP_PASSWD_SYNC_OFF, "no"},
745 {LDAP_PASSWD_SYNC_OFF, "off"},
746 {LDAP_PASSWD_SYNC_ON, "yes"},
747 {LDAP_PASSWD_SYNC_ON, "on"},
748 {LDAP_PASSWD_SYNC_ONLY, "only"},
752 /* Types of machine we can announce as. */
753 #define ANNOUNCE_AS_NT_SERVER 1
754 #define ANNOUNCE_AS_WIN95 2
755 #define ANNOUNCE_AS_WFW 3
756 #define ANNOUNCE_AS_NT_WORKSTATION 4
758 static const struct enum_list enum_announce_as[] = {
759 {ANNOUNCE_AS_NT_SERVER, "NT"},
760 {ANNOUNCE_AS_NT_SERVER, "NT Server"},
761 {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
762 {ANNOUNCE_AS_WIN95, "win95"},
763 {ANNOUNCE_AS_WFW, "WfW"},
767 static const struct enum_list enum_map_readonly[] = {
768 {MAP_READONLY_NO, "no"},
769 {MAP_READONLY_NO, "false"},
770 {MAP_READONLY_NO, "0"},
771 {MAP_READONLY_YES, "yes"},
772 {MAP_READONLY_YES, "true"},
773 {MAP_READONLY_YES, "1"},
774 {MAP_READONLY_PERMISSIONS, "permissions"},
775 {MAP_READONLY_PERMISSIONS, "perms"},
779 static const struct enum_list enum_case[] = {
780 {CASE_LOWER, "lower"},
781 {CASE_UPPER, "upper"},
787 static const struct enum_list enum_bool_auto[] = {
798 /* Client-side offline caching policy types */
799 #define CSC_POLICY_MANUAL 0
800 #define CSC_POLICY_DOCUMENTS 1
801 #define CSC_POLICY_PROGRAMS 2
802 #define CSC_POLICY_DISABLE 3
804 static const struct enum_list enum_csc_policy[] = {
805 {CSC_POLICY_MANUAL, "manual"},
806 {CSC_POLICY_DOCUMENTS, "documents"},
807 {CSC_POLICY_PROGRAMS, "programs"},
808 {CSC_POLICY_DISABLE, "disable"},
812 /* SMB signing types. */
813 static const struct enum_list enum_smb_signing_vals[] = {
825 {Required, "required"},
826 {Required, "mandatory"},
828 {Required, "forced"},
829 {Required, "enforced"},
833 /* ACL compatibility options. */
834 static const struct enum_list enum_acl_compat_vals[] = {
835 { ACL_COMPAT_AUTO, "auto" },
836 { ACL_COMPAT_WINNT, "winnt" },
837 { ACL_COMPAT_WIN2K, "win2k" },
842 Do you want session setups at user level security with a invalid
843 password to be rejected or allowed in as guest? WinNT rejects them
844 but it can be a pain as it means "net view" needs to use a password
846 You have 3 choices in the setting of map_to_guest:
848 "Never" means session setups with an invalid password
849 are rejected. This is the default.
851 "Bad User" means session setups with an invalid password
852 are rejected, unless the username does not exist, in which case it
853 is treated as a guest login
855 "Bad Password" means session setups with an invalid password
856 are treated as a guest login
858 Note that map_to_guest only has an effect in user or server
862 static const struct enum_list enum_map_to_guest[] = {
863 {NEVER_MAP_TO_GUEST, "Never"},
864 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
865 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
866 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
870 /* Config backend options */
872 static const struct enum_list enum_config_backend[] = {
873 {CONFIG_BACKEND_FILE, "file"},
874 {CONFIG_BACKEND_REGISTRY, "registry"},
878 /* ADS kerberos ticket verification options */
880 static const struct enum_list enum_kerberos_method[] = {
881 {KERBEROS_VERIFY_SECRETS, "default"},
882 {KERBEROS_VERIFY_SECRETS, "secrets only"},
883 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
884 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
885 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
889 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
891 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
892 * screen in SWAT. This is used to exclude parameters as well as to squash all
893 * parameters that have been duplicated by pseudonyms.
895 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
896 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
897 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
900 * NOTE2: Handling of duplicated (synonym) parameters:
901 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
902 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
903 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
904 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
907 static struct parm_struct parm_table[] = {
908 {N_("Base Options"), P_SEP, P_SEPARATOR},
911 .label = "dos charset",
914 .ptr = &Globals.dos_charset,
915 .special = handle_charset,
917 .flags = FLAG_ADVANCED
920 .label = "unix charset",
923 .ptr = &Globals.unix_charset,
924 .special = handle_charset,
926 .flags = FLAG_ADVANCED
929 .label = "display charset",
932 .ptr = &Globals.display_charset,
933 .special = handle_charset,
935 .flags = FLAG_ADVANCED
941 .ptr = &sDefault.comment,
944 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
950 .ptr = &sDefault.szPath,
953 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
956 .label = "directory",
959 .ptr = &sDefault.szPath,
965 .label = "workgroup",
968 .ptr = &Globals.szWorkgroup,
969 .special = handle_workgroup,
971 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
978 .ptr = &Globals.szRealm,
981 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
985 .label = "netbios name",
988 .ptr = &Globals.szNetbiosName,
989 .special = handle_netbios_name,
991 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
994 .label = "netbios aliases",
997 .ptr = &Globals.szNetbiosAliases,
998 .special = handle_netbios_aliases,
1000 .flags = FLAG_ADVANCED,
1003 .label = "netbios scope",
1005 .p_class = P_GLOBAL,
1006 .ptr = &Globals.szNetbiosScope,
1007 .special = handle_netbios_scope,
1009 .flags = FLAG_ADVANCED,
1012 .label = "server string",
1014 .p_class = P_GLOBAL,
1015 .ptr = &Globals.szServerString,
1018 .flags = FLAG_BASIC | FLAG_ADVANCED,
1021 .label = "interfaces",
1023 .p_class = P_GLOBAL,
1024 .ptr = &Globals.szInterfaces,
1027 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1030 .label = "bind interfaces only",
1032 .p_class = P_GLOBAL,
1033 .ptr = &Globals.bBindInterfacesOnly,
1036 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1039 .label = "config backend",
1041 .p_class = P_GLOBAL,
1042 .ptr = &Globals.ConfigBackend,
1044 .enum_list = enum_config_backend,
1045 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
1048 {N_("Security Options"), P_SEP, P_SEPARATOR},
1051 .label = "security",
1053 .p_class = P_GLOBAL,
1054 .ptr = &Globals.security,
1056 .enum_list = enum_security,
1057 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1060 .label = "auth methods",
1062 .p_class = P_GLOBAL,
1063 .ptr = &Globals.AuthMethods,
1066 .flags = FLAG_ADVANCED,
1069 .label = "encrypt passwords",
1071 .p_class = P_GLOBAL,
1072 .ptr = &Globals.bEncryptPasswords,
1075 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1078 .label = "update encrypted",
1080 .p_class = P_GLOBAL,
1081 .ptr = &Globals.bUpdateEncrypt,
1084 .flags = FLAG_ADVANCED,
1087 .label = "client schannel",
1089 .p_class = P_GLOBAL,
1090 .ptr = &Globals.clientSchannel,
1092 .enum_list = enum_bool_auto,
1093 .flags = FLAG_BASIC | FLAG_ADVANCED,
1096 .label = "server schannel",
1098 .p_class = P_GLOBAL,
1099 .ptr = &Globals.serverSchannel,
1101 .enum_list = enum_bool_auto,
1102 .flags = FLAG_BASIC | FLAG_ADVANCED,
1105 .label = "allow trusted domains",
1107 .p_class = P_GLOBAL,
1108 .ptr = &Globals.bAllowTrustedDomains,
1111 .flags = FLAG_ADVANCED,
1114 .label = "map to guest",
1116 .p_class = P_GLOBAL,
1117 .ptr = &Globals.map_to_guest,
1119 .enum_list = enum_map_to_guest,
1120 .flags = FLAG_ADVANCED,
1123 .label = "null passwords",
1125 .p_class = P_GLOBAL,
1126 .ptr = &Globals.bNullPasswords,
1129 .flags = FLAG_ADVANCED,
1132 .label = "obey pam restrictions",
1134 .p_class = P_GLOBAL,
1135 .ptr = &Globals.bObeyPamRestrictions,
1138 .flags = FLAG_ADVANCED,
1141 .label = "password server",
1143 .p_class = P_GLOBAL,
1144 .ptr = &Globals.szPasswordServer,
1147 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1150 .label = "smb passwd file",
1152 .p_class = P_GLOBAL,
1153 .ptr = &Globals.szSMBPasswdFile,
1156 .flags = FLAG_ADVANCED,
1159 .label = "private dir",
1161 .p_class = P_GLOBAL,
1162 .ptr = &Globals.szPrivateDir,
1165 .flags = FLAG_ADVANCED,
1168 .label = "passdb backend",
1170 .p_class = P_GLOBAL,
1171 .ptr = &Globals.szPassdbBackend,
1174 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1177 .label = "algorithmic rid base",
1179 .p_class = P_GLOBAL,
1180 .ptr = &Globals.AlgorithmicRidBase,
1183 .flags = FLAG_ADVANCED,
1186 .label = "root directory",
1188 .p_class = P_GLOBAL,
1189 .ptr = &Globals.szRootdir,
1192 .flags = FLAG_ADVANCED,
1195 .label = "root dir",
1197 .p_class = P_GLOBAL,
1198 .ptr = &Globals.szRootdir,
1206 .p_class = P_GLOBAL,
1207 .ptr = &Globals.szRootdir,
1213 .label = "guest account",
1215 .p_class = P_GLOBAL,
1216 .ptr = &Globals.szGuestaccount,
1219 .flags = FLAG_BASIC | FLAG_ADVANCED,
1222 .label = "enable privileges",
1224 .p_class = P_GLOBAL,
1225 .ptr = &Globals.bEnablePrivileges,
1228 .flags = FLAG_ADVANCED,
1232 .label = "pam password change",
1234 .p_class = P_GLOBAL,
1235 .ptr = &Globals.bPamPasswordChange,
1238 .flags = FLAG_ADVANCED,
1241 .label = "passwd program",
1243 .p_class = P_GLOBAL,
1244 .ptr = &Globals.szPasswdProgram,
1247 .flags = FLAG_ADVANCED,
1250 .label = "passwd chat",
1252 .p_class = P_GLOBAL,
1253 .ptr = &Globals.szPasswdChat,
1256 .flags = FLAG_ADVANCED,
1259 .label = "passwd chat debug",
1261 .p_class = P_GLOBAL,
1262 .ptr = &Globals.bPasswdChatDebug,
1265 .flags = FLAG_ADVANCED,
1268 .label = "passwd chat timeout",
1270 .p_class = P_GLOBAL,
1271 .ptr = &Globals.iPasswdChatTimeout,
1274 .flags = FLAG_ADVANCED,
1277 .label = "check password script",
1279 .p_class = P_GLOBAL,
1280 .ptr = &Globals.szCheckPasswordScript,
1283 .flags = FLAG_ADVANCED,
1286 .label = "username map",
1288 .p_class = P_GLOBAL,
1289 .ptr = &Globals.szUsernameMap,
1292 .flags = FLAG_ADVANCED,
1295 .label = "password level",
1297 .p_class = P_GLOBAL,
1298 .ptr = &Globals.pwordlevel,
1301 .flags = FLAG_ADVANCED,
1304 .label = "username level",
1306 .p_class = P_GLOBAL,
1307 .ptr = &Globals.unamelevel,
1310 .flags = FLAG_ADVANCED,
1313 .label = "unix password sync",
1315 .p_class = P_GLOBAL,
1316 .ptr = &Globals.bUnixPasswdSync,
1319 .flags = FLAG_ADVANCED,
1322 .label = "restrict anonymous",
1324 .p_class = P_GLOBAL,
1325 .ptr = &Globals.restrict_anonymous,
1328 .flags = FLAG_ADVANCED,
1331 .label = "lanman auth",
1333 .p_class = P_GLOBAL,
1334 .ptr = &Globals.bLanmanAuth,
1337 .flags = FLAG_ADVANCED,
1340 .label = "ntlm auth",
1342 .p_class = P_GLOBAL,
1343 .ptr = &Globals.bNTLMAuth,
1346 .flags = FLAG_ADVANCED,
1349 .label = "client NTLMv2 auth",
1351 .p_class = P_GLOBAL,
1352 .ptr = &Globals.bClientNTLMv2Auth,
1355 .flags = FLAG_ADVANCED,
1358 .label = "client lanman auth",
1360 .p_class = P_GLOBAL,
1361 .ptr = &Globals.bClientLanManAuth,
1364 .flags = FLAG_ADVANCED,
1367 .label = "client plaintext auth",
1369 .p_class = P_GLOBAL,
1370 .ptr = &Globals.bClientPlaintextAuth,
1373 .flags = FLAG_ADVANCED,
1376 .label = "username",
1379 .ptr = &sDefault.szUsername,
1382 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1388 .ptr = &sDefault.szUsername,
1397 .ptr = &sDefault.szUsername,
1403 .label = "invalid users",
1406 .ptr = &sDefault.szInvalidUsers,
1409 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1412 .label = "valid users",
1415 .ptr = &sDefault.szValidUsers,
1418 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1421 .label = "admin users",
1424 .ptr = &sDefault.szAdminUsers,
1427 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1430 .label = "read list",
1433 .ptr = &sDefault.readlist,
1436 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1439 .label = "write list",
1442 .ptr = &sDefault.writelist,
1445 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1448 .label = "printer admin",
1451 .ptr = &sDefault.printer_admin,
1454 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1457 .label = "force user",
1460 .ptr = &sDefault.force_user,
1463 .flags = FLAG_ADVANCED | FLAG_SHARE,
1466 .label = "force group",
1469 .ptr = &sDefault.force_group,
1472 .flags = FLAG_ADVANCED | FLAG_SHARE,
1478 .ptr = &sDefault.force_group,
1481 .flags = FLAG_ADVANCED,
1484 .label = "read only",
1487 .ptr = &sDefault.bRead_only,
1490 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1493 .label = "write ok",
1496 .ptr = &sDefault.bRead_only,
1502 .label = "writeable",
1505 .ptr = &sDefault.bRead_only,
1511 .label = "writable",
1514 .ptr = &sDefault.bRead_only,
1520 .label = "acl check permissions",
1523 .ptr = &sDefault.bAclCheckPermissions,
1526 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1529 .label = "acl group control",
1532 .ptr = &sDefault.bAclGroupControl,
1535 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1538 .label = "acl map full control",
1541 .ptr = &sDefault.bAclMapFullControl,
1544 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1547 .label = "create mask",
1550 .ptr = &sDefault.iCreate_mask,
1553 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1556 .label = "create mode",
1559 .ptr = &sDefault.iCreate_mask,
1565 .label = "force create mode",
1568 .ptr = &sDefault.iCreate_force_mode,
1571 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1574 .label = "security mask",
1577 .ptr = &sDefault.iSecurity_mask,
1580 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1583 .label = "force security mode",
1586 .ptr = &sDefault.iSecurity_force_mode,
1589 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1592 .label = "directory mask",
1595 .ptr = &sDefault.iDir_mask,
1598 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1601 .label = "directory mode",
1604 .ptr = &sDefault.iDir_mask,
1607 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1610 .label = "force directory mode",
1613 .ptr = &sDefault.iDir_force_mode,
1616 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1619 .label = "directory security mask",
1622 .ptr = &sDefault.iDir_Security_mask,
1625 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1628 .label = "force directory security mode",
1631 .ptr = &sDefault.iDir_Security_force_mode,
1634 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1637 .label = "force unknown acl user",
1640 .ptr = &sDefault.bForceUnknownAclUser,
1643 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1646 .label = "inherit permissions",
1649 .ptr = &sDefault.bInheritPerms,
1652 .flags = FLAG_ADVANCED | FLAG_SHARE,
1655 .label = "inherit acls",
1658 .ptr = &sDefault.bInheritACLS,
1661 .flags = FLAG_ADVANCED | FLAG_SHARE,
1664 .label = "inherit owner",
1667 .ptr = &sDefault.bInheritOwner,
1670 .flags = FLAG_ADVANCED | FLAG_SHARE,
1673 .label = "guest only",
1676 .ptr = &sDefault.bGuest_only,
1679 .flags = FLAG_ADVANCED | FLAG_SHARE,
1682 .label = "only guest",
1685 .ptr = &sDefault.bGuest_only,
1691 .label = "administrative share",
1694 .ptr = &sDefault.bAdministrative_share,
1697 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1701 .label = "guest ok",
1704 .ptr = &sDefault.bGuest_ok,
1707 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1713 .ptr = &sDefault.bGuest_ok,
1719 .label = "only user",
1722 .ptr = &sDefault.bOnlyUser,
1725 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1728 .label = "hosts allow",
1731 .ptr = &sDefault.szHostsallow,
1734 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1737 .label = "allow hosts",
1740 .ptr = &sDefault.szHostsallow,
1746 .label = "hosts deny",
1749 .ptr = &sDefault.szHostsdeny,
1752 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1755 .label = "deny hosts",
1758 .ptr = &sDefault.szHostsdeny,
1764 .label = "preload modules",
1766 .p_class = P_GLOBAL,
1767 .ptr = &Globals.szPreloadModules,
1770 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1773 .label = "dedicated keytab file",
1775 .p_class = P_GLOBAL,
1776 .ptr = &Globals.szDedicatedKeytabFile,
1779 .flags = FLAG_ADVANCED,
1782 .label = "kerberos method",
1784 .p_class = P_GLOBAL,
1785 .ptr = &Globals.iKerberosMethod,
1787 .enum_list = enum_kerberos_method,
1788 .flags = FLAG_ADVANCED,
1791 .label = "map untrusted to domain",
1793 .p_class = P_GLOBAL,
1794 .ptr = &Globals.bMapUntrustedToDomain,
1797 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1801 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1804 .label = "log level",
1806 .p_class = P_GLOBAL,
1807 .ptr = &Globals.szLogLevel,
1808 .special = handle_debug_list,
1810 .flags = FLAG_ADVANCED,
1813 .label = "debuglevel",
1815 .p_class = P_GLOBAL,
1816 .ptr = &Globals.szLogLevel,
1817 .special = handle_debug_list,
1824 .p_class = P_GLOBAL,
1825 .ptr = &Globals.syslog,
1828 .flags = FLAG_ADVANCED,
1831 .label = "syslog only",
1833 .p_class = P_GLOBAL,
1834 .ptr = &Globals.bSyslogOnly,
1837 .flags = FLAG_ADVANCED,
1840 .label = "log file",
1842 .p_class = P_GLOBAL,
1843 .ptr = &Globals.szLogFile,
1846 .flags = FLAG_ADVANCED,
1849 .label = "max log size",
1851 .p_class = P_GLOBAL,
1852 .ptr = &Globals.max_log_size,
1855 .flags = FLAG_ADVANCED,
1858 .label = "debug timestamp",
1860 .p_class = P_GLOBAL,
1861 .ptr = &Globals.bTimestampLogs,
1864 .flags = FLAG_ADVANCED,
1867 .label = "timestamp logs",
1869 .p_class = P_GLOBAL,
1870 .ptr = &Globals.bTimestampLogs,
1873 .flags = FLAG_ADVANCED,
1876 .label = "debug prefix timestamp",
1878 .p_class = P_GLOBAL,
1879 .ptr = &Globals.bDebugPrefixTimestamp,
1882 .flags = FLAG_ADVANCED,
1885 .label = "debug hires timestamp",
1887 .p_class = P_GLOBAL,
1888 .ptr = &Globals.bDebugHiresTimestamp,
1891 .flags = FLAG_ADVANCED,
1894 .label = "debug pid",
1896 .p_class = P_GLOBAL,
1897 .ptr = &Globals.bDebugPid,
1900 .flags = FLAG_ADVANCED,
1903 .label = "debug uid",
1905 .p_class = P_GLOBAL,
1906 .ptr = &Globals.bDebugUid,
1909 .flags = FLAG_ADVANCED,
1912 .label = "debug class",
1914 .p_class = P_GLOBAL,
1915 .ptr = &Globals.bDebugClass,
1918 .flags = FLAG_ADVANCED,
1921 .label = "enable core files",
1923 .p_class = P_GLOBAL,
1924 .ptr = &Globals.bEnableCoreFiles,
1927 .flags = FLAG_ADVANCED,
1930 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1933 .label = "allocation roundup size",
1936 .ptr = &sDefault.iallocation_roundup_size,
1939 .flags = FLAG_ADVANCED,
1942 .label = "aio read size",
1945 .ptr = &sDefault.iAioReadSize,
1948 .flags = FLAG_ADVANCED,
1951 .label = "aio write size",
1954 .ptr = &sDefault.iAioWriteSize,
1957 .flags = FLAG_ADVANCED,
1960 .label = "aio write behind",
1963 .ptr = &sDefault.szAioWriteBehind,
1966 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1969 .label = "smb ports",
1971 .p_class = P_GLOBAL,
1972 .ptr = &Globals.smb_ports,
1975 .flags = FLAG_ADVANCED,
1978 .label = "large readwrite",
1980 .p_class = P_GLOBAL,
1981 .ptr = &Globals.bLargeReadwrite,
1984 .flags = FLAG_ADVANCED,
1987 .label = "max protocol",
1989 .p_class = P_GLOBAL,
1990 .ptr = &Globals.maxprotocol,
1992 .enum_list = enum_protocol,
1993 .flags = FLAG_ADVANCED,
1996 .label = "protocol",
1998 .p_class = P_GLOBAL,
1999 .ptr = &Globals.maxprotocol,
2001 .enum_list = enum_protocol,
2002 .flags = FLAG_ADVANCED,
2005 .label = "min protocol",
2007 .p_class = P_GLOBAL,
2008 .ptr = &Globals.minprotocol,
2010 .enum_list = enum_protocol,
2011 .flags = FLAG_ADVANCED,
2014 .label = "min receivefile size",
2016 .p_class = P_GLOBAL,
2017 .ptr = &Globals.iminreceivefile,
2020 .flags = FLAG_ADVANCED,
2023 .label = "read raw",
2025 .p_class = P_GLOBAL,
2026 .ptr = &Globals.bReadRaw,
2029 .flags = FLAG_ADVANCED,
2032 .label = "write raw",
2034 .p_class = P_GLOBAL,
2035 .ptr = &Globals.bWriteRaw,
2038 .flags = FLAG_ADVANCED,
2041 .label = "disable netbios",
2043 .p_class = P_GLOBAL,
2044 .ptr = &Globals.bDisableNetbios,
2047 .flags = FLAG_ADVANCED,
2050 .label = "reset on zero vc",
2052 .p_class = P_GLOBAL,
2053 .ptr = &Globals.bResetOnZeroVC,
2056 .flags = FLAG_ADVANCED,
2059 .label = "acl compatibility",
2061 .p_class = P_GLOBAL,
2062 .ptr = &Globals.iAclCompat,
2064 .enum_list = enum_acl_compat_vals,
2065 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2068 .label = "defer sharing violations",
2070 .p_class = P_GLOBAL,
2071 .ptr = &Globals.bDeferSharingViolations,
2074 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2077 .label = "ea support",
2080 .ptr = &sDefault.bEASupport,
2083 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2086 .label = "nt acl support",
2089 .ptr = &sDefault.bNTAclSupport,
2092 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2095 .label = "nt pipe support",
2097 .p_class = P_GLOBAL,
2098 .ptr = &Globals.bNTPipeSupport,
2101 .flags = FLAG_ADVANCED,
2104 .label = "nt status support",
2106 .p_class = P_GLOBAL,
2107 .ptr = &Globals.bNTStatusSupport,
2110 .flags = FLAG_ADVANCED,
2113 .label = "profile acls",
2116 .ptr = &sDefault.bProfileAcls,
2119 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
2122 .label = "announce version",
2124 .p_class = P_GLOBAL,
2125 .ptr = &Globals.szAnnounceVersion,
2128 .flags = FLAG_ADVANCED,
2131 .label = "announce as",
2133 .p_class = P_GLOBAL,
2134 .ptr = &Globals.announce_as,
2136 .enum_list = enum_announce_as,
2137 .flags = FLAG_ADVANCED,
2140 .label = "map acl inherit",
2143 .ptr = &sDefault.bMap_acl_inherit,
2146 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2149 .label = "afs share",
2152 .ptr = &sDefault.bAfs_Share,
2155 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2160 .p_class = P_GLOBAL,
2161 .ptr = &Globals.max_mux,
2164 .flags = FLAG_ADVANCED,
2167 .label = "max xmit",
2169 .p_class = P_GLOBAL,
2170 .ptr = &Globals.max_xmit,
2173 .flags = FLAG_ADVANCED,
2176 .label = "name resolve order",
2178 .p_class = P_GLOBAL,
2179 .ptr = &Globals.szNameResolveOrder,
2182 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2187 .p_class = P_GLOBAL,
2188 .ptr = &Globals.max_ttl,
2191 .flags = FLAG_ADVANCED,
2194 .label = "max wins ttl",
2196 .p_class = P_GLOBAL,
2197 .ptr = &Globals.max_wins_ttl,
2200 .flags = FLAG_ADVANCED,
2203 .label = "min wins ttl",
2205 .p_class = P_GLOBAL,
2206 .ptr = &Globals.min_wins_ttl,
2209 .flags = FLAG_ADVANCED,
2212 .label = "time server",
2214 .p_class = P_GLOBAL,
2215 .ptr = &Globals.bTimeServer,
2218 .flags = FLAG_ADVANCED,
2221 .label = "unix extensions",
2223 .p_class = P_GLOBAL,
2224 .ptr = &Globals.bUnixExtensions,
2227 .flags = FLAG_ADVANCED,
2230 .label = "use spnego",
2232 .p_class = P_GLOBAL,
2233 .ptr = &Globals.bUseSpnego,
2236 .flags = FLAG_ADVANCED,
2239 .label = "client signing",
2241 .p_class = P_GLOBAL,
2242 .ptr = &Globals.client_signing,
2244 .enum_list = enum_smb_signing_vals,
2245 .flags = FLAG_ADVANCED,
2248 .label = "server signing",
2250 .p_class = P_GLOBAL,
2251 .ptr = &Globals.server_signing,
2253 .enum_list = enum_smb_signing_vals,
2254 .flags = FLAG_ADVANCED,
2257 .label = "smb encrypt",
2260 .ptr = &sDefault.ismb_encrypt,
2262 .enum_list = enum_smb_signing_vals,
2263 .flags = FLAG_ADVANCED,
2266 .label = "client use spnego",
2268 .p_class = P_GLOBAL,
2269 .ptr = &Globals.bClientUseSpnego,
2272 .flags = FLAG_ADVANCED,
2275 .label = "client ldap sasl wrapping",
2277 .p_class = P_GLOBAL,
2278 .ptr = &Globals.client_ldap_sasl_wrapping,
2280 .enum_list = enum_ldap_sasl_wrapping,
2281 .flags = FLAG_ADVANCED,
2284 .label = "enable asu support",
2286 .p_class = P_GLOBAL,
2287 .ptr = &Globals.bASUSupport,
2290 .flags = FLAG_ADVANCED,
2293 .label = "svcctl list",
2295 .p_class = P_GLOBAL,
2296 .ptr = &Globals.szServicesList,
2299 .flags = FLAG_ADVANCED,
2302 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
2305 .label = "block size",
2308 .ptr = &sDefault.iBlock_size,
2311 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2314 .label = "deadtime",
2316 .p_class = P_GLOBAL,
2317 .ptr = &Globals.deadtime,
2320 .flags = FLAG_ADVANCED,
2323 .label = "getwd cache",
2325 .p_class = P_GLOBAL,
2326 .ptr = &Globals.getwd_cache,
2329 .flags = FLAG_ADVANCED,
2332 .label = "keepalive",
2334 .p_class = P_GLOBAL,
2335 .ptr = &Globals.iKeepalive,
2338 .flags = FLAG_ADVANCED,
2341 .label = "change notify",
2344 .ptr = &sDefault.bChangeNotify,
2347 .flags = FLAG_ADVANCED | FLAG_SHARE,
2350 .label = "directory name cache size",
2353 .ptr = &sDefault.iDirectoryNameCacheSize,
2356 .flags = FLAG_ADVANCED | FLAG_SHARE,
2359 .label = "kernel change notify",
2362 .ptr = &sDefault.bKernelChangeNotify,
2365 .flags = FLAG_ADVANCED | FLAG_SHARE,
2368 .label = "lpq cache time",
2370 .p_class = P_GLOBAL,
2371 .ptr = &Globals.lpqcachetime,
2374 .flags = FLAG_ADVANCED,
2377 .label = "max smbd processes",
2379 .p_class = P_GLOBAL,
2380 .ptr = &Globals.iMaxSmbdProcesses,
2383 .flags = FLAG_ADVANCED,
2386 .label = "max connections",
2389 .ptr = &sDefault.iMaxConnections,
2392 .flags = FLAG_ADVANCED | FLAG_SHARE,
2395 .label = "paranoid server security",
2397 .p_class = P_GLOBAL,
2398 .ptr = &Globals.paranoid_server_security,
2401 .flags = FLAG_ADVANCED,
2404 .label = "max disk size",
2406 .p_class = P_GLOBAL,
2407 .ptr = &Globals.maxdisksize,
2410 .flags = FLAG_ADVANCED,
2413 .label = "max open files",
2415 .p_class = P_GLOBAL,
2416 .ptr = &Globals.max_open_files,
2419 .flags = FLAG_ADVANCED,
2422 .label = "min print space",
2425 .ptr = &sDefault.iMinPrintSpace,
2428 .flags = FLAG_ADVANCED | FLAG_PRINT,
2431 .label = "socket options",
2433 .p_class = P_GLOBAL,
2434 .ptr = &Globals.szSocketOptions,
2437 .flags = FLAG_ADVANCED,
2440 .label = "strict allocate",
2443 .ptr = &sDefault.bStrictAllocate,
2446 .flags = FLAG_ADVANCED | FLAG_SHARE,
2449 .label = "strict sync",
2452 .ptr = &sDefault.bStrictSync,
2455 .flags = FLAG_ADVANCED | FLAG_SHARE,
2458 .label = "sync always",
2461 .ptr = &sDefault.bSyncAlways,
2464 .flags = FLAG_ADVANCED | FLAG_SHARE,
2467 .label = "use mmap",
2469 .p_class = P_GLOBAL,
2470 .ptr = &Globals.bUseMmap,
2473 .flags = FLAG_ADVANCED,
2476 .label = "use sendfile",
2479 .ptr = &sDefault.bUseSendfile,
2482 .flags = FLAG_ADVANCED | FLAG_SHARE,
2485 .label = "hostname lookups",
2487 .p_class = P_GLOBAL,
2488 .ptr = &Globals.bHostnameLookups,
2491 .flags = FLAG_ADVANCED,
2494 .label = "write cache size",
2497 .ptr = &sDefault.iWriteCacheSize,
2500 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
2503 .label = "name cache timeout",
2505 .p_class = P_GLOBAL,
2506 .ptr = &Globals.name_cache_timeout,
2509 .flags = FLAG_ADVANCED,
2512 .label = "ctdbd socket",
2514 .p_class = P_GLOBAL,
2515 .ptr = &Globals.ctdbdSocket,
2518 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2521 .label = "cluster addresses",
2523 .p_class = P_GLOBAL,
2524 .ptr = &Globals.szClusterAddresses,
2527 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2530 .label = "clustering",
2532 .p_class = P_GLOBAL,
2533 .ptr = &Globals.clustering,
2536 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2539 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2542 .label = "max reported print jobs",
2545 .ptr = &sDefault.iMaxReportedPrintJobs,
2548 .flags = FLAG_ADVANCED | FLAG_PRINT,
2551 .label = "max print jobs",
2554 .ptr = &sDefault.iMaxPrintJobs,
2557 .flags = FLAG_ADVANCED | FLAG_PRINT,
2560 .label = "load printers",
2562 .p_class = P_GLOBAL,
2563 .ptr = &Globals.bLoadPrinters,
2566 .flags = FLAG_ADVANCED | FLAG_PRINT,
2569 .label = "printcap cache time",
2571 .p_class = P_GLOBAL,
2572 .ptr = &Globals.PrintcapCacheTime,
2575 .flags = FLAG_ADVANCED | FLAG_PRINT,
2578 .label = "printcap name",
2580 .p_class = P_GLOBAL,
2581 .ptr = &Globals.szPrintcapname,
2584 .flags = FLAG_ADVANCED | FLAG_PRINT,
2587 .label = "printcap",
2589 .p_class = P_GLOBAL,
2590 .ptr = &Globals.szPrintcapname,
2596 .label = "printable",
2599 .ptr = &sDefault.bPrint_ok,
2602 .flags = FLAG_ADVANCED | FLAG_PRINT,
2605 .label = "print ok",
2608 .ptr = &sDefault.bPrint_ok,
2614 .label = "printing",
2617 .ptr = &sDefault.iPrinting,
2618 .special = handle_printing,
2619 .enum_list = enum_printing,
2620 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2623 .label = "cups options",
2626 .ptr = &sDefault.szCupsOptions,
2629 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2632 .label = "cups server",
2634 .p_class = P_GLOBAL,
2635 .ptr = &Globals.szCupsServer,
2638 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2641 .label = "cups encrypt",
2643 .p_class = P_GLOBAL,
2644 .ptr = &Globals.CupsEncrypt,
2646 .enum_list = enum_bool_auto,
2647 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2651 .label = "cups connection timeout",
2653 .p_class = P_GLOBAL,
2654 .ptr = &Globals.cups_connection_timeout,
2657 .flags = FLAG_ADVANCED,
2660 .label = "iprint server",
2662 .p_class = P_GLOBAL,
2663 .ptr = &Globals.szIPrintServer,
2666 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2669 .label = "print command",
2672 .ptr = &sDefault.szPrintcommand,
2675 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2678 .label = "disable spoolss",
2680 .p_class = P_GLOBAL,
2681 .ptr = &Globals.bDisableSpoolss,
2684 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2687 .label = "enable spoolss",
2689 .p_class = P_GLOBAL,
2690 .ptr = &Globals.bDisableSpoolss,
2696 .label = "lpq command",
2699 .ptr = &sDefault.szLpqcommand,
2702 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2705 .label = "lprm command",
2708 .ptr = &sDefault.szLprmcommand,
2711 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2714 .label = "lppause command",
2717 .ptr = &sDefault.szLppausecommand,
2720 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2723 .label = "lpresume command",
2726 .ptr = &sDefault.szLpresumecommand,
2729 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2732 .label = "queuepause command",
2735 .ptr = &sDefault.szQueuepausecommand,
2738 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2741 .label = "queueresume command",
2744 .ptr = &sDefault.szQueueresumecommand,
2747 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2750 .label = "addport command",
2752 .p_class = P_GLOBAL,
2753 .ptr = &Globals.szAddPortCommand,
2756 .flags = FLAG_ADVANCED,
2759 .label = "enumports command",
2761 .p_class = P_GLOBAL,
2762 .ptr = &Globals.szEnumPortsCommand,
2765 .flags = FLAG_ADVANCED,
2768 .label = "addprinter command",
2770 .p_class = P_GLOBAL,
2771 .ptr = &Globals.szAddPrinterCommand,
2774 .flags = FLAG_ADVANCED,
2777 .label = "deleteprinter command",
2779 .p_class = P_GLOBAL,
2780 .ptr = &Globals.szDeletePrinterCommand,
2783 .flags = FLAG_ADVANCED,
2786 .label = "show add printer wizard",
2788 .p_class = P_GLOBAL,
2789 .ptr = &Globals.bMsAddPrinterWizard,
2792 .flags = FLAG_ADVANCED,
2795 .label = "os2 driver map",
2797 .p_class = P_GLOBAL,
2798 .ptr = &Globals.szOs2DriverMap,
2801 .flags = FLAG_ADVANCED,
2805 .label = "printer name",
2808 .ptr = &sDefault.szPrintername,
2811 .flags = FLAG_ADVANCED | FLAG_PRINT,
2817 .ptr = &sDefault.szPrintername,
2823 .label = "use client driver",
2826 .ptr = &sDefault.bUseClientDriver,
2829 .flags = FLAG_ADVANCED | FLAG_PRINT,
2832 .label = "default devmode",
2835 .ptr = &sDefault.bDefaultDevmode,
2838 .flags = FLAG_ADVANCED | FLAG_PRINT,
2841 .label = "force printername",
2844 .ptr = &sDefault.bForcePrintername,
2847 .flags = FLAG_ADVANCED | FLAG_PRINT,
2850 .label = "printjob username",
2853 .ptr = &sDefault.szPrintjobUsername,
2856 .flags = FLAG_ADVANCED | FLAG_PRINT,
2859 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2862 .label = "mangling method",
2864 .p_class = P_GLOBAL,
2865 .ptr = &Globals.szManglingMethod,
2868 .flags = FLAG_ADVANCED,
2871 .label = "mangle prefix",
2873 .p_class = P_GLOBAL,
2874 .ptr = &Globals.mangle_prefix,
2877 .flags = FLAG_ADVANCED,
2881 .label = "default case",
2884 .ptr = &sDefault.iDefaultCase,
2886 .enum_list = enum_case,
2887 .flags = FLAG_ADVANCED | FLAG_SHARE,
2890 .label = "case sensitive",
2893 .ptr = &sDefault.iCaseSensitive,
2895 .enum_list = enum_bool_auto,
2896 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2899 .label = "casesignames",
2902 .ptr = &sDefault.iCaseSensitive,
2904 .enum_list = enum_bool_auto,
2905 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2908 .label = "preserve case",
2911 .ptr = &sDefault.bCasePreserve,
2914 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2917 .label = "short preserve case",
2920 .ptr = &sDefault.bShortCasePreserve,
2923 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2926 .label = "mangling char",
2929 .ptr = &sDefault.magic_char,
2932 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2935 .label = "hide dot files",
2938 .ptr = &sDefault.bHideDotFiles,
2941 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2944 .label = "hide special files",
2947 .ptr = &sDefault.bHideSpecialFiles,
2950 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2953 .label = "hide unreadable",
2956 .ptr = &sDefault.bHideUnReadable,
2959 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2962 .label = "hide unwriteable files",
2965 .ptr = &sDefault.bHideUnWriteableFiles,
2968 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2971 .label = "delete veto files",
2974 .ptr = &sDefault.bDeleteVetoFiles,
2977 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2980 .label = "veto files",
2983 .ptr = &sDefault.szVetoFiles,
2986 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2989 .label = "hide files",
2992 .ptr = &sDefault.szHideFiles,
2995 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2998 .label = "veto oplock files",
3001 .ptr = &sDefault.szVetoOplockFiles,
3004 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3007 .label = "map archive",
3010 .ptr = &sDefault.bMap_archive,
3013 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3016 .label = "map hidden",
3019 .ptr = &sDefault.bMap_hidden,
3022 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3025 .label = "map system",
3028 .ptr = &sDefault.bMap_system,
3031 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3034 .label = "map readonly",
3037 .ptr = &sDefault.iMap_readonly,
3039 .enum_list = enum_map_readonly,
3040 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3043 .label = "mangled names",
3046 .ptr = &sDefault.bMangledNames,
3049 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3052 .label = "max stat cache size",
3054 .p_class = P_GLOBAL,
3055 .ptr = &Globals.iMaxStatCacheSize,
3058 .flags = FLAG_ADVANCED,
3061 .label = "stat cache",
3063 .p_class = P_GLOBAL,
3064 .ptr = &Globals.bStatCache,
3067 .flags = FLAG_ADVANCED,
3070 .label = "store dos attributes",
3073 .ptr = &sDefault.bStoreDosAttributes,
3076 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3079 .label = "dmapi support",
3082 .ptr = &sDefault.bDmapiSupport,
3085 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3089 {N_("Domain Options"), P_SEP, P_SEPARATOR},
3092 .label = "machine password timeout",
3094 .p_class = P_GLOBAL,
3095 .ptr = &Globals.machine_password_timeout,
3098 .flags = FLAG_ADVANCED | FLAG_WIZARD,
3101 {N_("Logon Options"), P_SEP, P_SEPARATOR},
3104 .label = "add user script",
3106 .p_class = P_GLOBAL,
3107 .ptr = &Globals.szAddUserScript,
3110 .flags = FLAG_ADVANCED,
3113 .label = "rename user script",
3115 .p_class = P_GLOBAL,
3116 .ptr = &Globals.szRenameUserScript,
3119 .flags = FLAG_ADVANCED,
3122 .label = "delete user script",
3124 .p_class = P_GLOBAL,
3125 .ptr = &Globals.szDelUserScript,
3128 .flags = FLAG_ADVANCED,
3131 .label = "add group script",
3133 .p_class = P_GLOBAL,
3134 .ptr = &Globals.szAddGroupScript,
3137 .flags = FLAG_ADVANCED,
3140 .label = "delete group script",
3142 .p_class = P_GLOBAL,
3143 .ptr = &Globals.szDelGroupScript,
3146 .flags = FLAG_ADVANCED,
3149 .label = "add user to group script",
3151 .p_class = P_GLOBAL,
3152 .ptr = &Globals.szAddUserToGroupScript,
3155 .flags = FLAG_ADVANCED,
3158 .label = "delete user from group script",
3160 .p_class = P_GLOBAL,
3161 .ptr = &Globals.szDelUserFromGroupScript,
3164 .flags = FLAG_ADVANCED,
3167 .label = "set primary group script",
3169 .p_class = P_GLOBAL,
3170 .ptr = &Globals.szSetPrimaryGroupScript,
3173 .flags = FLAG_ADVANCED,
3176 .label = "add machine script",
3178 .p_class = P_GLOBAL,
3179 .ptr = &Globals.szAddMachineScript,
3182 .flags = FLAG_ADVANCED,
3185 .label = "shutdown script",
3187 .p_class = P_GLOBAL,
3188 .ptr = &Globals.szShutdownScript,
3191 .flags = FLAG_ADVANCED,
3194 .label = "abort shutdown script",
3196 .p_class = P_GLOBAL,
3197 .ptr = &Globals.szAbortShutdownScript,
3200 .flags = FLAG_ADVANCED,
3203 .label = "username map script",
3205 .p_class = P_GLOBAL,
3206 .ptr = &Globals.szUsernameMapScript,
3209 .flags = FLAG_ADVANCED,
3212 .label = "logon script",
3214 .p_class = P_GLOBAL,
3215 .ptr = &Globals.szLogonScript,
3218 .flags = FLAG_ADVANCED,
3221 .label = "logon path",
3223 .p_class = P_GLOBAL,
3224 .ptr = &Globals.szLogonPath,
3227 .flags = FLAG_ADVANCED,
3230 .label = "logon drive",
3232 .p_class = P_GLOBAL,
3233 .ptr = &Globals.szLogonDrive,
3236 .flags = FLAG_ADVANCED,
3239 .label = "logon home",
3241 .p_class = P_GLOBAL,
3242 .ptr = &Globals.szLogonHome,
3245 .flags = FLAG_ADVANCED,
3248 .label = "domain logons",
3250 .p_class = P_GLOBAL,
3251 .ptr = &Globals.bDomainLogons,
3254 .flags = FLAG_ADVANCED,
3258 .label = "init logon delayed hosts",
3260 .p_class = P_GLOBAL,
3261 .ptr = &Globals.szInitLogonDelayedHosts,
3262 .flags = FLAG_ADVANCED,
3266 .label = "init logon delay",
3268 .p_class = P_GLOBAL,
3269 .ptr = &Globals.InitLogonDelay,
3270 .flags = FLAG_ADVANCED,
3274 {N_("Browse Options"), P_SEP, P_SEPARATOR},
3277 .label = "os level",
3279 .p_class = P_GLOBAL,
3280 .ptr = &Globals.os_level,
3283 .flags = FLAG_BASIC | FLAG_ADVANCED,
3286 .label = "lm announce",
3288 .p_class = P_GLOBAL,
3289 .ptr = &Globals.lm_announce,
3291 .enum_list = enum_bool_auto,
3292 .flags = FLAG_ADVANCED,
3295 .label = "lm interval",
3297 .p_class = P_GLOBAL,
3298 .ptr = &Globals.lm_interval,
3301 .flags = FLAG_ADVANCED,
3304 .label = "preferred master",
3306 .p_class = P_GLOBAL,
3307 .ptr = &Globals.iPreferredMaster,
3309 .enum_list = enum_bool_auto,
3310 .flags = FLAG_BASIC | FLAG_ADVANCED,
3313 .label = "prefered master",
3315 .p_class = P_GLOBAL,
3316 .ptr = &Globals.iPreferredMaster,
3318 .enum_list = enum_bool_auto,
3322 .label = "local master",
3324 .p_class = P_GLOBAL,
3325 .ptr = &Globals.bLocalMaster,
3328 .flags = FLAG_BASIC | FLAG_ADVANCED,
3331 .label = "domain master",
3333 .p_class = P_GLOBAL,
3334 .ptr = &Globals.iDomainMaster,
3336 .enum_list = enum_bool_auto,
3337 .flags = FLAG_BASIC | FLAG_ADVANCED,
3340 .label = "browse list",
3342 .p_class = P_GLOBAL,
3343 .ptr = &Globals.bBrowseList,
3346 .flags = FLAG_ADVANCED,
3349 .label = "browseable",
3352 .ptr = &sDefault.bBrowseable,
3355 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3358 .label = "browsable",
3361 .ptr = &sDefault.bBrowseable,
3367 .label = "access based share enum",
3370 .ptr = &sDefault.bAccessBasedShareEnum,
3373 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3376 .label = "enhanced browsing",
3378 .p_class = P_GLOBAL,
3379 .ptr = &Globals.enhanced_browsing,
3382 .flags = FLAG_ADVANCED,
3385 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3388 .label = "dns proxy",
3390 .p_class = P_GLOBAL,
3391 .ptr = &Globals.bDNSproxy,
3394 .flags = FLAG_ADVANCED,
3397 .label = "wins proxy",
3399 .p_class = P_GLOBAL,
3400 .ptr = &Globals.bWINSproxy,
3403 .flags = FLAG_ADVANCED,
3406 .label = "wins server",
3408 .p_class = P_GLOBAL,
3409 .ptr = &Globals.szWINSservers,
3412 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3415 .label = "wins support",
3417 .p_class = P_GLOBAL,
3418 .ptr = &Globals.bWINSsupport,
3421 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3424 .label = "wins hook",
3426 .p_class = P_GLOBAL,
3427 .ptr = &Globals.szWINSHook,
3430 .flags = FLAG_ADVANCED,
3433 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3436 .label = "blocking locks",
3439 .ptr = &sDefault.bBlockingLocks,
3442 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3445 .label = "csc policy",
3448 .ptr = &sDefault.iCSCPolicy,
3450 .enum_list = enum_csc_policy,
3451 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3454 .label = "fake oplocks",
3457 .ptr = &sDefault.bFakeOplocks,
3460 .flags = FLAG_ADVANCED | FLAG_SHARE,
3463 .label = "kernel oplocks",
3465 .p_class = P_GLOBAL,
3466 .ptr = &Globals.bKernelOplocks,
3469 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3475 .ptr = &sDefault.bLocking,
3478 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3481 .label = "lock spin time",
3483 .p_class = P_GLOBAL,
3484 .ptr = &Globals.iLockSpinTime,
3487 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3493 .ptr = &sDefault.bOpLocks,
3496 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3499 .label = "level2 oplocks",
3502 .ptr = &sDefault.bLevel2OpLocks,
3505 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3508 .label = "oplock break wait time",
3510 .p_class = P_GLOBAL,
3511 .ptr = &Globals.oplock_break_wait_time,
3514 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3517 .label = "oplock contention limit",
3520 .ptr = &sDefault.iOplockContentionLimit,
3523 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3526 .label = "posix locking",
3529 .ptr = &sDefault.bPosixLocking,
3532 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3535 .label = "strict locking",
3538 .ptr = &sDefault.iStrictLocking,
3540 .enum_list = enum_bool_auto,
3541 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3544 .label = "share modes",
3547 .ptr = &sDefault.bShareModes,
3550 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3553 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3556 .label = "ldap admin dn",
3558 .p_class = P_GLOBAL,
3559 .ptr = &Globals.szLdapAdminDn,
3562 .flags = FLAG_ADVANCED,
3565 .label = "ldap delete dn",
3567 .p_class = P_GLOBAL,
3568 .ptr = &Globals.ldap_delete_dn,
3571 .flags = FLAG_ADVANCED,
3574 .label = "ldap group suffix",
3576 .p_class = P_GLOBAL,
3577 .ptr = &Globals.szLdapGroupSuffix,
3580 .flags = FLAG_ADVANCED,
3583 .label = "ldap idmap suffix",
3585 .p_class = P_GLOBAL,
3586 .ptr = &Globals.szLdapIdmapSuffix,
3589 .flags = FLAG_ADVANCED,
3592 .label = "ldap machine suffix",
3594 .p_class = P_GLOBAL,
3595 .ptr = &Globals.szLdapMachineSuffix,
3598 .flags = FLAG_ADVANCED,
3601 .label = "ldap passwd sync",
3603 .p_class = P_GLOBAL,
3604 .ptr = &Globals.ldap_passwd_sync,
3606 .enum_list = enum_ldap_passwd_sync,
3607 .flags = FLAG_ADVANCED,
3610 .label = "ldap password sync",
3612 .p_class = P_GLOBAL,
3613 .ptr = &Globals.ldap_passwd_sync,
3615 .enum_list = enum_ldap_passwd_sync,
3619 .label = "ldap replication sleep",
3621 .p_class = P_GLOBAL,
3622 .ptr = &Globals.ldap_replication_sleep,
3625 .flags = FLAG_ADVANCED,
3628 .label = "ldap suffix",
3630 .p_class = P_GLOBAL,
3631 .ptr = &Globals.szLdapSuffix,
3634 .flags = FLAG_ADVANCED,
3637 .label = "ldap ssl",
3639 .p_class = P_GLOBAL,
3640 .ptr = &Globals.ldap_ssl,
3642 .enum_list = enum_ldap_ssl,
3643 .flags = FLAG_ADVANCED,
3646 .label = "ldap ssl ads",
3648 .p_class = P_GLOBAL,
3649 .ptr = &Globals.ldap_ssl_ads,
3652 .flags = FLAG_ADVANCED,
3655 .label = "ldap timeout",
3657 .p_class = P_GLOBAL,
3658 .ptr = &Globals.ldap_timeout,
3661 .flags = FLAG_ADVANCED,
3664 .label = "ldap connection timeout",
3666 .p_class = P_GLOBAL,
3667 .ptr = &Globals.ldap_connection_timeout,
3670 .flags = FLAG_ADVANCED,
3673 .label = "ldap page size",
3675 .p_class = P_GLOBAL,
3676 .ptr = &Globals.ldap_page_size,
3679 .flags = FLAG_ADVANCED,
3682 .label = "ldap user suffix",
3684 .p_class = P_GLOBAL,
3685 .ptr = &Globals.szLdapUserSuffix,
3688 .flags = FLAG_ADVANCED,
3691 .label = "ldap debug level",
3693 .p_class = P_GLOBAL,
3694 .ptr = &Globals.ldap_debug_level,
3695 .special = handle_ldap_debug_level,
3697 .flags = FLAG_ADVANCED,
3700 .label = "ldap debug threshold",
3702 .p_class = P_GLOBAL,
3703 .ptr = &Globals.ldap_debug_threshold,
3706 .flags = FLAG_ADVANCED,
3709 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3712 .label = "eventlog list",
3714 .p_class = P_GLOBAL,
3715 .ptr = &Globals.szEventLogs,
3718 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3721 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3724 .label = "add share command",
3726 .p_class = P_GLOBAL,
3727 .ptr = &Globals.szAddShareCommand,
3730 .flags = FLAG_ADVANCED,
3733 .label = "change share command",
3735 .p_class = P_GLOBAL,
3736 .ptr = &Globals.szChangeShareCommand,
3739 .flags = FLAG_ADVANCED,
3742 .label = "delete share command",
3744 .p_class = P_GLOBAL,
3745 .ptr = &Globals.szDeleteShareCommand,
3748 .flags = FLAG_ADVANCED,
3751 .label = "config file",
3753 .p_class = P_GLOBAL,
3754 .ptr = &Globals.szConfigFile,
3757 .flags = FLAG_HIDE|FLAG_META,
3762 .p_class = P_GLOBAL,
3763 .ptr = &Globals.szAutoServices,
3766 .flags = FLAG_ADVANCED,
3769 .label = "auto services",
3771 .p_class = P_GLOBAL,
3772 .ptr = &Globals.szAutoServices,
3775 .flags = FLAG_ADVANCED,
3778 .label = "lock directory",
3780 .p_class = P_GLOBAL,
3781 .ptr = &Globals.szLockDir,
3784 .flags = FLAG_ADVANCED,
3787 .label = "lock dir",
3789 .p_class = P_GLOBAL,
3790 .ptr = &Globals.szLockDir,
3796 .label = "state directory",
3798 .p_class = P_GLOBAL,
3799 .ptr = &Globals.szStateDir,
3802 .flags = FLAG_ADVANCED,
3805 .label = "cache directory",
3807 .p_class = P_GLOBAL,
3808 .ptr = &Globals.szCacheDir,
3811 .flags = FLAG_ADVANCED,
3814 .label = "pid directory",
3816 .p_class = P_GLOBAL,
3817 .ptr = &Globals.szPidDir,
3820 .flags = FLAG_ADVANCED,
3824 .label = "utmp directory",
3826 .p_class = P_GLOBAL,
3827 .ptr = &Globals.szUtmpDir,
3830 .flags = FLAG_ADVANCED,
3833 .label = "wtmp directory",
3835 .p_class = P_GLOBAL,
3836 .ptr = &Globals.szWtmpDir,
3839 .flags = FLAG_ADVANCED,
3844 .p_class = P_GLOBAL,
3845 .ptr = &Globals.bUtmp,
3848 .flags = FLAG_ADVANCED,
3852 .label = "default service",
3854 .p_class = P_GLOBAL,
3855 .ptr = &Globals.szDefaultService,
3858 .flags = FLAG_ADVANCED,
3863 .p_class = P_GLOBAL,
3864 .ptr = &Globals.szDefaultService,
3867 .flags = FLAG_ADVANCED,
3870 .label = "message command",
3872 .p_class = P_GLOBAL,
3873 .ptr = &Globals.szMsgCommand,
3876 .flags = FLAG_ADVANCED,
3879 .label = "dfree cache time",
3882 .ptr = &sDefault.iDfreeCacheTime,
3885 .flags = FLAG_ADVANCED,
3888 .label = "dfree command",
3891 .ptr = &sDefault.szDfree,
3894 .flags = FLAG_ADVANCED,
3897 .label = "get quota command",
3899 .p_class = P_GLOBAL,
3900 .ptr = &Globals.szGetQuota,
3903 .flags = FLAG_ADVANCED,
3906 .label = "set quota command",
3908 .p_class = P_GLOBAL,
3909 .ptr = &Globals.szSetQuota,
3912 .flags = FLAG_ADVANCED,
3915 .label = "remote announce",
3917 .p_class = P_GLOBAL,
3918 .ptr = &Globals.szRemoteAnnounce,
3921 .flags = FLAG_ADVANCED,
3924 .label = "remote browse sync",
3926 .p_class = P_GLOBAL,
3927 .ptr = &Globals.szRemoteBrowseSync,
3930 .flags = FLAG_ADVANCED,
3933 .label = "socket address",
3935 .p_class = P_GLOBAL,
3936 .ptr = &Globals.szSocketAddress,
3939 .flags = FLAG_ADVANCED,
3942 .label = "homedir map",
3944 .p_class = P_GLOBAL,
3945 .ptr = &Globals.szNISHomeMapName,
3948 .flags = FLAG_ADVANCED,
3951 .label = "afs username map",
3953 .p_class = P_GLOBAL,
3954 .ptr = &Globals.szAfsUsernameMap,
3957 .flags = FLAG_ADVANCED,
3960 .label = "afs token lifetime",
3962 .p_class = P_GLOBAL,
3963 .ptr = &Globals.iAfsTokenLifetime,
3966 .flags = FLAG_ADVANCED,
3969 .label = "log nt token command",
3971 .p_class = P_GLOBAL,
3972 .ptr = &Globals.szLogNtTokenCommand,
3975 .flags = FLAG_ADVANCED,
3978 .label = "time offset",
3980 .p_class = P_GLOBAL,
3981 .ptr = &extra_time_offset,
3984 .flags = FLAG_ADVANCED,
3987 .label = "NIS homedir",
3989 .p_class = P_GLOBAL,
3990 .ptr = &Globals.bNISHomeMap,
3993 .flags = FLAG_ADVANCED,
3999 .ptr = &sDefault.valid,
4008 .ptr = &sDefault.szCopy,
4009 .special = handle_copy,
4017 .ptr = &sDefault.szInclude,
4018 .special = handle_include,
4020 .flags = FLAG_HIDE|FLAG_META,
4026 .ptr = &sDefault.szPreExec,
4029 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4035 .ptr = &sDefault.szPreExec,
4038 .flags = FLAG_ADVANCED,
4041 .label = "preexec close",
4044 .ptr = &sDefault.bPreexecClose,
4047 .flags = FLAG_ADVANCED | FLAG_SHARE,
4050 .label = "postexec",
4053 .ptr = &sDefault.szPostExec,
4056 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4059 .label = "root preexec",
4062 .ptr = &sDefault.szRootPreExec,
4065 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4068 .label = "root preexec close",
4071 .ptr = &sDefault.bRootpreexecClose,
4074 .flags = FLAG_ADVANCED | FLAG_SHARE,
4077 .label = "root postexec",
4080 .ptr = &sDefault.szRootPostExec,
4083 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4086 .label = "available",
4089 .ptr = &sDefault.bAvailable,
4092 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4095 .label = "registry shares",
4097 .p_class = P_GLOBAL,
4098 .ptr = &Globals.bRegistryShares,
4101 .flags = FLAG_ADVANCED,
4104 .label = "usershare allow guests",
4106 .p_class = P_GLOBAL,
4107 .ptr = &Globals.bUsershareAllowGuests,
4110 .flags = FLAG_ADVANCED,
4113 .label = "usershare max shares",
4115 .p_class = P_GLOBAL,
4116 .ptr = &Globals.iUsershareMaxShares,
4119 .flags = FLAG_ADVANCED,
4122 .label = "usershare owner only",
4124 .p_class = P_GLOBAL,
4125 .ptr = &Globals.bUsershareOwnerOnly,
4128 .flags = FLAG_ADVANCED,
4131 .label = "usershare path",
4133 .p_class = P_GLOBAL,
4134 .ptr = &Globals.szUsersharePath,
4137 .flags = FLAG_ADVANCED,
4140 .label = "usershare prefix allow list",
4142 .p_class = P_GLOBAL,
4143 .ptr = &Globals.szUsersharePrefixAllowList,
4146 .flags = FLAG_ADVANCED,
4149 .label = "usershare prefix deny list",
4151 .p_class = P_GLOBAL,
4152 .ptr = &Globals.szUsersharePrefixDenyList,
4155 .flags = FLAG_ADVANCED,
4158 .label = "usershare template share",
4160 .p_class = P_GLOBAL,
4161 .ptr = &Globals.szUsershareTemplateShare,
4164 .flags = FLAG_ADVANCED,
4170 .ptr = &sDefault.volume,
4173 .flags = FLAG_ADVANCED | FLAG_SHARE,
4179 .ptr = &sDefault.fstype,
4182 .flags = FLAG_ADVANCED | FLAG_SHARE,
4185 .label = "set directory",
4188 .ptr = &sDefault.bNo_set_dir,
4191 .flags = FLAG_ADVANCED | FLAG_SHARE,
4194 .label = "wide links",
4197 .ptr = &sDefault.bWidelinks,
4200 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4203 .label = "follow symlinks",
4206 .ptr = &sDefault.bSymlinks,
4209 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4212 .label = "dont descend",
4215 .ptr = &sDefault.szDontdescend,
4218 .flags = FLAG_ADVANCED | FLAG_SHARE,
4221 .label = "magic script",
4224 .ptr = &sDefault.szMagicScript,
4227 .flags = FLAG_ADVANCED | FLAG_SHARE,
4230 .label = "magic output",
4233 .ptr = &sDefault.szMagicOutput,
4236 .flags = FLAG_ADVANCED | FLAG_SHARE,
4239 .label = "delete readonly",
4242 .ptr = &sDefault.bDeleteReadonly,
4245 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4248 .label = "dos filemode",
4251 .ptr = &sDefault.bDosFilemode,
4254 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4257 .label = "dos filetimes",
4260 .ptr = &sDefault.bDosFiletimes,
4263 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4266 .label = "dos filetime resolution",
4269 .ptr = &sDefault.bDosFiletimeResolution,
4272 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4275 .label = "fake directory create times",
4278 .ptr = &sDefault.bFakeDirCreateTimes,
4281 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4284 .label = "panic action",
4286 .p_class = P_GLOBAL,
4287 .ptr = &Globals.szPanicAction,
4290 .flags = FLAG_ADVANCED,
4293 .label = "perfcount module",
4295 .p_class = P_GLOBAL,
4296 .ptr = &Globals.szSMBPerfcountModule,
4299 .flags = FLAG_ADVANCED,
4302 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4305 .label = "vfs objects",
4308 .ptr = &sDefault.szVfsObjects,
4311 .flags = FLAG_ADVANCED | FLAG_SHARE,
4314 .label = "vfs object",
4317 .ptr = &sDefault.szVfsObjects,
4324 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4327 .label = "msdfs root",
4330 .ptr = &sDefault.bMSDfsRoot,
4333 .flags = FLAG_ADVANCED | FLAG_SHARE,
4336 .label = "msdfs proxy",
4339 .ptr = &sDefault.szMSDfsProxy,
4342 .flags = FLAG_ADVANCED | FLAG_SHARE,
4345 .label = "host msdfs",
4347 .p_class = P_GLOBAL,
4348 .ptr = &Globals.bHostMSDfs,
4351 .flags = FLAG_ADVANCED,
4354 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4357 .label = "passdb expand explicit",
4359 .p_class = P_GLOBAL,
4360 .ptr = &Globals.bPassdbExpandExplicit,
4363 .flags = FLAG_ADVANCED,
4366 .label = "idmap backend",
4368 .p_class = P_GLOBAL,
4369 .ptr = &Globals.szIdmapBackend,
4372 .flags = FLAG_ADVANCED,
4375 .label = "idmap alloc backend",
4377 .p_class = P_GLOBAL,
4378 .ptr = &Globals.szIdmapAllocBackend,
4381 .flags = FLAG_ADVANCED,
4384 .label = "idmap cache time",
4386 .p_class = P_GLOBAL,
4387 .ptr = &Globals.iIdmapCacheTime,
4390 .flags = FLAG_ADVANCED,
4393 .label = "idmap negative cache time",
4395 .p_class = P_GLOBAL,
4396 .ptr = &Globals.iIdmapNegativeCacheTime,
4399 .flags = FLAG_ADVANCED,
4402 .label = "idmap uid",
4404 .p_class = P_GLOBAL,
4405 .ptr = &Globals.szIdmapUID,
4406 .special = handle_idmap_uid,
4408 .flags = FLAG_ADVANCED,
4411 .label = "winbind uid",
4413 .p_class = P_GLOBAL,
4414 .ptr = &Globals.szIdmapUID,
4415 .special = handle_idmap_uid,
4420 .label = "idmap gid",
4422 .p_class = P_GLOBAL,
4423 .ptr = &Globals.szIdmapGID,
4424 .special = handle_idmap_gid,
4426 .flags = FLAG_ADVANCED,
4429 .label = "winbind gid",
4431 .p_class = P_GLOBAL,
4432 .ptr = &Globals.szIdmapGID,
4433 .special = handle_idmap_gid,
4438 .label = "template homedir",
4440 .p_class = P_GLOBAL,
4441 .ptr = &Globals.szTemplateHomedir,
4444 .flags = FLAG_ADVANCED,
4447 .label = "template shell",
4449 .p_class = P_GLOBAL,
4450 .ptr = &Globals.szTemplateShell,
4453 .flags = FLAG_ADVANCED,
4456 .label = "winbind separator",
4458 .p_class = P_GLOBAL,
4459 .ptr = &Globals.szWinbindSeparator,
4462 .flags = FLAG_ADVANCED,
4465 .label = "winbind cache time",
4467 .p_class = P_GLOBAL,
4468 .ptr = &Globals.winbind_cache_time,
4471 .flags = FLAG_ADVANCED,
4474 .label = "winbind reconnect delay",
4476 .p_class = P_GLOBAL,
4477 .ptr = &Globals.winbind_reconnect_delay,
4480 .flags = FLAG_ADVANCED,
4483 .label = "winbind enum users",
4485 .p_class = P_GLOBAL,
4486 .ptr = &Globals.bWinbindEnumUsers,
4489 .flags = FLAG_ADVANCED,
4492 .label = "winbind enum groups",
4494 .p_class = P_GLOBAL,
4495 .ptr = &Globals.bWinbindEnumGroups,
4498 .flags = FLAG_ADVANCED,
4501 .label = "winbind use default domain",
4503 .p_class = P_GLOBAL,
4504 .ptr = &Globals.bWinbindUseDefaultDomain,
4507 .flags = FLAG_ADVANCED,
4510 .label = "winbind trusted domains only",
4512 .p_class = P_GLOBAL,
4513 .ptr = &Globals.bWinbindTrustedDomainsOnly,
4516 .flags = FLAG_ADVANCED,
4519 .label = "winbind nested groups",
4521 .p_class = P_GLOBAL,
4522 .ptr = &Globals.bWinbindNestedGroups,
4525 .flags = FLAG_ADVANCED,
4528 .label = "winbind expand groups",
4530 .p_class = P_GLOBAL,
4531 .ptr = &Globals.winbind_expand_groups,
4534 .flags = FLAG_ADVANCED,
4537 .label = "winbind nss info",
4539 .p_class = P_GLOBAL,
4540 .ptr = &Globals.szWinbindNssInfo,
4543 .flags = FLAG_ADVANCED,
4546 .label = "winbind refresh tickets",
4548 .p_class = P_GLOBAL,
4549 .ptr = &Globals.bWinbindRefreshTickets,
4552 .flags = FLAG_ADVANCED,
4555 .label = "winbind offline logon",
4557 .p_class = P_GLOBAL,
4558 .ptr = &Globals.bWinbindOfflineLogon,
4561 .flags = FLAG_ADVANCED,
4564 .label = "winbind normalize names",
4566 .p_class = P_GLOBAL,
4567 .ptr = &Globals.bWinbindNormalizeNames,
4570 .flags = FLAG_ADVANCED,
4573 .label = "winbind rpc only",
4575 .p_class = P_GLOBAL,
4576 .ptr = &Globals.bWinbindRpcOnly,
4579 .flags = FLAG_ADVANCED,
4582 {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
4585 /***************************************************************************
4586 Initialise the sDefault parameter structure for the printer values.
4587 ***************************************************************************/
4589 static void init_printer_values(struct service *pService)
4591 /* choose defaults depending on the type of printing */
4592 switch (pService->iPrinting) {
4597 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4598 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4599 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4604 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4605 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4606 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4607 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4608 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4609 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4610 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4616 /* set the lpq command to contain the destination printer
4617 name only. This is used by cups_queue_get() */
4618 string_set(&pService->szLpqcommand, "%p");
4619 string_set(&pService->szLprmcommand, "");
4620 string_set(&pService->szPrintcommand, "");
4621 string_set(&pService->szLppausecommand, "");
4622 string_set(&pService->szLpresumecommand, "");
4623 string_set(&pService->szQueuepausecommand, "");
4624 string_set(&pService->szQueueresumecommand, "");
4626 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4627 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4628 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4629 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4630 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4631 string_set(&pService->szQueuepausecommand, "disable '%p'");
4632 string_set(&pService->szQueueresumecommand, "enable '%p'");
4633 #endif /* HAVE_CUPS */
4638 string_set(&pService->szLpqcommand, "lpstat -o%p");
4639 string_set(&pService->szLprmcommand, "cancel %p-%j");
4640 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4641 string_set(&pService->szQueuepausecommand, "disable %p");
4642 string_set(&pService->szQueueresumecommand, "enable %p");
4644 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4645 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4650 string_set(&pService->szLpqcommand, "lpq -P%p");
4651 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4652 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4658 string_set(&pService->szPrintcommand, "vlp print %p %s");
4659 string_set(&pService->szLpqcommand, "vlp lpq %p");
4660 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
4661 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
4662 string_set(&pService->szLpresumecommand, "vlp lpresume %p %j");
4663 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
4664 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
4666 #endif /* DEVELOPER */
4671 * Function to return the default value for the maximum number of open
4672 * file descriptors permitted. This function tries to consult the
4673 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4674 * the smaller of those.
4676 static int max_open_files(void)
4678 int sysctl_max = MAX_OPEN_FILES;
4679 int rlimit_max = MAX_OPEN_FILES;
4681 #ifdef HAVE_SYSCTLBYNAME
4683 size_t size = sizeof(sysctl_max);
4684 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4689 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4695 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4696 rlimit_max = rl.rlim_cur;
4698 #if defined(RLIM_INFINITY)
4699 if(rl.rlim_cur == RLIM_INFINITY)
4700 rlimit_max = MAX_OPEN_FILES;
4705 return MIN(sysctl_max, rlimit_max);
4709 * Common part of freeing allocated data for one parameter.
4711 static void free_one_parameter_common(void *parm_ptr,
4712 struct parm_struct parm)
4714 if ((parm.type == P_STRING) ||
4715 (parm.type == P_USTRING))
4717 string_free((char**)parm_ptr);
4718 } else if (parm.type == P_LIST) {
4719 TALLOC_FREE(*((char***)parm_ptr));
4724 * Free the allocated data for one parameter for a share
4725 * given as a service struct.
4727 static void free_one_parameter(struct service *service,
4728 struct parm_struct parm)
4732 if (parm.p_class != P_LOCAL) {
4736 parm_ptr = lp_local_ptr(service, parm.ptr);
4738 free_one_parameter_common(parm_ptr, parm);
4742 * Free the allocated parameter data of a share given
4743 * as a service struct.
4745 static void free_parameters(struct service *service)
4749 for (i=0; parm_table[i].label; i++) {
4750 free_one_parameter(service, parm_table[i]);
4755 * Free the allocated data for one parameter for a given share
4756 * specified by an snum.
4758 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4762 if (parm.ptr == NULL) {
4767 parm_ptr = parm.ptr;
4768 } else if (parm.p_class != P_LOCAL) {
4771 parm_ptr = lp_local_ptr_by_snum(snum, parm.ptr);
4774 free_one_parameter_common(parm_ptr, parm);
4778 * Free the allocated parameter data for a share specified
4781 static void free_parameters_by_snum(int snum)
4785 for (i=0; parm_table[i].label; i++) {
4786 free_one_parameter_by_snum(snum, parm_table[i]);
4791 * Free the allocated global parameters.
4793 static void free_global_parameters(void)
4795 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4798 /***************************************************************************
4799 Initialise the global parameter structure.
4800 ***************************************************************************/
4802 static void init_globals(bool first_time_only)
4804 static bool done_init = False;
4808 /* If requested to initialize only once and we've already done it... */
4809 if (first_time_only && done_init) {
4810 /* ... then we have nothing more to do */
4815 /* The logfile can be set before this is invoked. Free it if so. */
4816 if (Globals.szLogFile != NULL) {
4817 string_free(&Globals.szLogFile);
4818 Globals.szLogFile = NULL;
4822 free_global_parameters();
4825 memset((void *)&Globals, '\0', sizeof(Globals));
4827 for (i = 0; parm_table[i].label; i++) {
4828 if ((parm_table[i].type == P_STRING ||
4829 parm_table[i].type == P_USTRING) &&
4832 string_set((char **)parm_table[i].ptr, "");
4836 string_set(&sDefault.fstype, FSTYPE_STRING);
4837 string_set(&sDefault.szPrintjobUsername, "%U");
4839 init_printer_values(&sDefault);
4842 DEBUG(3, ("Initialising global parameters\n"));
4844 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4845 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4847 /* use the new 'hash2' method by default, with a prefix of 1 */
4848 string_set(&Globals.szManglingMethod, "hash2");
4849 Globals.mangle_prefix = 1;
4851 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4853 /* using UTF8 by default allows us to support all chars */
4854 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4856 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
4857 /* If the system supports nl_langinfo(), try to grab the value
4858 from the user's locale */
4859 string_set(&Globals.display_charset, "LOCALE");
4861 string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
4864 /* Use codepage 850 as a default for the dos character set */
4865 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4868 * Allow the default PASSWD_CHAT to be overridden in local.h.
4870 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4872 set_global_myname(myhostname());
4873 string_set(&Globals.szNetbiosName,global_myname());
4875 set_global_myworkgroup(WORKGROUP);
4876 string_set(&Globals.szWorkgroup, lp_workgroup());
4878 string_set(&Globals.szPasswdProgram, "");
4879 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4880 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4881 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4882 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4883 string_set(&Globals.szSocketAddress, "0.0.0.0");
4885 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4886 smb_panic("init_globals: ENOMEM");
4888 string_set(&Globals.szServerString, s);
4890 if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
4891 DEFAULT_MINOR_VERSION) < 0) {
4892 smb_panic("init_globals: ENOMEM");
4894 string_set(&Globals.szAnnounceVersion, s);
4897 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4900 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
4902 string_set(&Globals.szLogonDrive, "");
4903 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4904 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4905 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4907 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
4908 string_set(&Globals.szPasswordServer, "*");
4910 Globals.AlgorithmicRidBase = BASE_RID;
4912 Globals.bLoadPrinters = True;
4913 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4915 Globals.ConfigBackend = config_backend;
4917 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4918 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4919 Globals.max_xmit = 0x4104;
4920 Globals.max_mux = 50; /* This is *needed* for profile support. */
4921 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4922 Globals.bDisableSpoolss = False;
4923 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4924 Globals.pwordlevel = 0;
4925 Globals.unamelevel = 0;
4926 Globals.deadtime = 0;
4927 Globals.getwd_cache = true;
4928 Globals.bLargeReadwrite = True;
4929 Globals.max_log_size = 5000;
4930 Globals.max_open_files = max_open_files();
4931 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4932 Globals.maxprotocol = PROTOCOL_NT1;
4933 Globals.minprotocol = PROTOCOL_CORE;
4934 Globals.security = SEC_USER;
4935 Globals.paranoid_server_security = True;
4936 Globals.bEncryptPasswords = True;
4937 Globals.bUpdateEncrypt = False;
4938 Globals.clientSchannel = Auto;
4939 Globals.serverSchannel = Auto;
4940 Globals.bReadRaw = True;
4941 Globals.bWriteRaw = True;
4942 Globals.bNullPasswords = False;
4943 Globals.bObeyPamRestrictions = False;
4945 Globals.bSyslogOnly = False;
4946 Globals.bTimestampLogs = True;
4947 string_set(&Globals.szLogLevel, "0");
4948 Globals.bDebugPrefixTimestamp = False;
4949 Globals.bDebugHiresTimestamp = False;
4950 Globals.bDebugPid = False;
4951 Globals.bDebugUid = False;
4952 Globals.bDebugClass = False;
4953 Globals.bEnableCoreFiles = True;
4954 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4955 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4956 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4957 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4958 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
4959 Globals.lm_interval = 60;
4960 Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
4961 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4962 Globals.bNISHomeMap = False;
4963 #ifdef WITH_NISPLUS_HOME
4964 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4966 string_set(&Globals.szNISHomeMapName, "auto.home");
4969 Globals.bTimeServer = False;
4970 Globals.bBindInterfacesOnly = False;
4971 Globals.bUnixPasswdSync = False;
4972 Globals.bPamPasswordChange = False;
4973 Globals.bPasswdChatDebug = False;
4974 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4975 Globals.bNTPipeSupport = True; /* Do NT pipes by default. */
4976 Globals.bNTStatusSupport = True; /* Use NT status by default. */
4977 Globals.bStatCache = True; /* use stat cache by default */
4978 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4979 Globals.restrict_anonymous = 0;
4980 Globals.bClientLanManAuth = False; /* Do NOT use the LanMan hash if it is available */
4981 Globals.bClientPlaintextAuth = False; /* Do NOT use a plaintext password even if is requested by the server */
4982 Globals.bLanmanAuth = False; /* Do NOT use the LanMan hash, even if it is supplied */
4983 Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4984 Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
4985 /* Note, that we will use NTLM2 session security (which is different), if it is available */
4987 Globals.map_to_guest = 0; /* By Default, "Never" */
4988 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4989 Globals.enhanced_browsing = true;
4990 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4991 #ifdef MMAP_BLACKLIST
4992 Globals.bUseMmap = False;
4994 Globals.bUseMmap = True;
4996 Globals.bUnixExtensions = True;
4997 Globals.bResetOnZeroVC = False;
4999 /* hostname lookups can be very expensive and are broken on
5000 a large number of sites (tridge) */
5001 Globals.bHostnameLookups = False;
5003 string_set(&Globals.szPassdbBackend, "smbpasswd");
5004 string_set(&Globals.szLdapSuffix, "");
5005 string_set(&Globals.szLdapMachineSuffix, "");
5006 string_set(&Globals.szLdapUserSuffix, "");
5007 string_set(&Globals.szLdapGroupSuffix, "");
5008 string_set(&Globals.szLdapIdmapSuffix, "");
5010 string_set(&Globals.szLdapAdminDn, "");
5011 Globals.ldap_ssl = LDAP_SSL_START_TLS;
5012 Globals.ldap_ssl_ads = False;
5013 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
5014 Globals.ldap_delete_dn = False;
5015 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
5016 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
5017 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
5018 Globals.ldap_page_size = LDAP_PAGE_SIZE;
5020 Globals.ldap_debug_level = 0;
5021 Globals.ldap_debug_threshold = 10;
5023 /* This is what we tell the afs client. in reality we set the token
5024 * to never expire, though, when this runs out the afs client will
5025 * forget the token. Set to 0 to get NEVERDATE.*/
5026 Globals.iAfsTokenLifetime = 604800;
5027 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
5029 /* these parameters are set to defaults that are more appropriate
5030 for the increasing samba install base:
5032 as a member of the workgroup, that will possibly become a
5033 _local_ master browser (lm = True). this is opposed to a forced
5034 local master browser startup (pm = True).
5036 doesn't provide WINS server service by default (wsupp = False),
5037 and doesn't provide domain master browser services by default, either.
5041 Globals.bMsAddPrinterWizard = True;
5042 Globals.os_level = 20;
5043 Globals.bLocalMaster = True;
5044 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
5045 Globals.bDomainLogons = False;
5046 Globals.bBrowseList = True;
5047 Globals.bWINSsupport = False;
5048 Globals.bWINSproxy = False;
5050 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
5051 Globals.InitLogonDelay = 100; /* 100 ms default delay */
5053 Globals.bDNSproxy = True;
5055 /* this just means to use them if they exist */
5056 Globals.bKernelOplocks = True;
5058 Globals.bAllowTrustedDomains = True;
5059 string_set(&Globals.szIdmapBackend, "tdb");
5061 string_set(&Globals.szTemplateShell, "/bin/false");
5062 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
5063 string_set(&Globals.szWinbindSeparator, "\\");
5065 string_set(&Globals.szCupsServer, "");
5066 string_set(&Globals.szIPrintServer, "");
5068 string_set(&Globals.ctdbdSocket, "");
5069 Globals.szClusterAddresses = NULL;
5070 Globals.clustering = False;
5072 Globals.winbind_cache_time = 300; /* 5 minutes */
5073 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
5074 Globals.bWinbindEnumUsers = False;
5075 Globals.bWinbindEnumGroups = False;
5076 Globals.bWinbindUseDefaultDomain = False;
5077 Globals.bWinbindTrustedDomainsOnly = False;
5078 Globals.bWinbindNestedGroups = True;
5079 Globals.winbind_expand_groups = 1;
5080 Globals.szWinbindNssInfo = str_list_make_v3(talloc_autofree_context(), "template", NULL);
5081 Globals.bWinbindRefreshTickets = False;
5082 Globals.bWinbindOfflineLogon = False;
5084 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
5085 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
5087 Globals.bPassdbExpandExplicit = False;
5089 Globals.name_cache_timeout = 660; /* In seconds */
5091 Globals.bUseSpnego = True;
5092 Globals.bClientUseSpnego = True;
5094 Globals.client_signing = Auto;
5095 Globals.server_signing = False;
5097 Globals.bDeferSharingViolations = True;
5098 string_set(&Globals.smb_ports, SMB_PORTS);
5100 Globals.bEnablePrivileges = True;
5101 Globals.bHostMSDfs = True;
5102 Globals.bASUSupport = False;
5104 /* User defined shares. */
5105 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5106 smb_panic("init_globals: ENOMEM");
5108 string_set(&Globals.szUsersharePath, s);
5110 string_set(&Globals.szUsershareTemplateShare, "");
5111 Globals.iUsershareMaxShares = 0;
5112 /* By default disallow sharing of directories not owned by the sharer. */
5113 Globals.bUsershareOwnerOnly = True;
5114 /* By default disallow guest access to usershares. */
5115 Globals.bUsershareAllowGuests = False;
5117 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5119 /* By default no shares out of the registry */
5120 Globals.bRegistryShares = False;
5122 Globals.iminreceivefile = 0;
5124 Globals.bMapUntrustedToDomain = false;
5127 /*******************************************************************
5128 Convenience routine to grab string parameters into temporary memory
5129 and run standard_sub_basic on them. The buffers can be written to by
5130 callers without affecting the source string.
5131 ********************************************************************/
5133 static char *lp_string(const char *s)
5136 TALLOC_CTX *ctx = talloc_tos();
5138 /* The follow debug is useful for tracking down memory problems
5139 especially if you have an inner loop that is calling a lp_*()
5140 function that returns a string. Perhaps this debug should be
5141 present all the time? */
5144 DEBUG(10, ("lp_string(%s)\n", s));
5147 ret = talloc_sub_basic(ctx,
5148 get_current_username(),
5149 current_user_info.domain,
5151 if (trim_char(ret, '\"', '\"')) {
5152 if (strchr(ret,'\"') != NULL) {
5154 ret = talloc_sub_basic(ctx,
5155 get_current_username(),
5156 current_user_info.domain,
5164 In this section all the functions that are used to access the
5165 parameters from the rest of the program are defined
5168 #define FN_GLOBAL_STRING(fn_name,ptr) \
5169 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
5170 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5171 const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
5172 #define FN_GLOBAL_LIST(fn_name,ptr) \
5173 const char **fn_name(void) {return(*(const char ***)(ptr));}
5174 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5175 bool fn_name(void) {return(*(bool *)(ptr));}
5176 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5177 char fn_name(void) {return(*(char *)(ptr));}
5178 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5179 int fn_name(void) {return(*(int *)(ptr));}
5181 #define FN_LOCAL_STRING(fn_name,val) \
5182 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5183 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5184 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5185 #define FN_LOCAL_LIST(fn_name,val) \
5186 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5187 #define FN_LOCAL_BOOL(fn_name,val) \
5188 bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5189 #define FN_LOCAL_INTEGER(fn_name,val) \
5190 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5192 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5193 bool fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5194 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5195 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5196 #define FN_LOCAL_PARM_STRING(fn_name,val) \
5197 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));}
5198 #define FN_LOCAL_CHAR(fn_name,val) \
5199 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5201 FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
5202 FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
5203 FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
5204 FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
5205 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
5206 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
5207 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
5208 FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
5209 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
5210 FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
5211 FN_GLOBAL_STRING(lp_addport_cmd, &Globals.szAddPortCommand)
5212 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
5213 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
5214 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
5215 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
5216 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
5217 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5218 * build process or in smb.conf, we use that value. Otherwise they
5219 * default to the value of lp_lockdir(). */
5220 char *lp_statedir(void) {
5221 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5222 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5223 return(lp_string(*(char **)(&Globals.szStateDir) ?
5224 *(char **)(&Globals.szStateDir) : ""));
5226 return(lp_string(*(char **)(&Globals.szLockDir) ?
5227 *(char **)(&Globals.szLockDir) : ""));
5229 char *lp_cachedir(void) {
5230 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5231 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5232 return(lp_string(*(char **)(&Globals.szCacheDir) ?
5233 *(char **)(&Globals.szCacheDir) : ""));
5235 return(lp_string(*(char **)(&Globals.szLockDir) ?
5236 *(char **)(&Globals.szLockDir) : ""));
5238 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
5239 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
5240 FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
5241 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
5242 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
5243 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
5244 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
5245 FN_GLOBAL_STRING(lp_perfcount_module, &Globals.szSMBPerfcountModule)
5246 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
5247 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
5248 FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
5249 FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
5250 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
5251 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
5252 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
5253 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
5254 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
5255 FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
5256 FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
5257 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
5258 FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
5259 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
5260 FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
5261 FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
5262 FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
5263 FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
5264 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
5265 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
5266 FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
5267 FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
5268 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
5269 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
5270 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
5271 /* FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
5272 * lp_passdb_backend() should be replace by the this macro again after
5275 const char *lp_passdb_backend(void)
5277 char *delim, *quote;
5279 delim = strchr( Globals.szPassdbBackend, ' ');
5280 /* no space at all */
5281 if (delim == NULL) {
5285 quote = strchr(Globals.szPassdbBackend, '"');
5286 /* no quote char or non in the first part */
5287 if (quote == NULL || quote > delim) {
5292 quote = strchr(quote+1, '"');
5293 if (quote == NULL) {
5294 DEBUG(0, ("WARNING: Your 'passdb backend' configuration is invalid due to a missing second \" char.\n"));
5296 } else if (*(quote+1) == '\0') {
5297 /* space, fitting quote char, and one backend only */
5300 /* terminate string after the fitting quote char */
5305 DEBUG(0, ("WARNING: Your 'passdb backend' configuration includes multiple backends. This\n"
5306 "is deprecated since Samba 3.0.23. Please check WHATSNEW.txt or the section 'Passdb\n"
5307 "Changes' from the ChangeNotes as part of the Samba HOWTO collection. Only the first\n"
5308 "backend (%s) is used. The rest is ignored.\n", Globals.szPassdbBackend));
5311 return Globals.szPassdbBackend;
5313 FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
5314 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
5315 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
5316 FN_GLOBAL_STRING(lp_renameuser_script, &Globals.szRenameUserScript)
5317 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
5319 FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
5320 FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
5321 FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
5322 FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
5323 FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
5324 FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
5326 FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
5328 FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
5329 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
5330 FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
5332 FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
5334 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
5335 FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
5336 FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
5337 FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
5338 FN_GLOBAL_INTEGER(lp_acl_compatibility, &Globals.iAclCompat)
5339 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
5340 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
5341 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
5342 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
5343 FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
5344 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups)
5345 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets)
5346 FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon)
5347 FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames)
5348 FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
5350 FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
5351 FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)
5352 FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
5353 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
5354 FN_GLOBAL_INTEGER(lp_keepalive, &Globals.iKeepalive)
5355 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit)
5357 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
5358 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
5359 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
5360 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, &Globals.ldap_ssl_ads)
5361 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
5362 FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
5363 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
5364 FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
5365 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, &Globals.ldap_connection_timeout)
5366 FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
5367 FN_GLOBAL_INTEGER(lp_ldap_debug_level, &Globals.ldap_debug_level)
5368 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, &Globals.ldap_debug_threshold)
5369 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
5370 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
5371 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
5372 FN_GLOBAL_STRING(lp_usershare_path, &Globals.szUsersharePath)
5373 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, &Globals.szUsersharePrefixAllowList)
5374 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, &Globals.szUsersharePrefixDenyList)
5376 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
5378 FN_GLOBAL_BOOL(lp_registry_shares, &Globals.bRegistryShares)
5379 FN_GLOBAL_BOOL(lp_usershare_allow_guests, &Globals.bUsershareAllowGuests)
5380 FN_GLOBAL_BOOL(lp_usershare_owner_only, &Globals.bUsershareOwnerOnly)
5381 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
5382 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
5383 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
5384 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
5385 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
5386 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
5387 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
5388 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
5389 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
5390 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, &Globals.szInitLogonDelayedHosts)
5391 FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
5392 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
5393 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
5394 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
5395 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
5396 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
5397 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
5398 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
5399 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
5400 FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
5401 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
5402 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
5403 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
5404 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
5405 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
5406 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
5407 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
5408 FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
5409 FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
5410 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
5411 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
5412 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
5413 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
5414 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
5415 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
5416 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
5417 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
5418 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
5419 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
5420 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
5421 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
5422 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
5423 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, &Globals.bMapUntrustedToDomain)
5424 FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
5425 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
5426 FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
5427 FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
5428 FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
5429 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
5430 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
5431 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
5432 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
5433 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
5434 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
5435 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
5436 FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
5437 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
5438 FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
5439 FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
5440 FN_GLOBAL_STRING(lp_dedicated_keytab_file, &Globals.szDedicatedKeytabFile)
5441 FN_GLOBAL_INTEGER(lp_kerberos_method, &Globals.iKerberosMethod)
5442 FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
5443 FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
5444 FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport)
5445 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
5446 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
5447 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
5448 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
5449 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
5450 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
5451 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, &Globals.open_files_db_hash_size)
5452 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
5453 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
5454 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
5455 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
5456 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
5457 FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
5458 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
5459 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
5460 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
5461 FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
5462 FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
5463 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
5464 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
5465 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
5466 FN_GLOBAL_BOOL(_lp_disable_spoolss, &Globals.bDisableSpoolss)
5467 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
5468 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
5469 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
5470 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
5471 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
5472 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
5473 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
5474 FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
5475 FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
5476 FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
5477 FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
5479 FN_LOCAL_STRING(lp_preexec, szPreExec)
5480 FN_LOCAL_STRING(lp_postexec, szPostExec)
5481 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
5482 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
5483 FN_LOCAL_STRING(lp_servicename, szService)
5484 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
5485 FN_LOCAL_STRING(lp_pathname, szPath)
5486 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
5487 FN_LOCAL_STRING(lp_username, szUsername)
5488 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
5489 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
5490 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
5491 FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
5492 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
5493 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
5494 int lp_cups_encrypt(void)
5496 #ifdef HAVE_HTTPCONNECTENCRYPT
5497 switch (Globals.CupsEncrypt) {
5499 Globals.CupsEncrypt = HTTP_ENCRYPT_REQUIRED;
5502 Globals.CupsEncrypt = HTTP_ENCRYPT_ALWAYS;
5505 Globals.CupsEncrypt = HTTP_ENCRYPT_NEVER;
5509 return Globals.CupsEncrypt;
5511 FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
5512 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
5513 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
5514 FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
5515 FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
5516 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
5517 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
5518 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
5519 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
5520 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
5521 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
5522 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
5523 static FN_LOCAL_STRING(_lp_printername, szPrintername)
5524 FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
5525 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
5526 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
5527 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
5528 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
5529 FN_LOCAL_STRING(lp_comment, comment)
5530 FN_LOCAL_STRING(lp_force_user, force_user)
5531 FN_LOCAL_STRING(lp_force_group, force_group)
5532 FN_LOCAL_LIST(lp_readlist, readlist)
5533 FN_LOCAL_LIST(lp_writelist, writelist)
5534 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
5535 FN_LOCAL_STRING(lp_fstype, fstype)
5536 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
5537 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
5538 static FN_LOCAL_STRING(lp_volume, volume)
5539 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
5540 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
5541 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
5542 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
5543 FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
5544 FN_LOCAL_STRING(lp_dfree_command, szDfree)
5545 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
5546 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
5547 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
5548 FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
5549 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
5550 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
5551 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
5552 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
5553 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
5554 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
5555 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
5556 FN_LOCAL_BOOL(lp_access_based_share_enum, bAccessBasedShareEnum)
5557 FN_LOCAL_BOOL(lp_readonly, bRead_only)
5558 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
5559 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
5560 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
5561 FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
5562 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
5563 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
5564 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
5565 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
5566 FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
5567 FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
5568 FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
5569 FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
5570 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
5571 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
5572 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
5573 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
5574 FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames)
5575 FN_LOCAL_BOOL(lp_widelinks, bWidelinks)
5576 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
5577 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
5578 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
5579 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
5580 FN_LOCAL_BOOL(lp_map_system, bMap_system)
5581 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
5582 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
5583 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
5584 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
5585 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
5586 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
5587 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
5588 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
5589 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
5590 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
5591 FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
5592 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
5593 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
5594 FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
5595 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
5596 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
5597 FN_LOCAL_BOOL(lp_ea_support, bEASupport)
5598 FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
5599 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
5600 FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
5601 FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
5602 FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
5603 FN_LOCAL_BOOL(lp_acl_group_control, bAclGroupControl)
5604 FN_LOCAL_BOOL(lp_acl_map_full_control, bAclMapFullControl)
5605 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
5606 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
5607 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
5608 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
5609 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
5610 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
5611 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
5612 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
5613 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
5614 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
5615 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
5616 FN_LOCAL_INTEGER(lp_printing, iPrinting)
5617 FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
5618 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
5619 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
5620 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
5621 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
5622 FN_LOCAL_INTEGER(lp_dfree_cache_time, iDfreeCacheTime)
5623 FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
5624 FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
5625 FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
5626 FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
5627 FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
5628 FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
5629 FN_LOCAL_CHAR(lp_magicchar, magic_char)
5630 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
5631 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
5632 FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
5633 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
5634 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
5635 FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
5636 FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
5637 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
5639 /* local prototypes */
5641 static int map_parameter(const char *pszParmName);
5642 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5643 static const char *get_boolean(bool bool_value);
5644 static int getservicebyname(const char *pszServiceName,
5645 struct service *pserviceDest);
5646 static void copy_service(struct service *pserviceDest,
5647 struct service *pserviceSource,
5648 struct bitmap *pcopymapDest);
5649 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5651 static bool do_section(const char *pszSectionName, void *userdata);
5652 static void init_copymap(struct service *pservice);
5653 static bool hash_a_service(const char *name, int number);
5654 static void free_service_byindex(int iService);
5655 static void free_param_opts(struct param_opt_struct **popts);
5656 static char * canonicalize_servicename(const char *name);
5657 static void show_parameter(int parmIndex);
5658 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5661 * This is a helper function for parametrical options support. It returns a
5662 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5663 * parametrical functions are quite simple
5665 static struct param_opt_struct *get_parametrics(int snum, const char *type,
5668 bool global_section = False;
5670 struct param_opt_struct *data;
5672 if (snum >= iNumServices) return NULL;
5675 data = Globals.param_opt;
5676 global_section = True;
5678 data = ServicePtrs[snum]->param_opt;
5681 if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
5682 DEBUG(0,("asprintf failed!\n"));
5687 if (strwicmp(data->key, param_key) == 0) {
5688 string_free(¶m_key);
5694 if (!global_section) {
5695 /* Try to fetch the same option but from globals */
5696 /* but only if we are not already working with Globals */
5697 data = Globals.param_opt;
5699 if (strwicmp(data->key, param_key) == 0) {
5700 string_free(¶m_key);
5707 string_free(¶m_key);
5713 #define MISSING_PARAMETER(name) \
5714 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5716 /*******************************************************************
5717 convenience routine to return int parameters.
5718 ********************************************************************/
5719 static int lp_int(const char *s)
5723 MISSING_PARAMETER(lp_int);
5727 return (int)strtol(s, NULL, 0);
5730 /*******************************************************************
5731 convenience routine to return unsigned long parameters.
5732 ********************************************************************/
5733 static unsigned long lp_ulong(const char *s)
5737 MISSING_PARAMETER(lp_ulong);
5741 return strtoul(s, NULL, 0);
5744 /*******************************************************************
5745 convenience routine to return boolean parameters.
5746 ********************************************************************/
5747 static bool lp_bool(const char *s)
5752 MISSING_PARAMETER(lp_bool);
5756 if (!set_boolean(s, &ret)) {
5757 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5764 /*******************************************************************
5765 convenience routine to return enum parameters.
5766 ********************************************************************/
5767 static int lp_enum(const char *s,const struct enum_list *_enum)
5771 if (!s || !*s || !_enum) {
5772 MISSING_PARAMETER(lp_enum);
5776 for (i=0; _enum[i].name; i++) {
5777 if (strequal(_enum[i].name,s))
5778 return _enum[i].value;
5781 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5785 #undef MISSING_PARAMETER
5787 /* DO NOT USE lp_parm_string ANYMORE!!!!
5788 * use lp_parm_const_string or lp_parm_talloc_string
5790 * lp_parm_string is only used to let old modules find this symbol
5792 #undef lp_parm_string
5793 char *lp_parm_string(const char *servicename, const char *type, const char *option);
5794 char *lp_parm_string(const char *servicename, const char *type, const char *option)
5796 return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
5799 /* Return parametric option from a given service. Type is a part of option before ':' */
5800 /* Parametric option has following syntax: 'Type: option = value' */
5801 /* the returned value is talloced on the talloc_tos() */
5802 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5804 struct param_opt_struct *data = get_parametrics(snum, type, option);
5806 if (data == NULL||data->value==NULL) {
5808 return lp_string(def);
5814 return lp_string(data->value);
5817 /* Return parametric option from a given service. Type is a part of option before ':' */
5818 /* Parametric option has following syntax: 'Type: option = value' */
5819 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5821 struct param_opt_struct *data = get_parametrics(snum, type, option);
5823 if (data == NULL||data->value==NULL)
5829 /* Return parametric option from a given service. Type is a part of option before ':' */
5830 /* Parametric option has following syntax: 'Type: option = value' */
5832 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5834 struct param_opt_struct *data = get_parametrics(snum, type, option);
5836 if (data == NULL||data->value==NULL)
5837 return (const char **)def;
5839 if (data->list==NULL) {
5840 data->list = str_list_make_v3(talloc_autofree_context(), data->value, NULL);
5843 return (const char **)data->list;
5846 /* Return parametric option from a given service. Type is a part of option before ':' */
5847 /* Parametric option has following syntax: 'Type: option = value' */
5849 int lp_parm_int(int snum, const char *type, const char *option, int def)
5851 struct param_opt_struct *data = get_parametrics(snum, type, option);
5853 if (data && data->value && *data->value)
5854 return lp_int(data->value);
5859 /* Return parametric option from a given service. Type is a part of option before ':' */
5860 /* Parametric option has following syntax: 'Type: option = value' */
5862 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5864 struct param_opt_struct *data = get_parametrics(snum, type, option);
5866 if (data && data->value && *data->value)
5867 return lp_ulong(data->value);
5872 /* Return parametric option from a given service. Type is a part of option before ':' */
5873 /* Parametric option has following syntax: 'Type: option = value' */
5875 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5877 struct param_opt_struct *data = get_parametrics(snum, type, option);
5879 if (data && data->value && *data->value)
5880 return lp_bool(data->value);
5885 /* Return parametric option from a given service. Type is a part of option before ':' */
5886 /* Parametric option has following syntax: 'Type: option = value' */
5888 int lp_parm_enum(int snum, const char *type, const char *option,
5889 const struct enum_list *_enum, int def)
5891 struct param_opt_struct *data = get_parametrics(snum, type, option);
5893 if (data && data->value && *data->value && _enum)
5894 return lp_enum(data->value, _enum);
5900 /***************************************************************************
5901 Initialise a service to the defaults.
5902 ***************************************************************************/
5904 static void init_service(struct service *pservice)
5906 memset((char *)pservice, '\0', sizeof(struct service));
5907 copy_service(pservice, &sDefault, NULL);
5912 * free a param_opts structure.
5913 * param_opts handling should be moved to talloc;
5914 * then this whole functions reduces to a TALLOC_FREE().
5917 static void free_param_opts(struct param_opt_struct **popts)
5919 struct param_opt_struct *opt, *next_opt;
5921 if (popts == NULL) {
5925 if (*popts != NULL) {
5926 DEBUG(5, ("Freeing parametrics:\n"));
5929 while (opt != NULL) {
5930 string_free(&opt->key);
5931 string_free(&opt->value);
5932 TALLOC_FREE(opt->list);
5933 next_opt = opt->next;
5940 /***************************************************************************
5941 Free the dynamically allocated parts of a service struct.
5942 ***************************************************************************/
5944 static void free_service(struct service *pservice)
5949 if (pservice->szService)
5950 DEBUG(5, ("free_service: Freeing service %s\n",
5951 pservice->szService));
5953 free_parameters(pservice);
5955 string_free(&pservice->szService);
5956 bitmap_free(pservice->copymap);
5958 free_param_opts(&pservice->param_opt);
5960 ZERO_STRUCTP(pservice);
5964 /***************************************************************************
5965 remove a service indexed in the ServicePtrs array from the ServiceHash
5966 and free the dynamically allocated parts
5967 ***************************************************************************/
5969 static void free_service_byindex(int idx)
5971 if ( !LP_SNUM_OK(idx) )
5974 ServicePtrs[idx]->valid = False;
5975 invalid_services[num_invalid_services++] = idx;
5977 /* we have to cleanup the hash record */
5979 if (ServicePtrs[idx]->szService) {
5980 char *canon_name = canonicalize_servicename(
5981 ServicePtrs[idx]->szService );
5983 dbwrap_delete_bystring(ServiceHash, canon_name );
5984 TALLOC_FREE(canon_name);
5987 free_service(ServicePtrs[idx]);
5990 /***************************************************************************
5991 Add a new service to the services array initialising it with the given
5993 ***************************************************************************/
5995 static int add_a_service(const struct service *pservice, const char *name)
5998 struct service tservice;
5999 int num_to_alloc = iNumServices + 1;
6001 tservice = *pservice;
6003 /* it might already exist */
6005 i = getservicebyname(name, NULL);
6007 /* Clean all parametric options for service */
6008 /* They will be added during parsing again */
6009 free_param_opts(&ServicePtrs[i]->param_opt);
6014 /* find an invalid one */
6016 if (num_invalid_services > 0) {
6017 i = invalid_services[--num_invalid_services];
6020 /* if not, then create one */
6021 if (i == iNumServices) {
6022 struct service **tsp;
6025 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
6027 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
6031 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct service);
6032 if (!ServicePtrs[iNumServices]) {
6033 DEBUG(0,("add_a_service: out of memory!\n"));
6038 /* enlarge invalid_services here for now... */
6039 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
6041 if (tinvalid == NULL) {
6042 DEBUG(0,("add_a_service: failed to enlarge "
6043 "invalid_services!\n"));
6046 invalid_services = tinvalid;
6048 free_service_byindex(i);
6051 ServicePtrs[i]->valid = True;
6053 init_service(ServicePtrs[i]);
6054 copy_service(ServicePtrs[i], &tservice, NULL);
6056 string_set(&ServicePtrs[i]->szService, name);
6058 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
6059 i, ServicePtrs[i]->szService));
6061 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
6068 /***************************************************************************
6069 Convert a string to uppercase and remove whitespaces.
6070 ***************************************************************************/
6072 static char *canonicalize_servicename(const char *src)
6077 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
6081 result = talloc_strdup(talloc_tos(), src);
6082 SMB_ASSERT(result != NULL);
6088 /***************************************************************************
6089 Add a name/index pair for the services array to the hash table.
6090 ***************************************************************************/
6092 static bool hash_a_service(const char *name, int idx)
6096 if ( !ServiceHash ) {
6097 DEBUG(10,("hash_a_service: creating servicehash\n"));
6098 ServiceHash = db_open_rbt(NULL);
6099 if ( !ServiceHash ) {
6100 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
6105 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
6108 canon_name = canonicalize_servicename( name );
6110 dbwrap_store_bystring(ServiceHash, canon_name,
6111 make_tdb_data((uint8 *)&idx, sizeof(idx)),
6114 TALLOC_FREE(canon_name);
6119 /***************************************************************************
6120 Add a new home service, with the specified home directory, defaults coming
6122 ***************************************************************************/
6124 bool lp_add_home(const char *pszHomename, int iDefaultService,
6125 const char *user, const char *pszHomedir)
6129 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
6134 if (!(*(ServicePtrs[iDefaultService]->szPath))
6135 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
6136 string_set(&ServicePtrs[i]->szPath, pszHomedir);
6139 if (!(*(ServicePtrs[i]->comment))) {
6140 char *comment = NULL;
6141 if (asprintf(&comment, "Home directory of %s", user) < 0) {
6144 string_set(&ServicePtrs[i]->comment, comment);
6148 /* set the browseable flag from the global default */
6150 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6151 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
6153 ServicePtrs[i]->autoloaded = True;
6155 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
6156 user, ServicePtrs[i]->szPath ));
6161 /***************************************************************************
6162 Add a new service, based on an old one.
6163 ***************************************************************************/
6165 int lp_add_service(const char *pszService, int iDefaultService)
6167 if (iDefaultService < 0) {
6168 return add_a_service(&sDefault, pszService);
6171 return (add_a_service(ServicePtrs[iDefaultService], pszService));
6174 /***************************************************************************
6175 Add the IPC service.
6176 ***************************************************************************/
6178 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
6180 char *comment = NULL;
6181 int i = add_a_service(&sDefault, ipc_name);
6186 if (asprintf(&comment, "IPC Service (%s)",
6187 Globals.szServerString) < 0) {
6191 string_set(&ServicePtrs[i]->szPath, tmpdir());
6192 string_set(&ServicePtrs[i]->szUsername, "");
6193 string_set(&ServicePtrs[i]->comment, comment);
6194 string_set(&ServicePtrs[i]->fstype, "IPC");
6195 ServicePtrs[i]->iMaxConnections = 0;
6196 ServicePtrs[i]->bAvailable = True;
6197 ServicePtrs[i]->bRead_only = True;
6198 ServicePtrs[i]->bGuest_only = False;
6199 ServicePtrs[i]->bAdministrative_share = True;
6200 ServicePtrs[i]->bGuest_ok = guest_ok;
6201 ServicePtrs[i]->bPrint_ok = False;
6202 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6204 DEBUG(3, ("adding IPC service\n"));
6210 /***************************************************************************
6211 Add a new printer service, with defaults coming from service iFrom.
6212 ***************************************************************************/
6214 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
6216 const char *comment = "From Printcap";
6217 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6222 /* note that we do NOT default the availability flag to True - */
6223 /* we take it from the default service passed. This allows all */
6224 /* dynamic printers to be disabled by disabling the [printers] */
6225 /* entry (if/when the 'available' keyword is implemented!). */
6227 /* the printer name is set to the service name. */
6228 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6229 string_set(&ServicePtrs[i]->comment, comment);
6231 /* set the browseable flag from the gloabl default */
6232 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6234 /* Printers cannot be read_only. */
6235 ServicePtrs[i]->bRead_only = False;
6236 /* No share modes on printer services. */
6237 ServicePtrs[i]->bShareModes = False;
6238 /* No oplocks on printer services. */
6239 ServicePtrs[i]->bOpLocks = False;
6240 /* Printer services must be printable. */
6241 ServicePtrs[i]->bPrint_ok = True;
6243 DEBUG(3, ("adding printer service %s\n", pszPrintername));
6249 /***************************************************************************
6250 Check whether the given parameter name is valid.
6251 Parametric options (names containing a colon) are considered valid.
6252 ***************************************************************************/
6254 bool lp_parameter_is_valid(const char *pszParmName)
6256 return ((map_parameter(pszParmName) != -1) ||
6257 (strchr(pszParmName, ':') != NULL));
6260 /***************************************************************************
6261 Check whether the given name is the name of a global parameter.
6262 Returns True for strings belonging to parameters of class
6263 P_GLOBAL, False for all other strings, also for parametric options
6264 and strings not belonging to any option.
6265 ***************************************************************************/
6267 bool lp_parameter_is_global(const char *pszParmName)
6269 int num = map_parameter(pszParmName);
6272 return (parm_table[num].p_class == P_GLOBAL);
6278 /**************************************************************************
6279 Check whether the given name is the canonical name of a parameter.
6280 Returns False if it is not a valid parameter Name.
6281 For parametric options, True is returned.
6282 **************************************************************************/
6284 bool lp_parameter_is_canonical(const char *parm_name)
6286 if (!lp_parameter_is_valid(parm_name)) {
6290 return (map_parameter(parm_name) ==
6291 map_parameter_canonical(parm_name, NULL));
6294 /**************************************************************************
6295 Determine the canonical name for a parameter.
6296 Indicate when it is an inverse (boolean) synonym instead of a
6298 **************************************************************************/
6300 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6305 if (!lp_parameter_is_valid(parm_name)) {
6310 num = map_parameter_canonical(parm_name, inverse);
6312 /* parametric option */
6313 *canon_parm = parm_name;
6315 *canon_parm = parm_table[num].label;
6322 /**************************************************************************
6323 Determine the canonical name for a parameter.
6324 Turn the value given into the inverse boolean expression when
6325 the synonym is an invers boolean synonym.
6327 Return True if parm_name is a valid parameter name and
6328 in case it is an invers boolean synonym, if the val string could
6329 successfully be converted to the reverse bool.
6330 Return false in all other cases.
6331 **************************************************************************/
6333 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6335 const char **canon_parm,
6336 const char **canon_val)
6341 if (!lp_parameter_is_valid(parm_name)) {
6347 num = map_parameter_canonical(parm_name, &inverse);
6349 /* parametric option */
6350 *canon_parm = parm_name;
6353 *canon_parm = parm_table[num].label;
6355 if (!lp_invert_boolean(val, canon_val)) {
6367 /***************************************************************************
6368 Map a parameter's string representation to something we can use.
6369 Returns False if the parameter string is not recognised, else TRUE.
6370 ***************************************************************************/
6372 static int map_parameter(const char *pszParmName)
6376 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6379 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6380 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6383 /* Warn only if it isn't parametric option */
6384 if (strchr(pszParmName, ':') == NULL)
6385 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6386 /* We do return 'fail' for parametric options as well because they are
6387 stored in different storage
6392 /***************************************************************************
6393 Map a parameter's string representation to the index of the canonical
6394 form of the parameter (it might be a synonym).
6395 Returns -1 if the parameter string is not recognised.
6396 ***************************************************************************/
6398 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6400 int parm_num, canon_num;
6401 bool loc_inverse = False;
6403 parm_num = map_parameter(pszParmName);
6404 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6405 /* invalid, parametric or no canidate for synonyms ... */
6409 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6410 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6411 parm_num = canon_num;
6417 if (inverse != NULL) {
6418 *inverse = loc_inverse;
6423 /***************************************************************************
6424 return true if parameter number parm1 is a synonym of parameter
6425 number parm2 (parm2 being the principal name).
6426 set inverse to True if parm1 is P_BOOLREV and parm2 is P_BOOL,
6428 ***************************************************************************/
6430 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6432 if ((parm_table[parm1].ptr == parm_table[parm2].ptr) &&
6433 (parm_table[parm1].flags & FLAG_HIDE) &&
6434 !(parm_table[parm2].flags & FLAG_HIDE))
6436 if (inverse != NULL) {
6437 if ((parm_table[parm1].type == P_BOOLREV) &&
6438 (parm_table[parm2].type == P_BOOL))
6450 /***************************************************************************
6451 Show one parameter's name, type, [values,] and flags.
6452 (helper functions for show_parameter_list)
6453 ***************************************************************************/
6455 static void show_parameter(int parmIndex)
6457 int enumIndex, flagIndex;
6462 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6463 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6465 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6466 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6467 FLAG_HIDE, FLAG_DOS_STRING};
6468 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6469 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6470 "FLAG_DEPRECATED", "FLAG_HIDE", "FLAG_DOS_STRING", NULL};
6472 printf("%s=%s", parm_table[parmIndex].label,
6473 type[parm_table[parmIndex].type]);
6474 if (parm_table[parmIndex].type == P_ENUM) {
6477 parm_table[parmIndex].enum_list[enumIndex].name;
6481 enumIndex ? "|" : "",
6482 parm_table[parmIndex].enum_list[enumIndex].name);
6487 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6488 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6491 flag_names[flagIndex]);
6496 /* output synonyms */
6498 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6499 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6500 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6501 parm_table[parmIndex2].label);
6502 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6504 printf(" (synonyms: ");
6509 printf("%s%s", parm_table[parmIndex2].label,
6510 inverse ? "[i]" : "");
6520 /***************************************************************************
6521 Show all parameter's name, type, [values,] and flags.
6522 ***************************************************************************/
6524 void show_parameter_list(void)
6526 int classIndex, parmIndex;
6527 const char *section_names[] = { "local", "global", NULL};
6529 for (classIndex=0; section_names[classIndex]; classIndex++) {
6530 printf("[%s]\n", section_names[classIndex]);
6531 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6532 if (parm_table[parmIndex].p_class == classIndex) {
6533 show_parameter(parmIndex);
6539 /***************************************************************************
6540 Check if a given string correctly represents a boolean value.
6541 ***************************************************************************/
6543 bool lp_string_is_valid_boolean(const char *parm_value)
6545 return set_boolean(parm_value, NULL);
6548 /***************************************************************************
6549 Get the standard string representation of a boolean value ("yes" or "no")
6550 ***************************************************************************/
6552 static const char *get_boolean(bool bool_value)
6554 static const char *yes_str = "yes";
6555 static const char *no_str = "no";
6557 return (bool_value ? yes_str : no_str);
6560 /***************************************************************************
6561 Provide the string of the negated boolean value associated to the boolean
6562 given as a string. Returns False if the passed string does not correctly
6563 represent a boolean.
6564 ***************************************************************************/
6566 bool lp_invert_boolean(const char *str, const char **inverse_str)
6570 if (!set_boolean(str, &val)) {
6574 *inverse_str = get_boolean(!val);
6578 /***************************************************************************
6579 Provide the canonical string representation of a boolean value given
6580 as a string. Return True on success, False if the string given does
6581 not correctly represent a boolean.
6582 ***************************************************************************/
6584 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6588 if (!set_boolean(str, &val)) {
6592 *canon_str = get_boolean(val);
6596 /***************************************************************************
6597 Find a service by name. Otherwise works like get_service.
6598 ***************************************************************************/
6600 static int getservicebyname(const char *pszServiceName, struct service *pserviceDest)
6606 if (ServiceHash == NULL) {
6610 canon_name = canonicalize_servicename(pszServiceName);
6612 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
6614 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
6615 iService = *(int *)data.dptr;
6618 TALLOC_FREE(canon_name);
6620 if ((iService != -1) && (LP_SNUM_OK(iService))
6621 && (pserviceDest != NULL)) {
6622 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6628 /***************************************************************************
6629 Copy a service structure to another.
6630 If pcopymapDest is NULL then copy all fields
6631 ***************************************************************************/
6634 * Add a parametric option to a param_opt_struct,
6635 * replacing old value, if already present.
6637 static void set_param_opt(struct param_opt_struct **opt_list,
6638 const char *opt_name,
6639 const char *opt_value)
6641 struct param_opt_struct *new_opt, *opt;
6644 if (opt_list == NULL) {
6651 /* Traverse destination */
6653 /* If we already have same option, override it */
6654 if (strwicmp(opt->key, opt_name) == 0) {
6655 string_free(&opt->value);
6656 TALLOC_FREE(opt->list);
6657 opt->value = SMB_STRDUP(opt_value);
6664 new_opt = SMB_XMALLOC_P(struct param_opt_struct);
6665 new_opt->key = SMB_STRDUP(opt_name);
6666 new_opt->value = SMB_STRDUP(opt_value);
6667 new_opt->list = NULL;
6668 DLIST_ADD(*opt_list, new_opt);
6672 static void copy_service(struct service *pserviceDest, struct service *pserviceSource,
6673 struct bitmap *pcopymapDest)
6676 bool bcopyall = (pcopymapDest == NULL);
6677 struct param_opt_struct *data;
6679 for (i = 0; parm_table[i].label; i++)
6680 if (parm_table[i].ptr && parm_table[i].p_class == P_LOCAL &&
6681 (bcopyall || bitmap_query(pcopymapDest,i))) {
6682 void *def_ptr = parm_table[i].ptr;
6684 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
6687 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
6690 switch (parm_table[i].type) {
6693 *(bool *)dest_ptr = *(bool *)src_ptr;
6699 *(int *)dest_ptr = *(int *)src_ptr;
6703 *(char *)dest_ptr = *(char *)src_ptr;
6707 string_set((char **)dest_ptr,
6712 string_set((char **)dest_ptr,
6714 strupper_m(*(char **)dest_ptr);
6717 TALLOC_FREE(*((char ***)dest_ptr));
6718 *((char ***)dest_ptr) = str_list_copy(NULL,
6719 *(const char ***)src_ptr);
6727 init_copymap(pserviceDest);
6728 if (pserviceSource->copymap)
6729 bitmap_copy(pserviceDest->copymap,
6730 pserviceSource->copymap);
6733 data = pserviceSource->param_opt;
6735 set_param_opt(&pserviceDest->param_opt, data->key, data->value);
6740 /***************************************************************************
6741 Check a service for consistency. Return False if the service is in any way
6742 incomplete or faulty, else True.
6743 ***************************************************************************/
6745 bool service_ok(int iService)
6750 if (ServicePtrs[iService]->szService[0] == '\0') {
6751 DEBUG(0, ("The following message indicates an internal error:\n"));
6752 DEBUG(0, ("No service name in service entry.\n"));
6756 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6757 /* I can't see why you'd want a non-printable printer service... */
6758 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6759 if (!ServicePtrs[iService]->bPrint_ok) {
6760 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6761 ServicePtrs[iService]->szService));
6762 ServicePtrs[iService]->bPrint_ok = True;
6764 /* [printers] service must also be non-browsable. */
6765 if (ServicePtrs[iService]->bBrowseable)
6766 ServicePtrs[iService]->bBrowseable = False;
6769 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6770 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6771 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6773 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6774 ServicePtrs[iService]->szService));
6775 ServicePtrs[iService]->bAvailable = False;
6778 /* If a service is flagged unavailable, log the fact at level 1. */
6779 if (!ServicePtrs[iService]->bAvailable)
6780 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6781 ServicePtrs[iService]->szService));
6786 static struct smbconf_ctx *lp_smbconf_ctx(void)
6789 static struct smbconf_ctx *conf_ctx = NULL;
6791 if (conf_ctx == NULL) {
6792 werr = smbconf_init(NULL, &conf_ctx, "registry:");
6793 if (!W_ERROR_IS_OK(werr)) {
6794 DEBUG(1, ("error initializing registry configuration: "
6795 "%s\n", win_errstr(werr)));
6803 static bool process_smbconf_service(struct smbconf_service *service)
6808 if (service == NULL) {
6812 ret = do_section(service->name, NULL);
6816 for (count = 0; count < service->num_params; count++) {
6817 ret = do_parameter(service->param_names[count],
6818 service->param_values[count],
6824 if (iServiceIndex >= 0) {
6825 return service_ok(iServiceIndex);
6831 * load a service from registry and activate it
6833 bool process_registry_service(const char *service_name)
6836 struct smbconf_service *service = NULL;
6837 TALLOC_CTX *mem_ctx = talloc_stackframe();
6838 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6841 if (conf_ctx == NULL) {
6845 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6847 if (!smbconf_share_exists(conf_ctx, service_name)) {
6849 * Registry does not contain data for this service (yet),
6850 * but make sure lp_load doesn't return false.
6856 werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6857 if (!W_ERROR_IS_OK(werr)) {
6861 ret = process_smbconf_service(service);
6867 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6870 TALLOC_FREE(mem_ctx);
6875 * process_registry_globals
6877 static bool process_registry_globals(void)
6881 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6883 ret = do_parameter("registry shares", "yes", NULL);
6888 return process_registry_service(GLOBAL_NAME);
6891 bool process_registry_shares(void)
6895 struct smbconf_service **service = NULL;
6896 uint32_t num_shares = 0;
6897 TALLOC_CTX *mem_ctx = talloc_stackframe();
6898 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6901 if (conf_ctx == NULL) {
6905 werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6906 if (!W_ERROR_IS_OK(werr)) {
6912 for (count = 0; count < num_shares; count++) {
6913 if (strequal(service[count]->name, GLOBAL_NAME)) {
6916 ret = process_smbconf_service(service[count]);
6923 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6926 TALLOC_FREE(mem_ctx);
6930 #define MAX_INCLUDE_DEPTH 100
6932 static uint8_t include_depth;
6934 static struct file_lists {
6935 struct file_lists *next;
6939 } *file_lists = NULL;
6941 /*******************************************************************
6942 Keep a linked list of all config files so we know when one has changed
6943 it's date and needs to be reloaded.
6944 ********************************************************************/
6946 static void add_to_file_list(const char *fname, const char *subfname)
6948 struct file_lists *f = file_lists;
6951 if (f->name && !strcmp(f->name, fname))
6957 f = SMB_MALLOC_P(struct file_lists);
6960 f->next = file_lists;
6961 f->name = SMB_STRDUP(fname);
6966 f->subfname = SMB_STRDUP(subfname);
6972 f->modtime = file_modtime(subfname);
6974 time_t t = file_modtime(subfname);
6981 * Free the file lists
6983 static void free_file_list(void)
6985 struct file_lists *f;
6986 struct file_lists *next;
6991 SAFE_FREE( f->name );
6992 SAFE_FREE( f->subfname );
7001 * Utility function for outsiders to check if we're running on registry.
7003 bool lp_config_backend_is_registry(void)
7005 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
7009 * Utility function to check if the config backend is FILE.
7011 bool lp_config_backend_is_file(void)
7013 return (lp_config_backend() == CONFIG_BACKEND_FILE);
7016 /*******************************************************************
7017 Check if a config file has changed date.
7018 ********************************************************************/
7020 bool lp_file_list_changed(void)
7022 struct file_lists *f = file_lists;
7024 DEBUG(6, ("lp_file_list_changed()\n"));
7030 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
7031 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7033 if (conf_ctx == NULL) {
7036 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
7039 DEBUGADD(6, ("registry config changed\n"));
7043 n2 = alloc_sub_basic(get_current_username(),
7044 current_user_info.domain,
7049 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
7050 f->name, n2, ctime(&f->modtime)));
7052 mod_time = file_modtime(n2);
7055 ((f->modtime != mod_time) ||
7056 (f->subfname == NULL) ||
7057 (strcmp(n2, f->subfname) != 0)))
7060 ("file %s modified: %s\n", n2,
7062 f->modtime = mod_time;
7063 SAFE_FREE(f->subfname);
7064 f->subfname = n2; /* Passing ownership of
7065 return from alloc_sub_basic
7077 /***************************************************************************
7078 Run standard_sub_basic on netbios name... needed because global_myname
7079 is not accessed through any lp_ macro.
7080 Note: We must *NOT* use string_set() here as ptr points to global_myname.
7081 ***************************************************************************/
7083 static bool handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
7086 char *netbios_name = alloc_sub_basic(get_current_username(),
7087 current_user_info.domain,
7090 ret = set_global_myname(netbios_name);
7091 SAFE_FREE(netbios_name);
7092 string_set(&Globals.szNetbiosName,global_myname());
7094 DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
7100 static bool handle_charset(int snum, const char *pszParmValue, char **ptr)
7102 if (strcmp(*ptr, pszParmValue) != 0) {
7103 string_set(ptr, pszParmValue);
7111 static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
7115 ret = set_global_myworkgroup(pszParmValue);
7116 string_set(&Globals.szWorkgroup,lp_workgroup());
7121 static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
7125 ret = set_global_scope(pszParmValue);
7126 string_set(&Globals.szNetbiosScope,global_scope());
7131 static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
7133 TALLOC_FREE(Globals.szNetbiosAliases);
7134 Globals.szNetbiosAliases = str_list_make_v3(talloc_autofree_context(), pszParmValue, NULL);
7135 return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
7138 /***************************************************************************
7139 Handle the include operation.
7140 ***************************************************************************/
7141 static bool bAllowIncludeRegistry = true;
7143 static bool handle_include(int snum, const char *pszParmValue, char **ptr)
7147 if (include_depth >= MAX_INCLUDE_DEPTH) {
7148 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
7153 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
7154 if (!bAllowIncludeRegistry) {
7157 if (bInGlobalSection) {
7160 ret = process_registry_globals();
7164 DEBUG(1, ("\"include = registry\" only effective "
7165 "in %s section\n", GLOBAL_NAME));
7170 fname = alloc_sub_basic(get_current_username(),
7171 current_user_info.domain,
7174 add_to_file_list(pszParmValue, fname);
7176 string_set(ptr, fname);
7178 if (file_exist(fname)) {
7181 ret = pm_process(fname, do_section, do_parameter, NULL);
7187 DEBUG(2, ("Can't find include file %s\n", fname));
7192 /***************************************************************************
7193 Handle the interpretation of the copy parameter.
7194 ***************************************************************************/
7196 static bool handle_copy(int snum, const char *pszParmValue, char **ptr)
7200 struct service serviceTemp;
7202 string_set(ptr, pszParmValue);
7204 init_service(&serviceTemp);
7208 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7210 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7211 if (iTemp == iServiceIndex) {
7212 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7214 copy_service(ServicePtrs[iServiceIndex],
7216 ServicePtrs[iServiceIndex]->copymap);
7220 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7224 free_service(&serviceTemp);
7228 static bool handle_ldap_debug_level(int snum, const char *pszParmValue, char **ptr)
7230 Globals.ldap_debug_level = lp_int(pszParmValue);
7231 init_ldap_debugging();
7235 /***************************************************************************
7236 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7241 idmap uid = 1000-1999
7244 We only do simple parsing checks here. The strings are parsed into useful
7245 structures in the idmap daemon code.
7247 ***************************************************************************/
7249 /* Some lp_ routines to return idmap [ug]id information */
7251 static uid_t idmap_uid_low, idmap_uid_high;
7252 static gid_t idmap_gid_low, idmap_gid_high;
7254 bool lp_idmap_uid(uid_t *low, uid_t *high)
7256 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7260 *low = idmap_uid_low;
7263 *high = idmap_uid_high;
7268 bool lp_idmap_gid(gid_t *low, gid_t *high)
7270 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7274 *low = idmap_gid_low;
7277 *high = idmap_gid_high;
7282 /* Do some simple checks on "idmap [ug]id" parameter values */
7284 static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
7288 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7293 string_set(ptr, pszParmValue);
7295 idmap_uid_low = low;
7296 idmap_uid_high = high;
7301 static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
7305 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7310 string_set(ptr, pszParmValue);
7312 idmap_gid_low = low;
7313 idmap_gid_high = high;
7318 /***************************************************************************
7319 Handle the DEBUG level list.
7320 ***************************************************************************/
7322 static bool handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
7324 string_set(ptr, pszParmValueIn);
7325 return debug_parse_levels(pszParmValueIn);
7328 /***************************************************************************
7329 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7330 ***************************************************************************/
7332 static const char *append_ldap_suffix( const char *str )
7334 const char *suffix_string;
7337 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7338 Globals.szLdapSuffix );
7339 if ( !suffix_string ) {
7340 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7344 return suffix_string;
7347 const char *lp_ldap_machine_suffix(void)
7349 if (Globals.szLdapMachineSuffix[0])
7350 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7352 return lp_string(Globals.szLdapSuffix);
7355 const char *lp_ldap_user_suffix(void)
7357 if (Globals.szLdapUserSuffix[0])
7358 return append_ldap_suffix(Globals.szLdapUserSuffix);
7360 return lp_string(Globals.szLdapSuffix);
7363 const char *lp_ldap_group_suffix(void)
7365 if (Globals.szLdapGroupSuffix[0])
7366 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7368 return lp_string(Globals.szLdapSuffix);
7371 const char *lp_ldap_idmap_suffix(void)
7373 if (Globals.szLdapIdmapSuffix[0])
7374 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7376 return lp_string(Globals.szLdapSuffix);
7379 /****************************************************************************
7380 set the value for a P_ENUM
7381 ***************************************************************************/
7383 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7388 for (i = 0; parm->enum_list[i].name; i++) {
7389 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7390 *ptr = parm->enum_list[i].value;
7394 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7395 pszParmValue, parm->label));
7398 /***************************************************************************
7399 ***************************************************************************/
7401 static bool handle_printing(int snum, const char *pszParmValue, char **ptr)
7403 static int parm_num = -1;
7406 if ( parm_num == -1 )
7407 parm_num = map_parameter( "printing" );
7409 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7414 s = ServicePtrs[snum];
7416 init_printer_values( s );
7422 /***************************************************************************
7423 Initialise a copymap.
7424 ***************************************************************************/
7426 static void init_copymap(struct service *pservice)
7429 if (pservice->copymap) {
7430 bitmap_free(pservice->copymap);
7432 pservice->copymap = bitmap_allocate(NUMPARAMETERS);
7433 if (!pservice->copymap)
7435 ("Couldn't allocate copymap!! (size %d)\n",
7436 (int)NUMPARAMETERS));
7438 for (i = 0; i < NUMPARAMETERS; i++)
7439 bitmap_set(pservice->copymap, i);
7442 /***************************************************************************
7443 Return the local pointer to a parameter given a service struct and the
7444 pointer into the default structure.
7445 ***************************************************************************/
7447 static void *lp_local_ptr(struct service *service, void *ptr)
7449 return (void *)(((char *)service) + PTR_DIFF(ptr, &sDefault));
7452 /***************************************************************************
7453 Return the local pointer to a parameter given the service number and the
7454 pointer into the default structure.
7455 ***************************************************************************/
7457 void *lp_local_ptr_by_snum(int snum, void *ptr)
7459 return lp_local_ptr(ServicePtrs[snum], ptr);
7462 /***************************************************************************
7463 Process a parameter for a particular service number. If snum < 0
7464 then assume we are in the globals.
7465 ***************************************************************************/
7467 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7470 void *parm_ptr = NULL; /* where we are going to store the result */
7471 void *def_ptr = NULL;
7472 struct param_opt_struct **opt_list;
7474 parmnum = map_parameter(pszParmName);
7477 if (strchr(pszParmName, ':') == NULL) {
7478 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7484 * We've got a parametric option
7487 opt_list = (snum < 0)
7488 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7489 set_param_opt(opt_list, pszParmName, pszParmValue);
7494 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7495 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7499 def_ptr = parm_table[parmnum].ptr;
7501 /* we might point at a service, the default service or a global */
7505 if (parm_table[parmnum].p_class == P_GLOBAL) {
7507 ("Global parameter %s found in service section!\n",
7511 parm_ptr = lp_local_ptr_by_snum(snum, def_ptr);
7515 if (!ServicePtrs[snum]->copymap)
7516 init_copymap(ServicePtrs[snum]);
7518 /* this handles the aliases - set the copymap for other entries with
7519 the same data pointer */
7520 for (i = 0; parm_table[i].label; i++)
7521 if (parm_table[i].ptr == parm_table[parmnum].ptr)
7522 bitmap_clear(ServicePtrs[snum]->copymap, i);
7525 /* if it is a special case then go ahead */
7526 if (parm_table[parmnum].special) {
7527 return parm_table[parmnum].special(snum, pszParmValue,
7531 /* now switch on the type of variable it is */
7532 switch (parm_table[parmnum].type)
7535 *(bool *)parm_ptr = lp_bool(pszParmValue);
7539 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7543 *(int *)parm_ptr = lp_int(pszParmValue);
7547 *(char *)parm_ptr = *pszParmValue;
7551 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7553 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7558 TALLOC_FREE(*((char ***)parm_ptr));
7559 *(char ***)parm_ptr = str_list_make_v3(
7560 talloc_autofree_context(), pszParmValue, NULL);
7564 string_set((char **)parm_ptr, pszParmValue);
7568 string_set((char **)parm_ptr, pszParmValue);
7569 strupper_m(*(char **)parm_ptr);
7573 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7582 /***************************************************************************
7583 Process a parameter.
7584 ***************************************************************************/
7586 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7589 if (!bInGlobalSection && bGlobalOnly)
7592 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7594 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7595 pszParmName, pszParmValue));
7598 /***************************************************************************
7599 Print a parameter of the specified type.
7600 ***************************************************************************/
7602 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7608 for (i = 0; p->enum_list[i].name; i++) {
7609 if (*(int *)ptr == p->enum_list[i].value) {
7611 p->enum_list[i].name);
7618 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7622 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7626 fprintf(f, "%d", *(int *)ptr);
7630 fprintf(f, "%c", *(char *)ptr);
7634 char *o = octal_string(*(int *)ptr);
7635 fprintf(f, "%s", o);
7641 if ((char ***)ptr && *(char ***)ptr) {
7642 char **list = *(char ***)ptr;
7643 for (; *list; list++) {
7644 /* surround strings with whitespace in double quotes */
7645 if ( strchr_m( *list, ' ' ) )
7646 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
7648 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
7655 if (*(char **)ptr) {
7656 fprintf(f, "%s", *(char **)ptr);
7664 /***************************************************************************
7665 Check if two parameters are equal.
7666 ***************************************************************************/
7668 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7673 return (*((bool *)ptr1) == *((bool *)ptr2));
7678 return (*((int *)ptr1) == *((int *)ptr2));
7681 return (*((char *)ptr1) == *((char *)ptr2));
7684 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7689 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7694 return (p1 == p2 || strequal(p1, p2));
7702 /***************************************************************************
7703 Initialize any local varients in the sDefault table.
7704 ***************************************************************************/
7706 void init_locals(void)
7711 /***************************************************************************
7712 Process a new section (service). At this stage all sections are services.
7713 Later we'll have special sections that permit server parameters to be set.
7714 Returns True on success, False on failure.
7715 ***************************************************************************/
7717 static bool do_section(const char *pszSectionName, void *userdata)
7720 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7721 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7724 /* if we were in a global section then do the local inits */
7725 if (bInGlobalSection && !isglobal)
7728 /* if we've just struck a global section, note the fact. */
7729 bInGlobalSection = isglobal;
7731 /* check for multiple global sections */
7732 if (bInGlobalSection) {
7733 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7737 if (!bInGlobalSection && bGlobalOnly)
7740 /* if we have a current service, tidy it up before moving on */
7743 if (iServiceIndex >= 0)
7744 bRetval = service_ok(iServiceIndex);
7746 /* if all is still well, move to the next record in the services array */
7748 /* We put this here to avoid an odd message order if messages are */
7749 /* issued by the post-processing of a previous section. */
7750 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7752 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
7754 DEBUG(0, ("Failed to add a new service\n"));
7763 /***************************************************************************
7764 Determine if a partcular base parameter is currentl set to the default value.
7765 ***************************************************************************/
7767 static bool is_default(int i)
7769 if (!defaults_saved)
7771 switch (parm_table[i].type) {
7773 return str_list_equal((const char **)parm_table[i].def.lvalue,
7774 *(const char ***)parm_table[i].ptr);
7777 return strequal(parm_table[i].def.svalue,
7778 *(char **)parm_table[i].ptr);
7781 return parm_table[i].def.bvalue ==
7782 *(bool *)parm_table[i].ptr;
7784 return parm_table[i].def.cvalue ==
7785 *(char *)parm_table[i].ptr;
7789 return parm_table[i].def.ivalue ==
7790 *(int *)parm_table[i].ptr;
7797 /***************************************************************************
7798 Display the contents of the global structure.
7799 ***************************************************************************/
7801 static void dump_globals(FILE *f)
7804 struct param_opt_struct *data;
7806 fprintf(f, "[global]\n");
7808 for (i = 0; parm_table[i].label; i++)
7809 if (parm_table[i].p_class == P_GLOBAL &&
7810 !(parm_table[i].flags & FLAG_META) &&
7811 parm_table[i].ptr &&
7812 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
7813 if (defaults_saved && is_default(i))
7815 fprintf(f, "\t%s = ", parm_table[i].label);
7816 print_parameter(&parm_table[i], parm_table[i].ptr, f);
7819 if (Globals.param_opt != NULL) {
7820 data = Globals.param_opt;
7822 fprintf(f, "\t%s = %s\n", data->key, data->value);
7829 /***************************************************************************
7830 Return True if a local parameter is currently set to the global default.
7831 ***************************************************************************/
7833 bool lp_is_default(int snum, struct parm_struct *parm)
7835 int pdiff = PTR_DIFF(parm->ptr, &sDefault);
7837 return equal_parameter(parm->type,
7838 ((char *)ServicePtrs[snum]) + pdiff,
7839 ((char *)&sDefault) + pdiff);
7842 /***************************************************************************
7843 Display the contents of a single services record.
7844 ***************************************************************************/
7846 static void dump_a_service(struct service *pService, FILE * f)
7849 struct param_opt_struct *data;
7851 if (pService != &sDefault)
7852 fprintf(f, "[%s]\n", pService->szService);
7854 for (i = 0; parm_table[i].label; i++) {
7856 if (parm_table[i].p_class == P_LOCAL &&
7857 !(parm_table[i].flags & FLAG_META) &&
7858 parm_table[i].ptr &&
7859 (*parm_table[i].label != '-') &&
7860 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7863 int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
7865 if (pService == &sDefault) {
7866 if (defaults_saved && is_default(i))
7869 if (equal_parameter(parm_table[i].type,
7870 ((char *)pService) +
7872 ((char *)&sDefault) +
7877 fprintf(f, "\t%s = ", parm_table[i].label);
7878 print_parameter(&parm_table[i],
7879 ((char *)pService) + pdiff, f);
7884 if (pService->param_opt != NULL) {
7885 data = pService->param_opt;
7887 fprintf(f, "\t%s = %s\n", data->key, data->value);
7893 /***************************************************************************
7894 Display the contents of a parameter of a single services record.
7895 ***************************************************************************/
7897 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7900 bool result = False;
7903 fstring local_parm_name;
7905 const char *parm_opt_value;
7907 /* check for parametrical option */
7908 fstrcpy( local_parm_name, parm_name);
7909 parm_opt = strchr( local_parm_name, ':');
7914 if (strlen(parm_opt)) {
7915 parm_opt_value = lp_parm_const_string( snum,
7916 local_parm_name, parm_opt, NULL);
7917 if (parm_opt_value) {
7918 printf( "%s\n", parm_opt_value);
7925 /* check for a key and print the value */
7932 for (i = 0; parm_table[i].label; i++) {
7933 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7934 !(parm_table[i].flags & FLAG_META) &&
7935 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7936 parm_table[i].ptr &&
7937 (*parm_table[i].label != '-') &&
7938 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7943 ptr = parm_table[i].ptr;
7945 struct service *pService = ServicePtrs[snum];
7946 ptr = ((char *)pService) +
7947 PTR_DIFF(parm_table[i].ptr, &sDefault);
7950 print_parameter(&parm_table[i],
7961 /***************************************************************************
7962 Return info about the requested parameter (given as a string).
7963 Return NULL when the string is not a valid parameter name.
7964 ***************************************************************************/
7966 struct parm_struct *lp_get_parameter(const char *param_name)
7968 int num = map_parameter(param_name);
7974 return &parm_table[num];
7977 /***************************************************************************
7978 Return info about the next parameter in a service.
7979 snum==GLOBAL_SECTION_SNUM gives the globals.
7980 Return NULL when out of parameters.
7981 ***************************************************************************/
7983 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
7986 /* do the globals */
7987 for (; parm_table[*i].label; (*i)++) {
7988 if (parm_table[*i].p_class == P_SEPARATOR)
7989 return &parm_table[(*i)++];
7991 if (!parm_table[*i].ptr
7992 || (*parm_table[*i].label == '-'))
7996 && (parm_table[*i].ptr ==
7997 parm_table[(*i) - 1].ptr))
8000 if (is_default(*i) && !allparameters)
8003 return &parm_table[(*i)++];
8006 struct service *pService = ServicePtrs[snum];
8008 for (; parm_table[*i].label; (*i)++) {
8009 if (parm_table[*i].p_class == P_SEPARATOR)
8010 return &parm_table[(*i)++];
8012 if (parm_table[*i].p_class == P_LOCAL &&
8013 parm_table[*i].ptr &&
8014 (*parm_table[*i].label != '-') &&
8016 (parm_table[*i].ptr !=
8017 parm_table[(*i) - 1].ptr)))
8020 PTR_DIFF(parm_table[*i].ptr,
8023 if (allparameters ||
8024 !equal_parameter(parm_table[*i].type,
8025 ((char *)pService) +
8027 ((char *)&sDefault) +
8030 return &parm_table[(*i)++];
8041 /***************************************************************************
8042 Display the contents of a single copy structure.
8043 ***************************************************************************/
8044 static void dump_copy_map(bool *pcopymap)
8050 printf("\n\tNon-Copied parameters:\n");
8052 for (i = 0; parm_table[i].label; i++)
8053 if (parm_table[i].p_class == P_LOCAL &&
8054 parm_table[i].ptr && !pcopymap[i] &&
8055 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8057 printf("\t\t%s\n", parm_table[i].label);
8062 /***************************************************************************
8063 Return TRUE if the passed service number is within range.
8064 ***************************************************************************/
8066 bool lp_snum_ok(int iService)
8068 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8071 /***************************************************************************
8072 Auto-load some home services.
8073 ***************************************************************************/
8075 static void lp_add_auto_services(char *str)
8085 s = SMB_STRDUP(str);
8089 homes = lp_servicenumber(HOMES_NAME);
8091 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8092 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8095 if (lp_servicenumber(p) >= 0)
8098 home = get_user_home_dir(talloc_tos(), p);
8100 if (home && homes >= 0)
8101 lp_add_home(p, homes, p, home);
8108 /***************************************************************************
8109 Auto-load one printer.
8110 ***************************************************************************/
8112 void lp_add_one_printer(const char *name, const char *comment, void *pdata)
8114 int printers = lp_servicenumber(PRINTERS_NAME);
8117 if (lp_servicenumber(name) < 0) {
8118 lp_add_printer(name, printers);
8119 if ((i = lp_servicenumber(name)) >= 0) {
8120 string_set(&ServicePtrs[i]->comment, comment);
8121 ServicePtrs[i]->autoloaded = True;
8126 /***************************************************************************
8127 Have we loaded a services file yet?
8128 ***************************************************************************/
8130 bool lp_loaded(void)
8135 /***************************************************************************
8136 Unload unused services.
8137 ***************************************************************************/
8139 void lp_killunused(bool (*snumused) (int))
8142 for (i = 0; i < iNumServices; i++) {
8146 /* don't kill autoloaded or usershare services */
8147 if ( ServicePtrs[i]->autoloaded ||
8148 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8152 if (!snumused || !snumused(i)) {
8153 free_service_byindex(i);
8159 * Kill all except autoloaded and usershare services - convenience wrapper
8161 void lp_kill_all_services(void)
8163 lp_killunused(NULL);
8166 /***************************************************************************
8168 ***************************************************************************/
8170 void lp_killservice(int iServiceIn)
8172 if (VALID(iServiceIn)) {
8173 free_service_byindex(iServiceIn);
8177 /***************************************************************************
8178 Save the curent values of all global and sDefault parameters into the
8179 defaults union. This allows swat and testparm to show only the
8180 changed (ie. non-default) parameters.
8181 ***************************************************************************/
8183 static void lp_save_defaults(void)
8186 for (i = 0; parm_table[i].label; i++) {
8187 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
8189 switch (parm_table[i].type) {
8191 parm_table[i].def.lvalue = str_list_copy(
8192 NULL, *(const char ***)parm_table[i].ptr);
8196 if (parm_table[i].ptr) {
8197 parm_table[i].def.svalue = SMB_STRDUP(*(char **)parm_table[i].ptr);
8199 parm_table[i].def.svalue = NULL;
8204 parm_table[i].def.bvalue =
8205 *(bool *)parm_table[i].ptr;
8208 parm_table[i].def.cvalue =
8209 *(char *)parm_table[i].ptr;
8214 parm_table[i].def.ivalue =
8215 *(int *)parm_table[i].ptr;
8221 defaults_saved = True;
8224 /*******************************************************************
8225 Set the server type we will announce as via nmbd.
8226 ********************************************************************/
8228 static const struct srv_role_tab {
8230 const char *role_str;
8231 } srv_role_tab [] = {
8232 { ROLE_STANDALONE, "ROLE_STANDALONE" },
8233 { ROLE_DOMAIN_MEMBER, "ROLE_DOMAIN_MEMBER" },
8234 { ROLE_DOMAIN_BDC, "ROLE_DOMAIN_BDC" },
8235 { ROLE_DOMAIN_PDC, "ROLE_DOMAIN_PDC" },
8239 const char* server_role_str(uint32 role)
8242 for (i=0; srv_role_tab[i].role_str; i++) {
8243 if (role == srv_role_tab[i].role) {
8244 return srv_role_tab[i].role_str;
8250 static void set_server_role(void)
8252 server_role = ROLE_STANDALONE;
8254 switch (lp_security()) {
8256 if (lp_domain_logons())
8257 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
8260 if (lp_domain_logons())
8261 DEBUG(0, ("Server's Role (logon server) conflicts with server-level security\n"));
8262 /* this used to be considered ROLE_DOMAIN_MEMBER but that's just wrong */
8263 server_role = ROLE_STANDALONE;
8266 if (lp_domain_logons()) {
8267 DEBUG(1, ("Server's Role (logon server) NOT ADVISED with domain-level security\n"));
8268 server_role = ROLE_DOMAIN_BDC;
8271 server_role = ROLE_DOMAIN_MEMBER;
8274 if (lp_domain_logons()) {
8275 server_role = ROLE_DOMAIN_PDC;
8278 server_role = ROLE_DOMAIN_MEMBER;
8281 if (lp_domain_logons()) {
8283 if (Globals.iDomainMaster) /* auto or yes */
8284 server_role = ROLE_DOMAIN_PDC;
8286 server_role = ROLE_DOMAIN_BDC;
8290 DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
8294 DEBUG(10, ("set_server_role: role = %s\n", server_role_str(server_role)));
8297 /***********************************************************
8298 If we should send plaintext/LANMAN passwords in the clinet
8299 ************************************************************/
8301 static void set_allowed_client_auth(void)
8303 if (Globals.bClientNTLMv2Auth) {
8304 Globals.bClientLanManAuth = False;
8306 if (!Globals.bClientLanManAuth) {
8307 Globals.bClientPlaintextAuth = False;
8311 /***************************************************************************
8313 The following code allows smbd to read a user defined share file.
8314 Yes, this is my intent. Yes, I'm comfortable with that...
8316 THE FOLLOWING IS SECURITY CRITICAL CODE.
8318 It washes your clothes, it cleans your house, it guards you while you sleep...
8319 Do not f%^k with it....
8320 ***************************************************************************/
8322 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8324 /***************************************************************************
8325 Check allowed stat state of a usershare file.
8326 Ensure we print out who is dicking with us so the admin can
8327 get their sorry ass fired.
8328 ***************************************************************************/
8330 static bool check_usershare_stat(const char *fname,
8331 const SMB_STRUCT_STAT *psbuf)
8333 if (!S_ISREG(psbuf->st_mode)) {
8334 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8335 "not a regular file\n",
8336 fname, (unsigned int)psbuf->st_uid ));
8340 /* Ensure this doesn't have the other write bit set. */
8341 if (psbuf->st_mode & S_IWOTH) {
8342 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8343 "public write. Refusing to allow as a usershare file.\n",
8344 fname, (unsigned int)psbuf->st_uid ));
8348 /* Should be 10k or less. */
8349 if (psbuf->st_size > MAX_USERSHARE_FILE_SIZE) {
8350 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8351 "too large (%u) to be a user share file.\n",
8352 fname, (unsigned int)psbuf->st_uid,
8353 (unsigned int)psbuf->st_size ));
8360 /***************************************************************************
8361 Parse the contents of a usershare file.
8362 ***************************************************************************/
8364 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8365 SMB_STRUCT_STAT *psbuf,
8366 const char *servicename,
8370 char **pp_sharepath,
8375 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8376 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8379 SMB_STRUCT_STAT sbuf;
8380 char *sharepath = NULL;
8381 char *comment = NULL;
8383 *pp_sharepath = NULL;
8386 *pallow_guest = False;
8389 return USERSHARE_MALFORMED_FILE;
8392 if (strcmp(lines[0], "#VERSION 1") == 0) {
8394 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8397 return USERSHARE_MALFORMED_FILE;
8400 return USERSHARE_BAD_VERSION;
8403 if (strncmp(lines[1], "path=", 5) != 0) {
8404 return USERSHARE_MALFORMED_PATH;
8407 sharepath = talloc_strdup(ctx, &lines[1][5]);
8409 return USERSHARE_POSIX_ERR;
8411 trim_string(sharepath, " ", " ");
8413 if (strncmp(lines[2], "comment=", 8) != 0) {
8414 return USERSHARE_MALFORMED_COMMENT_DEF;
8417 comment = talloc_strdup(ctx, &lines[2][8]);
8419 return USERSHARE_POSIX_ERR;
8421 trim_string(comment, " ", " ");
8422 trim_char(comment, '"', '"');
8424 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8425 return USERSHARE_MALFORMED_ACL_DEF;
8428 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8429 return USERSHARE_ACL_ERR;
8433 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8434 return USERSHARE_MALFORMED_ACL_DEF;
8436 if (lines[4][9] == 'y') {
8437 *pallow_guest = True;
8441 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8442 /* Path didn't change, no checks needed. */
8443 *pp_sharepath = sharepath;
8444 *pp_comment = comment;
8445 return USERSHARE_OK;
8448 /* The path *must* be absolute. */
8449 if (sharepath[0] != '/') {
8450 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8451 servicename, sharepath));
8452 return USERSHARE_PATH_NOT_ABSOLUTE;
8455 /* If there is a usershare prefix deny list ensure one of these paths
8456 doesn't match the start of the user given path. */
8457 if (prefixdenylist) {
8459 for ( i=0; prefixdenylist[i]; i++ ) {
8460 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8461 servicename, i, prefixdenylist[i], sharepath ));
8462 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8463 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8464 "usershare prefix deny list entries.\n",
8465 servicename, sharepath));
8466 return USERSHARE_PATH_IS_DENIED;
8471 /* If there is a usershare prefix allow list ensure one of these paths
8472 does match the start of the user given path. */
8474 if (prefixallowlist) {
8476 for ( i=0; prefixallowlist[i]; i++ ) {
8477 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8478 servicename, i, prefixallowlist[i], sharepath ));
8479 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8483 if (prefixallowlist[i] == NULL) {
8484 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8485 "usershare prefix allow list entries.\n",
8486 servicename, sharepath));
8487 return USERSHARE_PATH_NOT_ALLOWED;
8491 /* Ensure this is pointing to a directory. */
8492 dp = sys_opendir(sharepath);
8495 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8496 servicename, sharepath));
8497 return USERSHARE_PATH_NOT_DIRECTORY;
8500 /* Ensure the owner of the usershare file has permission to share
8503 if (sys_stat(sharepath, &sbuf) == -1) {
8504 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8505 servicename, sharepath, strerror(errno) ));
8507 return USERSHARE_POSIX_ERR;
8512 if (!S_ISDIR(sbuf.st_mode)) {
8513 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8514 servicename, sharepath ));
8515 return USERSHARE_PATH_NOT_DIRECTORY;
8518 /* Check if sharing is restricted to owner-only. */
8519 /* psbuf is the stat of the usershare definition file,
8520 sbuf is the stat of the target directory to be shared. */
8522 if (lp_usershare_owner_only()) {
8523 /* root can share anything. */
8524 if ((psbuf->st_uid != 0) && (sbuf.st_uid != psbuf->st_uid)) {
8525 return USERSHARE_PATH_NOT_ALLOWED;
8529 *pp_sharepath = sharepath;
8530 *pp_comment = comment;
8531 return USERSHARE_OK;
8534 /***************************************************************************
8535 Deal with a usershare file.
8538 -1 - Bad name, invalid contents.
8539 - service name already existed and not a usershare, problem
8540 with permissions to share directory etc.
8541 ***************************************************************************/
8543 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8545 SMB_STRUCT_STAT sbuf;
8546 SMB_STRUCT_STAT lsbuf;
8548 char *sharepath = NULL;
8549 char *comment = NULL;
8550 fstring service_name;
8551 char **lines = NULL;
8555 TALLOC_CTX *ctx = NULL;
8556 SEC_DESC *psd = NULL;
8557 bool guest_ok = False;
8559 /* Ensure share name doesn't contain invalid characters. */
8560 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8561 DEBUG(0,("process_usershare_file: share name %s contains "
8562 "invalid characters (any of %s)\n",
8563 file_name, INVALID_SHARENAME_CHARS ));
8567 fstrcpy(service_name, file_name);
8569 if (asprintf(&fname, "%s/%s", dir_name, file_name) < 0) {
8572 /* Minimize the race condition by doing an lstat before we
8573 open and fstat. Ensure this isn't a symlink link. */
8575 if (sys_lstat(fname, &lsbuf) != 0) {
8576 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8577 fname, strerror(errno) ));
8582 /* This must be a regular file, not a symlink, directory or
8583 other strange filetype. */
8584 if (!check_usershare_stat(fname, &lsbuf)) {
8590 char *canon_name = canonicalize_servicename(service_name);
8591 TDB_DATA data = dbwrap_fetch_bystring(
8592 ServiceHash, canon_name, canon_name);
8596 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
8597 iService = *(int *)data.dptr;
8599 TALLOC_FREE(canon_name);
8602 if (iService != -1 && ServicePtrs[iService]->usershare_last_mod == lsbuf.st_mtime) {
8603 /* Nothing changed - Mark valid and return. */
8604 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8606 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8611 /* Try and open the file read only - no symlinks allowed. */
8613 fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8615 fd = sys_open(fname, O_RDONLY, 0);
8619 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8620 fname, strerror(errno) ));
8625 /* Now fstat to be *SURE* it's a regular file. */
8626 if (sys_fstat(fd, &sbuf) != 0) {
8628 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8629 fname, strerror(errno) ));
8634 /* Is it the same dev/inode as was lstated ? */
8635 if (lsbuf.st_dev != sbuf.st_dev || lsbuf.st_ino != sbuf.st_ino) {
8637 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8638 "Symlink spoofing going on ?\n", fname ));
8643 /* This must be a regular file, not a symlink, directory or
8644 other strange filetype. */
8645 if (!check_usershare_stat(fname, &sbuf)) {
8650 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8653 if (lines == NULL) {
8654 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8655 fname, (unsigned int)sbuf.st_uid ));
8662 /* Should we allow printers to be shared... ? */
8663 ctx = talloc_init("usershare_sd_xctx");
8669 if (parse_usershare_file(ctx, &sbuf, service_name,
8670 iService, lines, numlines, &sharepath,
8671 &comment, &psd, &guest_ok) != USERSHARE_OK) {
8672 talloc_destroy(ctx);
8679 /* Everything ok - add the service possibly using a template. */
8681 const struct service *sp = &sDefault;
8682 if (snum_template != -1) {
8683 sp = ServicePtrs[snum_template];
8686 if ((iService = add_a_service(sp, service_name)) < 0) {
8687 DEBUG(0, ("process_usershare_file: Failed to add "
8688 "new service %s\n", service_name));
8689 talloc_destroy(ctx);
8693 /* Read only is controlled by usershare ACL below. */
8694 ServicePtrs[iService]->bRead_only = False;
8697 /* Write the ACL of the new/modified share. */
8698 if (!set_share_security(service_name, psd)) {
8699 DEBUG(0, ("process_usershare_file: Failed to set share "
8700 "security for user share %s\n",
8702 lp_remove_service(iService);
8703 talloc_destroy(ctx);
8707 /* If from a template it may be marked invalid. */
8708 ServicePtrs[iService]->valid = True;
8710 /* Set the service as a valid usershare. */
8711 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8713 /* Set guest access. */
8714 if (lp_usershare_allow_guests()) {
8715 ServicePtrs[iService]->bGuest_ok = guest_ok;
8718 /* And note when it was loaded. */
8719 ServicePtrs[iService]->usershare_last_mod = sbuf.st_mtime;
8720 string_set(&ServicePtrs[iService]->szPath, sharepath);
8721 string_set(&ServicePtrs[iService]->comment, comment);
8723 talloc_destroy(ctx);
8728 /***************************************************************************
8729 Checks if a usershare entry has been modified since last load.
8730 ***************************************************************************/
8732 static bool usershare_exists(int iService, time_t *last_mod)
8734 SMB_STRUCT_STAT lsbuf;
8735 const char *usersharepath = Globals.szUsersharePath;
8738 if (asprintf(&fname, "%s/%s",
8740 ServicePtrs[iService]->szService) < 0) {
8744 if (sys_lstat(fname, &lsbuf) != 0) {
8749 if (!S_ISREG(lsbuf.st_mode)) {
8755 *last_mod = lsbuf.st_mtime;
8759 /***************************************************************************
8760 Load a usershare service by name. Returns a valid servicenumber or -1.
8761 ***************************************************************************/
8763 int load_usershare_service(const char *servicename)
8765 SMB_STRUCT_STAT sbuf;
8766 const char *usersharepath = Globals.szUsersharePath;
8767 int max_user_shares = Globals.iUsershareMaxShares;
8768 int snum_template = -1;
8770 if (*usersharepath == 0 || max_user_shares == 0) {
8774 if (sys_stat(usersharepath, &sbuf) != 0) {
8775 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8776 usersharepath, strerror(errno) ));
8780 if (!S_ISDIR(sbuf.st_mode)) {
8781 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8787 * This directory must be owned by root, and have the 't' bit set.
8788 * It also must not be writable by "other".
8792 if (sbuf.st_uid != 0 || !(sbuf.st_mode & S_ISVTX) || (sbuf.st_mode & S_IWOTH)) {
8794 if (sbuf.st_uid != 0 || (sbuf.st_mode & S_IWOTH)) {
8796 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8797 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8802 /* Ensure the template share exists if it's set. */
8803 if (Globals.szUsershareTemplateShare[0]) {
8804 /* We can't use lp_servicenumber here as we are recommending that
8805 template shares have -valid=False set. */
8806 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8807 if (ServicePtrs[snum_template]->szService &&
8808 strequal(ServicePtrs[snum_template]->szService,
8809 Globals.szUsershareTemplateShare)) {
8814 if (snum_template == -1) {
8815 DEBUG(0,("load_usershare_service: usershare template share %s "
8816 "does not exist.\n",
8817 Globals.szUsershareTemplateShare ));
8822 return process_usershare_file(usersharepath, servicename, snum_template);
8825 /***************************************************************************
8826 Load all user defined shares from the user share directory.
8827 We only do this if we're enumerating the share list.
8828 This is the function that can delete usershares that have
8830 ***************************************************************************/
8832 int load_usershare_shares(void)
8835 SMB_STRUCT_STAT sbuf;
8836 SMB_STRUCT_DIRENT *de;
8837 int num_usershares = 0;
8838 int max_user_shares = Globals.iUsershareMaxShares;
8839 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8840 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8841 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8843 int snum_template = -1;
8844 const char *usersharepath = Globals.szUsersharePath;
8845 int ret = lp_numservices();
8847 if (max_user_shares == 0 || *usersharepath == '\0') {
8848 return lp_numservices();
8851 if (sys_stat(usersharepath, &sbuf) != 0) {
8852 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8853 usersharepath, strerror(errno) ));
8858 * This directory must be owned by root, and have the 't' bit set.
8859 * It also must not be writable by "other".
8863 if (sbuf.st_uid != 0 || !(sbuf.st_mode & S_ISVTX) || (sbuf.st_mode & S_IWOTH)) {
8865 if (sbuf.st_uid != 0 || (sbuf.st_mode & S_IWOTH)) {
8867 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8868 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8873 /* Ensure the template share exists if it's set. */
8874 if (Globals.szUsershareTemplateShare[0]) {
8875 /* We can't use lp_servicenumber here as we are recommending that
8876 template shares have -valid=False set. */
8877 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8878 if (ServicePtrs[snum_template]->szService &&
8879 strequal(ServicePtrs[snum_template]->szService,
8880 Globals.szUsershareTemplateShare)) {
8885 if (snum_template == -1) {
8886 DEBUG(0,("load_usershare_shares: usershare template share %s "
8887 "does not exist.\n",
8888 Globals.szUsershareTemplateShare ));
8893 /* Mark all existing usershares as pending delete. */
8894 for (iService = iNumServices - 1; iService >= 0; iService--) {
8895 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8896 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8900 dp = sys_opendir(usersharepath);
8902 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8903 usersharepath, strerror(errno) ));
8907 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8908 (de = sys_readdir(dp));
8909 num_dir_entries++ ) {
8911 const char *n = de->d_name;
8913 /* Ignore . and .. */
8915 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8921 /* Temporary file used when creating a share. */
8922 num_tmp_dir_entries++;
8925 /* Allow 20% tmp entries. */
8926 if (num_tmp_dir_entries > allowed_tmp_entries) {
8927 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8928 "in directory %s\n",
8929 num_tmp_dir_entries, usersharepath));
8933 r = process_usershare_file(usersharepath, n, snum_template);
8935 /* Update the services count. */
8937 if (num_usershares >= max_user_shares) {
8938 DEBUG(0,("load_usershare_shares: max user shares reached "
8939 "on file %s in directory %s\n",
8940 n, usersharepath ));
8943 } else if (r == -1) {
8944 num_bad_dir_entries++;
8947 /* Allow 20% bad entries. */
8948 if (num_bad_dir_entries > allowed_bad_entries) {
8949 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8950 "in directory %s\n",
8951 num_bad_dir_entries, usersharepath));
8955 /* Allow 20% bad entries. */
8956 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
8957 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8958 "in directory %s\n",
8959 num_dir_entries, usersharepath));
8966 /* Sweep through and delete any non-refreshed usershares that are
8967 not currently in use. */
8968 for (iService = iNumServices - 1; iService >= 0; iService--) {
8969 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
8970 if (conn_snum_used(iService)) {
8973 /* Remove from the share ACL db. */
8974 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8975 lp_servicename(iService) ));
8976 delete_share_security(lp_servicename(iService));
8977 free_service_byindex(iService);
8981 return lp_numservices();
8984 /********************************************************
8985 Destroy global resources allocated in this file
8986 ********************************************************/
8988 void gfree_loadparm(void)
8994 /* Free resources allocated to services */
8996 for ( i = 0; i < iNumServices; i++ ) {
8998 free_service_byindex(i);
9002 SAFE_FREE( ServicePtrs );
9005 /* Now release all resources allocated to global
9006 parameters and the default service */
9008 free_global_parameters();
9012 /***************************************************************************
9013 Allow client apps to specify that they are a client
9014 ***************************************************************************/
9015 void lp_set_in_client(bool b)
9021 /***************************************************************************
9022 Determine if we're running in a client app
9023 ***************************************************************************/
9024 bool lp_is_in_client(void)
9029 /***************************************************************************
9030 Load the services array from the services file. Return True on success,
9032 ***************************************************************************/
9034 bool lp_load_ex(const char *pszFname,
9038 bool initialize_globals,
9039 bool allow_include_registry,
9040 bool allow_registry_shares)
9047 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
9049 bInGlobalSection = True;
9050 bGlobalOnly = global_only;
9051 bAllowIncludeRegistry = allow_include_registry;
9053 init_globals(! initialize_globals);
9058 if (save_defaults) {
9063 free_param_opts(&Globals.param_opt);
9065 /* We get sections first, so have to start 'behind' to make up */
9068 if (lp_config_backend_is_file()) {
9069 n2 = alloc_sub_basic(get_current_username(),
9070 current_user_info.domain,
9073 smb_panic("lp_load_ex: out of memory");
9076 add_to_file_list(pszFname, n2);
9078 bRetval = pm_process(n2, do_section, do_parameter, NULL);
9081 /* finish up the last section */
9082 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
9084 if (iServiceIndex >= 0) {
9085 bRetval = service_ok(iServiceIndex);
9089 if (lp_config_backend_is_registry()) {
9090 /* config backend changed to registry in config file */
9092 * We need to use this extra global variable here to
9093 * survive restart: init_globals uses this as a default
9094 * for ConfigBackend. Otherwise, init_globals would
9095 * send us into an endless loop here.
9097 config_backend = CONFIG_BACKEND_REGISTRY;
9099 DEBUG(1, ("lp_load_ex: changing to config backend "
9101 init_globals(false);
9102 lp_kill_all_services();
9103 return lp_load_ex(pszFname, global_only, save_defaults,
9104 add_ipc, initialize_globals,
9105 allow_include_registry,
9106 allow_registry_shares);
9108 } else if (lp_config_backend_is_registry()) {
9109 bRetval = process_registry_globals();
9111 DEBUG(0, ("Illegal config backend given: %d\n",
9112 lp_config_backend()));
9116 if (bRetval && lp_registry_shares() && allow_registry_shares) {
9117 bRetval = process_registry_shares();
9120 lp_add_auto_services(lp_auto_services());
9123 /* When 'restrict anonymous = 2' guest connections to ipc$
9125 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9126 if ( lp_enable_asu_support() ) {
9127 lp_add_ipc("ADMIN$", false);
9132 set_default_server_announce_type();
9133 set_allowed_client_auth();
9137 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9138 /* if bWINSsupport is true and we are in the client */
9139 if (lp_is_in_client() && Globals.bWINSsupport) {
9140 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9145 bAllowIncludeRegistry = true;
9150 bool lp_load(const char *pszFname,
9154 bool initialize_globals)
9156 return lp_load_ex(pszFname,
9164 bool lp_load_initial_only(const char *pszFname)
9166 return lp_load_ex(pszFname,
9175 bool lp_load_with_registry_shares(const char *pszFname,
9179 bool initialize_globals)
9181 return lp_load_ex(pszFname,
9190 /***************************************************************************
9191 Return the max number of services.
9192 ***************************************************************************/
9194 int lp_numservices(void)
9196 return (iNumServices);
9199 /***************************************************************************
9200 Display the contents of the services array in human-readable form.
9201 ***************************************************************************/
9203 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9208 defaults_saved = False;
9212 dump_a_service(&sDefault, f);
9214 for (iService = 0; iService < maxtoprint; iService++) {
9216 lp_dump_one(f, show_defaults, iService);
9220 /***************************************************************************
9221 Display the contents of one service in human-readable form.
9222 ***************************************************************************/
9224 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9227 if (ServicePtrs[snum]->szService[0] == '\0')
9229 dump_a_service(ServicePtrs[snum], f);
9233 /***************************************************************************
9234 Return the number of the service with the given name, or -1 if it doesn't
9235 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9236 getservicebyname()! This works ONLY if all services have been loaded, and
9237 does not copy the found service.
9238 ***************************************************************************/
9240 int lp_servicenumber(const char *pszServiceName)
9243 fstring serviceName;
9245 if (!pszServiceName) {
9246 return GLOBAL_SECTION_SNUM;
9249 for (iService = iNumServices - 1; iService >= 0; iService--) {
9250 if (VALID(iService) && ServicePtrs[iService]->szService) {
9252 * The substitution here is used to support %U is
9255 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9256 standard_sub_basic(get_current_username(),
9257 current_user_info.domain,
9258 serviceName,sizeof(serviceName));
9259 if (strequal(serviceName, pszServiceName)) {
9265 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9268 if (!usershare_exists(iService, &last_mod)) {
9269 /* Remove the share security tdb entry for it. */
9270 delete_share_security(lp_servicename(iService));
9271 /* Remove it from the array. */
9272 free_service_byindex(iService);
9273 /* Doesn't exist anymore. */
9274 return GLOBAL_SECTION_SNUM;
9277 /* Has it been modified ? If so delete and reload. */
9278 if (ServicePtrs[iService]->usershare_last_mod < last_mod) {
9279 /* Remove it from the array. */
9280 free_service_byindex(iService);
9281 /* and now reload it. */
9282 iService = load_usershare_service(pszServiceName);
9287 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9288 return GLOBAL_SECTION_SNUM;
9294 bool share_defined(const char *service_name)
9296 return (lp_servicenumber(service_name) != -1);
9299 struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
9300 const char *sharename)
9302 struct share_params *result;
9306 if (!(sname = SMB_STRDUP(sharename))) {
9310 snum = find_service(sname);
9317 if (!(result = TALLOC_P(mem_ctx, struct share_params))) {
9318 DEBUG(0, ("talloc failed\n"));
9322 result->service = snum;
9326 struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx)
9328 struct share_iterator *result;
9330 if (!(result = TALLOC_P(mem_ctx, struct share_iterator))) {
9331 DEBUG(0, ("talloc failed\n"));
9335 result->next_id = 0;
9339 struct share_params *next_share(struct share_iterator *list)
9341 struct share_params *result;
9343 while (!lp_snum_ok(list->next_id) &&
9344 (list->next_id < lp_numservices())) {
9348 if (list->next_id >= lp_numservices()) {
9352 if (!(result = TALLOC_P(list, struct share_params))) {
9353 DEBUG(0, ("talloc failed\n"));
9357 result->service = list->next_id;
9362 struct share_params *next_printer(struct share_iterator *list)
9364 struct share_params *result;
9366 while ((result = next_share(list)) != NULL) {
9367 if (lp_print_ok(result->service)) {
9375 * This is a hack for a transition period until we transformed all code from
9376 * service numbers to struct share_params.
9379 struct share_params *snum2params_static(int snum)
9381 static struct share_params result;
9382 result.service = snum;
9386 /*******************************************************************
9387 A useful volume label function.
9388 ********************************************************************/
9390 const char *volume_label(int snum)
9393 const char *label = lp_volume(snum);
9395 label = lp_servicename(snum);
9398 /* This returns a 33 byte guarenteed null terminated string. */
9399 ret = talloc_strndup(talloc_tos(), label, 32);
9406 /*******************************************************************
9407 Set the server type we will announce as via nmbd.
9408 ********************************************************************/
9410 static void set_default_server_announce_type(void)
9412 default_server_announce = 0;
9413 default_server_announce |= SV_TYPE_WORKSTATION;
9414 default_server_announce |= SV_TYPE_SERVER;
9415 default_server_announce |= SV_TYPE_SERVER_UNIX;
9417 /* note that the flag should be set only if we have a
9418 printer service but nmbd doesn't actually load the
9419 services so we can't tell --jerry */
9421 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9423 switch (lp_announce_as()) {
9424 case ANNOUNCE_AS_NT_SERVER:
9425 default_server_announce |= SV_TYPE_SERVER_NT;
9426 /* fall through... */
9427 case ANNOUNCE_AS_NT_WORKSTATION:
9428 default_server_announce |= SV_TYPE_NT;
9430 case ANNOUNCE_AS_WIN95:
9431 default_server_announce |= SV_TYPE_WIN95_PLUS;
9433 case ANNOUNCE_AS_WFW:
9434 default_server_announce |= SV_TYPE_WFW;
9440 switch (lp_server_role()) {
9441 case ROLE_DOMAIN_MEMBER:
9442 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9444 case ROLE_DOMAIN_PDC:
9445 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9447 case ROLE_DOMAIN_BDC:
9448 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9450 case ROLE_STANDALONE:
9454 if (lp_time_server())
9455 default_server_announce |= SV_TYPE_TIME_SOURCE;
9457 if (lp_host_msdfs())
9458 default_server_announce |= SV_TYPE_DFS_SERVER;
9461 /***********************************************************
9462 returns role of Samba server
9463 ************************************************************/
9465 int lp_server_role(void)
9470 /***********************************************************
9471 If we are PDC then prefer us as DMB
9472 ************************************************************/
9474 bool lp_domain_master(void)
9476 if (Globals.iDomainMaster == Auto)
9477 return (lp_server_role() == ROLE_DOMAIN_PDC);
9479 return (bool)Globals.iDomainMaster;
9482 /***********************************************************
9483 If we are DMB then prefer us as LMB
9484 ************************************************************/
9486 bool lp_preferred_master(void)
9488 if (Globals.iPreferredMaster == Auto)
9489 return (lp_local_master() && lp_domain_master());
9491 return (bool)Globals.iPreferredMaster;
9494 /*******************************************************************
9496 ********************************************************************/
9498 void lp_remove_service(int snum)
9500 ServicePtrs[snum]->valid = False;
9501 invalid_services[num_invalid_services++] = snum;
9504 /*******************************************************************
9506 ********************************************************************/
9508 void lp_copy_service(int snum, const char *new_name)
9510 do_section(new_name, NULL);
9512 snum = lp_servicenumber(new_name);
9514 lp_do_parameter(snum, "copy", lp_servicename(snum));
9519 /*******************************************************************
9520 Get the default server type we will announce as via nmbd.
9521 ********************************************************************/
9523 int lp_default_server_announce(void)
9525 return default_server_announce;
9528 /*******************************************************************
9529 Split the announce version into major and minor numbers.
9530 ********************************************************************/
9532 int lp_major_announce_version(void)
9534 static bool got_major = False;
9535 static int major_version = DEFAULT_MAJOR_VERSION;
9540 return major_version;
9543 if ((vers = lp_announce_version()) == NULL)
9544 return major_version;
9546 if ((p = strchr_m(vers, '.')) == 0)
9547 return major_version;
9550 major_version = atoi(vers);
9551 return major_version;
9554 int lp_minor_announce_version(void)
9556 static bool got_minor = False;
9557 static int minor_version = DEFAULT_MINOR_VERSION;
9562 return minor_version;
9565 if ((vers = lp_announce_version()) == NULL)
9566 return minor_version;
9568 if ((p = strchr_m(vers, '.')) == 0)
9569 return minor_version;
9572 minor_version = atoi(p);
9573 return minor_version;
9576 /***********************************************************
9577 Set the global name resolution order (used in smbclient).
9578 ************************************************************/
9580 void lp_set_name_resolve_order(const char *new_order)
9582 string_set(&Globals.szNameResolveOrder, new_order);
9585 const char *lp_printername(int snum)
9587 const char *ret = _lp_printername(snum);
9588 if (ret == NULL || (ret != NULL && *ret == '\0'))
9589 ret = lp_const_servicename(snum);
9595 /***********************************************************
9596 Allow daemons such as winbindd to fix their logfile name.
9597 ************************************************************/
9599 void lp_set_logfile(const char *name)
9601 string_set(&Globals.szLogFile, name);
9602 debug_set_logfile(name);
9605 /*******************************************************************
9606 Return the max print jobs per queue.
9607 ********************************************************************/
9609 int lp_maxprintjobs(int snum)
9611 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9612 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9613 maxjobs = PRINT_MAX_JOBID - 1;
9618 const char *lp_printcapname(void)
9620 if ((Globals.szPrintcapname != NULL) &&
9621 (Globals.szPrintcapname[0] != '\0'))
9622 return Globals.szPrintcapname;
9624 if (sDefault.iPrinting == PRINT_CUPS) {
9632 if (sDefault.iPrinting == PRINT_BSD)
9633 return "/etc/printcap";
9635 return PRINTCAP_NAME;
9638 static uint32 spoolss_state;
9640 bool lp_disable_spoolss( void )
9642 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9643 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9645 return spoolss_state == SVCCTL_STOPPED ? True : False;
9648 void lp_set_spoolss_state( uint32 state )
9650 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9652 spoolss_state = state;
9655 uint32 lp_get_spoolss_state( void )
9657 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9660 /*******************************************************************
9661 Ensure we don't use sendfile if server smb signing is active.
9662 ********************************************************************/
9664 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9666 bool sign_active = false;
9668 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9669 if (Protocol < PROTOCOL_NT1) {
9672 if (signing_state) {
9673 sign_active = smb_signing_is_active(signing_state);
9675 return (_lp_use_sendfile(snum) &&
9676 (get_remote_arch() != RA_WIN95) &&
9680 /*******************************************************************
9681 Turn off sendfile if we find the underlying OS doesn't support it.
9682 ********************************************************************/
9684 void set_use_sendfile(int snum, bool val)
9686 if (LP_SNUM_OK(snum))
9687 ServicePtrs[snum]->bUseSendfile = val;
9689 sDefault.bUseSendfile = val;
9692 /*******************************************************************
9693 Turn off storing DOS attributes if this share doesn't support it.
9694 ********************************************************************/
9696 void set_store_dos_attributes(int snum, bool val)
9698 if (!LP_SNUM_OK(snum))
9700 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9703 void lp_set_mangling_method(const char *new_method)
9705 string_set(&Globals.szManglingMethod, new_method);
9708 /*******************************************************************
9709 Global state for POSIX pathname processing.
9710 ********************************************************************/
9712 static bool posix_pathnames;
9714 bool lp_posix_pathnames(void)
9716 return posix_pathnames;
9719 /*******************************************************************
9720 Change everything needed to ensure POSIX pathname processing (currently
9722 ********************************************************************/
9724 void lp_set_posix_pathnames(void)
9726 posix_pathnames = True;
9729 /*******************************************************************
9730 Global state for POSIX lock processing - CIFS unix extensions.
9731 ********************************************************************/
9733 bool posix_default_lock_was_set;
9734 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9736 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9738 if (posix_default_lock_was_set) {
9739 return posix_cifsx_locktype;
9741 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9745 /*******************************************************************
9746 ********************************************************************/
9748 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9750 posix_default_lock_was_set = True;
9751 posix_cifsx_locktype = val;
9754 int lp_min_receive_file_size(void)
9756 if (Globals.iminreceivefile < 0) {
9759 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9762 /*******************************************************************
9763 If socket address is an empty character string, it is necessary to
9764 define it as "0.0.0.0".
9765 ********************************************************************/
9767 const char *lp_socket_address(void)
9769 char *sock_addr = Globals.szSocketAddress;
9771 if (sock_addr[0] == '\0'){
9772 string_set(&Globals.szSocketAddress, "0.0.0.0");
9774 return Globals.szSocketAddress;