2 Unix SMB/CIFS implementation.
3 Parameter loading functions
4 Copyright (C) Karl Auer 1993-1998
6 Largely re-written by Andrew Tridgell, September 1994
8 Copyright (C) Simo Sorce 2001
9 Copyright (C) Alexander Bokovoy 2002
10 Copyright (C) Stefan (metze) Metzmacher 2002
11 Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
12 Copyright (C) Michael Adam 2008
13 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
14 Copyright (C) Andrew Bartlett 2011
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 3 of the License, or
19 (at your option) any later version.
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program. If not, see <http://www.gnu.org/licenses/>.
33 * This module provides suitable callback functions for the params
34 * module. It builds the internal table of service details which is
35 * then used by the rest of the server.
39 * 1) add it to the global or service structure definition
40 * 2) add it to the parm_table
41 * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
42 * 4) If it's a global then initialise it in init_globals. If a local
43 * (ie. service) parameter then initialise it in the sDefault structure
47 * The configuration file is processed sequentially for speed. It is NOT
48 * accessed randomly as happens in 'real' Windows. For this reason, there
49 * is a fair bit of sequence-dependent code here - ie., code which assumes
50 * that certain things happen before others. In particular, the code which
51 * happens at the boundary between sections is delicately poised, so be
57 #include "system/filesys.h"
60 #include "lib/smbconf/smbconf.h"
61 #include "lib/smbconf/smbconf_init.h"
62 #include "lib/param/loadparm.h"
65 #include "../librpc/gen_ndr/svcctl.h"
67 #include "../libcli/smb/smb_signing.h"
68 #include "dbwrap/dbwrap.h"
69 #include "dbwrap/dbwrap_rbt.h"
70 #include "../lib/util/bitmap.h"
71 #include "../source4/dns_server/dns_update.h"
73 #ifdef HAVE_SYS_SYSCTL_H
74 #include <sys/sysctl.h>
77 #ifdef HAVE_HTTPCONNECTENCRYPT
78 #include <cups/http.h>
81 #ifdef CLUSTER_SUPPORT
82 #include "ctdb_private.h"
87 extern userdom_struct current_user_info
;
89 /* the special value for the include parameter
90 * to be interpreted not as a file name but to
91 * trigger loading of the global smb.conf options
93 #ifndef INCLUDE_REGISTRY_NAME
94 #define INCLUDE_REGISTRY_NAME "registry"
97 static bool in_client
= false; /* Not in the client by default */
98 static struct smbconf_csn conf_last_csn
;
100 #define CONFIG_BACKEND_FILE 0
101 #define CONFIG_BACKEND_REGISTRY 1
103 static int config_backend
= CONFIG_BACKEND_FILE
;
105 /* some helpful bits */
106 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
107 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
109 #define USERSHARE_VALID 1
110 #define USERSHARE_PENDING_DELETE 2
112 static bool defaults_saved
= false;
114 #define LOADPARM_EXTRA_GLOBALS \
115 struct parmlist_entry *param_opt; \
118 int iminreceivefile; \
119 char *szPrintcapname; \
121 int iPreferredMaster; \
123 char *szLdapMachineSuffix; \
124 char *szLdapUserSuffix; \
125 char *szLdapIdmapSuffix; \
126 char *szLdapGroupSuffix; \
129 char *szSocketAddress; \
130 char *szUsershareTemplateShare; \
133 int winbindMaxDomainConnections; \
134 int ismb2_max_credits; \
136 char *tls_certfile; \
140 char *panic_action; \
141 int bPreferredMaster;
143 #include "param/param_global.h"
145 static struct loadparm_global Globals
;
147 /* This is a default service used to prime a services structure */
148 static struct loadparm_service sDefault
=
153 .usershare_last_mod
= {0, 0},
157 .szInvalidUsers
= NULL
,
158 .szValidUsers
= NULL
,
159 .szAdminUsers
= NULL
,
164 .szRootPreExec
= NULL
,
165 .szRootPostExec
= NULL
,
166 .szCupsOptions
= NULL
,
167 .szPrintcommand
= NULL
,
168 .szLpqcommand
= NULL
,
169 .szLprmcommand
= NULL
,
170 .szLppausecommand
= NULL
,
171 .szLpresumecommand
= NULL
,
172 .szQueuepausecommand
= NULL
,
173 .szQueueresumecommand
= NULL
,
174 .szPrintername
= NULL
,
175 .szPrintjobUsername
= NULL
,
176 .szDontdescend
= NULL
,
177 .szHostsallow
= NULL
,
179 .szMagicScript
= NULL
,
180 .szMagicOutput
= NULL
,
183 .szVetoOplockFiles
= NULL
,
191 .szVfsObjects
= NULL
,
192 .szMSDfsProxy
= NULL
,
193 .szAioWriteBehind
= NULL
,
196 .iMaxPrintJobs
= 1000,
197 .iMaxReportedPrintJobs
= 0,
198 .iWriteCacheSize
= 0,
199 .iCreate_mask
= 0744,
200 .iCreate_force_mode
= 0,
201 .iSecurity_mask
= 0777,
202 .iSecurity_force_mode
= 0,
204 .iDir_force_mode
= 0,
205 .iDir_Security_mask
= 0777,
206 .iDir_Security_force_mode
= 0,
207 .iMaxConnections
= 0,
208 .iDefaultCase
= CASE_LOWER
,
209 .iPrinting
= DEFAULT_PRINTING
,
210 .iOplockContentionLimit
= 2,
213 .iDfreeCacheTime
= 0,
214 .bPreexecClose
= false,
215 .bRootpreexecClose
= false,
216 .iCaseSensitive
= Auto
,
217 .bCasePreserve
= true,
218 .bShortCasePreserve
= true,
219 .bHideDotFiles
= true,
220 .bHideSpecialFiles
= false,
221 .bHideUnReadable
= false,
222 .bHideUnWriteableFiles
= false,
224 .bAccessBasedShareEnum
= false,
228 .bGuest_only
= false,
229 .bAdministrative_share
= false,
232 .bPrintNotifyBackchannel
= true,
233 .bMap_system
= false,
234 .bMap_hidden
= false,
235 .bMap_archive
= true,
236 .bStoreDosAttributes
= false,
237 .bDmapiSupport
= false,
239 .iStrictLocking
= Auto
,
240 .bPosixLocking
= true,
243 .bKernelOplocks
= false,
244 .bLevel2OpLocks
= true,
246 .bMangledNames
= true,
249 .bSyncAlways
= false,
250 .bStrictAllocate
= false,
251 .bStrictSync
= false,
254 .bDeleteReadonly
= false,
255 .bFakeOplocks
= false,
256 .bDeleteVetoFiles
= false,
257 .bDosFilemode
= false,
258 .bDosFiletimes
= true,
259 .bDosFiletimeResolution
= false,
260 .bFakeDirCreateTimes
= false,
261 .bBlockingLocks
= true,
262 .bInheritPerms
= false,
263 .bInheritACLS
= false,
264 .bInheritOwner
= false,
266 .bUseClientDriver
= false,
267 .bDefaultDevmode
= true,
268 .bForcePrintername
= false,
269 .bNTAclSupport
= true,
270 .bForceUnknownAclUser
= false,
271 .bUseSendfile
= false,
272 .bProfileAcls
= false,
273 .bMap_acl_inherit
= false,
276 .bAclCheckPermissions
= true,
277 .bAclMapFullControl
= true,
278 .bAclGroupControl
= false,
279 .bChangeNotify
= true,
280 .bKernelChangeNotify
= true,
281 .iallocation_roundup_size
= SMB_ROUNDUP_ALLOCATION_SIZE
,
284 .iMap_readonly
= MAP_READONLY_YES
,
285 #ifdef BROKEN_DIRECTORY_HANDLING
286 .iDirectoryNameCacheSize
= 0,
288 .iDirectoryNameCacheSize
= 100,
290 .ismb_encrypt
= Auto
,
295 /* local variables */
296 static struct loadparm_service
**ServicePtrs
= NULL
;
297 static int iNumServices
= 0;
298 static int iServiceIndex
= 0;
299 static struct db_context
*ServiceHash
;
300 static int *invalid_services
= NULL
;
301 static int num_invalid_services
= 0;
302 static bool bInGlobalSection
= true;
303 static bool bGlobalOnly
= false;
305 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
307 /* prototypes for the special type handlers */
308 static bool handle_include(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
);
309 static bool handle_copy(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
);
310 static bool handle_idmap_backend(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
);
311 static bool handle_idmap_uid(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
);
312 static bool handle_idmap_gid(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
);
313 static bool handle_debug_list(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
);
314 static bool handle_realm(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
);
315 static bool handle_netbios_aliases(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
);
316 static bool handle_charset(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
);
317 static bool handle_dos_charset(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
);
318 static bool handle_printing(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
);
319 static bool handle_ldap_debug_level(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
);
321 static void set_allowed_client_auth(void);
323 static void add_to_file_list(const char *fname
, const char *subfname
);
324 static bool lp_set_cmdline_helper(const char *pszParmName
, const char *pszParmValue
, bool store_values
);
325 static void free_param_opts(struct parmlist_entry
**popts
);
327 #include "lib/param/param_table.c"
329 static const struct enum_list enum_printing
[] = {
330 {PRINT_SYSV
, "sysv"},
332 {PRINT_HPUX
, "hpux"},
336 {PRINT_LPRNG
, "lprng"},
337 {PRINT_CUPS
, "cups"},
338 {PRINT_IPRINT
, "iprint"},
340 {PRINT_LPROS2
, "os2"},
341 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
342 {PRINT_TEST
, "test"},
344 #endif /* DEVELOPER */
348 static const struct enum_list enum_ldap_sasl_wrapping
[] = {
350 {ADS_AUTH_SASL_SIGN
, "sign"},
351 {ADS_AUTH_SASL_SEAL
, "seal"},
355 static const struct enum_list enum_ldap_ssl
[] = {
356 {LDAP_SSL_OFF
, "no"},
357 {LDAP_SSL_OFF
, "off"},
358 {LDAP_SSL_START_TLS
, "start tls"},
359 {LDAP_SSL_START_TLS
, "start_tls"},
363 /* LDAP Dereferencing Alias types */
364 #define SAMBA_LDAP_DEREF_NEVER 0
365 #define SAMBA_LDAP_DEREF_SEARCHING 1
366 #define SAMBA_LDAP_DEREF_FINDING 2
367 #define SAMBA_LDAP_DEREF_ALWAYS 3
369 static const struct enum_list enum_ldap_deref
[] = {
370 {SAMBA_LDAP_DEREF_NEVER
, "never"},
371 {SAMBA_LDAP_DEREF_SEARCHING
, "searching"},
372 {SAMBA_LDAP_DEREF_FINDING
, "finding"},
373 {SAMBA_LDAP_DEREF_ALWAYS
, "always"},
377 static const struct enum_list enum_ldap_passwd_sync
[] = {
378 {LDAP_PASSWD_SYNC_OFF
, "no"},
379 {LDAP_PASSWD_SYNC_OFF
, "off"},
380 {LDAP_PASSWD_SYNC_ON
, "yes"},
381 {LDAP_PASSWD_SYNC_ON
, "on"},
382 {LDAP_PASSWD_SYNC_ONLY
, "only"},
386 static const struct enum_list enum_map_readonly
[] = {
387 {MAP_READONLY_NO
, "no"},
388 {MAP_READONLY_NO
, "false"},
389 {MAP_READONLY_NO
, "0"},
390 {MAP_READONLY_YES
, "yes"},
391 {MAP_READONLY_YES
, "true"},
392 {MAP_READONLY_YES
, "1"},
393 {MAP_READONLY_PERMISSIONS
, "permissions"},
394 {MAP_READONLY_PERMISSIONS
, "perms"},
398 static const struct enum_list enum_case
[] = {
399 {CASE_LOWER
, "lower"},
400 {CASE_UPPER
, "upper"},
405 /* ACL compatibility options. */
406 static const struct enum_list enum_acl_compat_vals
[] = {
407 { ACL_COMPAT_AUTO
, "auto" },
408 { ACL_COMPAT_WINNT
, "winnt" },
409 { ACL_COMPAT_WIN2K
, "win2k" },
414 Do you want session setups at user level security with a invalid
415 password to be rejected or allowed in as guest? WinNT rejects them
416 but it can be a pain as it means "net view" needs to use a password
418 You have 3 choices in the setting of map_to_guest:
420 "Never" means session setups with an invalid password
421 are rejected. This is the default.
423 "Bad User" means session setups with an invalid password
424 are rejected, unless the username does not exist, in which case it
425 is treated as a guest login
427 "Bad Password" means session setups with an invalid password
428 are treated as a guest login
430 Note that map_to_guest only has an effect in user or server
434 static const struct enum_list enum_map_to_guest
[] = {
435 {NEVER_MAP_TO_GUEST
, "Never"},
436 {MAP_TO_GUEST_ON_BAD_USER
, "Bad User"},
437 {MAP_TO_GUEST_ON_BAD_PASSWORD
, "Bad Password"},
438 {MAP_TO_GUEST_ON_BAD_UID
, "Bad Uid"},
442 /* Config backend options */
444 static const struct enum_list enum_config_backend
[] = {
445 {CONFIG_BACKEND_FILE
, "file"},
446 {CONFIG_BACKEND_REGISTRY
, "registry"},
450 /* ADS kerberos ticket verification options */
452 static const struct enum_list enum_kerberos_method
[] = {
453 {KERBEROS_VERIFY_SECRETS
, "default"},
454 {KERBEROS_VERIFY_SECRETS
, "secrets only"},
455 {KERBEROS_VERIFY_SYSTEM_KEYTAB
, "system keytab"},
456 {KERBEROS_VERIFY_DEDICATED_KEYTAB
, "dedicated keytab"},
457 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB
, "secrets and keytab"},
461 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
463 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
464 * screen in SWAT. This is used to exclude parameters as well as to squash all
465 * parameters that have been duplicated by pseudonyms.
467 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
468 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
469 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
472 * NOTE2: Handling of duplicated (synonym) parameters:
473 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
474 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
475 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
476 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
479 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
480 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
483 static struct parm_struct parm_table
[] = {
484 {N_("Base Options"), P_SEP
, P_SEPARATOR
},
487 .label
= "dos charset",
490 .offset
= GLOBAL_VAR(dos_charset
),
491 .special
= handle_dos_charset
,
493 .flags
= FLAG_ADVANCED
496 .label
= "unix charset",
499 .offset
= GLOBAL_VAR(unix_charset
),
500 .special
= handle_charset
,
502 .flags
= FLAG_ADVANCED
508 .offset
= LOCAL_VAR(comment
),
511 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
517 .offset
= LOCAL_VAR(szPath
),
520 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
523 .label
= "directory",
526 .offset
= LOCAL_VAR(szPath
),
532 .label
= "workgroup",
535 .offset
= GLOBAL_VAR(szWorkgroup
),
538 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
544 .offset
= GLOBAL_VAR(szRealm
),
545 .special
= handle_realm
,
547 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
550 .label
= "netbios name",
553 .offset
= GLOBAL_VAR(szNetbiosName
),
556 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
559 .label
= "netbios aliases",
562 .offset
= GLOBAL_VAR(szNetbiosAliases
),
563 .special
= handle_netbios_aliases
,
565 .flags
= FLAG_ADVANCED
,
568 .label
= "netbios scope",
571 .offset
= GLOBAL_VAR(szNetbiosScope
),
574 .flags
= FLAG_ADVANCED
,
577 .label
= "server string",
580 .offset
= GLOBAL_VAR(szServerString
),
583 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
586 .label
= "interfaces",
589 .offset
= GLOBAL_VAR(szInterfaces
),
592 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
595 .label
= "bind interfaces only",
598 .offset
= GLOBAL_VAR(bBindInterfacesOnly
),
601 .flags
= FLAG_ADVANCED
| FLAG_WIZARD
,
604 .label
= "config backend",
607 .offset
= GLOBAL_VAR(ConfigBackend
),
609 .enum_list
= enum_config_backend
,
610 .flags
= FLAG_HIDE
|FLAG_ADVANCED
|FLAG_META
,
613 .label
= "server role",
616 .offset
= GLOBAL_VAR(server_role
),
618 .enum_list
= enum_server_role
,
619 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
622 {N_("Security Options"), P_SEP
, P_SEPARATOR
},
628 .offset
= GLOBAL_VAR(security
),
630 .enum_list
= enum_security
,
631 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
634 .label
= "auth methods",
637 .offset
= GLOBAL_VAR(AuthMethods
),
640 .flags
= FLAG_ADVANCED
,
643 .label
= "encrypt passwords",
646 .offset
= GLOBAL_VAR(bEncryptPasswords
),
649 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
652 .label
= "client schannel",
655 .offset
= GLOBAL_VAR(clientSchannel
),
657 .enum_list
= enum_bool_auto
,
658 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
661 .label
= "server schannel",
664 .offset
= GLOBAL_VAR(serverSchannel
),
666 .enum_list
= enum_bool_auto
,
667 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
670 .label
= "allow trusted domains",
673 .offset
= GLOBAL_VAR(bAllowTrustedDomains
),
676 .flags
= FLAG_ADVANCED
,
679 .label
= "map to guest",
682 .offset
= GLOBAL_VAR(map_to_guest
),
684 .enum_list
= enum_map_to_guest
,
685 .flags
= FLAG_ADVANCED
,
688 .label
= "null passwords",
691 .offset
= GLOBAL_VAR(bNullPasswords
),
694 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
697 .label
= "obey pam restrictions",
700 .offset
= GLOBAL_VAR(bObeyPamRestrictions
),
703 .flags
= FLAG_ADVANCED
,
706 .label
= "password server",
709 .offset
= GLOBAL_VAR(szPasswordServer
),
712 .flags
= FLAG_ADVANCED
| FLAG_WIZARD
,
715 .label
= "smb passwd file",
718 .offset
= GLOBAL_VAR(szSMBPasswdFile
),
721 .flags
= FLAG_ADVANCED
,
724 .label
= "private dir",
727 .offset
= GLOBAL_VAR(szPrivateDir
),
730 .flags
= FLAG_ADVANCED
,
733 .label
= "private directory",
736 .offset
= GLOBAL_VAR(szPrivateDir
),
742 .label
= "passdb backend",
745 .offset
= GLOBAL_VAR(passdb_backend
),
748 .flags
= FLAG_ADVANCED
| FLAG_WIZARD
,
751 .label
= "algorithmic rid base",
754 .offset
= GLOBAL_VAR(AlgorithmicRidBase
),
757 .flags
= FLAG_ADVANCED
,
760 .label
= "root directory",
763 .offset
= GLOBAL_VAR(szRootdir
),
766 .flags
= FLAG_ADVANCED
,
772 .offset
= GLOBAL_VAR(szRootdir
),
781 .offset
= GLOBAL_VAR(szRootdir
),
787 .label
= "guest account",
790 .offset
= GLOBAL_VAR(szGuestaccount
),
793 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
796 .label
= "enable privileges",
799 .offset
= GLOBAL_VAR(bEnablePrivileges
),
802 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
806 .label
= "pam password change",
809 .offset
= GLOBAL_VAR(bPamPasswordChange
),
812 .flags
= FLAG_ADVANCED
,
815 .label
= "passwd program",
818 .offset
= GLOBAL_VAR(szPasswdProgram
),
821 .flags
= FLAG_ADVANCED
,
824 .label
= "passwd chat",
827 .offset
= GLOBAL_VAR(szPasswdChat
),
830 .flags
= FLAG_ADVANCED
,
833 .label
= "passwd chat debug",
836 .offset
= GLOBAL_VAR(bPasswdChatDebug
),
839 .flags
= FLAG_ADVANCED
,
842 .label
= "passwd chat timeout",
845 .offset
= GLOBAL_VAR(iPasswdChatTimeout
),
848 .flags
= FLAG_ADVANCED
,
851 .label
= "check password script",
854 .offset
= GLOBAL_VAR(szCheckPasswordScript
),
857 .flags
= FLAG_ADVANCED
,
860 .label
= "username map",
863 .offset
= GLOBAL_VAR(szUsernameMap
),
866 .flags
= FLAG_ADVANCED
,
869 .label
= "password level",
872 .offset
= GLOBAL_VAR(pwordlevel
),
875 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
878 .label
= "username level",
881 .offset
= GLOBAL_VAR(unamelevel
),
884 .flags
= FLAG_ADVANCED
,
887 .label
= "unix password sync",
890 .offset
= GLOBAL_VAR(bUnixPasswdSync
),
893 .flags
= FLAG_ADVANCED
,
896 .label
= "restrict anonymous",
899 .offset
= GLOBAL_VAR(restrict_anonymous
),
902 .flags
= FLAG_ADVANCED
,
905 .label
= "lanman auth",
908 .offset
= GLOBAL_VAR(bLanmanAuth
),
911 .flags
= FLAG_ADVANCED
,
914 .label
= "ntlm auth",
917 .offset
= GLOBAL_VAR(bNTLMAuth
),
920 .flags
= FLAG_ADVANCED
,
923 .label
= "client NTLMv2 auth",
926 .offset
= GLOBAL_VAR(bClientNTLMv2Auth
),
929 .flags
= FLAG_ADVANCED
,
932 .label
= "client lanman auth",
935 .offset
= GLOBAL_VAR(bClientLanManAuth
),
938 .flags
= FLAG_ADVANCED
,
941 .label
= "client plaintext auth",
944 .offset
= GLOBAL_VAR(bClientPlaintextAuth
),
947 .flags
= FLAG_ADVANCED
,
950 .label
= "client use spnego principal",
953 .offset
= GLOBAL_VAR(client_use_spnego_principal
),
956 .flags
= FLAG_ADVANCED
,
962 .offset
= LOCAL_VAR(szUsername
),
965 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
| FLAG_DEPRECATED
,
971 .offset
= LOCAL_VAR(szUsername
),
980 .offset
= LOCAL_VAR(szUsername
),
986 .label
= "invalid users",
989 .offset
= LOCAL_VAR(szInvalidUsers
),
992 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
995 .label
= "valid users",
998 .offset
= LOCAL_VAR(szValidUsers
),
1001 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1004 .label
= "admin users",
1007 .offset
= LOCAL_VAR(szAdminUsers
),
1010 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1013 .label
= "read list",
1016 .offset
= LOCAL_VAR(readlist
),
1019 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1022 .label
= "write list",
1025 .offset
= LOCAL_VAR(writelist
),
1028 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1031 .label
= "force user",
1034 .offset
= LOCAL_VAR(force_user
),
1037 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1040 .label
= "force group",
1043 .offset
= LOCAL_VAR(force_group
),
1046 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1052 .offset
= LOCAL_VAR(force_group
),
1055 .flags
= FLAG_ADVANCED
,
1058 .label
= "read only",
1061 .offset
= LOCAL_VAR(bRead_only
),
1064 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
,
1067 .label
= "write ok",
1070 .offset
= LOCAL_VAR(bRead_only
),
1076 .label
= "writeable",
1079 .offset
= LOCAL_VAR(bRead_only
),
1085 .label
= "writable",
1088 .offset
= LOCAL_VAR(bRead_only
),
1094 .label
= "acl check permissions",
1097 .offset
= LOCAL_VAR(bAclCheckPermissions
),
1100 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
| FLAG_DEPRECATED
,
1103 .label
= "acl group control",
1106 .offset
= LOCAL_VAR(bAclGroupControl
),
1109 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1112 .label
= "acl map full control",
1115 .offset
= LOCAL_VAR(bAclMapFullControl
),
1118 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1121 .label
= "create mask",
1124 .offset
= LOCAL_VAR(iCreate_mask
),
1127 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1130 .label
= "create mode",
1133 .offset
= LOCAL_VAR(iCreate_mask
),
1139 .label
= "force create mode",
1142 .offset
= LOCAL_VAR(iCreate_force_mode
),
1145 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1148 .label
= "security mask",
1151 .offset
= LOCAL_VAR(iSecurity_mask
),
1154 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1157 .label
= "force security mode",
1160 .offset
= LOCAL_VAR(iSecurity_force_mode
),
1163 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1166 .label
= "directory mask",
1169 .offset
= LOCAL_VAR(iDir_mask
),
1172 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1175 .label
= "directory mode",
1178 .offset
= LOCAL_VAR(iDir_mask
),
1181 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
1184 .label
= "force directory mode",
1187 .offset
= LOCAL_VAR(iDir_force_mode
),
1190 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1193 .label
= "directory security mask",
1196 .offset
= LOCAL_VAR(iDir_Security_mask
),
1199 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1202 .label
= "force directory security mode",
1205 .offset
= LOCAL_VAR(iDir_Security_force_mode
),
1208 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1211 .label
= "force unknown acl user",
1214 .offset
= LOCAL_VAR(bForceUnknownAclUser
),
1217 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1220 .label
= "inherit permissions",
1223 .offset
= LOCAL_VAR(bInheritPerms
),
1226 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1229 .label
= "inherit acls",
1232 .offset
= LOCAL_VAR(bInheritACLS
),
1235 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1238 .label
= "inherit owner",
1241 .offset
= LOCAL_VAR(bInheritOwner
),
1244 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1247 .label
= "guest only",
1250 .offset
= LOCAL_VAR(bGuest_only
),
1253 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1256 .label
= "only guest",
1259 .offset
= LOCAL_VAR(bGuest_only
),
1265 .label
= "administrative share",
1268 .offset
= LOCAL_VAR(bAdministrative_share
),
1271 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
1275 .label
= "guest ok",
1278 .offset
= LOCAL_VAR(bGuest_ok
),
1281 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
1287 .offset
= LOCAL_VAR(bGuest_ok
),
1293 .label
= "only user",
1296 .offset
= LOCAL_VAR(bOnlyUser
),
1299 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_DEPRECATED
,
1302 .label
= "hosts allow",
1305 .offset
= LOCAL_VAR(szHostsallow
),
1308 .flags
= FLAG_GLOBAL
| FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
1311 .label
= "allow hosts",
1314 .offset
= LOCAL_VAR(szHostsallow
),
1320 .label
= "hosts deny",
1323 .offset
= LOCAL_VAR(szHostsdeny
),
1326 .flags
= FLAG_GLOBAL
| FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
1329 .label
= "deny hosts",
1332 .offset
= LOCAL_VAR(szHostsdeny
),
1338 .label
= "preload modules",
1340 .p_class
= P_GLOBAL
,
1341 .offset
= GLOBAL_VAR(szPreloadModules
),
1344 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
1347 .label
= "dedicated keytab file",
1349 .p_class
= P_GLOBAL
,
1350 .offset
= GLOBAL_VAR(szDedicatedKeytabFile
),
1353 .flags
= FLAG_ADVANCED
,
1356 .label
= "kerberos method",
1358 .p_class
= P_GLOBAL
,
1359 .offset
= GLOBAL_VAR(iKerberosMethod
),
1361 .enum_list
= enum_kerberos_method
,
1362 .flags
= FLAG_ADVANCED
,
1365 .label
= "map untrusted to domain",
1367 .p_class
= P_GLOBAL
,
1368 .offset
= GLOBAL_VAR(bMapUntrustedToDomain
),
1371 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
1375 {N_("Logging Options"), P_SEP
, P_SEPARATOR
},
1378 .label
= "log level",
1380 .p_class
= P_GLOBAL
,
1381 .offset
= GLOBAL_VAR(loglevel
),
1382 .special
= handle_debug_list
,
1384 .flags
= FLAG_ADVANCED
,
1387 .label
= "debuglevel",
1389 .p_class
= P_GLOBAL
,
1390 .offset
= GLOBAL_VAR(loglevel
),
1391 .special
= handle_debug_list
,
1398 .p_class
= P_GLOBAL
,
1399 .offset
= GLOBAL_VAR(syslog
),
1402 .flags
= FLAG_ADVANCED
,
1405 .label
= "syslog only",
1407 .p_class
= P_GLOBAL
,
1408 .offset
= GLOBAL_VAR(bSyslogOnly
),
1411 .flags
= FLAG_ADVANCED
,
1414 .label
= "log file",
1416 .p_class
= P_GLOBAL
,
1417 .offset
= GLOBAL_VAR(logfile
),
1420 .flags
= FLAG_ADVANCED
,
1423 .label
= "max log size",
1425 .p_class
= P_GLOBAL
,
1426 .offset
= GLOBAL_VAR(max_log_size
),
1429 .flags
= FLAG_ADVANCED
,
1432 .label
= "debug timestamp",
1434 .p_class
= P_GLOBAL
,
1435 .offset
= GLOBAL_VAR(bTimestampLogs
),
1438 .flags
= FLAG_ADVANCED
,
1441 .label
= "timestamp logs",
1443 .p_class
= P_GLOBAL
,
1444 .offset
= GLOBAL_VAR(bTimestampLogs
),
1447 .flags
= FLAG_ADVANCED
,
1450 .label
= "debug prefix timestamp",
1452 .p_class
= P_GLOBAL
,
1453 .offset
= GLOBAL_VAR(bDebugPrefixTimestamp
),
1456 .flags
= FLAG_ADVANCED
,
1459 .label
= "debug hires timestamp",
1461 .p_class
= P_GLOBAL
,
1462 .offset
= GLOBAL_VAR(bDebugHiresTimestamp
),
1465 .flags
= FLAG_ADVANCED
,
1468 .label
= "debug pid",
1470 .p_class
= P_GLOBAL
,
1471 .offset
= GLOBAL_VAR(bDebugPid
),
1474 .flags
= FLAG_ADVANCED
,
1477 .label
= "debug uid",
1479 .p_class
= P_GLOBAL
,
1480 .offset
= GLOBAL_VAR(bDebugUid
),
1483 .flags
= FLAG_ADVANCED
,
1486 .label
= "debug class",
1488 .p_class
= P_GLOBAL
,
1489 .offset
= GLOBAL_VAR(bDebugClass
),
1492 .flags
= FLAG_ADVANCED
,
1495 .label
= "enable core files",
1497 .p_class
= P_GLOBAL
,
1498 .offset
= GLOBAL_VAR(bEnableCoreFiles
),
1501 .flags
= FLAG_ADVANCED
,
1504 {N_("Protocol Options"), P_SEP
, P_SEPARATOR
},
1507 .label
= "allocation roundup size",
1510 .offset
= LOCAL_VAR(iallocation_roundup_size
),
1513 .flags
= FLAG_ADVANCED
,
1516 .label
= "aio read size",
1519 .offset
= LOCAL_VAR(iAioReadSize
),
1522 .flags
= FLAG_ADVANCED
,
1525 .label
= "aio write size",
1528 .offset
= LOCAL_VAR(iAioWriteSize
),
1531 .flags
= FLAG_ADVANCED
,
1534 .label
= "aio write behind",
1537 .offset
= LOCAL_VAR(szAioWriteBehind
),
1540 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1543 .label
= "smb ports",
1545 .p_class
= P_GLOBAL
,
1546 .offset
= GLOBAL_VAR(smb_ports
),
1549 .flags
= FLAG_ADVANCED
,
1552 .label
= "large readwrite",
1554 .p_class
= P_GLOBAL
,
1555 .offset
= GLOBAL_VAR(bLargeReadwrite
),
1558 .flags
= FLAG_ADVANCED
,
1561 .label
= "server max protocol",
1563 .p_class
= P_GLOBAL
,
1564 .offset
= GLOBAL_VAR(srv_maxprotocol
),
1566 .enum_list
= enum_protocol
,
1567 .flags
= FLAG_ADVANCED
,
1570 .label
= "max protocol",
1572 .p_class
= P_GLOBAL
,
1573 .offset
= GLOBAL_VAR(srv_maxprotocol
),
1575 .enum_list
= enum_protocol
,
1576 .flags
= FLAG_ADVANCED
,
1579 .label
= "protocol",
1581 .p_class
= P_GLOBAL
,
1582 .offset
= GLOBAL_VAR(srv_maxprotocol
),
1584 .enum_list
= enum_protocol
,
1585 .flags
= FLAG_ADVANCED
,
1588 .label
= "server min protocol",
1590 .p_class
= P_GLOBAL
,
1591 .offset
= GLOBAL_VAR(srv_minprotocol
),
1593 .enum_list
= enum_protocol
,
1594 .flags
= FLAG_ADVANCED
,
1597 .label
= "min protocol",
1599 .p_class
= P_GLOBAL
,
1600 .offset
= GLOBAL_VAR(srv_minprotocol
),
1602 .enum_list
= enum_protocol
,
1603 .flags
= FLAG_ADVANCED
,
1606 .label
= "client max protocol",
1608 .p_class
= P_GLOBAL
,
1609 .offset
= GLOBAL_VAR(cli_maxprotocol
),
1611 .enum_list
= enum_protocol
,
1612 .flags
= FLAG_ADVANCED
,
1615 .label
= "client min protocol",
1617 .p_class
= P_GLOBAL
,
1618 .offset
= GLOBAL_VAR(cli_minprotocol
),
1620 .enum_list
= enum_protocol
,
1621 .flags
= FLAG_ADVANCED
,
1626 .p_class
= P_GLOBAL
,
1627 .offset
= GLOBAL_VAR(bUnicode
),
1632 .label
= "min receivefile size",
1634 .p_class
= P_GLOBAL
,
1635 .offset
= GLOBAL_VAR(iminreceivefile
),
1638 .flags
= FLAG_ADVANCED
,
1641 .label
= "read raw",
1643 .p_class
= P_GLOBAL
,
1644 .offset
= GLOBAL_VAR(bReadRaw
),
1647 .flags
= FLAG_ADVANCED
,
1650 .label
= "write raw",
1652 .p_class
= P_GLOBAL
,
1653 .offset
= GLOBAL_VAR(bWriteRaw
),
1656 .flags
= FLAG_ADVANCED
,
1659 .label
= "disable netbios",
1661 .p_class
= P_GLOBAL
,
1662 .offset
= GLOBAL_VAR(bDisableNetbios
),
1665 .flags
= FLAG_ADVANCED
,
1668 .label
= "reset on zero vc",
1670 .p_class
= P_GLOBAL
,
1671 .offset
= GLOBAL_VAR(bResetOnZeroVC
),
1674 .flags
= FLAG_ADVANCED
,
1677 .label
= "log writeable files on exit",
1679 .p_class
= P_GLOBAL
,
1680 .offset
= GLOBAL_VAR(bLogWriteableFilesOnExit
),
1683 .flags
= FLAG_ADVANCED
,
1686 .label
= "acl compatibility",
1688 .p_class
= P_GLOBAL
,
1689 .offset
= GLOBAL_VAR(iAclCompat
),
1691 .enum_list
= enum_acl_compat_vals
,
1692 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1695 .label
= "defer sharing violations",
1697 .p_class
= P_GLOBAL
,
1698 .offset
= GLOBAL_VAR(bDeferSharingViolations
),
1701 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
1704 .label
= "ea support",
1707 .offset
= LOCAL_VAR(bEASupport
),
1710 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1713 .label
= "nt acl support",
1716 .offset
= LOCAL_VAR(bNTAclSupport
),
1719 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1722 .label
= "nt pipe support",
1724 .p_class
= P_GLOBAL
,
1725 .offset
= GLOBAL_VAR(bNTPipeSupport
),
1728 .flags
= FLAG_ADVANCED
,
1731 .label
= "nt status support",
1733 .p_class
= P_GLOBAL
,
1734 .offset
= GLOBAL_VAR(bNTStatusSupport
),
1737 .flags
= FLAG_ADVANCED
,
1740 .label
= "profile acls",
1743 .offset
= LOCAL_VAR(bProfileAcls
),
1746 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1749 .label
= "map acl inherit",
1752 .offset
= LOCAL_VAR(bMap_acl_inherit
),
1755 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1758 .label
= "afs share",
1761 .offset
= LOCAL_VAR(bAfs_Share
),
1764 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1769 .p_class
= P_GLOBAL
,
1770 .offset
= GLOBAL_VAR(max_mux
),
1773 .flags
= FLAG_ADVANCED
,
1776 .label
= "max xmit",
1778 .p_class
= P_GLOBAL
,
1779 .offset
= GLOBAL_VAR(max_xmit
),
1782 .flags
= FLAG_ADVANCED
,
1785 .label
= "name resolve order",
1787 .p_class
= P_GLOBAL
,
1788 .offset
= GLOBAL_VAR(szNameResolveOrder
),
1791 .flags
= FLAG_ADVANCED
| FLAG_WIZARD
,
1796 .p_class
= P_GLOBAL
,
1797 .offset
= GLOBAL_VAR(max_ttl
),
1800 .flags
= FLAG_ADVANCED
,
1803 .label
= "max wins ttl",
1805 .p_class
= P_GLOBAL
,
1806 .offset
= GLOBAL_VAR(max_wins_ttl
),
1809 .flags
= FLAG_ADVANCED
,
1812 .label
= "min wins ttl",
1814 .p_class
= P_GLOBAL
,
1815 .offset
= GLOBAL_VAR(min_wins_ttl
),
1818 .flags
= FLAG_ADVANCED
,
1821 .label
= "time server",
1823 .p_class
= P_GLOBAL
,
1824 .offset
= GLOBAL_VAR(bTimeServer
),
1827 .flags
= FLAG_ADVANCED
,
1830 .label
= "unix extensions",
1832 .p_class
= P_GLOBAL
,
1833 .offset
= GLOBAL_VAR(bUnixExtensions
),
1836 .flags
= FLAG_ADVANCED
,
1839 .label
= "use spnego",
1841 .p_class
= P_GLOBAL
,
1842 .offset
= GLOBAL_VAR(bUseSpnego
),
1845 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
1848 .label
= "client signing",
1850 .p_class
= P_GLOBAL
,
1851 .offset
= GLOBAL_VAR(client_signing
),
1853 .enum_list
= enum_smb_signing_vals
,
1854 .flags
= FLAG_ADVANCED
,
1857 .label
= "server signing",
1859 .p_class
= P_GLOBAL
,
1860 .offset
= GLOBAL_VAR(server_signing
),
1862 .enum_list
= enum_smb_signing_vals
,
1863 .flags
= FLAG_ADVANCED
,
1866 .label
= "smb encrypt",
1869 .offset
= LOCAL_VAR(ismb_encrypt
),
1871 .enum_list
= enum_smb_signing_vals
,
1872 .flags
= FLAG_ADVANCED
,
1875 .label
= "client use spnego",
1877 .p_class
= P_GLOBAL
,
1878 .offset
= GLOBAL_VAR(bClientUseSpnego
),
1881 .flags
= FLAG_ADVANCED
,
1884 .label
= "client ldap sasl wrapping",
1886 .p_class
= P_GLOBAL
,
1887 .offset
= GLOBAL_VAR(client_ldap_sasl_wrapping
),
1889 .enum_list
= enum_ldap_sasl_wrapping
,
1890 .flags
= FLAG_ADVANCED
,
1893 .label
= "enable asu support",
1895 .p_class
= P_GLOBAL
,
1896 .offset
= GLOBAL_VAR(bASUSupport
),
1899 .flags
= FLAG_ADVANCED
,
1902 .label
= "svcctl list",
1904 .p_class
= P_GLOBAL
,
1905 .offset
= GLOBAL_VAR(szServicesList
),
1908 .flags
= FLAG_ADVANCED
,
1911 .label
= "cldap port",
1913 .p_class
= P_GLOBAL
,
1914 .offset
= GLOBAL_VAR(cldap_port
),
1919 .label
= "dgram port",
1921 .p_class
= P_GLOBAL
,
1922 .offset
= GLOBAL_VAR(dgram_port
),
1927 .label
= "nbt port",
1929 .p_class
= P_GLOBAL
,
1930 .offset
= GLOBAL_VAR(nbt_port
),
1935 .label
= "krb5 port",
1937 .p_class
= P_GLOBAL
,
1938 .offset
= GLOBAL_VAR(krb5_port
),
1943 .label
= "kpasswd port",
1945 .p_class
= P_GLOBAL
,
1946 .offset
= GLOBAL_VAR(kpasswd_port
),
1951 .label
= "web port",
1953 .p_class
= P_GLOBAL
,
1954 .offset
= GLOBAL_VAR(web_port
),
1959 .label
= "rpc big endian",
1961 .p_class
= P_GLOBAL
,
1962 .offset
= GLOBAL_VAR(bRpcBigEndian
),
1967 {N_("Tuning Options"), P_SEP
, P_SEPARATOR
},
1970 .label
= "block size",
1973 .offset
= LOCAL_VAR(iBlock_size
),
1976 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1979 .label
= "deadtime",
1981 .p_class
= P_GLOBAL
,
1982 .offset
= GLOBAL_VAR(deadtime
),
1985 .flags
= FLAG_ADVANCED
,
1988 .label
= "getwd cache",
1990 .p_class
= P_GLOBAL
,
1991 .offset
= GLOBAL_VAR(getwd_cache
),
1994 .flags
= FLAG_ADVANCED
,
1997 .label
= "keepalive",
1999 .p_class
= P_GLOBAL
,
2000 .offset
= GLOBAL_VAR(iKeepalive
),
2003 .flags
= FLAG_ADVANCED
,
2006 .label
= "change notify",
2009 .offset
= LOCAL_VAR(bChangeNotify
),
2012 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2015 .label
= "directory name cache size",
2018 .offset
= LOCAL_VAR(iDirectoryNameCacheSize
),
2021 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2024 .label
= "kernel change notify",
2027 .offset
= LOCAL_VAR(bKernelChangeNotify
),
2030 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2033 .label
= "lpq cache time",
2035 .p_class
= P_GLOBAL
,
2036 .offset
= GLOBAL_VAR(lpqcachetime
),
2039 .flags
= FLAG_ADVANCED
,
2042 .label
= "max smbd processes",
2044 .p_class
= P_GLOBAL
,
2045 .offset
= GLOBAL_VAR(iMaxSmbdProcesses
),
2048 .flags
= FLAG_ADVANCED
,
2051 .label
= "max connections",
2054 .offset
= LOCAL_VAR(iMaxConnections
),
2057 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2060 .label
= "paranoid server security",
2062 .p_class
= P_GLOBAL
,
2063 .offset
= GLOBAL_VAR(paranoid_server_security
),
2066 .flags
= FLAG_ADVANCED
,
2069 .label
= "max disk size",
2071 .p_class
= P_GLOBAL
,
2072 .offset
= GLOBAL_VAR(maxdisksize
),
2075 .flags
= FLAG_ADVANCED
,
2078 .label
= "max open files",
2080 .p_class
= P_GLOBAL
,
2081 .offset
= GLOBAL_VAR(max_open_files
),
2084 .flags
= FLAG_ADVANCED
,
2087 .label
= "min print space",
2090 .offset
= LOCAL_VAR(iMinPrintSpace
),
2093 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
2096 .label
= "socket options",
2098 .p_class
= P_GLOBAL
,
2099 .offset
= GLOBAL_VAR(socket_options
),
2102 .flags
= FLAG_ADVANCED
,
2105 .label
= "strict allocate",
2108 .offset
= LOCAL_VAR(bStrictAllocate
),
2111 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2114 .label
= "strict sync",
2117 .offset
= LOCAL_VAR(bStrictSync
),
2120 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2123 .label
= "sync always",
2126 .offset
= LOCAL_VAR(bSyncAlways
),
2129 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2132 .label
= "use mmap",
2134 .p_class
= P_GLOBAL
,
2135 .offset
= GLOBAL_VAR(bUseMmap
),
2138 .flags
= FLAG_ADVANCED
,
2141 .label
= "use sendfile",
2144 .offset
= LOCAL_VAR(bUseSendfile
),
2147 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2150 .label
= "hostname lookups",
2152 .p_class
= P_GLOBAL
,
2153 .offset
= GLOBAL_VAR(bHostnameLookups
),
2156 .flags
= FLAG_ADVANCED
,
2159 .label
= "write cache size",
2162 .offset
= LOCAL_VAR(iWriteCacheSize
),
2165 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2168 .label
= "name cache timeout",
2170 .p_class
= P_GLOBAL
,
2171 .offset
= GLOBAL_VAR(name_cache_timeout
),
2174 .flags
= FLAG_ADVANCED
,
2177 .label
= "ctdbd socket",
2179 .p_class
= P_GLOBAL
,
2180 .offset
= GLOBAL_VAR(ctdbdSocket
),
2183 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
2186 .label
= "cluster addresses",
2188 .p_class
= P_GLOBAL
,
2189 .offset
= GLOBAL_VAR(szClusterAddresses
),
2192 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
2195 .label
= "clustering",
2197 .p_class
= P_GLOBAL
,
2198 .offset
= GLOBAL_VAR(clustering
),
2201 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
2204 .label
= "ctdb timeout",
2206 .p_class
= P_GLOBAL
,
2207 .offset
= GLOBAL_VAR(ctdb_timeout
),
2210 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
2213 .label
= "ctdb locktime warn threshold",
2215 .p_class
= P_GLOBAL
,
2216 .offset
= GLOBAL_VAR(ctdb_locktime_warn_threshold
),
2219 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
2222 .label
= "smb2 max read",
2224 .p_class
= P_GLOBAL
,
2225 .offset
= GLOBAL_VAR(ismb2_max_read
),
2228 .flags
= FLAG_ADVANCED
,
2231 .label
= "smb2 max write",
2233 .p_class
= P_GLOBAL
,
2234 .offset
= GLOBAL_VAR(ismb2_max_write
),
2237 .flags
= FLAG_ADVANCED
,
2240 .label
= "smb2 max trans",
2242 .p_class
= P_GLOBAL
,
2243 .offset
= GLOBAL_VAR(ismb2_max_trans
),
2246 .flags
= FLAG_ADVANCED
,
2249 .label
= "smb2 max credits",
2251 .p_class
= P_GLOBAL
,
2252 .offset
= GLOBAL_VAR(ismb2_max_credits
),
2255 .flags
= FLAG_ADVANCED
,
2258 {N_("Printing Options"), P_SEP
, P_SEPARATOR
},
2261 .label
= "max reported print jobs",
2264 .offset
= LOCAL_VAR(iMaxReportedPrintJobs
),
2267 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
2270 .label
= "max print jobs",
2273 .offset
= LOCAL_VAR(iMaxPrintJobs
),
2276 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
2279 .label
= "load printers",
2281 .p_class
= P_GLOBAL
,
2282 .offset
= GLOBAL_VAR(bLoadPrinters
),
2285 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
2288 .label
= "printcap cache time",
2290 .p_class
= P_GLOBAL
,
2291 .offset
= GLOBAL_VAR(PrintcapCacheTime
),
2294 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
2297 .label
= "printcap name",
2299 .p_class
= P_GLOBAL
,
2300 .offset
= GLOBAL_VAR(szPrintcapname
),
2303 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
2306 .label
= "printcap",
2308 .p_class
= P_GLOBAL
,
2309 .offset
= GLOBAL_VAR(szPrintcapname
),
2315 .label
= "printable",
2318 .offset
= LOCAL_VAR(bPrint_ok
),
2321 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
2324 .label
= "print notify backchannel",
2327 .offset
= LOCAL_VAR(bPrintNotifyBackchannel
),
2330 .flags
= FLAG_ADVANCED
,
2333 .label
= "print ok",
2336 .offset
= LOCAL_VAR(bPrint_ok
),
2342 .label
= "printing",
2345 .offset
= LOCAL_VAR(iPrinting
),
2346 .special
= handle_printing
,
2347 .enum_list
= enum_printing
,
2348 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2351 .label
= "cups options",
2354 .offset
= LOCAL_VAR(szCupsOptions
),
2357 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2360 .label
= "cups server",
2362 .p_class
= P_GLOBAL
,
2363 .offset
= GLOBAL_VAR(szCupsServer
),
2366 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2369 .label
= "cups encrypt",
2371 .p_class
= P_GLOBAL
,
2372 .offset
= GLOBAL_VAR(CupsEncrypt
),
2374 .enum_list
= enum_bool_auto
,
2375 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2379 .label
= "cups connection timeout",
2381 .p_class
= P_GLOBAL
,
2382 .offset
= GLOBAL_VAR(cups_connection_timeout
),
2385 .flags
= FLAG_ADVANCED
,
2388 .label
= "iprint server",
2390 .p_class
= P_GLOBAL
,
2391 .offset
= GLOBAL_VAR(szIPrintServer
),
2394 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2397 .label
= "print command",
2400 .offset
= LOCAL_VAR(szPrintcommand
),
2403 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2406 .label
= "disable spoolss",
2408 .p_class
= P_GLOBAL
,
2409 .offset
= GLOBAL_VAR(bDisableSpoolss
),
2412 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2415 .label
= "enable spoolss",
2417 .p_class
= P_GLOBAL
,
2418 .offset
= GLOBAL_VAR(bDisableSpoolss
),
2424 .label
= "lpq command",
2427 .offset
= LOCAL_VAR(szLpqcommand
),
2430 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2433 .label
= "lprm command",
2436 .offset
= LOCAL_VAR(szLprmcommand
),
2439 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2442 .label
= "lppause command",
2445 .offset
= LOCAL_VAR(szLppausecommand
),
2448 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2451 .label
= "lpresume command",
2454 .offset
= LOCAL_VAR(szLpresumecommand
),
2457 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2460 .label
= "queuepause command",
2463 .offset
= LOCAL_VAR(szQueuepausecommand
),
2466 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2469 .label
= "queueresume command",
2472 .offset
= LOCAL_VAR(szQueueresumecommand
),
2475 .flags
= FLAG_ADVANCED
| FLAG_PRINT
| FLAG_GLOBAL
,
2478 .label
= "addport command",
2480 .p_class
= P_GLOBAL
,
2481 .offset
= GLOBAL_VAR(szAddPortCommand
),
2484 .flags
= FLAG_ADVANCED
,
2487 .label
= "enumports command",
2489 .p_class
= P_GLOBAL
,
2490 .offset
= GLOBAL_VAR(szEnumPortsCommand
),
2493 .flags
= FLAG_ADVANCED
,
2496 .label
= "addprinter command",
2498 .p_class
= P_GLOBAL
,
2499 .offset
= GLOBAL_VAR(szAddPrinterCommand
),
2502 .flags
= FLAG_ADVANCED
,
2505 .label
= "deleteprinter command",
2507 .p_class
= P_GLOBAL
,
2508 .offset
= GLOBAL_VAR(szDeletePrinterCommand
),
2511 .flags
= FLAG_ADVANCED
,
2514 .label
= "show add printer wizard",
2516 .p_class
= P_GLOBAL
,
2517 .offset
= GLOBAL_VAR(bMsAddPrinterWizard
),
2520 .flags
= FLAG_ADVANCED
,
2523 .label
= "os2 driver map",
2525 .p_class
= P_GLOBAL
,
2526 .offset
= GLOBAL_VAR(szOs2DriverMap
),
2529 .flags
= FLAG_ADVANCED
,
2533 .label
= "printer name",
2536 .offset
= LOCAL_VAR(szPrintername
),
2539 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
2545 .offset
= LOCAL_VAR(szPrintername
),
2551 .label
= "use client driver",
2554 .offset
= LOCAL_VAR(bUseClientDriver
),
2557 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
2560 .label
= "default devmode",
2563 .offset
= LOCAL_VAR(bDefaultDevmode
),
2566 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
2569 .label
= "force printername",
2572 .offset
= LOCAL_VAR(bForcePrintername
),
2575 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
2578 .label
= "printjob username",
2581 .offset
= LOCAL_VAR(szPrintjobUsername
),
2584 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
2587 {N_("Filename Handling"), P_SEP
, P_SEPARATOR
},
2590 .label
= "mangling method",
2592 .p_class
= P_GLOBAL
,
2593 .offset
= GLOBAL_VAR(szManglingMethod
),
2596 .flags
= FLAG_ADVANCED
,
2599 .label
= "mangle prefix",
2601 .p_class
= P_GLOBAL
,
2602 .offset
= GLOBAL_VAR(mangle_prefix
),
2605 .flags
= FLAG_ADVANCED
,
2609 .label
= "default case",
2612 .offset
= LOCAL_VAR(iDefaultCase
),
2614 .enum_list
= enum_case
,
2615 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
2618 .label
= "case sensitive",
2621 .offset
= LOCAL_VAR(iCaseSensitive
),
2623 .enum_list
= enum_bool_auto
,
2624 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2627 .label
= "casesignames",
2630 .offset
= LOCAL_VAR(iCaseSensitive
),
2632 .enum_list
= enum_bool_auto
,
2633 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
| FLAG_HIDE
,
2636 .label
= "preserve case",
2639 .offset
= LOCAL_VAR(bCasePreserve
),
2642 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2645 .label
= "short preserve case",
2648 .offset
= LOCAL_VAR(bShortCasePreserve
),
2651 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2654 .label
= "mangling char",
2657 .offset
= LOCAL_VAR(magic_char
),
2660 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2663 .label
= "hide dot files",
2666 .offset
= LOCAL_VAR(bHideDotFiles
),
2669 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2672 .label
= "hide special files",
2675 .offset
= LOCAL_VAR(bHideSpecialFiles
),
2678 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2681 .label
= "hide unreadable",
2684 .offset
= LOCAL_VAR(bHideUnReadable
),
2687 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2690 .label
= "hide unwriteable files",
2693 .offset
= LOCAL_VAR(bHideUnWriteableFiles
),
2696 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2699 .label
= "delete veto files",
2702 .offset
= LOCAL_VAR(bDeleteVetoFiles
),
2705 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2708 .label
= "veto files",
2711 .offset
= LOCAL_VAR(szVetoFiles
),
2714 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2717 .label
= "hide files",
2720 .offset
= LOCAL_VAR(szHideFiles
),
2723 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2726 .label
= "veto oplock files",
2729 .offset
= LOCAL_VAR(szVetoOplockFiles
),
2732 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2735 .label
= "map archive",
2738 .offset
= LOCAL_VAR(bMap_archive
),
2741 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2744 .label
= "map hidden",
2747 .offset
= LOCAL_VAR(bMap_hidden
),
2750 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2753 .label
= "map system",
2756 .offset
= LOCAL_VAR(bMap_system
),
2759 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2762 .label
= "map readonly",
2765 .offset
= LOCAL_VAR(iMap_readonly
),
2767 .enum_list
= enum_map_readonly
,
2768 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2771 .label
= "mangled names",
2774 .offset
= LOCAL_VAR(bMangledNames
),
2777 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2780 .label
= "max stat cache size",
2782 .p_class
= P_GLOBAL
,
2783 .offset
= GLOBAL_VAR(iMaxStatCacheSize
),
2786 .flags
= FLAG_ADVANCED
,
2789 .label
= "stat cache",
2791 .p_class
= P_GLOBAL
,
2792 .offset
= GLOBAL_VAR(bStatCache
),
2795 .flags
= FLAG_ADVANCED
,
2798 .label
= "store dos attributes",
2801 .offset
= LOCAL_VAR(bStoreDosAttributes
),
2804 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2807 .label
= "dmapi support",
2810 .offset
= LOCAL_VAR(bDmapiSupport
),
2813 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
2817 {N_("Domain Options"), P_SEP
, P_SEPARATOR
},
2820 .label
= "machine password timeout",
2822 .p_class
= P_GLOBAL
,
2823 .offset
= GLOBAL_VAR(machine_password_timeout
),
2826 .flags
= FLAG_ADVANCED
| FLAG_WIZARD
,
2829 {N_("Logon Options"), P_SEP
, P_SEPARATOR
},
2832 .label
= "add user script",
2834 .p_class
= P_GLOBAL
,
2835 .offset
= GLOBAL_VAR(szAddUserScript
),
2838 .flags
= FLAG_ADVANCED
,
2841 .label
= "rename user script",
2843 .p_class
= P_GLOBAL
,
2844 .offset
= GLOBAL_VAR(szRenameUserScript
),
2847 .flags
= FLAG_ADVANCED
,
2850 .label
= "delete user script",
2852 .p_class
= P_GLOBAL
,
2853 .offset
= GLOBAL_VAR(szDelUserScript
),
2856 .flags
= FLAG_ADVANCED
,
2859 .label
= "add group script",
2861 .p_class
= P_GLOBAL
,
2862 .offset
= GLOBAL_VAR(szAddGroupScript
),
2865 .flags
= FLAG_ADVANCED
,
2868 .label
= "delete group script",
2870 .p_class
= P_GLOBAL
,
2871 .offset
= GLOBAL_VAR(szDelGroupScript
),
2874 .flags
= FLAG_ADVANCED
,
2877 .label
= "add user to group script",
2879 .p_class
= P_GLOBAL
,
2880 .offset
= GLOBAL_VAR(szAddUserToGroupScript
),
2883 .flags
= FLAG_ADVANCED
,
2886 .label
= "delete user from group script",
2888 .p_class
= P_GLOBAL
,
2889 .offset
= GLOBAL_VAR(szDelUserFromGroupScript
),
2892 .flags
= FLAG_ADVANCED
,
2895 .label
= "set primary group script",
2897 .p_class
= P_GLOBAL
,
2898 .offset
= GLOBAL_VAR(szSetPrimaryGroupScript
),
2901 .flags
= FLAG_ADVANCED
,
2904 .label
= "add machine script",
2906 .p_class
= P_GLOBAL
,
2907 .offset
= GLOBAL_VAR(szAddMachineScript
),
2910 .flags
= FLAG_ADVANCED
,
2913 .label
= "shutdown script",
2915 .p_class
= P_GLOBAL
,
2916 .offset
= GLOBAL_VAR(szShutdownScript
),
2919 .flags
= FLAG_ADVANCED
,
2922 .label
= "abort shutdown script",
2924 .p_class
= P_GLOBAL
,
2925 .offset
= GLOBAL_VAR(szAbortShutdownScript
),
2928 .flags
= FLAG_ADVANCED
,
2931 .label
= "username map script",
2933 .p_class
= P_GLOBAL
,
2934 .offset
= GLOBAL_VAR(szUsernameMapScript
),
2937 .flags
= FLAG_ADVANCED
,
2940 .label
= "username map cache time",
2942 .p_class
= P_GLOBAL
,
2943 .offset
= GLOBAL_VAR(iUsernameMapCacheTime
),
2946 .flags
= FLAG_ADVANCED
,
2949 .label
= "logon script",
2951 .p_class
= P_GLOBAL
,
2952 .offset
= GLOBAL_VAR(szLogonScript
),
2955 .flags
= FLAG_ADVANCED
,
2958 .label
= "logon path",
2960 .p_class
= P_GLOBAL
,
2961 .offset
= GLOBAL_VAR(szLogonPath
),
2964 .flags
= FLAG_ADVANCED
,
2967 .label
= "logon drive",
2969 .p_class
= P_GLOBAL
,
2970 .offset
= GLOBAL_VAR(szLogonDrive
),
2973 .flags
= FLAG_ADVANCED
,
2976 .label
= "logon home",
2978 .p_class
= P_GLOBAL
,
2979 .offset
= GLOBAL_VAR(szLogonHome
),
2982 .flags
= FLAG_ADVANCED
,
2985 .label
= "domain logons",
2987 .p_class
= P_GLOBAL
,
2988 .offset
= GLOBAL_VAR(bDomainLogons
),
2991 .flags
= FLAG_ADVANCED
,
2995 .label
= "init logon delayed hosts",
2997 .p_class
= P_GLOBAL
,
2998 .offset
= GLOBAL_VAR(szInitLogonDelayedHosts
),
3001 .flags
= FLAG_ADVANCED
,
3005 .label
= "init logon delay",
3007 .p_class
= P_GLOBAL
,
3008 .offset
= GLOBAL_VAR(InitLogonDelay
),
3011 .flags
= FLAG_ADVANCED
,
3015 {N_("Browse Options"), P_SEP
, P_SEPARATOR
},
3018 .label
= "os level",
3020 .p_class
= P_GLOBAL
,
3021 .offset
= GLOBAL_VAR(os_level
),
3024 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
3027 .label
= "lm announce",
3029 .p_class
= P_GLOBAL
,
3030 .offset
= GLOBAL_VAR(lm_announce
),
3032 .enum_list
= enum_bool_auto
,
3033 .flags
= FLAG_ADVANCED
,
3036 .label
= "lm interval",
3038 .p_class
= P_GLOBAL
,
3039 .offset
= GLOBAL_VAR(lm_interval
),
3042 .flags
= FLAG_ADVANCED
,
3045 .label
= "preferred master",
3047 .p_class
= P_GLOBAL
,
3048 .offset
= GLOBAL_VAR(iPreferredMaster
),
3050 .enum_list
= enum_bool_auto
,
3051 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
3054 .label
= "prefered master",
3056 .p_class
= P_GLOBAL
,
3057 .offset
= GLOBAL_VAR(iPreferredMaster
),
3059 .enum_list
= enum_bool_auto
,
3063 .label
= "local master",
3065 .p_class
= P_GLOBAL
,
3066 .offset
= GLOBAL_VAR(bLocalMaster
),
3069 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
3072 .label
= "domain master",
3074 .p_class
= P_GLOBAL
,
3075 .offset
= GLOBAL_VAR(domain_master
),
3077 .enum_list
= enum_bool_auto
,
3078 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
3081 .label
= "browse list",
3083 .p_class
= P_GLOBAL
,
3084 .offset
= GLOBAL_VAR(bBrowseList
),
3087 .flags
= FLAG_ADVANCED
,
3090 .label
= "browseable",
3093 .offset
= LOCAL_VAR(bBrowseable
),
3096 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
3099 .label
= "browsable",
3102 .offset
= LOCAL_VAR(bBrowseable
),
3108 .label
= "access based share enum",
3111 .offset
= LOCAL_VAR(bAccessBasedShareEnum
),
3114 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
3117 .label
= "enhanced browsing",
3119 .p_class
= P_GLOBAL
,
3120 .offset
= GLOBAL_VAR(enhanced_browsing
),
3123 .flags
= FLAG_ADVANCED
,
3126 {N_("WINS Options"), P_SEP
, P_SEPARATOR
},
3129 .label
= "dns proxy",
3131 .p_class
= P_GLOBAL
,
3132 .offset
= GLOBAL_VAR(bWINSdnsProxy
),
3135 .flags
= FLAG_ADVANCED
,
3138 .label
= "wins proxy",
3140 .p_class
= P_GLOBAL
,
3141 .offset
= GLOBAL_VAR(bWINSproxy
),
3144 .flags
= FLAG_ADVANCED
,
3147 .label
= "wins server",
3149 .p_class
= P_GLOBAL
,
3150 .offset
= GLOBAL_VAR(szWINSservers
),
3153 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
3156 .label
= "wins support",
3158 .p_class
= P_GLOBAL
,
3159 .offset
= GLOBAL_VAR(bWINSsupport
),
3162 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
3165 .label
= "wins hook",
3167 .p_class
= P_GLOBAL
,
3168 .offset
= GLOBAL_VAR(szWINSHook
),
3171 .flags
= FLAG_ADVANCED
,
3174 {N_("Locking Options"), P_SEP
, P_SEPARATOR
},
3177 .label
= "blocking locks",
3180 .offset
= LOCAL_VAR(bBlockingLocks
),
3183 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
3186 .label
= "csc policy",
3189 .offset
= LOCAL_VAR(iCSCPolicy
),
3191 .enum_list
= enum_csc_policy
,
3192 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
3195 .label
= "fake oplocks",
3198 .offset
= LOCAL_VAR(bFakeOplocks
),
3201 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
3204 .label
= "kernel oplocks",
3207 .offset
= LOCAL_VAR(bKernelOplocks
),
3210 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
3216 .offset
= LOCAL_VAR(bLocking
),
3219 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
3222 .label
= "lock spin time",
3224 .p_class
= P_GLOBAL
,
3225 .offset
= GLOBAL_VAR(iLockSpinTime
),
3228 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
3234 .offset
= LOCAL_VAR(bOpLocks
),
3237 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
3240 .label
= "level2 oplocks",
3243 .offset
= LOCAL_VAR(bLevel2OpLocks
),
3246 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
3249 .label
= "oplock break wait time",
3251 .p_class
= P_GLOBAL
,
3252 .offset
= GLOBAL_VAR(oplock_break_wait_time
),
3255 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
3258 .label
= "oplock contention limit",
3261 .offset
= LOCAL_VAR(iOplockContentionLimit
),
3264 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
3267 .label
= "posix locking",
3270 .offset
= LOCAL_VAR(bPosixLocking
),
3273 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
3276 .label
= "strict locking",
3279 .offset
= LOCAL_VAR(iStrictLocking
),
3281 .enum_list
= enum_bool_auto
,
3282 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
3285 {N_("Ldap Options"), P_SEP
, P_SEPARATOR
},
3288 .label
= "ldap admin dn",
3290 .p_class
= P_GLOBAL
,
3291 .offset
= GLOBAL_VAR(szLdapAdminDn
),
3294 .flags
= FLAG_ADVANCED
,
3297 .label
= "ldap delete dn",
3299 .p_class
= P_GLOBAL
,
3300 .offset
= GLOBAL_VAR(ldap_delete_dn
),
3303 .flags
= FLAG_ADVANCED
,
3306 .label
= "ldap group suffix",
3308 .p_class
= P_GLOBAL
,
3309 .offset
= GLOBAL_VAR(szLdapGroupSuffix
),
3312 .flags
= FLAG_ADVANCED
,
3315 .label
= "ldap idmap suffix",
3317 .p_class
= P_GLOBAL
,
3318 .offset
= GLOBAL_VAR(szLdapIdmapSuffix
),
3321 .flags
= FLAG_ADVANCED
,
3324 .label
= "ldap machine suffix",
3326 .p_class
= P_GLOBAL
,
3327 .offset
= GLOBAL_VAR(szLdapMachineSuffix
),
3330 .flags
= FLAG_ADVANCED
,
3333 .label
= "ldap passwd sync",
3335 .p_class
= P_GLOBAL
,
3336 .offset
= GLOBAL_VAR(ldap_passwd_sync
),
3338 .enum_list
= enum_ldap_passwd_sync
,
3339 .flags
= FLAG_ADVANCED
,
3342 .label
= "ldap password sync",
3344 .p_class
= P_GLOBAL
,
3345 .offset
= GLOBAL_VAR(ldap_passwd_sync
),
3347 .enum_list
= enum_ldap_passwd_sync
,
3351 .label
= "ldap replication sleep",
3353 .p_class
= P_GLOBAL
,
3354 .offset
= GLOBAL_VAR(ldap_replication_sleep
),
3357 .flags
= FLAG_ADVANCED
,
3360 .label
= "ldap suffix",
3362 .p_class
= P_GLOBAL
,
3363 .offset
= GLOBAL_VAR(szLdapSuffix
),
3366 .flags
= FLAG_ADVANCED
,
3369 .label
= "ldap ssl",
3371 .p_class
= P_GLOBAL
,
3372 .offset
= GLOBAL_VAR(ldap_ssl
),
3374 .enum_list
= enum_ldap_ssl
,
3375 .flags
= FLAG_ADVANCED
,
3378 .label
= "ldap ssl ads",
3380 .p_class
= P_GLOBAL
,
3381 .offset
= GLOBAL_VAR(ldap_ssl_ads
),
3384 .flags
= FLAG_ADVANCED
,
3387 .label
= "ldap deref",
3389 .p_class
= P_GLOBAL
,
3390 .offset
= GLOBAL_VAR(ldap_deref
),
3392 .enum_list
= enum_ldap_deref
,
3393 .flags
= FLAG_ADVANCED
,
3396 .label
= "ldap follow referral",
3398 .p_class
= P_GLOBAL
,
3399 .offset
= GLOBAL_VAR(ldap_follow_referral
),
3401 .enum_list
= enum_bool_auto
,
3402 .flags
= FLAG_ADVANCED
,
3405 .label
= "ldap timeout",
3407 .p_class
= P_GLOBAL
,
3408 .offset
= GLOBAL_VAR(ldap_timeout
),
3411 .flags
= FLAG_ADVANCED
,
3414 .label
= "ldap connection timeout",
3416 .p_class
= P_GLOBAL
,
3417 .offset
= GLOBAL_VAR(ldap_connection_timeout
),
3420 .flags
= FLAG_ADVANCED
,
3423 .label
= "ldap page size",
3425 .p_class
= P_GLOBAL
,
3426 .offset
= GLOBAL_VAR(ldap_page_size
),
3429 .flags
= FLAG_ADVANCED
,
3432 .label
= "ldap user suffix",
3434 .p_class
= P_GLOBAL
,
3435 .offset
= GLOBAL_VAR(szLdapUserSuffix
),
3438 .flags
= FLAG_ADVANCED
,
3441 .label
= "ldap debug level",
3443 .p_class
= P_GLOBAL
,
3444 .offset
= GLOBAL_VAR(ldap_debug_level
),
3445 .special
= handle_ldap_debug_level
,
3447 .flags
= FLAG_ADVANCED
,
3450 .label
= "ldap debug threshold",
3452 .p_class
= P_GLOBAL
,
3453 .offset
= GLOBAL_VAR(ldap_debug_threshold
),
3456 .flags
= FLAG_ADVANCED
,
3459 {N_("EventLog Options"), P_SEP
, P_SEPARATOR
},
3462 .label
= "eventlog list",
3464 .p_class
= P_GLOBAL
,
3465 .offset
= GLOBAL_VAR(szEventLogs
),
3468 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
3471 {N_("Miscellaneous Options"), P_SEP
, P_SEPARATOR
},
3474 .label
= "add share command",
3476 .p_class
= P_GLOBAL
,
3477 .offset
= GLOBAL_VAR(szAddShareCommand
),
3480 .flags
= FLAG_ADVANCED
,
3483 .label
= "change share command",
3485 .p_class
= P_GLOBAL
,
3486 .offset
= GLOBAL_VAR(szChangeShareCommand
),
3489 .flags
= FLAG_ADVANCED
,
3492 .label
= "delete share command",
3494 .p_class
= P_GLOBAL
,
3495 .offset
= GLOBAL_VAR(szDeleteShareCommand
),
3498 .flags
= FLAG_ADVANCED
,
3501 .label
= "config file",
3503 .p_class
= P_GLOBAL
,
3504 .offset
= GLOBAL_VAR(szConfigFile
),
3507 .flags
= FLAG_HIDE
|FLAG_META
,
3512 .p_class
= P_GLOBAL
,
3513 .offset
= GLOBAL_VAR(szAutoServices
),
3516 .flags
= FLAG_ADVANCED
,
3519 .label
= "auto services",
3521 .p_class
= P_GLOBAL
,
3522 .offset
= GLOBAL_VAR(szAutoServices
),
3525 .flags
= FLAG_ADVANCED
,
3528 .label
= "lock directory",
3530 .p_class
= P_GLOBAL
,
3531 .offset
= GLOBAL_VAR(szLockDir
),
3534 .flags
= FLAG_ADVANCED
,
3537 .label
= "lock dir",
3539 .p_class
= P_GLOBAL
,
3540 .offset
= GLOBAL_VAR(szLockDir
),
3546 .label
= "state directory",
3548 .p_class
= P_GLOBAL
,
3549 .offset
= GLOBAL_VAR(szStateDir
),
3552 .flags
= FLAG_ADVANCED
,
3555 .label
= "cache directory",
3557 .p_class
= P_GLOBAL
,
3558 .offset
= GLOBAL_VAR(szCacheDir
),
3561 .flags
= FLAG_ADVANCED
,
3564 .label
= "pid directory",
3566 .p_class
= P_GLOBAL
,
3567 .offset
= GLOBAL_VAR(szPidDir
),
3570 .flags
= FLAG_ADVANCED
,
3573 .label
= "ntp signd socket directory",
3575 .p_class
= P_GLOBAL
,
3576 .offset
= GLOBAL_VAR(szNTPSignDSocketDirectory
),
3579 .flags
= FLAG_ADVANCED
,
3584 .label
= "utmp directory",
3586 .p_class
= P_GLOBAL
,
3587 .offset
= GLOBAL_VAR(szUtmpDir
),
3590 .flags
= FLAG_ADVANCED
,
3593 .label
= "wtmp directory",
3595 .p_class
= P_GLOBAL
,
3596 .offset
= GLOBAL_VAR(szWtmpDir
),
3599 .flags
= FLAG_ADVANCED
,
3604 .p_class
= P_GLOBAL
,
3605 .offset
= GLOBAL_VAR(bUtmp
),
3608 .flags
= FLAG_ADVANCED
,
3612 .label
= "default service",
3614 .p_class
= P_GLOBAL
,
3615 .offset
= GLOBAL_VAR(szDefaultService
),
3618 .flags
= FLAG_ADVANCED
,
3623 .p_class
= P_GLOBAL
,
3624 .offset
= GLOBAL_VAR(szDefaultService
),
3627 .flags
= FLAG_ADVANCED
,
3630 .label
= "message command",
3632 .p_class
= P_GLOBAL
,
3633 .offset
= GLOBAL_VAR(szMsgCommand
),
3636 .flags
= FLAG_ADVANCED
,
3639 .label
= "dfree cache time",
3642 .offset
= LOCAL_VAR(iDfreeCacheTime
),
3645 .flags
= FLAG_ADVANCED
,
3648 .label
= "dfree command",
3651 .offset
= LOCAL_VAR(szDfree
),
3654 .flags
= FLAG_ADVANCED
,
3657 .label
= "get quota command",
3659 .p_class
= P_GLOBAL
,
3660 .offset
= GLOBAL_VAR(szGetQuota
),
3663 .flags
= FLAG_ADVANCED
,
3666 .label
= "set quota command",
3668 .p_class
= P_GLOBAL
,
3669 .offset
= GLOBAL_VAR(szSetQuota
),
3672 .flags
= FLAG_ADVANCED
,
3675 .label
= "remote announce",
3677 .p_class
= P_GLOBAL
,
3678 .offset
= GLOBAL_VAR(szRemoteAnnounce
),
3681 .flags
= FLAG_ADVANCED
,
3684 .label
= "remote browse sync",
3686 .p_class
= P_GLOBAL
,
3687 .offset
= GLOBAL_VAR(szRemoteBrowseSync
),
3690 .flags
= FLAG_ADVANCED
,
3693 .label
= "socket address",
3695 .p_class
= P_GLOBAL
,
3696 .offset
= GLOBAL_VAR(szSocketAddress
),
3699 .flags
= FLAG_ADVANCED
,
3702 .label
= "nmbd bind explicit broadcast",
3704 .p_class
= P_GLOBAL
,
3705 .offset
= GLOBAL_VAR(bNmbdBindExplicitBroadcast
),
3708 .flags
= FLAG_ADVANCED
,
3711 .label
= "homedir map",
3713 .p_class
= P_GLOBAL
,
3714 .offset
= GLOBAL_VAR(szNISHomeMapName
),
3717 .flags
= FLAG_ADVANCED
,
3720 .label
= "afs username map",
3722 .p_class
= P_GLOBAL
,
3723 .offset
= GLOBAL_VAR(szAfsUsernameMap
),
3726 .flags
= FLAG_ADVANCED
,
3729 .label
= "afs token lifetime",
3731 .p_class
= P_GLOBAL
,
3732 .offset
= GLOBAL_VAR(iAfsTokenLifetime
),
3735 .flags
= FLAG_ADVANCED
,
3738 .label
= "log nt token command",
3740 .p_class
= P_GLOBAL
,
3741 .offset
= GLOBAL_VAR(szLogNtTokenCommand
),
3744 .flags
= FLAG_ADVANCED
,
3747 .label
= "NIS homedir",
3749 .p_class
= P_GLOBAL
,
3750 .offset
= GLOBAL_VAR(bNISHomeMap
),
3753 .flags
= FLAG_ADVANCED
,
3759 .offset
= LOCAL_VAR(valid
),
3768 .offset
= LOCAL_VAR(szCopy
),
3769 .special
= handle_copy
,
3777 .offset
= LOCAL_VAR(szInclude
),
3778 .special
= handle_include
,
3780 .flags
= FLAG_HIDE
|FLAG_META
,
3786 .offset
= LOCAL_VAR(szPreExec
),
3789 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
3795 .offset
= LOCAL_VAR(szPreExec
),
3798 .flags
= FLAG_ADVANCED
,
3801 .label
= "preexec close",
3804 .offset
= LOCAL_VAR(bPreexecClose
),
3807 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
3810 .label
= "postexec",
3813 .offset
= LOCAL_VAR(szPostExec
),
3816 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
3819 .label
= "root preexec",
3822 .offset
= LOCAL_VAR(szRootPreExec
),
3825 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
3828 .label
= "root preexec close",
3831 .offset
= LOCAL_VAR(bRootpreexecClose
),
3834 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
3837 .label
= "root postexec",
3840 .offset
= LOCAL_VAR(szRootPostExec
),
3843 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
3846 .label
= "available",
3849 .offset
= LOCAL_VAR(bAvailable
),
3852 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
3855 .label
= "registry shares",
3857 .p_class
= P_GLOBAL
,
3858 .offset
= GLOBAL_VAR(bRegistryShares
),
3861 .flags
= FLAG_ADVANCED
,
3864 .label
= "usershare allow guests",
3866 .p_class
= P_GLOBAL
,
3867 .offset
= GLOBAL_VAR(bUsershareAllowGuests
),
3870 .flags
= FLAG_ADVANCED
,
3873 .label
= "usershare max shares",
3875 .p_class
= P_GLOBAL
,
3876 .offset
= GLOBAL_VAR(iUsershareMaxShares
),
3879 .flags
= FLAG_ADVANCED
,
3882 .label
= "usershare owner only",
3884 .p_class
= P_GLOBAL
,
3885 .offset
= GLOBAL_VAR(bUsershareOwnerOnly
),
3888 .flags
= FLAG_ADVANCED
,
3891 .label
= "usershare path",
3893 .p_class
= P_GLOBAL
,
3894 .offset
= GLOBAL_VAR(szUsersharePath
),
3897 .flags
= FLAG_ADVANCED
,
3900 .label
= "usershare prefix allow list",
3902 .p_class
= P_GLOBAL
,
3903 .offset
= GLOBAL_VAR(szUsersharePrefixAllowList
),
3906 .flags
= FLAG_ADVANCED
,
3909 .label
= "usershare prefix deny list",
3911 .p_class
= P_GLOBAL
,
3912 .offset
= GLOBAL_VAR(szUsersharePrefixDenyList
),
3915 .flags
= FLAG_ADVANCED
,
3918 .label
= "usershare template share",
3920 .p_class
= P_GLOBAL
,
3921 .offset
= GLOBAL_VAR(szUsershareTemplateShare
),
3924 .flags
= FLAG_ADVANCED
,
3930 .offset
= LOCAL_VAR(volume
),
3933 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
3939 .offset
= LOCAL_VAR(fstype
),
3942 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
3945 .label
= "set directory",
3948 .offset
= LOCAL_VAR(bNo_set_dir
),
3951 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
3954 .label
= "allow insecure wide links",
3956 .p_class
= P_GLOBAL
,
3957 .offset
= GLOBAL_VAR(bAllowInsecureWidelinks
),
3960 .flags
= FLAG_ADVANCED
,
3963 .label
= "wide links",
3966 .offset
= LOCAL_VAR(bWidelinks
),
3969 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
3972 .label
= "follow symlinks",
3975 .offset
= LOCAL_VAR(bSymlinks
),
3978 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
3981 .label
= "dont descend",
3984 .offset
= LOCAL_VAR(szDontdescend
),
3987 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
3990 .label
= "magic script",
3993 .offset
= LOCAL_VAR(szMagicScript
),
3996 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
3999 .label
= "magic output",
4002 .offset
= LOCAL_VAR(szMagicOutput
),
4005 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
4008 .label
= "delete readonly",
4011 .offset
= LOCAL_VAR(bDeleteReadonly
),
4014 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
4017 .label
= "dos filemode",
4020 .offset
= LOCAL_VAR(bDosFilemode
),
4023 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
4026 .label
= "dos filetimes",
4029 .offset
= LOCAL_VAR(bDosFiletimes
),
4032 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
4035 .label
= "dos filetime resolution",
4038 .offset
= LOCAL_VAR(bDosFiletimeResolution
),
4041 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
4044 .label
= "fake directory create times",
4047 .offset
= LOCAL_VAR(bFakeDirCreateTimes
),
4050 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
4053 .label
= "async smb echo handler",
4055 .p_class
= P_GLOBAL
,
4056 .offset
= GLOBAL_VAR(bAsyncSMBEchoHandler
),
4059 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
4062 .label
= "panic action",
4064 .p_class
= P_GLOBAL
,
4065 .offset
= GLOBAL_VAR(szPanicAction
),
4068 .flags
= FLAG_ADVANCED
,
4071 .label
= "perfcount module",
4073 .p_class
= P_GLOBAL
,
4074 .offset
= GLOBAL_VAR(szSMBPerfcountModule
),
4077 .flags
= FLAG_ADVANCED
,
4080 {N_("VFS module options"), P_SEP
, P_SEPARATOR
},
4083 .label
= "vfs objects",
4086 .offset
= LOCAL_VAR(szVfsObjects
),
4089 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
4092 .label
= "vfs object",
4095 .offset
= LOCAL_VAR(szVfsObjects
),
4102 {N_("MSDFS options"), P_SEP
, P_SEPARATOR
},
4105 .label
= "msdfs root",
4108 .offset
= LOCAL_VAR(bMSDfsRoot
),
4111 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
4114 .label
= "msdfs proxy",
4117 .offset
= LOCAL_VAR(szMSDfsProxy
),
4120 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
4123 .label
= "host msdfs",
4125 .p_class
= P_GLOBAL
,
4126 .offset
= GLOBAL_VAR(bHostMSDfs
),
4129 .flags
= FLAG_ADVANCED
,
4132 {N_("Winbind options"), P_SEP
, P_SEPARATOR
},
4135 .label
= "passdb expand explicit",
4137 .p_class
= P_GLOBAL
,
4138 .offset
= GLOBAL_VAR(bPassdbExpandExplicit
),
4141 .flags
= FLAG_ADVANCED
,
4144 .label
= "idmap backend",
4146 .p_class
= P_GLOBAL
,
4147 .offset
= GLOBAL_VAR(szIdmapBackend
),
4148 .special
= handle_idmap_backend
,
4150 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
4153 .label
= "idmap cache time",
4155 .p_class
= P_GLOBAL
,
4156 .offset
= GLOBAL_VAR(iIdmapCacheTime
),
4159 .flags
= FLAG_ADVANCED
,
4162 .label
= "idmap negative cache time",
4164 .p_class
= P_GLOBAL
,
4165 .offset
= GLOBAL_VAR(iIdmapNegativeCacheTime
),
4168 .flags
= FLAG_ADVANCED
,
4171 .label
= "idmap uid",
4173 .p_class
= P_GLOBAL
,
4174 .offset
= GLOBAL_VAR(szIdmapUID
),
4175 .special
= handle_idmap_uid
,
4177 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
4180 .label
= "winbind uid",
4182 .p_class
= P_GLOBAL
,
4183 .offset
= GLOBAL_VAR(szIdmapUID
),
4184 .special
= handle_idmap_uid
,
4189 .label
= "idmap gid",
4191 .p_class
= P_GLOBAL
,
4192 .offset
= GLOBAL_VAR(szIdmapGID
),
4193 .special
= handle_idmap_gid
,
4195 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
4198 .label
= "winbind gid",
4200 .p_class
= P_GLOBAL
,
4201 .offset
= GLOBAL_VAR(szIdmapGID
),
4202 .special
= handle_idmap_gid
,
4207 .label
= "template homedir",
4209 .p_class
= P_GLOBAL
,
4210 .offset
= GLOBAL_VAR(szTemplateHomedir
),
4213 .flags
= FLAG_ADVANCED
,
4216 .label
= "template shell",
4218 .p_class
= P_GLOBAL
,
4219 .offset
= GLOBAL_VAR(szTemplateShell
),
4222 .flags
= FLAG_ADVANCED
,
4225 .label
= "winbind separator",
4227 .p_class
= P_GLOBAL
,
4228 .offset
= GLOBAL_VAR(szWinbindSeparator
),
4231 .flags
= FLAG_ADVANCED
,
4234 .label
= "winbind cache time",
4236 .p_class
= P_GLOBAL
,
4237 .offset
= GLOBAL_VAR(winbind_cache_time
),
4240 .flags
= FLAG_ADVANCED
,
4243 .label
= "winbind reconnect delay",
4245 .p_class
= P_GLOBAL
,
4246 .offset
= GLOBAL_VAR(winbind_reconnect_delay
),
4249 .flags
= FLAG_ADVANCED
,
4252 .label
= "winbind max clients",
4254 .p_class
= P_GLOBAL
,
4255 .offset
= GLOBAL_VAR(winbind_max_clients
),
4258 .flags
= FLAG_ADVANCED
,
4261 .label
= "winbind enum users",
4263 .p_class
= P_GLOBAL
,
4264 .offset
= GLOBAL_VAR(bWinbindEnumUsers
),
4267 .flags
= FLAG_ADVANCED
,
4270 .label
= "winbind enum groups",
4272 .p_class
= P_GLOBAL
,
4273 .offset
= GLOBAL_VAR(bWinbindEnumGroups
),
4276 .flags
= FLAG_ADVANCED
,
4279 .label
= "winbind use default domain",
4281 .p_class
= P_GLOBAL
,
4282 .offset
= GLOBAL_VAR(bWinbindUseDefaultDomain
),
4285 .flags
= FLAG_ADVANCED
,
4288 .label
= "winbind trusted domains only",
4290 .p_class
= P_GLOBAL
,
4291 .offset
= GLOBAL_VAR(bWinbindTrustedDomainsOnly
),
4294 .flags
= FLAG_ADVANCED
,
4297 .label
= "winbind nested groups",
4299 .p_class
= P_GLOBAL
,
4300 .offset
= GLOBAL_VAR(bWinbindNestedGroups
),
4303 .flags
= FLAG_ADVANCED
,
4306 .label
= "winbind expand groups",
4308 .p_class
= P_GLOBAL
,
4309 .offset
= GLOBAL_VAR(winbind_expand_groups
),
4312 .flags
= FLAG_ADVANCED
,
4315 .label
= "winbind nss info",
4317 .p_class
= P_GLOBAL
,
4318 .offset
= GLOBAL_VAR(szWinbindNssInfo
),
4321 .flags
= FLAG_ADVANCED
,
4324 .label
= "winbind refresh tickets",
4326 .p_class
= P_GLOBAL
,
4327 .offset
= GLOBAL_VAR(bWinbindRefreshTickets
),
4330 .flags
= FLAG_ADVANCED
,
4333 .label
= "winbind offline logon",
4335 .p_class
= P_GLOBAL
,
4336 .offset
= GLOBAL_VAR(bWinbindOfflineLogon
),
4339 .flags
= FLAG_ADVANCED
,
4342 .label
= "winbind normalize names",
4344 .p_class
= P_GLOBAL
,
4345 .offset
= GLOBAL_VAR(bWinbindNormalizeNames
),
4348 .flags
= FLAG_ADVANCED
,
4351 .label
= "winbind rpc only",
4353 .p_class
= P_GLOBAL
,
4354 .offset
= GLOBAL_VAR(bWinbindRpcOnly
),
4357 .flags
= FLAG_ADVANCED
,
4360 .label
= "create krb5 conf",
4362 .p_class
= P_GLOBAL
,
4363 .offset
= GLOBAL_VAR(bCreateKrb5Conf
),
4366 .flags
= FLAG_ADVANCED
,
4369 .label
= "ncalrpc dir",
4371 .p_class
= P_GLOBAL
,
4372 .offset
= GLOBAL_VAR(ncalrpc_dir
),
4375 .flags
= FLAG_ADVANCED
,
4378 .label
= "winbind max domain connections",
4380 .p_class
= P_GLOBAL
,
4381 .offset
= GLOBAL_VAR(winbindMaxDomainConnections
),
4384 .flags
= FLAG_ADVANCED
,
4387 .label
= "winbindd socket directory",
4389 .p_class
= P_GLOBAL
,
4390 .offset
= GLOBAL_VAR(szWinbinddSocketDirectory
),
4393 .flags
= FLAG_ADVANCED
,
4396 .label
= "winbindd privileged socket directory",
4398 .p_class
= P_GLOBAL
,
4399 .offset
= GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory
),
4402 .flags
= FLAG_ADVANCED
,
4405 .label
= "winbind sealed pipes",
4407 .p_class
= P_GLOBAL
,
4408 .offset
= GLOBAL_VAR(bWinbindSealedPipes
),
4411 .flags
= FLAG_ADVANCED
,
4414 {N_("DNS options"), P_SEP
, P_SEPARATOR
},
4416 .label
= "allow dns updates",
4418 .p_class
= P_GLOBAL
,
4419 .offset
= GLOBAL_VAR(allow_dns_updates
),
4421 .enum_list
= enum_dns_update_settings
,
4422 .flags
= FLAG_ADVANCED
,
4425 .label
= "dns forwarder",
4427 .p_class
= P_GLOBAL
,
4428 .offset
= GLOBAL_VAR(dns_forwarder
),
4431 .flags
= FLAG_ADVANCED
,
4434 .label
= "dns recursive queries",
4436 .p_class
= P_GLOBAL
,
4437 .offset
= GLOBAL_VAR(dns_recursive_queries
),
4442 .label
= "dns update command",
4444 .p_class
= P_GLOBAL
,
4445 .offset
= GLOBAL_VAR(szDNSUpdateCommand
),
4448 .flags
= FLAG_ADVANCED
,
4451 .label
= "nsupdate command",
4453 .p_class
= P_GLOBAL
,
4454 .offset
= GLOBAL_VAR(szNSUpdateCommand
),
4457 .flags
= FLAG_ADVANCED
,
4460 .label
= "rndc command",
4462 .p_class
= P_GLOBAL
,
4463 .offset
= GLOBAL_VAR(szRNDCCommand
),
4466 .flags
= FLAG_ADVANCED
,
4469 .label
= "multicast dns register",
4471 .p_class
= P_GLOBAL
,
4472 .offset
= GLOBAL_VAR(bMulticastDnsRegister
),
4475 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
4478 {N_("AD DC options"), P_SEP
, P_SEPARATOR
},
4481 .label
= "samba kcc command",
4483 .p_class
= P_GLOBAL
,
4484 .offset
= GLOBAL_VAR(szSambaKCCCommand
),
4487 .flags
= FLAG_ADVANCED
,
4490 .label
= "server services",
4492 .p_class
= P_GLOBAL
,
4493 .offset
= GLOBAL_VAR(server_services
),
4498 .label
= "dcerpc endpoint servers",
4500 .p_class
= P_GLOBAL
,
4501 .offset
= GLOBAL_VAR(dcerpc_ep_servers
),
4506 .label
= "spn update command",
4508 .p_class
= P_GLOBAL
,
4509 .offset
= GLOBAL_VAR(szSPNUpdateCommand
),
4512 .flags
= FLAG_ADVANCED
,
4515 .label
= "share backend",
4517 .p_class
= P_GLOBAL
,
4518 .offset
= GLOBAL_VAR(szShareBackend
),
4523 .label
= "ntvfs handler",
4526 .offset
= LOCAL_VAR(ntvfs_handler
),
4531 {N_("TLS options"), P_SEP
, P_SEPARATOR
},
4534 .label
= "tls enabled",
4536 .p_class
= P_GLOBAL
,
4537 .offset
= GLOBAL_VAR(tls_enabled
),
4542 .label
= "tls keyfile",
4544 .p_class
= P_GLOBAL
,
4545 .offset
= GLOBAL_VAR(tls_keyfile
),
4550 .label
= "tls certfile",
4552 .p_class
= P_GLOBAL
,
4553 .offset
= GLOBAL_VAR(tls_certfile
),
4558 .label
= "tls cafile",
4560 .p_class
= P_GLOBAL
,
4561 .offset
= GLOBAL_VAR(tls_cafile
),
4566 .label
= "tls crlfile",
4568 .p_class
= P_GLOBAL
,
4569 .offset
= GLOBAL_VAR(tls_crlfile
),
4574 .label
= "tls dh params file",
4576 .p_class
= P_GLOBAL
,
4577 .offset
= GLOBAL_VAR(tls_dhpfile
),
4582 {NULL
, P_BOOL
, P_NONE
, 0, NULL
, NULL
, 0}
4585 /***************************************************************************
4586 Initialise the sDefault parameter structure for the printer values.
4587 ***************************************************************************/
4589 static void init_printer_values(struct loadparm_service
*pService
)
4591 /* choose defaults depending on the type of printing */
4592 switch (pService
->iPrinting
) {
4597 string_set(&pService
->szLpqcommand
, "lpq -P'%p'");
4598 string_set(&pService
->szLprmcommand
, "lprm -P'%p' %j");
4599 string_set(&pService
->szPrintcommand
, "lpr -r -P'%p' %s");
4604 string_set(&pService
->szLpqcommand
, "lpq -P'%p'");
4605 string_set(&pService
->szLprmcommand
, "lprm -P'%p' %j");
4606 string_set(&pService
->szPrintcommand
, "lpr -r -P'%p' %s");
4607 string_set(&pService
->szQueuepausecommand
, "lpc stop '%p'");
4608 string_set(&pService
->szQueueresumecommand
, "lpc start '%p'");
4609 string_set(&pService
->szLppausecommand
, "lpc hold '%p' %j");
4610 string_set(&pService
->szLpresumecommand
, "lpc release '%p' %j");
4616 /* set the lpq command to contain the destination printer
4617 name only. This is used by cups_queue_get() */
4618 string_set(&pService
->szLpqcommand
, "%p");
4619 string_set(&pService
->szLprmcommand
, "");
4620 string_set(&pService
->szPrintcommand
, "");
4621 string_set(&pService
->szLppausecommand
, "");
4622 string_set(&pService
->szLpresumecommand
, "");
4623 string_set(&pService
->szQueuepausecommand
, "");
4624 string_set(&pService
->szQueueresumecommand
, "");
4626 string_set(&pService
->szLpqcommand
, "lpq -P'%p'");
4627 string_set(&pService
->szLprmcommand
, "lprm -P'%p' %j");
4628 string_set(&pService
->szPrintcommand
, "lpr -P'%p' %s; rm %s");
4629 string_set(&pService
->szLppausecommand
, "lp -i '%p-%j' -H hold");
4630 string_set(&pService
->szLpresumecommand
, "lp -i '%p-%j' -H resume");
4631 string_set(&pService
->szQueuepausecommand
, "disable '%p'");
4632 string_set(&pService
->szQueueresumecommand
, "enable '%p'");
4633 #endif /* HAVE_CUPS */
4638 string_set(&pService
->szLpqcommand
, "lpstat -o%p");
4639 string_set(&pService
->szLprmcommand
, "cancel %p-%j");
4640 string_set(&pService
->szPrintcommand
, "lp -c -d%p %s; rm %s");
4641 string_set(&pService
->szQueuepausecommand
, "disable %p");
4642 string_set(&pService
->szQueueresumecommand
, "enable %p");
4644 string_set(&pService
->szLppausecommand
, "lp -i %p-%j -H hold");
4645 string_set(&pService
->szLpresumecommand
, "lp -i %p-%j -H resume");
4650 string_set(&pService
->szLpqcommand
, "lpq -P%p");
4651 string_set(&pService
->szLprmcommand
, "lprm -P%p %j");
4652 string_set(&pService
->szPrintcommand
, "lp -r -P%p %s");
4655 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
4659 const char *tdbfile
;
4660 TALLOC_CTX
*tmp_ctx
= talloc_stackframe();
4663 tdbfile
= talloc_asprintf(
4664 tmp_ctx
, "tdbfile=%s",
4665 lp_parm_const_string(-1, "vlp", "tdbfile",
4667 if (tdbfile
== NULL
) {
4668 tdbfile
="tdbfile=/tmp/vlp.tdb";
4671 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s print %%p %%s",
4673 string_set(&pService
->szPrintcommand
,
4674 tmp
? tmp
: "vlp print %p %s");
4676 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s lpq %%p",
4678 string_set(&pService
->szLpqcommand
,
4679 tmp
? tmp
: "vlp lpq %p");
4681 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s lprm %%p %%j",
4683 string_set(&pService
->szLprmcommand
,
4684 tmp
? tmp
: "vlp lprm %p %j");
4686 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s lppause %%p %%j",
4688 string_set(&pService
->szLppausecommand
,
4689 tmp
? tmp
: "vlp lppause %p %j");
4691 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s lpresume %%p %%j",
4693 string_set(&pService
->szLpresumecommand
,
4694 tmp
? tmp
: "vlp lpresume %p %j");
4696 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s queuepause %%p",
4698 string_set(&pService
->szQueuepausecommand
,
4699 tmp
? tmp
: "vlp queuepause %p");
4701 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s queueresume %%p",
4703 string_set(&pService
->szQueueresumecommand
,
4704 tmp
? tmp
: "vlp queueresume %p");
4705 TALLOC_FREE(tmp_ctx
);
4709 #endif /* DEVELOPER */
4714 * Function to return the default value for the maximum number of open
4715 * file descriptors permitted. This function tries to consult the
4716 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4717 * the smaller of those.
4719 static int max_open_files(void)
4721 int sysctl_max
= MAX_OPEN_FILES
;
4722 int rlimit_max
= MAX_OPEN_FILES
;
4724 #ifdef HAVE_SYSCTLBYNAME
4726 size_t size
= sizeof(sysctl_max
);
4727 sysctlbyname("kern.maxfilesperproc", &sysctl_max
, &size
, NULL
,
4732 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4738 if (getrlimit(RLIMIT_NOFILE
, &rl
) == 0)
4739 rlimit_max
= rl
.rlim_cur
;
4741 #if defined(RLIM_INFINITY)
4742 if(rl
.rlim_cur
== RLIM_INFINITY
)
4743 rlimit_max
= MAX_OPEN_FILES
;
4748 if (sysctl_max
< MIN_OPEN_FILES_WINDOWS
) {
4749 DEBUG(2,("max_open_files: increasing sysctl_max (%d) to "
4750 "minimum Windows limit (%d)\n",
4752 MIN_OPEN_FILES_WINDOWS
));
4753 sysctl_max
= MIN_OPEN_FILES_WINDOWS
;
4756 if (rlimit_max
< MIN_OPEN_FILES_WINDOWS
) {
4757 DEBUG(2,("rlimit_max: increasing rlimit_max (%d) to "
4758 "minimum Windows limit (%d)\n",
4760 MIN_OPEN_FILES_WINDOWS
));
4761 rlimit_max
= MIN_OPEN_FILES_WINDOWS
;
4764 return MIN(sysctl_max
, rlimit_max
);
4768 * Common part of freeing allocated data for one parameter.
4770 static void free_one_parameter_common(void *parm_ptr
,
4771 struct parm_struct parm
)
4773 if ((parm
.type
== P_STRING
) ||
4774 (parm
.type
== P_USTRING
))
4776 string_free((char**)parm_ptr
);
4777 } else if (parm
.type
== P_LIST
) {
4778 TALLOC_FREE(*((char***)parm_ptr
));
4783 * Free the allocated data for one parameter for a share
4784 * given as a service struct.
4786 static void free_one_parameter(struct loadparm_service
*service
,
4787 struct parm_struct parm
)
4791 if (parm
.p_class
!= P_LOCAL
) {
4795 parm_ptr
= lp_parm_ptr(service
, &parm
);
4797 free_one_parameter_common(parm_ptr
, parm
);
4801 * Free the allocated parameter data of a share given
4802 * as a service struct.
4804 static void free_parameters(struct loadparm_service
*service
)
4808 for (i
=0; parm_table
[i
].label
; i
++) {
4809 free_one_parameter(service
, parm_table
[i
]);
4814 * Free the allocated data for one parameter for a given share
4815 * specified by an snum.
4817 static void free_one_parameter_by_snum(int snum
, struct parm_struct parm
)
4822 parm_ptr
= lp_parm_ptr(NULL
, &parm
);
4823 } else if (parm
.p_class
!= P_LOCAL
) {
4826 parm_ptr
= lp_local_ptr_by_snum(snum
, &parm
);
4829 free_one_parameter_common(parm_ptr
, parm
);
4833 * Free the allocated parameter data for a share specified
4836 static void free_parameters_by_snum(int snum
)
4840 for (i
=0; parm_table
[i
].label
; i
++) {
4841 free_one_parameter_by_snum(snum
, parm_table
[i
]);
4846 * Free the allocated global parameters.
4848 static void free_global_parameters(void)
4850 free_param_opts(&Globals
.param_opt
);
4851 free_parameters_by_snum(GLOBAL_SECTION_SNUM
);
4854 static int map_parameter(const char *pszParmName
);
4856 struct lp_stored_option
{
4857 struct lp_stored_option
*prev
, *next
;
4862 static struct lp_stored_option
*stored_options
;
4865 save options set by lp_set_cmdline() into a list. This list is
4866 re-applied when we do a globals reset, so that cmdline set options
4867 are sticky across reloads of smb.conf
4869 static bool store_lp_set_cmdline(const char *pszParmName
, const char *pszParmValue
)
4871 struct lp_stored_option
*entry
, *entry_next
;
4872 for (entry
= stored_options
; entry
!= NULL
; entry
= entry_next
) {
4873 entry_next
= entry
->next
;
4874 if (strcmp(pszParmName
, entry
->label
) == 0) {
4875 DLIST_REMOVE(stored_options
, entry
);
4881 entry
= talloc(NULL
, struct lp_stored_option
);
4886 entry
->label
= talloc_strdup(entry
, pszParmName
);
4887 if (!entry
->label
) {
4892 entry
->value
= talloc_strdup(entry
, pszParmValue
);
4893 if (!entry
->value
) {
4898 DLIST_ADD_END(stored_options
, entry
, struct lp_stored_option
);
4903 static bool apply_lp_set_cmdline(void)
4905 struct lp_stored_option
*entry
= NULL
;
4906 for (entry
= stored_options
; entry
!= NULL
; entry
= entry
->next
) {
4907 if (!lp_set_cmdline_helper(entry
->label
, entry
->value
, false)) {
4908 DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
4909 entry
->label
, entry
->value
));
4916 /***************************************************************************
4917 Initialise the global parameter structure.
4918 ***************************************************************************/
4920 static void init_globals(bool reinit_globals
)
4922 static bool done_init
= false;
4926 /* If requested to initialize only once and we've already done it... */
4927 if (!reinit_globals
&& done_init
) {
4928 /* ... then we have nothing more to do */
4933 /* The logfile can be set before this is invoked. Free it if so. */
4934 if (Globals
.logfile
!= NULL
) {
4935 string_free(&Globals
.logfile
);
4936 Globals
.logfile
= NULL
;
4940 free_global_parameters();
4943 /* This memset and the free_global_parameters() above will
4944 * wipe out smb.conf options set with lp_set_cmdline(). The
4945 * apply_lp_set_cmdline() call puts these values back in the
4946 * table once the defaults are set */
4947 ZERO_STRUCT(Globals
);
4949 for (i
= 0; parm_table
[i
].label
; i
++) {
4950 if ((parm_table
[i
].type
== P_STRING
||
4951 parm_table
[i
].type
== P_USTRING
))
4953 string_set((char **)lp_parm_ptr(NULL
, &parm_table
[i
]), "");
4958 string_set(&sDefault
.fstype
, FSTYPE_STRING
);
4959 string_set(&sDefault
.szPrintjobUsername
, "%U");
4961 init_printer_values(&sDefault
);
4964 DEBUG(3, ("Initialising global parameters\n"));
4966 /* Must manually force to upper case here, as this does not go via the handler */
4967 string_set(&Globals
.szNetbiosName
, myhostname_upper());
4969 string_set(&Globals
.szSMBPasswdFile
, get_dyn_SMB_PASSWD_FILE());
4970 string_set(&Globals
.szPrivateDir
, get_dyn_PRIVATE_DIR());
4972 /* use the new 'hash2' method by default, with a prefix of 1 */
4973 string_set(&Globals
.szManglingMethod
, "hash2");
4974 Globals
.mangle_prefix
= 1;
4976 string_set(&Globals
.szGuestaccount
, GUEST_ACCOUNT
);
4978 /* using UTF8 by default allows us to support all chars */
4979 string_set(&Globals
.unix_charset
, DEFAULT_UNIX_CHARSET
);
4981 /* Use codepage 850 as a default for the dos character set */
4982 string_set(&Globals
.dos_charset
, DEFAULT_DOS_CHARSET
);
4985 * Allow the default PASSWD_CHAT to be overridden in local.h.
4987 string_set(&Globals
.szPasswdChat
, DEFAULT_PASSWD_CHAT
);
4989 string_set(&Globals
.szWorkgroup
, DEFAULT_WORKGROUP
);
4991 string_set(&Globals
.szPasswdProgram
, "");
4992 string_set(&Globals
.szLockDir
, get_dyn_LOCKDIR());
4993 string_set(&Globals
.szStateDir
, get_dyn_STATEDIR());
4994 string_set(&Globals
.szCacheDir
, get_dyn_CACHEDIR());
4995 string_set(&Globals
.szPidDir
, get_dyn_PIDDIR());
4996 string_set(&Globals
.szSocketAddress
, "0.0.0.0");
4998 * By default support explicit binding to broadcast
5001 Globals
.bNmbdBindExplicitBroadcast
= true;
5003 if (asprintf(&s
, "Samba %s", samba_version_string()) < 0) {
5004 smb_panic("init_globals: ENOMEM");
5006 string_set(&Globals
.szServerString
, s
);
5009 string_set(&Globals
.szPanicAction
, "/bin/sleep 999999999");
5012 string_set(&Globals
.socket_options
, DEFAULT_SOCKET_OPTIONS
);
5014 string_set(&Globals
.szLogonDrive
, "");
5015 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
5016 string_set(&Globals
.szLogonHome
, "\\\\%N\\%U");
5017 string_set(&Globals
.szLogonPath
, "\\\\%N\\%U\\profile");
5019 Globals
.szNameResolveOrder
= (const char **)str_list_make_v3(NULL
, "lmhosts wins host bcast", NULL
);
5020 string_set(&Globals
.szPasswordServer
, "*");
5022 Globals
.AlgorithmicRidBase
= BASE_RID
;
5024 Globals
.bLoadPrinters
= true;
5025 Globals
.PrintcapCacheTime
= 750; /* 12.5 minutes */
5027 Globals
.ConfigBackend
= config_backend
;
5028 Globals
.server_role
= ROLE_AUTO
;
5030 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
5031 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
5032 Globals
.max_xmit
= 0x4104;
5033 Globals
.max_mux
= 50; /* This is *needed* for profile support. */
5034 Globals
.lpqcachetime
= 30; /* changed to handle large print servers better -- jerry */
5035 Globals
.bDisableSpoolss
= false;
5036 Globals
.iMaxSmbdProcesses
= 0;/* no limit specified */
5037 Globals
.pwordlevel
= 0;
5038 Globals
.unamelevel
= 0;
5039 Globals
.deadtime
= 0;
5040 Globals
.getwd_cache
= true;
5041 Globals
.bLargeReadwrite
= true;
5042 Globals
.max_log_size
= 5000;
5043 Globals
.max_open_files
= max_open_files();
5044 Globals
.open_files_db_hash_size
= SMB_OPEN_DATABASE_TDB_HASH_SIZE
;
5045 Globals
.srv_maxprotocol
= PROTOCOL_SMB2_10
;
5046 Globals
.srv_minprotocol
= PROTOCOL_LANMAN1
;
5047 Globals
.security
= SEC_USER
;
5048 Globals
.paranoid_server_security
= true;
5049 Globals
.bEncryptPasswords
= true;
5050 Globals
.clientSchannel
= Auto
;
5051 Globals
.serverSchannel
= Auto
;
5052 Globals
.bReadRaw
= true;
5053 Globals
.bWriteRaw
= true;
5054 Globals
.bNullPasswords
= false;
5055 Globals
.bObeyPamRestrictions
= false;
5057 Globals
.bSyslogOnly
= false;
5058 Globals
.bTimestampLogs
= true;
5059 string_set(&Globals
.loglevel
, "0");
5060 Globals
.bDebugPrefixTimestamp
= false;
5061 Globals
.bDebugHiresTimestamp
= true;
5062 Globals
.bDebugPid
= false;
5063 Globals
.bDebugUid
= false;
5064 Globals
.bDebugClass
= false;
5065 Globals
.bEnableCoreFiles
= true;
5066 Globals
.max_ttl
= 60 * 60 * 24 * 3; /* 3 days default. */
5067 Globals
.max_wins_ttl
= 60 * 60 * 24 * 6; /* 6 days default. */
5068 Globals
.min_wins_ttl
= 60 * 60 * 6; /* 6 hours default. */
5069 Globals
.machine_password_timeout
= 60 * 60 * 24 * 7; /* 7 days default. */
5070 Globals
.lm_announce
= Auto
; /* = Auto: send only if LM clients found */
5071 Globals
.lm_interval
= 60;
5072 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
5073 Globals
.bNISHomeMap
= false;
5074 #ifdef WITH_NISPLUS_HOME
5075 string_set(&Globals
.szNISHomeMapName
, "auto_home.org_dir");
5077 string_set(&Globals
.szNISHomeMapName
, "auto.home");
5080 Globals
.bTimeServer
= false;
5081 Globals
.bBindInterfacesOnly
= false;
5082 Globals
.bUnixPasswdSync
= false;
5083 Globals
.bPamPasswordChange
= false;
5084 Globals
.bPasswdChatDebug
= false;
5085 Globals
.iPasswdChatTimeout
= 2; /* 2 second default. */
5086 Globals
.bNTPipeSupport
= true; /* Do NT pipes by default. */
5087 Globals
.bNTStatusSupport
= true; /* Use NT status by default. */
5088 Globals
.bStatCache
= true; /* use stat cache by default */
5089 Globals
.iMaxStatCacheSize
= 256; /* 256k by default */
5090 Globals
.restrict_anonymous
= 0;
5091 Globals
.bClientLanManAuth
= false; /* Do NOT use the LanMan hash if it is available */
5092 Globals
.bClientPlaintextAuth
= false; /* Do NOT use a plaintext password even if is requested by the server */
5093 Globals
.bLanmanAuth
= false; /* Do NOT use the LanMan hash, even if it is supplied */
5094 Globals
.bNTLMAuth
= true; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
5095 Globals
.bClientNTLMv2Auth
= true; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
5096 /* Note, that we will also use NTLM2 session security (which is different), if it is available */
5098 Globals
.map_to_guest
= 0; /* By Default, "Never" */
5099 Globals
.oplock_break_wait_time
= 0; /* By Default, 0 msecs. */
5100 Globals
.enhanced_browsing
= true;
5101 Globals
.iLockSpinTime
= WINDOWS_MINIMUM_LOCK_TIMEOUT_MS
; /* msec. */
5102 #ifdef MMAP_BLACKLIST
5103 Globals
.bUseMmap
= false;
5105 Globals
.bUseMmap
= true;
5107 Globals
.bUnicode
= true;
5108 Globals
.bUnixExtensions
= true;
5109 Globals
.bResetOnZeroVC
= false;
5110 Globals
.bLogWriteableFilesOnExit
= false;
5111 Globals
.bCreateKrb5Conf
= true;
5112 Globals
.winbindMaxDomainConnections
= 1;
5114 /* hostname lookups can be very expensive and are broken on
5115 a large number of sites (tridge) */
5116 Globals
.bHostnameLookups
= false;
5118 string_set(&Globals
.passdb_backend
, "tdbsam");
5119 string_set(&Globals
.szLdapSuffix
, "");
5120 string_set(&Globals
.szLdapMachineSuffix
, "");
5121 string_set(&Globals
.szLdapUserSuffix
, "");
5122 string_set(&Globals
.szLdapGroupSuffix
, "");
5123 string_set(&Globals
.szLdapIdmapSuffix
, "");
5125 string_set(&Globals
.szLdapAdminDn
, "");
5126 Globals
.ldap_ssl
= LDAP_SSL_START_TLS
;
5127 Globals
.ldap_ssl_ads
= false;
5128 Globals
.ldap_deref
= -1;
5129 Globals
.ldap_passwd_sync
= LDAP_PASSWD_SYNC_OFF
;
5130 Globals
.ldap_delete_dn
= false;
5131 Globals
.ldap_replication_sleep
= 1000; /* wait 1 sec for replication */
5132 Globals
.ldap_follow_referral
= Auto
;
5133 Globals
.ldap_timeout
= LDAP_DEFAULT_TIMEOUT
;
5134 Globals
.ldap_connection_timeout
= LDAP_CONNECTION_DEFAULT_TIMEOUT
;
5135 Globals
.ldap_page_size
= LDAP_PAGE_SIZE
;
5137 Globals
.ldap_debug_level
= 0;
5138 Globals
.ldap_debug_threshold
= 10;
5140 /* This is what we tell the afs client. in reality we set the token
5141 * to never expire, though, when this runs out the afs client will
5142 * forget the token. Set to 0 to get NEVERDATE.*/
5143 Globals
.iAfsTokenLifetime
= 604800;
5144 Globals
.cups_connection_timeout
= CUPS_DEFAULT_CONNECTION_TIMEOUT
;
5146 /* these parameters are set to defaults that are more appropriate
5147 for the increasing samba install base:
5149 as a member of the workgroup, that will possibly become a
5150 _local_ master browser (lm = true). this is opposed to a forced
5151 local master browser startup (pm = true).
5153 doesn't provide WINS server service by default (wsupp = false),
5154 and doesn't provide domain master browser services by default, either.
5158 Globals
.bMsAddPrinterWizard
= true;
5159 Globals
.os_level
= 20;
5160 Globals
.bLocalMaster
= true;
5161 Globals
.domain_master
= Auto
; /* depending on bDomainLogons */
5162 Globals
.bDomainLogons
= false;
5163 Globals
.bBrowseList
= true;
5164 Globals
.bWINSsupport
= false;
5165 Globals
.bWINSproxy
= false;
5167 TALLOC_FREE(Globals
.szInitLogonDelayedHosts
);
5168 Globals
.InitLogonDelay
= 100; /* 100 ms default delay */
5170 Globals
.bWINSdnsProxy
= true;
5172 Globals
.bAllowTrustedDomains
= true;
5173 string_set(&Globals
.szIdmapBackend
, "tdb");
5175 string_set(&Globals
.szTemplateShell
, "/bin/false");
5176 string_set(&Globals
.szTemplateHomedir
, "/home/%D/%U");
5177 string_set(&Globals
.szWinbindSeparator
, "\\");
5179 string_set(&Globals
.szCupsServer
, "");
5180 string_set(&Globals
.szIPrintServer
, "");
5182 #ifdef CLUSTER_SUPPORT
5183 string_set(&Globals
.ctdbdSocket
, CTDB_PATH
);
5185 string_set(&Globals
.ctdbdSocket
, "");
5188 Globals
.szClusterAddresses
= NULL
;
5189 Globals
.clustering
= false;
5190 Globals
.ctdb_timeout
= 0;
5191 Globals
.ctdb_locktime_warn_threshold
= 0;
5193 Globals
.winbind_cache_time
= 300; /* 5 minutes */
5194 Globals
.winbind_reconnect_delay
= 30; /* 30 seconds */
5195 Globals
.winbind_max_clients
= 200;
5196 Globals
.bWinbindEnumUsers
= false;
5197 Globals
.bWinbindEnumGroups
= false;
5198 Globals
.bWinbindUseDefaultDomain
= false;
5199 Globals
.bWinbindTrustedDomainsOnly
= false;
5200 Globals
.bWinbindNestedGroups
= true;
5201 Globals
.winbind_expand_groups
= 1;
5202 Globals
.szWinbindNssInfo
= (const char **)str_list_make_v3(NULL
, "template", NULL
);
5203 Globals
.bWinbindRefreshTickets
= false;
5204 Globals
.bWinbindOfflineLogon
= false;
5206 Globals
.iIdmapCacheTime
= 86400 * 7; /* a week by default */
5207 Globals
.iIdmapNegativeCacheTime
= 120; /* 2 minutes by default */
5209 Globals
.bPassdbExpandExplicit
= false;
5211 Globals
.name_cache_timeout
= 660; /* In seconds */
5213 Globals
.bUseSpnego
= true;
5214 Globals
.bClientUseSpnego
= true;
5216 Globals
.client_signing
= SMB_SIGNING_DEFAULT
;
5217 Globals
.server_signing
= SMB_SIGNING_DEFAULT
;
5219 Globals
.bDeferSharingViolations
= true;
5220 Globals
.smb_ports
= (const char **)str_list_make_v3(NULL
, SMB_PORTS
, NULL
);
5222 Globals
.bEnablePrivileges
= true;
5223 Globals
.bHostMSDfs
= true;
5224 Globals
.bASUSupport
= false;
5226 /* User defined shares. */
5227 if (asprintf(&s
, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5228 smb_panic("init_globals: ENOMEM");
5230 string_set(&Globals
.szUsersharePath
, s
);
5232 string_set(&Globals
.szUsershareTemplateShare
, "");
5233 Globals
.iUsershareMaxShares
= 0;
5234 /* By default disallow sharing of directories not owned by the sharer. */
5235 Globals
.bUsershareOwnerOnly
= true;
5236 /* By default disallow guest access to usershares. */
5237 Globals
.bUsershareAllowGuests
= false;
5239 Globals
.iKeepalive
= DEFAULT_KEEPALIVE
;
5241 /* By default no shares out of the registry */
5242 Globals
.bRegistryShares
= false;
5244 Globals
.iminreceivefile
= 0;
5246 Globals
.bMapUntrustedToDomain
= false;
5247 Globals
.bMulticastDnsRegister
= true;
5249 Globals
.ismb2_max_read
= DEFAULT_SMB2_MAX_READ
;
5250 Globals
.ismb2_max_write
= DEFAULT_SMB2_MAX_WRITE
;
5251 Globals
.ismb2_max_trans
= DEFAULT_SMB2_MAX_TRANSACT
;
5252 Globals
.ismb2_max_credits
= DEFAULT_SMB2_MAX_CREDITS
;
5254 string_set(&Globals
.ncalrpc_dir
, get_dyn_NCALRPCDIR());
5256 /* Now put back the settings that were set with lp_set_cmdline() */
5257 apply_lp_set_cmdline();
5260 /*******************************************************************
5261 Convenience routine to grab string parameters into talloced memory
5262 and run standard_sub_basic on them. The buffers can be written to by
5263 callers without affecting the source string.
5264 ********************************************************************/
5266 static char *lp_string(TALLOC_CTX
*ctx
, const char *s
)
5270 /* The follow debug is useful for tracking down memory problems
5271 especially if you have an inner loop that is calling a lp_*()
5272 function that returns a string. Perhaps this debug should be
5273 present all the time? */
5276 DEBUG(10, ("lp_string(%s)\n", s
));
5282 ret
= talloc_sub_basic(ctx
,
5283 get_current_username(),
5284 current_user_info
.domain
,
5286 if (trim_char(ret
, '\"', '\"')) {
5287 if (strchr(ret
,'\"') != NULL
) {
5289 ret
= talloc_sub_basic(ctx
,
5290 get_current_username(),
5291 current_user_info
.domain
,
5299 In this section all the functions that are used to access the
5300 parameters from the rest of the program are defined
5303 #define FN_GLOBAL_STRING(fn_name,ptr) \
5304 char *lp_ ## fn_name(TALLOC_CTX *ctx) {return(lp_string((ctx), *(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : ""));}
5305 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5306 const char *lp_ ## fn_name(void) {return(*(const char **)(&Globals.ptr) ? *(const char **)(&Globals.ptr) : "");}
5307 #define FN_GLOBAL_LIST(fn_name,ptr) \
5308 const char **lp_ ## fn_name(void) {return(*(const char ***)(&Globals.ptr));}
5309 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5310 bool lp_ ## fn_name(void) {return(*(bool *)(&Globals.ptr));}
5311 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5312 char lp_ ## fn_name(void) {return(*(char *)(&Globals.ptr));}
5313 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5314 int lp_ ## fn_name(void) {return(*(int *)(&Globals.ptr));}
5316 #define FN_LOCAL_STRING(fn_name,val) \
5317 char *lp_ ## fn_name(TALLOC_CTX *ctx,int i) {return(lp_string((ctx), (LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5318 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5319 const char *lp_ ## fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5320 #define FN_LOCAL_LIST(fn_name,val) \
5321 const char **lp_ ## fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5322 #define FN_LOCAL_BOOL(fn_name,val) \
5323 bool lp_ ## fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5324 #define FN_LOCAL_INTEGER(fn_name,val) \
5325 int lp_ ## fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5327 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5328 bool lp_ ## fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5329 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5330 int lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5331 #define FN_LOCAL_CHAR(fn_name,val) \
5332 char lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5335 static FN_GLOBAL_BOOL(domain_logons
, bDomainLogons
)
5336 static FN_GLOBAL_BOOL(_readraw
, bReadRaw
)
5337 static FN_GLOBAL_BOOL(_writeraw
, bWriteRaw
)
5339 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5340 * build process or in smb.conf, we use that value. Otherwise they
5341 * default to the value of lp_lockdir(). */
5342 const char *lp_statedir(void) {
5343 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5344 (strcmp(get_dyn_STATEDIR(), Globals
.szStateDir
) != 0))
5345 return(*(char **)(&Globals
.szStateDir
) ?
5346 *(char **)(&Globals
.szStateDir
) : "");
5348 return(*(char **)(&Globals
.szLockDir
) ?
5349 *(char **)(&Globals
.szLockDir
) : "");
5351 const char *lp_cachedir(void) {
5352 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5353 (strcmp(get_dyn_CACHEDIR(), Globals
.szCacheDir
) != 0))
5354 return(*(char **)(&Globals
.szCacheDir
) ?
5355 *(char **)(&Globals
.szCacheDir
) : "");
5357 return(*(char **)(&Globals
.szLockDir
) ?
5358 *(char **)(&Globals
.szLockDir
) : "");
5360 static FN_GLOBAL_INTEGER(winbind_max_domain_connections_int
,
5361 winbindMaxDomainConnections
)
5363 int lp_winbind_max_domain_connections(void)
5365 if (lp_winbind_offline_logon() &&
5366 lp_winbind_max_domain_connections_int() > 1) {
5367 DEBUG(1, ("offline logons active, restricting max domain "
5368 "connections to 1\n"));
5371 return MAX(1, lp_winbind_max_domain_connections_int());
5374 int lp_smb2_max_credits(void)
5376 if (Globals
.ismb2_max_credits
== 0) {
5377 Globals
.ismb2_max_credits
= DEFAULT_SMB2_MAX_CREDITS
;
5379 return Globals
.ismb2_max_credits
;
5381 int lp_cups_encrypt(void)
5384 #ifdef HAVE_HTTPCONNECTENCRYPT
5385 switch (Globals
.CupsEncrypt
) {
5387 result
= HTTP_ENCRYPT_REQUIRED
;
5390 result
= HTTP_ENCRYPT_ALWAYS
;
5393 result
= HTTP_ENCRYPT_NEVER
;
5400 /* These functions remain in source3/param for now */
5402 FN_GLOBAL_INTEGER(security
, security
)
5403 FN_GLOBAL_INTEGER(usershare_max_shares
, iUsershareMaxShares
)
5404 FN_GLOBAL_STRING(configfile
, szConfigFile
)
5406 #include "lib/param/param_functions.c"
5408 FN_LOCAL_STRING(servicename
, szService
)
5409 FN_LOCAL_CONST_STRING(const_servicename
, szService
)
5411 /* local prototypes */
5413 static int map_parameter_canonical(const char *pszParmName
, bool *inverse
);
5414 static const char *get_boolean(bool bool_value
);
5415 static int getservicebyname(const char *pszServiceName
,
5416 struct loadparm_service
*pserviceDest
);
5417 static void copy_service(struct loadparm_service
*pserviceDest
,
5418 struct loadparm_service
*pserviceSource
,
5419 struct bitmap
*pcopymapDest
);
5420 static bool do_parameter(const char *pszParmName
, const char *pszParmValue
,
5422 static bool do_section(const char *pszSectionName
, void *userdata
);
5423 static void init_copymap(struct loadparm_service
*pservice
);
5424 static bool hash_a_service(const char *name
, int number
);
5425 static void free_service_byindex(int iService
);
5426 static void show_parameter(int parmIndex
);
5427 static bool is_synonym_of(int parm1
, int parm2
, bool *inverse
);
5430 * This is a helper function for parametrical options support. It returns a
5431 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5432 * parametrical functions are quite simple
5434 static struct parmlist_entry
*get_parametrics_by_service(struct loadparm_service
*service
, const char *type
,
5437 bool global_section
= false;
5439 struct parmlist_entry
*data
;
5441 if (service
== NULL
) {
5442 data
= Globals
.param_opt
;
5443 global_section
= true;
5445 data
= service
->param_opt
;
5448 if (asprintf(¶m_key
, "%s:%s", type
, option
) == -1) {
5449 DEBUG(0,("asprintf failed!\n"));
5454 if (strwicmp(data
->key
, param_key
) == 0) {
5455 string_free(¶m_key
);
5461 if (!global_section
) {
5462 /* Try to fetch the same option but from globals */
5463 /* but only if we are not already working with Globals */
5464 data
= Globals
.param_opt
;
5466 if (strwicmp(data
->key
, param_key
) == 0) {
5467 string_free(¶m_key
);
5474 string_free(¶m_key
);
5480 * This is a helper function for parametrical options support. It returns a
5481 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5482 * parametrical functions are quite simple
5484 static struct parmlist_entry
*get_parametrics(int snum
, const char *type
,
5487 if (snum
>= iNumServices
) return NULL
;
5490 return get_parametrics_by_service(NULL
, type
, option
);
5492 return get_parametrics_by_service(ServicePtrs
[snum
], type
, option
);
5497 #define MISSING_PARAMETER(name) \
5498 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5500 /*******************************************************************
5501 convenience routine to return int parameters.
5502 ********************************************************************/
5503 static int lp_int(const char *s
)
5507 MISSING_PARAMETER(lp_int
);
5511 return (int)strtol(s
, NULL
, 0);
5514 /*******************************************************************
5515 convenience routine to return unsigned long parameters.
5516 ********************************************************************/
5517 static unsigned long lp_ulong(const char *s
)
5521 MISSING_PARAMETER(lp_ulong
);
5525 return strtoul(s
, NULL
, 0);
5528 /*******************************************************************
5529 convenience routine to return boolean parameters.
5530 ********************************************************************/
5531 static bool lp_bool(const char *s
)
5536 MISSING_PARAMETER(lp_bool
);
5540 if (!set_boolean(s
, &ret
)) {
5541 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s
));
5548 /*******************************************************************
5549 convenience routine to return enum parameters.
5550 ********************************************************************/
5551 static int lp_enum(const char *s
,const struct enum_list
*_enum
)
5555 if (!s
|| !*s
|| !_enum
) {
5556 MISSING_PARAMETER(lp_enum
);
5560 for (i
=0; _enum
[i
].name
; i
++) {
5561 if (strequal(_enum
[i
].name
,s
))
5562 return _enum
[i
].value
;
5565 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s
));
5569 #undef MISSING_PARAMETER
5571 /* Return parametric option from a given service. Type is a part of option before ':' */
5572 /* Parametric option has following syntax: 'Type: option = value' */
5573 char *lp_parm_talloc_string(TALLOC_CTX
*ctx
, int snum
, const char *type
, const char *option
, const char *def
)
5575 struct parmlist_entry
*data
= get_parametrics(snum
, type
, option
);
5577 if (data
== NULL
||data
->value
==NULL
) {
5579 return lp_string(ctx
, def
);
5585 return lp_string(ctx
, data
->value
);
5588 /* Return parametric option from a given service. Type is a part of option before ':' */
5589 /* Parametric option has following syntax: 'Type: option = value' */
5590 const char *lp_parm_const_string(int snum
, const char *type
, const char *option
, const char *def
)
5592 struct parmlist_entry
*data
= get_parametrics(snum
, type
, option
);
5594 if (data
== NULL
||data
->value
==NULL
)
5600 const char *lp_parm_const_string_service(struct loadparm_service
*service
, const char *type
, const char *option
)
5602 struct parmlist_entry
*data
= get_parametrics_by_service(service
, type
, option
);
5604 if (data
== NULL
||data
->value
==NULL
)
5611 /* Return parametric option from a given service. Type is a part of option before ':' */
5612 /* Parametric option has following syntax: 'Type: option = value' */
5614 const char **lp_parm_string_list(int snum
, const char *type
, const char *option
, const char **def
)
5616 struct parmlist_entry
*data
= get_parametrics(snum
, type
, option
);
5618 if (data
== NULL
||data
->value
==NULL
)
5619 return (const char **)def
;
5621 if (data
->list
==NULL
) {
5622 data
->list
= str_list_make_v3(NULL
, data
->value
, NULL
);
5625 return (const char **)data
->list
;
5628 /* Return parametric option from a given service. Type is a part of option before ':' */
5629 /* Parametric option has following syntax: 'Type: option = value' */
5631 int lp_parm_int(int snum
, const char *type
, const char *option
, int def
)
5633 struct parmlist_entry
*data
= get_parametrics(snum
, type
, option
);
5635 if (data
&& data
->value
&& *data
->value
)
5636 return lp_int(data
->value
);
5641 /* Return parametric option from a given service. Type is a part of option before ':' */
5642 /* Parametric option has following syntax: 'Type: option = value' */
5644 unsigned long lp_parm_ulong(int snum
, const char *type
, const char *option
, unsigned long def
)
5646 struct parmlist_entry
*data
= get_parametrics(snum
, type
, option
);
5648 if (data
&& data
->value
&& *data
->value
)
5649 return lp_ulong(data
->value
);
5654 /* Return parametric option from a given service. Type is a part of option before ':' */
5655 /* Parametric option has following syntax: 'Type: option = value' */
5657 bool lp_parm_bool(int snum
, const char *type
, const char *option
, bool def
)
5659 struct parmlist_entry
*data
= get_parametrics(snum
, type
, option
);
5661 if (data
&& data
->value
&& *data
->value
)
5662 return lp_bool(data
->value
);
5667 /* Return parametric option from a given service. Type is a part of option before ':' */
5668 /* Parametric option has following syntax: 'Type: option = value' */
5670 int lp_parm_enum(int snum
, const char *type
, const char *option
,
5671 const struct enum_list
*_enum
, int def
)
5673 struct parmlist_entry
*data
= get_parametrics(snum
, type
, option
);
5675 if (data
&& data
->value
&& *data
->value
&& _enum
)
5676 return lp_enum(data
->value
, _enum
);
5682 /***************************************************************************
5683 Initialise a service to the defaults.
5684 ***************************************************************************/
5686 static void init_service(struct loadparm_service
*pservice
)
5688 memset((char *)pservice
, '\0', sizeof(struct loadparm_service
));
5689 copy_service(pservice
, &sDefault
, NULL
);
5694 * free a param_opts structure.
5695 * param_opts handling should be moved to talloc;
5696 * then this whole functions reduces to a TALLOC_FREE().
5699 static void free_param_opts(struct parmlist_entry
**popts
)
5701 struct parmlist_entry
*opt
, *next_opt
;
5703 if (popts
== NULL
) {
5707 if (*popts
!= NULL
) {
5708 DEBUG(5, ("Freeing parametrics:\n"));
5711 while (opt
!= NULL
) {
5712 string_free(&opt
->key
);
5713 string_free(&opt
->value
);
5714 TALLOC_FREE(opt
->list
);
5715 next_opt
= opt
->next
;
5722 /***************************************************************************
5723 Free the dynamically allocated parts of a service struct.
5724 ***************************************************************************/
5726 static void free_service(struct loadparm_service
*pservice
)
5731 if (pservice
->szService
)
5732 DEBUG(5, ("free_service: Freeing service %s\n",
5733 pservice
->szService
));
5735 free_parameters(pservice
);
5737 string_free(&pservice
->szService
);
5738 TALLOC_FREE(pservice
->copymap
);
5740 free_param_opts(&pservice
->param_opt
);
5742 ZERO_STRUCTP(pservice
);
5746 /***************************************************************************
5747 remove a service indexed in the ServicePtrs array from the ServiceHash
5748 and free the dynamically allocated parts
5749 ***************************************************************************/
5751 static void free_service_byindex(int idx
)
5753 if ( !LP_SNUM_OK(idx
) )
5756 ServicePtrs
[idx
]->valid
= false;
5757 invalid_services
[num_invalid_services
++] = idx
;
5759 /* we have to cleanup the hash record */
5761 if (ServicePtrs
[idx
]->szService
) {
5762 char *canon_name
= canonicalize_servicename(
5764 ServicePtrs
[idx
]->szService
);
5766 dbwrap_delete_bystring(ServiceHash
, canon_name
);
5767 TALLOC_FREE(canon_name
);
5770 free_service(ServicePtrs
[idx
]);
5773 /***************************************************************************
5774 Add a new service to the services array initialising it with the given
5776 ***************************************************************************/
5778 static int add_a_service(const struct loadparm_service
*pservice
, const char *name
)
5781 struct loadparm_service tservice
;
5782 int num_to_alloc
= iNumServices
+ 1;
5784 tservice
= *pservice
;
5786 /* it might already exist */
5788 i
= getservicebyname(name
, NULL
);
5794 /* find an invalid one */
5796 if (num_invalid_services
> 0) {
5797 i
= invalid_services
[--num_invalid_services
];
5800 /* if not, then create one */
5801 if (i
== iNumServices
) {
5802 struct loadparm_service
**tsp
;
5805 tsp
= SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs
, struct loadparm_service
*, num_to_alloc
);
5807 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
5811 ServicePtrs
[iNumServices
] = SMB_MALLOC_P(struct loadparm_service
);
5812 if (!ServicePtrs
[iNumServices
]) {
5813 DEBUG(0,("add_a_service: out of memory!\n"));
5818 /* enlarge invalid_services here for now... */
5819 tinvalid
= SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services
, int,
5821 if (tinvalid
== NULL
) {
5822 DEBUG(0,("add_a_service: failed to enlarge "
5823 "invalid_services!\n"));
5826 invalid_services
= tinvalid
;
5828 free_service_byindex(i
);
5831 ServicePtrs
[i
]->valid
= true;
5833 init_service(ServicePtrs
[i
]);
5834 copy_service(ServicePtrs
[i
], &tservice
, NULL
);
5836 string_set(&ServicePtrs
[i
]->szService
, name
);
5838 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
5839 i
, ServicePtrs
[i
]->szService
));
5841 if (!hash_a_service(ServicePtrs
[i
]->szService
, i
)) {
5848 /***************************************************************************
5849 Convert a string to uppercase and remove whitespaces.
5850 ***************************************************************************/
5852 char *canonicalize_servicename(TALLOC_CTX
*ctx
, const char *src
)
5857 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
5861 result
= talloc_strdup(ctx
, src
);
5862 SMB_ASSERT(result
!= NULL
);
5868 /***************************************************************************
5869 Add a name/index pair for the services array to the hash table.
5870 ***************************************************************************/
5872 static bool hash_a_service(const char *name
, int idx
)
5876 if ( !ServiceHash
) {
5877 DEBUG(10,("hash_a_service: creating servicehash\n"));
5878 ServiceHash
= db_open_rbt(NULL
);
5879 if ( !ServiceHash
) {
5880 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
5885 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
5888 canon_name
= canonicalize_servicename(talloc_tos(), name
);
5890 dbwrap_store_bystring(ServiceHash
, canon_name
,
5891 make_tdb_data((uint8
*)&idx
, sizeof(idx
)),
5894 TALLOC_FREE(canon_name
);
5899 /***************************************************************************
5900 Add a new home service, with the specified home directory, defaults coming
5902 ***************************************************************************/
5904 bool lp_add_home(const char *pszHomename
, int iDefaultService
,
5905 const char *user
, const char *pszHomedir
)
5909 if (pszHomename
== NULL
|| user
== NULL
|| pszHomedir
== NULL
||
5910 pszHomedir
[0] == '\0') {
5914 i
= add_a_service(ServicePtrs
[iDefaultService
], pszHomename
);
5919 if (!(*(ServicePtrs
[iDefaultService
]->szPath
))
5920 || strequal(ServicePtrs
[iDefaultService
]->szPath
,
5921 lp_pathname(talloc_tos(), GLOBAL_SECTION_SNUM
))) {
5922 string_set(&ServicePtrs
[i
]->szPath
, pszHomedir
);
5925 if (!(*(ServicePtrs
[i
]->comment
))) {
5926 char *comment
= NULL
;
5927 if (asprintf(&comment
, "Home directory of %s", user
) < 0) {
5930 string_set(&ServicePtrs
[i
]->comment
, comment
);
5934 /* set the browseable flag from the global default */
5936 ServicePtrs
[i
]->bBrowseable
= sDefault
.bBrowseable
;
5937 ServicePtrs
[i
]->bAccessBasedShareEnum
= sDefault
.bAccessBasedShareEnum
;
5939 ServicePtrs
[i
]->autoloaded
= true;
5941 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename
,
5942 user
, ServicePtrs
[i
]->szPath
));
5947 /***************************************************************************
5948 Add a new service, based on an old one.
5949 ***************************************************************************/
5951 int lp_add_service(const char *pszService
, int iDefaultService
)
5953 if (iDefaultService
< 0) {
5954 return add_a_service(&sDefault
, pszService
);
5957 return (add_a_service(ServicePtrs
[iDefaultService
], pszService
));
5960 /***************************************************************************
5961 Add the IPC service.
5962 ***************************************************************************/
5964 static bool lp_add_ipc(const char *ipc_name
, bool guest_ok
)
5966 char *comment
= NULL
;
5967 int i
= add_a_service(&sDefault
, ipc_name
);
5972 if (asprintf(&comment
, "IPC Service (%s)",
5973 Globals
.szServerString
) < 0) {
5977 string_set(&ServicePtrs
[i
]->szPath
, tmpdir());
5978 string_set(&ServicePtrs
[i
]->szUsername
, "");
5979 string_set(&ServicePtrs
[i
]->comment
, comment
);
5980 string_set(&ServicePtrs
[i
]->fstype
, "IPC");
5981 ServicePtrs
[i
]->iMaxConnections
= 0;
5982 ServicePtrs
[i
]->bAvailable
= true;
5983 ServicePtrs
[i
]->bRead_only
= true;
5984 ServicePtrs
[i
]->bGuest_only
= false;
5985 ServicePtrs
[i
]->bAdministrative_share
= true;
5986 ServicePtrs
[i
]->bGuest_ok
= guest_ok
;
5987 ServicePtrs
[i
]->bPrint_ok
= false;
5988 ServicePtrs
[i
]->bBrowseable
= sDefault
.bBrowseable
;
5990 DEBUG(3, ("adding IPC service\n"));
5996 /***************************************************************************
5997 Add a new printer service, with defaults coming from service iFrom.
5998 ***************************************************************************/
6000 bool lp_add_printer(const char *pszPrintername
, int iDefaultService
)
6002 const char *comment
= "From Printcap";
6003 int i
= add_a_service(ServicePtrs
[iDefaultService
], pszPrintername
);
6008 /* note that we do NOT default the availability flag to true - */
6009 /* we take it from the default service passed. This allows all */
6010 /* dynamic printers to be disabled by disabling the [printers] */
6011 /* entry (if/when the 'available' keyword is implemented!). */
6013 /* the printer name is set to the service name. */
6014 string_set(&ServicePtrs
[i
]->szPrintername
, pszPrintername
);
6015 string_set(&ServicePtrs
[i
]->comment
, comment
);
6017 /* set the browseable flag from the gloabl default */
6018 ServicePtrs
[i
]->bBrowseable
= sDefault
.bBrowseable
;
6020 /* Printers cannot be read_only. */
6021 ServicePtrs
[i
]->bRead_only
= false;
6022 /* No share modes on printer services. */
6023 ServicePtrs
[i
]->bShareModes
= false;
6024 /* No oplocks on printer services. */
6025 ServicePtrs
[i
]->bOpLocks
= false;
6026 /* Printer services must be printable. */
6027 ServicePtrs
[i
]->bPrint_ok
= true;
6029 DEBUG(3, ("adding printer service %s\n", pszPrintername
));
6035 /***************************************************************************
6036 Check whether the given parameter name is valid.
6037 Parametric options (names containing a colon) are considered valid.
6038 ***************************************************************************/
6040 bool lp_parameter_is_valid(const char *pszParmName
)
6042 return ((map_parameter(pszParmName
) != -1) ||
6043 (strchr(pszParmName
, ':') != NULL
));
6046 /***************************************************************************
6047 Check whether the given name is the name of a global parameter.
6048 Returns true for strings belonging to parameters of class
6049 P_GLOBAL, false for all other strings, also for parametric options
6050 and strings not belonging to any option.
6051 ***************************************************************************/
6053 bool lp_parameter_is_global(const char *pszParmName
)
6055 int num
= map_parameter(pszParmName
);
6058 return (parm_table
[num
].p_class
== P_GLOBAL
);
6064 /**************************************************************************
6065 Check whether the given name is the canonical name of a parameter.
6066 Returns false if it is not a valid parameter Name.
6067 For parametric options, true is returned.
6068 **************************************************************************/
6070 bool lp_parameter_is_canonical(const char *parm_name
)
6072 if (!lp_parameter_is_valid(parm_name
)) {
6076 return (map_parameter(parm_name
) ==
6077 map_parameter_canonical(parm_name
, NULL
));
6080 /**************************************************************************
6081 Determine the canonical name for a parameter.
6082 Indicate when it is an inverse (boolean) synonym instead of a
6084 **************************************************************************/
6086 bool lp_canonicalize_parameter(const char *parm_name
, const char **canon_parm
,
6091 if (!lp_parameter_is_valid(parm_name
)) {
6096 num
= map_parameter_canonical(parm_name
, inverse
);
6098 /* parametric option */
6099 *canon_parm
= parm_name
;
6101 *canon_parm
= parm_table
[num
].label
;
6108 /**************************************************************************
6109 Determine the canonical name for a parameter.
6110 Turn the value given into the inverse boolean expression when
6111 the synonym is an invers boolean synonym.
6113 Return true if parm_name is a valid parameter name and
6114 in case it is an invers boolean synonym, if the val string could
6115 successfully be converted to the reverse bool.
6116 Return false in all other cases.
6117 **************************************************************************/
6119 bool lp_canonicalize_parameter_with_value(const char *parm_name
,
6121 const char **canon_parm
,
6122 const char **canon_val
)
6127 if (!lp_parameter_is_valid(parm_name
)) {
6133 num
= map_parameter_canonical(parm_name
, &inverse
);
6135 /* parametric option */
6136 *canon_parm
= parm_name
;
6139 *canon_parm
= parm_table
[num
].label
;
6141 if (!lp_invert_boolean(val
, canon_val
)) {
6153 /***************************************************************************
6154 Map a parameter's string representation to something we can use.
6155 Returns false if the parameter string is not recognised, else TRUE.
6156 ***************************************************************************/
6158 static int map_parameter(const char *pszParmName
)
6162 if (*pszParmName
== '-' && !strequal(pszParmName
, "-valid"))
6165 for (iIndex
= 0; parm_table
[iIndex
].label
; iIndex
++)
6166 if (strwicmp(parm_table
[iIndex
].label
, pszParmName
) == 0)
6169 /* Warn only if it isn't parametric option */
6170 if (strchr(pszParmName
, ':') == NULL
)
6171 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName
));
6172 /* We do return 'fail' for parametric options as well because they are
6173 stored in different storage
6178 /***************************************************************************
6179 Map a parameter's string representation to the index of the canonical
6180 form of the parameter (it might be a synonym).
6181 Returns -1 if the parameter string is not recognised.
6182 ***************************************************************************/
6184 static int map_parameter_canonical(const char *pszParmName
, bool *inverse
)
6186 int parm_num
, canon_num
;
6187 bool loc_inverse
= false;
6189 parm_num
= map_parameter(pszParmName
);
6190 if ((parm_num
< 0) || !(parm_table
[parm_num
].flags
& FLAG_HIDE
)) {
6191 /* invalid, parametric or no canidate for synonyms ... */
6195 for (canon_num
= 0; parm_table
[canon_num
].label
; canon_num
++) {
6196 if (is_synonym_of(parm_num
, canon_num
, &loc_inverse
)) {
6197 parm_num
= canon_num
;
6203 if (inverse
!= NULL
) {
6204 *inverse
= loc_inverse
;
6209 /***************************************************************************
6210 return true if parameter number parm1 is a synonym of parameter
6211 number parm2 (parm2 being the principal name).
6212 set inverse to true if parm1 is P_BOOLREV and parm2 is P_BOOL,
6214 ***************************************************************************/
6216 static bool is_synonym_of(int parm1
, int parm2
, bool *inverse
)
6218 if ((parm_table
[parm1
].offset
== parm_table
[parm2
].offset
) &&
6219 (parm_table
[parm1
].p_class
== parm_table
[parm2
].p_class
) &&
6220 (parm_table
[parm1
].flags
& FLAG_HIDE
) &&
6221 !(parm_table
[parm2
].flags
& FLAG_HIDE
))
6223 if (inverse
!= NULL
) {
6224 if ((parm_table
[parm1
].type
== P_BOOLREV
) &&
6225 (parm_table
[parm2
].type
== P_BOOL
))
6237 /***************************************************************************
6238 Show one parameter's name, type, [values,] and flags.
6239 (helper functions for show_parameter_list)
6240 ***************************************************************************/
6242 static void show_parameter(int parmIndex
)
6244 int enumIndex
, flagIndex
;
6249 const char *type
[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6250 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6252 unsigned flags
[] = { FLAG_BASIC
, FLAG_SHARE
, FLAG_PRINT
, FLAG_GLOBAL
,
6253 FLAG_WIZARD
, FLAG_ADVANCED
, FLAG_DEVELOPER
, FLAG_DEPRECATED
,
6255 const char *flag_names
[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6256 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6257 "FLAG_DEPRECATED", "FLAG_HIDE", NULL
};
6259 printf("%s=%s", parm_table
[parmIndex
].label
,
6260 type
[parm_table
[parmIndex
].type
]);
6261 if (parm_table
[parmIndex
].type
== P_ENUM
) {
6264 parm_table
[parmIndex
].enum_list
[enumIndex
].name
;
6268 enumIndex
? "|" : "",
6269 parm_table
[parmIndex
].enum_list
[enumIndex
].name
);
6274 for (flagIndex
=0; flag_names
[flagIndex
]; flagIndex
++) {
6275 if (parm_table
[parmIndex
].flags
& flags
[flagIndex
]) {
6278 flag_names
[flagIndex
]);
6283 /* output synonyms */
6285 for (parmIndex2
=0; parm_table
[parmIndex2
].label
; parmIndex2
++) {
6286 if (is_synonym_of(parmIndex
, parmIndex2
, &inverse
)) {
6287 printf(" (%ssynonym of %s)", inverse
? "inverse " : "",
6288 parm_table
[parmIndex2
].label
);
6289 } else if (is_synonym_of(parmIndex2
, parmIndex
, &inverse
)) {
6291 printf(" (synonyms: ");
6296 printf("%s%s", parm_table
[parmIndex2
].label
,
6297 inverse
? "[i]" : "");
6307 /***************************************************************************
6308 Show all parameter's name, type, [values,] and flags.
6309 ***************************************************************************/
6311 void show_parameter_list(void)
6313 int classIndex
, parmIndex
;
6314 const char *section_names
[] = { "local", "global", NULL
};
6316 for (classIndex
=0; section_names
[classIndex
]; classIndex
++) {
6317 printf("[%s]\n", section_names
[classIndex
]);
6318 for (parmIndex
= 0; parm_table
[parmIndex
].label
; parmIndex
++) {
6319 if (parm_table
[parmIndex
].p_class
== classIndex
) {
6320 show_parameter(parmIndex
);
6326 /***************************************************************************
6327 Check if a given string correctly represents a boolean value.
6328 ***************************************************************************/
6330 bool lp_string_is_valid_boolean(const char *parm_value
)
6332 return set_boolean(parm_value
, NULL
);
6335 /***************************************************************************
6336 Get the standard string representation of a boolean value ("yes" or "no")
6337 ***************************************************************************/
6339 static const char *get_boolean(bool bool_value
)
6341 static const char *yes_str
= "yes";
6342 static const char *no_str
= "no";
6344 return (bool_value
? yes_str
: no_str
);
6347 /***************************************************************************
6348 Provide the string of the negated boolean value associated to the boolean
6349 given as a string. Returns false if the passed string does not correctly
6350 represent a boolean.
6351 ***************************************************************************/
6353 bool lp_invert_boolean(const char *str
, const char **inverse_str
)
6357 if (!set_boolean(str
, &val
)) {
6361 *inverse_str
= get_boolean(!val
);
6365 /***************************************************************************
6366 Provide the canonical string representation of a boolean value given
6367 as a string. Return true on success, false if the string given does
6368 not correctly represent a boolean.
6369 ***************************************************************************/
6371 bool lp_canonicalize_boolean(const char *str
, const char**canon_str
)
6375 if (!set_boolean(str
, &val
)) {
6379 *canon_str
= get_boolean(val
);
6383 /***************************************************************************
6384 Find a service by name. Otherwise works like get_service.
6385 ***************************************************************************/
6387 static int getservicebyname(const char *pszServiceName
, struct loadparm_service
*pserviceDest
)
6394 if (ServiceHash
== NULL
) {
6398 canon_name
= canonicalize_servicename(talloc_tos(), pszServiceName
);
6400 status
= dbwrap_fetch_bystring(ServiceHash
, canon_name
, canon_name
,
6403 if (NT_STATUS_IS_OK(status
) &&
6404 (data
.dptr
!= NULL
) &&
6405 (data
.dsize
== sizeof(iService
)))
6407 iService
= *(int *)data
.dptr
;
6410 TALLOC_FREE(canon_name
);
6412 if ((iService
!= -1) && (LP_SNUM_OK(iService
))
6413 && (pserviceDest
!= NULL
)) {
6414 copy_service(pserviceDest
, ServicePtrs
[iService
], NULL
);
6420 /* Return a pointer to a service by name. Unlike getservicebyname, it does not copy the service */
6421 struct loadparm_service
*lp_service(const char *pszServiceName
)
6423 int iService
= getservicebyname(pszServiceName
, NULL
);
6424 if (iService
== -1 || !LP_SNUM_OK(iService
)) {
6427 return ServicePtrs
[iService
];
6430 struct loadparm_service
*lp_servicebynum(int snum
)
6432 if ((snum
== -1) || !LP_SNUM_OK(snum
)) {
6435 return ServicePtrs
[snum
];
6438 struct loadparm_service
*lp_default_loadparm_service()
6444 /***************************************************************************
6445 Copy a service structure to another.
6446 If pcopymapDest is NULL then copy all fields
6447 ***************************************************************************/
6450 * Add a parametric option to a parmlist_entry,
6451 * replacing old value, if already present.
6453 static void set_param_opt(struct parmlist_entry
**opt_list
,
6454 const char *opt_name
,
6455 const char *opt_value
,
6458 struct parmlist_entry
*new_opt
, *opt
;
6461 if (opt_list
== NULL
) {
6468 /* Traverse destination */
6470 /* If we already have same option, override it */
6471 if (strwicmp(opt
->key
, opt_name
) == 0) {
6472 if ((opt
->priority
& FLAG_CMDLINE
) &&
6473 !(priority
& FLAG_CMDLINE
)) {
6474 /* it's been marked as not to be
6478 string_free(&opt
->value
);
6479 TALLOC_FREE(opt
->list
);
6480 opt
->value
= SMB_STRDUP(opt_value
);
6481 opt
->priority
= priority
;
6488 new_opt
= SMB_XMALLOC_P(struct parmlist_entry
);
6489 new_opt
->key
= SMB_STRDUP(opt_name
);
6490 new_opt
->value
= SMB_STRDUP(opt_value
);
6491 new_opt
->list
= NULL
;
6492 new_opt
->priority
= priority
;
6493 DLIST_ADD(*opt_list
, new_opt
);
6497 static void copy_service(struct loadparm_service
*pserviceDest
, struct loadparm_service
*pserviceSource
,
6498 struct bitmap
*pcopymapDest
)
6501 bool bcopyall
= (pcopymapDest
== NULL
);
6502 struct parmlist_entry
*data
;
6504 for (i
= 0; parm_table
[i
].label
; i
++)
6505 if (parm_table
[i
].p_class
== P_LOCAL
&&
6506 (bcopyall
|| bitmap_query(pcopymapDest
,i
))) {
6507 void *src_ptr
= lp_parm_ptr(pserviceSource
, &parm_table
[i
]);
6508 void *dest_ptr
= lp_parm_ptr(pserviceDest
, &parm_table
[i
]);
6510 switch (parm_table
[i
].type
) {
6513 *(bool *)dest_ptr
= *(bool *)src_ptr
;
6520 *(int *)dest_ptr
= *(int *)src_ptr
;
6524 *(char *)dest_ptr
= *(char *)src_ptr
;
6528 string_set((char **)dest_ptr
,
6534 char *upper_string
= strupper_talloc(talloc_tos(),
6536 string_set((char **)dest_ptr
,
6538 TALLOC_FREE(upper_string
);
6542 TALLOC_FREE(*((char ***)dest_ptr
));
6543 *((char ***)dest_ptr
) = str_list_copy(NULL
,
6544 *(const char ***)src_ptr
);
6552 init_copymap(pserviceDest
);
6553 if (pserviceSource
->copymap
)
6554 bitmap_copy(pserviceDest
->copymap
,
6555 pserviceSource
->copymap
);
6558 data
= pserviceSource
->param_opt
;
6560 set_param_opt(&pserviceDest
->param_opt
, data
->key
, data
->value
, data
->priority
);
6565 /***************************************************************************
6566 Check a service for consistency. Return false if the service is in any way
6567 incomplete or faulty, else true.
6568 ***************************************************************************/
6570 bool service_ok(int iService
)
6575 if (ServicePtrs
[iService
]->szService
[0] == '\0') {
6576 DEBUG(0, ("The following message indicates an internal error:\n"));
6577 DEBUG(0, ("No service name in service entry.\n"));
6581 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6582 /* I can't see why you'd want a non-printable printer service... */
6583 if (strwicmp(ServicePtrs
[iService
]->szService
, PRINTERS_NAME
) == 0) {
6584 if (!ServicePtrs
[iService
]->bPrint_ok
) {
6585 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6586 ServicePtrs
[iService
]->szService
));
6587 ServicePtrs
[iService
]->bPrint_ok
= true;
6589 /* [printers] service must also be non-browsable. */
6590 if (ServicePtrs
[iService
]->bBrowseable
)
6591 ServicePtrs
[iService
]->bBrowseable
= false;
6594 if (ServicePtrs
[iService
]->szPath
[0] == '\0' &&
6595 strwicmp(ServicePtrs
[iService
]->szService
, HOMES_NAME
) != 0 &&
6596 ServicePtrs
[iService
]->szMSDfsProxy
[0] == '\0'
6598 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6599 ServicePtrs
[iService
]->szService
));
6600 ServicePtrs
[iService
]->bAvailable
= false;
6603 /* If a service is flagged unavailable, log the fact at level 1. */
6604 if (!ServicePtrs
[iService
]->bAvailable
)
6605 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6606 ServicePtrs
[iService
]->szService
));
6611 static struct smbconf_ctx
*lp_smbconf_ctx(void)
6614 static struct smbconf_ctx
*conf_ctx
= NULL
;
6616 if (conf_ctx
== NULL
) {
6617 err
= smbconf_init(NULL
, &conf_ctx
, "registry:");
6618 if (!SBC_ERROR_IS_OK(err
)) {
6619 DEBUG(1, ("error initializing registry configuration: "
6620 "%s\n", sbcErrorString(err
)));
6628 static bool process_smbconf_service(struct smbconf_service
*service
)
6633 if (service
== NULL
) {
6637 ret
= do_section(service
->name
, NULL
);
6641 for (count
= 0; count
< service
->num_params
; count
++) {
6642 ret
= do_parameter(service
->param_names
[count
],
6643 service
->param_values
[count
],
6649 if (iServiceIndex
>= 0) {
6650 return service_ok(iServiceIndex
);
6656 * load a service from registry and activate it
6658 bool process_registry_service(const char *service_name
)
6661 struct smbconf_service
*service
= NULL
;
6662 TALLOC_CTX
*mem_ctx
= talloc_stackframe();
6663 struct smbconf_ctx
*conf_ctx
= lp_smbconf_ctx();
6666 if (conf_ctx
== NULL
) {
6670 DEBUG(5, ("process_registry_service: service name %s\n", service_name
));
6672 if (!smbconf_share_exists(conf_ctx
, service_name
)) {
6674 * Registry does not contain data for this service (yet),
6675 * but make sure lp_load doesn't return false.
6681 err
= smbconf_get_share(conf_ctx
, mem_ctx
, service_name
, &service
);
6682 if (!SBC_ERROR_IS_OK(err
)) {
6686 ret
= process_smbconf_service(service
);
6692 smbconf_changed(conf_ctx
, &conf_last_csn
, NULL
, NULL
);
6695 TALLOC_FREE(mem_ctx
);
6700 * process_registry_globals
6702 static bool process_registry_globals(void)
6706 add_to_file_list(INCLUDE_REGISTRY_NAME
, INCLUDE_REGISTRY_NAME
);
6708 ret
= do_parameter("registry shares", "yes", NULL
);
6713 return process_registry_service(GLOBAL_NAME
);
6716 bool process_registry_shares(void)
6720 struct smbconf_service
**service
= NULL
;
6721 uint32_t num_shares
= 0;
6722 TALLOC_CTX
*mem_ctx
= talloc_stackframe();
6723 struct smbconf_ctx
*conf_ctx
= lp_smbconf_ctx();
6726 if (conf_ctx
== NULL
) {
6730 err
= smbconf_get_config(conf_ctx
, mem_ctx
, &num_shares
, &service
);
6731 if (!SBC_ERROR_IS_OK(err
)) {
6737 for (count
= 0; count
< num_shares
; count
++) {
6738 if (strequal(service
[count
]->name
, GLOBAL_NAME
)) {
6741 ret
= process_smbconf_service(service
[count
]);
6748 smbconf_changed(conf_ctx
, &conf_last_csn
, NULL
, NULL
);
6751 TALLOC_FREE(mem_ctx
);
6756 * reload those shares from registry that are already
6757 * activated in the services array.
6759 static bool reload_registry_shares(void)
6764 for (i
= 0; i
< iNumServices
; i
++) {
6769 if (ServicePtrs
[i
]->usershare
== USERSHARE_VALID
) {
6773 ret
= process_registry_service(ServicePtrs
[i
]->szService
);
6784 #define MAX_INCLUDE_DEPTH 100
6786 static uint8_t include_depth
;
6788 static struct file_lists
{
6789 struct file_lists
*next
;
6793 } *file_lists
= NULL
;
6795 /*******************************************************************
6796 Keep a linked list of all config files so we know when one has changed
6797 it's date and needs to be reloaded.
6798 ********************************************************************/
6800 static void add_to_file_list(const char *fname
, const char *subfname
)
6802 struct file_lists
*f
= file_lists
;
6805 if (f
->name
&& !strcmp(f
->name
, fname
))
6811 f
= SMB_MALLOC_P(struct file_lists
);
6814 f
->next
= file_lists
;
6815 f
->name
= SMB_STRDUP(fname
);
6820 f
->subfname
= SMB_STRDUP(subfname
);
6827 f
->modtime
= file_modtime(subfname
);
6829 time_t t
= file_modtime(subfname
);
6837 * Free the file lists
6839 static void free_file_list(void)
6841 struct file_lists
*f
;
6842 struct file_lists
*next
;
6847 SAFE_FREE( f
->name
);
6848 SAFE_FREE( f
->subfname
);
6857 * Utility function for outsiders to check if we're running on registry.
6859 bool lp_config_backend_is_registry(void)
6861 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY
);
6865 * Utility function to check if the config backend is FILE.
6867 bool lp_config_backend_is_file(void)
6869 return (lp_config_backend() == CONFIG_BACKEND_FILE
);
6872 /*******************************************************************
6873 Check if a config file has changed date.
6874 ********************************************************************/
6876 bool lp_file_list_changed(void)
6878 struct file_lists
*f
= file_lists
;
6880 DEBUG(6, ("lp_file_list_changed()\n"));
6885 if (strequal(f
->name
, INCLUDE_REGISTRY_NAME
)) {
6886 struct smbconf_ctx
*conf_ctx
= lp_smbconf_ctx();
6888 if (conf_ctx
== NULL
) {
6891 if (smbconf_changed(conf_ctx
, &conf_last_csn
, NULL
,
6894 DEBUGADD(6, ("registry config changed\n"));
6899 n2
= talloc_sub_basic(talloc_tos(),
6900 get_current_username(),
6901 current_user_info
.domain
,
6906 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
6907 f
->name
, n2
, ctime(&f
->modtime
)));
6909 mod_time
= file_modtime(n2
);
6912 ((f
->modtime
!= mod_time
) ||
6913 (f
->subfname
== NULL
) ||
6914 (strcmp(n2
, f
->subfname
) != 0)))
6917 ("file %s modified: %s\n", n2
,
6919 f
->modtime
= mod_time
;
6920 SAFE_FREE(f
->subfname
);
6921 f
->subfname
= SMB_STRDUP(n2
);
6934 * Initialize iconv conversion descriptors.
6936 * This is called the first time it is needed, and also called again
6937 * every time the configuration is reloaded, because the charset or
6938 * codepage might have changed.
6940 static void init_iconv(void)
6942 global_iconv_handle
= smb_iconv_handle_reinit(NULL
, lp_dos_charset(),
6944 true, global_iconv_handle
);
6947 static bool handle_charset(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
)
6949 if (strcmp(*ptr
, pszParmValue
) != 0) {
6950 string_set(ptr
, pszParmValue
);
6956 static bool handle_dos_charset(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
)
6958 bool is_utf8
= false;
6959 size_t len
= strlen(pszParmValue
);
6961 if (len
== 4 || len
== 5) {
6962 /* Don't use StrCaseCmp here as we don't want to
6963 initialize iconv. */
6964 if ((toupper_m(pszParmValue
[0]) == 'U') &&
6965 (toupper_m(pszParmValue
[1]) == 'T') &&
6966 (toupper_m(pszParmValue
[2]) == 'F')) {
6968 if (pszParmValue
[3] == '8') {
6972 if (pszParmValue
[3] == '-' &&
6973 pszParmValue
[4] == '8') {
6980 if (strcmp(*ptr
, pszParmValue
) != 0) {
6982 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
6983 "be UTF8, using (default value) %s instead.\n",
6984 DEFAULT_DOS_CHARSET
));
6985 pszParmValue
= DEFAULT_DOS_CHARSET
;
6987 string_set(ptr
, pszParmValue
);
6993 static bool handle_realm(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
)
6996 char *realm
= strupper_talloc(talloc_tos(), pszParmValue
);
6997 char *dnsdomain
= strlower_talloc(realm
, pszParmValue
);
6999 ret
&= string_set(&Globals
.szRealm
, pszParmValue
);
7000 ret
&= string_set(&Globals
.szRealm_upper
, realm
);
7001 ret
&= string_set(&Globals
.szRealm_lower
, dnsdomain
);
7007 static bool handle_netbios_aliases(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
)
7009 TALLOC_FREE(Globals
.szNetbiosAliases
);
7010 Globals
.szNetbiosAliases
= (const char **)str_list_make_v3(NULL
, pszParmValue
, NULL
);
7011 return set_netbios_aliases(Globals
.szNetbiosAliases
);
7014 /***************************************************************************
7015 Handle the include operation.
7016 ***************************************************************************/
7017 static bool bAllowIncludeRegistry
= true;
7019 static bool handle_include(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
)
7023 if (include_depth
>= MAX_INCLUDE_DEPTH
) {
7024 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
7029 if (strequal(pszParmValue
, INCLUDE_REGISTRY_NAME
)) {
7030 if (!bAllowIncludeRegistry
) {
7033 if (bInGlobalSection
) {
7036 ret
= process_registry_globals();
7040 DEBUG(1, ("\"include = registry\" only effective "
7041 "in %s section\n", GLOBAL_NAME
));
7046 fname
= talloc_sub_basic(talloc_tos(), get_current_username(),
7047 current_user_info
.domain
,
7050 add_to_file_list(pszParmValue
, fname
);
7052 string_set(ptr
, fname
);
7054 if (file_exist(fname
)) {
7057 ret
= pm_process(fname
, do_section
, do_parameter
, NULL
);
7063 DEBUG(2, ("Can't find include file %s\n", fname
));
7068 /***************************************************************************
7069 Handle the interpretation of the copy parameter.
7070 ***************************************************************************/
7072 static bool handle_copy(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
)
7076 struct loadparm_service serviceTemp
;
7078 string_set(ptr
, pszParmValue
);
7080 init_service(&serviceTemp
);
7084 DEBUG(3, ("Copying service from service %s\n", pszParmValue
));
7086 if ((iTemp
= getservicebyname(pszParmValue
, &serviceTemp
)) >= 0) {
7087 if (iTemp
== iServiceIndex
) {
7088 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue
));
7090 copy_service(ServicePtrs
[iServiceIndex
],
7092 ServicePtrs
[iServiceIndex
]->copymap
);
7096 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue
));
7100 free_service(&serviceTemp
);
7104 static bool handle_ldap_debug_level(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
)
7106 Globals
.ldap_debug_level
= lp_int(pszParmValue
);
7107 init_ldap_debugging();
7111 /***************************************************************************
7112 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7117 idmap uid = 1000-1999
7120 We only do simple parsing checks here. The strings are parsed into useful
7121 structures in the idmap daemon code.
7123 ***************************************************************************/
7125 /* Some lp_ routines to return idmap [ug]id information */
7127 static uid_t idmap_uid_low
, idmap_uid_high
;
7128 static gid_t idmap_gid_low
, idmap_gid_high
;
7130 bool lp_idmap_uid(uid_t
*low
, uid_t
*high
)
7132 if (idmap_uid_low
== 0 || idmap_uid_high
== 0)
7136 *low
= idmap_uid_low
;
7139 *high
= idmap_uid_high
;
7144 bool lp_idmap_gid(gid_t
*low
, gid_t
*high
)
7146 if (idmap_gid_low
== 0 || idmap_gid_high
== 0)
7150 *low
= idmap_gid_low
;
7153 *high
= idmap_gid_high
;
7158 static bool handle_idmap_backend(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
)
7160 lp_do_parameter(snum
, "idmap config * : backend", pszParmValue
);
7165 /* Do some simple checks on "idmap [ug]id" parameter values */
7167 static bool handle_idmap_uid(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
)
7169 lp_do_parameter(snum
, "idmap config * : range", pszParmValue
);
7174 static bool handle_idmap_gid(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
)
7176 lp_do_parameter(snum
, "idmap config * : range", pszParmValue
);
7181 /***************************************************************************
7182 Handle the DEBUG level list.
7183 ***************************************************************************/
7185 static bool handle_debug_list(struct loadparm_context
*unused
, int snum
, const char *pszParmValueIn
, char **ptr
)
7187 string_set(ptr
, pszParmValueIn
);
7188 return debug_parse_levels(pszParmValueIn
);
7191 /***************************************************************************
7192 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7193 ***************************************************************************/
7195 static const char *append_ldap_suffix(TALLOC_CTX
*ctx
, const char *str
)
7197 const char *suffix_string
;
7199 suffix_string
= talloc_asprintf(ctx
, "%s,%s", str
,
7200 Globals
.szLdapSuffix
);
7201 if ( !suffix_string
) {
7202 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7206 return suffix_string
;
7209 const char *lp_ldap_machine_suffix(TALLOC_CTX
*ctx
)
7211 if (Globals
.szLdapMachineSuffix
[0])
7212 return append_ldap_suffix(ctx
, Globals
.szLdapMachineSuffix
);
7214 return lp_string(ctx
, Globals
.szLdapSuffix
);
7217 const char *lp_ldap_user_suffix(TALLOC_CTX
*ctx
)
7219 if (Globals
.szLdapUserSuffix
[0])
7220 return append_ldap_suffix(ctx
, Globals
.szLdapUserSuffix
);
7222 return lp_string(ctx
, Globals
.szLdapSuffix
);
7225 const char *lp_ldap_group_suffix(TALLOC_CTX
*ctx
)
7227 if (Globals
.szLdapGroupSuffix
[0])
7228 return append_ldap_suffix(ctx
, Globals
.szLdapGroupSuffix
);
7230 return lp_string(ctx
, Globals
.szLdapSuffix
);
7233 const char *lp_ldap_idmap_suffix(TALLOC_CTX
*ctx
)
7235 if (Globals
.szLdapIdmapSuffix
[0])
7236 return append_ldap_suffix(ctx
, Globals
.szLdapIdmapSuffix
);
7238 return lp_string(ctx
, Globals
.szLdapSuffix
);
7241 /****************************************************************************
7242 set the value for a P_ENUM
7243 ***************************************************************************/
7245 static void lp_set_enum_parm( struct parm_struct
*parm
, const char *pszParmValue
,
7250 for (i
= 0; parm
->enum_list
[i
].name
; i
++) {
7251 if ( strequal(pszParmValue
, parm
->enum_list
[i
].name
)) {
7252 *ptr
= parm
->enum_list
[i
].value
;
7256 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7257 pszParmValue
, parm
->label
));
7260 /***************************************************************************
7261 ***************************************************************************/
7263 static bool handle_printing(struct loadparm_context
*unused
, int snum
, const char *pszParmValue
, char **ptr
)
7265 static int parm_num
= -1;
7266 struct loadparm_service
*s
;
7268 if ( parm_num
== -1 )
7269 parm_num
= map_parameter( "printing" );
7271 lp_set_enum_parm( &parm_table
[parm_num
], pszParmValue
, (int*)ptr
);
7276 s
= ServicePtrs
[snum
];
7278 init_printer_values( s
);
7284 /***************************************************************************
7285 Initialise a copymap.
7286 ***************************************************************************/
7288 static void init_copymap(struct loadparm_service
*pservice
)
7292 TALLOC_FREE(pservice
->copymap
);
7294 pservice
->copymap
= bitmap_talloc(NULL
, NUMPARAMETERS
);
7295 if (!pservice
->copymap
)
7297 ("Couldn't allocate copymap!! (size %d)\n",
7298 (int)NUMPARAMETERS
));
7300 for (i
= 0; i
< NUMPARAMETERS
; i
++)
7301 bitmap_set(pservice
->copymap
, i
);
7305 return the parameter pointer for a parameter
7307 void *lp_parm_ptr(struct loadparm_service
*service
, struct parm_struct
*parm
)
7309 if (service
== NULL
) {
7310 if (parm
->p_class
== P_LOCAL
)
7311 return (void *)(((char *)&sDefault
)+parm
->offset
);
7312 else if (parm
->p_class
== P_GLOBAL
)
7313 return (void *)(((char *)&Globals
)+parm
->offset
);
7316 return (void *)(((char *)service
) + parm
->offset
);
7320 /***************************************************************************
7321 Return the local pointer to a parameter given the service number and parameter
7322 ***************************************************************************/
7324 void *lp_local_ptr_by_snum(int snum
, struct parm_struct
*parm
)
7326 return lp_parm_ptr(ServicePtrs
[snum
], parm
);
7329 /***************************************************************************
7330 Process a parameter for a particular service number. If snum < 0
7331 then assume we are in the globals.
7332 ***************************************************************************/
7334 bool lp_do_parameter(int snum
, const char *pszParmName
, const char *pszParmValue
)
7337 void *parm_ptr
= NULL
; /* where we are going to store the result */
7338 struct parmlist_entry
**opt_list
;
7340 parmnum
= map_parameter(pszParmName
);
7343 if (strchr(pszParmName
, ':') == NULL
) {
7344 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7350 * We've got a parametric option
7353 opt_list
= (snum
< 0)
7354 ? &Globals
.param_opt
: &ServicePtrs
[snum
]->param_opt
;
7355 set_param_opt(opt_list
, pszParmName
, pszParmValue
, 0);
7360 /* if it's already been set by the command line, then we don't
7362 if (parm_table
[parmnum
].flags
& FLAG_CMDLINE
) {
7366 if (parm_table
[parmnum
].flags
& FLAG_DEPRECATED
) {
7367 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7371 /* we might point at a service, the default service or a global */
7373 parm_ptr
= lp_parm_ptr(NULL
, &parm_table
[parmnum
]);
7375 if (parm_table
[parmnum
].p_class
== P_GLOBAL
) {
7377 ("Global parameter %s found in service section!\n",
7381 parm_ptr
= lp_local_ptr_by_snum(snum
, &parm_table
[parmnum
]);
7385 if (!ServicePtrs
[snum
]->copymap
)
7386 init_copymap(ServicePtrs
[snum
]);
7388 /* this handles the aliases - set the copymap for other entries with
7389 the same data pointer */
7390 for (i
= 0; parm_table
[i
].label
; i
++) {
7391 if ((parm_table
[i
].offset
== parm_table
[parmnum
].offset
)
7392 && (parm_table
[i
].p_class
== parm_table
[parmnum
].p_class
)) {
7393 bitmap_clear(ServicePtrs
[snum
]->copymap
, i
);
7398 /* if it is a special case then go ahead */
7399 if (parm_table
[parmnum
].special
) {
7400 return parm_table
[parmnum
].special(NULL
, snum
, pszParmValue
,
7404 /* now switch on the type of variable it is */
7405 switch (parm_table
[parmnum
].type
)
7408 *(bool *)parm_ptr
= lp_bool(pszParmValue
);
7412 *(bool *)parm_ptr
= !lp_bool(pszParmValue
);
7416 *(int *)parm_ptr
= lp_int(pszParmValue
);
7420 *(char *)parm_ptr
= *pszParmValue
;
7424 i
= sscanf(pszParmValue
, "%o", (int *)parm_ptr
);
7426 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName
));
7433 if (conv_str_size_error(pszParmValue
, &val
)) {
7434 if (val
<= INT_MAX
) {
7435 *(int *)parm_ptr
= (int)val
;
7440 DEBUG(0,("lp_do_parameter(%s): value is not "
7441 "a valid size specifier!\n", pszParmValue
));
7447 TALLOC_FREE(*((char ***)parm_ptr
));
7448 *(char ***)parm_ptr
= str_list_make_v3(
7449 NULL
, pszParmValue
, NULL
);
7453 string_set((char **)parm_ptr
, pszParmValue
);
7458 char *upper_string
= strupper_talloc(talloc_tos(),
7460 string_set((char **)parm_ptr
, upper_string
);
7461 TALLOC_FREE(upper_string
);
7465 lp_set_enum_parm( &parm_table
[parmnum
], pszParmValue
, (int*)parm_ptr
);
7474 /***************************************************************************
7475 set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
7476 FLAG_CMDLINE won't be overridden by loads from smb.conf.
7477 ***************************************************************************/
7479 static bool lp_set_cmdline_helper(const char *pszParmName
, const char *pszParmValue
, bool store_values
)
7482 parmnum
= map_parameter(pszParmName
);
7484 parm_table
[parmnum
].flags
&= ~FLAG_CMDLINE
;
7485 if (!lp_do_parameter(-1, pszParmName
, pszParmValue
)) {
7488 parm_table
[parmnum
].flags
|= FLAG_CMDLINE
;
7490 /* we have to also set FLAG_CMDLINE on aliases. Aliases must
7491 * be grouped in the table, so we don't have to search the
7494 i
>=0 && parm_table
[i
].offset
== parm_table
[parmnum
].offset
7495 && parm_table
[i
].p_class
== parm_table
[parmnum
].p_class
;
7497 parm_table
[i
].flags
|= FLAG_CMDLINE
;
7499 for (i
=parmnum
+1;i
<NUMPARAMETERS
&& parm_table
[i
].offset
== parm_table
[parmnum
].offset
7500 && parm_table
[i
].p_class
== parm_table
[parmnum
].p_class
;i
++) {
7501 parm_table
[i
].flags
|= FLAG_CMDLINE
;
7505 store_lp_set_cmdline(pszParmName
, pszParmValue
);
7510 /* it might be parametric */
7511 if (strchr(pszParmName
, ':') != NULL
) {
7512 set_param_opt(&Globals
.param_opt
, pszParmName
, pszParmValue
, FLAG_CMDLINE
);
7514 store_lp_set_cmdline(pszParmName
, pszParmValue
);
7519 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName
));
7523 bool lp_set_cmdline(const char *pszParmName
, const char *pszParmValue
)
7525 return lp_set_cmdline_helper(pszParmName
, pszParmValue
, true);
7528 /***************************************************************************
7529 Process a parameter.
7530 ***************************************************************************/
7532 static bool do_parameter(const char *pszParmName
, const char *pszParmValue
,
7535 if (!bInGlobalSection
&& bGlobalOnly
)
7538 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName
, pszParmValue
));
7540 return (lp_do_parameter(bInGlobalSection
? -2 : iServiceIndex
,
7541 pszParmName
, pszParmValue
));
7545 set a option from the commandline in 'a=b' format. Use to support --option
7547 bool lp_set_option(const char *option
)
7552 s
= talloc_strdup(NULL
, option
);
7565 /* skip white spaces after the = sign */
7568 } while (*p
== ' ');
7570 ret
= lp_set_cmdline(s
, p
);
7575 /**************************************************************************
7576 Print a parameter of the specified type.
7577 ***************************************************************************/
7579 static void print_parameter(struct parm_struct
*p
, void *ptr
, FILE * f
)
7581 /* For the seperation of lists values that we print below */
7582 const char *list_sep
= ", ";
7587 for (i
= 0; p
->enum_list
[i
].name
; i
++) {
7588 if (*(int *)ptr
== p
->enum_list
[i
].value
) {
7590 p
->enum_list
[i
].name
);
7597 fprintf(f
, "%s", BOOLSTR(*(bool *)ptr
));
7601 fprintf(f
, "%s", BOOLSTR(!*(bool *)ptr
));
7606 fprintf(f
, "%d", *(int *)ptr
);
7610 fprintf(f
, "%c", *(char *)ptr
);
7614 int val
= *(int *)ptr
;
7618 fprintf(f
, "0%o", val
);
7627 if ((char ***)ptr
&& *(char ***)ptr
) {
7628 char **list
= *(char ***)ptr
;
7629 for (; *list
; list
++) {
7630 /* surround strings with whitespace in double quotes */
7631 if (*(list
+1) == NULL
) {
7632 /* last item, no extra separator */
7635 if ( strchr_m( *list
, ' ' ) ) {
7636 fprintf(f
, "\"%s\"%s", *list
, list_sep
);
7638 fprintf(f
, "%s%s", *list
, list_sep
);
7646 if (*(char **)ptr
) {
7647 fprintf(f
, "%s", *(char **)ptr
);
7655 /***************************************************************************
7656 Check if two parameters are equal.
7657 ***************************************************************************/
7659 static bool equal_parameter(parm_type type
, void *ptr1
, void *ptr2
)
7664 return (*((bool *)ptr1
) == *((bool *)ptr2
));
7670 return (*((int *)ptr1
) == *((int *)ptr2
));
7673 return (*((char *)ptr1
) == *((char *)ptr2
));
7677 return str_list_equal(*(const char ***)ptr1
, *(const char ***)ptr2
);
7682 char *p1
= *(char **)ptr1
, *p2
= *(char **)ptr2
;
7687 return (p1
== p2
|| strequal(p1
, p2
));
7695 /***************************************************************************
7696 Initialize any local varients in the sDefault table.
7697 ***************************************************************************/
7699 void init_locals(void)
7704 /***************************************************************************
7705 Process a new section (service). At this stage all sections are services.
7706 Later we'll have special sections that permit server parameters to be set.
7707 Returns true on success, false on failure.
7708 ***************************************************************************/
7710 static bool do_section(const char *pszSectionName
, void *userdata
)
7713 bool isglobal
= ((strwicmp(pszSectionName
, GLOBAL_NAME
) == 0) ||
7714 (strwicmp(pszSectionName
, GLOBAL_NAME2
) == 0));
7717 /* if we were in a global section then do the local inits */
7718 if (bInGlobalSection
&& !isglobal
)
7721 /* if we've just struck a global section, note the fact. */
7722 bInGlobalSection
= isglobal
;
7724 /* check for multiple global sections */
7725 if (bInGlobalSection
) {
7726 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName
));
7730 if (!bInGlobalSection
&& bGlobalOnly
)
7733 /* if we have a current service, tidy it up before moving on */
7736 if (iServiceIndex
>= 0)
7737 bRetval
= service_ok(iServiceIndex
);
7739 /* if all is still well, move to the next record in the services array */
7741 /* We put this here to avoid an odd message order if messages are */
7742 /* issued by the post-processing of a previous section. */
7743 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName
));
7745 iServiceIndex
= add_a_service(&sDefault
, pszSectionName
);
7746 if (iServiceIndex
< 0) {
7747 DEBUG(0, ("Failed to add a new service\n"));
7750 /* Clean all parametric options for service */
7751 /* They will be added during parsing again */
7752 free_param_opts(&ServicePtrs
[iServiceIndex
]->param_opt
);
7759 /***************************************************************************
7760 Determine if a partcular base parameter is currentl set to the default value.
7761 ***************************************************************************/
7763 static bool is_default(int i
)
7765 if (!defaults_saved
)
7767 switch (parm_table
[i
].type
) {
7770 return str_list_equal((const char **)parm_table
[i
].def
.lvalue
,
7771 *(const char ***)lp_parm_ptr(NULL
,
7775 return strequal(parm_table
[i
].def
.svalue
,
7776 *(char **)lp_parm_ptr(NULL
,
7780 return parm_table
[i
].def
.bvalue
==
7781 *(bool *)lp_parm_ptr(NULL
,
7784 return parm_table
[i
].def
.cvalue
==
7785 *(char *)lp_parm_ptr(NULL
,
7791 return parm_table
[i
].def
.ivalue
==
7792 *(int *)lp_parm_ptr(NULL
,
7800 /***************************************************************************
7801 Display the contents of the global structure.
7802 ***************************************************************************/
7804 static void dump_globals(FILE *f
)
7807 struct parmlist_entry
*data
;
7809 fprintf(f
, "[global]\n");
7811 for (i
= 0; parm_table
[i
].label
; i
++)
7812 if (parm_table
[i
].p_class
== P_GLOBAL
&&
7813 !(parm_table
[i
].flags
& FLAG_META
) &&
7814 (i
== 0 || (parm_table
[i
].offset
!= parm_table
[i
- 1].offset
))) {
7815 if (defaults_saved
&& is_default(i
))
7817 fprintf(f
, "\t%s = ", parm_table
[i
].label
);
7818 print_parameter(&parm_table
[i
], lp_parm_ptr(NULL
,
7823 if (Globals
.param_opt
!= NULL
) {
7824 data
= Globals
.param_opt
;
7826 fprintf(f
, "\t%s = %s\n", data
->key
, data
->value
);
7833 /***************************************************************************
7834 Return true if a local parameter is currently set to the global default.
7835 ***************************************************************************/
7837 bool lp_is_default(int snum
, struct parm_struct
*parm
)
7839 return equal_parameter(parm
->type
,
7840 lp_parm_ptr(ServicePtrs
[snum
], parm
),
7841 lp_parm_ptr(NULL
, parm
));
7844 /***************************************************************************
7845 Display the contents of a single services record.
7846 ***************************************************************************/
7848 static void dump_a_service(struct loadparm_service
*pService
, FILE * f
)
7851 struct parmlist_entry
*data
;
7853 if (pService
!= &sDefault
)
7854 fprintf(f
, "[%s]\n", pService
->szService
);
7856 for (i
= 0; parm_table
[i
].label
; i
++) {
7858 if (parm_table
[i
].p_class
== P_LOCAL
&&
7859 !(parm_table
[i
].flags
& FLAG_META
) &&
7860 (*parm_table
[i
].label
!= '-') &&
7861 (i
== 0 || (parm_table
[i
].offset
!= parm_table
[i
- 1].offset
)))
7863 if (pService
== &sDefault
) {
7864 if (defaults_saved
&& is_default(i
))
7867 if (equal_parameter(parm_table
[i
].type
,
7868 lp_parm_ptr(pService
, &parm_table
[i
]),
7869 lp_parm_ptr(NULL
, &parm_table
[i
])))
7873 fprintf(f
, "\t%s = ", parm_table
[i
].label
);
7874 print_parameter(&parm_table
[i
],
7875 lp_parm_ptr(pService
, &parm_table
[i
]),
7881 if (pService
->param_opt
!= NULL
) {
7882 data
= pService
->param_opt
;
7884 fprintf(f
, "\t%s = %s\n", data
->key
, data
->value
);
7890 /***************************************************************************
7891 Display the contents of a parameter of a single services record.
7892 ***************************************************************************/
7894 bool dump_a_parameter(int snum
, char *parm_name
, FILE * f
, bool isGlobal
)
7897 bool result
= false;
7900 fstring local_parm_name
;
7902 const char *parm_opt_value
;
7904 /* check for parametrical option */
7905 fstrcpy( local_parm_name
, parm_name
);
7906 parm_opt
= strchr( local_parm_name
, ':');
7911 if (strlen(parm_opt
)) {
7912 parm_opt_value
= lp_parm_const_string( snum
,
7913 local_parm_name
, parm_opt
, NULL
);
7914 if (parm_opt_value
) {
7915 printf( "%s\n", parm_opt_value
);
7922 /* check for a key and print the value */
7929 for (i
= 0; parm_table
[i
].label
; i
++) {
7930 if (strwicmp(parm_table
[i
].label
, parm_name
) == 0 &&
7931 !(parm_table
[i
].flags
& FLAG_META
) &&
7932 (parm_table
[i
].p_class
== p_class
|| parm_table
[i
].flags
& flag
) &&
7933 (*parm_table
[i
].label
!= '-') &&
7934 (i
== 0 || (parm_table
[i
].offset
!= parm_table
[i
- 1].offset
)))
7939 ptr
= lp_parm_ptr(NULL
,
7942 ptr
= lp_parm_ptr(ServicePtrs
[snum
],
7946 print_parameter(&parm_table
[i
],
7957 /***************************************************************************
7958 Return info about the requested parameter (given as a string).
7959 Return NULL when the string is not a valid parameter name.
7960 ***************************************************************************/
7962 struct parm_struct
*lp_get_parameter(const char *param_name
)
7964 int num
= map_parameter(param_name
);
7970 return &parm_table
[num
];
7973 /***************************************************************************
7974 Return info about the next parameter in a service.
7975 snum==GLOBAL_SECTION_SNUM gives the globals.
7976 Return NULL when out of parameters.
7977 ***************************************************************************/
7979 struct parm_struct
*lp_next_parameter(int snum
, int *i
, int allparameters
)
7982 /* do the globals */
7983 for (; parm_table
[*i
].label
; (*i
)++) {
7984 if (parm_table
[*i
].p_class
== P_SEPARATOR
)
7985 return &parm_table
[(*i
)++];
7987 if ((*parm_table
[*i
].label
== '-'))
7991 && (parm_table
[*i
].offset
==
7992 parm_table
[(*i
) - 1].offset
)
7993 && (parm_table
[*i
].p_class
==
7994 parm_table
[(*i
) - 1].p_class
))
7997 if (is_default(*i
) && !allparameters
)
8000 return &parm_table
[(*i
)++];
8003 struct loadparm_service
*pService
= ServicePtrs
[snum
];
8005 for (; parm_table
[*i
].label
; (*i
)++) {
8006 if (parm_table
[*i
].p_class
== P_SEPARATOR
)
8007 return &parm_table
[(*i
)++];
8009 if (parm_table
[*i
].p_class
== P_LOCAL
&&
8010 (*parm_table
[*i
].label
!= '-') &&
8012 (parm_table
[*i
].offset
!=
8013 parm_table
[(*i
) - 1].offset
)))
8015 if (allparameters
||
8016 !equal_parameter(parm_table
[*i
].type
,
8017 lp_parm_ptr(pService
,
8022 return &parm_table
[(*i
)++];
8033 /***************************************************************************
8034 Display the contents of a single copy structure.
8035 ***************************************************************************/
8036 static void dump_copy_map(bool *pcopymap
)
8042 printf("\n\tNon-Copied parameters:\n");
8044 for (i
= 0; parm_table
[i
].label
; i
++)
8045 if (parm_table
[i
].p_class
== P_LOCAL
&&
8046 parm_table
[i
].ptr
&& !pcopymap
[i
] &&
8047 (i
== 0 || (parm_table
[i
].ptr
!= parm_table
[i
- 1].ptr
)))
8049 printf("\t\t%s\n", parm_table
[i
].label
);
8054 /***************************************************************************
8055 Return TRUE if the passed service number is within range.
8056 ***************************************************************************/
8058 bool lp_snum_ok(int iService
)
8060 return (LP_SNUM_OK(iService
) && ServicePtrs
[iService
]->bAvailable
);
8063 /***************************************************************************
8064 Auto-load some home services.
8065 ***************************************************************************/
8067 static void lp_add_auto_services(char *str
)
8077 s
= SMB_STRDUP(str
);
8081 homes
= lp_servicenumber(HOMES_NAME
);
8083 for (p
= strtok_r(s
, LIST_SEP
, &saveptr
); p
;
8084 p
= strtok_r(NULL
, LIST_SEP
, &saveptr
)) {
8087 if (lp_servicenumber(p
) >= 0)
8090 home
= get_user_home_dir(talloc_tos(), p
);
8092 if (home
&& home
[0] && homes
>= 0)
8093 lp_add_home(p
, homes
, p
, home
);
8100 /***************************************************************************
8101 Auto-load one printer.
8102 ***************************************************************************/
8104 void lp_add_one_printer(const char *name
, const char *comment
,
8105 const char *location
, void *pdata
)
8107 int printers
= lp_servicenumber(PRINTERS_NAME
);
8110 if (lp_servicenumber(name
) < 0) {
8111 lp_add_printer(name
, printers
);
8112 if ((i
= lp_servicenumber(name
)) >= 0) {
8113 string_set(&ServicePtrs
[i
]->comment
, comment
);
8114 ServicePtrs
[i
]->autoloaded
= true;
8119 /***************************************************************************
8120 Have we loaded a services file yet?
8121 ***************************************************************************/
8123 bool lp_loaded(void)
8128 /***************************************************************************
8129 Unload unused services.
8130 ***************************************************************************/
8132 void lp_killunused(struct smbd_server_connection
*sconn
,
8133 bool (*snumused
) (struct smbd_server_connection
*, int))
8136 for (i
= 0; i
< iNumServices
; i
++) {
8140 /* don't kill autoloaded or usershare services */
8141 if ( ServicePtrs
[i
]->autoloaded
||
8142 ServicePtrs
[i
]->usershare
== USERSHARE_VALID
) {
8146 if (!snumused
|| !snumused(sconn
, i
)) {
8147 free_service_byindex(i
);
8153 * Kill all except autoloaded and usershare services - convenience wrapper
8155 void lp_kill_all_services(void)
8157 lp_killunused(NULL
, NULL
);
8160 /***************************************************************************
8162 ***************************************************************************/
8164 void lp_killservice(int iServiceIn
)
8166 if (VALID(iServiceIn
)) {
8167 free_service_byindex(iServiceIn
);
8171 /***************************************************************************
8172 Save the curent values of all global and sDefault parameters into the
8173 defaults union. This allows swat and testparm to show only the
8174 changed (ie. non-default) parameters.
8175 ***************************************************************************/
8177 static void lp_save_defaults(void)
8180 for (i
= 0; parm_table
[i
].label
; i
++) {
8181 if (i
> 0 && parm_table
[i
].offset
== parm_table
[i
- 1].offset
8182 && parm_table
[i
].p_class
== parm_table
[i
- 1].p_class
)
8184 switch (parm_table
[i
].type
) {
8187 parm_table
[i
].def
.lvalue
= str_list_copy(
8188 NULL
, *(const char ***)lp_parm_ptr(NULL
, &parm_table
[i
]));
8192 parm_table
[i
].def
.svalue
= SMB_STRDUP(*(char **)lp_parm_ptr(NULL
, &parm_table
[i
]));
8196 parm_table
[i
].def
.bvalue
=
8197 *(bool *)lp_parm_ptr(NULL
, &parm_table
[i
]);
8200 parm_table
[i
].def
.cvalue
=
8201 *(char *)lp_parm_ptr(NULL
, &parm_table
[i
]);
8207 parm_table
[i
].def
.ivalue
=
8208 *(int *)lp_parm_ptr(NULL
, &parm_table
[i
]);
8214 defaults_saved
= true;
8217 /***********************************************************
8218 If we should send plaintext/LANMAN passwords in the clinet
8219 ************************************************************/
8221 static void set_allowed_client_auth(void)
8223 if (Globals
.bClientNTLMv2Auth
) {
8224 Globals
.bClientLanManAuth
= false;
8226 if (!Globals
.bClientLanManAuth
) {
8227 Globals
.bClientPlaintextAuth
= false;
8231 /***************************************************************************
8233 The following code allows smbd to read a user defined share file.
8234 Yes, this is my intent. Yes, I'm comfortable with that...
8236 THE FOLLOWING IS SECURITY CRITICAL CODE.
8238 It washes your clothes, it cleans your house, it guards you while you sleep...
8239 Do not f%^k with it....
8240 ***************************************************************************/
8242 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8244 /***************************************************************************
8245 Check allowed stat state of a usershare file.
8246 Ensure we print out who is dicking with us so the admin can
8247 get their sorry ass fired.
8248 ***************************************************************************/
8250 static bool check_usershare_stat(const char *fname
,
8251 const SMB_STRUCT_STAT
*psbuf
)
8253 if (!S_ISREG(psbuf
->st_ex_mode
)) {
8254 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8255 "not a regular file\n",
8256 fname
, (unsigned int)psbuf
->st_ex_uid
));
8260 /* Ensure this doesn't have the other write bit set. */
8261 if (psbuf
->st_ex_mode
& S_IWOTH
) {
8262 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8263 "public write. Refusing to allow as a usershare file.\n",
8264 fname
, (unsigned int)psbuf
->st_ex_uid
));
8268 /* Should be 10k or less. */
8269 if (psbuf
->st_ex_size
> MAX_USERSHARE_FILE_SIZE
) {
8270 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8271 "too large (%u) to be a user share file.\n",
8272 fname
, (unsigned int)psbuf
->st_ex_uid
,
8273 (unsigned int)psbuf
->st_ex_size
));
8280 /***************************************************************************
8281 Parse the contents of a usershare file.
8282 ***************************************************************************/
8284 enum usershare_err
parse_usershare_file(TALLOC_CTX
*ctx
,
8285 SMB_STRUCT_STAT
*psbuf
,
8286 const char *servicename
,
8290 char **pp_sharepath
,
8292 char **pp_cp_servicename
,
8293 struct security_descriptor
**ppsd
,
8296 const char **prefixallowlist
= lp_usershare_prefix_allow_list();
8297 const char **prefixdenylist
= lp_usershare_prefix_deny_list();
8300 SMB_STRUCT_STAT sbuf
;
8301 char *sharepath
= NULL
;
8302 char *comment
= NULL
;
8304 *pp_sharepath
= NULL
;
8307 *pallow_guest
= false;
8310 return USERSHARE_MALFORMED_FILE
;
8313 if (strcmp(lines
[0], "#VERSION 1") == 0) {
8315 } else if (strcmp(lines
[0], "#VERSION 2") == 0) {
8318 return USERSHARE_MALFORMED_FILE
;
8321 return USERSHARE_BAD_VERSION
;
8324 if (strncmp(lines
[1], "path=", 5) != 0) {
8325 return USERSHARE_MALFORMED_PATH
;
8328 sharepath
= talloc_strdup(ctx
, &lines
[1][5]);
8330 return USERSHARE_POSIX_ERR
;
8332 trim_string(sharepath
, " ", " ");
8334 if (strncmp(lines
[2], "comment=", 8) != 0) {
8335 return USERSHARE_MALFORMED_COMMENT_DEF
;
8338 comment
= talloc_strdup(ctx
, &lines
[2][8]);
8340 return USERSHARE_POSIX_ERR
;
8342 trim_string(comment
, " ", " ");
8343 trim_char(comment
, '"', '"');
8345 if (strncmp(lines
[3], "usershare_acl=", 14) != 0) {
8346 return USERSHARE_MALFORMED_ACL_DEF
;
8349 if (!parse_usershare_acl(ctx
, &lines
[3][14], ppsd
)) {
8350 return USERSHARE_ACL_ERR
;
8354 if (strncmp(lines
[4], "guest_ok=", 9) != 0) {
8355 return USERSHARE_MALFORMED_ACL_DEF
;
8357 if (lines
[4][9] == 'y') {
8358 *pallow_guest
= true;
8361 /* Backwards compatible extension to file version #2. */
8363 if (strncmp(lines
[5], "sharename=", 10) != 0) {
8364 return USERSHARE_MALFORMED_SHARENAME_DEF
;
8366 if (!strequal(&lines
[5][10], servicename
)) {
8367 return USERSHARE_BAD_SHARENAME
;
8369 *pp_cp_servicename
= talloc_strdup(ctx
, &lines
[5][10]);
8370 if (!*pp_cp_servicename
) {
8371 return USERSHARE_POSIX_ERR
;
8376 if (*pp_cp_servicename
== NULL
) {
8377 *pp_cp_servicename
= talloc_strdup(ctx
, servicename
);
8378 if (!*pp_cp_servicename
) {
8379 return USERSHARE_POSIX_ERR
;
8383 if (snum
!= -1 && (strcmp(sharepath
, ServicePtrs
[snum
]->szPath
) == 0)) {
8384 /* Path didn't change, no checks needed. */
8385 *pp_sharepath
= sharepath
;
8386 *pp_comment
= comment
;
8387 return USERSHARE_OK
;
8390 /* The path *must* be absolute. */
8391 if (sharepath
[0] != '/') {
8392 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8393 servicename
, sharepath
));
8394 return USERSHARE_PATH_NOT_ABSOLUTE
;
8397 /* If there is a usershare prefix deny list ensure one of these paths
8398 doesn't match the start of the user given path. */
8399 if (prefixdenylist
) {
8401 for ( i
=0; prefixdenylist
[i
]; i
++ ) {
8402 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8403 servicename
, i
, prefixdenylist
[i
], sharepath
));
8404 if (memcmp( sharepath
, prefixdenylist
[i
], strlen(prefixdenylist
[i
])) == 0) {
8405 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8406 "usershare prefix deny list entries.\n",
8407 servicename
, sharepath
));
8408 return USERSHARE_PATH_IS_DENIED
;
8413 /* If there is a usershare prefix allow list ensure one of these paths
8414 does match the start of the user given path. */
8416 if (prefixallowlist
) {
8418 for ( i
=0; prefixallowlist
[i
]; i
++ ) {
8419 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8420 servicename
, i
, prefixallowlist
[i
], sharepath
));
8421 if (memcmp( sharepath
, prefixallowlist
[i
], strlen(prefixallowlist
[i
])) == 0) {
8425 if (prefixallowlist
[i
] == NULL
) {
8426 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8427 "usershare prefix allow list entries.\n",
8428 servicename
, sharepath
));
8429 return USERSHARE_PATH_NOT_ALLOWED
;
8433 /* Ensure this is pointing to a directory. */
8434 dp
= opendir(sharepath
);
8437 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8438 servicename
, sharepath
));
8439 return USERSHARE_PATH_NOT_DIRECTORY
;
8442 /* Ensure the owner of the usershare file has permission to share
8445 if (sys_stat(sharepath
, &sbuf
, false) == -1) {
8446 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8447 servicename
, sharepath
, strerror(errno
) ));
8449 return USERSHARE_POSIX_ERR
;
8454 if (!S_ISDIR(sbuf
.st_ex_mode
)) {
8455 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8456 servicename
, sharepath
));
8457 return USERSHARE_PATH_NOT_DIRECTORY
;
8460 /* Check if sharing is restricted to owner-only. */
8461 /* psbuf is the stat of the usershare definition file,
8462 sbuf is the stat of the target directory to be shared. */
8464 if (lp_usershare_owner_only()) {
8465 /* root can share anything. */
8466 if ((psbuf
->st_ex_uid
!= 0) && (sbuf
.st_ex_uid
!= psbuf
->st_ex_uid
)) {
8467 return USERSHARE_PATH_NOT_ALLOWED
;
8471 *pp_sharepath
= sharepath
;
8472 *pp_comment
= comment
;
8473 return USERSHARE_OK
;
8476 /***************************************************************************
8477 Deal with a usershare file.
8480 -1 - Bad name, invalid contents.
8481 - service name already existed and not a usershare, problem
8482 with permissions to share directory etc.
8483 ***************************************************************************/
8485 static int process_usershare_file(const char *dir_name
, const char *file_name
, int snum_template
)
8487 SMB_STRUCT_STAT sbuf
;
8488 SMB_STRUCT_STAT lsbuf
;
8490 char *sharepath
= NULL
;
8491 char *comment
= NULL
;
8492 char *cp_service_name
= NULL
;
8493 char **lines
= NULL
;
8497 TALLOC_CTX
*ctx
= talloc_stackframe();
8498 struct security_descriptor
*psd
= NULL
;
8499 bool guest_ok
= false;
8500 char *canon_name
= NULL
;
8501 bool added_service
= false;
8504 /* Ensure share name doesn't contain invalid characters. */
8505 if (!validate_net_name(file_name
, INVALID_SHARENAME_CHARS
, strlen(file_name
))) {
8506 DEBUG(0,("process_usershare_file: share name %s contains "
8507 "invalid characters (any of %s)\n",
8508 file_name
, INVALID_SHARENAME_CHARS
));
8512 canon_name
= canonicalize_servicename(ctx
, file_name
);
8517 fname
= talloc_asprintf(ctx
, "%s/%s", dir_name
, file_name
);
8522 /* Minimize the race condition by doing an lstat before we
8523 open and fstat. Ensure this isn't a symlink link. */
8525 if (sys_lstat(fname
, &lsbuf
, false) != 0) {
8526 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8527 fname
, strerror(errno
) ));
8531 /* This must be a regular file, not a symlink, directory or
8532 other strange filetype. */
8533 if (!check_usershare_stat(fname
, &lsbuf
)) {
8541 status
= dbwrap_fetch_bystring(ServiceHash
, canon_name
,
8546 if (NT_STATUS_IS_OK(status
) &&
8547 (data
.dptr
!= NULL
) &&
8548 (data
.dsize
== sizeof(iService
))) {
8549 memcpy(&iService
, data
.dptr
, sizeof(iService
));
8553 if (iService
!= -1 &&
8554 timespec_compare(&ServicePtrs
[iService
]->usershare_last_mod
,
8555 &lsbuf
.st_ex_mtime
) == 0) {
8556 /* Nothing changed - Mark valid and return. */
8557 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8559 ServicePtrs
[iService
]->usershare
= USERSHARE_VALID
;
8564 /* Try and open the file read only - no symlinks allowed. */
8566 fd
= open(fname
, O_RDONLY
|O_NOFOLLOW
, 0);
8568 fd
= open(fname
, O_RDONLY
, 0);
8572 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8573 fname
, strerror(errno
) ));
8577 /* Now fstat to be *SURE* it's a regular file. */
8578 if (sys_fstat(fd
, &sbuf
, false) != 0) {
8580 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8581 fname
, strerror(errno
) ));
8585 /* Is it the same dev/inode as was lstated ? */
8586 if (!check_same_stat(&lsbuf
, &sbuf
)) {
8588 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8589 "Symlink spoofing going on ?\n", fname
));
8593 /* This must be a regular file, not a symlink, directory or
8594 other strange filetype. */
8595 if (!check_usershare_stat(fname
, &sbuf
)) {
8599 lines
= fd_lines_load(fd
, &numlines
, MAX_USERSHARE_FILE_SIZE
, NULL
);
8602 if (lines
== NULL
) {
8603 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8604 fname
, (unsigned int)sbuf
.st_ex_uid
));
8608 if (parse_usershare_file(ctx
, &sbuf
, file_name
,
8609 iService
, lines
, numlines
, &sharepath
,
8610 &comment
, &cp_service_name
,
8611 &psd
, &guest_ok
) != USERSHARE_OK
) {
8615 /* Everything ok - add the service possibly using a template. */
8617 const struct loadparm_service
*sp
= &sDefault
;
8618 if (snum_template
!= -1) {
8619 sp
= ServicePtrs
[snum_template
];
8622 if ((iService
= add_a_service(sp
, cp_service_name
)) < 0) {
8623 DEBUG(0, ("process_usershare_file: Failed to add "
8624 "new service %s\n", cp_service_name
));
8628 added_service
= true;
8630 /* Read only is controlled by usershare ACL below. */
8631 ServicePtrs
[iService
]->bRead_only
= false;
8634 /* Write the ACL of the new/modified share. */
8635 if (!set_share_security(canon_name
, psd
)) {
8636 DEBUG(0, ("process_usershare_file: Failed to set share "
8637 "security for user share %s\n",
8642 /* If from a template it may be marked invalid. */
8643 ServicePtrs
[iService
]->valid
= true;
8645 /* Set the service as a valid usershare. */
8646 ServicePtrs
[iService
]->usershare
= USERSHARE_VALID
;
8648 /* Set guest access. */
8649 if (lp_usershare_allow_guests()) {
8650 ServicePtrs
[iService
]->bGuest_ok
= guest_ok
;
8653 /* And note when it was loaded. */
8654 ServicePtrs
[iService
]->usershare_last_mod
= sbuf
.st_ex_mtime
;
8655 string_set(&ServicePtrs
[iService
]->szPath
, sharepath
);
8656 string_set(&ServicePtrs
[iService
]->comment
, comment
);
8662 if (ret
== -1 && iService
!= -1 && added_service
) {
8663 lp_remove_service(iService
);
8671 /***************************************************************************
8672 Checks if a usershare entry has been modified since last load.
8673 ***************************************************************************/
8675 static bool usershare_exists(int iService
, struct timespec
*last_mod
)
8677 SMB_STRUCT_STAT lsbuf
;
8678 const char *usersharepath
= Globals
.szUsersharePath
;
8681 if (asprintf(&fname
, "%s/%s",
8683 ServicePtrs
[iService
]->szService
) < 0) {
8687 if (sys_lstat(fname
, &lsbuf
, false) != 0) {
8692 if (!S_ISREG(lsbuf
.st_ex_mode
)) {
8698 *last_mod
= lsbuf
.st_ex_mtime
;
8702 /***************************************************************************
8703 Load a usershare service by name. Returns a valid servicenumber or -1.
8704 ***************************************************************************/
8706 int load_usershare_service(const char *servicename
)
8708 SMB_STRUCT_STAT sbuf
;
8709 const char *usersharepath
= Globals
.szUsersharePath
;
8710 int max_user_shares
= Globals
.iUsershareMaxShares
;
8711 int snum_template
= -1;
8713 if (*usersharepath
== 0 || max_user_shares
== 0) {
8717 if (sys_stat(usersharepath
, &sbuf
, false) != 0) {
8718 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8719 usersharepath
, strerror(errno
) ));
8723 if (!S_ISDIR(sbuf
.st_ex_mode
)) {
8724 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8730 * This directory must be owned by root, and have the 't' bit set.
8731 * It also must not be writable by "other".
8735 if (sbuf
.st_ex_uid
!= 0 || !(sbuf
.st_ex_mode
& S_ISVTX
) || (sbuf
.st_ex_mode
& S_IWOTH
)) {
8737 if (sbuf
.st_ex_uid
!= 0 || (sbuf
.st_ex_mode
& S_IWOTH
)) {
8739 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8740 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8745 /* Ensure the template share exists if it's set. */
8746 if (Globals
.szUsershareTemplateShare
[0]) {
8747 /* We can't use lp_servicenumber here as we are recommending that
8748 template shares have -valid=false set. */
8749 for (snum_template
= iNumServices
- 1; snum_template
>= 0; snum_template
--) {
8750 if (ServicePtrs
[snum_template
]->szService
&&
8751 strequal(ServicePtrs
[snum_template
]->szService
,
8752 Globals
.szUsershareTemplateShare
)) {
8757 if (snum_template
== -1) {
8758 DEBUG(0,("load_usershare_service: usershare template share %s "
8759 "does not exist.\n",
8760 Globals
.szUsershareTemplateShare
));
8765 return process_usershare_file(usersharepath
, servicename
, snum_template
);
8768 /***************************************************************************
8769 Load all user defined shares from the user share directory.
8770 We only do this if we're enumerating the share list.
8771 This is the function that can delete usershares that have
8773 ***************************************************************************/
8775 int load_usershare_shares(struct smbd_server_connection
*sconn
,
8776 bool (*snumused
) (struct smbd_server_connection
*, int))
8779 SMB_STRUCT_STAT sbuf
;
8781 int num_usershares
= 0;
8782 int max_user_shares
= Globals
.iUsershareMaxShares
;
8783 unsigned int num_dir_entries
, num_bad_dir_entries
, num_tmp_dir_entries
;
8784 unsigned int allowed_bad_entries
= ((2*max_user_shares
)/10);
8785 unsigned int allowed_tmp_entries
= ((2*max_user_shares
)/10);
8787 int snum_template
= -1;
8788 const char *usersharepath
= Globals
.szUsersharePath
;
8789 int ret
= lp_numservices();
8790 TALLOC_CTX
*tmp_ctx
;
8792 if (max_user_shares
== 0 || *usersharepath
== '\0') {
8793 return lp_numservices();
8796 if (sys_stat(usersharepath
, &sbuf
, false) != 0) {
8797 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8798 usersharepath
, strerror(errno
) ));
8803 * This directory must be owned by root, and have the 't' bit set.
8804 * It also must not be writable by "other".
8808 if (sbuf
.st_ex_uid
!= 0 || !(sbuf
.st_ex_mode
& S_ISVTX
) || (sbuf
.st_ex_mode
& S_IWOTH
)) {
8810 if (sbuf
.st_ex_uid
!= 0 || (sbuf
.st_ex_mode
& S_IWOTH
)) {
8812 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8813 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8818 /* Ensure the template share exists if it's set. */
8819 if (Globals
.szUsershareTemplateShare
[0]) {
8820 /* We can't use lp_servicenumber here as we are recommending that
8821 template shares have -valid=false set. */
8822 for (snum_template
= iNumServices
- 1; snum_template
>= 0; snum_template
--) {
8823 if (ServicePtrs
[snum_template
]->szService
&&
8824 strequal(ServicePtrs
[snum_template
]->szService
,
8825 Globals
.szUsershareTemplateShare
)) {
8830 if (snum_template
== -1) {
8831 DEBUG(0,("load_usershare_shares: usershare template share %s "
8832 "does not exist.\n",
8833 Globals
.szUsershareTemplateShare
));
8838 /* Mark all existing usershares as pending delete. */
8839 for (iService
= iNumServices
- 1; iService
>= 0; iService
--) {
8840 if (VALID(iService
) && ServicePtrs
[iService
]->usershare
) {
8841 ServicePtrs
[iService
]->usershare
= USERSHARE_PENDING_DELETE
;
8845 dp
= opendir(usersharepath
);
8847 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8848 usersharepath
, strerror(errno
) ));
8852 for (num_dir_entries
= 0, num_bad_dir_entries
= 0, num_tmp_dir_entries
= 0;
8854 num_dir_entries
++ ) {
8856 const char *n
= de
->d_name
;
8858 /* Ignore . and .. */
8860 if ((n
[1] == '\0') || (n
[1] == '.' && n
[2] == '\0')) {
8866 /* Temporary file used when creating a share. */
8867 num_tmp_dir_entries
++;
8870 /* Allow 20% tmp entries. */
8871 if (num_tmp_dir_entries
> allowed_tmp_entries
) {
8872 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8873 "in directory %s\n",
8874 num_tmp_dir_entries
, usersharepath
));
8878 r
= process_usershare_file(usersharepath
, n
, snum_template
);
8880 /* Update the services count. */
8882 if (num_usershares
>= max_user_shares
) {
8883 DEBUG(0,("load_usershare_shares: max user shares reached "
8884 "on file %s in directory %s\n",
8885 n
, usersharepath
));
8888 } else if (r
== -1) {
8889 num_bad_dir_entries
++;
8892 /* Allow 20% bad entries. */
8893 if (num_bad_dir_entries
> allowed_bad_entries
) {
8894 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8895 "in directory %s\n",
8896 num_bad_dir_entries
, usersharepath
));
8900 /* Allow 20% bad entries. */
8901 if (num_dir_entries
> max_user_shares
+ allowed_bad_entries
) {
8902 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8903 "in directory %s\n",
8904 num_dir_entries
, usersharepath
));
8911 /* Sweep through and delete any non-refreshed usershares that are
8912 not currently in use. */
8913 tmp_ctx
= talloc_stackframe();
8914 for (iService
= iNumServices
- 1; iService
>= 0; iService
--) {
8915 if (VALID(iService
) && (ServicePtrs
[iService
]->usershare
== USERSHARE_PENDING_DELETE
)) {
8918 if (snumused
&& snumused(sconn
, iService
)) {
8922 servname
= lp_servicename(tmp_ctx
, iService
);
8924 /* Remove from the share ACL db. */
8925 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8927 delete_share_security(servname
);
8928 free_service_byindex(iService
);
8931 talloc_free(tmp_ctx
);
8933 return lp_numservices();
8936 /********************************************************
8937 Destroy global resources allocated in this file
8938 ********************************************************/
8940 void gfree_loadparm(void)
8946 /* Free resources allocated to services */
8948 for ( i
= 0; i
< iNumServices
; i
++ ) {
8950 free_service_byindex(i
);
8954 SAFE_FREE( ServicePtrs
);
8957 /* Now release all resources allocated to global
8958 parameters and the default service */
8960 free_global_parameters();
8964 /***************************************************************************
8965 Allow client apps to specify that they are a client
8966 ***************************************************************************/
8967 static void lp_set_in_client(bool b
)
8973 /***************************************************************************
8974 Determine if we're running in a client app
8975 ***************************************************************************/
8976 static bool lp_is_in_client(void)
8981 /***************************************************************************
8982 Load the services array from the services file. Return true on success,
8984 ***************************************************************************/
8986 static bool lp_load_ex(const char *pszFname
,
8990 bool initialize_globals
,
8991 bool allow_include_registry
,
8992 bool load_all_shares
)
8999 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
9001 bInGlobalSection
= true;
9002 bGlobalOnly
= global_only
;
9003 bAllowIncludeRegistry
= allow_include_registry
;
9005 init_globals(initialize_globals
);
9009 if (save_defaults
) {
9014 if (!initialize_globals
) {
9015 free_param_opts(&Globals
.param_opt
);
9016 apply_lp_set_cmdline();
9019 lp_do_parameter(-1, "idmap config * : backend", Globals
.szIdmapBackend
);
9021 /* We get sections first, so have to start 'behind' to make up */
9024 if (lp_config_backend_is_file()) {
9025 n2
= talloc_sub_basic(talloc_tos(), get_current_username(),
9026 current_user_info
.domain
,
9029 smb_panic("lp_load_ex: out of memory");
9032 add_to_file_list(pszFname
, n2
);
9034 bRetval
= pm_process(n2
, do_section
, do_parameter
, NULL
);
9037 /* finish up the last section */
9038 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval
)));
9040 if (iServiceIndex
>= 0) {
9041 bRetval
= service_ok(iServiceIndex
);
9045 if (lp_config_backend_is_registry()) {
9046 /* config backend changed to registry in config file */
9048 * We need to use this extra global variable here to
9049 * survive restart: init_globals uses this as a default
9050 * for ConfigBackend. Otherwise, init_globals would
9051 * send us into an endless loop here.
9053 config_backend
= CONFIG_BACKEND_REGISTRY
;
9055 DEBUG(1, ("lp_load_ex: changing to config backend "
9058 lp_kill_all_services();
9059 return lp_load_ex(pszFname
, global_only
, save_defaults
,
9060 add_ipc
, initialize_globals
,
9061 allow_include_registry
,
9064 } else if (lp_config_backend_is_registry()) {
9065 bRetval
= process_registry_globals();
9067 DEBUG(0, ("Illegal config backend given: %d\n",
9068 lp_config_backend()));
9072 if (bRetval
&& lp_registry_shares()) {
9073 if (load_all_shares
) {
9074 bRetval
= process_registry_shares();
9076 bRetval
= reload_registry_shares();
9081 char *serv
= lp_auto_services(talloc_tos());
9082 lp_add_auto_services(serv
);
9087 /* When 'restrict anonymous = 2' guest connections to ipc$
9089 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9090 if ( lp_enable_asu_support() ) {
9091 lp_add_ipc("ADMIN$", false);
9095 set_allowed_client_auth();
9097 if (lp_security() == SEC_ADS
&& strchr(lp_passwordserver(), ':')) {
9098 DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
9099 lp_passwordserver()));
9104 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9105 /* if bWINSsupport is true and we are in the client */
9106 if (lp_is_in_client() && Globals
.bWINSsupport
) {
9107 lp_do_parameter(GLOBAL_SECTION_SNUM
, "wins server", "127.0.0.1");
9112 fault_configure(smb_panic_s3
);
9114 bAllowIncludeRegistry
= true;
9119 bool lp_load(const char *pszFname
,
9123 bool initialize_globals
)
9125 return lp_load_ex(pszFname
,
9130 true, /* allow_include_registry */
9131 false); /* load_all_shares*/
9134 bool lp_load_initial_only(const char *pszFname
)
9136 return lp_load_ex(pszFname
,
9137 true, /* global only */
9138 false, /* save_defaults */
9139 false, /* add_ipc */
9140 true, /* initialize_globals */
9141 false, /* allow_include_registry */
9142 false); /* load_all_shares*/
9146 * most common lp_load wrapper, loading only the globals
9148 bool lp_load_global(const char *file_name
)
9150 return lp_load_ex(file_name
,
9151 true, /* global_only */
9152 false, /* save_defaults */
9153 false, /* add_ipc */
9154 true, /* initialize_globals */
9155 true, /* allow_include_registry */
9156 false); /* load_all_shares*/
9160 * lp_load wrapper, especially for clients
9162 bool lp_load_client(const char *file_name
)
9164 lp_set_in_client(true);
9166 return lp_load_global(file_name
);
9170 * lp_load wrapper, loading only globals, but intended
9171 * for subsequent calls, not reinitializing the globals
9174 bool lp_load_global_no_reinit(const char *file_name
)
9176 return lp_load_ex(file_name
,
9177 true, /* global_only */
9178 false, /* save_defaults */
9179 false, /* add_ipc */
9180 false, /* initialize_globals */
9181 true, /* allow_include_registry */
9182 false); /* load_all_shares*/
9186 * lp_load wrapper, especially for clients, no reinitialization
9188 bool lp_load_client_no_reinit(const char *file_name
)
9190 lp_set_in_client(true);
9192 return lp_load_global_no_reinit(file_name
);
9195 bool lp_load_with_registry_shares(const char *pszFname
,
9199 bool initialize_globals
)
9201 return lp_load_ex(pszFname
,
9206 true, /* allow_include_registry */
9207 true); /* load_all_shares*/
9210 /***************************************************************************
9211 Return the max number of services.
9212 ***************************************************************************/
9214 int lp_numservices(void)
9216 return (iNumServices
);
9219 /***************************************************************************
9220 Display the contents of the services array in human-readable form.
9221 ***************************************************************************/
9223 void lp_dump(FILE *f
, bool show_defaults
, int maxtoprint
)
9228 defaults_saved
= false;
9232 dump_a_service(&sDefault
, f
);
9234 for (iService
= 0; iService
< maxtoprint
; iService
++) {
9236 lp_dump_one(f
, show_defaults
, iService
);
9240 /***************************************************************************
9241 Display the contents of one service in human-readable form.
9242 ***************************************************************************/
9244 void lp_dump_one(FILE * f
, bool show_defaults
, int snum
)
9247 if (ServicePtrs
[snum
]->szService
[0] == '\0')
9249 dump_a_service(ServicePtrs
[snum
], f
);
9253 /***************************************************************************
9254 Return the number of the service with the given name, or -1 if it doesn't
9255 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9256 getservicebyname()! This works ONLY if all services have been loaded, and
9257 does not copy the found service.
9258 ***************************************************************************/
9260 int lp_servicenumber(const char *pszServiceName
)
9263 fstring serviceName
;
9265 if (!pszServiceName
) {
9266 return GLOBAL_SECTION_SNUM
;
9269 for (iService
= iNumServices
- 1; iService
>= 0; iService
--) {
9270 if (VALID(iService
) && ServicePtrs
[iService
]->szService
) {
9272 * The substitution here is used to support %U is
9275 fstrcpy(serviceName
, ServicePtrs
[iService
]->szService
);
9276 standard_sub_basic(get_current_username(),
9277 current_user_info
.domain
,
9278 serviceName
,sizeof(serviceName
));
9279 if (strequal(serviceName
, pszServiceName
)) {
9285 if (iService
>= 0 && ServicePtrs
[iService
]->usershare
== USERSHARE_VALID
) {
9286 struct timespec last_mod
;
9288 if (!usershare_exists(iService
, &last_mod
)) {
9289 /* Remove the share security tdb entry for it. */
9290 delete_share_security(lp_servicename(talloc_tos(), iService
));
9291 /* Remove it from the array. */
9292 free_service_byindex(iService
);
9293 /* Doesn't exist anymore. */
9294 return GLOBAL_SECTION_SNUM
;
9297 /* Has it been modified ? If so delete and reload. */
9298 if (timespec_compare(&ServicePtrs
[iService
]->usershare_last_mod
,
9300 /* Remove it from the array. */
9301 free_service_byindex(iService
);
9302 /* and now reload it. */
9303 iService
= load_usershare_service(pszServiceName
);
9308 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName
));
9309 return GLOBAL_SECTION_SNUM
;
9315 /*******************************************************************
9316 A useful volume label function.
9317 ********************************************************************/
9319 const char *volume_label(TALLOC_CTX
*ctx
, int snum
)
9322 const char *label
= lp_volume(ctx
, snum
);
9324 label
= lp_servicename(ctx
, snum
);
9327 /* This returns a 33 byte guarenteed null terminated string. */
9328 ret
= talloc_strndup(ctx
, label
, 32);
9335 /*******************************************************************
9336 Get the default server type we will announce as via nmbd.
9337 ********************************************************************/
9339 int lp_default_server_announce(void)
9341 int default_server_announce
= 0;
9342 default_server_announce
|= SV_TYPE_WORKSTATION
;
9343 default_server_announce
|= SV_TYPE_SERVER
;
9344 default_server_announce
|= SV_TYPE_SERVER_UNIX
;
9346 /* note that the flag should be set only if we have a
9347 printer service but nmbd doesn't actually load the
9348 services so we can't tell --jerry */
9350 default_server_announce
|= SV_TYPE_PRINTQ_SERVER
;
9352 default_server_announce
|= SV_TYPE_SERVER_NT
;
9353 default_server_announce
|= SV_TYPE_NT
;
9355 switch (lp_server_role()) {
9356 case ROLE_DOMAIN_MEMBER
:
9357 default_server_announce
|= SV_TYPE_DOMAIN_MEMBER
;
9359 case ROLE_DOMAIN_PDC
:
9360 default_server_announce
|= SV_TYPE_DOMAIN_CTRL
;
9362 case ROLE_DOMAIN_BDC
:
9363 default_server_announce
|= SV_TYPE_DOMAIN_BAKCTRL
;
9365 case ROLE_STANDALONE
:
9369 if (lp_time_server())
9370 default_server_announce
|= SV_TYPE_TIME_SOURCE
;
9372 if (lp_host_msdfs())
9373 default_server_announce
|= SV_TYPE_DFS_SERVER
;
9375 return default_server_announce
;
9378 /***********************************************************
9379 If we are PDC then prefer us as DMB
9380 ************************************************************/
9382 bool lp_domain_master(void)
9384 if (Globals
.domain_master
== Auto
)
9385 return (lp_server_role() == ROLE_DOMAIN_PDC
);
9387 return (bool)Globals
.domain_master
;
9390 /***********************************************************
9391 If we are PDC then prefer us as DMB
9392 ************************************************************/
9394 static bool lp_domain_master_true_or_auto(void)
9396 if (Globals
.domain_master
) /* auto or yes */
9402 /***********************************************************
9403 If we are DMB then prefer us as LMB
9404 ************************************************************/
9406 bool lp_preferred_master(void)
9408 if (Globals
.iPreferredMaster
== Auto
)
9409 return (lp_local_master() && lp_domain_master());
9411 return (bool)Globals
.iPreferredMaster
;
9414 /*******************************************************************
9416 ********************************************************************/
9418 void lp_remove_service(int snum
)
9420 ServicePtrs
[snum
]->valid
= false;
9421 invalid_services
[num_invalid_services
++] = snum
;
9424 /*******************************************************************
9426 ********************************************************************/
9428 void lp_copy_service(int snum
, const char *new_name
)
9430 do_section(new_name
, NULL
);
9432 snum
= lp_servicenumber(new_name
);
9434 char *name
= lp_servicename(talloc_tos(), snum
);
9435 lp_do_parameter(snum
, "copy", name
);
9440 const char *lp_printername(TALLOC_CTX
*ctx
, int snum
)
9442 const char *ret
= lp__printername(talloc_tos(), snum
);
9443 if (ret
== NULL
|| *ret
== '\0') {
9444 ret
= lp_const_servicename(snum
);
9451 /***********************************************************
9452 Allow daemons such as winbindd to fix their logfile name.
9453 ************************************************************/
9455 void lp_set_logfile(const char *name
)
9457 string_set(&Globals
.logfile
, name
);
9458 debug_set_logfile(name
);
9461 /*******************************************************************
9462 Return the max print jobs per queue.
9463 ********************************************************************/
9465 int lp_maxprintjobs(int snum
)
9467 int maxjobs
= LP_SNUM_OK(snum
) ? ServicePtrs
[snum
]->iMaxPrintJobs
: sDefault
.iMaxPrintJobs
;
9468 if (maxjobs
<= 0 || maxjobs
>= PRINT_MAX_JOBID
)
9469 maxjobs
= PRINT_MAX_JOBID
- 1;
9474 const char *lp_printcapname(void)
9476 if ((Globals
.szPrintcapname
!= NULL
) &&
9477 (Globals
.szPrintcapname
[0] != '\0'))
9478 return Globals
.szPrintcapname
;
9480 if (sDefault
.iPrinting
== PRINT_CUPS
) {
9488 if (sDefault
.iPrinting
== PRINT_BSD
)
9489 return "/etc/printcap";
9491 return PRINTCAP_NAME
;
9494 static uint32 spoolss_state
;
9496 bool lp_disable_spoolss( void )
9498 if ( spoolss_state
== SVCCTL_STATE_UNKNOWN
)
9499 spoolss_state
= lp__disable_spoolss() ? SVCCTL_STOPPED
: SVCCTL_RUNNING
;
9501 return spoolss_state
== SVCCTL_STOPPED
? true : false;
9504 void lp_set_spoolss_state( uint32 state
)
9506 SMB_ASSERT( (state
== SVCCTL_STOPPED
) || (state
== SVCCTL_RUNNING
) );
9508 spoolss_state
= state
;
9511 uint32
lp_get_spoolss_state( void )
9513 return lp_disable_spoolss() ? SVCCTL_STOPPED
: SVCCTL_RUNNING
;
9516 /*******************************************************************
9517 Ensure we don't use sendfile if server smb signing is active.
9518 ********************************************************************/
9520 bool lp_use_sendfile(int snum
, struct smb_signing_state
*signing_state
)
9522 bool sign_active
= false;
9524 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9525 if (get_Protocol() < PROTOCOL_NT1
) {
9528 if (signing_state
) {
9529 sign_active
= smb_signing_is_active(signing_state
);
9531 return (lp__use_sendfile(snum
) &&
9532 (get_remote_arch() != RA_WIN95
) &&
9536 /*******************************************************************
9537 Turn off sendfile if we find the underlying OS doesn't support it.
9538 ********************************************************************/
9540 void set_use_sendfile(int snum
, bool val
)
9542 if (LP_SNUM_OK(snum
))
9543 ServicePtrs
[snum
]->bUseSendfile
= val
;
9545 sDefault
.bUseSendfile
= val
;
9548 /*******************************************************************
9549 Turn off storing DOS attributes if this share doesn't support it.
9550 ********************************************************************/
9552 void set_store_dos_attributes(int snum
, bool val
)
9554 if (!LP_SNUM_OK(snum
))
9556 ServicePtrs
[(snum
)]->bStoreDosAttributes
= val
;
9559 void lp_set_mangling_method(const char *new_method
)
9561 string_set(&Globals
.szManglingMethod
, new_method
);
9564 /*******************************************************************
9565 Global state for POSIX pathname processing.
9566 ********************************************************************/
9568 static bool posix_pathnames
;
9570 bool lp_posix_pathnames(void)
9572 return posix_pathnames
;
9575 /*******************************************************************
9576 Change everything needed to ensure POSIX pathname processing (currently
9578 ********************************************************************/
9580 void lp_set_posix_pathnames(void)
9582 posix_pathnames
= true;
9585 /*******************************************************************
9586 Global state for POSIX lock processing - CIFS unix extensions.
9587 ********************************************************************/
9589 bool posix_default_lock_was_set
;
9590 static enum brl_flavour posix_cifsx_locktype
; /* By default 0 == WINDOWS_LOCK */
9592 enum brl_flavour
lp_posix_cifsu_locktype(files_struct
*fsp
)
9594 if (posix_default_lock_was_set
) {
9595 return posix_cifsx_locktype
;
9597 return fsp
->posix_open
? POSIX_LOCK
: WINDOWS_LOCK
;
9601 /*******************************************************************
9602 ********************************************************************/
9604 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val
)
9606 posix_default_lock_was_set
= true;
9607 posix_cifsx_locktype
= val
;
9610 int lp_min_receive_file_size(void)
9612 if (Globals
.iminreceivefile
< 0) {
9615 return MIN(Globals
.iminreceivefile
, BUFFER_SIZE
);
9618 /*******************************************************************
9619 If socket address is an empty character string, it is necessary to
9620 define it as "0.0.0.0".
9621 ********************************************************************/
9623 const char *lp_socket_address(void)
9625 char *sock_addr
= Globals
.szSocketAddress
;
9627 if (sock_addr
[0] == '\0'){
9628 string_set(&Globals
.szSocketAddress
, "0.0.0.0");
9630 return Globals
.szSocketAddress
;
9633 /*******************************************************************
9634 Safe wide links checks.
9635 This helper function always verify the validity of wide links,
9636 even after a configuration file reload.
9637 ********************************************************************/
9639 static bool lp_widelinks_internal(int snum
)
9641 return (bool)(LP_SNUM_OK(snum
)? ServicePtrs
[(snum
)]->bWidelinks
:
9642 sDefault
.bWidelinks
);
9645 void widelinks_warning(int snum
)
9647 if (lp_allow_insecure_widelinks()) {
9651 if (lp_unix_extensions() && lp_widelinks_internal(snum
)) {
9652 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9653 "These parameters are incompatible. "
9654 "Wide links will be disabled for this share.\n",
9655 lp_servicename(talloc_tos(), snum
) ));
9659 bool lp_widelinks(int snum
)
9661 /* wide links is always incompatible with unix extensions */
9662 if (lp_unix_extensions()) {
9664 * Unless we have "allow insecure widelinks"
9667 if (!lp_allow_insecure_widelinks()) {
9672 return lp_widelinks_internal(snum
);
9675 bool lp_writeraw(void)
9677 if (lp_async_smb_echo_handler()) {
9680 return lp__writeraw();
9683 bool lp_readraw(void)
9685 if (lp_async_smb_echo_handler()) {
9688 return lp__readraw();
9691 int lp_server_role(void)
9693 return lp_find_server_role(lp__server_role(),
9696 lp_domain_master_true_or_auto());