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_SYS_SYSCTL_H
58 #include <sys/sysctl.h>
61 #ifdef HAVE_HTTPCONNECTENCRYPT
62 #include <cups/http.h>
67 extern userdom_struct current_user_info;
70 #define GLOBAL_NAME "global"
74 #define PRINTERS_NAME "printers"
78 #define HOMES_NAME "homes"
81 /* the special value for the include parameter
82 * to be interpreted not as a file name but to
83 * trigger loading of the global smb.conf options
85 #ifndef INCLUDE_REGISTRY_NAME
86 #define INCLUDE_REGISTRY_NAME "registry"
89 static bool in_client = False; /* Not in the client by default */
90 static struct smbconf_csn conf_last_csn;
92 #define CONFIG_BACKEND_FILE 0
93 #define CONFIG_BACKEND_REGISTRY 1
95 static int config_backend = CONFIG_BACKEND_FILE;
97 /* some helpful bits */
98 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
99 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
101 #define USERSHARE_VALID 1
102 #define USERSHARE_PENDING_DELETE 2
104 static bool defaults_saved = False;
106 struct param_opt_struct {
107 struct param_opt_struct *prev, *next;
114 * This structure describes global (ie., server-wide) parameters.
121 char *display_charset;
122 char *szPrintcapname;
123 char *szAddPortCommand;
124 char *szEnumPortsCommand;
125 char *szAddPrinterCommand;
126 char *szDeletePrinterCommand;
127 char *szOs2DriverMap;
133 char *szDefaultService;
137 char *szServerString;
138 char *szAutoServices;
139 char *szPasswdProgram;
143 char *szSMBPasswdFile;
145 char *szPassdbBackend;
146 char **szPreloadModules;
147 char *szPasswordServer;
148 char *szSocketOptions;
150 char *szAfsUsernameMap;
151 int iAfsTokenLifetime;
152 char *szLogNtTokenCommand;
158 char **szWINSservers;
160 char *szRemoteAnnounce;
161 char *szRemoteBrowseSync;
162 char *szSocketAddress;
163 char *szNISHomeMapName;
164 char *szAnnounceVersion; /* This is initialised in init_globals */
167 char **szNetbiosAliases;
168 char *szNetbiosScope;
169 char *szNameResolveOrder;
171 char *szAddUserScript;
172 char *szRenameUserScript;
173 char *szDelUserScript;
174 char *szAddGroupScript;
175 char *szDelGroupScript;
176 char *szAddUserToGroupScript;
177 char *szDelUserFromGroupScript;
178 char *szSetPrimaryGroupScript;
179 char *szAddMachineScript;
180 char *szShutdownScript;
181 char *szAbortShutdownScript;
182 char *szUsernameMapScript;
183 char *szCheckPasswordScript;
190 bool bPassdbExpandExplicit;
191 int AlgorithmicRidBase;
192 char *szTemplateHomedir;
193 char *szTemplateShell;
194 char *szWinbindSeparator;
195 bool bWinbindEnumUsers;
196 bool bWinbindEnumGroups;
197 bool bWinbindUseDefaultDomain;
198 bool bWinbindTrustedDomainsOnly;
199 bool bWinbindNestedGroups;
200 int winbind_expand_groups;
201 bool bWinbindRefreshTickets;
202 bool bWinbindOfflineLogon;
203 bool bWinbindNormalizeNames;
204 bool bWinbindRpcOnly;
205 bool bCreateKrb5Conf;
206 char *szIdmapBackend;
207 char *szIdmapAllocBackend;
208 char *szAddShareCommand;
209 char *szChangeShareCommand;
210 char *szDeleteShareCommand;
212 char *szGuestaccount;
213 char *szManglingMethod;
214 char **szServicesList;
215 char *szUsersharePath;
216 char *szUsershareTemplateShare;
217 char **szUsersharePrefixAllowList;
218 char **szUsersharePrefixDenyList;
225 int open_files_db_hash_size;
234 bool paranoid_server_security;
237 int iMaxSmbdProcesses;
238 bool bDisableSpoolss;
241 bool enhanced_browsing;
247 int announce_as; /* This is initialised in init_globals */
248 int machine_password_timeout;
250 int oplock_break_wait_time;
251 int winbind_cache_time;
252 int winbind_reconnect_delay;
253 int winbind_max_idle_children;
254 char **szWinbindNssInfo;
256 char *szLdapMachineSuffix;
257 char *szLdapUserSuffix;
258 char *szLdapIdmapSuffix;
259 char *szLdapGroupSuffix;
262 int ldap_follow_referral;
265 int ldap_debug_level;
266 int ldap_debug_threshold;
270 char *szIPrintServer;
272 char **szClusterAddresses;
275 int ldap_passwd_sync;
276 int ldap_replication_sleep;
277 int ldap_timeout; /* This is initialised in init_globals */
278 int ldap_connection_timeout;
281 bool bMsAddPrinterWizard;
286 int iPreferredMaster;
289 char **szInitLogonDelayedHosts;
291 bool bEncryptPasswords;
296 bool bObeyPamRestrictions;
298 int PrintcapCacheTime;
299 bool bLargeReadwrite;
306 bool bBindInterfacesOnly;
307 bool bPamPasswordChange;
308 bool bUnixPasswdSync;
309 bool bPasswdChatDebug;
310 int iPasswdChatTimeout;
314 bool bNTStatusSupport;
316 int iMaxStatCacheSize;
318 bool bAllowTrustedDomains;
322 bool bClientLanManAuth;
323 bool bClientNTLMv2Auth;
324 bool bClientPlaintextAuth;
325 bool bClientUseSpnego;
326 bool bDebugPrefixTimestamp;
327 bool bDebugHiresTimestamp;
331 bool bEnableCoreFiles;
334 bool bHostnameLookups;
335 bool bUnixExtensions;
336 bool bDisableNetbios;
337 char * szDedicatedKeytabFile;
339 bool bDeferSharingViolations;
340 bool bEnablePrivileges;
342 bool bUsershareOwnerOnly;
343 bool bUsershareAllowGuests;
344 bool bRegistryShares;
345 int restrict_anonymous;
346 int name_cache_timeout;
349 int client_ldap_sasl_wrapping;
350 int iUsershareMaxShares;
352 int iIdmapNegativeCacheTime;
356 struct param_opt_struct *param_opt;
357 int cups_connection_timeout;
358 char *szSMBPerfcountModule;
359 bool bMapUntrustedToDomain;
360 bool bFakeDirCreateTimes;
363 static struct global Globals;
366 * This structure describes a single service.
372 struct timespec usershare_last_mod;
376 char **szInvalidUsers;
384 char *szRootPostExec;
386 char *szPrintcommand;
389 char *szLppausecommand;
390 char *szLpresumecommand;
391 char *szQueuepausecommand;
392 char *szQueueresumecommand;
394 char *szPrintjobUsername;
402 char *szVetoOplockFiles;
408 char **printer_admin;
413 char *szAioWriteBehind;
417 int iMaxReportedPrintJobs;
420 int iCreate_force_mode;
422 int iSecurity_force_mode;
425 int iDir_Security_mask;
426 int iDir_Security_force_mode;
430 int iOplockContentionLimit;
435 bool bRootpreexecClose;
438 bool bShortCasePreserve;
440 bool bHideSpecialFiles;
441 bool bHideUnReadable;
442 bool bHideUnWriteableFiles;
444 bool bAccessBasedShareEnum;
449 bool bAdministrative_share;
455 bool bStoreDosAttributes;
468 bool bStrictAllocate;
471 struct bitmap *copymap;
472 bool bDeleteReadonly;
474 bool bDeleteVetoFiles;
477 bool bDosFiletimeResolution;
483 bool bUseClientDriver;
484 bool bDefaultDevmode;
485 bool bForcePrintername;
487 bool bForceUnknownAclUser;
490 bool bMap_acl_inherit;
493 bool bAclCheckPermissions;
494 bool bAclMapFullControl;
495 bool bAclGroupControl;
497 bool bKernelChangeNotify;
498 int iallocation_roundup_size;
502 int iDirectoryNameCacheSize;
504 struct param_opt_struct *param_opt;
506 char dummy[3]; /* for alignment */
510 /* This is a default service used to prime a services structure */
511 static struct service sDefault = {
513 False, /* not autoloaded */
514 0, /* not a usershare */
515 {0, }, /* No last mod time */
516 NULL, /* szService */
518 NULL, /* szUsername */
519 NULL, /* szInvalidUsers */
520 NULL, /* szValidUsers */
521 NULL, /* szAdminUsers */
523 NULL, /* szInclude */
524 NULL, /* szPreExec */
525 NULL, /* szPostExec */
526 NULL, /* szRootPreExec */
527 NULL, /* szRootPostExec */
528 NULL, /* szCupsOptions */
529 NULL, /* szPrintcommand */
530 NULL, /* szLpqcommand */
531 NULL, /* szLprmcommand */
532 NULL, /* szLppausecommand */
533 NULL, /* szLpresumecommand */
534 NULL, /* szQueuepausecommand */
535 NULL, /* szQueueresumecommand */
536 NULL, /* szPrintername */
537 NULL, /* szPrintjobUsername */
538 NULL, /* szDontdescend */
539 NULL, /* szHostsallow */
540 NULL, /* szHostsdeny */
541 NULL, /* szMagicScript */
542 NULL, /* szMagicOutput */
543 NULL, /* szVetoFiles */
544 NULL, /* szHideFiles */
545 NULL, /* szVetoOplockFiles */
547 NULL, /* force user */
548 NULL, /* force group */
550 NULL, /* writelist */
551 NULL, /* printer admin */
554 NULL, /* vfs objects */
555 NULL, /* szMSDfsProxy */
556 NULL, /* szAioWriteBehind */
558 0, /* iMinPrintSpace */
559 1000, /* iMaxPrintJobs */
560 0, /* iMaxReportedPrintJobs */
561 0, /* iWriteCacheSize */
562 0744, /* iCreate_mask */
563 0000, /* iCreate_force_mode */
564 0777, /* iSecurity_mask */
565 0, /* iSecurity_force_mode */
566 0755, /* iDir_mask */
567 0000, /* iDir_force_mode */
568 0777, /* iDir_Security_mask */
569 0, /* iDir_Security_force_mode */
570 0, /* iMaxConnections */
571 CASE_LOWER, /* iDefaultCase */
572 DEFAULT_PRINTING, /* iPrinting */
573 2, /* iOplockContentionLimit */
575 1024, /* iBlock_size */
576 0, /* iDfreeCacheTime */
577 False, /* bPreexecClose */
578 False, /* bRootpreexecClose */
579 Auto, /* case sensitive */
580 True, /* case preserve */
581 True, /* short case preserve */
582 True, /* bHideDotFiles */
583 False, /* bHideSpecialFiles */
584 False, /* bHideUnReadable */
585 False, /* bHideUnWriteableFiles */
586 True, /* bBrowseable */
587 False, /* bAccessBasedShareEnum */
588 True, /* bAvailable */
589 True, /* bRead_only */
590 True, /* bNo_set_dir */
591 False, /* bGuest_only */
592 False, /* bAdministrative_share */
593 False, /* bGuest_ok */
594 False, /* bPrint_ok */
595 False, /* bMap_system */
596 False, /* bMap_hidden */
597 True, /* bMap_archive */
598 False, /* bStoreDosAttributes */
599 False, /* bDmapiSupport */
601 Auto, /* iStrictLocking */
602 True, /* bPosixLocking */
603 True, /* bShareModes */
605 True, /* bLevel2OpLocks */
606 False, /* bOnlyUser */
607 True, /* bMangledNames */
608 True, /* bWidelinks */
609 True, /* bSymlinks */
610 False, /* bSyncAlways */
611 False, /* bStrictAllocate */
612 False, /* bStrictSync */
613 '~', /* magic char */
615 False, /* bDeleteReadonly */
616 False, /* bFakeOplocks */
617 False, /* bDeleteVetoFiles */
618 False, /* bDosFilemode */
619 True, /* bDosFiletimes */
620 False, /* bDosFiletimeResolution */
621 True, /* bBlockingLocks */
622 False, /* bInheritPerms */
623 False, /* bInheritACLS */
624 False, /* bInheritOwner */
625 False, /* bMSDfsRoot */
626 False, /* bUseClientDriver */
627 True, /* bDefaultDevmode */
628 False, /* bForcePrintername */
629 True, /* bNTAclSupport */
630 False, /* bForceUnknownAclUser */
631 False, /* bUseSendfile */
632 False, /* bProfileAcls */
633 False, /* bMap_acl_inherit */
634 False, /* bAfs_Share */
635 False, /* bEASupport */
636 True, /* bAclCheckPermissions */
637 True, /* bAclMapFullControl */
638 False, /* bAclGroupControl */
639 True, /* bChangeNotify */
640 True, /* bKernelChangeNotify */
641 SMB_ROUNDUP_ALLOCATION_SIZE, /* iallocation_roundup_size */
642 0, /* iAioReadSize */
643 0, /* iAioWriteSize */
644 MAP_READONLY_YES, /* iMap_readonly */
645 #ifdef BROKEN_DIRECTORY_HANDLING
646 0, /* iDirectoryNameCacheSize */
648 100, /* iDirectoryNameCacheSize */
650 Auto, /* ismb_encrypt */
651 NULL, /* Parametric options */
656 /* local variables */
657 static struct service **ServicePtrs = NULL;
658 static int iNumServices = 0;
659 static int iServiceIndex = 0;
660 static struct db_context *ServiceHash;
661 static int *invalid_services = NULL;
662 static int num_invalid_services = 0;
663 static bool bInGlobalSection = True;
664 static bool bGlobalOnly = False;
665 static int server_role;
666 static int default_server_announce;
668 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
670 /* prototypes for the special type handlers */
671 static bool handle_include( int snum, const char *pszParmValue, char **ptr);
672 static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
673 static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
674 static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
675 static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
676 static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
677 static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
678 static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
679 static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
680 static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
681 static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
682 static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
684 static void set_server_role(void);
685 static void set_default_server_announce_type(void);
686 static void set_allowed_client_auth(void);
688 static void *lp_local_ptr(struct service *service, void *ptr);
690 static void add_to_file_list(const char *fname, const char *subfname);
692 static const struct enum_list enum_protocol[] = {
693 {PROTOCOL_SMB2, "SMB2"},
694 {PROTOCOL_NT1, "NT1"},
695 {PROTOCOL_LANMAN2, "LANMAN2"},
696 {PROTOCOL_LANMAN1, "LANMAN1"},
697 {PROTOCOL_CORE, "CORE"},
698 {PROTOCOL_COREPLUS, "COREPLUS"},
699 {PROTOCOL_COREPLUS, "CORE+"},
703 static const struct enum_list enum_security[] = {
704 {SEC_SHARE, "SHARE"},
706 {SEC_SERVER, "SERVER"},
707 {SEC_DOMAIN, "DOMAIN"},
714 static const struct enum_list enum_printing[] = {
715 {PRINT_SYSV, "sysv"},
717 {PRINT_HPUX, "hpux"},
721 {PRINT_LPRNG, "lprng"},
722 {PRINT_CUPS, "cups"},
723 {PRINT_IPRINT, "iprint"},
725 {PRINT_LPROS2, "os2"},
727 {PRINT_TEST, "test"},
729 #endif /* DEVELOPER */
733 static const struct enum_list enum_ldap_sasl_wrapping[] = {
735 {ADS_AUTH_SASL_SIGN, "sign"},
736 {ADS_AUTH_SASL_SEAL, "seal"},
740 static const struct enum_list enum_ldap_ssl[] = {
741 {LDAP_SSL_OFF, "no"},
742 {LDAP_SSL_OFF, "off"},
743 {LDAP_SSL_START_TLS, "start tls"},
744 {LDAP_SSL_START_TLS, "start_tls"},
748 static const struct enum_list enum_ldap_passwd_sync[] = {
749 {LDAP_PASSWD_SYNC_OFF, "no"},
750 {LDAP_PASSWD_SYNC_OFF, "off"},
751 {LDAP_PASSWD_SYNC_ON, "yes"},
752 {LDAP_PASSWD_SYNC_ON, "on"},
753 {LDAP_PASSWD_SYNC_ONLY, "only"},
757 /* Types of machine we can announce as. */
758 #define ANNOUNCE_AS_NT_SERVER 1
759 #define ANNOUNCE_AS_WIN95 2
760 #define ANNOUNCE_AS_WFW 3
761 #define ANNOUNCE_AS_NT_WORKSTATION 4
763 static const struct enum_list enum_announce_as[] = {
764 {ANNOUNCE_AS_NT_SERVER, "NT"},
765 {ANNOUNCE_AS_NT_SERVER, "NT Server"},
766 {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
767 {ANNOUNCE_AS_WIN95, "win95"},
768 {ANNOUNCE_AS_WFW, "WfW"},
772 static const struct enum_list enum_map_readonly[] = {
773 {MAP_READONLY_NO, "no"},
774 {MAP_READONLY_NO, "false"},
775 {MAP_READONLY_NO, "0"},
776 {MAP_READONLY_YES, "yes"},
777 {MAP_READONLY_YES, "true"},
778 {MAP_READONLY_YES, "1"},
779 {MAP_READONLY_PERMISSIONS, "permissions"},
780 {MAP_READONLY_PERMISSIONS, "perms"},
784 static const struct enum_list enum_case[] = {
785 {CASE_LOWER, "lower"},
786 {CASE_UPPER, "upper"},
792 static const struct enum_list enum_bool_auto[] = {
803 /* Client-side offline caching policy types */
804 #define CSC_POLICY_MANUAL 0
805 #define CSC_POLICY_DOCUMENTS 1
806 #define CSC_POLICY_PROGRAMS 2
807 #define CSC_POLICY_DISABLE 3
809 static const struct enum_list enum_csc_policy[] = {
810 {CSC_POLICY_MANUAL, "manual"},
811 {CSC_POLICY_DOCUMENTS, "documents"},
812 {CSC_POLICY_PROGRAMS, "programs"},
813 {CSC_POLICY_DISABLE, "disable"},
817 /* SMB signing types. */
818 static const struct enum_list enum_smb_signing_vals[] = {
830 {Required, "required"},
831 {Required, "mandatory"},
833 {Required, "forced"},
834 {Required, "enforced"},
838 /* ACL compatibility options. */
839 static const struct enum_list enum_acl_compat_vals[] = {
840 { ACL_COMPAT_AUTO, "auto" },
841 { ACL_COMPAT_WINNT, "winnt" },
842 { ACL_COMPAT_WIN2K, "win2k" },
847 Do you want session setups at user level security with a invalid
848 password to be rejected or allowed in as guest? WinNT rejects them
849 but it can be a pain as it means "net view" needs to use a password
851 You have 3 choices in the setting of map_to_guest:
853 "Never" means session setups with an invalid password
854 are rejected. This is the default.
856 "Bad User" means session setups with an invalid password
857 are rejected, unless the username does not exist, in which case it
858 is treated as a guest login
860 "Bad Password" means session setups with an invalid password
861 are treated as a guest login
863 Note that map_to_guest only has an effect in user or server
867 static const struct enum_list enum_map_to_guest[] = {
868 {NEVER_MAP_TO_GUEST, "Never"},
869 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
870 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
871 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
875 /* Config backend options */
877 static const struct enum_list enum_config_backend[] = {
878 {CONFIG_BACKEND_FILE, "file"},
879 {CONFIG_BACKEND_REGISTRY, "registry"},
883 /* ADS kerberos ticket verification options */
885 static const struct enum_list enum_kerberos_method[] = {
886 {KERBEROS_VERIFY_SECRETS, "default"},
887 {KERBEROS_VERIFY_SECRETS, "secrets only"},
888 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
889 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
890 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
894 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
896 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
897 * screen in SWAT. This is used to exclude parameters as well as to squash all
898 * parameters that have been duplicated by pseudonyms.
900 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
901 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
902 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
905 * NOTE2: Handling of duplicated (synonym) parameters:
906 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
907 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
908 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
909 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
912 static struct parm_struct parm_table[] = {
913 {N_("Base Options"), P_SEP, P_SEPARATOR},
916 .label = "dos charset",
919 .ptr = &Globals.dos_charset,
920 .special = handle_charset,
922 .flags = FLAG_ADVANCED
925 .label = "unix charset",
928 .ptr = &Globals.unix_charset,
929 .special = handle_charset,
931 .flags = FLAG_ADVANCED
934 .label = "display charset",
937 .ptr = &Globals.display_charset,
938 .special = handle_charset,
940 .flags = FLAG_ADVANCED
946 .ptr = &sDefault.comment,
949 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
955 .ptr = &sDefault.szPath,
958 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
961 .label = "directory",
964 .ptr = &sDefault.szPath,
970 .label = "workgroup",
973 .ptr = &Globals.szWorkgroup,
974 .special = handle_workgroup,
976 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
983 .ptr = &Globals.szRealm,
986 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
990 .label = "netbios name",
993 .ptr = &Globals.szNetbiosName,
994 .special = handle_netbios_name,
996 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
999 .label = "netbios aliases",
1001 .p_class = P_GLOBAL,
1002 .ptr = &Globals.szNetbiosAliases,
1003 .special = handle_netbios_aliases,
1005 .flags = FLAG_ADVANCED,
1008 .label = "netbios scope",
1010 .p_class = P_GLOBAL,
1011 .ptr = &Globals.szNetbiosScope,
1012 .special = handle_netbios_scope,
1014 .flags = FLAG_ADVANCED,
1017 .label = "server string",
1019 .p_class = P_GLOBAL,
1020 .ptr = &Globals.szServerString,
1023 .flags = FLAG_BASIC | FLAG_ADVANCED,
1026 .label = "interfaces",
1028 .p_class = P_GLOBAL,
1029 .ptr = &Globals.szInterfaces,
1032 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1035 .label = "bind interfaces only",
1037 .p_class = P_GLOBAL,
1038 .ptr = &Globals.bBindInterfacesOnly,
1041 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1044 .label = "config backend",
1046 .p_class = P_GLOBAL,
1047 .ptr = &Globals.ConfigBackend,
1049 .enum_list = enum_config_backend,
1050 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
1053 {N_("Security Options"), P_SEP, P_SEPARATOR},
1056 .label = "security",
1058 .p_class = P_GLOBAL,
1059 .ptr = &Globals.security,
1061 .enum_list = enum_security,
1062 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1065 .label = "auth methods",
1067 .p_class = P_GLOBAL,
1068 .ptr = &Globals.AuthMethods,
1071 .flags = FLAG_ADVANCED,
1074 .label = "encrypt passwords",
1076 .p_class = P_GLOBAL,
1077 .ptr = &Globals.bEncryptPasswords,
1080 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1083 .label = "update encrypted",
1085 .p_class = P_GLOBAL,
1086 .ptr = &Globals.bUpdateEncrypt,
1089 .flags = FLAG_ADVANCED,
1092 .label = "client schannel",
1094 .p_class = P_GLOBAL,
1095 .ptr = &Globals.clientSchannel,
1097 .enum_list = enum_bool_auto,
1098 .flags = FLAG_BASIC | FLAG_ADVANCED,
1101 .label = "server schannel",
1103 .p_class = P_GLOBAL,
1104 .ptr = &Globals.serverSchannel,
1106 .enum_list = enum_bool_auto,
1107 .flags = FLAG_BASIC | FLAG_ADVANCED,
1110 .label = "allow trusted domains",
1112 .p_class = P_GLOBAL,
1113 .ptr = &Globals.bAllowTrustedDomains,
1116 .flags = FLAG_ADVANCED,
1119 .label = "map to guest",
1121 .p_class = P_GLOBAL,
1122 .ptr = &Globals.map_to_guest,
1124 .enum_list = enum_map_to_guest,
1125 .flags = FLAG_ADVANCED,
1128 .label = "null passwords",
1130 .p_class = P_GLOBAL,
1131 .ptr = &Globals.bNullPasswords,
1134 .flags = FLAG_ADVANCED,
1137 .label = "obey pam restrictions",
1139 .p_class = P_GLOBAL,
1140 .ptr = &Globals.bObeyPamRestrictions,
1143 .flags = FLAG_ADVANCED,
1146 .label = "password server",
1148 .p_class = P_GLOBAL,
1149 .ptr = &Globals.szPasswordServer,
1152 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1155 .label = "smb passwd file",
1157 .p_class = P_GLOBAL,
1158 .ptr = &Globals.szSMBPasswdFile,
1161 .flags = FLAG_ADVANCED,
1164 .label = "private dir",
1166 .p_class = P_GLOBAL,
1167 .ptr = &Globals.szPrivateDir,
1170 .flags = FLAG_ADVANCED,
1173 .label = "passdb backend",
1175 .p_class = P_GLOBAL,
1176 .ptr = &Globals.szPassdbBackend,
1179 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1182 .label = "algorithmic rid base",
1184 .p_class = P_GLOBAL,
1185 .ptr = &Globals.AlgorithmicRidBase,
1188 .flags = FLAG_ADVANCED,
1191 .label = "root directory",
1193 .p_class = P_GLOBAL,
1194 .ptr = &Globals.szRootdir,
1197 .flags = FLAG_ADVANCED,
1200 .label = "root dir",
1202 .p_class = P_GLOBAL,
1203 .ptr = &Globals.szRootdir,
1211 .p_class = P_GLOBAL,
1212 .ptr = &Globals.szRootdir,
1218 .label = "guest account",
1220 .p_class = P_GLOBAL,
1221 .ptr = &Globals.szGuestaccount,
1224 .flags = FLAG_BASIC | FLAG_ADVANCED,
1227 .label = "enable privileges",
1229 .p_class = P_GLOBAL,
1230 .ptr = &Globals.bEnablePrivileges,
1233 .flags = FLAG_ADVANCED,
1237 .label = "pam password change",
1239 .p_class = P_GLOBAL,
1240 .ptr = &Globals.bPamPasswordChange,
1243 .flags = FLAG_ADVANCED,
1246 .label = "passwd program",
1248 .p_class = P_GLOBAL,
1249 .ptr = &Globals.szPasswdProgram,
1252 .flags = FLAG_ADVANCED,
1255 .label = "passwd chat",
1257 .p_class = P_GLOBAL,
1258 .ptr = &Globals.szPasswdChat,
1261 .flags = FLAG_ADVANCED,
1264 .label = "passwd chat debug",
1266 .p_class = P_GLOBAL,
1267 .ptr = &Globals.bPasswdChatDebug,
1270 .flags = FLAG_ADVANCED,
1273 .label = "passwd chat timeout",
1275 .p_class = P_GLOBAL,
1276 .ptr = &Globals.iPasswdChatTimeout,
1279 .flags = FLAG_ADVANCED,
1282 .label = "check password script",
1284 .p_class = P_GLOBAL,
1285 .ptr = &Globals.szCheckPasswordScript,
1288 .flags = FLAG_ADVANCED,
1291 .label = "username map",
1293 .p_class = P_GLOBAL,
1294 .ptr = &Globals.szUsernameMap,
1297 .flags = FLAG_ADVANCED,
1300 .label = "password level",
1302 .p_class = P_GLOBAL,
1303 .ptr = &Globals.pwordlevel,
1306 .flags = FLAG_ADVANCED,
1309 .label = "username level",
1311 .p_class = P_GLOBAL,
1312 .ptr = &Globals.unamelevel,
1315 .flags = FLAG_ADVANCED,
1318 .label = "unix password sync",
1320 .p_class = P_GLOBAL,
1321 .ptr = &Globals.bUnixPasswdSync,
1324 .flags = FLAG_ADVANCED,
1327 .label = "restrict anonymous",
1329 .p_class = P_GLOBAL,
1330 .ptr = &Globals.restrict_anonymous,
1333 .flags = FLAG_ADVANCED,
1336 .label = "lanman auth",
1338 .p_class = P_GLOBAL,
1339 .ptr = &Globals.bLanmanAuth,
1342 .flags = FLAG_ADVANCED,
1345 .label = "ntlm auth",
1347 .p_class = P_GLOBAL,
1348 .ptr = &Globals.bNTLMAuth,
1351 .flags = FLAG_ADVANCED,
1354 .label = "client NTLMv2 auth",
1356 .p_class = P_GLOBAL,
1357 .ptr = &Globals.bClientNTLMv2Auth,
1360 .flags = FLAG_ADVANCED,
1363 .label = "client lanman auth",
1365 .p_class = P_GLOBAL,
1366 .ptr = &Globals.bClientLanManAuth,
1369 .flags = FLAG_ADVANCED,
1372 .label = "client plaintext auth",
1374 .p_class = P_GLOBAL,
1375 .ptr = &Globals.bClientPlaintextAuth,
1378 .flags = FLAG_ADVANCED,
1381 .label = "username",
1384 .ptr = &sDefault.szUsername,
1387 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1393 .ptr = &sDefault.szUsername,
1402 .ptr = &sDefault.szUsername,
1408 .label = "invalid users",
1411 .ptr = &sDefault.szInvalidUsers,
1414 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1417 .label = "valid users",
1420 .ptr = &sDefault.szValidUsers,
1423 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1426 .label = "admin users",
1429 .ptr = &sDefault.szAdminUsers,
1432 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1435 .label = "read list",
1438 .ptr = &sDefault.readlist,
1441 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1444 .label = "write list",
1447 .ptr = &sDefault.writelist,
1450 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1453 .label = "printer admin",
1456 .ptr = &sDefault.printer_admin,
1459 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1462 .label = "force user",
1465 .ptr = &sDefault.force_user,
1468 .flags = FLAG_ADVANCED | FLAG_SHARE,
1471 .label = "force group",
1474 .ptr = &sDefault.force_group,
1477 .flags = FLAG_ADVANCED | FLAG_SHARE,
1483 .ptr = &sDefault.force_group,
1486 .flags = FLAG_ADVANCED,
1489 .label = "read only",
1492 .ptr = &sDefault.bRead_only,
1495 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1498 .label = "write ok",
1501 .ptr = &sDefault.bRead_only,
1507 .label = "writeable",
1510 .ptr = &sDefault.bRead_only,
1516 .label = "writable",
1519 .ptr = &sDefault.bRead_only,
1525 .label = "acl check permissions",
1528 .ptr = &sDefault.bAclCheckPermissions,
1531 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1534 .label = "acl group control",
1537 .ptr = &sDefault.bAclGroupControl,
1540 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1543 .label = "acl map full control",
1546 .ptr = &sDefault.bAclMapFullControl,
1549 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1552 .label = "create mask",
1555 .ptr = &sDefault.iCreate_mask,
1558 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1561 .label = "create mode",
1564 .ptr = &sDefault.iCreate_mask,
1570 .label = "force create mode",
1573 .ptr = &sDefault.iCreate_force_mode,
1576 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1579 .label = "security mask",
1582 .ptr = &sDefault.iSecurity_mask,
1585 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1588 .label = "force security mode",
1591 .ptr = &sDefault.iSecurity_force_mode,
1594 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1597 .label = "directory mask",
1600 .ptr = &sDefault.iDir_mask,
1603 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1606 .label = "directory mode",
1609 .ptr = &sDefault.iDir_mask,
1612 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1615 .label = "force directory mode",
1618 .ptr = &sDefault.iDir_force_mode,
1621 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1624 .label = "directory security mask",
1627 .ptr = &sDefault.iDir_Security_mask,
1630 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1633 .label = "force directory security mode",
1636 .ptr = &sDefault.iDir_Security_force_mode,
1639 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1642 .label = "force unknown acl user",
1645 .ptr = &sDefault.bForceUnknownAclUser,
1648 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1651 .label = "inherit permissions",
1654 .ptr = &sDefault.bInheritPerms,
1657 .flags = FLAG_ADVANCED | FLAG_SHARE,
1660 .label = "inherit acls",
1663 .ptr = &sDefault.bInheritACLS,
1666 .flags = FLAG_ADVANCED | FLAG_SHARE,
1669 .label = "inherit owner",
1672 .ptr = &sDefault.bInheritOwner,
1675 .flags = FLAG_ADVANCED | FLAG_SHARE,
1678 .label = "guest only",
1681 .ptr = &sDefault.bGuest_only,
1684 .flags = FLAG_ADVANCED | FLAG_SHARE,
1687 .label = "only guest",
1690 .ptr = &sDefault.bGuest_only,
1696 .label = "administrative share",
1699 .ptr = &sDefault.bAdministrative_share,
1702 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1706 .label = "guest ok",
1709 .ptr = &sDefault.bGuest_ok,
1712 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1718 .ptr = &sDefault.bGuest_ok,
1724 .label = "only user",
1727 .ptr = &sDefault.bOnlyUser,
1730 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1733 .label = "hosts allow",
1736 .ptr = &sDefault.szHostsallow,
1739 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1742 .label = "allow hosts",
1745 .ptr = &sDefault.szHostsallow,
1751 .label = "hosts deny",
1754 .ptr = &sDefault.szHostsdeny,
1757 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1760 .label = "deny hosts",
1763 .ptr = &sDefault.szHostsdeny,
1769 .label = "preload modules",
1771 .p_class = P_GLOBAL,
1772 .ptr = &Globals.szPreloadModules,
1775 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1778 .label = "dedicated keytab file",
1780 .p_class = P_GLOBAL,
1781 .ptr = &Globals.szDedicatedKeytabFile,
1784 .flags = FLAG_ADVANCED,
1787 .label = "kerberos method",
1789 .p_class = P_GLOBAL,
1790 .ptr = &Globals.iKerberosMethod,
1792 .enum_list = enum_kerberos_method,
1793 .flags = FLAG_ADVANCED,
1796 .label = "map untrusted to domain",
1798 .p_class = P_GLOBAL,
1799 .ptr = &Globals.bMapUntrustedToDomain,
1802 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1806 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1809 .label = "log level",
1811 .p_class = P_GLOBAL,
1812 .ptr = &Globals.szLogLevel,
1813 .special = handle_debug_list,
1815 .flags = FLAG_ADVANCED,
1818 .label = "debuglevel",
1820 .p_class = P_GLOBAL,
1821 .ptr = &Globals.szLogLevel,
1822 .special = handle_debug_list,
1829 .p_class = P_GLOBAL,
1830 .ptr = &Globals.syslog,
1833 .flags = FLAG_ADVANCED,
1836 .label = "syslog only",
1838 .p_class = P_GLOBAL,
1839 .ptr = &Globals.bSyslogOnly,
1842 .flags = FLAG_ADVANCED,
1845 .label = "log file",
1847 .p_class = P_GLOBAL,
1848 .ptr = &Globals.szLogFile,
1851 .flags = FLAG_ADVANCED,
1854 .label = "max log size",
1856 .p_class = P_GLOBAL,
1857 .ptr = &Globals.max_log_size,
1860 .flags = FLAG_ADVANCED,
1863 .label = "debug timestamp",
1865 .p_class = P_GLOBAL,
1866 .ptr = &Globals.bTimestampLogs,
1869 .flags = FLAG_ADVANCED,
1872 .label = "timestamp logs",
1874 .p_class = P_GLOBAL,
1875 .ptr = &Globals.bTimestampLogs,
1878 .flags = FLAG_ADVANCED,
1881 .label = "debug prefix timestamp",
1883 .p_class = P_GLOBAL,
1884 .ptr = &Globals.bDebugPrefixTimestamp,
1887 .flags = FLAG_ADVANCED,
1890 .label = "debug hires timestamp",
1892 .p_class = P_GLOBAL,
1893 .ptr = &Globals.bDebugHiresTimestamp,
1896 .flags = FLAG_ADVANCED,
1899 .label = "debug pid",
1901 .p_class = P_GLOBAL,
1902 .ptr = &Globals.bDebugPid,
1905 .flags = FLAG_ADVANCED,
1908 .label = "debug uid",
1910 .p_class = P_GLOBAL,
1911 .ptr = &Globals.bDebugUid,
1914 .flags = FLAG_ADVANCED,
1917 .label = "debug class",
1919 .p_class = P_GLOBAL,
1920 .ptr = &Globals.bDebugClass,
1923 .flags = FLAG_ADVANCED,
1926 .label = "enable core files",
1928 .p_class = P_GLOBAL,
1929 .ptr = &Globals.bEnableCoreFiles,
1932 .flags = FLAG_ADVANCED,
1935 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1938 .label = "allocation roundup size",
1941 .ptr = &sDefault.iallocation_roundup_size,
1944 .flags = FLAG_ADVANCED,
1947 .label = "aio read size",
1950 .ptr = &sDefault.iAioReadSize,
1953 .flags = FLAG_ADVANCED,
1956 .label = "aio write size",
1959 .ptr = &sDefault.iAioWriteSize,
1962 .flags = FLAG_ADVANCED,
1965 .label = "aio write behind",
1968 .ptr = &sDefault.szAioWriteBehind,
1971 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1974 .label = "smb ports",
1976 .p_class = P_GLOBAL,
1977 .ptr = &Globals.smb_ports,
1980 .flags = FLAG_ADVANCED,
1983 .label = "large readwrite",
1985 .p_class = P_GLOBAL,
1986 .ptr = &Globals.bLargeReadwrite,
1989 .flags = FLAG_ADVANCED,
1992 .label = "max protocol",
1994 .p_class = P_GLOBAL,
1995 .ptr = &Globals.maxprotocol,
1997 .enum_list = enum_protocol,
1998 .flags = FLAG_ADVANCED,
2001 .label = "protocol",
2003 .p_class = P_GLOBAL,
2004 .ptr = &Globals.maxprotocol,
2006 .enum_list = enum_protocol,
2007 .flags = FLAG_ADVANCED,
2010 .label = "min protocol",
2012 .p_class = P_GLOBAL,
2013 .ptr = &Globals.minprotocol,
2015 .enum_list = enum_protocol,
2016 .flags = FLAG_ADVANCED,
2019 .label = "min receivefile size",
2021 .p_class = P_GLOBAL,
2022 .ptr = &Globals.iminreceivefile,
2025 .flags = FLAG_ADVANCED,
2028 .label = "read raw",
2030 .p_class = P_GLOBAL,
2031 .ptr = &Globals.bReadRaw,
2034 .flags = FLAG_ADVANCED,
2037 .label = "write raw",
2039 .p_class = P_GLOBAL,
2040 .ptr = &Globals.bWriteRaw,
2043 .flags = FLAG_ADVANCED,
2046 .label = "disable netbios",
2048 .p_class = P_GLOBAL,
2049 .ptr = &Globals.bDisableNetbios,
2052 .flags = FLAG_ADVANCED,
2055 .label = "reset on zero vc",
2057 .p_class = P_GLOBAL,
2058 .ptr = &Globals.bResetOnZeroVC,
2061 .flags = FLAG_ADVANCED,
2064 .label = "acl compatibility",
2066 .p_class = P_GLOBAL,
2067 .ptr = &Globals.iAclCompat,
2069 .enum_list = enum_acl_compat_vals,
2070 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2073 .label = "defer sharing violations",
2075 .p_class = P_GLOBAL,
2076 .ptr = &Globals.bDeferSharingViolations,
2079 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2082 .label = "ea support",
2085 .ptr = &sDefault.bEASupport,
2088 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2091 .label = "nt acl support",
2094 .ptr = &sDefault.bNTAclSupport,
2097 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2100 .label = "nt pipe support",
2102 .p_class = P_GLOBAL,
2103 .ptr = &Globals.bNTPipeSupport,
2106 .flags = FLAG_ADVANCED,
2109 .label = "nt status support",
2111 .p_class = P_GLOBAL,
2112 .ptr = &Globals.bNTStatusSupport,
2115 .flags = FLAG_ADVANCED,
2118 .label = "profile acls",
2121 .ptr = &sDefault.bProfileAcls,
2124 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
2127 .label = "announce version",
2129 .p_class = P_GLOBAL,
2130 .ptr = &Globals.szAnnounceVersion,
2133 .flags = FLAG_ADVANCED,
2136 .label = "announce as",
2138 .p_class = P_GLOBAL,
2139 .ptr = &Globals.announce_as,
2141 .enum_list = enum_announce_as,
2142 .flags = FLAG_ADVANCED,
2145 .label = "map acl inherit",
2148 .ptr = &sDefault.bMap_acl_inherit,
2151 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2154 .label = "afs share",
2157 .ptr = &sDefault.bAfs_Share,
2160 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2165 .p_class = P_GLOBAL,
2166 .ptr = &Globals.max_mux,
2169 .flags = FLAG_ADVANCED,
2172 .label = "max xmit",
2174 .p_class = P_GLOBAL,
2175 .ptr = &Globals.max_xmit,
2178 .flags = FLAG_ADVANCED,
2181 .label = "name resolve order",
2183 .p_class = P_GLOBAL,
2184 .ptr = &Globals.szNameResolveOrder,
2187 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2192 .p_class = P_GLOBAL,
2193 .ptr = &Globals.max_ttl,
2196 .flags = FLAG_ADVANCED,
2199 .label = "max wins ttl",
2201 .p_class = P_GLOBAL,
2202 .ptr = &Globals.max_wins_ttl,
2205 .flags = FLAG_ADVANCED,
2208 .label = "min wins ttl",
2210 .p_class = P_GLOBAL,
2211 .ptr = &Globals.min_wins_ttl,
2214 .flags = FLAG_ADVANCED,
2217 .label = "time server",
2219 .p_class = P_GLOBAL,
2220 .ptr = &Globals.bTimeServer,
2223 .flags = FLAG_ADVANCED,
2226 .label = "unix extensions",
2228 .p_class = P_GLOBAL,
2229 .ptr = &Globals.bUnixExtensions,
2232 .flags = FLAG_ADVANCED,
2235 .label = "use spnego",
2237 .p_class = P_GLOBAL,
2238 .ptr = &Globals.bUseSpnego,
2241 .flags = FLAG_ADVANCED,
2244 .label = "client signing",
2246 .p_class = P_GLOBAL,
2247 .ptr = &Globals.client_signing,
2249 .enum_list = enum_smb_signing_vals,
2250 .flags = FLAG_ADVANCED,
2253 .label = "server signing",
2255 .p_class = P_GLOBAL,
2256 .ptr = &Globals.server_signing,
2258 .enum_list = enum_smb_signing_vals,
2259 .flags = FLAG_ADVANCED,
2262 .label = "smb encrypt",
2265 .ptr = &sDefault.ismb_encrypt,
2267 .enum_list = enum_smb_signing_vals,
2268 .flags = FLAG_ADVANCED,
2271 .label = "client use spnego",
2273 .p_class = P_GLOBAL,
2274 .ptr = &Globals.bClientUseSpnego,
2277 .flags = FLAG_ADVANCED,
2280 .label = "client ldap sasl wrapping",
2282 .p_class = P_GLOBAL,
2283 .ptr = &Globals.client_ldap_sasl_wrapping,
2285 .enum_list = enum_ldap_sasl_wrapping,
2286 .flags = FLAG_ADVANCED,
2289 .label = "enable asu support",
2291 .p_class = P_GLOBAL,
2292 .ptr = &Globals.bASUSupport,
2295 .flags = FLAG_ADVANCED,
2298 .label = "svcctl list",
2300 .p_class = P_GLOBAL,
2301 .ptr = &Globals.szServicesList,
2304 .flags = FLAG_ADVANCED,
2307 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
2310 .label = "block size",
2313 .ptr = &sDefault.iBlock_size,
2316 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2319 .label = "deadtime",
2321 .p_class = P_GLOBAL,
2322 .ptr = &Globals.deadtime,
2325 .flags = FLAG_ADVANCED,
2328 .label = "getwd cache",
2330 .p_class = P_GLOBAL,
2331 .ptr = &Globals.getwd_cache,
2334 .flags = FLAG_ADVANCED,
2337 .label = "keepalive",
2339 .p_class = P_GLOBAL,
2340 .ptr = &Globals.iKeepalive,
2343 .flags = FLAG_ADVANCED,
2346 .label = "change notify",
2349 .ptr = &sDefault.bChangeNotify,
2352 .flags = FLAG_ADVANCED | FLAG_SHARE,
2355 .label = "directory name cache size",
2358 .ptr = &sDefault.iDirectoryNameCacheSize,
2361 .flags = FLAG_ADVANCED | FLAG_SHARE,
2364 .label = "kernel change notify",
2367 .ptr = &sDefault.bKernelChangeNotify,
2370 .flags = FLAG_ADVANCED | FLAG_SHARE,
2373 .label = "lpq cache time",
2375 .p_class = P_GLOBAL,
2376 .ptr = &Globals.lpqcachetime,
2379 .flags = FLAG_ADVANCED,
2382 .label = "max smbd processes",
2384 .p_class = P_GLOBAL,
2385 .ptr = &Globals.iMaxSmbdProcesses,
2388 .flags = FLAG_ADVANCED,
2391 .label = "max connections",
2394 .ptr = &sDefault.iMaxConnections,
2397 .flags = FLAG_ADVANCED | FLAG_SHARE,
2400 .label = "paranoid server security",
2402 .p_class = P_GLOBAL,
2403 .ptr = &Globals.paranoid_server_security,
2406 .flags = FLAG_ADVANCED,
2409 .label = "max disk size",
2411 .p_class = P_GLOBAL,
2412 .ptr = &Globals.maxdisksize,
2415 .flags = FLAG_ADVANCED,
2418 .label = "max open files",
2420 .p_class = P_GLOBAL,
2421 .ptr = &Globals.max_open_files,
2424 .flags = FLAG_ADVANCED,
2427 .label = "min print space",
2430 .ptr = &sDefault.iMinPrintSpace,
2433 .flags = FLAG_ADVANCED | FLAG_PRINT,
2436 .label = "socket options",
2438 .p_class = P_GLOBAL,
2439 .ptr = &Globals.szSocketOptions,
2442 .flags = FLAG_ADVANCED,
2445 .label = "strict allocate",
2448 .ptr = &sDefault.bStrictAllocate,
2451 .flags = FLAG_ADVANCED | FLAG_SHARE,
2454 .label = "strict sync",
2457 .ptr = &sDefault.bStrictSync,
2460 .flags = FLAG_ADVANCED | FLAG_SHARE,
2463 .label = "sync always",
2466 .ptr = &sDefault.bSyncAlways,
2469 .flags = FLAG_ADVANCED | FLAG_SHARE,
2472 .label = "use mmap",
2474 .p_class = P_GLOBAL,
2475 .ptr = &Globals.bUseMmap,
2478 .flags = FLAG_ADVANCED,
2481 .label = "use sendfile",
2484 .ptr = &sDefault.bUseSendfile,
2487 .flags = FLAG_ADVANCED | FLAG_SHARE,
2490 .label = "hostname lookups",
2492 .p_class = P_GLOBAL,
2493 .ptr = &Globals.bHostnameLookups,
2496 .flags = FLAG_ADVANCED,
2499 .label = "write cache size",
2502 .ptr = &sDefault.iWriteCacheSize,
2505 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
2508 .label = "name cache timeout",
2510 .p_class = P_GLOBAL,
2511 .ptr = &Globals.name_cache_timeout,
2514 .flags = FLAG_ADVANCED,
2517 .label = "ctdbd socket",
2519 .p_class = P_GLOBAL,
2520 .ptr = &Globals.ctdbdSocket,
2523 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2526 .label = "cluster addresses",
2528 .p_class = P_GLOBAL,
2529 .ptr = &Globals.szClusterAddresses,
2532 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2535 .label = "clustering",
2537 .p_class = P_GLOBAL,
2538 .ptr = &Globals.clustering,
2541 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2544 .label = "ctdb timeout",
2546 .p_class = P_GLOBAL,
2547 .ptr = &Globals.ctdb_timeout,
2550 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2553 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2556 .label = "max reported print jobs",
2559 .ptr = &sDefault.iMaxReportedPrintJobs,
2562 .flags = FLAG_ADVANCED | FLAG_PRINT,
2565 .label = "max print jobs",
2568 .ptr = &sDefault.iMaxPrintJobs,
2571 .flags = FLAG_ADVANCED | FLAG_PRINT,
2574 .label = "load printers",
2576 .p_class = P_GLOBAL,
2577 .ptr = &Globals.bLoadPrinters,
2580 .flags = FLAG_ADVANCED | FLAG_PRINT,
2583 .label = "printcap cache time",
2585 .p_class = P_GLOBAL,
2586 .ptr = &Globals.PrintcapCacheTime,
2589 .flags = FLAG_ADVANCED | FLAG_PRINT,
2592 .label = "printcap name",
2594 .p_class = P_GLOBAL,
2595 .ptr = &Globals.szPrintcapname,
2598 .flags = FLAG_ADVANCED | FLAG_PRINT,
2601 .label = "printcap",
2603 .p_class = P_GLOBAL,
2604 .ptr = &Globals.szPrintcapname,
2610 .label = "printable",
2613 .ptr = &sDefault.bPrint_ok,
2616 .flags = FLAG_ADVANCED | FLAG_PRINT,
2619 .label = "print ok",
2622 .ptr = &sDefault.bPrint_ok,
2628 .label = "printing",
2631 .ptr = &sDefault.iPrinting,
2632 .special = handle_printing,
2633 .enum_list = enum_printing,
2634 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2637 .label = "cups options",
2640 .ptr = &sDefault.szCupsOptions,
2643 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2646 .label = "cups server",
2648 .p_class = P_GLOBAL,
2649 .ptr = &Globals.szCupsServer,
2652 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2655 .label = "cups encrypt",
2657 .p_class = P_GLOBAL,
2658 .ptr = &Globals.CupsEncrypt,
2660 .enum_list = enum_bool_auto,
2661 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2665 .label = "cups connection timeout",
2667 .p_class = P_GLOBAL,
2668 .ptr = &Globals.cups_connection_timeout,
2671 .flags = FLAG_ADVANCED,
2674 .label = "iprint server",
2676 .p_class = P_GLOBAL,
2677 .ptr = &Globals.szIPrintServer,
2680 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2683 .label = "print command",
2686 .ptr = &sDefault.szPrintcommand,
2689 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2692 .label = "disable spoolss",
2694 .p_class = P_GLOBAL,
2695 .ptr = &Globals.bDisableSpoolss,
2698 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2701 .label = "enable spoolss",
2703 .p_class = P_GLOBAL,
2704 .ptr = &Globals.bDisableSpoolss,
2710 .label = "lpq command",
2713 .ptr = &sDefault.szLpqcommand,
2716 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2719 .label = "lprm command",
2722 .ptr = &sDefault.szLprmcommand,
2725 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2728 .label = "lppause command",
2731 .ptr = &sDefault.szLppausecommand,
2734 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2737 .label = "lpresume command",
2740 .ptr = &sDefault.szLpresumecommand,
2743 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2746 .label = "queuepause command",
2749 .ptr = &sDefault.szQueuepausecommand,
2752 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2755 .label = "queueresume command",
2758 .ptr = &sDefault.szQueueresumecommand,
2761 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2764 .label = "addport command",
2766 .p_class = P_GLOBAL,
2767 .ptr = &Globals.szAddPortCommand,
2770 .flags = FLAG_ADVANCED,
2773 .label = "enumports command",
2775 .p_class = P_GLOBAL,
2776 .ptr = &Globals.szEnumPortsCommand,
2779 .flags = FLAG_ADVANCED,
2782 .label = "addprinter command",
2784 .p_class = P_GLOBAL,
2785 .ptr = &Globals.szAddPrinterCommand,
2788 .flags = FLAG_ADVANCED,
2791 .label = "deleteprinter command",
2793 .p_class = P_GLOBAL,
2794 .ptr = &Globals.szDeletePrinterCommand,
2797 .flags = FLAG_ADVANCED,
2800 .label = "show add printer wizard",
2802 .p_class = P_GLOBAL,
2803 .ptr = &Globals.bMsAddPrinterWizard,
2806 .flags = FLAG_ADVANCED,
2809 .label = "os2 driver map",
2811 .p_class = P_GLOBAL,
2812 .ptr = &Globals.szOs2DriverMap,
2815 .flags = FLAG_ADVANCED,
2819 .label = "printer name",
2822 .ptr = &sDefault.szPrintername,
2825 .flags = FLAG_ADVANCED | FLAG_PRINT,
2831 .ptr = &sDefault.szPrintername,
2837 .label = "use client driver",
2840 .ptr = &sDefault.bUseClientDriver,
2843 .flags = FLAG_ADVANCED | FLAG_PRINT,
2846 .label = "default devmode",
2849 .ptr = &sDefault.bDefaultDevmode,
2852 .flags = FLAG_ADVANCED | FLAG_PRINT,
2855 .label = "force printername",
2858 .ptr = &sDefault.bForcePrintername,
2861 .flags = FLAG_ADVANCED | FLAG_PRINT,
2864 .label = "printjob username",
2867 .ptr = &sDefault.szPrintjobUsername,
2870 .flags = FLAG_ADVANCED | FLAG_PRINT,
2873 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2876 .label = "mangling method",
2878 .p_class = P_GLOBAL,
2879 .ptr = &Globals.szManglingMethod,
2882 .flags = FLAG_ADVANCED,
2885 .label = "mangle prefix",
2887 .p_class = P_GLOBAL,
2888 .ptr = &Globals.mangle_prefix,
2891 .flags = FLAG_ADVANCED,
2895 .label = "default case",
2898 .ptr = &sDefault.iDefaultCase,
2900 .enum_list = enum_case,
2901 .flags = FLAG_ADVANCED | FLAG_SHARE,
2904 .label = "case sensitive",
2907 .ptr = &sDefault.iCaseSensitive,
2909 .enum_list = enum_bool_auto,
2910 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2913 .label = "casesignames",
2916 .ptr = &sDefault.iCaseSensitive,
2918 .enum_list = enum_bool_auto,
2919 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2922 .label = "preserve case",
2925 .ptr = &sDefault.bCasePreserve,
2928 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2931 .label = "short preserve case",
2934 .ptr = &sDefault.bShortCasePreserve,
2937 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2940 .label = "mangling char",
2943 .ptr = &sDefault.magic_char,
2946 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2949 .label = "hide dot files",
2952 .ptr = &sDefault.bHideDotFiles,
2955 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2958 .label = "hide special files",
2961 .ptr = &sDefault.bHideSpecialFiles,
2964 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2967 .label = "hide unreadable",
2970 .ptr = &sDefault.bHideUnReadable,
2973 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2976 .label = "hide unwriteable files",
2979 .ptr = &sDefault.bHideUnWriteableFiles,
2982 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2985 .label = "delete veto files",
2988 .ptr = &sDefault.bDeleteVetoFiles,
2991 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2994 .label = "veto files",
2997 .ptr = &sDefault.szVetoFiles,
3000 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3003 .label = "hide files",
3006 .ptr = &sDefault.szHideFiles,
3009 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3012 .label = "veto oplock files",
3015 .ptr = &sDefault.szVetoOplockFiles,
3018 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3021 .label = "map archive",
3024 .ptr = &sDefault.bMap_archive,
3027 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3030 .label = "map hidden",
3033 .ptr = &sDefault.bMap_hidden,
3036 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3039 .label = "map system",
3042 .ptr = &sDefault.bMap_system,
3045 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3048 .label = "map readonly",
3051 .ptr = &sDefault.iMap_readonly,
3053 .enum_list = enum_map_readonly,
3054 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3057 .label = "mangled names",
3060 .ptr = &sDefault.bMangledNames,
3063 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3066 .label = "max stat cache size",
3068 .p_class = P_GLOBAL,
3069 .ptr = &Globals.iMaxStatCacheSize,
3072 .flags = FLAG_ADVANCED,
3075 .label = "stat cache",
3077 .p_class = P_GLOBAL,
3078 .ptr = &Globals.bStatCache,
3081 .flags = FLAG_ADVANCED,
3084 .label = "store dos attributes",
3087 .ptr = &sDefault.bStoreDosAttributes,
3090 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3093 .label = "dmapi support",
3096 .ptr = &sDefault.bDmapiSupport,
3099 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3103 {N_("Domain Options"), P_SEP, P_SEPARATOR},
3106 .label = "machine password timeout",
3108 .p_class = P_GLOBAL,
3109 .ptr = &Globals.machine_password_timeout,
3112 .flags = FLAG_ADVANCED | FLAG_WIZARD,
3115 {N_("Logon Options"), P_SEP, P_SEPARATOR},
3118 .label = "add user script",
3120 .p_class = P_GLOBAL,
3121 .ptr = &Globals.szAddUserScript,
3124 .flags = FLAG_ADVANCED,
3127 .label = "rename user script",
3129 .p_class = P_GLOBAL,
3130 .ptr = &Globals.szRenameUserScript,
3133 .flags = FLAG_ADVANCED,
3136 .label = "delete user script",
3138 .p_class = P_GLOBAL,
3139 .ptr = &Globals.szDelUserScript,
3142 .flags = FLAG_ADVANCED,
3145 .label = "add group script",
3147 .p_class = P_GLOBAL,
3148 .ptr = &Globals.szAddGroupScript,
3151 .flags = FLAG_ADVANCED,
3154 .label = "delete group script",
3156 .p_class = P_GLOBAL,
3157 .ptr = &Globals.szDelGroupScript,
3160 .flags = FLAG_ADVANCED,
3163 .label = "add user to group script",
3165 .p_class = P_GLOBAL,
3166 .ptr = &Globals.szAddUserToGroupScript,
3169 .flags = FLAG_ADVANCED,
3172 .label = "delete user from group script",
3174 .p_class = P_GLOBAL,
3175 .ptr = &Globals.szDelUserFromGroupScript,
3178 .flags = FLAG_ADVANCED,
3181 .label = "set primary group script",
3183 .p_class = P_GLOBAL,
3184 .ptr = &Globals.szSetPrimaryGroupScript,
3187 .flags = FLAG_ADVANCED,
3190 .label = "add machine script",
3192 .p_class = P_GLOBAL,
3193 .ptr = &Globals.szAddMachineScript,
3196 .flags = FLAG_ADVANCED,
3199 .label = "shutdown script",
3201 .p_class = P_GLOBAL,
3202 .ptr = &Globals.szShutdownScript,
3205 .flags = FLAG_ADVANCED,
3208 .label = "abort shutdown script",
3210 .p_class = P_GLOBAL,
3211 .ptr = &Globals.szAbortShutdownScript,
3214 .flags = FLAG_ADVANCED,
3217 .label = "username map script",
3219 .p_class = P_GLOBAL,
3220 .ptr = &Globals.szUsernameMapScript,
3223 .flags = FLAG_ADVANCED,
3226 .label = "logon script",
3228 .p_class = P_GLOBAL,
3229 .ptr = &Globals.szLogonScript,
3232 .flags = FLAG_ADVANCED,
3235 .label = "logon path",
3237 .p_class = P_GLOBAL,
3238 .ptr = &Globals.szLogonPath,
3241 .flags = FLAG_ADVANCED,
3244 .label = "logon drive",
3246 .p_class = P_GLOBAL,
3247 .ptr = &Globals.szLogonDrive,
3250 .flags = FLAG_ADVANCED,
3253 .label = "logon home",
3255 .p_class = P_GLOBAL,
3256 .ptr = &Globals.szLogonHome,
3259 .flags = FLAG_ADVANCED,
3262 .label = "domain logons",
3264 .p_class = P_GLOBAL,
3265 .ptr = &Globals.bDomainLogons,
3268 .flags = FLAG_ADVANCED,
3272 .label = "init logon delayed hosts",
3274 .p_class = P_GLOBAL,
3275 .ptr = &Globals.szInitLogonDelayedHosts,
3278 .flags = FLAG_ADVANCED,
3282 .label = "init logon delay",
3284 .p_class = P_GLOBAL,
3285 .ptr = &Globals.InitLogonDelay,
3288 .flags = FLAG_ADVANCED,
3292 {N_("Browse Options"), P_SEP, P_SEPARATOR},
3295 .label = "os level",
3297 .p_class = P_GLOBAL,
3298 .ptr = &Globals.os_level,
3301 .flags = FLAG_BASIC | FLAG_ADVANCED,
3304 .label = "lm announce",
3306 .p_class = P_GLOBAL,
3307 .ptr = &Globals.lm_announce,
3309 .enum_list = enum_bool_auto,
3310 .flags = FLAG_ADVANCED,
3313 .label = "lm interval",
3315 .p_class = P_GLOBAL,
3316 .ptr = &Globals.lm_interval,
3319 .flags = FLAG_ADVANCED,
3322 .label = "preferred master",
3324 .p_class = P_GLOBAL,
3325 .ptr = &Globals.iPreferredMaster,
3327 .enum_list = enum_bool_auto,
3328 .flags = FLAG_BASIC | FLAG_ADVANCED,
3331 .label = "prefered master",
3333 .p_class = P_GLOBAL,
3334 .ptr = &Globals.iPreferredMaster,
3336 .enum_list = enum_bool_auto,
3340 .label = "local master",
3342 .p_class = P_GLOBAL,
3343 .ptr = &Globals.bLocalMaster,
3346 .flags = FLAG_BASIC | FLAG_ADVANCED,
3349 .label = "domain master",
3351 .p_class = P_GLOBAL,
3352 .ptr = &Globals.iDomainMaster,
3354 .enum_list = enum_bool_auto,
3355 .flags = FLAG_BASIC | FLAG_ADVANCED,
3358 .label = "browse list",
3360 .p_class = P_GLOBAL,
3361 .ptr = &Globals.bBrowseList,
3364 .flags = FLAG_ADVANCED,
3367 .label = "browseable",
3370 .ptr = &sDefault.bBrowseable,
3373 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3376 .label = "browsable",
3379 .ptr = &sDefault.bBrowseable,
3385 .label = "access based share enum",
3388 .ptr = &sDefault.bAccessBasedShareEnum,
3391 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3394 .label = "enhanced browsing",
3396 .p_class = P_GLOBAL,
3397 .ptr = &Globals.enhanced_browsing,
3400 .flags = FLAG_ADVANCED,
3403 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3406 .label = "dns proxy",
3408 .p_class = P_GLOBAL,
3409 .ptr = &Globals.bDNSproxy,
3412 .flags = FLAG_ADVANCED,
3415 .label = "wins proxy",
3417 .p_class = P_GLOBAL,
3418 .ptr = &Globals.bWINSproxy,
3421 .flags = FLAG_ADVANCED,
3424 .label = "wins server",
3426 .p_class = P_GLOBAL,
3427 .ptr = &Globals.szWINSservers,
3430 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3433 .label = "wins support",
3435 .p_class = P_GLOBAL,
3436 .ptr = &Globals.bWINSsupport,
3439 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3442 .label = "wins hook",
3444 .p_class = P_GLOBAL,
3445 .ptr = &Globals.szWINSHook,
3448 .flags = FLAG_ADVANCED,
3451 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3454 .label = "blocking locks",
3457 .ptr = &sDefault.bBlockingLocks,
3460 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3463 .label = "csc policy",
3466 .ptr = &sDefault.iCSCPolicy,
3468 .enum_list = enum_csc_policy,
3469 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3472 .label = "fake oplocks",
3475 .ptr = &sDefault.bFakeOplocks,
3478 .flags = FLAG_ADVANCED | FLAG_SHARE,
3481 .label = "kernel oplocks",
3483 .p_class = P_GLOBAL,
3484 .ptr = &Globals.bKernelOplocks,
3487 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3493 .ptr = &sDefault.bLocking,
3496 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3499 .label = "lock spin time",
3501 .p_class = P_GLOBAL,
3502 .ptr = &Globals.iLockSpinTime,
3505 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3511 .ptr = &sDefault.bOpLocks,
3514 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3517 .label = "level2 oplocks",
3520 .ptr = &sDefault.bLevel2OpLocks,
3523 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3526 .label = "oplock break wait time",
3528 .p_class = P_GLOBAL,
3529 .ptr = &Globals.oplock_break_wait_time,
3532 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3535 .label = "oplock contention limit",
3538 .ptr = &sDefault.iOplockContentionLimit,
3541 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3544 .label = "posix locking",
3547 .ptr = &sDefault.bPosixLocking,
3550 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3553 .label = "strict locking",
3556 .ptr = &sDefault.iStrictLocking,
3558 .enum_list = enum_bool_auto,
3559 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3562 .label = "share modes",
3565 .ptr = &sDefault.bShareModes,
3568 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3571 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3574 .label = "ldap admin dn",
3576 .p_class = P_GLOBAL,
3577 .ptr = &Globals.szLdapAdminDn,
3580 .flags = FLAG_ADVANCED,
3583 .label = "ldap delete dn",
3585 .p_class = P_GLOBAL,
3586 .ptr = &Globals.ldap_delete_dn,
3589 .flags = FLAG_ADVANCED,
3592 .label = "ldap group suffix",
3594 .p_class = P_GLOBAL,
3595 .ptr = &Globals.szLdapGroupSuffix,
3598 .flags = FLAG_ADVANCED,
3601 .label = "ldap idmap suffix",
3603 .p_class = P_GLOBAL,
3604 .ptr = &Globals.szLdapIdmapSuffix,
3607 .flags = FLAG_ADVANCED,
3610 .label = "ldap machine suffix",
3612 .p_class = P_GLOBAL,
3613 .ptr = &Globals.szLdapMachineSuffix,
3616 .flags = FLAG_ADVANCED,
3619 .label = "ldap passwd sync",
3621 .p_class = P_GLOBAL,
3622 .ptr = &Globals.ldap_passwd_sync,
3624 .enum_list = enum_ldap_passwd_sync,
3625 .flags = FLAG_ADVANCED,
3628 .label = "ldap password sync",
3630 .p_class = P_GLOBAL,
3631 .ptr = &Globals.ldap_passwd_sync,
3633 .enum_list = enum_ldap_passwd_sync,
3637 .label = "ldap replication sleep",
3639 .p_class = P_GLOBAL,
3640 .ptr = &Globals.ldap_replication_sleep,
3643 .flags = FLAG_ADVANCED,
3646 .label = "ldap suffix",
3648 .p_class = P_GLOBAL,
3649 .ptr = &Globals.szLdapSuffix,
3652 .flags = FLAG_ADVANCED,
3655 .label = "ldap ssl",
3657 .p_class = P_GLOBAL,
3658 .ptr = &Globals.ldap_ssl,
3660 .enum_list = enum_ldap_ssl,
3661 .flags = FLAG_ADVANCED,
3664 .label = "ldap ssl ads",
3666 .p_class = P_GLOBAL,
3667 .ptr = &Globals.ldap_ssl_ads,
3670 .flags = FLAG_ADVANCED,
3673 .label = "ldap follow referral",
3675 .p_class = P_GLOBAL,
3676 .ptr = &Globals.ldap_follow_referral,
3678 .enum_list = enum_bool_auto,
3679 .flags = FLAG_ADVANCED,
3682 .label = "ldap timeout",
3684 .p_class = P_GLOBAL,
3685 .ptr = &Globals.ldap_timeout,
3688 .flags = FLAG_ADVANCED,
3691 .label = "ldap connection timeout",
3693 .p_class = P_GLOBAL,
3694 .ptr = &Globals.ldap_connection_timeout,
3697 .flags = FLAG_ADVANCED,
3700 .label = "ldap page size",
3702 .p_class = P_GLOBAL,
3703 .ptr = &Globals.ldap_page_size,
3706 .flags = FLAG_ADVANCED,
3709 .label = "ldap user suffix",
3711 .p_class = P_GLOBAL,
3712 .ptr = &Globals.szLdapUserSuffix,
3715 .flags = FLAG_ADVANCED,
3718 .label = "ldap debug level",
3720 .p_class = P_GLOBAL,
3721 .ptr = &Globals.ldap_debug_level,
3722 .special = handle_ldap_debug_level,
3724 .flags = FLAG_ADVANCED,
3727 .label = "ldap debug threshold",
3729 .p_class = P_GLOBAL,
3730 .ptr = &Globals.ldap_debug_threshold,
3733 .flags = FLAG_ADVANCED,
3736 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3739 .label = "eventlog list",
3741 .p_class = P_GLOBAL,
3742 .ptr = &Globals.szEventLogs,
3745 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3748 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3751 .label = "add share command",
3753 .p_class = P_GLOBAL,
3754 .ptr = &Globals.szAddShareCommand,
3757 .flags = FLAG_ADVANCED,
3760 .label = "change share command",
3762 .p_class = P_GLOBAL,
3763 .ptr = &Globals.szChangeShareCommand,
3766 .flags = FLAG_ADVANCED,
3769 .label = "delete share command",
3771 .p_class = P_GLOBAL,
3772 .ptr = &Globals.szDeleteShareCommand,
3775 .flags = FLAG_ADVANCED,
3778 .label = "config file",
3780 .p_class = P_GLOBAL,
3781 .ptr = &Globals.szConfigFile,
3784 .flags = FLAG_HIDE|FLAG_META,
3789 .p_class = P_GLOBAL,
3790 .ptr = &Globals.szAutoServices,
3793 .flags = FLAG_ADVANCED,
3796 .label = "auto services",
3798 .p_class = P_GLOBAL,
3799 .ptr = &Globals.szAutoServices,
3802 .flags = FLAG_ADVANCED,
3805 .label = "lock directory",
3807 .p_class = P_GLOBAL,
3808 .ptr = &Globals.szLockDir,
3811 .flags = FLAG_ADVANCED,
3814 .label = "lock dir",
3816 .p_class = P_GLOBAL,
3817 .ptr = &Globals.szLockDir,
3823 .label = "state directory",
3825 .p_class = P_GLOBAL,
3826 .ptr = &Globals.szStateDir,
3829 .flags = FLAG_ADVANCED,
3832 .label = "cache directory",
3834 .p_class = P_GLOBAL,
3835 .ptr = &Globals.szCacheDir,
3838 .flags = FLAG_ADVANCED,
3841 .label = "pid directory",
3843 .p_class = P_GLOBAL,
3844 .ptr = &Globals.szPidDir,
3847 .flags = FLAG_ADVANCED,
3851 .label = "utmp directory",
3853 .p_class = P_GLOBAL,
3854 .ptr = &Globals.szUtmpDir,
3857 .flags = FLAG_ADVANCED,
3860 .label = "wtmp directory",
3862 .p_class = P_GLOBAL,
3863 .ptr = &Globals.szWtmpDir,
3866 .flags = FLAG_ADVANCED,
3871 .p_class = P_GLOBAL,
3872 .ptr = &Globals.bUtmp,
3875 .flags = FLAG_ADVANCED,
3879 .label = "default service",
3881 .p_class = P_GLOBAL,
3882 .ptr = &Globals.szDefaultService,
3885 .flags = FLAG_ADVANCED,
3890 .p_class = P_GLOBAL,
3891 .ptr = &Globals.szDefaultService,
3894 .flags = FLAG_ADVANCED,
3897 .label = "message command",
3899 .p_class = P_GLOBAL,
3900 .ptr = &Globals.szMsgCommand,
3903 .flags = FLAG_ADVANCED,
3906 .label = "dfree cache time",
3909 .ptr = &sDefault.iDfreeCacheTime,
3912 .flags = FLAG_ADVANCED,
3915 .label = "dfree command",
3918 .ptr = &sDefault.szDfree,
3921 .flags = FLAG_ADVANCED,
3924 .label = "get quota command",
3926 .p_class = P_GLOBAL,
3927 .ptr = &Globals.szGetQuota,
3930 .flags = FLAG_ADVANCED,
3933 .label = "set quota command",
3935 .p_class = P_GLOBAL,
3936 .ptr = &Globals.szSetQuota,
3939 .flags = FLAG_ADVANCED,
3942 .label = "remote announce",
3944 .p_class = P_GLOBAL,
3945 .ptr = &Globals.szRemoteAnnounce,
3948 .flags = FLAG_ADVANCED,
3951 .label = "remote browse sync",
3953 .p_class = P_GLOBAL,
3954 .ptr = &Globals.szRemoteBrowseSync,
3957 .flags = FLAG_ADVANCED,
3960 .label = "socket address",
3962 .p_class = P_GLOBAL,
3963 .ptr = &Globals.szSocketAddress,
3966 .flags = FLAG_ADVANCED,
3969 .label = "homedir map",
3971 .p_class = P_GLOBAL,
3972 .ptr = &Globals.szNISHomeMapName,
3975 .flags = FLAG_ADVANCED,
3978 .label = "afs username map",
3980 .p_class = P_GLOBAL,
3981 .ptr = &Globals.szAfsUsernameMap,
3984 .flags = FLAG_ADVANCED,
3987 .label = "afs token lifetime",
3989 .p_class = P_GLOBAL,
3990 .ptr = &Globals.iAfsTokenLifetime,
3993 .flags = FLAG_ADVANCED,
3996 .label = "log nt token command",
3998 .p_class = P_GLOBAL,
3999 .ptr = &Globals.szLogNtTokenCommand,
4002 .flags = FLAG_ADVANCED,
4005 .label = "time offset",
4007 .p_class = P_GLOBAL,
4008 .ptr = &extra_time_offset,
4011 .flags = FLAG_ADVANCED,
4014 .label = "NIS homedir",
4016 .p_class = P_GLOBAL,
4017 .ptr = &Globals.bNISHomeMap,
4020 .flags = FLAG_ADVANCED,
4026 .ptr = &sDefault.valid,
4035 .ptr = &sDefault.szCopy,
4036 .special = handle_copy,
4044 .ptr = &sDefault.szInclude,
4045 .special = handle_include,
4047 .flags = FLAG_HIDE|FLAG_META,
4053 .ptr = &sDefault.szPreExec,
4056 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4062 .ptr = &sDefault.szPreExec,
4065 .flags = FLAG_ADVANCED,
4068 .label = "preexec close",
4071 .ptr = &sDefault.bPreexecClose,
4074 .flags = FLAG_ADVANCED | FLAG_SHARE,
4077 .label = "postexec",
4080 .ptr = &sDefault.szPostExec,
4083 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4086 .label = "root preexec",
4089 .ptr = &sDefault.szRootPreExec,
4092 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4095 .label = "root preexec close",
4098 .ptr = &sDefault.bRootpreexecClose,
4101 .flags = FLAG_ADVANCED | FLAG_SHARE,
4104 .label = "root postexec",
4107 .ptr = &sDefault.szRootPostExec,
4110 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4113 .label = "available",
4116 .ptr = &sDefault.bAvailable,
4119 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4122 .label = "registry shares",
4124 .p_class = P_GLOBAL,
4125 .ptr = &Globals.bRegistryShares,
4128 .flags = FLAG_ADVANCED,
4131 .label = "usershare allow guests",
4133 .p_class = P_GLOBAL,
4134 .ptr = &Globals.bUsershareAllowGuests,
4137 .flags = FLAG_ADVANCED,
4140 .label = "usershare max shares",
4142 .p_class = P_GLOBAL,
4143 .ptr = &Globals.iUsershareMaxShares,
4146 .flags = FLAG_ADVANCED,
4149 .label = "usershare owner only",
4151 .p_class = P_GLOBAL,
4152 .ptr = &Globals.bUsershareOwnerOnly,
4155 .flags = FLAG_ADVANCED,
4158 .label = "usershare path",
4160 .p_class = P_GLOBAL,
4161 .ptr = &Globals.szUsersharePath,
4164 .flags = FLAG_ADVANCED,
4167 .label = "usershare prefix allow list",
4169 .p_class = P_GLOBAL,
4170 .ptr = &Globals.szUsersharePrefixAllowList,
4173 .flags = FLAG_ADVANCED,
4176 .label = "usershare prefix deny list",
4178 .p_class = P_GLOBAL,
4179 .ptr = &Globals.szUsersharePrefixDenyList,
4182 .flags = FLAG_ADVANCED,
4185 .label = "usershare template share",
4187 .p_class = P_GLOBAL,
4188 .ptr = &Globals.szUsershareTemplateShare,
4191 .flags = FLAG_ADVANCED,
4197 .ptr = &sDefault.volume,
4200 .flags = FLAG_ADVANCED | FLAG_SHARE,
4206 .ptr = &sDefault.fstype,
4209 .flags = FLAG_ADVANCED | FLAG_SHARE,
4212 .label = "set directory",
4215 .ptr = &sDefault.bNo_set_dir,
4218 .flags = FLAG_ADVANCED | FLAG_SHARE,
4221 .label = "wide links",
4224 .ptr = &sDefault.bWidelinks,
4227 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4230 .label = "follow symlinks",
4233 .ptr = &sDefault.bSymlinks,
4236 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4239 .label = "dont descend",
4242 .ptr = &sDefault.szDontdescend,
4245 .flags = FLAG_ADVANCED | FLAG_SHARE,
4248 .label = "magic script",
4251 .ptr = &sDefault.szMagicScript,
4254 .flags = FLAG_ADVANCED | FLAG_SHARE,
4257 .label = "magic output",
4260 .ptr = &sDefault.szMagicOutput,
4263 .flags = FLAG_ADVANCED | FLAG_SHARE,
4266 .label = "delete readonly",
4269 .ptr = &sDefault.bDeleteReadonly,
4272 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4275 .label = "dos filemode",
4278 .ptr = &sDefault.bDosFilemode,
4281 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4284 .label = "dos filetimes",
4287 .ptr = &sDefault.bDosFiletimes,
4290 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4293 .label = "dos filetime resolution",
4296 .ptr = &sDefault.bDosFiletimeResolution,
4299 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4302 .label = "fake directory create times",
4304 .p_class = P_GLOBAL,
4305 .ptr = &Globals.bFakeDirCreateTimes,
4308 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4311 .label = "panic action",
4313 .p_class = P_GLOBAL,
4314 .ptr = &Globals.szPanicAction,
4317 .flags = FLAG_ADVANCED,
4320 .label = "perfcount module",
4322 .p_class = P_GLOBAL,
4323 .ptr = &Globals.szSMBPerfcountModule,
4326 .flags = FLAG_ADVANCED,
4329 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4332 .label = "vfs objects",
4335 .ptr = &sDefault.szVfsObjects,
4338 .flags = FLAG_ADVANCED | FLAG_SHARE,
4341 .label = "vfs object",
4344 .ptr = &sDefault.szVfsObjects,
4351 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4354 .label = "msdfs root",
4357 .ptr = &sDefault.bMSDfsRoot,
4360 .flags = FLAG_ADVANCED | FLAG_SHARE,
4363 .label = "msdfs proxy",
4366 .ptr = &sDefault.szMSDfsProxy,
4369 .flags = FLAG_ADVANCED | FLAG_SHARE,
4372 .label = "host msdfs",
4374 .p_class = P_GLOBAL,
4375 .ptr = &Globals.bHostMSDfs,
4378 .flags = FLAG_ADVANCED,
4381 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4384 .label = "passdb expand explicit",
4386 .p_class = P_GLOBAL,
4387 .ptr = &Globals.bPassdbExpandExplicit,
4390 .flags = FLAG_ADVANCED,
4393 .label = "idmap backend",
4395 .p_class = P_GLOBAL,
4396 .ptr = &Globals.szIdmapBackend,
4399 .flags = FLAG_ADVANCED,
4402 .label = "idmap alloc backend",
4404 .p_class = P_GLOBAL,
4405 .ptr = &Globals.szIdmapAllocBackend,
4408 .flags = FLAG_ADVANCED,
4411 .label = "idmap cache time",
4413 .p_class = P_GLOBAL,
4414 .ptr = &Globals.iIdmapCacheTime,
4417 .flags = FLAG_ADVANCED,
4420 .label = "idmap negative cache time",
4422 .p_class = P_GLOBAL,
4423 .ptr = &Globals.iIdmapNegativeCacheTime,
4426 .flags = FLAG_ADVANCED,
4429 .label = "idmap uid",
4431 .p_class = P_GLOBAL,
4432 .ptr = &Globals.szIdmapUID,
4433 .special = handle_idmap_uid,
4435 .flags = FLAG_ADVANCED,
4438 .label = "winbind uid",
4440 .p_class = P_GLOBAL,
4441 .ptr = &Globals.szIdmapUID,
4442 .special = handle_idmap_uid,
4447 .label = "idmap gid",
4449 .p_class = P_GLOBAL,
4450 .ptr = &Globals.szIdmapGID,
4451 .special = handle_idmap_gid,
4453 .flags = FLAG_ADVANCED,
4456 .label = "winbind gid",
4458 .p_class = P_GLOBAL,
4459 .ptr = &Globals.szIdmapGID,
4460 .special = handle_idmap_gid,
4465 .label = "template homedir",
4467 .p_class = P_GLOBAL,
4468 .ptr = &Globals.szTemplateHomedir,
4471 .flags = FLAG_ADVANCED,
4474 .label = "template shell",
4476 .p_class = P_GLOBAL,
4477 .ptr = &Globals.szTemplateShell,
4480 .flags = FLAG_ADVANCED,
4483 .label = "winbind separator",
4485 .p_class = P_GLOBAL,
4486 .ptr = &Globals.szWinbindSeparator,
4489 .flags = FLAG_ADVANCED,
4492 .label = "winbind cache time",
4494 .p_class = P_GLOBAL,
4495 .ptr = &Globals.winbind_cache_time,
4498 .flags = FLAG_ADVANCED,
4501 .label = "winbind reconnect delay",
4503 .p_class = P_GLOBAL,
4504 .ptr = &Globals.winbind_reconnect_delay,
4507 .flags = FLAG_ADVANCED,
4510 .label = "winbind enum users",
4512 .p_class = P_GLOBAL,
4513 .ptr = &Globals.bWinbindEnumUsers,
4516 .flags = FLAG_ADVANCED,
4519 .label = "winbind enum groups",
4521 .p_class = P_GLOBAL,
4522 .ptr = &Globals.bWinbindEnumGroups,
4525 .flags = FLAG_ADVANCED,
4528 .label = "winbind use default domain",
4530 .p_class = P_GLOBAL,
4531 .ptr = &Globals.bWinbindUseDefaultDomain,
4534 .flags = FLAG_ADVANCED,
4537 .label = "winbind trusted domains only",
4539 .p_class = P_GLOBAL,
4540 .ptr = &Globals.bWinbindTrustedDomainsOnly,
4543 .flags = FLAG_ADVANCED,
4546 .label = "winbind nested groups",
4548 .p_class = P_GLOBAL,
4549 .ptr = &Globals.bWinbindNestedGroups,
4552 .flags = FLAG_ADVANCED,
4555 .label = "winbind expand groups",
4557 .p_class = P_GLOBAL,
4558 .ptr = &Globals.winbind_expand_groups,
4561 .flags = FLAG_ADVANCED,
4564 .label = "winbind nss info",
4566 .p_class = P_GLOBAL,
4567 .ptr = &Globals.szWinbindNssInfo,
4570 .flags = FLAG_ADVANCED,
4573 .label = "winbind refresh tickets",
4575 .p_class = P_GLOBAL,
4576 .ptr = &Globals.bWinbindRefreshTickets,
4579 .flags = FLAG_ADVANCED,
4582 .label = "winbind offline logon",
4584 .p_class = P_GLOBAL,
4585 .ptr = &Globals.bWinbindOfflineLogon,
4588 .flags = FLAG_ADVANCED,
4591 .label = "winbind normalize names",
4593 .p_class = P_GLOBAL,
4594 .ptr = &Globals.bWinbindNormalizeNames,
4597 .flags = FLAG_ADVANCED,
4600 .label = "winbind rpc only",
4602 .p_class = P_GLOBAL,
4603 .ptr = &Globals.bWinbindRpcOnly,
4606 .flags = FLAG_ADVANCED,
4609 .label = "create krb5 conf",
4611 .p_class = P_GLOBAL,
4612 .ptr = &Globals.bCreateKrb5Conf,
4615 .flags = FLAG_ADVANCED,
4618 {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
4621 /***************************************************************************
4622 Initialise the sDefault parameter structure for the printer values.
4623 ***************************************************************************/
4625 static void init_printer_values(struct service *pService)
4627 /* choose defaults depending on the type of printing */
4628 switch (pService->iPrinting) {
4633 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4634 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4635 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4640 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4641 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4642 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4643 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4644 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4645 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4646 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4652 /* set the lpq command to contain the destination printer
4653 name only. This is used by cups_queue_get() */
4654 string_set(&pService->szLpqcommand, "%p");
4655 string_set(&pService->szLprmcommand, "");
4656 string_set(&pService->szPrintcommand, "");
4657 string_set(&pService->szLppausecommand, "");
4658 string_set(&pService->szLpresumecommand, "");
4659 string_set(&pService->szQueuepausecommand, "");
4660 string_set(&pService->szQueueresumecommand, "");
4662 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4663 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4664 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4665 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4666 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4667 string_set(&pService->szQueuepausecommand, "disable '%p'");
4668 string_set(&pService->szQueueresumecommand, "enable '%p'");
4669 #endif /* HAVE_CUPS */
4674 string_set(&pService->szLpqcommand, "lpstat -o%p");
4675 string_set(&pService->szLprmcommand, "cancel %p-%j");
4676 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4677 string_set(&pService->szQueuepausecommand, "disable %p");
4678 string_set(&pService->szQueueresumecommand, "enable %p");
4680 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4681 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4686 string_set(&pService->szLpqcommand, "lpq -P%p");
4687 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4688 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4694 string_set(&pService->szPrintcommand, "vlp print %p %s");
4695 string_set(&pService->szLpqcommand, "vlp lpq %p");
4696 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
4697 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
4698 string_set(&pService->szLpresumecommand, "vlp lpresume %p %j");
4699 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
4700 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
4702 #endif /* DEVELOPER */
4707 * Function to return the default value for the maximum number of open
4708 * file descriptors permitted. This function tries to consult the
4709 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4710 * the smaller of those.
4712 static int max_open_files(void)
4714 int sysctl_max = MAX_OPEN_FILES;
4715 int rlimit_max = MAX_OPEN_FILES;
4717 #ifdef HAVE_SYSCTLBYNAME
4719 size_t size = sizeof(sysctl_max);
4720 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4725 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4731 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4732 rlimit_max = rl.rlim_cur;
4734 #if defined(RLIM_INFINITY)
4735 if(rl.rlim_cur == RLIM_INFINITY)
4736 rlimit_max = MAX_OPEN_FILES;
4741 return MIN(sysctl_max, rlimit_max);
4745 * Common part of freeing allocated data for one parameter.
4747 static void free_one_parameter_common(void *parm_ptr,
4748 struct parm_struct parm)
4750 if ((parm.type == P_STRING) ||
4751 (parm.type == P_USTRING))
4753 string_free((char**)parm_ptr);
4754 } else if (parm.type == P_LIST) {
4755 TALLOC_FREE(*((char***)parm_ptr));
4760 * Free the allocated data for one parameter for a share
4761 * given as a service struct.
4763 static void free_one_parameter(struct service *service,
4764 struct parm_struct parm)
4768 if (parm.p_class != P_LOCAL) {
4772 parm_ptr = lp_local_ptr(service, parm.ptr);
4774 free_one_parameter_common(parm_ptr, parm);
4778 * Free the allocated parameter data of a share given
4779 * as a service struct.
4781 static void free_parameters(struct service *service)
4785 for (i=0; parm_table[i].label; i++) {
4786 free_one_parameter(service, parm_table[i]);
4791 * Free the allocated data for one parameter for a given share
4792 * specified by an snum.
4794 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4798 if (parm.ptr == NULL) {
4803 parm_ptr = parm.ptr;
4804 } else if (parm.p_class != P_LOCAL) {
4807 parm_ptr = lp_local_ptr_by_snum(snum, parm.ptr);
4810 free_one_parameter_common(parm_ptr, parm);
4814 * Free the allocated parameter data for a share specified
4817 static void free_parameters_by_snum(int snum)
4821 for (i=0; parm_table[i].label; i++) {
4822 free_one_parameter_by_snum(snum, parm_table[i]);
4827 * Free the allocated global parameters.
4829 static void free_global_parameters(void)
4831 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4834 /***************************************************************************
4835 Initialise the global parameter structure.
4836 ***************************************************************************/
4838 static void init_globals(bool first_time_only)
4840 static bool done_init = False;
4844 /* If requested to initialize only once and we've already done it... */
4845 if (first_time_only && done_init) {
4846 /* ... then we have nothing more to do */
4851 /* The logfile can be set before this is invoked. Free it if so. */
4852 if (Globals.szLogFile != NULL) {
4853 string_free(&Globals.szLogFile);
4854 Globals.szLogFile = NULL;
4858 free_global_parameters();
4861 memset((void *)&Globals, '\0', sizeof(Globals));
4863 for (i = 0; parm_table[i].label; i++) {
4864 if ((parm_table[i].type == P_STRING ||
4865 parm_table[i].type == P_USTRING) &&
4868 string_set((char **)parm_table[i].ptr, "");
4872 string_set(&sDefault.fstype, FSTYPE_STRING);
4873 string_set(&sDefault.szPrintjobUsername, "%U");
4875 init_printer_values(&sDefault);
4878 DEBUG(3, ("Initialising global parameters\n"));
4880 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4881 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4883 /* use the new 'hash2' method by default, with a prefix of 1 */
4884 string_set(&Globals.szManglingMethod, "hash2");
4885 Globals.mangle_prefix = 1;
4887 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4889 /* using UTF8 by default allows us to support all chars */
4890 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4892 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
4893 /* If the system supports nl_langinfo(), try to grab the value
4894 from the user's locale */
4895 string_set(&Globals.display_charset, "LOCALE");
4897 string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
4900 /* Use codepage 850 as a default for the dos character set */
4901 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4904 * Allow the default PASSWD_CHAT to be overridden in local.h.
4906 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4908 set_global_myname(myhostname());
4909 string_set(&Globals.szNetbiosName,global_myname());
4911 set_global_myworkgroup(WORKGROUP);
4912 string_set(&Globals.szWorkgroup, lp_workgroup());
4914 string_set(&Globals.szPasswdProgram, "");
4915 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4916 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4917 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4918 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4919 string_set(&Globals.szSocketAddress, "0.0.0.0");
4921 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4922 smb_panic("init_globals: ENOMEM");
4924 string_set(&Globals.szServerString, s);
4926 if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
4927 DEFAULT_MINOR_VERSION) < 0) {
4928 smb_panic("init_globals: ENOMEM");
4930 string_set(&Globals.szAnnounceVersion, s);
4933 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4936 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
4938 string_set(&Globals.szLogonDrive, "");
4939 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4940 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4941 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4943 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
4944 string_set(&Globals.szPasswordServer, "*");
4946 Globals.AlgorithmicRidBase = BASE_RID;
4948 Globals.bLoadPrinters = True;
4949 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4951 Globals.ConfigBackend = config_backend;
4953 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4954 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4955 Globals.max_xmit = 0x4104;
4956 Globals.max_mux = 50; /* This is *needed* for profile support. */
4957 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4958 Globals.bDisableSpoolss = False;
4959 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4960 Globals.pwordlevel = 0;
4961 Globals.unamelevel = 0;
4962 Globals.deadtime = 0;
4963 Globals.getwd_cache = true;
4964 Globals.bLargeReadwrite = True;
4965 Globals.max_log_size = 5000;
4966 Globals.max_open_files = max_open_files();
4967 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4968 Globals.maxprotocol = PROTOCOL_NT1;
4969 Globals.minprotocol = PROTOCOL_CORE;
4970 Globals.security = SEC_USER;
4971 Globals.paranoid_server_security = True;
4972 Globals.bEncryptPasswords = True;
4973 Globals.bUpdateEncrypt = False;
4974 Globals.clientSchannel = Auto;
4975 Globals.serverSchannel = Auto;
4976 Globals.bReadRaw = True;
4977 Globals.bWriteRaw = True;
4978 Globals.bNullPasswords = False;
4979 Globals.bObeyPamRestrictions = False;
4981 Globals.bSyslogOnly = False;
4982 Globals.bTimestampLogs = True;
4983 string_set(&Globals.szLogLevel, "0");
4984 Globals.bDebugPrefixTimestamp = False;
4985 Globals.bDebugHiresTimestamp = true;
4986 Globals.bDebugPid = False;
4987 Globals.bDebugUid = False;
4988 Globals.bDebugClass = False;
4989 Globals.bEnableCoreFiles = True;
4990 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4991 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4992 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4993 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4994 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
4995 Globals.lm_interval = 60;
4996 Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
4997 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4998 Globals.bNISHomeMap = False;
4999 #ifdef WITH_NISPLUS_HOME
5000 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
5002 string_set(&Globals.szNISHomeMapName, "auto.home");
5005 Globals.bTimeServer = False;
5006 Globals.bBindInterfacesOnly = False;
5007 Globals.bUnixPasswdSync = False;
5008 Globals.bPamPasswordChange = False;
5009 Globals.bPasswdChatDebug = False;
5010 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
5011 Globals.bNTPipeSupport = True; /* Do NT pipes by default. */
5012 Globals.bNTStatusSupport = True; /* Use NT status by default. */
5013 Globals.bStatCache = True; /* use stat cache by default */
5014 Globals.iMaxStatCacheSize = 256; /* 256k by default */
5015 Globals.restrict_anonymous = 0;
5016 Globals.bClientLanManAuth = False; /* Do NOT use the LanMan hash if it is available */
5017 Globals.bClientPlaintextAuth = False; /* Do NOT use a plaintext password even if is requested by the server */
5018 Globals.bLanmanAuth = False; /* Do NOT use the LanMan hash, even if it is supplied */
5019 Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
5020 Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
5021 /* Note, that we will use NTLM2 session security (which is different), if it is available */
5023 Globals.map_to_guest = 0; /* By Default, "Never" */
5024 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
5025 Globals.enhanced_browsing = true;
5026 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
5027 #ifdef MMAP_BLACKLIST
5028 Globals.bUseMmap = False;
5030 Globals.bUseMmap = True;
5032 Globals.bUnixExtensions = True;
5033 Globals.bResetOnZeroVC = False;
5034 Globals.bCreateKrb5Conf = true;
5036 /* hostname lookups can be very expensive and are broken on
5037 a large number of sites (tridge) */
5038 Globals.bHostnameLookups = False;
5040 string_set(&Globals.szPassdbBackend, "tdbsam");
5041 string_set(&Globals.szLdapSuffix, "");
5042 string_set(&Globals.szLdapMachineSuffix, "");
5043 string_set(&Globals.szLdapUserSuffix, "");
5044 string_set(&Globals.szLdapGroupSuffix, "");
5045 string_set(&Globals.szLdapIdmapSuffix, "");
5047 string_set(&Globals.szLdapAdminDn, "");
5048 Globals.ldap_ssl = LDAP_SSL_START_TLS;
5049 Globals.ldap_ssl_ads = False;
5050 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
5051 Globals.ldap_delete_dn = False;
5052 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
5053 Globals.ldap_follow_referral = Auto;
5054 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
5055 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
5056 Globals.ldap_page_size = LDAP_PAGE_SIZE;
5058 Globals.ldap_debug_level = 0;
5059 Globals.ldap_debug_threshold = 10;
5061 /* This is what we tell the afs client. in reality we set the token
5062 * to never expire, though, when this runs out the afs client will
5063 * forget the token. Set to 0 to get NEVERDATE.*/
5064 Globals.iAfsTokenLifetime = 604800;
5065 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
5067 /* these parameters are set to defaults that are more appropriate
5068 for the increasing samba install base:
5070 as a member of the workgroup, that will possibly become a
5071 _local_ master browser (lm = True). this is opposed to a forced
5072 local master browser startup (pm = True).
5074 doesn't provide WINS server service by default (wsupp = False),
5075 and doesn't provide domain master browser services by default, either.
5079 Globals.bMsAddPrinterWizard = True;
5080 Globals.os_level = 20;
5081 Globals.bLocalMaster = True;
5082 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
5083 Globals.bDomainLogons = False;
5084 Globals.bBrowseList = True;
5085 Globals.bWINSsupport = False;
5086 Globals.bWINSproxy = False;
5088 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
5089 Globals.InitLogonDelay = 100; /* 100 ms default delay */
5091 Globals.bDNSproxy = True;
5093 /* this just means to use them if they exist */
5094 Globals.bKernelOplocks = True;
5096 Globals.bAllowTrustedDomains = True;
5097 string_set(&Globals.szIdmapBackend, "tdb");
5099 string_set(&Globals.szTemplateShell, "/bin/false");
5100 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
5101 string_set(&Globals.szWinbindSeparator, "\\");
5103 string_set(&Globals.szCupsServer, "");
5104 string_set(&Globals.szIPrintServer, "");
5106 string_set(&Globals.ctdbdSocket, "");
5107 Globals.szClusterAddresses = NULL;
5108 Globals.clustering = False;
5109 Globals.ctdb_timeout = 0;
5111 Globals.winbind_cache_time = 300; /* 5 minutes */
5112 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
5113 Globals.bWinbindEnumUsers = False;
5114 Globals.bWinbindEnumGroups = False;
5115 Globals.bWinbindUseDefaultDomain = False;
5116 Globals.bWinbindTrustedDomainsOnly = False;
5117 Globals.bWinbindNestedGroups = True;
5118 Globals.winbind_expand_groups = 1;
5119 Globals.szWinbindNssInfo = str_list_make_v3(talloc_autofree_context(), "template", NULL);
5120 Globals.bWinbindRefreshTickets = False;
5121 Globals.bWinbindOfflineLogon = False;
5123 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
5124 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
5126 Globals.bPassdbExpandExplicit = False;
5128 Globals.name_cache_timeout = 660; /* In seconds */
5130 Globals.bUseSpnego = True;
5131 Globals.bClientUseSpnego = True;
5133 Globals.client_signing = Auto;
5134 Globals.server_signing = False;
5136 Globals.bDeferSharingViolations = True;
5137 string_set(&Globals.smb_ports, SMB_PORTS);
5139 Globals.bEnablePrivileges = True;
5140 Globals.bHostMSDfs = True;
5141 Globals.bASUSupport = False;
5143 /* User defined shares. */
5144 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5145 smb_panic("init_globals: ENOMEM");
5147 string_set(&Globals.szUsersharePath, s);
5149 string_set(&Globals.szUsershareTemplateShare, "");
5150 Globals.iUsershareMaxShares = 0;
5151 /* By default disallow sharing of directories not owned by the sharer. */
5152 Globals.bUsershareOwnerOnly = True;
5153 /* By default disallow guest access to usershares. */
5154 Globals.bUsershareAllowGuests = False;
5156 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5158 /* By default no shares out of the registry */
5159 Globals.bRegistryShares = False;
5161 Globals.iminreceivefile = 0;
5163 Globals.bMapUntrustedToDomain = false;
5166 /*******************************************************************
5167 Convenience routine to grab string parameters into temporary memory
5168 and run standard_sub_basic on them. The buffers can be written to by
5169 callers without affecting the source string.
5170 ********************************************************************/
5172 static char *lp_string(const char *s)
5175 TALLOC_CTX *ctx = talloc_tos();
5177 /* The follow debug is useful for tracking down memory problems
5178 especially if you have an inner loop that is calling a lp_*()
5179 function that returns a string. Perhaps this debug should be
5180 present all the time? */
5183 DEBUG(10, ("lp_string(%s)\n", s));
5189 ret = talloc_sub_basic(ctx,
5190 get_current_username(),
5191 current_user_info.domain,
5193 if (trim_char(ret, '\"', '\"')) {
5194 if (strchr(ret,'\"') != NULL) {
5196 ret = talloc_sub_basic(ctx,
5197 get_current_username(),
5198 current_user_info.domain,
5206 In this section all the functions that are used to access the
5207 parameters from the rest of the program are defined
5210 #define FN_GLOBAL_STRING(fn_name,ptr) \
5211 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
5212 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5213 const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
5214 #define FN_GLOBAL_LIST(fn_name,ptr) \
5215 const char **fn_name(void) {return(*(const char ***)(ptr));}
5216 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5217 bool fn_name(void) {return(*(bool *)(ptr));}
5218 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5219 char fn_name(void) {return(*(char *)(ptr));}
5220 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5221 int fn_name(void) {return(*(int *)(ptr));}
5223 #define FN_LOCAL_STRING(fn_name,val) \
5224 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5225 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5226 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5227 #define FN_LOCAL_LIST(fn_name,val) \
5228 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5229 #define FN_LOCAL_BOOL(fn_name,val) \
5230 bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5231 #define FN_LOCAL_INTEGER(fn_name,val) \
5232 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5234 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5235 bool fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5236 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5237 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5238 #define FN_LOCAL_PARM_STRING(fn_name,val) \
5239 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));}
5240 #define FN_LOCAL_CHAR(fn_name,val) \
5241 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5243 FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
5244 FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
5245 FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
5246 FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
5247 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
5248 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
5249 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
5250 FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
5251 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
5252 FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
5253 FN_GLOBAL_STRING(lp_addport_cmd, &Globals.szAddPortCommand)
5254 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
5255 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
5256 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
5257 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
5258 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
5259 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5260 * build process or in smb.conf, we use that value. Otherwise they
5261 * default to the value of lp_lockdir(). */
5262 char *lp_statedir(void) {
5263 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5264 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5265 return(lp_string(*(char **)(&Globals.szStateDir) ?
5266 *(char **)(&Globals.szStateDir) : ""));
5268 return(lp_string(*(char **)(&Globals.szLockDir) ?
5269 *(char **)(&Globals.szLockDir) : ""));
5271 char *lp_cachedir(void) {
5272 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5273 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5274 return(lp_string(*(char **)(&Globals.szCacheDir) ?
5275 *(char **)(&Globals.szCacheDir) : ""));
5277 return(lp_string(*(char **)(&Globals.szLockDir) ?
5278 *(char **)(&Globals.szLockDir) : ""));
5280 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
5281 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
5282 FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
5283 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
5284 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
5285 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
5286 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
5287 FN_GLOBAL_STRING(lp_perfcount_module, &Globals.szSMBPerfcountModule)
5288 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
5289 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
5290 FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
5291 FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
5292 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
5293 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
5294 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
5295 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
5296 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
5297 FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
5298 FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
5299 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
5300 FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
5301 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
5302 FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
5303 FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
5304 FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
5305 FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
5306 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
5307 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
5308 FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
5309 FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
5310 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
5311 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
5312 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
5313 /* FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
5314 * lp_passdb_backend() should be replace by the this macro again after
5317 const char *lp_passdb_backend(void)
5319 char *delim, *quote;
5321 delim = strchr( Globals.szPassdbBackend, ' ');
5322 /* no space at all */
5323 if (delim == NULL) {
5327 quote = strchr(Globals.szPassdbBackend, '"');
5328 /* no quote char or non in the first part */
5329 if (quote == NULL || quote > delim) {
5334 quote = strchr(quote+1, '"');
5335 if (quote == NULL) {
5336 DEBUG(0, ("WARNING: Your 'passdb backend' configuration is invalid due to a missing second \" char.\n"));
5338 } else if (*(quote+1) == '\0') {
5339 /* space, fitting quote char, and one backend only */
5342 /* terminate string after the fitting quote char */
5347 DEBUG(0, ("WARNING: Your 'passdb backend' configuration includes multiple backends. This\n"
5348 "is deprecated since Samba 3.0.23. Please check WHATSNEW.txt or the section 'Passdb\n"
5349 "Changes' from the ChangeNotes as part of the Samba HOWTO collection. Only the first\n"
5350 "backend (%s) is used. The rest is ignored.\n", Globals.szPassdbBackend));
5353 return Globals.szPassdbBackend;
5355 FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
5356 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
5357 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
5358 FN_GLOBAL_STRING(lp_renameuser_script, &Globals.szRenameUserScript)
5359 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
5361 FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
5362 FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
5363 FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
5364 FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
5365 FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
5366 FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
5368 FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
5370 FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
5371 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
5372 FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
5374 FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
5376 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
5377 FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
5378 FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
5379 FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
5380 FN_GLOBAL_INTEGER(lp_acl_compatibility, &Globals.iAclCompat)
5381 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
5382 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
5383 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
5384 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
5385 FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
5386 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups)
5387 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets)
5388 FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon)
5389 FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames)
5390 FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
5391 FN_GLOBAL_BOOL(lp_create_krb5_conf, &Globals.bCreateKrb5Conf)
5393 FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
5394 FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)
5395 FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
5396 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
5397 FN_GLOBAL_INTEGER(lp_keepalive, &Globals.iKeepalive)
5398 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit)
5400 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
5401 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
5402 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
5403 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, &Globals.ldap_ssl_ads)
5404 FN_GLOBAL_INTEGER(lp_ldap_follow_referral, &Globals.ldap_follow_referral)
5405 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
5406 FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
5407 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
5408 FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
5409 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, &Globals.ldap_connection_timeout)
5410 FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
5411 FN_GLOBAL_INTEGER(lp_ldap_debug_level, &Globals.ldap_debug_level)
5412 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, &Globals.ldap_debug_threshold)
5413 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
5414 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
5415 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
5416 FN_GLOBAL_STRING(lp_usershare_path, &Globals.szUsersharePath)
5417 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, &Globals.szUsersharePrefixAllowList)
5418 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, &Globals.szUsersharePrefixDenyList)
5420 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
5422 FN_GLOBAL_BOOL(lp_registry_shares, &Globals.bRegistryShares)
5423 FN_GLOBAL_BOOL(lp_usershare_allow_guests, &Globals.bUsershareAllowGuests)
5424 FN_GLOBAL_BOOL(lp_usershare_owner_only, &Globals.bUsershareOwnerOnly)
5425 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
5426 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
5427 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
5428 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
5429 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
5430 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
5431 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
5432 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
5433 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
5434 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, &Globals.szInitLogonDelayedHosts)
5435 FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
5436 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
5437 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
5438 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
5439 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
5440 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
5441 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
5442 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
5443 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
5444 FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
5445 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
5446 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
5447 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
5448 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
5449 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
5450 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
5451 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
5452 FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
5453 FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
5454 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
5455 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
5456 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
5457 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
5458 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
5459 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
5460 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
5461 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
5462 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
5463 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
5464 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
5465 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
5466 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
5467 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, &Globals.bMapUntrustedToDomain)
5468 FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
5469 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
5470 FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
5471 FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
5472 FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
5473 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
5474 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
5475 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
5476 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
5477 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
5478 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
5479 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
5480 FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
5481 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
5482 FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
5483 FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
5484 FN_GLOBAL_STRING(lp_dedicated_keytab_file, &Globals.szDedicatedKeytabFile)
5485 FN_GLOBAL_INTEGER(lp_kerberos_method, &Globals.iKerberosMethod)
5486 FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
5487 FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
5488 FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport)
5489 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
5490 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
5491 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
5492 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
5493 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
5494 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
5495 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, &Globals.open_files_db_hash_size)
5496 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
5497 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
5498 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
5499 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
5500 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
5501 FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
5502 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
5503 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
5504 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
5505 FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
5506 FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
5507 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
5508 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
5509 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
5510 FN_GLOBAL_BOOL(_lp_disable_spoolss, &Globals.bDisableSpoolss)
5511 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
5512 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
5513 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
5514 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
5515 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
5516 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
5517 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
5518 FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
5519 FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
5520 FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
5521 FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
5523 FN_LOCAL_STRING(lp_preexec, szPreExec)
5524 FN_LOCAL_STRING(lp_postexec, szPostExec)
5525 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
5526 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
5527 FN_LOCAL_STRING(lp_servicename, szService)
5528 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
5529 FN_LOCAL_STRING(lp_pathname, szPath)
5530 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
5531 FN_LOCAL_STRING(lp_username, szUsername)
5532 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
5533 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
5534 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
5535 FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
5536 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
5537 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
5538 int lp_cups_encrypt(void)
5540 #ifdef HAVE_HTTPCONNECTENCRYPT
5541 switch (Globals.CupsEncrypt) {
5543 Globals.CupsEncrypt = HTTP_ENCRYPT_REQUIRED;
5546 Globals.CupsEncrypt = HTTP_ENCRYPT_ALWAYS;
5549 Globals.CupsEncrypt = HTTP_ENCRYPT_NEVER;
5553 return Globals.CupsEncrypt;
5555 FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
5556 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
5557 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
5558 FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
5559 FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
5560 FN_GLOBAL_INTEGER(lp_ctdb_timeout, &Globals.ctdb_timeout)
5561 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
5562 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
5563 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
5564 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
5565 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
5566 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
5567 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
5568 static FN_LOCAL_STRING(_lp_printername, szPrintername)
5569 FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
5570 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
5571 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
5572 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
5573 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
5574 FN_LOCAL_STRING(lp_comment, comment)
5575 FN_LOCAL_STRING(lp_force_user, force_user)
5576 FN_LOCAL_STRING(lp_force_group, force_group)
5577 FN_LOCAL_LIST(lp_readlist, readlist)
5578 FN_LOCAL_LIST(lp_writelist, writelist)
5579 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
5580 FN_LOCAL_STRING(lp_fstype, fstype)
5581 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
5582 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
5583 static FN_LOCAL_STRING(lp_volume, volume)
5584 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
5585 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
5586 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
5587 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
5588 FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
5589 FN_LOCAL_STRING(lp_dfree_command, szDfree)
5590 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
5591 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
5592 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
5593 FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
5594 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
5595 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
5596 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
5597 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
5598 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
5599 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
5600 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
5601 FN_LOCAL_BOOL(lp_access_based_share_enum, bAccessBasedShareEnum)
5602 FN_LOCAL_BOOL(lp_readonly, bRead_only)
5603 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
5604 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
5605 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
5606 FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
5607 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
5608 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
5609 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
5610 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
5611 FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
5612 FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
5613 FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
5614 FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
5615 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
5616 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
5617 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
5618 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
5619 FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames)
5620 FN_LOCAL_BOOL(lp_widelinks, bWidelinks)
5621 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
5622 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
5623 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
5624 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
5625 FN_LOCAL_BOOL(lp_map_system, bMap_system)
5626 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
5627 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
5628 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
5629 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
5630 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
5631 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
5632 FN_GLOBAL_BOOL(lp_fake_dir_create_times, &Globals.bFakeDirCreateTimes)
5633 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
5634 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
5635 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
5636 FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
5637 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
5638 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
5639 FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
5640 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
5641 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
5642 FN_LOCAL_BOOL(lp_ea_support, bEASupport)
5643 FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
5644 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
5645 FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
5646 FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
5647 FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
5648 FN_LOCAL_BOOL(lp_acl_group_control, bAclGroupControl)
5649 FN_LOCAL_BOOL(lp_acl_map_full_control, bAclMapFullControl)
5650 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
5651 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
5652 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
5653 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
5654 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
5655 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
5656 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
5657 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
5658 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
5659 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
5660 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
5661 FN_LOCAL_INTEGER(lp_printing, iPrinting)
5662 FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
5663 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
5664 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
5665 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
5666 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
5667 FN_LOCAL_INTEGER(lp_dfree_cache_time, iDfreeCacheTime)
5668 FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
5669 FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
5670 FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
5671 FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
5672 FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
5673 FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
5674 FN_LOCAL_CHAR(lp_magicchar, magic_char)
5675 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
5676 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
5677 FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
5678 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
5679 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
5680 FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
5681 FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
5682 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
5684 /* local prototypes */
5686 static int map_parameter(const char *pszParmName);
5687 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5688 static const char *get_boolean(bool bool_value);
5689 static int getservicebyname(const char *pszServiceName,
5690 struct service *pserviceDest);
5691 static void copy_service(struct service *pserviceDest,
5692 struct service *pserviceSource,
5693 struct bitmap *pcopymapDest);
5694 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5696 static bool do_section(const char *pszSectionName, void *userdata);
5697 static void init_copymap(struct service *pservice);
5698 static bool hash_a_service(const char *name, int number);
5699 static void free_service_byindex(int iService);
5700 static void free_param_opts(struct param_opt_struct **popts);
5701 static char * canonicalize_servicename(const char *name);
5702 static void show_parameter(int parmIndex);
5703 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5706 * This is a helper function for parametrical options support. It returns a
5707 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5708 * parametrical functions are quite simple
5710 static struct param_opt_struct *get_parametrics(int snum, const char *type,
5713 bool global_section = False;
5715 struct param_opt_struct *data;
5717 if (snum >= iNumServices) return NULL;
5720 data = Globals.param_opt;
5721 global_section = True;
5723 data = ServicePtrs[snum]->param_opt;
5726 if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
5727 DEBUG(0,("asprintf failed!\n"));
5732 if (strwicmp(data->key, param_key) == 0) {
5733 string_free(¶m_key);
5739 if (!global_section) {
5740 /* Try to fetch the same option but from globals */
5741 /* but only if we are not already working with Globals */
5742 data = Globals.param_opt;
5744 if (strwicmp(data->key, param_key) == 0) {
5745 string_free(¶m_key);
5752 string_free(¶m_key);
5758 #define MISSING_PARAMETER(name) \
5759 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5761 /*******************************************************************
5762 convenience routine to return int parameters.
5763 ********************************************************************/
5764 static int lp_int(const char *s)
5768 MISSING_PARAMETER(lp_int);
5772 return (int)strtol(s, NULL, 0);
5775 /*******************************************************************
5776 convenience routine to return unsigned long parameters.
5777 ********************************************************************/
5778 static unsigned long lp_ulong(const char *s)
5782 MISSING_PARAMETER(lp_ulong);
5786 return strtoul(s, NULL, 0);
5789 /*******************************************************************
5790 convenience routine to return boolean parameters.
5791 ********************************************************************/
5792 static bool lp_bool(const char *s)
5797 MISSING_PARAMETER(lp_bool);
5801 if (!set_boolean(s, &ret)) {
5802 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5809 /*******************************************************************
5810 convenience routine to return enum parameters.
5811 ********************************************************************/
5812 static int lp_enum(const char *s,const struct enum_list *_enum)
5816 if (!s || !*s || !_enum) {
5817 MISSING_PARAMETER(lp_enum);
5821 for (i=0; _enum[i].name; i++) {
5822 if (strequal(_enum[i].name,s))
5823 return _enum[i].value;
5826 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5830 #undef MISSING_PARAMETER
5832 /* DO NOT USE lp_parm_string ANYMORE!!!!
5833 * use lp_parm_const_string or lp_parm_talloc_string
5835 * lp_parm_string is only used to let old modules find this symbol
5837 #undef lp_parm_string
5838 char *lp_parm_string(const char *servicename, const char *type, const char *option);
5839 char *lp_parm_string(const char *servicename, const char *type, const char *option)
5841 return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
5844 /* Return parametric option from a given service. Type is a part of option before ':' */
5845 /* Parametric option has following syntax: 'Type: option = value' */
5846 /* the returned value is talloced on the talloc_tos() */
5847 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5849 struct param_opt_struct *data = get_parametrics(snum, type, option);
5851 if (data == NULL||data->value==NULL) {
5853 return lp_string(def);
5859 return lp_string(data->value);
5862 /* Return parametric option from a given service. Type is a part of option before ':' */
5863 /* Parametric option has following syntax: 'Type: option = value' */
5864 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5866 struct param_opt_struct *data = get_parametrics(snum, type, option);
5868 if (data == NULL||data->value==NULL)
5874 /* Return parametric option from a given service. Type is a part of option before ':' */
5875 /* Parametric option has following syntax: 'Type: option = value' */
5877 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5879 struct param_opt_struct *data = get_parametrics(snum, type, option);
5881 if (data == NULL||data->value==NULL)
5882 return (const char **)def;
5884 if (data->list==NULL) {
5885 data->list = str_list_make_v3(talloc_autofree_context(), data->value, NULL);
5888 return (const char **)data->list;
5891 /* Return parametric option from a given service. Type is a part of option before ':' */
5892 /* Parametric option has following syntax: 'Type: option = value' */
5894 int lp_parm_int(int snum, const char *type, const char *option, int def)
5896 struct param_opt_struct *data = get_parametrics(snum, type, option);
5898 if (data && data->value && *data->value)
5899 return lp_int(data->value);
5904 /* Return parametric option from a given service. Type is a part of option before ':' */
5905 /* Parametric option has following syntax: 'Type: option = value' */
5907 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5909 struct param_opt_struct *data = get_parametrics(snum, type, option);
5911 if (data && data->value && *data->value)
5912 return lp_ulong(data->value);
5917 /* Return parametric option from a given service. Type is a part of option before ':' */
5918 /* Parametric option has following syntax: 'Type: option = value' */
5920 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5922 struct param_opt_struct *data = get_parametrics(snum, type, option);
5924 if (data && data->value && *data->value)
5925 return lp_bool(data->value);
5930 /* Return parametric option from a given service. Type is a part of option before ':' */
5931 /* Parametric option has following syntax: 'Type: option = value' */
5933 int lp_parm_enum(int snum, const char *type, const char *option,
5934 const struct enum_list *_enum, int def)
5936 struct param_opt_struct *data = get_parametrics(snum, type, option);
5938 if (data && data->value && *data->value && _enum)
5939 return lp_enum(data->value, _enum);
5945 /***************************************************************************
5946 Initialise a service to the defaults.
5947 ***************************************************************************/
5949 static void init_service(struct service *pservice)
5951 memset((char *)pservice, '\0', sizeof(struct service));
5952 copy_service(pservice, &sDefault, NULL);
5957 * free a param_opts structure.
5958 * param_opts handling should be moved to talloc;
5959 * then this whole functions reduces to a TALLOC_FREE().
5962 static void free_param_opts(struct param_opt_struct **popts)
5964 struct param_opt_struct *opt, *next_opt;
5966 if (popts == NULL) {
5970 if (*popts != NULL) {
5971 DEBUG(5, ("Freeing parametrics:\n"));
5974 while (opt != NULL) {
5975 string_free(&opt->key);
5976 string_free(&opt->value);
5977 TALLOC_FREE(opt->list);
5978 next_opt = opt->next;
5985 /***************************************************************************
5986 Free the dynamically allocated parts of a service struct.
5987 ***************************************************************************/
5989 static void free_service(struct service *pservice)
5994 if (pservice->szService)
5995 DEBUG(5, ("free_service: Freeing service %s\n",
5996 pservice->szService));
5998 free_parameters(pservice);
6000 string_free(&pservice->szService);
6001 bitmap_free(pservice->copymap);
6003 free_param_opts(&pservice->param_opt);
6005 ZERO_STRUCTP(pservice);
6009 /***************************************************************************
6010 remove a service indexed in the ServicePtrs array from the ServiceHash
6011 and free the dynamically allocated parts
6012 ***************************************************************************/
6014 static void free_service_byindex(int idx)
6016 if ( !LP_SNUM_OK(idx) )
6019 ServicePtrs[idx]->valid = False;
6020 invalid_services[num_invalid_services++] = idx;
6022 /* we have to cleanup the hash record */
6024 if (ServicePtrs[idx]->szService) {
6025 char *canon_name = canonicalize_servicename(
6026 ServicePtrs[idx]->szService );
6028 dbwrap_delete_bystring(ServiceHash, canon_name );
6029 TALLOC_FREE(canon_name);
6032 free_service(ServicePtrs[idx]);
6035 /***************************************************************************
6036 Add a new service to the services array initialising it with the given
6038 ***************************************************************************/
6040 static int add_a_service(const struct service *pservice, const char *name)
6043 struct service tservice;
6044 int num_to_alloc = iNumServices + 1;
6046 tservice = *pservice;
6048 /* it might already exist */
6050 i = getservicebyname(name, NULL);
6052 /* Clean all parametric options for service */
6053 /* They will be added during parsing again */
6054 free_param_opts(&ServicePtrs[i]->param_opt);
6059 /* find an invalid one */
6061 if (num_invalid_services > 0) {
6062 i = invalid_services[--num_invalid_services];
6065 /* if not, then create one */
6066 if (i == iNumServices) {
6067 struct service **tsp;
6070 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
6072 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
6076 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct service);
6077 if (!ServicePtrs[iNumServices]) {
6078 DEBUG(0,("add_a_service: out of memory!\n"));
6083 /* enlarge invalid_services here for now... */
6084 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
6086 if (tinvalid == NULL) {
6087 DEBUG(0,("add_a_service: failed to enlarge "
6088 "invalid_services!\n"));
6091 invalid_services = tinvalid;
6093 free_service_byindex(i);
6096 ServicePtrs[i]->valid = True;
6098 init_service(ServicePtrs[i]);
6099 copy_service(ServicePtrs[i], &tservice, NULL);
6101 string_set(&ServicePtrs[i]->szService, name);
6103 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
6104 i, ServicePtrs[i]->szService));
6106 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
6113 /***************************************************************************
6114 Convert a string to uppercase and remove whitespaces.
6115 ***************************************************************************/
6117 static char *canonicalize_servicename(const char *src)
6122 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
6126 result = talloc_strdup(talloc_tos(), src);
6127 SMB_ASSERT(result != NULL);
6133 /***************************************************************************
6134 Add a name/index pair for the services array to the hash table.
6135 ***************************************************************************/
6137 static bool hash_a_service(const char *name, int idx)
6141 if ( !ServiceHash ) {
6142 DEBUG(10,("hash_a_service: creating servicehash\n"));
6143 ServiceHash = db_open_rbt(NULL);
6144 if ( !ServiceHash ) {
6145 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
6150 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
6153 canon_name = canonicalize_servicename( name );
6155 dbwrap_store_bystring(ServiceHash, canon_name,
6156 make_tdb_data((uint8 *)&idx, sizeof(idx)),
6159 TALLOC_FREE(canon_name);
6164 /***************************************************************************
6165 Add a new home service, with the specified home directory, defaults coming
6167 ***************************************************************************/
6169 bool lp_add_home(const char *pszHomename, int iDefaultService,
6170 const char *user, const char *pszHomedir)
6174 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
6175 pszHomedir[0] == '\0') {
6179 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
6184 if (!(*(ServicePtrs[iDefaultService]->szPath))
6185 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
6186 string_set(&ServicePtrs[i]->szPath, pszHomedir);
6189 if (!(*(ServicePtrs[i]->comment))) {
6190 char *comment = NULL;
6191 if (asprintf(&comment, "Home directory of %s", user) < 0) {
6194 string_set(&ServicePtrs[i]->comment, comment);
6198 /* set the browseable flag from the global default */
6200 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6201 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
6203 ServicePtrs[i]->autoloaded = True;
6205 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
6206 user, ServicePtrs[i]->szPath ));
6211 /***************************************************************************
6212 Add a new service, based on an old one.
6213 ***************************************************************************/
6215 int lp_add_service(const char *pszService, int iDefaultService)
6217 if (iDefaultService < 0) {
6218 return add_a_service(&sDefault, pszService);
6221 return (add_a_service(ServicePtrs[iDefaultService], pszService));
6224 /***************************************************************************
6225 Add the IPC service.
6226 ***************************************************************************/
6228 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
6230 char *comment = NULL;
6231 int i = add_a_service(&sDefault, ipc_name);
6236 if (asprintf(&comment, "IPC Service (%s)",
6237 Globals.szServerString) < 0) {
6241 string_set(&ServicePtrs[i]->szPath, tmpdir());
6242 string_set(&ServicePtrs[i]->szUsername, "");
6243 string_set(&ServicePtrs[i]->comment, comment);
6244 string_set(&ServicePtrs[i]->fstype, "IPC");
6245 ServicePtrs[i]->iMaxConnections = 0;
6246 ServicePtrs[i]->bAvailable = True;
6247 ServicePtrs[i]->bRead_only = True;
6248 ServicePtrs[i]->bGuest_only = False;
6249 ServicePtrs[i]->bAdministrative_share = True;
6250 ServicePtrs[i]->bGuest_ok = guest_ok;
6251 ServicePtrs[i]->bPrint_ok = False;
6252 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6254 DEBUG(3, ("adding IPC service\n"));
6260 /***************************************************************************
6261 Add a new printer service, with defaults coming from service iFrom.
6262 ***************************************************************************/
6264 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
6266 const char *comment = "From Printcap";
6267 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6272 /* note that we do NOT default the availability flag to True - */
6273 /* we take it from the default service passed. This allows all */
6274 /* dynamic printers to be disabled by disabling the [printers] */
6275 /* entry (if/when the 'available' keyword is implemented!). */
6277 /* the printer name is set to the service name. */
6278 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6279 string_set(&ServicePtrs[i]->comment, comment);
6281 /* set the browseable flag from the gloabl default */
6282 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6284 /* Printers cannot be read_only. */
6285 ServicePtrs[i]->bRead_only = False;
6286 /* No share modes on printer services. */
6287 ServicePtrs[i]->bShareModes = False;
6288 /* No oplocks on printer services. */
6289 ServicePtrs[i]->bOpLocks = False;
6290 /* Printer services must be printable. */
6291 ServicePtrs[i]->bPrint_ok = True;
6293 DEBUG(3, ("adding printer service %s\n", pszPrintername));
6299 /***************************************************************************
6300 Check whether the given parameter name is valid.
6301 Parametric options (names containing a colon) are considered valid.
6302 ***************************************************************************/
6304 bool lp_parameter_is_valid(const char *pszParmName)
6306 return ((map_parameter(pszParmName) != -1) ||
6307 (strchr(pszParmName, ':') != NULL));
6310 /***************************************************************************
6311 Check whether the given name is the name of a global parameter.
6312 Returns True for strings belonging to parameters of class
6313 P_GLOBAL, False for all other strings, also for parametric options
6314 and strings not belonging to any option.
6315 ***************************************************************************/
6317 bool lp_parameter_is_global(const char *pszParmName)
6319 int num = map_parameter(pszParmName);
6322 return (parm_table[num].p_class == P_GLOBAL);
6328 /**************************************************************************
6329 Check whether the given name is the canonical name of a parameter.
6330 Returns False if it is not a valid parameter Name.
6331 For parametric options, True is returned.
6332 **************************************************************************/
6334 bool lp_parameter_is_canonical(const char *parm_name)
6336 if (!lp_parameter_is_valid(parm_name)) {
6340 return (map_parameter(parm_name) ==
6341 map_parameter_canonical(parm_name, NULL));
6344 /**************************************************************************
6345 Determine the canonical name for a parameter.
6346 Indicate when it is an inverse (boolean) synonym instead of a
6348 **************************************************************************/
6350 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6355 if (!lp_parameter_is_valid(parm_name)) {
6360 num = map_parameter_canonical(parm_name, inverse);
6362 /* parametric option */
6363 *canon_parm = parm_name;
6365 *canon_parm = parm_table[num].label;
6372 /**************************************************************************
6373 Determine the canonical name for a parameter.
6374 Turn the value given into the inverse boolean expression when
6375 the synonym is an invers boolean synonym.
6377 Return True if parm_name is a valid parameter name and
6378 in case it is an invers boolean synonym, if the val string could
6379 successfully be converted to the reverse bool.
6380 Return false in all other cases.
6381 **************************************************************************/
6383 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6385 const char **canon_parm,
6386 const char **canon_val)
6391 if (!lp_parameter_is_valid(parm_name)) {
6397 num = map_parameter_canonical(parm_name, &inverse);
6399 /* parametric option */
6400 *canon_parm = parm_name;
6403 *canon_parm = parm_table[num].label;
6405 if (!lp_invert_boolean(val, canon_val)) {
6417 /***************************************************************************
6418 Map a parameter's string representation to something we can use.
6419 Returns False if the parameter string is not recognised, else TRUE.
6420 ***************************************************************************/
6422 static int map_parameter(const char *pszParmName)
6426 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6429 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6430 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6433 /* Warn only if it isn't parametric option */
6434 if (strchr(pszParmName, ':') == NULL)
6435 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6436 /* We do return 'fail' for parametric options as well because they are
6437 stored in different storage
6442 /***************************************************************************
6443 Map a parameter's string representation to the index of the canonical
6444 form of the parameter (it might be a synonym).
6445 Returns -1 if the parameter string is not recognised.
6446 ***************************************************************************/
6448 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6450 int parm_num, canon_num;
6451 bool loc_inverse = False;
6453 parm_num = map_parameter(pszParmName);
6454 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6455 /* invalid, parametric or no canidate for synonyms ... */
6459 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6460 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6461 parm_num = canon_num;
6467 if (inverse != NULL) {
6468 *inverse = loc_inverse;
6473 /***************************************************************************
6474 return true if parameter number parm1 is a synonym of parameter
6475 number parm2 (parm2 being the principal name).
6476 set inverse to True if parm1 is P_BOOLREV and parm2 is P_BOOL,
6478 ***************************************************************************/
6480 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6482 if ((parm_table[parm1].ptr == parm_table[parm2].ptr) &&
6483 (parm_table[parm1].flags & FLAG_HIDE) &&
6484 !(parm_table[parm2].flags & FLAG_HIDE))
6486 if (inverse != NULL) {
6487 if ((parm_table[parm1].type == P_BOOLREV) &&
6488 (parm_table[parm2].type == P_BOOL))
6500 /***************************************************************************
6501 Show one parameter's name, type, [values,] and flags.
6502 (helper functions for show_parameter_list)
6503 ***************************************************************************/
6505 static void show_parameter(int parmIndex)
6507 int enumIndex, flagIndex;
6512 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6513 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6515 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6516 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6517 FLAG_HIDE, FLAG_DOS_STRING};
6518 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6519 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6520 "FLAG_DEPRECATED", "FLAG_HIDE", "FLAG_DOS_STRING", NULL};
6522 printf("%s=%s", parm_table[parmIndex].label,
6523 type[parm_table[parmIndex].type]);
6524 if (parm_table[parmIndex].type == P_ENUM) {
6527 parm_table[parmIndex].enum_list[enumIndex].name;
6531 enumIndex ? "|" : "",
6532 parm_table[parmIndex].enum_list[enumIndex].name);
6537 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6538 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6541 flag_names[flagIndex]);
6546 /* output synonyms */
6548 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6549 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6550 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6551 parm_table[parmIndex2].label);
6552 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6554 printf(" (synonyms: ");
6559 printf("%s%s", parm_table[parmIndex2].label,
6560 inverse ? "[i]" : "");
6570 /***************************************************************************
6571 Show all parameter's name, type, [values,] and flags.
6572 ***************************************************************************/
6574 void show_parameter_list(void)
6576 int classIndex, parmIndex;
6577 const char *section_names[] = { "local", "global", NULL};
6579 for (classIndex=0; section_names[classIndex]; classIndex++) {
6580 printf("[%s]\n", section_names[classIndex]);
6581 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6582 if (parm_table[parmIndex].p_class == classIndex) {
6583 show_parameter(parmIndex);
6589 /***************************************************************************
6590 Check if a given string correctly represents a boolean value.
6591 ***************************************************************************/
6593 bool lp_string_is_valid_boolean(const char *parm_value)
6595 return set_boolean(parm_value, NULL);
6598 /***************************************************************************
6599 Get the standard string representation of a boolean value ("yes" or "no")
6600 ***************************************************************************/
6602 static const char *get_boolean(bool bool_value)
6604 static const char *yes_str = "yes";
6605 static const char *no_str = "no";
6607 return (bool_value ? yes_str : no_str);
6610 /***************************************************************************
6611 Provide the string of the negated boolean value associated to the boolean
6612 given as a string. Returns False if the passed string does not correctly
6613 represent a boolean.
6614 ***************************************************************************/
6616 bool lp_invert_boolean(const char *str, const char **inverse_str)
6620 if (!set_boolean(str, &val)) {
6624 *inverse_str = get_boolean(!val);
6628 /***************************************************************************
6629 Provide the canonical string representation of a boolean value given
6630 as a string. Return True on success, False if the string given does
6631 not correctly represent a boolean.
6632 ***************************************************************************/
6634 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6638 if (!set_boolean(str, &val)) {
6642 *canon_str = get_boolean(val);
6646 /***************************************************************************
6647 Find a service by name. Otherwise works like get_service.
6648 ***************************************************************************/
6650 static int getservicebyname(const char *pszServiceName, struct service *pserviceDest)
6656 if (ServiceHash == NULL) {
6660 canon_name = canonicalize_servicename(pszServiceName);
6662 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
6664 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
6665 iService = *(int *)data.dptr;
6668 TALLOC_FREE(canon_name);
6670 if ((iService != -1) && (LP_SNUM_OK(iService))
6671 && (pserviceDest != NULL)) {
6672 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6678 /***************************************************************************
6679 Copy a service structure to another.
6680 If pcopymapDest is NULL then copy all fields
6681 ***************************************************************************/
6684 * Add a parametric option to a param_opt_struct,
6685 * replacing old value, if already present.
6687 static void set_param_opt(struct param_opt_struct **opt_list,
6688 const char *opt_name,
6689 const char *opt_value)
6691 struct param_opt_struct *new_opt, *opt;
6694 if (opt_list == NULL) {
6701 /* Traverse destination */
6703 /* If we already have same option, override it */
6704 if (strwicmp(opt->key, opt_name) == 0) {
6705 string_free(&opt->value);
6706 TALLOC_FREE(opt->list);
6707 opt->value = SMB_STRDUP(opt_value);
6714 new_opt = SMB_XMALLOC_P(struct param_opt_struct);
6715 new_opt->key = SMB_STRDUP(opt_name);
6716 new_opt->value = SMB_STRDUP(opt_value);
6717 new_opt->list = NULL;
6718 DLIST_ADD(*opt_list, new_opt);
6722 static void copy_service(struct service *pserviceDest, struct service *pserviceSource,
6723 struct bitmap *pcopymapDest)
6726 bool bcopyall = (pcopymapDest == NULL);
6727 struct param_opt_struct *data;
6729 for (i = 0; parm_table[i].label; i++)
6730 if (parm_table[i].ptr && parm_table[i].p_class == P_LOCAL &&
6731 (bcopyall || bitmap_query(pcopymapDest,i))) {
6732 void *def_ptr = parm_table[i].ptr;
6734 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
6737 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
6740 switch (parm_table[i].type) {
6743 *(bool *)dest_ptr = *(bool *)src_ptr;
6749 *(int *)dest_ptr = *(int *)src_ptr;
6753 *(char *)dest_ptr = *(char *)src_ptr;
6757 string_set((char **)dest_ptr,
6762 string_set((char **)dest_ptr,
6764 strupper_m(*(char **)dest_ptr);
6767 TALLOC_FREE(*((char ***)dest_ptr));
6768 *((char ***)dest_ptr) = str_list_copy(NULL,
6769 *(const char ***)src_ptr);
6777 init_copymap(pserviceDest);
6778 if (pserviceSource->copymap)
6779 bitmap_copy(pserviceDest->copymap,
6780 pserviceSource->copymap);
6783 data = pserviceSource->param_opt;
6785 set_param_opt(&pserviceDest->param_opt, data->key, data->value);
6790 /***************************************************************************
6791 Check a service for consistency. Return False if the service is in any way
6792 incomplete or faulty, else True.
6793 ***************************************************************************/
6795 bool service_ok(int iService)
6800 if (ServicePtrs[iService]->szService[0] == '\0') {
6801 DEBUG(0, ("The following message indicates an internal error:\n"));
6802 DEBUG(0, ("No service name in service entry.\n"));
6806 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6807 /* I can't see why you'd want a non-printable printer service... */
6808 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6809 if (!ServicePtrs[iService]->bPrint_ok) {
6810 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6811 ServicePtrs[iService]->szService));
6812 ServicePtrs[iService]->bPrint_ok = True;
6814 /* [printers] service must also be non-browsable. */
6815 if (ServicePtrs[iService]->bBrowseable)
6816 ServicePtrs[iService]->bBrowseable = False;
6819 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6820 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6821 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6823 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6824 ServicePtrs[iService]->szService));
6825 ServicePtrs[iService]->bAvailable = False;
6828 /* If a service is flagged unavailable, log the fact at level 1. */
6829 if (!ServicePtrs[iService]->bAvailable)
6830 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6831 ServicePtrs[iService]->szService));
6836 static struct smbconf_ctx *lp_smbconf_ctx(void)
6839 static struct smbconf_ctx *conf_ctx = NULL;
6841 if (conf_ctx == NULL) {
6842 werr = smbconf_init(NULL, &conf_ctx, "registry:");
6843 if (!W_ERROR_IS_OK(werr)) {
6844 DEBUG(1, ("error initializing registry configuration: "
6845 "%s\n", win_errstr(werr)));
6853 static bool process_smbconf_service(struct smbconf_service *service)
6858 if (service == NULL) {
6862 ret = do_section(service->name, NULL);
6866 for (count = 0; count < service->num_params; count++) {
6867 ret = do_parameter(service->param_names[count],
6868 service->param_values[count],
6874 if (iServiceIndex >= 0) {
6875 return service_ok(iServiceIndex);
6881 * load a service from registry and activate it
6883 bool process_registry_service(const char *service_name)
6886 struct smbconf_service *service = NULL;
6887 TALLOC_CTX *mem_ctx = talloc_stackframe();
6888 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6891 if (conf_ctx == NULL) {
6895 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6897 if (!smbconf_share_exists(conf_ctx, service_name)) {
6899 * Registry does not contain data for this service (yet),
6900 * but make sure lp_load doesn't return false.
6906 werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6907 if (!W_ERROR_IS_OK(werr)) {
6911 ret = process_smbconf_service(service);
6917 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6920 TALLOC_FREE(mem_ctx);
6925 * process_registry_globals
6927 static bool process_registry_globals(void)
6931 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6933 ret = do_parameter("registry shares", "yes", NULL);
6938 return process_registry_service(GLOBAL_NAME);
6941 bool process_registry_shares(void)
6945 struct smbconf_service **service = NULL;
6946 uint32_t num_shares = 0;
6947 TALLOC_CTX *mem_ctx = talloc_stackframe();
6948 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6951 if (conf_ctx == NULL) {
6955 werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6956 if (!W_ERROR_IS_OK(werr)) {
6962 for (count = 0; count < num_shares; count++) {
6963 if (strequal(service[count]->name, GLOBAL_NAME)) {
6966 ret = process_smbconf_service(service[count]);
6973 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6976 TALLOC_FREE(mem_ctx);
6980 #define MAX_INCLUDE_DEPTH 100
6982 static uint8_t include_depth;
6984 static struct file_lists {
6985 struct file_lists *next;
6989 } *file_lists = NULL;
6991 /*******************************************************************
6992 Keep a linked list of all config files so we know when one has changed
6993 it's date and needs to be reloaded.
6994 ********************************************************************/
6996 static void add_to_file_list(const char *fname, const char *subfname)
6998 struct file_lists *f = file_lists;
7001 if (f->name && !strcmp(f->name, fname))
7007 f = SMB_MALLOC_P(struct file_lists);
7010 f->next = file_lists;
7011 f->name = SMB_STRDUP(fname);
7016 f->subfname = SMB_STRDUP(subfname);
7022 f->modtime = file_modtime(subfname);
7024 time_t t = file_modtime(subfname);
7031 * Free the file lists
7033 static void free_file_list(void)
7035 struct file_lists *f;
7036 struct file_lists *next;
7041 SAFE_FREE( f->name );
7042 SAFE_FREE( f->subfname );
7051 * Utility function for outsiders to check if we're running on registry.
7053 bool lp_config_backend_is_registry(void)
7055 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
7059 * Utility function to check if the config backend is FILE.
7061 bool lp_config_backend_is_file(void)
7063 return (lp_config_backend() == CONFIG_BACKEND_FILE);
7066 /*******************************************************************
7067 Check if a config file has changed date.
7068 ********************************************************************/
7070 bool lp_file_list_changed(void)
7072 struct file_lists *f = file_lists;
7074 DEBUG(6, ("lp_file_list_changed()\n"));
7080 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
7081 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7083 if (conf_ctx == NULL) {
7086 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
7089 DEBUGADD(6, ("registry config changed\n"));
7093 n2 = alloc_sub_basic(get_current_username(),
7094 current_user_info.domain,
7099 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
7100 f->name, n2, ctime(&f->modtime)));
7102 mod_time = file_modtime(n2);
7105 ((f->modtime != mod_time) ||
7106 (f->subfname == NULL) ||
7107 (strcmp(n2, f->subfname) != 0)))
7110 ("file %s modified: %s\n", n2,
7112 f->modtime = mod_time;
7113 SAFE_FREE(f->subfname);
7114 f->subfname = n2; /* Passing ownership of
7115 return from alloc_sub_basic
7127 /***************************************************************************
7128 Run standard_sub_basic on netbios name... needed because global_myname
7129 is not accessed through any lp_ macro.
7130 Note: We must *NOT* use string_set() here as ptr points to global_myname.
7131 ***************************************************************************/
7133 static bool handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
7136 char *netbios_name = alloc_sub_basic(get_current_username(),
7137 current_user_info.domain,
7140 ret = set_global_myname(netbios_name);
7141 SAFE_FREE(netbios_name);
7142 string_set(&Globals.szNetbiosName,global_myname());
7144 DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
7150 static bool handle_charset(int snum, const char *pszParmValue, char **ptr)
7152 if (strcmp(*ptr, pszParmValue) != 0) {
7153 string_set(ptr, pszParmValue);
7161 static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
7165 ret = set_global_myworkgroup(pszParmValue);
7166 string_set(&Globals.szWorkgroup,lp_workgroup());
7171 static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
7175 ret = set_global_scope(pszParmValue);
7176 string_set(&Globals.szNetbiosScope,global_scope());
7181 static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
7183 TALLOC_FREE(Globals.szNetbiosAliases);
7184 Globals.szNetbiosAliases = str_list_make_v3(talloc_autofree_context(), pszParmValue, NULL);
7185 return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
7188 /***************************************************************************
7189 Handle the include operation.
7190 ***************************************************************************/
7191 static bool bAllowIncludeRegistry = true;
7193 static bool handle_include(int snum, const char *pszParmValue, char **ptr)
7197 if (include_depth >= MAX_INCLUDE_DEPTH) {
7198 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
7203 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
7204 if (!bAllowIncludeRegistry) {
7207 if (bInGlobalSection) {
7210 ret = process_registry_globals();
7214 DEBUG(1, ("\"include = registry\" only effective "
7215 "in %s section\n", GLOBAL_NAME));
7220 fname = alloc_sub_basic(get_current_username(),
7221 current_user_info.domain,
7224 add_to_file_list(pszParmValue, fname);
7226 string_set(ptr, fname);
7228 if (file_exist(fname)) {
7231 ret = pm_process(fname, do_section, do_parameter, NULL);
7237 DEBUG(2, ("Can't find include file %s\n", fname));
7242 /***************************************************************************
7243 Handle the interpretation of the copy parameter.
7244 ***************************************************************************/
7246 static bool handle_copy(int snum, const char *pszParmValue, char **ptr)
7250 struct service serviceTemp;
7252 string_set(ptr, pszParmValue);
7254 init_service(&serviceTemp);
7258 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7260 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7261 if (iTemp == iServiceIndex) {
7262 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7264 copy_service(ServicePtrs[iServiceIndex],
7266 ServicePtrs[iServiceIndex]->copymap);
7270 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7274 free_service(&serviceTemp);
7278 static bool handle_ldap_debug_level(int snum, const char *pszParmValue, char **ptr)
7280 Globals.ldap_debug_level = lp_int(pszParmValue);
7281 init_ldap_debugging();
7285 /***************************************************************************
7286 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7291 idmap uid = 1000-1999
7294 We only do simple parsing checks here. The strings are parsed into useful
7295 structures in the idmap daemon code.
7297 ***************************************************************************/
7299 /* Some lp_ routines to return idmap [ug]id information */
7301 static uid_t idmap_uid_low, idmap_uid_high;
7302 static gid_t idmap_gid_low, idmap_gid_high;
7304 bool lp_idmap_uid(uid_t *low, uid_t *high)
7306 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7310 *low = idmap_uid_low;
7313 *high = idmap_uid_high;
7318 bool lp_idmap_gid(gid_t *low, gid_t *high)
7320 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7324 *low = idmap_gid_low;
7327 *high = idmap_gid_high;
7332 /* Do some simple checks on "idmap [ug]id" parameter values */
7334 static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
7338 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7343 string_set(ptr, pszParmValue);
7345 idmap_uid_low = low;
7346 idmap_uid_high = high;
7351 static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
7355 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7360 string_set(ptr, pszParmValue);
7362 idmap_gid_low = low;
7363 idmap_gid_high = high;
7368 /***************************************************************************
7369 Handle the DEBUG level list.
7370 ***************************************************************************/
7372 static bool handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
7374 string_set(ptr, pszParmValueIn);
7375 return debug_parse_levels(pszParmValueIn);
7378 /***************************************************************************
7379 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7380 ***************************************************************************/
7382 static const char *append_ldap_suffix( const char *str )
7384 const char *suffix_string;
7387 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7388 Globals.szLdapSuffix );
7389 if ( !suffix_string ) {
7390 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7394 return suffix_string;
7397 const char *lp_ldap_machine_suffix(void)
7399 if (Globals.szLdapMachineSuffix[0])
7400 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7402 return lp_string(Globals.szLdapSuffix);
7405 const char *lp_ldap_user_suffix(void)
7407 if (Globals.szLdapUserSuffix[0])
7408 return append_ldap_suffix(Globals.szLdapUserSuffix);
7410 return lp_string(Globals.szLdapSuffix);
7413 const char *lp_ldap_group_suffix(void)
7415 if (Globals.szLdapGroupSuffix[0])
7416 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7418 return lp_string(Globals.szLdapSuffix);
7421 const char *lp_ldap_idmap_suffix(void)
7423 if (Globals.szLdapIdmapSuffix[0])
7424 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7426 return lp_string(Globals.szLdapSuffix);
7429 /****************************************************************************
7430 set the value for a P_ENUM
7431 ***************************************************************************/
7433 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7438 for (i = 0; parm->enum_list[i].name; i++) {
7439 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7440 *ptr = parm->enum_list[i].value;
7444 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7445 pszParmValue, parm->label));
7448 /***************************************************************************
7449 ***************************************************************************/
7451 static bool handle_printing(int snum, const char *pszParmValue, char **ptr)
7453 static int parm_num = -1;
7456 if ( parm_num == -1 )
7457 parm_num = map_parameter( "printing" );
7459 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7464 s = ServicePtrs[snum];
7466 init_printer_values( s );
7472 /***************************************************************************
7473 Initialise a copymap.
7474 ***************************************************************************/
7476 static void init_copymap(struct service *pservice)
7479 if (pservice->copymap) {
7480 bitmap_free(pservice->copymap);
7482 pservice->copymap = bitmap_allocate(NUMPARAMETERS);
7483 if (!pservice->copymap)
7485 ("Couldn't allocate copymap!! (size %d)\n",
7486 (int)NUMPARAMETERS));
7488 for (i = 0; i < NUMPARAMETERS; i++)
7489 bitmap_set(pservice->copymap, i);
7492 /***************************************************************************
7493 Return the local pointer to a parameter given a service struct and the
7494 pointer into the default structure.
7495 ***************************************************************************/
7497 static void *lp_local_ptr(struct service *service, void *ptr)
7499 return (void *)(((char *)service) + PTR_DIFF(ptr, &sDefault));
7502 /***************************************************************************
7503 Return the local pointer to a parameter given the service number and the
7504 pointer into the default structure.
7505 ***************************************************************************/
7507 void *lp_local_ptr_by_snum(int snum, void *ptr)
7509 return lp_local_ptr(ServicePtrs[snum], ptr);
7512 /***************************************************************************
7513 Process a parameter for a particular service number. If snum < 0
7514 then assume we are in the globals.
7515 ***************************************************************************/
7517 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7520 void *parm_ptr = NULL; /* where we are going to store the result */
7521 void *def_ptr = NULL;
7522 struct param_opt_struct **opt_list;
7524 parmnum = map_parameter(pszParmName);
7527 if (strchr(pszParmName, ':') == NULL) {
7528 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7534 * We've got a parametric option
7537 opt_list = (snum < 0)
7538 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7539 set_param_opt(opt_list, pszParmName, pszParmValue);
7544 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7545 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7549 def_ptr = parm_table[parmnum].ptr;
7551 /* we might point at a service, the default service or a global */
7555 if (parm_table[parmnum].p_class == P_GLOBAL) {
7557 ("Global parameter %s found in service section!\n",
7561 parm_ptr = lp_local_ptr_by_snum(snum, def_ptr);
7565 if (!ServicePtrs[snum]->copymap)
7566 init_copymap(ServicePtrs[snum]);
7568 /* this handles the aliases - set the copymap for other entries with
7569 the same data pointer */
7570 for (i = 0; parm_table[i].label; i++)
7571 if (parm_table[i].ptr == parm_table[parmnum].ptr)
7572 bitmap_clear(ServicePtrs[snum]->copymap, i);
7575 /* if it is a special case then go ahead */
7576 if (parm_table[parmnum].special) {
7577 return parm_table[parmnum].special(snum, pszParmValue,
7581 /* now switch on the type of variable it is */
7582 switch (parm_table[parmnum].type)
7585 *(bool *)parm_ptr = lp_bool(pszParmValue);
7589 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7593 *(int *)parm_ptr = lp_int(pszParmValue);
7597 *(char *)parm_ptr = *pszParmValue;
7601 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7603 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7608 TALLOC_FREE(*((char ***)parm_ptr));
7609 *(char ***)parm_ptr = str_list_make_v3(
7610 talloc_autofree_context(), pszParmValue, NULL);
7614 string_set((char **)parm_ptr, pszParmValue);
7618 string_set((char **)parm_ptr, pszParmValue);
7619 strupper_m(*(char **)parm_ptr);
7623 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7632 /***************************************************************************
7633 Process a parameter.
7634 ***************************************************************************/
7636 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7639 if (!bInGlobalSection && bGlobalOnly)
7642 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7644 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7645 pszParmName, pszParmValue));
7648 /***************************************************************************
7649 Print a parameter of the specified type.
7650 ***************************************************************************/
7652 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7658 for (i = 0; p->enum_list[i].name; i++) {
7659 if (*(int *)ptr == p->enum_list[i].value) {
7661 p->enum_list[i].name);
7668 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7672 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7676 fprintf(f, "%d", *(int *)ptr);
7680 fprintf(f, "%c", *(char *)ptr);
7684 char *o = octal_string(*(int *)ptr);
7685 fprintf(f, "%s", o);
7691 if ((char ***)ptr && *(char ***)ptr) {
7692 char **list = *(char ***)ptr;
7693 for (; *list; list++) {
7694 /* surround strings with whitespace in double quotes */
7695 if ( strchr_m( *list, ' ' ) )
7696 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
7698 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
7705 if (*(char **)ptr) {
7706 fprintf(f, "%s", *(char **)ptr);
7714 /***************************************************************************
7715 Check if two parameters are equal.
7716 ***************************************************************************/
7718 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7723 return (*((bool *)ptr1) == *((bool *)ptr2));
7728 return (*((int *)ptr1) == *((int *)ptr2));
7731 return (*((char *)ptr1) == *((char *)ptr2));
7734 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7739 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7744 return (p1 == p2 || strequal(p1, p2));
7752 /***************************************************************************
7753 Initialize any local varients in the sDefault table.
7754 ***************************************************************************/
7756 void init_locals(void)
7761 /***************************************************************************
7762 Process a new section (service). At this stage all sections are services.
7763 Later we'll have special sections that permit server parameters to be set.
7764 Returns True on success, False on failure.
7765 ***************************************************************************/
7767 static bool do_section(const char *pszSectionName, void *userdata)
7770 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7771 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7774 /* if we were in a global section then do the local inits */
7775 if (bInGlobalSection && !isglobal)
7778 /* if we've just struck a global section, note the fact. */
7779 bInGlobalSection = isglobal;
7781 /* check for multiple global sections */
7782 if (bInGlobalSection) {
7783 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7787 if (!bInGlobalSection && bGlobalOnly)
7790 /* if we have a current service, tidy it up before moving on */
7793 if (iServiceIndex >= 0)
7794 bRetval = service_ok(iServiceIndex);
7796 /* if all is still well, move to the next record in the services array */
7798 /* We put this here to avoid an odd message order if messages are */
7799 /* issued by the post-processing of a previous section. */
7800 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7802 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
7804 DEBUG(0, ("Failed to add a new service\n"));
7813 /***************************************************************************
7814 Determine if a partcular base parameter is currentl set to the default value.
7815 ***************************************************************************/
7817 static bool is_default(int i)
7819 if (!defaults_saved)
7821 switch (parm_table[i].type) {
7823 return str_list_equal((const char **)parm_table[i].def.lvalue,
7824 *(const char ***)parm_table[i].ptr);
7827 return strequal(parm_table[i].def.svalue,
7828 *(char **)parm_table[i].ptr);
7831 return parm_table[i].def.bvalue ==
7832 *(bool *)parm_table[i].ptr;
7834 return parm_table[i].def.cvalue ==
7835 *(char *)parm_table[i].ptr;
7839 return parm_table[i].def.ivalue ==
7840 *(int *)parm_table[i].ptr;
7847 /***************************************************************************
7848 Display the contents of the global structure.
7849 ***************************************************************************/
7851 static void dump_globals(FILE *f)
7854 struct param_opt_struct *data;
7856 fprintf(f, "[global]\n");
7858 for (i = 0; parm_table[i].label; i++)
7859 if (parm_table[i].p_class == P_GLOBAL &&
7860 !(parm_table[i].flags & FLAG_META) &&
7861 parm_table[i].ptr &&
7862 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
7863 if (defaults_saved && is_default(i))
7865 fprintf(f, "\t%s = ", parm_table[i].label);
7866 print_parameter(&parm_table[i], parm_table[i].ptr, f);
7869 if (Globals.param_opt != NULL) {
7870 data = Globals.param_opt;
7872 fprintf(f, "\t%s = %s\n", data->key, data->value);
7879 /***************************************************************************
7880 Return True if a local parameter is currently set to the global default.
7881 ***************************************************************************/
7883 bool lp_is_default(int snum, struct parm_struct *parm)
7885 int pdiff = PTR_DIFF(parm->ptr, &sDefault);
7887 return equal_parameter(parm->type,
7888 ((char *)ServicePtrs[snum]) + pdiff,
7889 ((char *)&sDefault) + pdiff);
7892 /***************************************************************************
7893 Display the contents of a single services record.
7894 ***************************************************************************/
7896 static void dump_a_service(struct service *pService, FILE * f)
7899 struct param_opt_struct *data;
7901 if (pService != &sDefault)
7902 fprintf(f, "[%s]\n", pService->szService);
7904 for (i = 0; parm_table[i].label; i++) {
7906 if (parm_table[i].p_class == P_LOCAL &&
7907 !(parm_table[i].flags & FLAG_META) &&
7908 parm_table[i].ptr &&
7909 (*parm_table[i].label != '-') &&
7910 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7912 int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
7914 if (pService == &sDefault) {
7915 if (defaults_saved && is_default(i))
7918 if (equal_parameter(parm_table[i].type,
7919 ((char *)pService) +
7921 ((char *)&sDefault) +
7926 fprintf(f, "\t%s = ", parm_table[i].label);
7927 print_parameter(&parm_table[i],
7928 ((char *)pService) + pdiff, f);
7933 if (pService->param_opt != NULL) {
7934 data = pService->param_opt;
7936 fprintf(f, "\t%s = %s\n", data->key, data->value);
7942 /***************************************************************************
7943 Display the contents of a parameter of a single services record.
7944 ***************************************************************************/
7946 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7949 bool result = False;
7952 fstring local_parm_name;
7954 const char *parm_opt_value;
7956 /* check for parametrical option */
7957 fstrcpy( local_parm_name, parm_name);
7958 parm_opt = strchr( local_parm_name, ':');
7963 if (strlen(parm_opt)) {
7964 parm_opt_value = lp_parm_const_string( snum,
7965 local_parm_name, parm_opt, NULL);
7966 if (parm_opt_value) {
7967 printf( "%s\n", parm_opt_value);
7974 /* check for a key and print the value */
7981 for (i = 0; parm_table[i].label; i++) {
7982 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7983 !(parm_table[i].flags & FLAG_META) &&
7984 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7985 parm_table[i].ptr &&
7986 (*parm_table[i].label != '-') &&
7987 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7992 ptr = parm_table[i].ptr;
7994 struct service *pService = ServicePtrs[snum];
7995 ptr = ((char *)pService) +
7996 PTR_DIFF(parm_table[i].ptr, &sDefault);
7999 print_parameter(&parm_table[i],
8010 /***************************************************************************
8011 Return info about the requested parameter (given as a string).
8012 Return NULL when the string is not a valid parameter name.
8013 ***************************************************************************/
8015 struct parm_struct *lp_get_parameter(const char *param_name)
8017 int num = map_parameter(param_name);
8023 return &parm_table[num];
8026 /***************************************************************************
8027 Return info about the next parameter in a service.
8028 snum==GLOBAL_SECTION_SNUM gives the globals.
8029 Return NULL when out of parameters.
8030 ***************************************************************************/
8032 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
8035 /* do the globals */
8036 for (; parm_table[*i].label; (*i)++) {
8037 if (parm_table[*i].p_class == P_SEPARATOR)
8038 return &parm_table[(*i)++];
8040 if (!parm_table[*i].ptr
8041 || (*parm_table[*i].label == '-'))
8045 && (parm_table[*i].ptr ==
8046 parm_table[(*i) - 1].ptr))
8049 if (is_default(*i) && !allparameters)
8052 return &parm_table[(*i)++];
8055 struct service *pService = ServicePtrs[snum];
8057 for (; parm_table[*i].label; (*i)++) {
8058 if (parm_table[*i].p_class == P_SEPARATOR)
8059 return &parm_table[(*i)++];
8061 if (parm_table[*i].p_class == P_LOCAL &&
8062 parm_table[*i].ptr &&
8063 (*parm_table[*i].label != '-') &&
8065 (parm_table[*i].ptr !=
8066 parm_table[(*i) - 1].ptr)))
8069 PTR_DIFF(parm_table[*i].ptr,
8072 if (allparameters ||
8073 !equal_parameter(parm_table[*i].type,
8074 ((char *)pService) +
8076 ((char *)&sDefault) +
8079 return &parm_table[(*i)++];
8090 /***************************************************************************
8091 Display the contents of a single copy structure.
8092 ***************************************************************************/
8093 static void dump_copy_map(bool *pcopymap)
8099 printf("\n\tNon-Copied parameters:\n");
8101 for (i = 0; parm_table[i].label; i++)
8102 if (parm_table[i].p_class == P_LOCAL &&
8103 parm_table[i].ptr && !pcopymap[i] &&
8104 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8106 printf("\t\t%s\n", parm_table[i].label);
8111 /***************************************************************************
8112 Return TRUE if the passed service number is within range.
8113 ***************************************************************************/
8115 bool lp_snum_ok(int iService)
8117 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8120 /***************************************************************************
8121 Auto-load some home services.
8122 ***************************************************************************/
8124 static void lp_add_auto_services(char *str)
8134 s = SMB_STRDUP(str);
8138 homes = lp_servicenumber(HOMES_NAME);
8140 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8141 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8144 if (lp_servicenumber(p) >= 0)
8147 home = get_user_home_dir(talloc_tos(), p);
8149 if (home && home[0] && homes >= 0)
8150 lp_add_home(p, homes, p, home);
8157 /***************************************************************************
8158 Auto-load one printer.
8159 ***************************************************************************/
8161 void lp_add_one_printer(const char *name, const char *comment, void *pdata)
8163 int printers = lp_servicenumber(PRINTERS_NAME);
8166 if (lp_servicenumber(name) < 0) {
8167 lp_add_printer(name, printers);
8168 if ((i = lp_servicenumber(name)) >= 0) {
8169 string_set(&ServicePtrs[i]->comment, comment);
8170 ServicePtrs[i]->autoloaded = True;
8175 /***************************************************************************
8176 Have we loaded a services file yet?
8177 ***************************************************************************/
8179 bool lp_loaded(void)
8184 /***************************************************************************
8185 Unload unused services.
8186 ***************************************************************************/
8188 void lp_killunused(bool (*snumused) (int))
8191 for (i = 0; i < iNumServices; i++) {
8195 /* don't kill autoloaded or usershare services */
8196 if ( ServicePtrs[i]->autoloaded ||
8197 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8201 if (!snumused || !snumused(i)) {
8202 free_service_byindex(i);
8208 * Kill all except autoloaded and usershare services - convenience wrapper
8210 void lp_kill_all_services(void)
8212 lp_killunused(NULL);
8215 /***************************************************************************
8217 ***************************************************************************/
8219 void lp_killservice(int iServiceIn)
8221 if (VALID(iServiceIn)) {
8222 free_service_byindex(iServiceIn);
8226 /***************************************************************************
8227 Save the curent values of all global and sDefault parameters into the
8228 defaults union. This allows swat and testparm to show only the
8229 changed (ie. non-default) parameters.
8230 ***************************************************************************/
8232 static void lp_save_defaults(void)
8235 for (i = 0; parm_table[i].label; i++) {
8236 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
8238 switch (parm_table[i].type) {
8240 parm_table[i].def.lvalue = str_list_copy(
8241 NULL, *(const char ***)parm_table[i].ptr);
8245 if (parm_table[i].ptr) {
8246 parm_table[i].def.svalue = SMB_STRDUP(*(char **)parm_table[i].ptr);
8248 parm_table[i].def.svalue = NULL;
8253 parm_table[i].def.bvalue =
8254 *(bool *)parm_table[i].ptr;
8257 parm_table[i].def.cvalue =
8258 *(char *)parm_table[i].ptr;
8263 parm_table[i].def.ivalue =
8264 *(int *)parm_table[i].ptr;
8270 defaults_saved = True;
8273 /*******************************************************************
8274 Set the server type we will announce as via nmbd.
8275 ********************************************************************/
8277 static const struct srv_role_tab {
8279 const char *role_str;
8280 } srv_role_tab [] = {
8281 { ROLE_STANDALONE, "ROLE_STANDALONE" },
8282 { ROLE_DOMAIN_MEMBER, "ROLE_DOMAIN_MEMBER" },
8283 { ROLE_DOMAIN_BDC, "ROLE_DOMAIN_BDC" },
8284 { ROLE_DOMAIN_PDC, "ROLE_DOMAIN_PDC" },
8288 const char* server_role_str(uint32 role)
8291 for (i=0; srv_role_tab[i].role_str; i++) {
8292 if (role == srv_role_tab[i].role) {
8293 return srv_role_tab[i].role_str;
8299 static void set_server_role(void)
8301 server_role = ROLE_STANDALONE;
8303 switch (lp_security()) {
8305 if (lp_domain_logons())
8306 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
8309 if (lp_domain_logons())
8310 DEBUG(0, ("Server's Role (logon server) conflicts with server-level security\n"));
8311 /* this used to be considered ROLE_DOMAIN_MEMBER but that's just wrong */
8312 server_role = ROLE_STANDALONE;
8315 if (lp_domain_logons()) {
8316 DEBUG(1, ("Server's Role (logon server) NOT ADVISED with domain-level security\n"));
8317 server_role = ROLE_DOMAIN_BDC;
8320 server_role = ROLE_DOMAIN_MEMBER;
8323 if (lp_domain_logons()) {
8324 server_role = ROLE_DOMAIN_PDC;
8327 server_role = ROLE_DOMAIN_MEMBER;
8330 if (lp_domain_logons()) {
8332 if (Globals.iDomainMaster) /* auto or yes */
8333 server_role = ROLE_DOMAIN_PDC;
8335 server_role = ROLE_DOMAIN_BDC;
8339 DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
8343 DEBUG(10, ("set_server_role: role = %s\n", server_role_str(server_role)));
8346 /***********************************************************
8347 If we should send plaintext/LANMAN passwords in the clinet
8348 ************************************************************/
8350 static void set_allowed_client_auth(void)
8352 if (Globals.bClientNTLMv2Auth) {
8353 Globals.bClientLanManAuth = False;
8355 if (!Globals.bClientLanManAuth) {
8356 Globals.bClientPlaintextAuth = False;
8360 /***************************************************************************
8362 The following code allows smbd to read a user defined share file.
8363 Yes, this is my intent. Yes, I'm comfortable with that...
8365 THE FOLLOWING IS SECURITY CRITICAL CODE.
8367 It washes your clothes, it cleans your house, it guards you while you sleep...
8368 Do not f%^k with it....
8369 ***************************************************************************/
8371 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8373 /***************************************************************************
8374 Check allowed stat state of a usershare file.
8375 Ensure we print out who is dicking with us so the admin can
8376 get their sorry ass fired.
8377 ***************************************************************************/
8379 static bool check_usershare_stat(const char *fname,
8380 const SMB_STRUCT_STAT *psbuf)
8382 if (!S_ISREG(psbuf->st_ex_mode)) {
8383 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8384 "not a regular file\n",
8385 fname, (unsigned int)psbuf->st_ex_uid ));
8389 /* Ensure this doesn't have the other write bit set. */
8390 if (psbuf->st_ex_mode & S_IWOTH) {
8391 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8392 "public write. Refusing to allow as a usershare file.\n",
8393 fname, (unsigned int)psbuf->st_ex_uid ));
8397 /* Should be 10k or less. */
8398 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8399 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8400 "too large (%u) to be a user share file.\n",
8401 fname, (unsigned int)psbuf->st_ex_uid,
8402 (unsigned int)psbuf->st_ex_size ));
8409 /***************************************************************************
8410 Parse the contents of a usershare file.
8411 ***************************************************************************/
8413 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8414 SMB_STRUCT_STAT *psbuf,
8415 const char *servicename,
8419 char **pp_sharepath,
8424 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8425 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8428 SMB_STRUCT_STAT sbuf;
8429 char *sharepath = NULL;
8430 char *comment = NULL;
8432 *pp_sharepath = NULL;
8435 *pallow_guest = False;
8438 return USERSHARE_MALFORMED_FILE;
8441 if (strcmp(lines[0], "#VERSION 1") == 0) {
8443 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8446 return USERSHARE_MALFORMED_FILE;
8449 return USERSHARE_BAD_VERSION;
8452 if (strncmp(lines[1], "path=", 5) != 0) {
8453 return USERSHARE_MALFORMED_PATH;
8456 sharepath = talloc_strdup(ctx, &lines[1][5]);
8458 return USERSHARE_POSIX_ERR;
8460 trim_string(sharepath, " ", " ");
8462 if (strncmp(lines[2], "comment=", 8) != 0) {
8463 return USERSHARE_MALFORMED_COMMENT_DEF;
8466 comment = talloc_strdup(ctx, &lines[2][8]);
8468 return USERSHARE_POSIX_ERR;
8470 trim_string(comment, " ", " ");
8471 trim_char(comment, '"', '"');
8473 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8474 return USERSHARE_MALFORMED_ACL_DEF;
8477 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8478 return USERSHARE_ACL_ERR;
8482 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8483 return USERSHARE_MALFORMED_ACL_DEF;
8485 if (lines[4][9] == 'y') {
8486 *pallow_guest = True;
8490 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8491 /* Path didn't change, no checks needed. */
8492 *pp_sharepath = sharepath;
8493 *pp_comment = comment;
8494 return USERSHARE_OK;
8497 /* The path *must* be absolute. */
8498 if (sharepath[0] != '/') {
8499 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8500 servicename, sharepath));
8501 return USERSHARE_PATH_NOT_ABSOLUTE;
8504 /* If there is a usershare prefix deny list ensure one of these paths
8505 doesn't match the start of the user given path. */
8506 if (prefixdenylist) {
8508 for ( i=0; prefixdenylist[i]; i++ ) {
8509 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8510 servicename, i, prefixdenylist[i], sharepath ));
8511 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8512 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8513 "usershare prefix deny list entries.\n",
8514 servicename, sharepath));
8515 return USERSHARE_PATH_IS_DENIED;
8520 /* If there is a usershare prefix allow list ensure one of these paths
8521 does match the start of the user given path. */
8523 if (prefixallowlist) {
8525 for ( i=0; prefixallowlist[i]; i++ ) {
8526 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8527 servicename, i, prefixallowlist[i], sharepath ));
8528 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8532 if (prefixallowlist[i] == NULL) {
8533 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8534 "usershare prefix allow list entries.\n",
8535 servicename, sharepath));
8536 return USERSHARE_PATH_NOT_ALLOWED;
8540 /* Ensure this is pointing to a directory. */
8541 dp = sys_opendir(sharepath);
8544 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8545 servicename, sharepath));
8546 return USERSHARE_PATH_NOT_DIRECTORY;
8549 /* Ensure the owner of the usershare file has permission to share
8552 if (sys_stat(sharepath, &sbuf) == -1) {
8553 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8554 servicename, sharepath, strerror(errno) ));
8556 return USERSHARE_POSIX_ERR;
8561 if (!S_ISDIR(sbuf.st_ex_mode)) {
8562 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8563 servicename, sharepath ));
8564 return USERSHARE_PATH_NOT_DIRECTORY;
8567 /* Check if sharing is restricted to owner-only. */
8568 /* psbuf is the stat of the usershare definition file,
8569 sbuf is the stat of the target directory to be shared. */
8571 if (lp_usershare_owner_only()) {
8572 /* root can share anything. */
8573 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8574 return USERSHARE_PATH_NOT_ALLOWED;
8578 *pp_sharepath = sharepath;
8579 *pp_comment = comment;
8580 return USERSHARE_OK;
8583 /***************************************************************************
8584 Deal with a usershare file.
8587 -1 - Bad name, invalid contents.
8588 - service name already existed and not a usershare, problem
8589 with permissions to share directory etc.
8590 ***************************************************************************/
8592 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8594 SMB_STRUCT_STAT sbuf;
8595 SMB_STRUCT_STAT lsbuf;
8597 char *sharepath = NULL;
8598 char *comment = NULL;
8599 fstring service_name;
8600 char **lines = NULL;
8604 TALLOC_CTX *ctx = NULL;
8605 SEC_DESC *psd = NULL;
8606 bool guest_ok = False;
8608 /* Ensure share name doesn't contain invalid characters. */
8609 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8610 DEBUG(0,("process_usershare_file: share name %s contains "
8611 "invalid characters (any of %s)\n",
8612 file_name, INVALID_SHARENAME_CHARS ));
8616 fstrcpy(service_name, file_name);
8618 if (asprintf(&fname, "%s/%s", dir_name, file_name) < 0) {
8621 /* Minimize the race condition by doing an lstat before we
8622 open and fstat. Ensure this isn't a symlink link. */
8624 if (sys_lstat(fname, &lsbuf) != 0) {
8625 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8626 fname, strerror(errno) ));
8631 /* This must be a regular file, not a symlink, directory or
8632 other strange filetype. */
8633 if (!check_usershare_stat(fname, &lsbuf)) {
8639 char *canon_name = canonicalize_servicename(service_name);
8640 TDB_DATA data = dbwrap_fetch_bystring(
8641 ServiceHash, canon_name, canon_name);
8645 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
8646 iService = *(int *)data.dptr;
8648 TALLOC_FREE(canon_name);
8651 if (iService != -1 &&
8652 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8653 &lsbuf.st_ex_mtime) == 0) {
8654 /* Nothing changed - Mark valid and return. */
8655 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8657 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8662 /* Try and open the file read only - no symlinks allowed. */
8664 fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8666 fd = sys_open(fname, O_RDONLY, 0);
8670 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8671 fname, strerror(errno) ));
8676 /* Now fstat to be *SURE* it's a regular file. */
8677 if (sys_fstat(fd, &sbuf) != 0) {
8679 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8680 fname, strerror(errno) ));
8685 /* Is it the same dev/inode as was lstated ? */
8686 if (lsbuf.st_ex_dev != sbuf.st_ex_dev || lsbuf.st_ex_ino != sbuf.st_ex_ino) {
8688 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8689 "Symlink spoofing going on ?\n", fname ));
8694 /* This must be a regular file, not a symlink, directory or
8695 other strange filetype. */
8696 if (!check_usershare_stat(fname, &sbuf)) {
8701 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8704 if (lines == NULL) {
8705 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8706 fname, (unsigned int)sbuf.st_ex_uid ));
8713 /* Should we allow printers to be shared... ? */
8714 ctx = talloc_init("usershare_sd_xctx");
8720 if (parse_usershare_file(ctx, &sbuf, service_name,
8721 iService, lines, numlines, &sharepath,
8722 &comment, &psd, &guest_ok) != USERSHARE_OK) {
8723 talloc_destroy(ctx);
8730 /* Everything ok - add the service possibly using a template. */
8732 const struct service *sp = &sDefault;
8733 if (snum_template != -1) {
8734 sp = ServicePtrs[snum_template];
8737 if ((iService = add_a_service(sp, service_name)) < 0) {
8738 DEBUG(0, ("process_usershare_file: Failed to add "
8739 "new service %s\n", service_name));
8740 talloc_destroy(ctx);
8744 /* Read only is controlled by usershare ACL below. */
8745 ServicePtrs[iService]->bRead_only = False;
8748 /* Write the ACL of the new/modified share. */
8749 if (!set_share_security(service_name, psd)) {
8750 DEBUG(0, ("process_usershare_file: Failed to set share "
8751 "security for user share %s\n",
8753 lp_remove_service(iService);
8754 talloc_destroy(ctx);
8758 /* If from a template it may be marked invalid. */
8759 ServicePtrs[iService]->valid = True;
8761 /* Set the service as a valid usershare. */
8762 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8764 /* Set guest access. */
8765 if (lp_usershare_allow_guests()) {
8766 ServicePtrs[iService]->bGuest_ok = guest_ok;
8769 /* And note when it was loaded. */
8770 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8771 string_set(&ServicePtrs[iService]->szPath, sharepath);
8772 string_set(&ServicePtrs[iService]->comment, comment);
8774 talloc_destroy(ctx);
8779 /***************************************************************************
8780 Checks if a usershare entry has been modified since last load.
8781 ***************************************************************************/
8783 static bool usershare_exists(int iService, struct timespec *last_mod)
8785 SMB_STRUCT_STAT lsbuf;
8786 const char *usersharepath = Globals.szUsersharePath;
8789 if (asprintf(&fname, "%s/%s",
8791 ServicePtrs[iService]->szService) < 0) {
8795 if (sys_lstat(fname, &lsbuf) != 0) {
8800 if (!S_ISREG(lsbuf.st_ex_mode)) {
8806 *last_mod = lsbuf.st_ex_mtime;
8810 /***************************************************************************
8811 Load a usershare service by name. Returns a valid servicenumber or -1.
8812 ***************************************************************************/
8814 int load_usershare_service(const char *servicename)
8816 SMB_STRUCT_STAT sbuf;
8817 const char *usersharepath = Globals.szUsersharePath;
8818 int max_user_shares = Globals.iUsershareMaxShares;
8819 int snum_template = -1;
8821 if (*usersharepath == 0 || max_user_shares == 0) {
8825 if (sys_stat(usersharepath, &sbuf) != 0) {
8826 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8827 usersharepath, strerror(errno) ));
8831 if (!S_ISDIR(sbuf.st_ex_mode)) {
8832 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8838 * This directory must be owned by root, and have the 't' bit set.
8839 * It also must not be writable by "other".
8843 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8845 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8847 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8848 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8853 /* Ensure the template share exists if it's set. */
8854 if (Globals.szUsershareTemplateShare[0]) {
8855 /* We can't use lp_servicenumber here as we are recommending that
8856 template shares have -valid=False set. */
8857 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8858 if (ServicePtrs[snum_template]->szService &&
8859 strequal(ServicePtrs[snum_template]->szService,
8860 Globals.szUsershareTemplateShare)) {
8865 if (snum_template == -1) {
8866 DEBUG(0,("load_usershare_service: usershare template share %s "
8867 "does not exist.\n",
8868 Globals.szUsershareTemplateShare ));
8873 return process_usershare_file(usersharepath, servicename, snum_template);
8876 /***************************************************************************
8877 Load all user defined shares from the user share directory.
8878 We only do this if we're enumerating the share list.
8879 This is the function that can delete usershares that have
8881 ***************************************************************************/
8883 int load_usershare_shares(void)
8886 SMB_STRUCT_STAT sbuf;
8887 SMB_STRUCT_DIRENT *de;
8888 int num_usershares = 0;
8889 int max_user_shares = Globals.iUsershareMaxShares;
8890 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8891 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8892 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8894 int snum_template = -1;
8895 const char *usersharepath = Globals.szUsersharePath;
8896 int ret = lp_numservices();
8898 if (max_user_shares == 0 || *usersharepath == '\0') {
8899 return lp_numservices();
8902 if (sys_stat(usersharepath, &sbuf) != 0) {
8903 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8904 usersharepath, strerror(errno) ));
8909 * This directory must be owned by root, and have the 't' bit set.
8910 * It also must not be writable by "other".
8914 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8916 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8918 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8919 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8924 /* Ensure the template share exists if it's set. */
8925 if (Globals.szUsershareTemplateShare[0]) {
8926 /* We can't use lp_servicenumber here as we are recommending that
8927 template shares have -valid=False set. */
8928 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8929 if (ServicePtrs[snum_template]->szService &&
8930 strequal(ServicePtrs[snum_template]->szService,
8931 Globals.szUsershareTemplateShare)) {
8936 if (snum_template == -1) {
8937 DEBUG(0,("load_usershare_shares: usershare template share %s "
8938 "does not exist.\n",
8939 Globals.szUsershareTemplateShare ));
8944 /* Mark all existing usershares as pending delete. */
8945 for (iService = iNumServices - 1; iService >= 0; iService--) {
8946 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8947 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8951 dp = sys_opendir(usersharepath);
8953 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8954 usersharepath, strerror(errno) ));
8958 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8959 (de = sys_readdir(dp));
8960 num_dir_entries++ ) {
8962 const char *n = de->d_name;
8964 /* Ignore . and .. */
8966 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8972 /* Temporary file used when creating a share. */
8973 num_tmp_dir_entries++;
8976 /* Allow 20% tmp entries. */
8977 if (num_tmp_dir_entries > allowed_tmp_entries) {
8978 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8979 "in directory %s\n",
8980 num_tmp_dir_entries, usersharepath));
8984 r = process_usershare_file(usersharepath, n, snum_template);
8986 /* Update the services count. */
8988 if (num_usershares >= max_user_shares) {
8989 DEBUG(0,("load_usershare_shares: max user shares reached "
8990 "on file %s in directory %s\n",
8991 n, usersharepath ));
8994 } else if (r == -1) {
8995 num_bad_dir_entries++;
8998 /* Allow 20% bad entries. */
8999 if (num_bad_dir_entries > allowed_bad_entries) {
9000 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
9001 "in directory %s\n",
9002 num_bad_dir_entries, usersharepath));
9006 /* Allow 20% bad entries. */
9007 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
9008 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
9009 "in directory %s\n",
9010 num_dir_entries, usersharepath));
9017 /* Sweep through and delete any non-refreshed usershares that are
9018 not currently in use. */
9019 for (iService = iNumServices - 1; iService >= 0; iService--) {
9020 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
9021 if (conn_snum_used(iService)) {
9024 /* Remove from the share ACL db. */
9025 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
9026 lp_servicename(iService) ));
9027 delete_share_security(lp_servicename(iService));
9028 free_service_byindex(iService);
9032 return lp_numservices();
9035 /********************************************************
9036 Destroy global resources allocated in this file
9037 ********************************************************/
9039 void gfree_loadparm(void)
9045 /* Free resources allocated to services */
9047 for ( i = 0; i < iNumServices; i++ ) {
9049 free_service_byindex(i);
9053 SAFE_FREE( ServicePtrs );
9056 /* Now release all resources allocated to global
9057 parameters and the default service */
9059 free_global_parameters();
9063 /***************************************************************************
9064 Allow client apps to specify that they are a client
9065 ***************************************************************************/
9066 void lp_set_in_client(bool b)
9072 /***************************************************************************
9073 Determine if we're running in a client app
9074 ***************************************************************************/
9075 bool lp_is_in_client(void)
9080 /***************************************************************************
9081 Load the services array from the services file. Return True on success,
9083 ***************************************************************************/
9085 bool lp_load_ex(const char *pszFname,
9089 bool initialize_globals,
9090 bool allow_include_registry,
9091 bool allow_registry_shares)
9098 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
9100 bInGlobalSection = True;
9101 bGlobalOnly = global_only;
9102 bAllowIncludeRegistry = allow_include_registry;
9104 init_globals(! initialize_globals);
9109 if (save_defaults) {
9114 free_param_opts(&Globals.param_opt);
9116 /* We get sections first, so have to start 'behind' to make up */
9119 if (lp_config_backend_is_file()) {
9120 n2 = alloc_sub_basic(get_current_username(),
9121 current_user_info.domain,
9124 smb_panic("lp_load_ex: out of memory");
9127 add_to_file_list(pszFname, n2);
9129 bRetval = pm_process(n2, do_section, do_parameter, NULL);
9132 /* finish up the last section */
9133 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
9135 if (iServiceIndex >= 0) {
9136 bRetval = service_ok(iServiceIndex);
9140 if (lp_config_backend_is_registry()) {
9141 /* config backend changed to registry in config file */
9143 * We need to use this extra global variable here to
9144 * survive restart: init_globals uses this as a default
9145 * for ConfigBackend. Otherwise, init_globals would
9146 * send us into an endless loop here.
9148 config_backend = CONFIG_BACKEND_REGISTRY;
9150 DEBUG(1, ("lp_load_ex: changing to config backend "
9152 init_globals(false);
9153 lp_kill_all_services();
9154 return lp_load_ex(pszFname, global_only, save_defaults,
9155 add_ipc, initialize_globals,
9156 allow_include_registry,
9157 allow_registry_shares);
9159 } else if (lp_config_backend_is_registry()) {
9160 bRetval = process_registry_globals();
9162 DEBUG(0, ("Illegal config backend given: %d\n",
9163 lp_config_backend()));
9167 if (bRetval && lp_registry_shares() && allow_registry_shares) {
9168 bRetval = process_registry_shares();
9171 lp_add_auto_services(lp_auto_services());
9174 /* When 'restrict anonymous = 2' guest connections to ipc$
9176 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9177 if ( lp_enable_asu_support() ) {
9178 lp_add_ipc("ADMIN$", false);
9183 set_default_server_announce_type();
9184 set_allowed_client_auth();
9188 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9189 /* if bWINSsupport is true and we are in the client */
9190 if (lp_is_in_client() && Globals.bWINSsupport) {
9191 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9196 bAllowIncludeRegistry = true;
9201 bool lp_load(const char *pszFname,
9205 bool initialize_globals)
9207 return lp_load_ex(pszFname,
9215 bool lp_load_initial_only(const char *pszFname)
9217 return lp_load_ex(pszFname,
9226 bool lp_load_with_registry_shares(const char *pszFname,
9230 bool initialize_globals)
9232 return lp_load_ex(pszFname,
9241 /***************************************************************************
9242 Return the max number of services.
9243 ***************************************************************************/
9245 int lp_numservices(void)
9247 return (iNumServices);
9250 /***************************************************************************
9251 Display the contents of the services array in human-readable form.
9252 ***************************************************************************/
9254 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9259 defaults_saved = False;
9263 dump_a_service(&sDefault, f);
9265 for (iService = 0; iService < maxtoprint; iService++) {
9267 lp_dump_one(f, show_defaults, iService);
9271 /***************************************************************************
9272 Display the contents of one service in human-readable form.
9273 ***************************************************************************/
9275 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9278 if (ServicePtrs[snum]->szService[0] == '\0')
9280 dump_a_service(ServicePtrs[snum], f);
9284 /***************************************************************************
9285 Return the number of the service with the given name, or -1 if it doesn't
9286 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9287 getservicebyname()! This works ONLY if all services have been loaded, and
9288 does not copy the found service.
9289 ***************************************************************************/
9291 int lp_servicenumber(const char *pszServiceName)
9294 fstring serviceName;
9296 if (!pszServiceName) {
9297 return GLOBAL_SECTION_SNUM;
9300 for (iService = iNumServices - 1; iService >= 0; iService--) {
9301 if (VALID(iService) && ServicePtrs[iService]->szService) {
9303 * The substitution here is used to support %U is
9306 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9307 standard_sub_basic(get_current_username(),
9308 current_user_info.domain,
9309 serviceName,sizeof(serviceName));
9310 if (strequal(serviceName, pszServiceName)) {
9316 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9317 struct timespec last_mod;
9319 if (!usershare_exists(iService, &last_mod)) {
9320 /* Remove the share security tdb entry for it. */
9321 delete_share_security(lp_servicename(iService));
9322 /* Remove it from the array. */
9323 free_service_byindex(iService);
9324 /* Doesn't exist anymore. */
9325 return GLOBAL_SECTION_SNUM;
9328 /* Has it been modified ? If so delete and reload. */
9329 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9331 /* Remove it from the array. */
9332 free_service_byindex(iService);
9333 /* and now reload it. */
9334 iService = load_usershare_service(pszServiceName);
9339 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9340 return GLOBAL_SECTION_SNUM;
9346 bool share_defined(const char *service_name)
9348 return (lp_servicenumber(service_name) != -1);
9351 struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
9352 const char *sharename)
9354 struct share_params *result;
9358 if (!(sname = SMB_STRDUP(sharename))) {
9362 snum = find_service(sname);
9369 if (!(result = TALLOC_P(mem_ctx, struct share_params))) {
9370 DEBUG(0, ("talloc failed\n"));
9374 result->service = snum;
9378 struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx)
9380 struct share_iterator *result;
9382 if (!(result = TALLOC_P(mem_ctx, struct share_iterator))) {
9383 DEBUG(0, ("talloc failed\n"));
9387 result->next_id = 0;
9391 struct share_params *next_share(struct share_iterator *list)
9393 struct share_params *result;
9395 while (!lp_snum_ok(list->next_id) &&
9396 (list->next_id < lp_numservices())) {
9400 if (list->next_id >= lp_numservices()) {
9404 if (!(result = TALLOC_P(list, struct share_params))) {
9405 DEBUG(0, ("talloc failed\n"));
9409 result->service = list->next_id;
9414 struct share_params *next_printer(struct share_iterator *list)
9416 struct share_params *result;
9418 while ((result = next_share(list)) != NULL) {
9419 if (lp_print_ok(result->service)) {
9427 * This is a hack for a transition period until we transformed all code from
9428 * service numbers to struct share_params.
9431 struct share_params *snum2params_static(int snum)
9433 static struct share_params result;
9434 result.service = snum;
9438 /*******************************************************************
9439 A useful volume label function.
9440 ********************************************************************/
9442 const char *volume_label(int snum)
9445 const char *label = lp_volume(snum);
9447 label = lp_servicename(snum);
9450 /* This returns a 33 byte guarenteed null terminated string. */
9451 ret = talloc_strndup(talloc_tos(), label, 32);
9458 /*******************************************************************
9459 Set the server type we will announce as via nmbd.
9460 ********************************************************************/
9462 static void set_default_server_announce_type(void)
9464 default_server_announce = 0;
9465 default_server_announce |= SV_TYPE_WORKSTATION;
9466 default_server_announce |= SV_TYPE_SERVER;
9467 default_server_announce |= SV_TYPE_SERVER_UNIX;
9469 /* note that the flag should be set only if we have a
9470 printer service but nmbd doesn't actually load the
9471 services so we can't tell --jerry */
9473 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9475 switch (lp_announce_as()) {
9476 case ANNOUNCE_AS_NT_SERVER:
9477 default_server_announce |= SV_TYPE_SERVER_NT;
9478 /* fall through... */
9479 case ANNOUNCE_AS_NT_WORKSTATION:
9480 default_server_announce |= SV_TYPE_NT;
9482 case ANNOUNCE_AS_WIN95:
9483 default_server_announce |= SV_TYPE_WIN95_PLUS;
9485 case ANNOUNCE_AS_WFW:
9486 default_server_announce |= SV_TYPE_WFW;
9492 switch (lp_server_role()) {
9493 case ROLE_DOMAIN_MEMBER:
9494 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9496 case ROLE_DOMAIN_PDC:
9497 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9499 case ROLE_DOMAIN_BDC:
9500 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9502 case ROLE_STANDALONE:
9506 if (lp_time_server())
9507 default_server_announce |= SV_TYPE_TIME_SOURCE;
9509 if (lp_host_msdfs())
9510 default_server_announce |= SV_TYPE_DFS_SERVER;
9513 /***********************************************************
9514 returns role of Samba server
9515 ************************************************************/
9517 int lp_server_role(void)
9522 /***********************************************************
9523 If we are PDC then prefer us as DMB
9524 ************************************************************/
9526 bool lp_domain_master(void)
9528 if (Globals.iDomainMaster == Auto)
9529 return (lp_server_role() == ROLE_DOMAIN_PDC);
9531 return (bool)Globals.iDomainMaster;
9534 /***********************************************************
9535 If we are DMB then prefer us as LMB
9536 ************************************************************/
9538 bool lp_preferred_master(void)
9540 if (Globals.iPreferredMaster == Auto)
9541 return (lp_local_master() && lp_domain_master());
9543 return (bool)Globals.iPreferredMaster;
9546 /*******************************************************************
9548 ********************************************************************/
9550 void lp_remove_service(int snum)
9552 ServicePtrs[snum]->valid = False;
9553 invalid_services[num_invalid_services++] = snum;
9556 /*******************************************************************
9558 ********************************************************************/
9560 void lp_copy_service(int snum, const char *new_name)
9562 do_section(new_name, NULL);
9564 snum = lp_servicenumber(new_name);
9566 lp_do_parameter(snum, "copy", lp_servicename(snum));
9571 /*******************************************************************
9572 Get the default server type we will announce as via nmbd.
9573 ********************************************************************/
9575 int lp_default_server_announce(void)
9577 return default_server_announce;
9580 /*******************************************************************
9581 Split the announce version into major and minor numbers.
9582 ********************************************************************/
9584 int lp_major_announce_version(void)
9586 static bool got_major = False;
9587 static int major_version = DEFAULT_MAJOR_VERSION;
9592 return major_version;
9595 if ((vers = lp_announce_version()) == NULL)
9596 return major_version;
9598 if ((p = strchr_m(vers, '.')) == 0)
9599 return major_version;
9602 major_version = atoi(vers);
9603 return major_version;
9606 int lp_minor_announce_version(void)
9608 static bool got_minor = False;
9609 static int minor_version = DEFAULT_MINOR_VERSION;
9614 return minor_version;
9617 if ((vers = lp_announce_version()) == NULL)
9618 return minor_version;
9620 if ((p = strchr_m(vers, '.')) == 0)
9621 return minor_version;
9624 minor_version = atoi(p);
9625 return minor_version;
9628 /***********************************************************
9629 Set the global name resolution order (used in smbclient).
9630 ************************************************************/
9632 void lp_set_name_resolve_order(const char *new_order)
9634 string_set(&Globals.szNameResolveOrder, new_order);
9637 const char *lp_printername(int snum)
9639 const char *ret = _lp_printername(snum);
9640 if (ret == NULL || (ret != NULL && *ret == '\0'))
9641 ret = lp_const_servicename(snum);
9647 /***********************************************************
9648 Allow daemons such as winbindd to fix their logfile name.
9649 ************************************************************/
9651 void lp_set_logfile(const char *name)
9653 string_set(&Globals.szLogFile, name);
9654 debug_set_logfile(name);
9657 /*******************************************************************
9658 Return the max print jobs per queue.
9659 ********************************************************************/
9661 int lp_maxprintjobs(int snum)
9663 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9664 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9665 maxjobs = PRINT_MAX_JOBID - 1;
9670 const char *lp_printcapname(void)
9672 if ((Globals.szPrintcapname != NULL) &&
9673 (Globals.szPrintcapname[0] != '\0'))
9674 return Globals.szPrintcapname;
9676 if (sDefault.iPrinting == PRINT_CUPS) {
9684 if (sDefault.iPrinting == PRINT_BSD)
9685 return "/etc/printcap";
9687 return PRINTCAP_NAME;
9690 static uint32 spoolss_state;
9692 bool lp_disable_spoolss( void )
9694 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9695 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9697 return spoolss_state == SVCCTL_STOPPED ? True : False;
9700 void lp_set_spoolss_state( uint32 state )
9702 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9704 spoolss_state = state;
9707 uint32 lp_get_spoolss_state( void )
9709 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9712 /*******************************************************************
9713 Ensure we don't use sendfile if server smb signing is active.
9714 ********************************************************************/
9716 bool lp_use_sendfile(int snum, enum protocol_types proto,
9717 struct smb_signing_state *signing_state)
9719 bool sign_active = false;
9721 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9722 if (proto < PROTOCOL_NT1) {
9725 if (signing_state) {
9726 sign_active = smb_signing_is_active(signing_state);
9728 return (_lp_use_sendfile(snum) &&
9729 (get_remote_arch() != RA_WIN95) &&
9733 /*******************************************************************
9734 Turn off sendfile if we find the underlying OS doesn't support it.
9735 ********************************************************************/
9737 void set_use_sendfile(int snum, bool val)
9739 if (LP_SNUM_OK(snum))
9740 ServicePtrs[snum]->bUseSendfile = val;
9742 sDefault.bUseSendfile = val;
9745 /*******************************************************************
9746 Turn off storing DOS attributes if this share doesn't support it.
9747 ********************************************************************/
9749 void set_store_dos_attributes(int snum, bool val)
9751 if (!LP_SNUM_OK(snum))
9753 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9756 void lp_set_mangling_method(const char *new_method)
9758 string_set(&Globals.szManglingMethod, new_method);
9761 /*******************************************************************
9762 Global state for POSIX pathname processing.
9763 ********************************************************************/
9765 static bool posix_pathnames;
9767 bool lp_posix_pathnames(void)
9769 return posix_pathnames;
9772 /*******************************************************************
9773 Change everything needed to ensure POSIX pathname processing (currently
9775 ********************************************************************/
9777 void lp_set_posix_pathnames(void)
9779 posix_pathnames = True;
9782 /*******************************************************************
9783 Global state for POSIX lock processing - CIFS unix extensions.
9784 ********************************************************************/
9786 bool posix_default_lock_was_set;
9787 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9789 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9791 if (posix_default_lock_was_set) {
9792 return posix_cifsx_locktype;
9794 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9798 /*******************************************************************
9799 ********************************************************************/
9801 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9803 posix_default_lock_was_set = True;
9804 posix_cifsx_locktype = val;
9807 int lp_min_receive_file_size(void)
9809 if (Globals.iminreceivefile < 0) {
9812 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9815 /*******************************************************************
9816 If socket address is an empty character string, it is necessary to
9817 define it as "0.0.0.0".
9818 ********************************************************************/
9820 const char *lp_socket_address(void)
9822 char *sock_addr = Globals.szSocketAddress;
9824 if (sock_addr[0] == '\0'){
9825 string_set(&Globals.szSocketAddress, "0.0.0.0");
9827 return Globals.szSocketAddress;
9830 void lp_set_passdb_backend(const char *backend)
9832 string_set(&Globals.szPassdbBackend, backend);