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"
59 #include "lib/param/loadparm.h"
61 #include "lib/smbconf/smbconf.h"
62 #include "lib/smbconf/smbconf_init.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 static int config_backend = CONFIG_BACKEND_FILE;
102 /* some helpful bits */
103 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
104 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
106 #define USERSHARE_VALID 1
107 #define USERSHARE_PENDING_DELETE 2
109 static bool defaults_saved = false;
111 #define LOADPARM_EXTRA_GLOBALS \
112 struct parmlist_entry *param_opt; \
115 int iminreceivefile; \
116 char *szPrintcapname; \
118 int iPreferredMaster; \
120 char *szLdapMachineSuffix; \
121 char *szLdapUserSuffix; \
122 char *szLdapIdmapSuffix; \
123 char *szLdapGroupSuffix; \
126 char *szSocketAddress; \
127 char *szUsershareTemplateShare; \
130 int winbindMaxDomainConnections; \
131 int ismb2_max_credits; \
133 char *tls_certfile; \
137 char *panic_action; \
138 int bPreferredMaster;
140 #include "param/param_global.h"
142 static struct loadparm_global Globals;
144 /* This is a default service used to prime a services structure */
145 static struct loadparm_service sDefault =
150 .usershare_last_mod = {0, 0},
154 .szInvalidUsers = NULL,
155 .szValidUsers = NULL,
156 .szAdminUsers = NULL,
161 .szRootPreExec = NULL,
162 .szRootPostExec = NULL,
163 .szCupsOptions = NULL,
164 .szPrintcommand = NULL,
165 .szLpqcommand = NULL,
166 .szLprmcommand = NULL,
167 .szLppausecommand = NULL,
168 .szLpresumecommand = NULL,
169 .szQueuepausecommand = NULL,
170 .szQueueresumecommand = NULL,
171 .szPrintername = NULL,
172 .szPrintjobUsername = NULL,
173 .szDontdescend = NULL,
174 .szHostsallow = NULL,
176 .szMagicScript = NULL,
177 .szMagicOutput = NULL,
180 .szVetoOplockFiles = NULL,
188 .szVfsObjects = NULL,
189 .szMSDfsProxy = NULL,
190 .szAioWriteBehind = NULL,
193 .iMaxPrintJobs = 1000,
194 .iMaxReportedPrintJobs = 0,
195 .iWriteCacheSize = 0,
196 .iCreate_mask = 0744,
197 .iCreate_force_mode = 0,
198 .iSecurity_mask = 0777,
199 .iSecurity_force_mode = 0,
201 .iDir_force_mode = 0,
202 .iDir_Security_mask = 0777,
203 .iDir_Security_force_mode = 0,
204 .iMaxConnections = 0,
205 .iDefaultCase = CASE_LOWER,
206 .iPrinting = DEFAULT_PRINTING,
207 .iOplockContentionLimit = 2,
210 .iDfreeCacheTime = 0,
211 .bPreexecClose = false,
212 .bRootpreexecClose = false,
213 .iCaseSensitive = Auto,
214 .bCasePreserve = true,
215 .bShortCasePreserve = true,
216 .bHideDotFiles = true,
217 .bHideSpecialFiles = false,
218 .bHideUnReadable = false,
219 .bHideUnWriteableFiles = false,
221 .bAccessBasedShareEnum = false,
225 .bGuest_only = false,
226 .bAdministrative_share = false,
229 .bPrintNotifyBackchannel = true,
230 .bMap_system = false,
231 .bMap_hidden = false,
232 .bMap_archive = true,
233 .bStoreDosAttributes = false,
234 .bDmapiSupport = false,
236 .iStrictLocking = Auto,
237 .bPosixLocking = true,
240 .bKernelOplocks = false,
241 .bLevel2OpLocks = true,
243 .bMangledNames = true,
246 .bSyncAlways = false,
247 .bStrictAllocate = false,
248 .bStrictSync = false,
251 .bDeleteReadonly = false,
252 .bFakeOplocks = false,
253 .bDeleteVetoFiles = false,
254 .bDosFilemode = false,
255 .bDosFiletimes = true,
256 .bDosFiletimeResolution = false,
257 .bFakeDirCreateTimes = false,
258 .bBlockingLocks = true,
259 .bInheritPerms = false,
260 .bInheritACLS = false,
261 .bInheritOwner = false,
263 .bUseClientDriver = false,
264 .bDefaultDevmode = true,
265 .bForcePrintername = false,
266 .bNTAclSupport = true,
267 .bForceUnknownAclUser = false,
268 .bUseSendfile = false,
269 .bProfileAcls = false,
270 .bMap_acl_inherit = false,
273 .bAclCheckPermissions = true,
274 .bAclMapFullControl = true,
275 .bAclGroupControl = false,
276 .bChangeNotify = true,
277 .bKernelChangeNotify = true,
278 .iallocation_roundup_size = SMB_ROUNDUP_ALLOCATION_SIZE,
281 .iMap_readonly = MAP_READONLY_YES,
282 #ifdef BROKEN_DIRECTORY_HANDLING
283 .iDirectoryNameCacheSize = 0,
285 .iDirectoryNameCacheSize = 100,
287 .ismb_encrypt = Auto,
292 /* local variables */
293 static struct loadparm_service **ServicePtrs = NULL;
294 static int iNumServices = 0;
295 static int iServiceIndex = 0;
296 static struct db_context *ServiceHash;
297 static int *invalid_services = NULL;
298 static int num_invalid_services = 0;
299 static bool bInGlobalSection = true;
300 static bool bGlobalOnly = false;
302 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
304 /* prototypes for the special type handlers */
305 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
306 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
307 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
308 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
309 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
310 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
311 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
312 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
313 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
314 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
315 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
316 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
318 static void set_allowed_client_auth(void);
320 static void add_to_file_list(const char *fname, const char *subfname);
321 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
322 static void free_param_opts(struct parmlist_entry **popts);
324 #include "lib/param/param_table.c"
326 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
328 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
329 * screen in SWAT. This is used to exclude parameters as well as to squash all
330 * parameters that have been duplicated by pseudonyms.
332 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
333 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
334 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
337 * NOTE2: Handling of duplicated (synonym) parameters:
338 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
339 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
340 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
341 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
344 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
345 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
348 static struct parm_struct parm_table[] = {
349 {N_("Base Options"), P_SEP, P_SEPARATOR},
352 .label = "dos charset",
355 .offset = GLOBAL_VAR(dos_charset),
356 .special = handle_dos_charset,
358 .flags = FLAG_ADVANCED
361 .label = "unix charset",
364 .offset = GLOBAL_VAR(unix_charset),
365 .special = handle_charset,
367 .flags = FLAG_ADVANCED
373 .offset = LOCAL_VAR(comment),
376 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
382 .offset = LOCAL_VAR(szPath),
385 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
388 .label = "directory",
391 .offset = LOCAL_VAR(szPath),
397 .label = "workgroup",
400 .offset = GLOBAL_VAR(szWorkgroup),
403 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
409 .offset = GLOBAL_VAR(szRealm),
410 .special = handle_realm,
412 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
415 .label = "netbios name",
418 .offset = GLOBAL_VAR(szNetbiosName),
421 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
424 .label = "netbios aliases",
427 .offset = GLOBAL_VAR(szNetbiosAliases),
428 .special = handle_netbios_aliases,
430 .flags = FLAG_ADVANCED,
433 .label = "netbios scope",
436 .offset = GLOBAL_VAR(szNetbiosScope),
439 .flags = FLAG_ADVANCED,
442 .label = "server string",
445 .offset = GLOBAL_VAR(szServerString),
448 .flags = FLAG_BASIC | FLAG_ADVANCED,
451 .label = "interfaces",
454 .offset = GLOBAL_VAR(szInterfaces),
457 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
460 .label = "bind interfaces only",
463 .offset = GLOBAL_VAR(bBindInterfacesOnly),
466 .flags = FLAG_ADVANCED | FLAG_WIZARD,
469 .label = "config backend",
472 .offset = GLOBAL_VAR(ConfigBackend),
474 .enum_list = enum_config_backend,
475 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
478 .label = "server role",
481 .offset = GLOBAL_VAR(server_role),
483 .enum_list = enum_server_role,
484 .flags = FLAG_BASIC | FLAG_ADVANCED,
487 {N_("Security Options"), P_SEP, P_SEPARATOR},
493 .offset = GLOBAL_VAR(security),
495 .enum_list = enum_security,
496 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
499 .label = "auth methods",
502 .offset = GLOBAL_VAR(AuthMethods),
505 .flags = FLAG_ADVANCED,
508 .label = "encrypt passwords",
511 .offset = GLOBAL_VAR(bEncryptPasswords),
514 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
517 .label = "client schannel",
520 .offset = GLOBAL_VAR(clientSchannel),
522 .enum_list = enum_bool_auto,
523 .flags = FLAG_BASIC | FLAG_ADVANCED,
526 .label = "server schannel",
529 .offset = GLOBAL_VAR(serverSchannel),
531 .enum_list = enum_bool_auto,
532 .flags = FLAG_BASIC | FLAG_ADVANCED,
535 .label = "allow trusted domains",
538 .offset = GLOBAL_VAR(bAllowTrustedDomains),
541 .flags = FLAG_ADVANCED,
544 .label = "map to guest",
547 .offset = GLOBAL_VAR(map_to_guest),
549 .enum_list = enum_map_to_guest,
550 .flags = FLAG_ADVANCED,
553 .label = "null passwords",
556 .offset = GLOBAL_VAR(bNullPasswords),
559 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
562 .label = "obey pam restrictions",
565 .offset = GLOBAL_VAR(bObeyPamRestrictions),
568 .flags = FLAG_ADVANCED,
571 .label = "password server",
574 .offset = GLOBAL_VAR(szPasswordServer),
577 .flags = FLAG_ADVANCED | FLAG_WIZARD,
580 .label = "smb passwd file",
583 .offset = GLOBAL_VAR(szSMBPasswdFile),
586 .flags = FLAG_ADVANCED,
589 .label = "private dir",
592 .offset = GLOBAL_VAR(szPrivateDir),
595 .flags = FLAG_ADVANCED,
598 .label = "private directory",
601 .offset = GLOBAL_VAR(szPrivateDir),
607 .label = "passdb backend",
610 .offset = GLOBAL_VAR(passdb_backend),
613 .flags = FLAG_ADVANCED | FLAG_WIZARD,
616 .label = "algorithmic rid base",
619 .offset = GLOBAL_VAR(AlgorithmicRidBase),
622 .flags = FLAG_ADVANCED,
625 .label = "root directory",
628 .offset = GLOBAL_VAR(szRootdir),
631 .flags = FLAG_ADVANCED,
637 .offset = GLOBAL_VAR(szRootdir),
646 .offset = GLOBAL_VAR(szRootdir),
652 .label = "guest account",
655 .offset = GLOBAL_VAR(szGuestaccount),
658 .flags = FLAG_BASIC | FLAG_ADVANCED,
661 .label = "enable privileges",
664 .offset = GLOBAL_VAR(bEnablePrivileges),
667 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
671 .label = "pam password change",
674 .offset = GLOBAL_VAR(bPamPasswordChange),
677 .flags = FLAG_ADVANCED,
680 .label = "passwd program",
683 .offset = GLOBAL_VAR(szPasswdProgram),
686 .flags = FLAG_ADVANCED,
689 .label = "passwd chat",
692 .offset = GLOBAL_VAR(szPasswdChat),
695 .flags = FLAG_ADVANCED,
698 .label = "passwd chat debug",
701 .offset = GLOBAL_VAR(bPasswdChatDebug),
704 .flags = FLAG_ADVANCED,
707 .label = "passwd chat timeout",
710 .offset = GLOBAL_VAR(iPasswdChatTimeout),
713 .flags = FLAG_ADVANCED,
716 .label = "check password script",
719 .offset = GLOBAL_VAR(szCheckPasswordScript),
722 .flags = FLAG_ADVANCED,
725 .label = "username map",
728 .offset = GLOBAL_VAR(szUsernameMap),
731 .flags = FLAG_ADVANCED,
734 .label = "password level",
737 .offset = GLOBAL_VAR(pwordlevel),
740 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
743 .label = "username level",
746 .offset = GLOBAL_VAR(unamelevel),
749 .flags = FLAG_ADVANCED,
752 .label = "unix password sync",
755 .offset = GLOBAL_VAR(bUnixPasswdSync),
758 .flags = FLAG_ADVANCED,
761 .label = "restrict anonymous",
764 .offset = GLOBAL_VAR(restrict_anonymous),
767 .flags = FLAG_ADVANCED,
770 .label = "lanman auth",
773 .offset = GLOBAL_VAR(bLanmanAuth),
776 .flags = FLAG_ADVANCED,
779 .label = "ntlm auth",
782 .offset = GLOBAL_VAR(bNTLMAuth),
785 .flags = FLAG_ADVANCED,
788 .label = "client NTLMv2 auth",
791 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
794 .flags = FLAG_ADVANCED,
797 .label = "client lanman auth",
800 .offset = GLOBAL_VAR(bClientLanManAuth),
803 .flags = FLAG_ADVANCED,
806 .label = "client plaintext auth",
809 .offset = GLOBAL_VAR(bClientPlaintextAuth),
812 .flags = FLAG_ADVANCED,
815 .label = "client use spnego principal",
818 .offset = GLOBAL_VAR(client_use_spnego_principal),
821 .flags = FLAG_ADVANCED,
827 .offset = LOCAL_VAR(szUsername),
830 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
836 .offset = LOCAL_VAR(szUsername),
845 .offset = LOCAL_VAR(szUsername),
851 .label = "invalid users",
854 .offset = LOCAL_VAR(szInvalidUsers),
857 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
860 .label = "valid users",
863 .offset = LOCAL_VAR(szValidUsers),
866 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
869 .label = "admin users",
872 .offset = LOCAL_VAR(szAdminUsers),
875 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
878 .label = "read list",
881 .offset = LOCAL_VAR(readlist),
884 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
887 .label = "write list",
890 .offset = LOCAL_VAR(writelist),
893 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
896 .label = "force user",
899 .offset = LOCAL_VAR(force_user),
902 .flags = FLAG_ADVANCED | FLAG_SHARE,
905 .label = "force group",
908 .offset = LOCAL_VAR(force_group),
911 .flags = FLAG_ADVANCED | FLAG_SHARE,
917 .offset = LOCAL_VAR(force_group),
920 .flags = FLAG_ADVANCED,
923 .label = "read only",
926 .offset = LOCAL_VAR(bRead_only),
929 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
935 .offset = LOCAL_VAR(bRead_only),
941 .label = "writeable",
944 .offset = LOCAL_VAR(bRead_only),
953 .offset = LOCAL_VAR(bRead_only),
959 .label = "acl check permissions",
962 .offset = LOCAL_VAR(bAclCheckPermissions),
965 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
968 .label = "acl group control",
971 .offset = LOCAL_VAR(bAclGroupControl),
974 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
977 .label = "acl map full control",
980 .offset = LOCAL_VAR(bAclMapFullControl),
983 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
986 .label = "create mask",
989 .offset = LOCAL_VAR(iCreate_mask),
992 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
995 .label = "create mode",
998 .offset = LOCAL_VAR(iCreate_mask),
1004 .label = "force create mode",
1007 .offset = LOCAL_VAR(iCreate_force_mode),
1010 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1013 .label = "security mask",
1016 .offset = LOCAL_VAR(iSecurity_mask),
1019 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1022 .label = "force security mode",
1025 .offset = LOCAL_VAR(iSecurity_force_mode),
1028 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1031 .label = "directory mask",
1034 .offset = LOCAL_VAR(iDir_mask),
1037 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1040 .label = "directory mode",
1043 .offset = LOCAL_VAR(iDir_mask),
1046 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1049 .label = "force directory mode",
1052 .offset = LOCAL_VAR(iDir_force_mode),
1055 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1058 .label = "directory security mask",
1061 .offset = LOCAL_VAR(iDir_Security_mask),
1064 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1067 .label = "force directory security mode",
1070 .offset = LOCAL_VAR(iDir_Security_force_mode),
1073 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1076 .label = "force unknown acl user",
1079 .offset = LOCAL_VAR(bForceUnknownAclUser),
1082 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1085 .label = "inherit permissions",
1088 .offset = LOCAL_VAR(bInheritPerms),
1091 .flags = FLAG_ADVANCED | FLAG_SHARE,
1094 .label = "inherit acls",
1097 .offset = LOCAL_VAR(bInheritACLS),
1100 .flags = FLAG_ADVANCED | FLAG_SHARE,
1103 .label = "inherit owner",
1106 .offset = LOCAL_VAR(bInheritOwner),
1109 .flags = FLAG_ADVANCED | FLAG_SHARE,
1112 .label = "guest only",
1115 .offset = LOCAL_VAR(bGuest_only),
1118 .flags = FLAG_ADVANCED | FLAG_SHARE,
1121 .label = "only guest",
1124 .offset = LOCAL_VAR(bGuest_only),
1130 .label = "administrative share",
1133 .offset = LOCAL_VAR(bAdministrative_share),
1136 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1140 .label = "guest ok",
1143 .offset = LOCAL_VAR(bGuest_ok),
1146 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1152 .offset = LOCAL_VAR(bGuest_ok),
1158 .label = "only user",
1161 .offset = LOCAL_VAR(bOnlyUser),
1164 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1167 .label = "hosts allow",
1170 .offset = LOCAL_VAR(szHostsallow),
1173 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1176 .label = "allow hosts",
1179 .offset = LOCAL_VAR(szHostsallow),
1185 .label = "hosts deny",
1188 .offset = LOCAL_VAR(szHostsdeny),
1191 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1194 .label = "deny hosts",
1197 .offset = LOCAL_VAR(szHostsdeny),
1203 .label = "preload modules",
1205 .p_class = P_GLOBAL,
1206 .offset = GLOBAL_VAR(szPreloadModules),
1209 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1212 .label = "dedicated keytab file",
1214 .p_class = P_GLOBAL,
1215 .offset = GLOBAL_VAR(szDedicatedKeytabFile),
1218 .flags = FLAG_ADVANCED,
1221 .label = "kerberos method",
1223 .p_class = P_GLOBAL,
1224 .offset = GLOBAL_VAR(iKerberosMethod),
1226 .enum_list = enum_kerberos_method,
1227 .flags = FLAG_ADVANCED,
1230 .label = "map untrusted to domain",
1232 .p_class = P_GLOBAL,
1233 .offset = GLOBAL_VAR(bMapUntrustedToDomain),
1236 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1240 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1243 .label = "log level",
1245 .p_class = P_GLOBAL,
1246 .offset = GLOBAL_VAR(loglevel),
1247 .special = handle_debug_list,
1249 .flags = FLAG_ADVANCED,
1252 .label = "debuglevel",
1254 .p_class = P_GLOBAL,
1255 .offset = GLOBAL_VAR(loglevel),
1256 .special = handle_debug_list,
1263 .p_class = P_GLOBAL,
1264 .offset = GLOBAL_VAR(syslog),
1267 .flags = FLAG_ADVANCED,
1270 .label = "syslog only",
1272 .p_class = P_GLOBAL,
1273 .offset = GLOBAL_VAR(bSyslogOnly),
1276 .flags = FLAG_ADVANCED,
1279 .label = "log file",
1281 .p_class = P_GLOBAL,
1282 .offset = GLOBAL_VAR(logfile),
1285 .flags = FLAG_ADVANCED,
1288 .label = "max log size",
1290 .p_class = P_GLOBAL,
1291 .offset = GLOBAL_VAR(max_log_size),
1294 .flags = FLAG_ADVANCED,
1297 .label = "debug timestamp",
1299 .p_class = P_GLOBAL,
1300 .offset = GLOBAL_VAR(bTimestampLogs),
1303 .flags = FLAG_ADVANCED,
1306 .label = "timestamp logs",
1308 .p_class = P_GLOBAL,
1309 .offset = GLOBAL_VAR(bTimestampLogs),
1312 .flags = FLAG_ADVANCED,
1315 .label = "debug prefix timestamp",
1317 .p_class = P_GLOBAL,
1318 .offset = GLOBAL_VAR(bDebugPrefixTimestamp),
1321 .flags = FLAG_ADVANCED,
1324 .label = "debug hires timestamp",
1326 .p_class = P_GLOBAL,
1327 .offset = GLOBAL_VAR(bDebugHiresTimestamp),
1330 .flags = FLAG_ADVANCED,
1333 .label = "debug pid",
1335 .p_class = P_GLOBAL,
1336 .offset = GLOBAL_VAR(bDebugPid),
1339 .flags = FLAG_ADVANCED,
1342 .label = "debug uid",
1344 .p_class = P_GLOBAL,
1345 .offset = GLOBAL_VAR(bDebugUid),
1348 .flags = FLAG_ADVANCED,
1351 .label = "debug class",
1353 .p_class = P_GLOBAL,
1354 .offset = GLOBAL_VAR(bDebugClass),
1357 .flags = FLAG_ADVANCED,
1360 .label = "enable core files",
1362 .p_class = P_GLOBAL,
1363 .offset = GLOBAL_VAR(bEnableCoreFiles),
1366 .flags = FLAG_ADVANCED,
1369 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1372 .label = "allocation roundup size",
1375 .offset = LOCAL_VAR(iallocation_roundup_size),
1378 .flags = FLAG_ADVANCED,
1381 .label = "aio read size",
1384 .offset = LOCAL_VAR(iAioReadSize),
1387 .flags = FLAG_ADVANCED,
1390 .label = "aio write size",
1393 .offset = LOCAL_VAR(iAioWriteSize),
1396 .flags = FLAG_ADVANCED,
1399 .label = "aio write behind",
1402 .offset = LOCAL_VAR(szAioWriteBehind),
1405 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1408 .label = "smb ports",
1410 .p_class = P_GLOBAL,
1411 .offset = GLOBAL_VAR(smb_ports),
1414 .flags = FLAG_ADVANCED,
1417 .label = "large readwrite",
1419 .p_class = P_GLOBAL,
1420 .offset = GLOBAL_VAR(bLargeReadwrite),
1423 .flags = FLAG_ADVANCED,
1426 .label = "server max protocol",
1428 .p_class = P_GLOBAL,
1429 .offset = GLOBAL_VAR(srv_maxprotocol),
1431 .enum_list = enum_protocol,
1432 .flags = FLAG_ADVANCED,
1435 .label = "max protocol",
1437 .p_class = P_GLOBAL,
1438 .offset = GLOBAL_VAR(srv_maxprotocol),
1440 .enum_list = enum_protocol,
1441 .flags = FLAG_ADVANCED,
1444 .label = "protocol",
1446 .p_class = P_GLOBAL,
1447 .offset = GLOBAL_VAR(srv_maxprotocol),
1449 .enum_list = enum_protocol,
1450 .flags = FLAG_ADVANCED,
1453 .label = "server min protocol",
1455 .p_class = P_GLOBAL,
1456 .offset = GLOBAL_VAR(srv_minprotocol),
1458 .enum_list = enum_protocol,
1459 .flags = FLAG_ADVANCED,
1462 .label = "min protocol",
1464 .p_class = P_GLOBAL,
1465 .offset = GLOBAL_VAR(srv_minprotocol),
1467 .enum_list = enum_protocol,
1468 .flags = FLAG_ADVANCED,
1471 .label = "client max protocol",
1473 .p_class = P_GLOBAL,
1474 .offset = GLOBAL_VAR(cli_maxprotocol),
1476 .enum_list = enum_protocol,
1477 .flags = FLAG_ADVANCED,
1480 .label = "client min protocol",
1482 .p_class = P_GLOBAL,
1483 .offset = GLOBAL_VAR(cli_minprotocol),
1485 .enum_list = enum_protocol,
1486 .flags = FLAG_ADVANCED,
1491 .p_class = P_GLOBAL,
1492 .offset = GLOBAL_VAR(bUnicode),
1497 .label = "min receivefile size",
1499 .p_class = P_GLOBAL,
1500 .offset = GLOBAL_VAR(iminreceivefile),
1503 .flags = FLAG_ADVANCED,
1506 .label = "read raw",
1508 .p_class = P_GLOBAL,
1509 .offset = GLOBAL_VAR(bReadRaw),
1512 .flags = FLAG_ADVANCED,
1515 .label = "write raw",
1517 .p_class = P_GLOBAL,
1518 .offset = GLOBAL_VAR(bWriteRaw),
1521 .flags = FLAG_ADVANCED,
1524 .label = "disable netbios",
1526 .p_class = P_GLOBAL,
1527 .offset = GLOBAL_VAR(bDisableNetbios),
1530 .flags = FLAG_ADVANCED,
1533 .label = "reset on zero vc",
1535 .p_class = P_GLOBAL,
1536 .offset = GLOBAL_VAR(bResetOnZeroVC),
1539 .flags = FLAG_ADVANCED,
1542 .label = "log writeable files on exit",
1544 .p_class = P_GLOBAL,
1545 .offset = GLOBAL_VAR(bLogWriteableFilesOnExit),
1548 .flags = FLAG_ADVANCED,
1551 .label = "acl compatibility",
1553 .p_class = P_GLOBAL,
1554 .offset = GLOBAL_VAR(iAclCompat),
1556 .enum_list = enum_acl_compat_vals,
1557 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1560 .label = "defer sharing violations",
1562 .p_class = P_GLOBAL,
1563 .offset = GLOBAL_VAR(bDeferSharingViolations),
1566 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1569 .label = "ea support",
1572 .offset = LOCAL_VAR(bEASupport),
1575 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1578 .label = "nt acl support",
1581 .offset = LOCAL_VAR(bNTAclSupport),
1584 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1587 .label = "nt pipe support",
1589 .p_class = P_GLOBAL,
1590 .offset = GLOBAL_VAR(bNTPipeSupport),
1593 .flags = FLAG_ADVANCED,
1596 .label = "nt status support",
1598 .p_class = P_GLOBAL,
1599 .offset = GLOBAL_VAR(bNTStatusSupport),
1602 .flags = FLAG_ADVANCED,
1605 .label = "profile acls",
1608 .offset = LOCAL_VAR(bProfileAcls),
1611 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1614 .label = "map acl inherit",
1617 .offset = LOCAL_VAR(bMap_acl_inherit),
1620 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1623 .label = "afs share",
1626 .offset = LOCAL_VAR(bAfs_Share),
1629 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1634 .p_class = P_GLOBAL,
1635 .offset = GLOBAL_VAR(max_mux),
1638 .flags = FLAG_ADVANCED,
1641 .label = "max xmit",
1643 .p_class = P_GLOBAL,
1644 .offset = GLOBAL_VAR(max_xmit),
1647 .flags = FLAG_ADVANCED,
1650 .label = "name resolve order",
1652 .p_class = P_GLOBAL,
1653 .offset = GLOBAL_VAR(szNameResolveOrder),
1656 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1661 .p_class = P_GLOBAL,
1662 .offset = GLOBAL_VAR(max_ttl),
1665 .flags = FLAG_ADVANCED,
1668 .label = "max wins ttl",
1670 .p_class = P_GLOBAL,
1671 .offset = GLOBAL_VAR(max_wins_ttl),
1674 .flags = FLAG_ADVANCED,
1677 .label = "min wins ttl",
1679 .p_class = P_GLOBAL,
1680 .offset = GLOBAL_VAR(min_wins_ttl),
1683 .flags = FLAG_ADVANCED,
1686 .label = "time server",
1688 .p_class = P_GLOBAL,
1689 .offset = GLOBAL_VAR(bTimeServer),
1692 .flags = FLAG_ADVANCED,
1695 .label = "unix extensions",
1697 .p_class = P_GLOBAL,
1698 .offset = GLOBAL_VAR(bUnixExtensions),
1701 .flags = FLAG_ADVANCED,
1704 .label = "use spnego",
1706 .p_class = P_GLOBAL,
1707 .offset = GLOBAL_VAR(bUseSpnego),
1710 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
1713 .label = "client signing",
1715 .p_class = P_GLOBAL,
1716 .offset = GLOBAL_VAR(client_signing),
1718 .enum_list = enum_smb_signing_vals,
1719 .flags = FLAG_ADVANCED,
1722 .label = "server signing",
1724 .p_class = P_GLOBAL,
1725 .offset = GLOBAL_VAR(server_signing),
1727 .enum_list = enum_smb_signing_vals,
1728 .flags = FLAG_ADVANCED,
1731 .label = "smb encrypt",
1734 .offset = LOCAL_VAR(ismb_encrypt),
1736 .enum_list = enum_smb_signing_vals,
1737 .flags = FLAG_ADVANCED,
1740 .label = "client use spnego",
1742 .p_class = P_GLOBAL,
1743 .offset = GLOBAL_VAR(bClientUseSpnego),
1746 .flags = FLAG_ADVANCED,
1749 .label = "client ldap sasl wrapping",
1751 .p_class = P_GLOBAL,
1752 .offset = GLOBAL_VAR(client_ldap_sasl_wrapping),
1754 .enum_list = enum_ldap_sasl_wrapping,
1755 .flags = FLAG_ADVANCED,
1758 .label = "enable asu support",
1760 .p_class = P_GLOBAL,
1761 .offset = GLOBAL_VAR(bASUSupport),
1764 .flags = FLAG_ADVANCED,
1767 .label = "svcctl list",
1769 .p_class = P_GLOBAL,
1770 .offset = GLOBAL_VAR(szServicesList),
1773 .flags = FLAG_ADVANCED,
1776 .label = "cldap port",
1778 .p_class = P_GLOBAL,
1779 .offset = GLOBAL_VAR(cldap_port),
1784 .label = "dgram port",
1786 .p_class = P_GLOBAL,
1787 .offset = GLOBAL_VAR(dgram_port),
1792 .label = "nbt port",
1794 .p_class = P_GLOBAL,
1795 .offset = GLOBAL_VAR(nbt_port),
1800 .label = "krb5 port",
1802 .p_class = P_GLOBAL,
1803 .offset = GLOBAL_VAR(krb5_port),
1808 .label = "kpasswd port",
1810 .p_class = P_GLOBAL,
1811 .offset = GLOBAL_VAR(kpasswd_port),
1816 .label = "web port",
1818 .p_class = P_GLOBAL,
1819 .offset = GLOBAL_VAR(web_port),
1824 .label = "rpc big endian",
1826 .p_class = P_GLOBAL,
1827 .offset = GLOBAL_VAR(bRpcBigEndian),
1832 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
1835 .label = "block size",
1838 .offset = LOCAL_VAR(iBlock_size),
1841 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1844 .label = "deadtime",
1846 .p_class = P_GLOBAL,
1847 .offset = GLOBAL_VAR(deadtime),
1850 .flags = FLAG_ADVANCED,
1853 .label = "getwd cache",
1855 .p_class = P_GLOBAL,
1856 .offset = GLOBAL_VAR(getwd_cache),
1859 .flags = FLAG_ADVANCED,
1862 .label = "keepalive",
1864 .p_class = P_GLOBAL,
1865 .offset = GLOBAL_VAR(iKeepalive),
1868 .flags = FLAG_ADVANCED,
1871 .label = "change notify",
1874 .offset = LOCAL_VAR(bChangeNotify),
1877 .flags = FLAG_ADVANCED | FLAG_SHARE,
1880 .label = "directory name cache size",
1883 .offset = LOCAL_VAR(iDirectoryNameCacheSize),
1886 .flags = FLAG_ADVANCED | FLAG_SHARE,
1889 .label = "kernel change notify",
1892 .offset = LOCAL_VAR(bKernelChangeNotify),
1895 .flags = FLAG_ADVANCED | FLAG_SHARE,
1898 .label = "lpq cache time",
1900 .p_class = P_GLOBAL,
1901 .offset = GLOBAL_VAR(lpqcachetime),
1904 .flags = FLAG_ADVANCED,
1907 .label = "max smbd processes",
1909 .p_class = P_GLOBAL,
1910 .offset = GLOBAL_VAR(iMaxSmbdProcesses),
1913 .flags = FLAG_ADVANCED,
1916 .label = "max connections",
1919 .offset = LOCAL_VAR(iMaxConnections),
1922 .flags = FLAG_ADVANCED | FLAG_SHARE,
1925 .label = "paranoid server security",
1927 .p_class = P_GLOBAL,
1928 .offset = GLOBAL_VAR(paranoid_server_security),
1931 .flags = FLAG_ADVANCED,
1934 .label = "max disk size",
1936 .p_class = P_GLOBAL,
1937 .offset = GLOBAL_VAR(maxdisksize),
1940 .flags = FLAG_ADVANCED,
1943 .label = "max open files",
1945 .p_class = P_GLOBAL,
1946 .offset = GLOBAL_VAR(max_open_files),
1949 .flags = FLAG_ADVANCED,
1952 .label = "min print space",
1955 .offset = LOCAL_VAR(iMinPrintSpace),
1958 .flags = FLAG_ADVANCED | FLAG_PRINT,
1961 .label = "socket options",
1963 .p_class = P_GLOBAL,
1964 .offset = GLOBAL_VAR(socket_options),
1967 .flags = FLAG_ADVANCED,
1970 .label = "strict allocate",
1973 .offset = LOCAL_VAR(bStrictAllocate),
1976 .flags = FLAG_ADVANCED | FLAG_SHARE,
1979 .label = "strict sync",
1982 .offset = LOCAL_VAR(bStrictSync),
1985 .flags = FLAG_ADVANCED | FLAG_SHARE,
1988 .label = "sync always",
1991 .offset = LOCAL_VAR(bSyncAlways),
1994 .flags = FLAG_ADVANCED | FLAG_SHARE,
1997 .label = "use mmap",
1999 .p_class = P_GLOBAL,
2000 .offset = GLOBAL_VAR(bUseMmap),
2003 .flags = FLAG_ADVANCED,
2006 .label = "use sendfile",
2009 .offset = LOCAL_VAR(bUseSendfile),
2012 .flags = FLAG_ADVANCED | FLAG_SHARE,
2015 .label = "hostname lookups",
2017 .p_class = P_GLOBAL,
2018 .offset = GLOBAL_VAR(bHostnameLookups),
2021 .flags = FLAG_ADVANCED,
2024 .label = "write cache size",
2027 .offset = LOCAL_VAR(iWriteCacheSize),
2030 .flags = FLAG_ADVANCED | FLAG_SHARE,
2033 .label = "name cache timeout",
2035 .p_class = P_GLOBAL,
2036 .offset = GLOBAL_VAR(name_cache_timeout),
2039 .flags = FLAG_ADVANCED,
2042 .label = "ctdbd socket",
2044 .p_class = P_GLOBAL,
2045 .offset = GLOBAL_VAR(ctdbdSocket),
2048 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2051 .label = "cluster addresses",
2053 .p_class = P_GLOBAL,
2054 .offset = GLOBAL_VAR(szClusterAddresses),
2057 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2060 .label = "clustering",
2062 .p_class = P_GLOBAL,
2063 .offset = GLOBAL_VAR(clustering),
2066 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2069 .label = "ctdb timeout",
2071 .p_class = P_GLOBAL,
2072 .offset = GLOBAL_VAR(ctdb_timeout),
2075 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2078 .label = "ctdb locktime warn threshold",
2080 .p_class = P_GLOBAL,
2081 .offset = GLOBAL_VAR(ctdb_locktime_warn_threshold),
2084 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2087 .label = "smb2 max read",
2089 .p_class = P_GLOBAL,
2090 .offset = GLOBAL_VAR(ismb2_max_read),
2093 .flags = FLAG_ADVANCED,
2096 .label = "smb2 max write",
2098 .p_class = P_GLOBAL,
2099 .offset = GLOBAL_VAR(ismb2_max_write),
2102 .flags = FLAG_ADVANCED,
2105 .label = "smb2 max trans",
2107 .p_class = P_GLOBAL,
2108 .offset = GLOBAL_VAR(ismb2_max_trans),
2111 .flags = FLAG_ADVANCED,
2114 .label = "smb2 max credits",
2116 .p_class = P_GLOBAL,
2117 .offset = GLOBAL_VAR(ismb2_max_credits),
2120 .flags = FLAG_ADVANCED,
2123 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2126 .label = "max reported print jobs",
2129 .offset = LOCAL_VAR(iMaxReportedPrintJobs),
2132 .flags = FLAG_ADVANCED | FLAG_PRINT,
2135 .label = "max print jobs",
2138 .offset = LOCAL_VAR(iMaxPrintJobs),
2141 .flags = FLAG_ADVANCED | FLAG_PRINT,
2144 .label = "load printers",
2146 .p_class = P_GLOBAL,
2147 .offset = GLOBAL_VAR(bLoadPrinters),
2150 .flags = FLAG_ADVANCED | FLAG_PRINT,
2153 .label = "printcap cache time",
2155 .p_class = P_GLOBAL,
2156 .offset = GLOBAL_VAR(PrintcapCacheTime),
2159 .flags = FLAG_ADVANCED | FLAG_PRINT,
2162 .label = "printcap name",
2164 .p_class = P_GLOBAL,
2165 .offset = GLOBAL_VAR(szPrintcapname),
2168 .flags = FLAG_ADVANCED | FLAG_PRINT,
2171 .label = "printcap",
2173 .p_class = P_GLOBAL,
2174 .offset = GLOBAL_VAR(szPrintcapname),
2180 .label = "printable",
2183 .offset = LOCAL_VAR(bPrint_ok),
2186 .flags = FLAG_ADVANCED | FLAG_PRINT,
2189 .label = "print notify backchannel",
2192 .offset = LOCAL_VAR(bPrintNotifyBackchannel),
2195 .flags = FLAG_ADVANCED,
2198 .label = "print ok",
2201 .offset = LOCAL_VAR(bPrint_ok),
2207 .label = "printing",
2210 .offset = LOCAL_VAR(iPrinting),
2211 .special = handle_printing,
2212 .enum_list = enum_printing,
2213 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2216 .label = "cups options",
2219 .offset = LOCAL_VAR(szCupsOptions),
2222 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2225 .label = "cups server",
2227 .p_class = P_GLOBAL,
2228 .offset = GLOBAL_VAR(szCupsServer),
2231 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2234 .label = "cups encrypt",
2236 .p_class = P_GLOBAL,
2237 .offset = GLOBAL_VAR(CupsEncrypt),
2239 .enum_list = enum_bool_auto,
2240 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2244 .label = "cups connection timeout",
2246 .p_class = P_GLOBAL,
2247 .offset = GLOBAL_VAR(cups_connection_timeout),
2250 .flags = FLAG_ADVANCED,
2253 .label = "iprint server",
2255 .p_class = P_GLOBAL,
2256 .offset = GLOBAL_VAR(szIPrintServer),
2259 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2262 .label = "print command",
2265 .offset = LOCAL_VAR(szPrintcommand),
2268 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2271 .label = "disable spoolss",
2273 .p_class = P_GLOBAL,
2274 .offset = GLOBAL_VAR(bDisableSpoolss),
2277 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2280 .label = "enable spoolss",
2282 .p_class = P_GLOBAL,
2283 .offset = GLOBAL_VAR(bDisableSpoolss),
2289 .label = "lpq command",
2292 .offset = LOCAL_VAR(szLpqcommand),
2295 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2298 .label = "lprm command",
2301 .offset = LOCAL_VAR(szLprmcommand),
2304 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2307 .label = "lppause command",
2310 .offset = LOCAL_VAR(szLppausecommand),
2313 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2316 .label = "lpresume command",
2319 .offset = LOCAL_VAR(szLpresumecommand),
2322 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2325 .label = "queuepause command",
2328 .offset = LOCAL_VAR(szQueuepausecommand),
2331 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2334 .label = "queueresume command",
2337 .offset = LOCAL_VAR(szQueueresumecommand),
2340 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2343 .label = "addport command",
2345 .p_class = P_GLOBAL,
2346 .offset = GLOBAL_VAR(szAddPortCommand),
2349 .flags = FLAG_ADVANCED,
2352 .label = "enumports command",
2354 .p_class = P_GLOBAL,
2355 .offset = GLOBAL_VAR(szEnumPortsCommand),
2358 .flags = FLAG_ADVANCED,
2361 .label = "addprinter command",
2363 .p_class = P_GLOBAL,
2364 .offset = GLOBAL_VAR(szAddPrinterCommand),
2367 .flags = FLAG_ADVANCED,
2370 .label = "deleteprinter command",
2372 .p_class = P_GLOBAL,
2373 .offset = GLOBAL_VAR(szDeletePrinterCommand),
2376 .flags = FLAG_ADVANCED,
2379 .label = "show add printer wizard",
2381 .p_class = P_GLOBAL,
2382 .offset = GLOBAL_VAR(bMsAddPrinterWizard),
2385 .flags = FLAG_ADVANCED,
2388 .label = "os2 driver map",
2390 .p_class = P_GLOBAL,
2391 .offset = GLOBAL_VAR(szOs2DriverMap),
2394 .flags = FLAG_ADVANCED,
2398 .label = "printer name",
2401 .offset = LOCAL_VAR(szPrintername),
2404 .flags = FLAG_ADVANCED | FLAG_PRINT,
2410 .offset = LOCAL_VAR(szPrintername),
2416 .label = "use client driver",
2419 .offset = LOCAL_VAR(bUseClientDriver),
2422 .flags = FLAG_ADVANCED | FLAG_PRINT,
2425 .label = "default devmode",
2428 .offset = LOCAL_VAR(bDefaultDevmode),
2431 .flags = FLAG_ADVANCED | FLAG_PRINT,
2434 .label = "force printername",
2437 .offset = LOCAL_VAR(bForcePrintername),
2440 .flags = FLAG_ADVANCED | FLAG_PRINT,
2443 .label = "printjob username",
2446 .offset = LOCAL_VAR(szPrintjobUsername),
2449 .flags = FLAG_ADVANCED | FLAG_PRINT,
2452 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2455 .label = "mangling method",
2457 .p_class = P_GLOBAL,
2458 .offset = GLOBAL_VAR(szManglingMethod),
2461 .flags = FLAG_ADVANCED,
2464 .label = "mangle prefix",
2466 .p_class = P_GLOBAL,
2467 .offset = GLOBAL_VAR(mangle_prefix),
2470 .flags = FLAG_ADVANCED,
2474 .label = "default case",
2477 .offset = LOCAL_VAR(iDefaultCase),
2479 .enum_list = enum_case,
2480 .flags = FLAG_ADVANCED | FLAG_SHARE,
2483 .label = "case sensitive",
2486 .offset = LOCAL_VAR(iCaseSensitive),
2488 .enum_list = enum_bool_auto,
2489 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2492 .label = "casesignames",
2495 .offset = LOCAL_VAR(iCaseSensitive),
2497 .enum_list = enum_bool_auto,
2498 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2501 .label = "preserve case",
2504 .offset = LOCAL_VAR(bCasePreserve),
2507 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2510 .label = "short preserve case",
2513 .offset = LOCAL_VAR(bShortCasePreserve),
2516 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2519 .label = "mangling char",
2522 .offset = LOCAL_VAR(magic_char),
2525 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2528 .label = "hide dot files",
2531 .offset = LOCAL_VAR(bHideDotFiles),
2534 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2537 .label = "hide special files",
2540 .offset = LOCAL_VAR(bHideSpecialFiles),
2543 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2546 .label = "hide unreadable",
2549 .offset = LOCAL_VAR(bHideUnReadable),
2552 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2555 .label = "hide unwriteable files",
2558 .offset = LOCAL_VAR(bHideUnWriteableFiles),
2561 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2564 .label = "delete veto files",
2567 .offset = LOCAL_VAR(bDeleteVetoFiles),
2570 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2573 .label = "veto files",
2576 .offset = LOCAL_VAR(szVetoFiles),
2579 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2582 .label = "hide files",
2585 .offset = LOCAL_VAR(szHideFiles),
2588 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2591 .label = "veto oplock files",
2594 .offset = LOCAL_VAR(szVetoOplockFiles),
2597 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2600 .label = "map archive",
2603 .offset = LOCAL_VAR(bMap_archive),
2606 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2609 .label = "map hidden",
2612 .offset = LOCAL_VAR(bMap_hidden),
2615 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2618 .label = "map system",
2621 .offset = LOCAL_VAR(bMap_system),
2624 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2627 .label = "map readonly",
2630 .offset = LOCAL_VAR(iMap_readonly),
2632 .enum_list = enum_map_readonly,
2633 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2636 .label = "mangled names",
2639 .offset = LOCAL_VAR(bMangledNames),
2642 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2645 .label = "max stat cache size",
2647 .p_class = P_GLOBAL,
2648 .offset = GLOBAL_VAR(iMaxStatCacheSize),
2651 .flags = FLAG_ADVANCED,
2654 .label = "stat cache",
2656 .p_class = P_GLOBAL,
2657 .offset = GLOBAL_VAR(bStatCache),
2660 .flags = FLAG_ADVANCED,
2663 .label = "store dos attributes",
2666 .offset = LOCAL_VAR(bStoreDosAttributes),
2669 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2672 .label = "dmapi support",
2675 .offset = LOCAL_VAR(bDmapiSupport),
2678 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2682 {N_("Domain Options"), P_SEP, P_SEPARATOR},
2685 .label = "machine password timeout",
2687 .p_class = P_GLOBAL,
2688 .offset = GLOBAL_VAR(machine_password_timeout),
2691 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2694 {N_("Logon Options"), P_SEP, P_SEPARATOR},
2697 .label = "add user script",
2699 .p_class = P_GLOBAL,
2700 .offset = GLOBAL_VAR(szAddUserScript),
2703 .flags = FLAG_ADVANCED,
2706 .label = "rename user script",
2708 .p_class = P_GLOBAL,
2709 .offset = GLOBAL_VAR(szRenameUserScript),
2712 .flags = FLAG_ADVANCED,
2715 .label = "delete user script",
2717 .p_class = P_GLOBAL,
2718 .offset = GLOBAL_VAR(szDelUserScript),
2721 .flags = FLAG_ADVANCED,
2724 .label = "add group script",
2726 .p_class = P_GLOBAL,
2727 .offset = GLOBAL_VAR(szAddGroupScript),
2730 .flags = FLAG_ADVANCED,
2733 .label = "delete group script",
2735 .p_class = P_GLOBAL,
2736 .offset = GLOBAL_VAR(szDelGroupScript),
2739 .flags = FLAG_ADVANCED,
2742 .label = "add user to group script",
2744 .p_class = P_GLOBAL,
2745 .offset = GLOBAL_VAR(szAddUserToGroupScript),
2748 .flags = FLAG_ADVANCED,
2751 .label = "delete user from group script",
2753 .p_class = P_GLOBAL,
2754 .offset = GLOBAL_VAR(szDelUserFromGroupScript),
2757 .flags = FLAG_ADVANCED,
2760 .label = "set primary group script",
2762 .p_class = P_GLOBAL,
2763 .offset = GLOBAL_VAR(szSetPrimaryGroupScript),
2766 .flags = FLAG_ADVANCED,
2769 .label = "add machine script",
2771 .p_class = P_GLOBAL,
2772 .offset = GLOBAL_VAR(szAddMachineScript),
2775 .flags = FLAG_ADVANCED,
2778 .label = "shutdown script",
2780 .p_class = P_GLOBAL,
2781 .offset = GLOBAL_VAR(szShutdownScript),
2784 .flags = FLAG_ADVANCED,
2787 .label = "abort shutdown script",
2789 .p_class = P_GLOBAL,
2790 .offset = GLOBAL_VAR(szAbortShutdownScript),
2793 .flags = FLAG_ADVANCED,
2796 .label = "username map script",
2798 .p_class = P_GLOBAL,
2799 .offset = GLOBAL_VAR(szUsernameMapScript),
2802 .flags = FLAG_ADVANCED,
2805 .label = "username map cache time",
2807 .p_class = P_GLOBAL,
2808 .offset = GLOBAL_VAR(iUsernameMapCacheTime),
2811 .flags = FLAG_ADVANCED,
2814 .label = "logon script",
2816 .p_class = P_GLOBAL,
2817 .offset = GLOBAL_VAR(szLogonScript),
2820 .flags = FLAG_ADVANCED,
2823 .label = "logon path",
2825 .p_class = P_GLOBAL,
2826 .offset = GLOBAL_VAR(szLogonPath),
2829 .flags = FLAG_ADVANCED,
2832 .label = "logon drive",
2834 .p_class = P_GLOBAL,
2835 .offset = GLOBAL_VAR(szLogonDrive),
2838 .flags = FLAG_ADVANCED,
2841 .label = "logon home",
2843 .p_class = P_GLOBAL,
2844 .offset = GLOBAL_VAR(szLogonHome),
2847 .flags = FLAG_ADVANCED,
2850 .label = "domain logons",
2852 .p_class = P_GLOBAL,
2853 .offset = GLOBAL_VAR(bDomainLogons),
2856 .flags = FLAG_ADVANCED,
2860 .label = "init logon delayed hosts",
2862 .p_class = P_GLOBAL,
2863 .offset = GLOBAL_VAR(szInitLogonDelayedHosts),
2866 .flags = FLAG_ADVANCED,
2870 .label = "init logon delay",
2872 .p_class = P_GLOBAL,
2873 .offset = GLOBAL_VAR(InitLogonDelay),
2876 .flags = FLAG_ADVANCED,
2880 {N_("Browse Options"), P_SEP, P_SEPARATOR},
2883 .label = "os level",
2885 .p_class = P_GLOBAL,
2886 .offset = GLOBAL_VAR(os_level),
2889 .flags = FLAG_BASIC | FLAG_ADVANCED,
2892 .label = "lm announce",
2894 .p_class = P_GLOBAL,
2895 .offset = GLOBAL_VAR(lm_announce),
2897 .enum_list = enum_bool_auto,
2898 .flags = FLAG_ADVANCED,
2901 .label = "lm interval",
2903 .p_class = P_GLOBAL,
2904 .offset = GLOBAL_VAR(lm_interval),
2907 .flags = FLAG_ADVANCED,
2910 .label = "preferred master",
2912 .p_class = P_GLOBAL,
2913 .offset = GLOBAL_VAR(iPreferredMaster),
2915 .enum_list = enum_bool_auto,
2916 .flags = FLAG_BASIC | FLAG_ADVANCED,
2919 .label = "prefered master",
2921 .p_class = P_GLOBAL,
2922 .offset = GLOBAL_VAR(iPreferredMaster),
2924 .enum_list = enum_bool_auto,
2928 .label = "local master",
2930 .p_class = P_GLOBAL,
2931 .offset = GLOBAL_VAR(bLocalMaster),
2934 .flags = FLAG_BASIC | FLAG_ADVANCED,
2937 .label = "domain master",
2939 .p_class = P_GLOBAL,
2940 .offset = GLOBAL_VAR(domain_master),
2942 .enum_list = enum_bool_auto,
2943 .flags = FLAG_BASIC | FLAG_ADVANCED,
2946 .label = "browse list",
2948 .p_class = P_GLOBAL,
2949 .offset = GLOBAL_VAR(bBrowseList),
2952 .flags = FLAG_ADVANCED,
2955 .label = "browseable",
2958 .offset = LOCAL_VAR(bBrowseable),
2961 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
2964 .label = "browsable",
2967 .offset = LOCAL_VAR(bBrowseable),
2973 .label = "access based share enum",
2976 .offset = LOCAL_VAR(bAccessBasedShareEnum),
2979 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
2982 .label = "enhanced browsing",
2984 .p_class = P_GLOBAL,
2985 .offset = GLOBAL_VAR(enhanced_browsing),
2988 .flags = FLAG_ADVANCED,
2991 {N_("WINS Options"), P_SEP, P_SEPARATOR},
2994 .label = "dns proxy",
2996 .p_class = P_GLOBAL,
2997 .offset = GLOBAL_VAR(bWINSdnsProxy),
3000 .flags = FLAG_ADVANCED,
3003 .label = "wins proxy",
3005 .p_class = P_GLOBAL,
3006 .offset = GLOBAL_VAR(bWINSproxy),
3009 .flags = FLAG_ADVANCED,
3012 .label = "wins server",
3014 .p_class = P_GLOBAL,
3015 .offset = GLOBAL_VAR(szWINSservers),
3018 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3021 .label = "wins support",
3023 .p_class = P_GLOBAL,
3024 .offset = GLOBAL_VAR(bWINSsupport),
3027 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3030 .label = "wins hook",
3032 .p_class = P_GLOBAL,
3033 .offset = GLOBAL_VAR(szWINSHook),
3036 .flags = FLAG_ADVANCED,
3039 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3042 .label = "blocking locks",
3045 .offset = LOCAL_VAR(bBlockingLocks),
3048 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3051 .label = "csc policy",
3054 .offset = LOCAL_VAR(iCSCPolicy),
3056 .enum_list = enum_csc_policy,
3057 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3060 .label = "fake oplocks",
3063 .offset = LOCAL_VAR(bFakeOplocks),
3066 .flags = FLAG_ADVANCED | FLAG_SHARE,
3069 .label = "kernel oplocks",
3072 .offset = LOCAL_VAR(bKernelOplocks),
3075 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3081 .offset = LOCAL_VAR(bLocking),
3084 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3087 .label = "lock spin time",
3089 .p_class = P_GLOBAL,
3090 .offset = GLOBAL_VAR(iLockSpinTime),
3093 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3099 .offset = LOCAL_VAR(bOpLocks),
3102 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3105 .label = "level2 oplocks",
3108 .offset = LOCAL_VAR(bLevel2OpLocks),
3111 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3114 .label = "oplock break wait time",
3116 .p_class = P_GLOBAL,
3117 .offset = GLOBAL_VAR(oplock_break_wait_time),
3120 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3123 .label = "oplock contention limit",
3126 .offset = LOCAL_VAR(iOplockContentionLimit),
3129 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3132 .label = "posix locking",
3135 .offset = LOCAL_VAR(bPosixLocking),
3138 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3141 .label = "strict locking",
3144 .offset = LOCAL_VAR(iStrictLocking),
3146 .enum_list = enum_bool_auto,
3147 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3150 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3153 .label = "ldap admin dn",
3155 .p_class = P_GLOBAL,
3156 .offset = GLOBAL_VAR(szLdapAdminDn),
3159 .flags = FLAG_ADVANCED,
3162 .label = "ldap delete dn",
3164 .p_class = P_GLOBAL,
3165 .offset = GLOBAL_VAR(ldap_delete_dn),
3168 .flags = FLAG_ADVANCED,
3171 .label = "ldap group suffix",
3173 .p_class = P_GLOBAL,
3174 .offset = GLOBAL_VAR(szLdapGroupSuffix),
3177 .flags = FLAG_ADVANCED,
3180 .label = "ldap idmap suffix",
3182 .p_class = P_GLOBAL,
3183 .offset = GLOBAL_VAR(szLdapIdmapSuffix),
3186 .flags = FLAG_ADVANCED,
3189 .label = "ldap machine suffix",
3191 .p_class = P_GLOBAL,
3192 .offset = GLOBAL_VAR(szLdapMachineSuffix),
3195 .flags = FLAG_ADVANCED,
3198 .label = "ldap passwd sync",
3200 .p_class = P_GLOBAL,
3201 .offset = GLOBAL_VAR(ldap_passwd_sync),
3203 .enum_list = enum_ldap_passwd_sync,
3204 .flags = FLAG_ADVANCED,
3207 .label = "ldap password sync",
3209 .p_class = P_GLOBAL,
3210 .offset = GLOBAL_VAR(ldap_passwd_sync),
3212 .enum_list = enum_ldap_passwd_sync,
3216 .label = "ldap replication sleep",
3218 .p_class = P_GLOBAL,
3219 .offset = GLOBAL_VAR(ldap_replication_sleep),
3222 .flags = FLAG_ADVANCED,
3225 .label = "ldap suffix",
3227 .p_class = P_GLOBAL,
3228 .offset = GLOBAL_VAR(szLdapSuffix),
3231 .flags = FLAG_ADVANCED,
3234 .label = "ldap ssl",
3236 .p_class = P_GLOBAL,
3237 .offset = GLOBAL_VAR(ldap_ssl),
3239 .enum_list = enum_ldap_ssl,
3240 .flags = FLAG_ADVANCED,
3243 .label = "ldap ssl ads",
3245 .p_class = P_GLOBAL,
3246 .offset = GLOBAL_VAR(ldap_ssl_ads),
3249 .flags = FLAG_ADVANCED,
3252 .label = "ldap deref",
3254 .p_class = P_GLOBAL,
3255 .offset = GLOBAL_VAR(ldap_deref),
3257 .enum_list = enum_ldap_deref,
3258 .flags = FLAG_ADVANCED,
3261 .label = "ldap follow referral",
3263 .p_class = P_GLOBAL,
3264 .offset = GLOBAL_VAR(ldap_follow_referral),
3266 .enum_list = enum_bool_auto,
3267 .flags = FLAG_ADVANCED,
3270 .label = "ldap timeout",
3272 .p_class = P_GLOBAL,
3273 .offset = GLOBAL_VAR(ldap_timeout),
3276 .flags = FLAG_ADVANCED,
3279 .label = "ldap connection timeout",
3281 .p_class = P_GLOBAL,
3282 .offset = GLOBAL_VAR(ldap_connection_timeout),
3285 .flags = FLAG_ADVANCED,
3288 .label = "ldap page size",
3290 .p_class = P_GLOBAL,
3291 .offset = GLOBAL_VAR(ldap_page_size),
3294 .flags = FLAG_ADVANCED,
3297 .label = "ldap user suffix",
3299 .p_class = P_GLOBAL,
3300 .offset = GLOBAL_VAR(szLdapUserSuffix),
3303 .flags = FLAG_ADVANCED,
3306 .label = "ldap debug level",
3308 .p_class = P_GLOBAL,
3309 .offset = GLOBAL_VAR(ldap_debug_level),
3310 .special = handle_ldap_debug_level,
3312 .flags = FLAG_ADVANCED,
3315 .label = "ldap debug threshold",
3317 .p_class = P_GLOBAL,
3318 .offset = GLOBAL_VAR(ldap_debug_threshold),
3321 .flags = FLAG_ADVANCED,
3324 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3327 .label = "eventlog list",
3329 .p_class = P_GLOBAL,
3330 .offset = GLOBAL_VAR(szEventLogs),
3333 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3336 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3339 .label = "add share command",
3341 .p_class = P_GLOBAL,
3342 .offset = GLOBAL_VAR(szAddShareCommand),
3345 .flags = FLAG_ADVANCED,
3348 .label = "change share command",
3350 .p_class = P_GLOBAL,
3351 .offset = GLOBAL_VAR(szChangeShareCommand),
3354 .flags = FLAG_ADVANCED,
3357 .label = "delete share command",
3359 .p_class = P_GLOBAL,
3360 .offset = GLOBAL_VAR(szDeleteShareCommand),
3363 .flags = FLAG_ADVANCED,
3366 .label = "config file",
3368 .p_class = P_GLOBAL,
3369 .offset = GLOBAL_VAR(szConfigFile),
3372 .flags = FLAG_HIDE|FLAG_META,
3377 .p_class = P_GLOBAL,
3378 .offset = GLOBAL_VAR(szAutoServices),
3381 .flags = FLAG_ADVANCED,
3384 .label = "auto services",
3386 .p_class = P_GLOBAL,
3387 .offset = GLOBAL_VAR(szAutoServices),
3390 .flags = FLAG_ADVANCED,
3393 .label = "lock directory",
3395 .p_class = P_GLOBAL,
3396 .offset = GLOBAL_VAR(szLockDir),
3399 .flags = FLAG_ADVANCED,
3402 .label = "lock dir",
3404 .p_class = P_GLOBAL,
3405 .offset = GLOBAL_VAR(szLockDir),
3411 .label = "state directory",
3413 .p_class = P_GLOBAL,
3414 .offset = GLOBAL_VAR(szStateDir),
3417 .flags = FLAG_ADVANCED,
3420 .label = "cache directory",
3422 .p_class = P_GLOBAL,
3423 .offset = GLOBAL_VAR(szCacheDir),
3426 .flags = FLAG_ADVANCED,
3429 .label = "pid directory",
3431 .p_class = P_GLOBAL,
3432 .offset = GLOBAL_VAR(szPidDir),
3435 .flags = FLAG_ADVANCED,
3438 .label = "ntp signd socket directory",
3440 .p_class = P_GLOBAL,
3441 .offset = GLOBAL_VAR(szNTPSignDSocketDirectory),
3444 .flags = FLAG_ADVANCED,
3449 .label = "utmp directory",
3451 .p_class = P_GLOBAL,
3452 .offset = GLOBAL_VAR(szUtmpDir),
3455 .flags = FLAG_ADVANCED,
3458 .label = "wtmp directory",
3460 .p_class = P_GLOBAL,
3461 .offset = GLOBAL_VAR(szWtmpDir),
3464 .flags = FLAG_ADVANCED,
3469 .p_class = P_GLOBAL,
3470 .offset = GLOBAL_VAR(bUtmp),
3473 .flags = FLAG_ADVANCED,
3477 .label = "default service",
3479 .p_class = P_GLOBAL,
3480 .offset = GLOBAL_VAR(szDefaultService),
3483 .flags = FLAG_ADVANCED,
3488 .p_class = P_GLOBAL,
3489 .offset = GLOBAL_VAR(szDefaultService),
3492 .flags = FLAG_ADVANCED,
3495 .label = "message command",
3497 .p_class = P_GLOBAL,
3498 .offset = GLOBAL_VAR(szMsgCommand),
3501 .flags = FLAG_ADVANCED,
3504 .label = "dfree cache time",
3507 .offset = LOCAL_VAR(iDfreeCacheTime),
3510 .flags = FLAG_ADVANCED,
3513 .label = "dfree command",
3516 .offset = LOCAL_VAR(szDfree),
3519 .flags = FLAG_ADVANCED,
3522 .label = "get quota command",
3524 .p_class = P_GLOBAL,
3525 .offset = GLOBAL_VAR(szGetQuota),
3528 .flags = FLAG_ADVANCED,
3531 .label = "set quota command",
3533 .p_class = P_GLOBAL,
3534 .offset = GLOBAL_VAR(szSetQuota),
3537 .flags = FLAG_ADVANCED,
3540 .label = "remote announce",
3542 .p_class = P_GLOBAL,
3543 .offset = GLOBAL_VAR(szRemoteAnnounce),
3546 .flags = FLAG_ADVANCED,
3549 .label = "remote browse sync",
3551 .p_class = P_GLOBAL,
3552 .offset = GLOBAL_VAR(szRemoteBrowseSync),
3555 .flags = FLAG_ADVANCED,
3558 .label = "socket address",
3560 .p_class = P_GLOBAL,
3561 .offset = GLOBAL_VAR(szSocketAddress),
3564 .flags = FLAG_ADVANCED,
3567 .label = "nmbd bind explicit broadcast",
3569 .p_class = P_GLOBAL,
3570 .offset = GLOBAL_VAR(bNmbdBindExplicitBroadcast),
3573 .flags = FLAG_ADVANCED,
3576 .label = "homedir map",
3578 .p_class = P_GLOBAL,
3579 .offset = GLOBAL_VAR(szNISHomeMapName),
3582 .flags = FLAG_ADVANCED,
3585 .label = "afs username map",
3587 .p_class = P_GLOBAL,
3588 .offset = GLOBAL_VAR(szAfsUsernameMap),
3591 .flags = FLAG_ADVANCED,
3594 .label = "afs token lifetime",
3596 .p_class = P_GLOBAL,
3597 .offset = GLOBAL_VAR(iAfsTokenLifetime),
3600 .flags = FLAG_ADVANCED,
3603 .label = "log nt token command",
3605 .p_class = P_GLOBAL,
3606 .offset = GLOBAL_VAR(szLogNtTokenCommand),
3609 .flags = FLAG_ADVANCED,
3612 .label = "NIS homedir",
3614 .p_class = P_GLOBAL,
3615 .offset = GLOBAL_VAR(bNISHomeMap),
3618 .flags = FLAG_ADVANCED,
3624 .offset = LOCAL_VAR(valid),
3633 .offset = LOCAL_VAR(szCopy),
3634 .special = handle_copy,
3642 .offset = LOCAL_VAR(szInclude),
3643 .special = handle_include,
3645 .flags = FLAG_HIDE|FLAG_META,
3651 .offset = LOCAL_VAR(szPreExec),
3654 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3660 .offset = LOCAL_VAR(szPreExec),
3663 .flags = FLAG_ADVANCED,
3666 .label = "preexec close",
3669 .offset = LOCAL_VAR(bPreexecClose),
3672 .flags = FLAG_ADVANCED | FLAG_SHARE,
3675 .label = "postexec",
3678 .offset = LOCAL_VAR(szPostExec),
3681 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3684 .label = "root preexec",
3687 .offset = LOCAL_VAR(szRootPreExec),
3690 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3693 .label = "root preexec close",
3696 .offset = LOCAL_VAR(bRootpreexecClose),
3699 .flags = FLAG_ADVANCED | FLAG_SHARE,
3702 .label = "root postexec",
3705 .offset = LOCAL_VAR(szRootPostExec),
3708 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3711 .label = "available",
3714 .offset = LOCAL_VAR(bAvailable),
3717 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3720 .label = "registry shares",
3722 .p_class = P_GLOBAL,
3723 .offset = GLOBAL_VAR(bRegistryShares),
3726 .flags = FLAG_ADVANCED,
3729 .label = "usershare allow guests",
3731 .p_class = P_GLOBAL,
3732 .offset = GLOBAL_VAR(bUsershareAllowGuests),
3735 .flags = FLAG_ADVANCED,
3738 .label = "usershare max shares",
3740 .p_class = P_GLOBAL,
3741 .offset = GLOBAL_VAR(iUsershareMaxShares),
3744 .flags = FLAG_ADVANCED,
3747 .label = "usershare owner only",
3749 .p_class = P_GLOBAL,
3750 .offset = GLOBAL_VAR(bUsershareOwnerOnly),
3753 .flags = FLAG_ADVANCED,
3756 .label = "usershare path",
3758 .p_class = P_GLOBAL,
3759 .offset = GLOBAL_VAR(szUsersharePath),
3762 .flags = FLAG_ADVANCED,
3765 .label = "usershare prefix allow list",
3767 .p_class = P_GLOBAL,
3768 .offset = GLOBAL_VAR(szUsersharePrefixAllowList),
3771 .flags = FLAG_ADVANCED,
3774 .label = "usershare prefix deny list",
3776 .p_class = P_GLOBAL,
3777 .offset = GLOBAL_VAR(szUsersharePrefixDenyList),
3780 .flags = FLAG_ADVANCED,
3783 .label = "usershare template share",
3785 .p_class = P_GLOBAL,
3786 .offset = GLOBAL_VAR(szUsershareTemplateShare),
3789 .flags = FLAG_ADVANCED,
3795 .offset = LOCAL_VAR(volume),
3798 .flags = FLAG_ADVANCED | FLAG_SHARE,
3804 .offset = LOCAL_VAR(fstype),
3807 .flags = FLAG_ADVANCED | FLAG_SHARE,
3810 .label = "set directory",
3813 .offset = LOCAL_VAR(bNo_set_dir),
3816 .flags = FLAG_ADVANCED | FLAG_SHARE,
3819 .label = "allow insecure wide links",
3821 .p_class = P_GLOBAL,
3822 .offset = GLOBAL_VAR(bAllowInsecureWidelinks),
3825 .flags = FLAG_ADVANCED,
3828 .label = "wide links",
3831 .offset = LOCAL_VAR(bWidelinks),
3834 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3837 .label = "follow symlinks",
3840 .offset = LOCAL_VAR(bSymlinks),
3843 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3846 .label = "dont descend",
3849 .offset = LOCAL_VAR(szDontdescend),
3852 .flags = FLAG_ADVANCED | FLAG_SHARE,
3855 .label = "magic script",
3858 .offset = LOCAL_VAR(szMagicScript),
3861 .flags = FLAG_ADVANCED | FLAG_SHARE,
3864 .label = "magic output",
3867 .offset = LOCAL_VAR(szMagicOutput),
3870 .flags = FLAG_ADVANCED | FLAG_SHARE,
3873 .label = "delete readonly",
3876 .offset = LOCAL_VAR(bDeleteReadonly),
3879 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3882 .label = "dos filemode",
3885 .offset = LOCAL_VAR(bDosFilemode),
3888 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3891 .label = "dos filetimes",
3894 .offset = LOCAL_VAR(bDosFiletimes),
3897 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3900 .label = "dos filetime resolution",
3903 .offset = LOCAL_VAR(bDosFiletimeResolution),
3906 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3909 .label = "fake directory create times",
3912 .offset = LOCAL_VAR(bFakeDirCreateTimes),
3915 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3918 .label = "async smb echo handler",
3920 .p_class = P_GLOBAL,
3921 .offset = GLOBAL_VAR(bAsyncSMBEchoHandler),
3924 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3927 .label = "panic action",
3929 .p_class = P_GLOBAL,
3930 .offset = GLOBAL_VAR(szPanicAction),
3933 .flags = FLAG_ADVANCED,
3936 .label = "perfcount module",
3938 .p_class = P_GLOBAL,
3939 .offset = GLOBAL_VAR(szSMBPerfcountModule),
3942 .flags = FLAG_ADVANCED,
3945 {N_("VFS module options"), P_SEP, P_SEPARATOR},
3948 .label = "vfs objects",
3951 .offset = LOCAL_VAR(szVfsObjects),
3954 .flags = FLAG_ADVANCED | FLAG_SHARE,
3957 .label = "vfs object",
3960 .offset = LOCAL_VAR(szVfsObjects),
3967 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
3970 .label = "msdfs root",
3973 .offset = LOCAL_VAR(bMSDfsRoot),
3976 .flags = FLAG_ADVANCED | FLAG_SHARE,
3979 .label = "msdfs proxy",
3982 .offset = LOCAL_VAR(szMSDfsProxy),
3985 .flags = FLAG_ADVANCED | FLAG_SHARE,
3988 .label = "host msdfs",
3990 .p_class = P_GLOBAL,
3991 .offset = GLOBAL_VAR(bHostMSDfs),
3994 .flags = FLAG_ADVANCED,
3997 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4000 .label = "passdb expand explicit",
4002 .p_class = P_GLOBAL,
4003 .offset = GLOBAL_VAR(bPassdbExpandExplicit),
4006 .flags = FLAG_ADVANCED,
4009 .label = "idmap backend",
4011 .p_class = P_GLOBAL,
4012 .offset = GLOBAL_VAR(szIdmapBackend),
4013 .special = handle_idmap_backend,
4015 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4018 .label = "idmap cache time",
4020 .p_class = P_GLOBAL,
4021 .offset = GLOBAL_VAR(iIdmapCacheTime),
4024 .flags = FLAG_ADVANCED,
4027 .label = "idmap negative cache time",
4029 .p_class = P_GLOBAL,
4030 .offset = GLOBAL_VAR(iIdmapNegativeCacheTime),
4033 .flags = FLAG_ADVANCED,
4036 .label = "idmap uid",
4038 .p_class = P_GLOBAL,
4039 .offset = GLOBAL_VAR(szIdmapUID),
4040 .special = handle_idmap_uid,
4042 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4045 .label = "winbind uid",
4047 .p_class = P_GLOBAL,
4048 .offset = GLOBAL_VAR(szIdmapUID),
4049 .special = handle_idmap_uid,
4054 .label = "idmap gid",
4056 .p_class = P_GLOBAL,
4057 .offset = GLOBAL_VAR(szIdmapGID),
4058 .special = handle_idmap_gid,
4060 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4063 .label = "winbind gid",
4065 .p_class = P_GLOBAL,
4066 .offset = GLOBAL_VAR(szIdmapGID),
4067 .special = handle_idmap_gid,
4072 .label = "template homedir",
4074 .p_class = P_GLOBAL,
4075 .offset = GLOBAL_VAR(szTemplateHomedir),
4078 .flags = FLAG_ADVANCED,
4081 .label = "template shell",
4083 .p_class = P_GLOBAL,
4084 .offset = GLOBAL_VAR(szTemplateShell),
4087 .flags = FLAG_ADVANCED,
4090 .label = "winbind separator",
4092 .p_class = P_GLOBAL,
4093 .offset = GLOBAL_VAR(szWinbindSeparator),
4096 .flags = FLAG_ADVANCED,
4099 .label = "winbind cache time",
4101 .p_class = P_GLOBAL,
4102 .offset = GLOBAL_VAR(winbind_cache_time),
4105 .flags = FLAG_ADVANCED,
4108 .label = "winbind reconnect delay",
4110 .p_class = P_GLOBAL,
4111 .offset = GLOBAL_VAR(winbind_reconnect_delay),
4114 .flags = FLAG_ADVANCED,
4117 .label = "winbind max clients",
4119 .p_class = P_GLOBAL,
4120 .offset = GLOBAL_VAR(winbind_max_clients),
4123 .flags = FLAG_ADVANCED,
4126 .label = "winbind enum users",
4128 .p_class = P_GLOBAL,
4129 .offset = GLOBAL_VAR(bWinbindEnumUsers),
4132 .flags = FLAG_ADVANCED,
4135 .label = "winbind enum groups",
4137 .p_class = P_GLOBAL,
4138 .offset = GLOBAL_VAR(bWinbindEnumGroups),
4141 .flags = FLAG_ADVANCED,
4144 .label = "winbind use default domain",
4146 .p_class = P_GLOBAL,
4147 .offset = GLOBAL_VAR(bWinbindUseDefaultDomain),
4150 .flags = FLAG_ADVANCED,
4153 .label = "winbind trusted domains only",
4155 .p_class = P_GLOBAL,
4156 .offset = GLOBAL_VAR(bWinbindTrustedDomainsOnly),
4159 .flags = FLAG_ADVANCED,
4162 .label = "winbind nested groups",
4164 .p_class = P_GLOBAL,
4165 .offset = GLOBAL_VAR(bWinbindNestedGroups),
4168 .flags = FLAG_ADVANCED,
4171 .label = "winbind expand groups",
4173 .p_class = P_GLOBAL,
4174 .offset = GLOBAL_VAR(winbind_expand_groups),
4177 .flags = FLAG_ADVANCED,
4180 .label = "winbind nss info",
4182 .p_class = P_GLOBAL,
4183 .offset = GLOBAL_VAR(szWinbindNssInfo),
4186 .flags = FLAG_ADVANCED,
4189 .label = "winbind refresh tickets",
4191 .p_class = P_GLOBAL,
4192 .offset = GLOBAL_VAR(bWinbindRefreshTickets),
4195 .flags = FLAG_ADVANCED,
4198 .label = "winbind offline logon",
4200 .p_class = P_GLOBAL,
4201 .offset = GLOBAL_VAR(bWinbindOfflineLogon),
4204 .flags = FLAG_ADVANCED,
4207 .label = "winbind normalize names",
4209 .p_class = P_GLOBAL,
4210 .offset = GLOBAL_VAR(bWinbindNormalizeNames),
4213 .flags = FLAG_ADVANCED,
4216 .label = "winbind rpc only",
4218 .p_class = P_GLOBAL,
4219 .offset = GLOBAL_VAR(bWinbindRpcOnly),
4222 .flags = FLAG_ADVANCED,
4225 .label = "create krb5 conf",
4227 .p_class = P_GLOBAL,
4228 .offset = GLOBAL_VAR(bCreateKrb5Conf),
4231 .flags = FLAG_ADVANCED,
4234 .label = "ncalrpc dir",
4236 .p_class = P_GLOBAL,
4237 .offset = GLOBAL_VAR(ncalrpc_dir),
4240 .flags = FLAG_ADVANCED,
4243 .label = "winbind max domain connections",
4245 .p_class = P_GLOBAL,
4246 .offset = GLOBAL_VAR(winbindMaxDomainConnections),
4249 .flags = FLAG_ADVANCED,
4252 .label = "winbindd socket directory",
4254 .p_class = P_GLOBAL,
4255 .offset = GLOBAL_VAR(szWinbinddSocketDirectory),
4258 .flags = FLAG_ADVANCED,
4261 .label = "winbindd privileged socket directory",
4263 .p_class = P_GLOBAL,
4264 .offset = GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory),
4267 .flags = FLAG_ADVANCED,
4270 .label = "winbind sealed pipes",
4272 .p_class = P_GLOBAL,
4273 .offset = GLOBAL_VAR(bWinbindSealedPipes),
4276 .flags = FLAG_ADVANCED,
4279 {N_("DNS options"), P_SEP, P_SEPARATOR},
4281 .label = "allow dns updates",
4283 .p_class = P_GLOBAL,
4284 .offset = GLOBAL_VAR(allow_dns_updates),
4286 .enum_list = enum_dns_update_settings,
4287 .flags = FLAG_ADVANCED,
4290 .label = "dns forwarder",
4292 .p_class = P_GLOBAL,
4293 .offset = GLOBAL_VAR(dns_forwarder),
4296 .flags = FLAG_ADVANCED,
4299 .label = "dns recursive queries",
4301 .p_class = P_GLOBAL,
4302 .offset = GLOBAL_VAR(dns_recursive_queries),
4307 .label = "dns update command",
4309 .p_class = P_GLOBAL,
4310 .offset = GLOBAL_VAR(szDNSUpdateCommand),
4313 .flags = FLAG_ADVANCED,
4316 .label = "nsupdate command",
4318 .p_class = P_GLOBAL,
4319 .offset = GLOBAL_VAR(szNSUpdateCommand),
4322 .flags = FLAG_ADVANCED,
4325 .label = "rndc command",
4327 .p_class = P_GLOBAL,
4328 .offset = GLOBAL_VAR(szRNDCCommand),
4331 .flags = FLAG_ADVANCED,
4334 .label = "multicast dns register",
4336 .p_class = P_GLOBAL,
4337 .offset = GLOBAL_VAR(bMulticastDnsRegister),
4340 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4343 {N_("AD DC options"), P_SEP, P_SEPARATOR},
4346 .label = "samba kcc command",
4348 .p_class = P_GLOBAL,
4349 .offset = GLOBAL_VAR(szSambaKCCCommand),
4352 .flags = FLAG_ADVANCED,
4355 .label = "server services",
4357 .p_class = P_GLOBAL,
4358 .offset = GLOBAL_VAR(server_services),
4363 .label = "dcerpc endpoint servers",
4365 .p_class = P_GLOBAL,
4366 .offset = GLOBAL_VAR(dcerpc_ep_servers),
4371 .label = "spn update command",
4373 .p_class = P_GLOBAL,
4374 .offset = GLOBAL_VAR(szSPNUpdateCommand),
4377 .flags = FLAG_ADVANCED,
4380 .label = "share backend",
4382 .p_class = P_GLOBAL,
4383 .offset = GLOBAL_VAR(szShareBackend),
4388 .label = "ntvfs handler",
4391 .offset = LOCAL_VAR(ntvfs_handler),
4396 {N_("TLS options"), P_SEP, P_SEPARATOR},
4399 .label = "tls enabled",
4401 .p_class = P_GLOBAL,
4402 .offset = GLOBAL_VAR(tls_enabled),
4407 .label = "tls keyfile",
4409 .p_class = P_GLOBAL,
4410 .offset = GLOBAL_VAR(tls_keyfile),
4415 .label = "tls certfile",
4417 .p_class = P_GLOBAL,
4418 .offset = GLOBAL_VAR(tls_certfile),
4423 .label = "tls cafile",
4425 .p_class = P_GLOBAL,
4426 .offset = GLOBAL_VAR(tls_cafile),
4431 .label = "tls crlfile",
4433 .p_class = P_GLOBAL,
4434 .offset = GLOBAL_VAR(tls_crlfile),
4439 .label = "tls dh params file",
4441 .p_class = P_GLOBAL,
4442 .offset = GLOBAL_VAR(tls_dhpfile),
4447 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
4450 /***************************************************************************
4451 Initialise the sDefault parameter structure for the printer values.
4452 ***************************************************************************/
4454 static void init_printer_values(struct loadparm_service *pService)
4456 /* choose defaults depending on the type of printing */
4457 switch (pService->iPrinting) {
4462 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4463 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4464 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4469 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4470 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4471 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4472 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4473 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4474 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4475 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4481 /* set the lpq command to contain the destination printer
4482 name only. This is used by cups_queue_get() */
4483 string_set(&pService->szLpqcommand, "%p");
4484 string_set(&pService->szLprmcommand, "");
4485 string_set(&pService->szPrintcommand, "");
4486 string_set(&pService->szLppausecommand, "");
4487 string_set(&pService->szLpresumecommand, "");
4488 string_set(&pService->szQueuepausecommand, "");
4489 string_set(&pService->szQueueresumecommand, "");
4491 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4492 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4493 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4494 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4495 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4496 string_set(&pService->szQueuepausecommand, "disable '%p'");
4497 string_set(&pService->szQueueresumecommand, "enable '%p'");
4498 #endif /* HAVE_CUPS */
4503 string_set(&pService->szLpqcommand, "lpstat -o%p");
4504 string_set(&pService->szLprmcommand, "cancel %p-%j");
4505 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4506 string_set(&pService->szQueuepausecommand, "disable %p");
4507 string_set(&pService->szQueueresumecommand, "enable %p");
4509 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4510 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4515 string_set(&pService->szLpqcommand, "lpq -P%p");
4516 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4517 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4520 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
4524 const char *tdbfile;
4525 TALLOC_CTX *tmp_ctx = talloc_stackframe();
4528 tdbfile = talloc_asprintf(
4529 tmp_ctx, "tdbfile=%s",
4530 lp_parm_const_string(-1, "vlp", "tdbfile",
4532 if (tdbfile == NULL) {
4533 tdbfile="tdbfile=/tmp/vlp.tdb";
4536 tmp = talloc_asprintf(tmp_ctx, "vlp %s print %%p %%s",
4538 string_set(&pService->szPrintcommand,
4539 tmp ? tmp : "vlp print %p %s");
4541 tmp = talloc_asprintf(tmp_ctx, "vlp %s lpq %%p",
4543 string_set(&pService->szLpqcommand,
4544 tmp ? tmp : "vlp lpq %p");
4546 tmp = talloc_asprintf(tmp_ctx, "vlp %s lprm %%p %%j",
4548 string_set(&pService->szLprmcommand,
4549 tmp ? tmp : "vlp lprm %p %j");
4551 tmp = talloc_asprintf(tmp_ctx, "vlp %s lppause %%p %%j",
4553 string_set(&pService->szLppausecommand,
4554 tmp ? tmp : "vlp lppause %p %j");
4556 tmp = talloc_asprintf(tmp_ctx, "vlp %s lpresume %%p %%j",
4558 string_set(&pService->szLpresumecommand,
4559 tmp ? tmp : "vlp lpresume %p %j");
4561 tmp = talloc_asprintf(tmp_ctx, "vlp %s queuepause %%p",
4563 string_set(&pService->szQueuepausecommand,
4564 tmp ? tmp : "vlp queuepause %p");
4566 tmp = talloc_asprintf(tmp_ctx, "vlp %s queueresume %%p",
4568 string_set(&pService->szQueueresumecommand,
4569 tmp ? tmp : "vlp queueresume %p");
4570 TALLOC_FREE(tmp_ctx);
4574 #endif /* DEVELOPER */
4579 * Function to return the default value for the maximum number of open
4580 * file descriptors permitted. This function tries to consult the
4581 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4582 * the smaller of those.
4584 static int max_open_files(void)
4586 int sysctl_max = MAX_OPEN_FILES;
4587 int rlimit_max = MAX_OPEN_FILES;
4589 #ifdef HAVE_SYSCTLBYNAME
4591 size_t size = sizeof(sysctl_max);
4592 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4597 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4603 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4604 rlimit_max = rl.rlim_cur;
4606 #if defined(RLIM_INFINITY)
4607 if(rl.rlim_cur == RLIM_INFINITY)
4608 rlimit_max = MAX_OPEN_FILES;
4613 if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4614 DEBUG(2,("max_open_files: increasing sysctl_max (%d) to "
4615 "minimum Windows limit (%d)\n",
4617 MIN_OPEN_FILES_WINDOWS));
4618 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4621 if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4622 DEBUG(2,("rlimit_max: increasing rlimit_max (%d) to "
4623 "minimum Windows limit (%d)\n",
4625 MIN_OPEN_FILES_WINDOWS));
4626 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4629 return MIN(sysctl_max, rlimit_max);
4633 * Common part of freeing allocated data for one parameter.
4635 static void free_one_parameter_common(void *parm_ptr,
4636 struct parm_struct parm)
4638 if ((parm.type == P_STRING) ||
4639 (parm.type == P_USTRING))
4641 string_free((char**)parm_ptr);
4642 } else if (parm.type == P_LIST) {
4643 TALLOC_FREE(*((char***)parm_ptr));
4648 * Free the allocated data for one parameter for a share
4649 * given as a service struct.
4651 static void free_one_parameter(struct loadparm_service *service,
4652 struct parm_struct parm)
4656 if (parm.p_class != P_LOCAL) {
4660 parm_ptr = lp_parm_ptr(service, &parm);
4662 free_one_parameter_common(parm_ptr, parm);
4666 * Free the allocated parameter data of a share given
4667 * as a service struct.
4669 static void free_parameters(struct loadparm_service *service)
4673 for (i=0; parm_table[i].label; i++) {
4674 free_one_parameter(service, parm_table[i]);
4679 * Free the allocated data for one parameter for a given share
4680 * specified by an snum.
4682 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4687 parm_ptr = lp_parm_ptr(NULL, &parm);
4688 } else if (parm.p_class != P_LOCAL) {
4691 parm_ptr = lp_local_ptr_by_snum(snum, &parm);
4694 free_one_parameter_common(parm_ptr, parm);
4698 * Free the allocated parameter data for a share specified
4701 static void free_parameters_by_snum(int snum)
4705 for (i=0; parm_table[i].label; i++) {
4706 free_one_parameter_by_snum(snum, parm_table[i]);
4711 * Free the allocated global parameters.
4713 static void free_global_parameters(void)
4715 free_param_opts(&Globals.param_opt);
4716 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4719 static int map_parameter(const char *pszParmName);
4721 struct lp_stored_option {
4722 struct lp_stored_option *prev, *next;
4727 static struct lp_stored_option *stored_options;
4730 save options set by lp_set_cmdline() into a list. This list is
4731 re-applied when we do a globals reset, so that cmdline set options
4732 are sticky across reloads of smb.conf
4734 static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
4736 struct lp_stored_option *entry, *entry_next;
4737 for (entry = stored_options; entry != NULL; entry = entry_next) {
4738 entry_next = entry->next;
4739 if (strcmp(pszParmName, entry->label) == 0) {
4740 DLIST_REMOVE(stored_options, entry);
4746 entry = talloc(NULL, struct lp_stored_option);
4751 entry->label = talloc_strdup(entry, pszParmName);
4752 if (!entry->label) {
4757 entry->value = talloc_strdup(entry, pszParmValue);
4758 if (!entry->value) {
4763 DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
4768 static bool apply_lp_set_cmdline(void)
4770 struct lp_stored_option *entry = NULL;
4771 for (entry = stored_options; entry != NULL; entry = entry->next) {
4772 if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
4773 DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
4774 entry->label, entry->value));
4781 /***************************************************************************
4782 Initialise the global parameter structure.
4783 ***************************************************************************/
4785 static void init_globals(bool reinit_globals)
4787 static bool done_init = false;
4791 /* If requested to initialize only once and we've already done it... */
4792 if (!reinit_globals && done_init) {
4793 /* ... then we have nothing more to do */
4798 /* The logfile can be set before this is invoked. Free it if so. */
4799 if (Globals.logfile != NULL) {
4800 string_free(&Globals.logfile);
4801 Globals.logfile = NULL;
4805 free_global_parameters();
4808 /* This memset and the free_global_parameters() above will
4809 * wipe out smb.conf options set with lp_set_cmdline(). The
4810 * apply_lp_set_cmdline() call puts these values back in the
4811 * table once the defaults are set */
4812 ZERO_STRUCT(Globals);
4814 for (i = 0; parm_table[i].label; i++) {
4815 if ((parm_table[i].type == P_STRING ||
4816 parm_table[i].type == P_USTRING))
4818 string_set((char **)lp_parm_ptr(NULL, &parm_table[i]), "");
4823 string_set(&sDefault.fstype, FSTYPE_STRING);
4824 string_set(&sDefault.szPrintjobUsername, "%U");
4826 init_printer_values(&sDefault);
4829 DEBUG(3, ("Initialising global parameters\n"));
4831 /* Must manually force to upper case here, as this does not go via the handler */
4832 string_set(&Globals.szNetbiosName, myhostname_upper());
4834 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4835 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4837 /* use the new 'hash2' method by default, with a prefix of 1 */
4838 string_set(&Globals.szManglingMethod, "hash2");
4839 Globals.mangle_prefix = 1;
4841 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4843 /* using UTF8 by default allows us to support all chars */
4844 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4846 /* Use codepage 850 as a default for the dos character set */
4847 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4850 * Allow the default PASSWD_CHAT to be overridden in local.h.
4852 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4854 string_set(&Globals.szWorkgroup, DEFAULT_WORKGROUP);
4856 string_set(&Globals.szPasswdProgram, "");
4857 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4858 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4859 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4860 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4861 string_set(&Globals.szSocketAddress, "0.0.0.0");
4863 * By default support explicit binding to broadcast
4866 Globals.bNmbdBindExplicitBroadcast = true;
4868 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4869 smb_panic("init_globals: ENOMEM");
4871 string_set(&Globals.szServerString, s);
4874 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4877 string_set(&Globals.socket_options, DEFAULT_SOCKET_OPTIONS);
4879 string_set(&Globals.szLogonDrive, "");
4880 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4881 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4882 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4884 Globals.szNameResolveOrder = (const char **)str_list_make_v3(NULL, "lmhosts wins host bcast", NULL);
4885 string_set(&Globals.szPasswordServer, "*");
4887 Globals.AlgorithmicRidBase = BASE_RID;
4889 Globals.bLoadPrinters = true;
4890 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4892 Globals.ConfigBackend = config_backend;
4893 Globals.server_role = ROLE_AUTO;
4895 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4896 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4897 Globals.max_xmit = 0x4104;
4898 Globals.max_mux = 50; /* This is *needed* for profile support. */
4899 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4900 Globals.bDisableSpoolss = false;
4901 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4902 Globals.pwordlevel = 0;
4903 Globals.unamelevel = 0;
4904 Globals.deadtime = 0;
4905 Globals.getwd_cache = true;
4906 Globals.bLargeReadwrite = true;
4907 Globals.max_log_size = 5000;
4908 Globals.max_open_files = max_open_files();
4909 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4910 Globals.srv_maxprotocol = PROTOCOL_SMB2_10;
4911 Globals.srv_minprotocol = PROTOCOL_LANMAN1;
4912 Globals.security = SEC_USER;
4913 Globals.paranoid_server_security = true;
4914 Globals.bEncryptPasswords = true;
4915 Globals.clientSchannel = Auto;
4916 Globals.serverSchannel = Auto;
4917 Globals.bReadRaw = true;
4918 Globals.bWriteRaw = true;
4919 Globals.bNullPasswords = false;
4920 Globals.bObeyPamRestrictions = false;
4922 Globals.bSyslogOnly = false;
4923 Globals.bTimestampLogs = true;
4924 string_set(&Globals.loglevel, "0");
4925 Globals.bDebugPrefixTimestamp = false;
4926 Globals.bDebugHiresTimestamp = true;
4927 Globals.bDebugPid = false;
4928 Globals.bDebugUid = false;
4929 Globals.bDebugClass = false;
4930 Globals.bEnableCoreFiles = true;
4931 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4932 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4933 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4934 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4935 Globals.lm_announce = Auto; /* = Auto: send only if LM clients found */
4936 Globals.lm_interval = 60;
4937 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4938 Globals.bNISHomeMap = false;
4939 #ifdef WITH_NISPLUS_HOME
4940 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4942 string_set(&Globals.szNISHomeMapName, "auto.home");
4945 Globals.bTimeServer = false;
4946 Globals.bBindInterfacesOnly = false;
4947 Globals.bUnixPasswdSync = false;
4948 Globals.bPamPasswordChange = false;
4949 Globals.bPasswdChatDebug = false;
4950 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4951 Globals.bNTPipeSupport = true; /* Do NT pipes by default. */
4952 Globals.bNTStatusSupport = true; /* Use NT status by default. */
4953 Globals.bStatCache = true; /* use stat cache by default */
4954 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4955 Globals.restrict_anonymous = 0;
4956 Globals.bClientLanManAuth = false; /* Do NOT use the LanMan hash if it is available */
4957 Globals.bClientPlaintextAuth = false; /* Do NOT use a plaintext password even if is requested by the server */
4958 Globals.bLanmanAuth = false; /* Do NOT use the LanMan hash, even if it is supplied */
4959 Globals.bNTLMAuth = true; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4960 Globals.bClientNTLMv2Auth = true; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
4961 /* Note, that we will also use NTLM2 session security (which is different), if it is available */
4963 Globals.map_to_guest = 0; /* By Default, "Never" */
4964 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4965 Globals.enhanced_browsing = true;
4966 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4967 #ifdef MMAP_BLACKLIST
4968 Globals.bUseMmap = false;
4970 Globals.bUseMmap = true;
4972 Globals.bUnicode = true;
4973 Globals.bUnixExtensions = true;
4974 Globals.bResetOnZeroVC = false;
4975 Globals.bLogWriteableFilesOnExit = false;
4976 Globals.bCreateKrb5Conf = true;
4977 Globals.winbindMaxDomainConnections = 1;
4979 /* hostname lookups can be very expensive and are broken on
4980 a large number of sites (tridge) */
4981 Globals.bHostnameLookups = false;
4983 string_set(&Globals.passdb_backend, "tdbsam");
4984 string_set(&Globals.szLdapSuffix, "");
4985 string_set(&Globals.szLdapMachineSuffix, "");
4986 string_set(&Globals.szLdapUserSuffix, "");
4987 string_set(&Globals.szLdapGroupSuffix, "");
4988 string_set(&Globals.szLdapIdmapSuffix, "");
4990 string_set(&Globals.szLdapAdminDn, "");
4991 Globals.ldap_ssl = LDAP_SSL_START_TLS;
4992 Globals.ldap_ssl_ads = false;
4993 Globals.ldap_deref = -1;
4994 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
4995 Globals.ldap_delete_dn = false;
4996 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
4997 Globals.ldap_follow_referral = Auto;
4998 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
4999 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
5000 Globals.ldap_page_size = LDAP_PAGE_SIZE;
5002 Globals.ldap_debug_level = 0;
5003 Globals.ldap_debug_threshold = 10;
5005 /* This is what we tell the afs client. in reality we set the token
5006 * to never expire, though, when this runs out the afs client will
5007 * forget the token. Set to 0 to get NEVERDATE.*/
5008 Globals.iAfsTokenLifetime = 604800;
5009 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
5011 /* these parameters are set to defaults that are more appropriate
5012 for the increasing samba install base:
5014 as a member of the workgroup, that will possibly become a
5015 _local_ master browser (lm = true). this is opposed to a forced
5016 local master browser startup (pm = true).
5018 doesn't provide WINS server service by default (wsupp = false),
5019 and doesn't provide domain master browser services by default, either.
5023 Globals.bMsAddPrinterWizard = true;
5024 Globals.os_level = 20;
5025 Globals.bLocalMaster = true;
5026 Globals.domain_master = Auto; /* depending on bDomainLogons */
5027 Globals.bDomainLogons = false;
5028 Globals.bBrowseList = true;
5029 Globals.bWINSsupport = false;
5030 Globals.bWINSproxy = false;
5032 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
5033 Globals.InitLogonDelay = 100; /* 100 ms default delay */
5035 Globals.bWINSdnsProxy = true;
5037 Globals.bAllowTrustedDomains = true;
5038 string_set(&Globals.szIdmapBackend, "tdb");
5040 string_set(&Globals.szTemplateShell, "/bin/false");
5041 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
5042 string_set(&Globals.szWinbindSeparator, "\\");
5044 string_set(&Globals.szCupsServer, "");
5045 string_set(&Globals.szIPrintServer, "");
5047 #ifdef CLUSTER_SUPPORT
5048 string_set(&Globals.ctdbdSocket, CTDB_PATH);
5050 string_set(&Globals.ctdbdSocket, "");
5053 Globals.szClusterAddresses = NULL;
5054 Globals.clustering = false;
5055 Globals.ctdb_timeout = 0;
5056 Globals.ctdb_locktime_warn_threshold = 0;
5058 Globals.winbind_cache_time = 300; /* 5 minutes */
5059 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
5060 Globals.winbind_max_clients = 200;
5061 Globals.bWinbindEnumUsers = false;
5062 Globals.bWinbindEnumGroups = false;
5063 Globals.bWinbindUseDefaultDomain = false;
5064 Globals.bWinbindTrustedDomainsOnly = false;
5065 Globals.bWinbindNestedGroups = true;
5066 Globals.winbind_expand_groups = 1;
5067 Globals.szWinbindNssInfo = (const char **)str_list_make_v3(NULL, "template", NULL);
5068 Globals.bWinbindRefreshTickets = false;
5069 Globals.bWinbindOfflineLogon = false;
5071 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
5072 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
5074 Globals.bPassdbExpandExplicit = false;
5076 Globals.name_cache_timeout = 660; /* In seconds */
5078 Globals.bUseSpnego = true;
5079 Globals.bClientUseSpnego = true;
5081 Globals.client_signing = SMB_SIGNING_DEFAULT;
5082 Globals.server_signing = SMB_SIGNING_DEFAULT;
5084 Globals.bDeferSharingViolations = true;
5085 Globals.smb_ports = (const char **)str_list_make_v3(NULL, SMB_PORTS, NULL);
5087 Globals.bEnablePrivileges = true;
5088 Globals.bHostMSDfs = true;
5089 Globals.bASUSupport = false;
5091 /* User defined shares. */
5092 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5093 smb_panic("init_globals: ENOMEM");
5095 string_set(&Globals.szUsersharePath, s);
5097 string_set(&Globals.szUsershareTemplateShare, "");
5098 Globals.iUsershareMaxShares = 0;
5099 /* By default disallow sharing of directories not owned by the sharer. */
5100 Globals.bUsershareOwnerOnly = true;
5101 /* By default disallow guest access to usershares. */
5102 Globals.bUsershareAllowGuests = false;
5104 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5106 /* By default no shares out of the registry */
5107 Globals.bRegistryShares = false;
5109 Globals.iminreceivefile = 0;
5111 Globals.bMapUntrustedToDomain = false;
5112 Globals.bMulticastDnsRegister = true;
5114 Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ;
5115 Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE;
5116 Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT;
5117 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5119 string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
5121 /* Now put back the settings that were set with lp_set_cmdline() */
5122 apply_lp_set_cmdline();
5125 /*******************************************************************
5126 Convenience routine to grab string parameters into talloced memory
5127 and run standard_sub_basic on them. The buffers can be written to by
5128 callers without affecting the source string.
5129 ********************************************************************/
5131 static char *lp_string(TALLOC_CTX *ctx, const char *s)
5135 /* The follow debug is useful for tracking down memory problems
5136 especially if you have an inner loop that is calling a lp_*()
5137 function that returns a string. Perhaps this debug should be
5138 present all the time? */
5141 DEBUG(10, ("lp_string(%s)\n", s));
5147 ret = talloc_sub_basic(ctx,
5148 get_current_username(),
5149 current_user_info.domain,
5151 if (trim_char(ret, '\"', '\"')) {
5152 if (strchr(ret,'\"') != NULL) {
5154 ret = talloc_sub_basic(ctx,
5155 get_current_username(),
5156 current_user_info.domain,
5164 In this section all the functions that are used to access the
5165 parameters from the rest of the program are defined
5168 #define FN_GLOBAL_STRING(fn_name,ptr) \
5169 char *lp_ ## fn_name(TALLOC_CTX *ctx) {return(lp_string((ctx), *(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : ""));}
5170 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5171 const char *lp_ ## fn_name(void) {return(*(const char **)(&Globals.ptr) ? *(const char **)(&Globals.ptr) : "");}
5172 #define FN_GLOBAL_LIST(fn_name,ptr) \
5173 const char **lp_ ## fn_name(void) {return(*(const char ***)(&Globals.ptr));}
5174 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5175 bool lp_ ## fn_name(void) {return(*(bool *)(&Globals.ptr));}
5176 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5177 char lp_ ## fn_name(void) {return(*(char *)(&Globals.ptr));}
5178 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5179 int lp_ ## fn_name(void) {return(*(int *)(&Globals.ptr));}
5181 #define FN_LOCAL_STRING(fn_name,val) \
5182 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));}
5183 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5184 const char *lp_ ## fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5185 #define FN_LOCAL_LIST(fn_name,val) \
5186 const char **lp_ ## fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5187 #define FN_LOCAL_BOOL(fn_name,val) \
5188 bool lp_ ## fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5189 #define FN_LOCAL_INTEGER(fn_name,val) \
5190 int lp_ ## fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5192 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5193 bool lp_ ## fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5194 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5195 int lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5196 #define FN_LOCAL_CHAR(fn_name,val) \
5197 char lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5200 static FN_GLOBAL_BOOL(domain_logons, bDomainLogons)
5201 static FN_GLOBAL_BOOL(_readraw, bReadRaw)
5202 static FN_GLOBAL_BOOL(_writeraw, bWriteRaw)
5204 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5205 * build process or in smb.conf, we use that value. Otherwise they
5206 * default to the value of lp_lockdir(). */
5207 const char *lp_statedir(void) {
5208 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5209 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5210 return(*(char **)(&Globals.szStateDir) ?
5211 *(char **)(&Globals.szStateDir) : "");
5213 return(*(char **)(&Globals.szLockDir) ?
5214 *(char **)(&Globals.szLockDir) : "");
5216 const char *lp_cachedir(void) {
5217 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5218 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5219 return(*(char **)(&Globals.szCacheDir) ?
5220 *(char **)(&Globals.szCacheDir) : "");
5222 return(*(char **)(&Globals.szLockDir) ?
5223 *(char **)(&Globals.szLockDir) : "");
5225 static FN_GLOBAL_INTEGER(winbind_max_domain_connections_int,
5226 winbindMaxDomainConnections)
5228 int lp_winbind_max_domain_connections(void)
5230 if (lp_winbind_offline_logon() &&
5231 lp_winbind_max_domain_connections_int() > 1) {
5232 DEBUG(1, ("offline logons active, restricting max domain "
5233 "connections to 1\n"));
5236 return MAX(1, lp_winbind_max_domain_connections_int());
5239 int lp_smb2_max_credits(void)
5241 if (Globals.ismb2_max_credits == 0) {
5242 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5244 return Globals.ismb2_max_credits;
5246 int lp_cups_encrypt(void)
5249 #ifdef HAVE_HTTPCONNECTENCRYPT
5250 switch (Globals.CupsEncrypt) {
5252 result = HTTP_ENCRYPT_REQUIRED;
5255 result = HTTP_ENCRYPT_ALWAYS;
5258 result = HTTP_ENCRYPT_NEVER;
5265 /* These functions remain in source3/param for now */
5267 FN_GLOBAL_INTEGER(security, security)
5268 FN_GLOBAL_STRING(configfile, szConfigFile)
5270 #include "lib/param/param_functions.c"
5272 FN_LOCAL_STRING(servicename, szService)
5273 FN_LOCAL_CONST_STRING(const_servicename, szService)
5275 /* local prototypes */
5277 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5278 static const char *get_boolean(bool bool_value);
5279 static int getservicebyname(const char *pszServiceName,
5280 struct loadparm_service *pserviceDest);
5281 static void copy_service(struct loadparm_service *pserviceDest,
5282 struct loadparm_service *pserviceSource,
5283 struct bitmap *pcopymapDest);
5284 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5286 static bool do_section(const char *pszSectionName, void *userdata);
5287 static void init_copymap(struct loadparm_service *pservice);
5288 static bool hash_a_service(const char *name, int number);
5289 static void free_service_byindex(int iService);
5290 static void show_parameter(int parmIndex);
5291 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5294 * This is a helper function for parametrical options support. It returns a
5295 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5296 * parametrical functions are quite simple
5298 static struct parmlist_entry *get_parametrics_by_service(struct loadparm_service *service, const char *type,
5301 bool global_section = false;
5303 struct parmlist_entry *data;
5305 if (service == NULL) {
5306 data = Globals.param_opt;
5307 global_section = true;
5309 data = service->param_opt;
5312 if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
5313 DEBUG(0,("asprintf failed!\n"));
5318 if (strwicmp(data->key, param_key) == 0) {
5319 string_free(¶m_key);
5325 if (!global_section) {
5326 /* Try to fetch the same option but from globals */
5327 /* but only if we are not already working with Globals */
5328 data = Globals.param_opt;
5330 if (strwicmp(data->key, param_key) == 0) {
5331 string_free(¶m_key);
5338 string_free(¶m_key);
5344 * This is a helper function for parametrical options support. It returns a
5345 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5346 * parametrical functions are quite simple
5348 static struct parmlist_entry *get_parametrics(int snum, const char *type,
5351 if (snum >= iNumServices) return NULL;
5354 return get_parametrics_by_service(NULL, type, option);
5356 return get_parametrics_by_service(ServicePtrs[snum], type, option);
5361 #define MISSING_PARAMETER(name) \
5362 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5364 /*******************************************************************
5365 convenience routine to return int parameters.
5366 ********************************************************************/
5367 static int lp_int(const char *s)
5371 MISSING_PARAMETER(lp_int);
5375 return (int)strtol(s, NULL, 0);
5378 /*******************************************************************
5379 convenience routine to return unsigned long parameters.
5380 ********************************************************************/
5381 static unsigned long lp_ulong(const char *s)
5385 MISSING_PARAMETER(lp_ulong);
5389 return strtoul(s, NULL, 0);
5392 /*******************************************************************
5393 convenience routine to return boolean parameters.
5394 ********************************************************************/
5395 static bool lp_bool(const char *s)
5400 MISSING_PARAMETER(lp_bool);
5404 if (!set_boolean(s, &ret)) {
5405 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5412 /*******************************************************************
5413 convenience routine to return enum parameters.
5414 ********************************************************************/
5415 static int lp_enum(const char *s,const struct enum_list *_enum)
5419 if (!s || !*s || !_enum) {
5420 MISSING_PARAMETER(lp_enum);
5424 for (i=0; _enum[i].name; i++) {
5425 if (strequal(_enum[i].name,s))
5426 return _enum[i].value;
5429 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5433 #undef MISSING_PARAMETER
5435 /* Return parametric option from a given service. Type is a part of option before ':' */
5436 /* Parametric option has following syntax: 'Type: option = value' */
5437 char *lp_parm_talloc_string(TALLOC_CTX *ctx, int snum, const char *type, const char *option, const char *def)
5439 struct parmlist_entry *data = get_parametrics(snum, type, option);
5441 if (data == NULL||data->value==NULL) {
5443 return lp_string(ctx, def);
5449 return lp_string(ctx, data->value);
5452 /* Return parametric option from a given service. Type is a part of option before ':' */
5453 /* Parametric option has following syntax: 'Type: option = value' */
5454 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5456 struct parmlist_entry *data = get_parametrics(snum, type, option);
5458 if (data == NULL||data->value==NULL)
5464 const char *lp_parm_const_string_service(struct loadparm_service *service, const char *type, const char *option)
5466 struct parmlist_entry *data = get_parametrics_by_service(service, type, option);
5468 if (data == NULL||data->value==NULL)
5475 /* Return parametric option from a given service. Type is a part of option before ':' */
5476 /* Parametric option has following syntax: 'Type: option = value' */
5478 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5480 struct parmlist_entry *data = get_parametrics(snum, type, option);
5482 if (data == NULL||data->value==NULL)
5483 return (const char **)def;
5485 if (data->list==NULL) {
5486 data->list = str_list_make_v3(NULL, data->value, NULL);
5489 return (const char **)data->list;
5492 /* Return parametric option from a given service. Type is a part of option before ':' */
5493 /* Parametric option has following syntax: 'Type: option = value' */
5495 int lp_parm_int(int snum, const char *type, const char *option, int def)
5497 struct parmlist_entry *data = get_parametrics(snum, type, option);
5499 if (data && data->value && *data->value)
5500 return lp_int(data->value);
5505 /* Return parametric option from a given service. Type is a part of option before ':' */
5506 /* Parametric option has following syntax: 'Type: option = value' */
5508 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5510 struct parmlist_entry *data = get_parametrics(snum, type, option);
5512 if (data && data->value && *data->value)
5513 return lp_ulong(data->value);
5518 /* Return parametric option from a given service. Type is a part of option before ':' */
5519 /* Parametric option has following syntax: 'Type: option = value' */
5521 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5523 struct parmlist_entry *data = get_parametrics(snum, type, option);
5525 if (data && data->value && *data->value)
5526 return lp_bool(data->value);
5531 /* Return parametric option from a given service. Type is a part of option before ':' */
5532 /* Parametric option has following syntax: 'Type: option = value' */
5534 int lp_parm_enum(int snum, const char *type, const char *option,
5535 const struct enum_list *_enum, int def)
5537 struct parmlist_entry *data = get_parametrics(snum, type, option);
5539 if (data && data->value && *data->value && _enum)
5540 return lp_enum(data->value, _enum);
5546 /***************************************************************************
5547 Initialise a service to the defaults.
5548 ***************************************************************************/
5550 static void init_service(struct loadparm_service *pservice)
5552 memset((char *)pservice, '\0', sizeof(struct loadparm_service));
5553 copy_service(pservice, &sDefault, NULL);
5558 * free a param_opts structure.
5559 * param_opts handling should be moved to talloc;
5560 * then this whole functions reduces to a TALLOC_FREE().
5563 static void free_param_opts(struct parmlist_entry **popts)
5565 struct parmlist_entry *opt, *next_opt;
5567 if (popts == NULL) {
5571 if (*popts != NULL) {
5572 DEBUG(5, ("Freeing parametrics:\n"));
5575 while (opt != NULL) {
5576 string_free(&opt->key);
5577 string_free(&opt->value);
5578 TALLOC_FREE(opt->list);
5579 next_opt = opt->next;
5586 /***************************************************************************
5587 Free the dynamically allocated parts of a service struct.
5588 ***************************************************************************/
5590 static void free_service(struct loadparm_service *pservice)
5595 if (pservice->szService)
5596 DEBUG(5, ("free_service: Freeing service %s\n",
5597 pservice->szService));
5599 free_parameters(pservice);
5601 string_free(&pservice->szService);
5602 TALLOC_FREE(pservice->copymap);
5604 free_param_opts(&pservice->param_opt);
5606 ZERO_STRUCTP(pservice);
5610 /***************************************************************************
5611 remove a service indexed in the ServicePtrs array from the ServiceHash
5612 and free the dynamically allocated parts
5613 ***************************************************************************/
5615 static void free_service_byindex(int idx)
5617 if ( !LP_SNUM_OK(idx) )
5620 ServicePtrs[idx]->valid = false;
5621 invalid_services[num_invalid_services++] = idx;
5623 /* we have to cleanup the hash record */
5625 if (ServicePtrs[idx]->szService) {
5626 char *canon_name = canonicalize_servicename(
5628 ServicePtrs[idx]->szService );
5630 dbwrap_delete_bystring(ServiceHash, canon_name );
5631 TALLOC_FREE(canon_name);
5634 free_service(ServicePtrs[idx]);
5637 /***************************************************************************
5638 Add a new service to the services array initialising it with the given
5640 ***************************************************************************/
5642 static int add_a_service(const struct loadparm_service *pservice, const char *name)
5645 struct loadparm_service tservice;
5646 int num_to_alloc = iNumServices + 1;
5648 tservice = *pservice;
5650 /* it might already exist */
5652 i = getservicebyname(name, NULL);
5658 /* find an invalid one */
5660 if (num_invalid_services > 0) {
5661 i = invalid_services[--num_invalid_services];
5664 /* if not, then create one */
5665 if (i == iNumServices) {
5666 struct loadparm_service **tsp;
5669 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct loadparm_service *, num_to_alloc);
5671 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
5675 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct loadparm_service);
5676 if (!ServicePtrs[iNumServices]) {
5677 DEBUG(0,("add_a_service: out of memory!\n"));
5682 /* enlarge invalid_services here for now... */
5683 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
5685 if (tinvalid == NULL) {
5686 DEBUG(0,("add_a_service: failed to enlarge "
5687 "invalid_services!\n"));
5690 invalid_services = tinvalid;
5692 free_service_byindex(i);
5695 ServicePtrs[i]->valid = true;
5697 init_service(ServicePtrs[i]);
5698 copy_service(ServicePtrs[i], &tservice, NULL);
5700 string_set(&ServicePtrs[i]->szService, name);
5702 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
5703 i, ServicePtrs[i]->szService));
5705 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
5712 /***************************************************************************
5713 Convert a string to uppercase and remove whitespaces.
5714 ***************************************************************************/
5716 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
5721 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
5725 result = talloc_strdup(ctx, src);
5726 SMB_ASSERT(result != NULL);
5732 /***************************************************************************
5733 Add a name/index pair for the services array to the hash table.
5734 ***************************************************************************/
5736 static bool hash_a_service(const char *name, int idx)
5740 if ( !ServiceHash ) {
5741 DEBUG(10,("hash_a_service: creating servicehash\n"));
5742 ServiceHash = db_open_rbt(NULL);
5743 if ( !ServiceHash ) {
5744 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
5749 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
5752 canon_name = canonicalize_servicename(talloc_tos(), name );
5754 dbwrap_store_bystring(ServiceHash, canon_name,
5755 make_tdb_data((uint8 *)&idx, sizeof(idx)),
5758 TALLOC_FREE(canon_name);
5763 /***************************************************************************
5764 Add a new home service, with the specified home directory, defaults coming
5766 ***************************************************************************/
5768 bool lp_add_home(const char *pszHomename, int iDefaultService,
5769 const char *user, const char *pszHomedir)
5773 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
5774 pszHomedir[0] == '\0') {
5778 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
5783 if (!(*(ServicePtrs[iDefaultService]->szPath))
5784 || strequal(ServicePtrs[iDefaultService]->szPath,
5785 lp_pathname(talloc_tos(), GLOBAL_SECTION_SNUM))) {
5786 string_set(&ServicePtrs[i]->szPath, pszHomedir);
5789 if (!(*(ServicePtrs[i]->comment))) {
5790 char *comment = NULL;
5791 if (asprintf(&comment, "Home directory of %s", user) < 0) {
5794 string_set(&ServicePtrs[i]->comment, comment);
5798 /* set the browseable flag from the global default */
5800 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5801 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
5803 ServicePtrs[i]->autoloaded = true;
5805 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
5806 user, ServicePtrs[i]->szPath ));
5811 /***************************************************************************
5812 Add a new service, based on an old one.
5813 ***************************************************************************/
5815 int lp_add_service(const char *pszService, int iDefaultService)
5817 if (iDefaultService < 0) {
5818 return add_a_service(&sDefault, pszService);
5821 return (add_a_service(ServicePtrs[iDefaultService], pszService));
5824 /***************************************************************************
5825 Add the IPC service.
5826 ***************************************************************************/
5828 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
5830 char *comment = NULL;
5831 int i = add_a_service(&sDefault, ipc_name);
5836 if (asprintf(&comment, "IPC Service (%s)",
5837 Globals.szServerString) < 0) {
5841 string_set(&ServicePtrs[i]->szPath, tmpdir());
5842 string_set(&ServicePtrs[i]->szUsername, "");
5843 string_set(&ServicePtrs[i]->comment, comment);
5844 string_set(&ServicePtrs[i]->fstype, "IPC");
5845 ServicePtrs[i]->iMaxConnections = 0;
5846 ServicePtrs[i]->bAvailable = true;
5847 ServicePtrs[i]->bRead_only = true;
5848 ServicePtrs[i]->bGuest_only = false;
5849 ServicePtrs[i]->bAdministrative_share = true;
5850 ServicePtrs[i]->bGuest_ok = guest_ok;
5851 ServicePtrs[i]->bPrint_ok = false;
5852 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5854 DEBUG(3, ("adding IPC service\n"));
5860 /***************************************************************************
5861 Add a new printer service, with defaults coming from service iFrom.
5862 ***************************************************************************/
5864 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
5866 const char *comment = "From Printcap";
5867 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
5872 /* note that we do NOT default the availability flag to true - */
5873 /* we take it from the default service passed. This allows all */
5874 /* dynamic printers to be disabled by disabling the [printers] */
5875 /* entry (if/when the 'available' keyword is implemented!). */
5877 /* the printer name is set to the service name. */
5878 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
5879 string_set(&ServicePtrs[i]->comment, comment);
5881 /* set the browseable flag from the gloabl default */
5882 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5884 /* Printers cannot be read_only. */
5885 ServicePtrs[i]->bRead_only = false;
5886 /* No share modes on printer services. */
5887 ServicePtrs[i]->bShareModes = false;
5888 /* No oplocks on printer services. */
5889 ServicePtrs[i]->bOpLocks = false;
5890 /* Printer services must be printable. */
5891 ServicePtrs[i]->bPrint_ok = true;
5893 DEBUG(3, ("adding printer service %s\n", pszPrintername));
5899 /***************************************************************************
5900 Check whether the given parameter name is valid.
5901 Parametric options (names containing a colon) are considered valid.
5902 ***************************************************************************/
5904 bool lp_parameter_is_valid(const char *pszParmName)
5906 return ((map_parameter(pszParmName) != -1) ||
5907 (strchr(pszParmName, ':') != NULL));
5910 /***************************************************************************
5911 Check whether the given name is the name of a global parameter.
5912 Returns true for strings belonging to parameters of class
5913 P_GLOBAL, false for all other strings, also for parametric options
5914 and strings not belonging to any option.
5915 ***************************************************************************/
5917 bool lp_parameter_is_global(const char *pszParmName)
5919 int num = map_parameter(pszParmName);
5922 return (parm_table[num].p_class == P_GLOBAL);
5928 /**************************************************************************
5929 Check whether the given name is the canonical name of a parameter.
5930 Returns false if it is not a valid parameter Name.
5931 For parametric options, true is returned.
5932 **************************************************************************/
5934 bool lp_parameter_is_canonical(const char *parm_name)
5936 if (!lp_parameter_is_valid(parm_name)) {
5940 return (map_parameter(parm_name) ==
5941 map_parameter_canonical(parm_name, NULL));
5944 /**************************************************************************
5945 Determine the canonical name for a parameter.
5946 Indicate when it is an inverse (boolean) synonym instead of a
5948 **************************************************************************/
5950 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
5955 if (!lp_parameter_is_valid(parm_name)) {
5960 num = map_parameter_canonical(parm_name, inverse);
5962 /* parametric option */
5963 *canon_parm = parm_name;
5965 *canon_parm = parm_table[num].label;
5972 /**************************************************************************
5973 Determine the canonical name for a parameter.
5974 Turn the value given into the inverse boolean expression when
5975 the synonym is an invers boolean synonym.
5977 Return true if parm_name is a valid parameter name and
5978 in case it is an invers boolean synonym, if the val string could
5979 successfully be converted to the reverse bool.
5980 Return false in all other cases.
5981 **************************************************************************/
5983 bool lp_canonicalize_parameter_with_value(const char *parm_name,
5985 const char **canon_parm,
5986 const char **canon_val)
5991 if (!lp_parameter_is_valid(parm_name)) {
5997 num = map_parameter_canonical(parm_name, &inverse);
5999 /* parametric option */
6000 *canon_parm = parm_name;
6003 *canon_parm = parm_table[num].label;
6005 if (!lp_invert_boolean(val, canon_val)) {
6017 /***************************************************************************
6018 Map a parameter's string representation to something we can use.
6019 Returns false if the parameter string is not recognised, else TRUE.
6020 ***************************************************************************/
6022 static int map_parameter(const char *pszParmName)
6026 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6029 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6030 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6033 /* Warn only if it isn't parametric option */
6034 if (strchr(pszParmName, ':') == NULL)
6035 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6036 /* We do return 'fail' for parametric options as well because they are
6037 stored in different storage
6042 /***************************************************************************
6043 Map a parameter's string representation to the index of the canonical
6044 form of the parameter (it might be a synonym).
6045 Returns -1 if the parameter string is not recognised.
6046 ***************************************************************************/
6048 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6050 int parm_num, canon_num;
6051 bool loc_inverse = false;
6053 parm_num = map_parameter(pszParmName);
6054 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6055 /* invalid, parametric or no canidate for synonyms ... */
6059 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6060 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6061 parm_num = canon_num;
6067 if (inverse != NULL) {
6068 *inverse = loc_inverse;
6073 /***************************************************************************
6074 return true if parameter number parm1 is a synonym of parameter
6075 number parm2 (parm2 being the principal name).
6076 set inverse to true if parm1 is P_BOOLREV and parm2 is P_BOOL,
6078 ***************************************************************************/
6080 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6082 if ((parm_table[parm1].offset == parm_table[parm2].offset) &&
6083 (parm_table[parm1].p_class == parm_table[parm2].p_class) &&
6084 (parm_table[parm1].flags & FLAG_HIDE) &&
6085 !(parm_table[parm2].flags & FLAG_HIDE))
6087 if (inverse != NULL) {
6088 if ((parm_table[parm1].type == P_BOOLREV) &&
6089 (parm_table[parm2].type == P_BOOL))
6101 /***************************************************************************
6102 Show one parameter's name, type, [values,] and flags.
6103 (helper functions for show_parameter_list)
6104 ***************************************************************************/
6106 static void show_parameter(int parmIndex)
6108 int enumIndex, flagIndex;
6113 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6114 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6116 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6117 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6119 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6120 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6121 "FLAG_DEPRECATED", "FLAG_HIDE", NULL};
6123 printf("%s=%s", parm_table[parmIndex].label,
6124 type[parm_table[parmIndex].type]);
6125 if (parm_table[parmIndex].type == P_ENUM) {
6128 parm_table[parmIndex].enum_list[enumIndex].name;
6132 enumIndex ? "|" : "",
6133 parm_table[parmIndex].enum_list[enumIndex].name);
6138 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6139 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6142 flag_names[flagIndex]);
6147 /* output synonyms */
6149 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6150 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6151 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6152 parm_table[parmIndex2].label);
6153 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6155 printf(" (synonyms: ");
6160 printf("%s%s", parm_table[parmIndex2].label,
6161 inverse ? "[i]" : "");
6171 /***************************************************************************
6172 Show all parameter's name, type, [values,] and flags.
6173 ***************************************************************************/
6175 void show_parameter_list(void)
6177 int classIndex, parmIndex;
6178 const char *section_names[] = { "local", "global", NULL};
6180 for (classIndex=0; section_names[classIndex]; classIndex++) {
6181 printf("[%s]\n", section_names[classIndex]);
6182 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6183 if (parm_table[parmIndex].p_class == classIndex) {
6184 show_parameter(parmIndex);
6190 /***************************************************************************
6191 Check if a given string correctly represents a boolean value.
6192 ***************************************************************************/
6194 bool lp_string_is_valid_boolean(const char *parm_value)
6196 return set_boolean(parm_value, NULL);
6199 /***************************************************************************
6200 Get the standard string representation of a boolean value ("yes" or "no")
6201 ***************************************************************************/
6203 static const char *get_boolean(bool bool_value)
6205 static const char *yes_str = "yes";
6206 static const char *no_str = "no";
6208 return (bool_value ? yes_str : no_str);
6211 /***************************************************************************
6212 Provide the string of the negated boolean value associated to the boolean
6213 given as a string. Returns false if the passed string does not correctly
6214 represent a boolean.
6215 ***************************************************************************/
6217 bool lp_invert_boolean(const char *str, const char **inverse_str)
6221 if (!set_boolean(str, &val)) {
6225 *inverse_str = get_boolean(!val);
6229 /***************************************************************************
6230 Provide the canonical string representation of a boolean value given
6231 as a string. Return true on success, false if the string given does
6232 not correctly represent a boolean.
6233 ***************************************************************************/
6235 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6239 if (!set_boolean(str, &val)) {
6243 *canon_str = get_boolean(val);
6247 /***************************************************************************
6248 Find a service by name. Otherwise works like get_service.
6249 ***************************************************************************/
6251 static int getservicebyname(const char *pszServiceName, struct loadparm_service *pserviceDest)
6258 if (ServiceHash == NULL) {
6262 canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
6264 status = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name,
6267 if (NT_STATUS_IS_OK(status) &&
6268 (data.dptr != NULL) &&
6269 (data.dsize == sizeof(iService)))
6271 iService = *(int *)data.dptr;
6274 TALLOC_FREE(canon_name);
6276 if ((iService != -1) && (LP_SNUM_OK(iService))
6277 && (pserviceDest != NULL)) {
6278 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6284 /* Return a pointer to a service by name. Unlike getservicebyname, it does not copy the service */
6285 struct loadparm_service *lp_service(const char *pszServiceName)
6287 int iService = getservicebyname(pszServiceName, NULL);
6288 if (iService == -1 || !LP_SNUM_OK(iService)) {
6291 return ServicePtrs[iService];
6294 struct loadparm_service *lp_servicebynum(int snum)
6296 if ((snum == -1) || !LP_SNUM_OK(snum)) {
6299 return ServicePtrs[snum];
6302 struct loadparm_service *lp_default_loadparm_service()
6308 /***************************************************************************
6309 Copy a service structure to another.
6310 If pcopymapDest is NULL then copy all fields
6311 ***************************************************************************/
6314 * Add a parametric option to a parmlist_entry,
6315 * replacing old value, if already present.
6317 static void set_param_opt(struct parmlist_entry **opt_list,
6318 const char *opt_name,
6319 const char *opt_value,
6322 struct parmlist_entry *new_opt, *opt;
6325 if (opt_list == NULL) {
6332 /* Traverse destination */
6334 /* If we already have same option, override it */
6335 if (strwicmp(opt->key, opt_name) == 0) {
6336 if ((opt->priority & FLAG_CMDLINE) &&
6337 !(priority & FLAG_CMDLINE)) {
6338 /* it's been marked as not to be
6342 string_free(&opt->value);
6343 TALLOC_FREE(opt->list);
6344 opt->value = SMB_STRDUP(opt_value);
6345 opt->priority = priority;
6352 new_opt = SMB_XMALLOC_P(struct parmlist_entry);
6353 new_opt->key = SMB_STRDUP(opt_name);
6354 new_opt->value = SMB_STRDUP(opt_value);
6355 new_opt->list = NULL;
6356 new_opt->priority = priority;
6357 DLIST_ADD(*opt_list, new_opt);
6361 static void copy_service(struct loadparm_service *pserviceDest, struct loadparm_service *pserviceSource,
6362 struct bitmap *pcopymapDest)
6365 bool bcopyall = (pcopymapDest == NULL);
6366 struct parmlist_entry *data;
6368 for (i = 0; parm_table[i].label; i++)
6369 if (parm_table[i].p_class == P_LOCAL &&
6370 (bcopyall || bitmap_query(pcopymapDest,i))) {
6371 void *src_ptr = lp_parm_ptr(pserviceSource, &parm_table[i]);
6372 void *dest_ptr = lp_parm_ptr(pserviceDest, &parm_table[i]);
6374 switch (parm_table[i].type) {
6377 *(bool *)dest_ptr = *(bool *)src_ptr;
6384 *(int *)dest_ptr = *(int *)src_ptr;
6388 *(char *)dest_ptr = *(char *)src_ptr;
6392 string_set((char **)dest_ptr,
6398 char *upper_string = strupper_talloc(talloc_tos(),
6400 string_set((char **)dest_ptr,
6402 TALLOC_FREE(upper_string);
6406 TALLOC_FREE(*((char ***)dest_ptr));
6407 *((char ***)dest_ptr) = str_list_copy(NULL,
6408 *(const char ***)src_ptr);
6416 init_copymap(pserviceDest);
6417 if (pserviceSource->copymap)
6418 bitmap_copy(pserviceDest->copymap,
6419 pserviceSource->copymap);
6422 data = pserviceSource->param_opt;
6424 set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->priority);
6429 /***************************************************************************
6430 Check a service for consistency. Return false if the service is in any way
6431 incomplete or faulty, else true.
6432 ***************************************************************************/
6434 bool service_ok(int iService)
6439 if (ServicePtrs[iService]->szService[0] == '\0') {
6440 DEBUG(0, ("The following message indicates an internal error:\n"));
6441 DEBUG(0, ("No service name in service entry.\n"));
6445 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6446 /* I can't see why you'd want a non-printable printer service... */
6447 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6448 if (!ServicePtrs[iService]->bPrint_ok) {
6449 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6450 ServicePtrs[iService]->szService));
6451 ServicePtrs[iService]->bPrint_ok = true;
6453 /* [printers] service must also be non-browsable. */
6454 if (ServicePtrs[iService]->bBrowseable)
6455 ServicePtrs[iService]->bBrowseable = false;
6458 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6459 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6460 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6462 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6463 ServicePtrs[iService]->szService));
6464 ServicePtrs[iService]->bAvailable = false;
6467 /* If a service is flagged unavailable, log the fact at level 1. */
6468 if (!ServicePtrs[iService]->bAvailable)
6469 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6470 ServicePtrs[iService]->szService));
6475 static struct smbconf_ctx *lp_smbconf_ctx(void)
6478 static struct smbconf_ctx *conf_ctx = NULL;
6480 if (conf_ctx == NULL) {
6481 err = smbconf_init(NULL, &conf_ctx, "registry:");
6482 if (!SBC_ERROR_IS_OK(err)) {
6483 DEBUG(1, ("error initializing registry configuration: "
6484 "%s\n", sbcErrorString(err)));
6492 static bool process_smbconf_service(struct smbconf_service *service)
6497 if (service == NULL) {
6501 ret = do_section(service->name, NULL);
6505 for (count = 0; count < service->num_params; count++) {
6506 ret = do_parameter(service->param_names[count],
6507 service->param_values[count],
6513 if (iServiceIndex >= 0) {
6514 return service_ok(iServiceIndex);
6520 * load a service from registry and activate it
6522 bool process_registry_service(const char *service_name)
6525 struct smbconf_service *service = NULL;
6526 TALLOC_CTX *mem_ctx = talloc_stackframe();
6527 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6530 if (conf_ctx == NULL) {
6534 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6536 if (!smbconf_share_exists(conf_ctx, service_name)) {
6538 * Registry does not contain data for this service (yet),
6539 * but make sure lp_load doesn't return false.
6545 err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6546 if (!SBC_ERROR_IS_OK(err)) {
6550 ret = process_smbconf_service(service);
6556 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6559 TALLOC_FREE(mem_ctx);
6564 * process_registry_globals
6566 static bool process_registry_globals(void)
6570 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6572 ret = do_parameter("registry shares", "yes", NULL);
6577 return process_registry_service(GLOBAL_NAME);
6580 bool process_registry_shares(void)
6584 struct smbconf_service **service = NULL;
6585 uint32_t num_shares = 0;
6586 TALLOC_CTX *mem_ctx = talloc_stackframe();
6587 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6590 if (conf_ctx == NULL) {
6594 err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6595 if (!SBC_ERROR_IS_OK(err)) {
6601 for (count = 0; count < num_shares; count++) {
6602 if (strequal(service[count]->name, GLOBAL_NAME)) {
6605 ret = process_smbconf_service(service[count]);
6612 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6615 TALLOC_FREE(mem_ctx);
6620 * reload those shares from registry that are already
6621 * activated in the services array.
6623 static bool reload_registry_shares(void)
6628 for (i = 0; i < iNumServices; i++) {
6633 if (ServicePtrs[i]->usershare == USERSHARE_VALID) {
6637 ret = process_registry_service(ServicePtrs[i]->szService);
6648 #define MAX_INCLUDE_DEPTH 100
6650 static uint8_t include_depth;
6652 static struct file_lists {
6653 struct file_lists *next;
6657 } *file_lists = NULL;
6659 /*******************************************************************
6660 Keep a linked list of all config files so we know when one has changed
6661 it's date and needs to be reloaded.
6662 ********************************************************************/
6664 static void add_to_file_list(const char *fname, const char *subfname)
6666 struct file_lists *f = file_lists;
6669 if (f->name && !strcmp(f->name, fname))
6675 f = SMB_MALLOC_P(struct file_lists);
6678 f->next = file_lists;
6679 f->name = SMB_STRDUP(fname);
6684 f->subfname = SMB_STRDUP(subfname);
6691 f->modtime = file_modtime(subfname);
6693 time_t t = file_modtime(subfname);
6701 * Free the file lists
6703 static void free_file_list(void)
6705 struct file_lists *f;
6706 struct file_lists *next;
6711 SAFE_FREE( f->name );
6712 SAFE_FREE( f->subfname );
6721 * Utility function for outsiders to check if we're running on registry.
6723 bool lp_config_backend_is_registry(void)
6725 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
6729 * Utility function to check if the config backend is FILE.
6731 bool lp_config_backend_is_file(void)
6733 return (lp_config_backend() == CONFIG_BACKEND_FILE);
6736 /*******************************************************************
6737 Check if a config file has changed date.
6738 ********************************************************************/
6740 bool lp_file_list_changed(void)
6742 struct file_lists *f = file_lists;
6744 DEBUG(6, ("lp_file_list_changed()\n"));
6749 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
6750 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6752 if (conf_ctx == NULL) {
6755 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
6758 DEBUGADD(6, ("registry config changed\n"));
6763 n2 = talloc_sub_basic(talloc_tos(),
6764 get_current_username(),
6765 current_user_info.domain,
6770 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
6771 f->name, n2, ctime(&f->modtime)));
6773 mod_time = file_modtime(n2);
6776 ((f->modtime != mod_time) ||
6777 (f->subfname == NULL) ||
6778 (strcmp(n2, f->subfname) != 0)))
6781 ("file %s modified: %s\n", n2,
6783 f->modtime = mod_time;
6784 SAFE_FREE(f->subfname);
6785 f->subfname = SMB_STRDUP(n2);
6798 * Initialize iconv conversion descriptors.
6800 * This is called the first time it is needed, and also called again
6801 * every time the configuration is reloaded, because the charset or
6802 * codepage might have changed.
6804 static void init_iconv(void)
6806 global_iconv_handle = smb_iconv_handle_reinit(NULL, lp_dos_charset(),
6808 true, global_iconv_handle);
6811 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6813 if (strcmp(*ptr, pszParmValue) != 0) {
6814 string_set(ptr, pszParmValue);
6820 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6822 bool is_utf8 = false;
6823 size_t len = strlen(pszParmValue);
6825 if (len == 4 || len == 5) {
6826 /* Don't use StrCaseCmp here as we don't want to
6827 initialize iconv. */
6828 if ((toupper_m(pszParmValue[0]) == 'U') &&
6829 (toupper_m(pszParmValue[1]) == 'T') &&
6830 (toupper_m(pszParmValue[2]) == 'F')) {
6832 if (pszParmValue[3] == '8') {
6836 if (pszParmValue[3] == '-' &&
6837 pszParmValue[4] == '8') {
6844 if (strcmp(*ptr, pszParmValue) != 0) {
6846 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
6847 "be UTF8, using (default value) %s instead.\n",
6848 DEFAULT_DOS_CHARSET));
6849 pszParmValue = DEFAULT_DOS_CHARSET;
6851 string_set(ptr, pszParmValue);
6857 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6860 char *realm = strupper_talloc(talloc_tos(), pszParmValue);
6861 char *dnsdomain = strlower_talloc(realm, pszParmValue);
6863 ret &= string_set(&Globals.szRealm, pszParmValue);
6864 ret &= string_set(&Globals.szRealm_upper, realm);
6865 ret &= string_set(&Globals.szRealm_lower, dnsdomain);
6871 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6873 TALLOC_FREE(Globals.szNetbiosAliases);
6874 Globals.szNetbiosAliases = (const char **)str_list_make_v3(NULL, pszParmValue, NULL);
6875 return set_netbios_aliases(Globals.szNetbiosAliases);
6878 /***************************************************************************
6879 Handle the include operation.
6880 ***************************************************************************/
6881 static bool bAllowIncludeRegistry = true;
6883 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6887 if (include_depth >= MAX_INCLUDE_DEPTH) {
6888 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
6893 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
6894 if (!bAllowIncludeRegistry) {
6897 if (bInGlobalSection) {
6900 ret = process_registry_globals();
6904 DEBUG(1, ("\"include = registry\" only effective "
6905 "in %s section\n", GLOBAL_NAME));
6910 fname = talloc_sub_basic(talloc_tos(), get_current_username(),
6911 current_user_info.domain,
6914 add_to_file_list(pszParmValue, fname);
6916 string_set(ptr, fname);
6918 if (file_exist(fname)) {
6921 ret = pm_process(fname, do_section, do_parameter, NULL);
6927 DEBUG(2, ("Can't find include file %s\n", fname));
6932 /***************************************************************************
6933 Handle the interpretation of the copy parameter.
6934 ***************************************************************************/
6936 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6940 struct loadparm_service serviceTemp;
6942 string_set(ptr, pszParmValue);
6944 init_service(&serviceTemp);
6948 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
6950 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
6951 if (iTemp == iServiceIndex) {
6952 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
6954 copy_service(ServicePtrs[iServiceIndex],
6956 ServicePtrs[iServiceIndex]->copymap);
6960 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
6964 free_service(&serviceTemp);
6968 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6970 Globals.ldap_debug_level = lp_int(pszParmValue);
6971 init_ldap_debugging();
6975 /***************************************************************************
6976 Handle idmap/non unix account uid and gid allocation parameters. The format of these
6981 idmap uid = 1000-1999
6984 We only do simple parsing checks here. The strings are parsed into useful
6985 structures in the idmap daemon code.
6987 ***************************************************************************/
6989 /* Some lp_ routines to return idmap [ug]id information */
6991 static uid_t idmap_uid_low, idmap_uid_high;
6992 static gid_t idmap_gid_low, idmap_gid_high;
6994 bool lp_idmap_uid(uid_t *low, uid_t *high)
6996 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7000 *low = idmap_uid_low;
7003 *high = idmap_uid_high;
7008 bool lp_idmap_gid(gid_t *low, gid_t *high)
7010 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7014 *low = idmap_gid_low;
7017 *high = idmap_gid_high;
7022 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7024 lp_do_parameter(snum, "idmap config * : backend", pszParmValue);
7029 /* Do some simple checks on "idmap [ug]id" parameter values */
7031 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7033 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7038 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7040 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7045 /***************************************************************************
7046 Handle the DEBUG level list.
7047 ***************************************************************************/
7049 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValueIn, char **ptr )
7051 string_set(ptr, pszParmValueIn);
7052 return debug_parse_levels(pszParmValueIn);
7055 /***************************************************************************
7056 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7057 ***************************************************************************/
7059 static const char *append_ldap_suffix(TALLOC_CTX *ctx, const char *str )
7061 const char *suffix_string;
7063 suffix_string = talloc_asprintf(ctx, "%s,%s", str,
7064 Globals.szLdapSuffix );
7065 if ( !suffix_string ) {
7066 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7070 return suffix_string;
7073 const char *lp_ldap_machine_suffix(TALLOC_CTX *ctx)
7075 if (Globals.szLdapMachineSuffix[0])
7076 return append_ldap_suffix(ctx, Globals.szLdapMachineSuffix);
7078 return lp_string(ctx, Globals.szLdapSuffix);
7081 const char *lp_ldap_user_suffix(TALLOC_CTX *ctx)
7083 if (Globals.szLdapUserSuffix[0])
7084 return append_ldap_suffix(ctx, Globals.szLdapUserSuffix);
7086 return lp_string(ctx, Globals.szLdapSuffix);
7089 const char *lp_ldap_group_suffix(TALLOC_CTX *ctx)
7091 if (Globals.szLdapGroupSuffix[0])
7092 return append_ldap_suffix(ctx, Globals.szLdapGroupSuffix);
7094 return lp_string(ctx, Globals.szLdapSuffix);
7097 const char *lp_ldap_idmap_suffix(TALLOC_CTX *ctx)
7099 if (Globals.szLdapIdmapSuffix[0])
7100 return append_ldap_suffix(ctx, Globals.szLdapIdmapSuffix);
7102 return lp_string(ctx, Globals.szLdapSuffix);
7105 /****************************************************************************
7106 set the value for a P_ENUM
7107 ***************************************************************************/
7109 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7114 for (i = 0; parm->enum_list[i].name; i++) {
7115 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7116 *ptr = parm->enum_list[i].value;
7120 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7121 pszParmValue, parm->label));
7124 /***************************************************************************
7125 ***************************************************************************/
7127 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7129 static int parm_num = -1;
7130 struct loadparm_service *s;
7132 if ( parm_num == -1 )
7133 parm_num = map_parameter( "printing" );
7135 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7140 s = ServicePtrs[snum];
7142 init_printer_values( s );
7148 /***************************************************************************
7149 Initialise a copymap.
7150 ***************************************************************************/
7152 static void init_copymap(struct loadparm_service *pservice)
7156 TALLOC_FREE(pservice->copymap);
7158 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
7159 if (!pservice->copymap)
7161 ("Couldn't allocate copymap!! (size %d)\n",
7162 (int)NUMPARAMETERS));
7164 for (i = 0; i < NUMPARAMETERS; i++)
7165 bitmap_set(pservice->copymap, i);
7169 return the parameter pointer for a parameter
7171 void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm)
7173 if (service == NULL) {
7174 if (parm->p_class == P_LOCAL)
7175 return (void *)(((char *)&sDefault)+parm->offset);
7176 else if (parm->p_class == P_GLOBAL)
7177 return (void *)(((char *)&Globals)+parm->offset);
7180 return (void *)(((char *)service) + parm->offset);
7184 /***************************************************************************
7185 Return the local pointer to a parameter given the service number and parameter
7186 ***************************************************************************/
7188 void *lp_local_ptr_by_snum(int snum, struct parm_struct *parm)
7190 return lp_parm_ptr(ServicePtrs[snum], parm);
7193 /***************************************************************************
7194 Process a parameter for a particular service number. If snum < 0
7195 then assume we are in the globals.
7196 ***************************************************************************/
7198 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7201 void *parm_ptr = NULL; /* where we are going to store the result */
7202 struct parmlist_entry **opt_list;
7204 parmnum = map_parameter(pszParmName);
7207 if (strchr(pszParmName, ':') == NULL) {
7208 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7214 * We've got a parametric option
7217 opt_list = (snum < 0)
7218 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7219 set_param_opt(opt_list, pszParmName, pszParmValue, 0);
7224 /* if it's already been set by the command line, then we don't
7226 if (parm_table[parmnum].flags & FLAG_CMDLINE) {
7230 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7231 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7235 /* we might point at a service, the default service or a global */
7237 parm_ptr = lp_parm_ptr(NULL, &parm_table[parmnum]);
7239 if (parm_table[parmnum].p_class == P_GLOBAL) {
7241 ("Global parameter %s found in service section!\n",
7245 parm_ptr = lp_local_ptr_by_snum(snum, &parm_table[parmnum]);
7249 if (!ServicePtrs[snum]->copymap)
7250 init_copymap(ServicePtrs[snum]);
7252 /* this handles the aliases - set the copymap for other entries with
7253 the same data pointer */
7254 for (i = 0; parm_table[i].label; i++) {
7255 if ((parm_table[i].offset == parm_table[parmnum].offset)
7256 && (parm_table[i].p_class == parm_table[parmnum].p_class)) {
7257 bitmap_clear(ServicePtrs[snum]->copymap, i);
7262 /* if it is a special case then go ahead */
7263 if (parm_table[parmnum].special) {
7264 return parm_table[parmnum].special(NULL, snum, pszParmValue,
7268 /* now switch on the type of variable it is */
7269 switch (parm_table[parmnum].type)
7272 *(bool *)parm_ptr = lp_bool(pszParmValue);
7276 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7280 *(int *)parm_ptr = lp_int(pszParmValue);
7284 *(char *)parm_ptr = *pszParmValue;
7288 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7290 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7297 if (conv_str_size_error(pszParmValue, &val)) {
7298 if (val <= INT_MAX) {
7299 *(int *)parm_ptr = (int)val;
7304 DEBUG(0,("lp_do_parameter(%s): value is not "
7305 "a valid size specifier!\n", pszParmValue));
7311 TALLOC_FREE(*((char ***)parm_ptr));
7312 *(char ***)parm_ptr = str_list_make_v3(
7313 NULL, pszParmValue, NULL);
7317 string_set((char **)parm_ptr, pszParmValue);
7322 char *upper_string = strupper_talloc(talloc_tos(),
7324 string_set((char **)parm_ptr, upper_string);
7325 TALLOC_FREE(upper_string);
7329 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7338 /***************************************************************************
7339 set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
7340 FLAG_CMDLINE won't be overridden by loads from smb.conf.
7341 ***************************************************************************/
7343 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
7346 parmnum = map_parameter(pszParmName);
7348 parm_table[parmnum].flags &= ~FLAG_CMDLINE;
7349 if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
7352 parm_table[parmnum].flags |= FLAG_CMDLINE;
7354 /* we have to also set FLAG_CMDLINE on aliases. Aliases must
7355 * be grouped in the table, so we don't have to search the
7358 i>=0 && parm_table[i].offset == parm_table[parmnum].offset
7359 && parm_table[i].p_class == parm_table[parmnum].p_class;
7361 parm_table[i].flags |= FLAG_CMDLINE;
7363 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset
7364 && parm_table[i].p_class == parm_table[parmnum].p_class;i++) {
7365 parm_table[i].flags |= FLAG_CMDLINE;
7369 store_lp_set_cmdline(pszParmName, pszParmValue);
7374 /* it might be parametric */
7375 if (strchr(pszParmName, ':') != NULL) {
7376 set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
7378 store_lp_set_cmdline(pszParmName, pszParmValue);
7383 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
7387 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
7389 return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
7392 /***************************************************************************
7393 Process a parameter.
7394 ***************************************************************************/
7396 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7399 if (!bInGlobalSection && bGlobalOnly)
7402 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7404 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7405 pszParmName, pszParmValue));
7409 set a option from the commandline in 'a=b' format. Use to support --option
7411 bool lp_set_option(const char *option)
7416 s = talloc_strdup(NULL, option);
7429 /* skip white spaces after the = sign */
7432 } while (*p == ' ');
7434 ret = lp_set_cmdline(s, p);
7439 /**************************************************************************
7440 Print a parameter of the specified type.
7441 ***************************************************************************/
7443 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7445 /* For the seperation of lists values that we print below */
7446 const char *list_sep = ", ";
7451 for (i = 0; p->enum_list[i].name; i++) {
7452 if (*(int *)ptr == p->enum_list[i].value) {
7454 p->enum_list[i].name);
7461 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7465 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7470 fprintf(f, "%d", *(int *)ptr);
7474 fprintf(f, "%c", *(char *)ptr);
7478 int val = *(int *)ptr;
7482 fprintf(f, "0%o", val);
7491 if ((char ***)ptr && *(char ***)ptr) {
7492 char **list = *(char ***)ptr;
7493 for (; *list; list++) {
7494 /* surround strings with whitespace in double quotes */
7495 if (*(list+1) == NULL) {
7496 /* last item, no extra separator */
7499 if ( strchr_m( *list, ' ' ) ) {
7500 fprintf(f, "\"%s\"%s", *list, list_sep);
7502 fprintf(f, "%s%s", *list, list_sep);
7510 if (*(char **)ptr) {
7511 fprintf(f, "%s", *(char **)ptr);
7519 /***************************************************************************
7520 Check if two parameters are equal.
7521 ***************************************************************************/
7523 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7528 return (*((bool *)ptr1) == *((bool *)ptr2));
7534 return (*((int *)ptr1) == *((int *)ptr2));
7537 return (*((char *)ptr1) == *((char *)ptr2));
7541 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7546 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7551 return (p1 == p2 || strequal(p1, p2));
7559 /***************************************************************************
7560 Initialize any local varients in the sDefault table.
7561 ***************************************************************************/
7563 void init_locals(void)
7568 /***************************************************************************
7569 Process a new section (service). At this stage all sections are services.
7570 Later we'll have special sections that permit server parameters to be set.
7571 Returns true on success, false on failure.
7572 ***************************************************************************/
7574 static bool do_section(const char *pszSectionName, void *userdata)
7577 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7578 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7581 /* if we were in a global section then do the local inits */
7582 if (bInGlobalSection && !isglobal)
7585 /* if we've just struck a global section, note the fact. */
7586 bInGlobalSection = isglobal;
7588 /* check for multiple global sections */
7589 if (bInGlobalSection) {
7590 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7594 if (!bInGlobalSection && bGlobalOnly)
7597 /* if we have a current service, tidy it up before moving on */
7600 if (iServiceIndex >= 0)
7601 bRetval = service_ok(iServiceIndex);
7603 /* if all is still well, move to the next record in the services array */
7605 /* We put this here to avoid an odd message order if messages are */
7606 /* issued by the post-processing of a previous section. */
7607 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7609 iServiceIndex = add_a_service(&sDefault, pszSectionName);
7610 if (iServiceIndex < 0) {
7611 DEBUG(0, ("Failed to add a new service\n"));
7614 /* Clean all parametric options for service */
7615 /* They will be added during parsing again */
7616 free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
7623 /***************************************************************************
7624 Determine if a partcular base parameter is currentl set to the default value.
7625 ***************************************************************************/
7627 static bool is_default(int i)
7629 if (!defaults_saved)
7631 switch (parm_table[i].type) {
7634 return str_list_equal((const char **)parm_table[i].def.lvalue,
7635 *(const char ***)lp_parm_ptr(NULL,
7639 return strequal(parm_table[i].def.svalue,
7640 *(char **)lp_parm_ptr(NULL,
7644 return parm_table[i].def.bvalue ==
7645 *(bool *)lp_parm_ptr(NULL,
7648 return parm_table[i].def.cvalue ==
7649 *(char *)lp_parm_ptr(NULL,
7655 return parm_table[i].def.ivalue ==
7656 *(int *)lp_parm_ptr(NULL,
7664 /***************************************************************************
7665 Display the contents of the global structure.
7666 ***************************************************************************/
7668 static void dump_globals(FILE *f)
7671 struct parmlist_entry *data;
7673 fprintf(f, "[global]\n");
7675 for (i = 0; parm_table[i].label; i++)
7676 if (parm_table[i].p_class == P_GLOBAL &&
7677 !(parm_table[i].flags & FLAG_META) &&
7678 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
7679 if (defaults_saved && is_default(i))
7681 fprintf(f, "\t%s = ", parm_table[i].label);
7682 print_parameter(&parm_table[i], lp_parm_ptr(NULL,
7687 if (Globals.param_opt != NULL) {
7688 data = Globals.param_opt;
7690 fprintf(f, "\t%s = %s\n", data->key, data->value);
7697 /***************************************************************************
7698 Return true if a local parameter is currently set to the global default.
7699 ***************************************************************************/
7701 bool lp_is_default(int snum, struct parm_struct *parm)
7703 return equal_parameter(parm->type,
7704 lp_parm_ptr(ServicePtrs[snum], parm),
7705 lp_parm_ptr(NULL, parm));
7708 /***************************************************************************
7709 Display the contents of a single services record.
7710 ***************************************************************************/
7712 static void dump_a_service(struct loadparm_service *pService, FILE * f)
7715 struct parmlist_entry *data;
7717 if (pService != &sDefault)
7718 fprintf(f, "[%s]\n", pService->szService);
7720 for (i = 0; parm_table[i].label; i++) {
7722 if (parm_table[i].p_class == P_LOCAL &&
7723 !(parm_table[i].flags & FLAG_META) &&
7724 (*parm_table[i].label != '-') &&
7725 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7727 if (pService == &sDefault) {
7728 if (defaults_saved && is_default(i))
7731 if (equal_parameter(parm_table[i].type,
7732 lp_parm_ptr(pService, &parm_table[i]),
7733 lp_parm_ptr(NULL, &parm_table[i])))
7737 fprintf(f, "\t%s = ", parm_table[i].label);
7738 print_parameter(&parm_table[i],
7739 lp_parm_ptr(pService, &parm_table[i]),
7745 if (pService->param_opt != NULL) {
7746 data = pService->param_opt;
7748 fprintf(f, "\t%s = %s\n", data->key, data->value);
7754 /***************************************************************************
7755 Display the contents of a parameter of a single services record.
7756 ***************************************************************************/
7758 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7761 bool result = false;
7764 fstring local_parm_name;
7766 const char *parm_opt_value;
7768 /* check for parametrical option */
7769 fstrcpy( local_parm_name, parm_name);
7770 parm_opt = strchr( local_parm_name, ':');
7775 if (strlen(parm_opt)) {
7776 parm_opt_value = lp_parm_const_string( snum,
7777 local_parm_name, parm_opt, NULL);
7778 if (parm_opt_value) {
7779 printf( "%s\n", parm_opt_value);
7786 /* check for a key and print the value */
7793 for (i = 0; parm_table[i].label; i++) {
7794 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7795 !(parm_table[i].flags & FLAG_META) &&
7796 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7797 (*parm_table[i].label != '-') &&
7798 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7803 ptr = lp_parm_ptr(NULL,
7806 ptr = lp_parm_ptr(ServicePtrs[snum],
7810 print_parameter(&parm_table[i],
7821 /***************************************************************************
7822 Return info about the requested parameter (given as a string).
7823 Return NULL when the string is not a valid parameter name.
7824 ***************************************************************************/
7826 struct parm_struct *lp_get_parameter(const char *param_name)
7828 int num = map_parameter(param_name);
7834 return &parm_table[num];
7837 /***************************************************************************
7838 Return info about the next parameter in a service.
7839 snum==GLOBAL_SECTION_SNUM gives the globals.
7840 Return NULL when out of parameters.
7841 ***************************************************************************/
7843 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
7846 /* do the globals */
7847 for (; parm_table[*i].label; (*i)++) {
7848 if (parm_table[*i].p_class == P_SEPARATOR)
7849 return &parm_table[(*i)++];
7851 if ((*parm_table[*i].label == '-'))
7855 && (parm_table[*i].offset ==
7856 parm_table[(*i) - 1].offset)
7857 && (parm_table[*i].p_class ==
7858 parm_table[(*i) - 1].p_class))
7861 if (is_default(*i) && !allparameters)
7864 return &parm_table[(*i)++];
7867 struct loadparm_service *pService = ServicePtrs[snum];
7869 for (; parm_table[*i].label; (*i)++) {
7870 if (parm_table[*i].p_class == P_SEPARATOR)
7871 return &parm_table[(*i)++];
7873 if (parm_table[*i].p_class == P_LOCAL &&
7874 (*parm_table[*i].label != '-') &&
7876 (parm_table[*i].offset !=
7877 parm_table[(*i) - 1].offset)))
7879 if (allparameters ||
7880 !equal_parameter(parm_table[*i].type,
7881 lp_parm_ptr(pService,
7886 return &parm_table[(*i)++];
7897 /***************************************************************************
7898 Display the contents of a single copy structure.
7899 ***************************************************************************/
7900 static void dump_copy_map(bool *pcopymap)
7906 printf("\n\tNon-Copied parameters:\n");
7908 for (i = 0; parm_table[i].label; i++)
7909 if (parm_table[i].p_class == P_LOCAL &&
7910 parm_table[i].ptr && !pcopymap[i] &&
7911 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7913 printf("\t\t%s\n", parm_table[i].label);
7918 /***************************************************************************
7919 Return TRUE if the passed service number is within range.
7920 ***************************************************************************/
7922 bool lp_snum_ok(int iService)
7924 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
7927 /***************************************************************************
7928 Auto-load some home services.
7929 ***************************************************************************/
7931 static void lp_add_auto_services(char *str)
7941 s = SMB_STRDUP(str);
7945 homes = lp_servicenumber(HOMES_NAME);
7947 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
7948 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
7951 if (lp_servicenumber(p) >= 0)
7954 home = get_user_home_dir(talloc_tos(), p);
7956 if (home && home[0] && homes >= 0)
7957 lp_add_home(p, homes, p, home);
7964 /***************************************************************************
7965 Auto-load one printer.
7966 ***************************************************************************/
7968 void lp_add_one_printer(const char *name, const char *comment,
7969 const char *location, void *pdata)
7971 int printers = lp_servicenumber(PRINTERS_NAME);
7974 if (lp_servicenumber(name) < 0) {
7975 lp_add_printer(name, printers);
7976 if ((i = lp_servicenumber(name)) >= 0) {
7977 string_set(&ServicePtrs[i]->comment, comment);
7978 ServicePtrs[i]->autoloaded = true;
7983 /***************************************************************************
7984 Have we loaded a services file yet?
7985 ***************************************************************************/
7987 bool lp_loaded(void)
7992 /***************************************************************************
7993 Unload unused services.
7994 ***************************************************************************/
7996 void lp_killunused(struct smbd_server_connection *sconn,
7997 bool (*snumused) (struct smbd_server_connection *, int))
8000 for (i = 0; i < iNumServices; i++) {
8004 /* don't kill autoloaded or usershare services */
8005 if ( ServicePtrs[i]->autoloaded ||
8006 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8010 if (!snumused || !snumused(sconn, i)) {
8011 free_service_byindex(i);
8017 * Kill all except autoloaded and usershare services - convenience wrapper
8019 void lp_kill_all_services(void)
8021 lp_killunused(NULL, NULL);
8024 /***************************************************************************
8026 ***************************************************************************/
8028 void lp_killservice(int iServiceIn)
8030 if (VALID(iServiceIn)) {
8031 free_service_byindex(iServiceIn);
8035 /***************************************************************************
8036 Save the curent values of all global and sDefault parameters into the
8037 defaults union. This allows swat and testparm to show only the
8038 changed (ie. non-default) parameters.
8039 ***************************************************************************/
8041 static void lp_save_defaults(void)
8044 for (i = 0; parm_table[i].label; i++) {
8045 if (i > 0 && parm_table[i].offset == parm_table[i - 1].offset
8046 && parm_table[i].p_class == parm_table[i - 1].p_class)
8048 switch (parm_table[i].type) {
8051 parm_table[i].def.lvalue = str_list_copy(
8052 NULL, *(const char ***)lp_parm_ptr(NULL, &parm_table[i]));
8056 parm_table[i].def.svalue = SMB_STRDUP(*(char **)lp_parm_ptr(NULL, &parm_table[i]));
8060 parm_table[i].def.bvalue =
8061 *(bool *)lp_parm_ptr(NULL, &parm_table[i]);
8064 parm_table[i].def.cvalue =
8065 *(char *)lp_parm_ptr(NULL, &parm_table[i]);
8071 parm_table[i].def.ivalue =
8072 *(int *)lp_parm_ptr(NULL, &parm_table[i]);
8078 defaults_saved = true;
8081 /***********************************************************
8082 If we should send plaintext/LANMAN passwords in the clinet
8083 ************************************************************/
8085 static void set_allowed_client_auth(void)
8087 if (Globals.bClientNTLMv2Auth) {
8088 Globals.bClientLanManAuth = false;
8090 if (!Globals.bClientLanManAuth) {
8091 Globals.bClientPlaintextAuth = false;
8095 /***************************************************************************
8097 The following code allows smbd to read a user defined share file.
8098 Yes, this is my intent. Yes, I'm comfortable with that...
8100 THE FOLLOWING IS SECURITY CRITICAL CODE.
8102 It washes your clothes, it cleans your house, it guards you while you sleep...
8103 Do not f%^k with it....
8104 ***************************************************************************/
8106 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8108 /***************************************************************************
8109 Check allowed stat state of a usershare file.
8110 Ensure we print out who is dicking with us so the admin can
8111 get their sorry ass fired.
8112 ***************************************************************************/
8114 static bool check_usershare_stat(const char *fname,
8115 const SMB_STRUCT_STAT *psbuf)
8117 if (!S_ISREG(psbuf->st_ex_mode)) {
8118 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8119 "not a regular file\n",
8120 fname, (unsigned int)psbuf->st_ex_uid ));
8124 /* Ensure this doesn't have the other write bit set. */
8125 if (psbuf->st_ex_mode & S_IWOTH) {
8126 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8127 "public write. Refusing to allow as a usershare file.\n",
8128 fname, (unsigned int)psbuf->st_ex_uid ));
8132 /* Should be 10k or less. */
8133 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8134 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8135 "too large (%u) to be a user share file.\n",
8136 fname, (unsigned int)psbuf->st_ex_uid,
8137 (unsigned int)psbuf->st_ex_size ));
8144 /***************************************************************************
8145 Parse the contents of a usershare file.
8146 ***************************************************************************/
8148 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8149 SMB_STRUCT_STAT *psbuf,
8150 const char *servicename,
8154 char **pp_sharepath,
8156 char **pp_cp_servicename,
8157 struct security_descriptor **ppsd,
8160 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8161 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8164 SMB_STRUCT_STAT sbuf;
8165 char *sharepath = NULL;
8166 char *comment = NULL;
8168 *pp_sharepath = NULL;
8171 *pallow_guest = false;
8174 return USERSHARE_MALFORMED_FILE;
8177 if (strcmp(lines[0], "#VERSION 1") == 0) {
8179 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8182 return USERSHARE_MALFORMED_FILE;
8185 return USERSHARE_BAD_VERSION;
8188 if (strncmp(lines[1], "path=", 5) != 0) {
8189 return USERSHARE_MALFORMED_PATH;
8192 sharepath = talloc_strdup(ctx, &lines[1][5]);
8194 return USERSHARE_POSIX_ERR;
8196 trim_string(sharepath, " ", " ");
8198 if (strncmp(lines[2], "comment=", 8) != 0) {
8199 return USERSHARE_MALFORMED_COMMENT_DEF;
8202 comment = talloc_strdup(ctx, &lines[2][8]);
8204 return USERSHARE_POSIX_ERR;
8206 trim_string(comment, " ", " ");
8207 trim_char(comment, '"', '"');
8209 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8210 return USERSHARE_MALFORMED_ACL_DEF;
8213 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8214 return USERSHARE_ACL_ERR;
8218 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8219 return USERSHARE_MALFORMED_ACL_DEF;
8221 if (lines[4][9] == 'y') {
8222 *pallow_guest = true;
8225 /* Backwards compatible extension to file version #2. */
8227 if (strncmp(lines[5], "sharename=", 10) != 0) {
8228 return USERSHARE_MALFORMED_SHARENAME_DEF;
8230 if (!strequal(&lines[5][10], servicename)) {
8231 return USERSHARE_BAD_SHARENAME;
8233 *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
8234 if (!*pp_cp_servicename) {
8235 return USERSHARE_POSIX_ERR;
8240 if (*pp_cp_servicename == NULL) {
8241 *pp_cp_servicename = talloc_strdup(ctx, servicename);
8242 if (!*pp_cp_servicename) {
8243 return USERSHARE_POSIX_ERR;
8247 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8248 /* Path didn't change, no checks needed. */
8249 *pp_sharepath = sharepath;
8250 *pp_comment = comment;
8251 return USERSHARE_OK;
8254 /* The path *must* be absolute. */
8255 if (sharepath[0] != '/') {
8256 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8257 servicename, sharepath));
8258 return USERSHARE_PATH_NOT_ABSOLUTE;
8261 /* If there is a usershare prefix deny list ensure one of these paths
8262 doesn't match the start of the user given path. */
8263 if (prefixdenylist) {
8265 for ( i=0; prefixdenylist[i]; i++ ) {
8266 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8267 servicename, i, prefixdenylist[i], sharepath ));
8268 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8269 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8270 "usershare prefix deny list entries.\n",
8271 servicename, sharepath));
8272 return USERSHARE_PATH_IS_DENIED;
8277 /* If there is a usershare prefix allow list ensure one of these paths
8278 does match the start of the user given path. */
8280 if (prefixallowlist) {
8282 for ( i=0; prefixallowlist[i]; i++ ) {
8283 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8284 servicename, i, prefixallowlist[i], sharepath ));
8285 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8289 if (prefixallowlist[i] == NULL) {
8290 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8291 "usershare prefix allow list entries.\n",
8292 servicename, sharepath));
8293 return USERSHARE_PATH_NOT_ALLOWED;
8297 /* Ensure this is pointing to a directory. */
8298 dp = opendir(sharepath);
8301 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8302 servicename, sharepath));
8303 return USERSHARE_PATH_NOT_DIRECTORY;
8306 /* Ensure the owner of the usershare file has permission to share
8309 if (sys_stat(sharepath, &sbuf, false) == -1) {
8310 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8311 servicename, sharepath, strerror(errno) ));
8313 return USERSHARE_POSIX_ERR;
8318 if (!S_ISDIR(sbuf.st_ex_mode)) {
8319 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8320 servicename, sharepath ));
8321 return USERSHARE_PATH_NOT_DIRECTORY;
8324 /* Check if sharing is restricted to owner-only. */
8325 /* psbuf is the stat of the usershare definition file,
8326 sbuf is the stat of the target directory to be shared. */
8328 if (lp_usershare_owner_only()) {
8329 /* root can share anything. */
8330 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8331 return USERSHARE_PATH_NOT_ALLOWED;
8335 *pp_sharepath = sharepath;
8336 *pp_comment = comment;
8337 return USERSHARE_OK;
8340 /***************************************************************************
8341 Deal with a usershare file.
8344 -1 - Bad name, invalid contents.
8345 - service name already existed and not a usershare, problem
8346 with permissions to share directory etc.
8347 ***************************************************************************/
8349 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8351 SMB_STRUCT_STAT sbuf;
8352 SMB_STRUCT_STAT lsbuf;
8354 char *sharepath = NULL;
8355 char *comment = NULL;
8356 char *cp_service_name = NULL;
8357 char **lines = NULL;
8361 TALLOC_CTX *ctx = talloc_stackframe();
8362 struct security_descriptor *psd = NULL;
8363 bool guest_ok = false;
8364 char *canon_name = NULL;
8365 bool added_service = false;
8368 /* Ensure share name doesn't contain invalid characters. */
8369 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8370 DEBUG(0,("process_usershare_file: share name %s contains "
8371 "invalid characters (any of %s)\n",
8372 file_name, INVALID_SHARENAME_CHARS ));
8376 canon_name = canonicalize_servicename(ctx, file_name);
8381 fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
8386 /* Minimize the race condition by doing an lstat before we
8387 open and fstat. Ensure this isn't a symlink link. */
8389 if (sys_lstat(fname, &lsbuf, false) != 0) {
8390 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8391 fname, strerror(errno) ));
8395 /* This must be a regular file, not a symlink, directory or
8396 other strange filetype. */
8397 if (!check_usershare_stat(fname, &lsbuf)) {
8405 status = dbwrap_fetch_bystring(ServiceHash, canon_name,
8410 if (NT_STATUS_IS_OK(status) &&
8411 (data.dptr != NULL) &&
8412 (data.dsize == sizeof(iService))) {
8413 memcpy(&iService, data.dptr, sizeof(iService));
8417 if (iService != -1 &&
8418 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8419 &lsbuf.st_ex_mtime) == 0) {
8420 /* Nothing changed - Mark valid and return. */
8421 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8423 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8428 /* Try and open the file read only - no symlinks allowed. */
8430 fd = open(fname, O_RDONLY|O_NOFOLLOW, 0);
8432 fd = open(fname, O_RDONLY, 0);
8436 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8437 fname, strerror(errno) ));
8441 /* Now fstat to be *SURE* it's a regular file. */
8442 if (sys_fstat(fd, &sbuf, false) != 0) {
8444 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8445 fname, strerror(errno) ));
8449 /* Is it the same dev/inode as was lstated ? */
8450 if (!check_same_stat(&lsbuf, &sbuf)) {
8452 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8453 "Symlink spoofing going on ?\n", fname ));
8457 /* This must be a regular file, not a symlink, directory or
8458 other strange filetype. */
8459 if (!check_usershare_stat(fname, &sbuf)) {
8463 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8466 if (lines == NULL) {
8467 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8468 fname, (unsigned int)sbuf.st_ex_uid ));
8472 if (parse_usershare_file(ctx, &sbuf, file_name,
8473 iService, lines, numlines, &sharepath,
8474 &comment, &cp_service_name,
8475 &psd, &guest_ok) != USERSHARE_OK) {
8479 /* Everything ok - add the service possibly using a template. */
8481 const struct loadparm_service *sp = &sDefault;
8482 if (snum_template != -1) {
8483 sp = ServicePtrs[snum_template];
8486 if ((iService = add_a_service(sp, cp_service_name)) < 0) {
8487 DEBUG(0, ("process_usershare_file: Failed to add "
8488 "new service %s\n", cp_service_name));
8492 added_service = true;
8494 /* Read only is controlled by usershare ACL below. */
8495 ServicePtrs[iService]->bRead_only = false;
8498 /* Write the ACL of the new/modified share. */
8499 if (!set_share_security(canon_name, psd)) {
8500 DEBUG(0, ("process_usershare_file: Failed to set share "
8501 "security for user share %s\n",
8506 /* If from a template it may be marked invalid. */
8507 ServicePtrs[iService]->valid = true;
8509 /* Set the service as a valid usershare. */
8510 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8512 /* Set guest access. */
8513 if (lp_usershare_allow_guests()) {
8514 ServicePtrs[iService]->bGuest_ok = guest_ok;
8517 /* And note when it was loaded. */
8518 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8519 string_set(&ServicePtrs[iService]->szPath, sharepath);
8520 string_set(&ServicePtrs[iService]->comment, comment);
8526 if (ret == -1 && iService != -1 && added_service) {
8527 lp_remove_service(iService);
8535 /***************************************************************************
8536 Checks if a usershare entry has been modified since last load.
8537 ***************************************************************************/
8539 static bool usershare_exists(int iService, struct timespec *last_mod)
8541 SMB_STRUCT_STAT lsbuf;
8542 const char *usersharepath = Globals.szUsersharePath;
8545 if (asprintf(&fname, "%s/%s",
8547 ServicePtrs[iService]->szService) < 0) {
8551 if (sys_lstat(fname, &lsbuf, false) != 0) {
8556 if (!S_ISREG(lsbuf.st_ex_mode)) {
8562 *last_mod = lsbuf.st_ex_mtime;
8566 /***************************************************************************
8567 Load a usershare service by name. Returns a valid servicenumber or -1.
8568 ***************************************************************************/
8570 int load_usershare_service(const char *servicename)
8572 SMB_STRUCT_STAT sbuf;
8573 const char *usersharepath = Globals.szUsersharePath;
8574 int max_user_shares = Globals.iUsershareMaxShares;
8575 int snum_template = -1;
8577 if (*usersharepath == 0 || max_user_shares == 0) {
8581 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8582 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8583 usersharepath, strerror(errno) ));
8587 if (!S_ISDIR(sbuf.st_ex_mode)) {
8588 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8594 * This directory must be owned by root, and have the 't' bit set.
8595 * It also must not be writable by "other".
8599 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8601 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8603 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8604 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8609 /* Ensure the template share exists if it's set. */
8610 if (Globals.szUsershareTemplateShare[0]) {
8611 /* We can't use lp_servicenumber here as we are recommending that
8612 template shares have -valid=false set. */
8613 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8614 if (ServicePtrs[snum_template]->szService &&
8615 strequal(ServicePtrs[snum_template]->szService,
8616 Globals.szUsershareTemplateShare)) {
8621 if (snum_template == -1) {
8622 DEBUG(0,("load_usershare_service: usershare template share %s "
8623 "does not exist.\n",
8624 Globals.szUsershareTemplateShare ));
8629 return process_usershare_file(usersharepath, servicename, snum_template);
8632 /***************************************************************************
8633 Load all user defined shares from the user share directory.
8634 We only do this if we're enumerating the share list.
8635 This is the function that can delete usershares that have
8637 ***************************************************************************/
8639 int load_usershare_shares(struct smbd_server_connection *sconn,
8640 bool (*snumused) (struct smbd_server_connection *, int))
8643 SMB_STRUCT_STAT sbuf;
8645 int num_usershares = 0;
8646 int max_user_shares = Globals.iUsershareMaxShares;
8647 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8648 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8649 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8651 int snum_template = -1;
8652 const char *usersharepath = Globals.szUsersharePath;
8653 int ret = lp_numservices();
8654 TALLOC_CTX *tmp_ctx;
8656 if (max_user_shares == 0 || *usersharepath == '\0') {
8657 return lp_numservices();
8660 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8661 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8662 usersharepath, strerror(errno) ));
8667 * This directory must be owned by root, and have the 't' bit set.
8668 * It also must not be writable by "other".
8672 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8674 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8676 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8677 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8682 /* Ensure the template share exists if it's set. */
8683 if (Globals.szUsershareTemplateShare[0]) {
8684 /* We can't use lp_servicenumber here as we are recommending that
8685 template shares have -valid=false set. */
8686 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8687 if (ServicePtrs[snum_template]->szService &&
8688 strequal(ServicePtrs[snum_template]->szService,
8689 Globals.szUsershareTemplateShare)) {
8694 if (snum_template == -1) {
8695 DEBUG(0,("load_usershare_shares: usershare template share %s "
8696 "does not exist.\n",
8697 Globals.szUsershareTemplateShare ));
8702 /* Mark all existing usershares as pending delete. */
8703 for (iService = iNumServices - 1; iService >= 0; iService--) {
8704 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8705 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8709 dp = opendir(usersharepath);
8711 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8712 usersharepath, strerror(errno) ));
8716 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8718 num_dir_entries++ ) {
8720 const char *n = de->d_name;
8722 /* Ignore . and .. */
8724 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8730 /* Temporary file used when creating a share. */
8731 num_tmp_dir_entries++;
8734 /* Allow 20% tmp entries. */
8735 if (num_tmp_dir_entries > allowed_tmp_entries) {
8736 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8737 "in directory %s\n",
8738 num_tmp_dir_entries, usersharepath));
8742 r = process_usershare_file(usersharepath, n, snum_template);
8744 /* Update the services count. */
8746 if (num_usershares >= max_user_shares) {
8747 DEBUG(0,("load_usershare_shares: max user shares reached "
8748 "on file %s in directory %s\n",
8749 n, usersharepath ));
8752 } else if (r == -1) {
8753 num_bad_dir_entries++;
8756 /* Allow 20% bad entries. */
8757 if (num_bad_dir_entries > allowed_bad_entries) {
8758 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8759 "in directory %s\n",
8760 num_bad_dir_entries, usersharepath));
8764 /* Allow 20% bad entries. */
8765 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
8766 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8767 "in directory %s\n",
8768 num_dir_entries, usersharepath));
8775 /* Sweep through and delete any non-refreshed usershares that are
8776 not currently in use. */
8777 tmp_ctx = talloc_stackframe();
8778 for (iService = iNumServices - 1; iService >= 0; iService--) {
8779 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
8782 if (snumused && snumused(sconn, iService)) {
8786 servname = lp_servicename(tmp_ctx, iService);
8788 /* Remove from the share ACL db. */
8789 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8791 delete_share_security(servname);
8792 free_service_byindex(iService);
8795 talloc_free(tmp_ctx);
8797 return lp_numservices();
8800 /********************************************************
8801 Destroy global resources allocated in this file
8802 ********************************************************/
8804 void gfree_loadparm(void)
8810 /* Free resources allocated to services */
8812 for ( i = 0; i < iNumServices; i++ ) {
8814 free_service_byindex(i);
8818 SAFE_FREE( ServicePtrs );
8821 /* Now release all resources allocated to global
8822 parameters and the default service */
8824 free_global_parameters();
8828 /***************************************************************************
8829 Allow client apps to specify that they are a client
8830 ***************************************************************************/
8831 static void lp_set_in_client(bool b)
8837 /***************************************************************************
8838 Determine if we're running in a client app
8839 ***************************************************************************/
8840 static bool lp_is_in_client(void)
8845 /***************************************************************************
8846 Load the services array from the services file. Return true on success,
8848 ***************************************************************************/
8850 static bool lp_load_ex(const char *pszFname,
8854 bool initialize_globals,
8855 bool allow_include_registry,
8856 bool load_all_shares)
8863 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
8865 bInGlobalSection = true;
8866 bGlobalOnly = global_only;
8867 bAllowIncludeRegistry = allow_include_registry;
8869 init_globals(initialize_globals);
8873 if (save_defaults) {
8878 if (!initialize_globals) {
8879 free_param_opts(&Globals.param_opt);
8880 apply_lp_set_cmdline();
8883 lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
8885 /* We get sections first, so have to start 'behind' to make up */
8888 if (lp_config_backend_is_file()) {
8889 n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
8890 current_user_info.domain,
8893 smb_panic("lp_load_ex: out of memory");
8896 add_to_file_list(pszFname, n2);
8898 bRetval = pm_process(n2, do_section, do_parameter, NULL);
8901 /* finish up the last section */
8902 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
8904 if (iServiceIndex >= 0) {
8905 bRetval = service_ok(iServiceIndex);
8909 if (lp_config_backend_is_registry()) {
8910 /* config backend changed to registry in config file */
8912 * We need to use this extra global variable here to
8913 * survive restart: init_globals uses this as a default
8914 * for ConfigBackend. Otherwise, init_globals would
8915 * send us into an endless loop here.
8917 config_backend = CONFIG_BACKEND_REGISTRY;
8919 DEBUG(1, ("lp_load_ex: changing to config backend "
8922 lp_kill_all_services();
8923 return lp_load_ex(pszFname, global_only, save_defaults,
8924 add_ipc, initialize_globals,
8925 allow_include_registry,
8928 } else if (lp_config_backend_is_registry()) {
8929 bRetval = process_registry_globals();
8931 DEBUG(0, ("Illegal config backend given: %d\n",
8932 lp_config_backend()));
8936 if (bRetval && lp_registry_shares()) {
8937 if (load_all_shares) {
8938 bRetval = process_registry_shares();
8940 bRetval = reload_registry_shares();
8945 char *serv = lp_auto_services(talloc_tos());
8946 lp_add_auto_services(serv);
8951 /* When 'restrict anonymous = 2' guest connections to ipc$
8953 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
8954 if ( lp_enable_asu_support() ) {
8955 lp_add_ipc("ADMIN$", false);
8959 set_allowed_client_auth();
8961 if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) {
8962 DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
8963 lp_passwordserver()));
8968 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
8969 /* if bWINSsupport is true and we are in the client */
8970 if (lp_is_in_client() && Globals.bWINSsupport) {
8971 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
8976 fault_configure(smb_panic_s3);
8978 bAllowIncludeRegistry = true;
8983 bool lp_load(const char *pszFname,
8987 bool initialize_globals)
8989 return lp_load_ex(pszFname,
8994 true, /* allow_include_registry */
8995 false); /* load_all_shares*/
8998 bool lp_load_initial_only(const char *pszFname)
9000 return lp_load_ex(pszFname,
9001 true, /* global only */
9002 false, /* save_defaults */
9003 false, /* add_ipc */
9004 true, /* initialize_globals */
9005 false, /* allow_include_registry */
9006 false); /* load_all_shares*/
9010 * most common lp_load wrapper, loading only the globals
9012 bool lp_load_global(const char *file_name)
9014 return lp_load_ex(file_name,
9015 true, /* global_only */
9016 false, /* save_defaults */
9017 false, /* add_ipc */
9018 true, /* initialize_globals */
9019 true, /* allow_include_registry */
9020 false); /* load_all_shares*/
9024 * lp_load wrapper, especially for clients
9026 bool lp_load_client(const char *file_name)
9028 lp_set_in_client(true);
9030 return lp_load_global(file_name);
9034 * lp_load wrapper, loading only globals, but intended
9035 * for subsequent calls, not reinitializing the globals
9038 bool lp_load_global_no_reinit(const char *file_name)
9040 return lp_load_ex(file_name,
9041 true, /* global_only */
9042 false, /* save_defaults */
9043 false, /* add_ipc */
9044 false, /* initialize_globals */
9045 true, /* allow_include_registry */
9046 false); /* load_all_shares*/
9050 * lp_load wrapper, especially for clients, no reinitialization
9052 bool lp_load_client_no_reinit(const char *file_name)
9054 lp_set_in_client(true);
9056 return lp_load_global_no_reinit(file_name);
9059 bool lp_load_with_registry_shares(const char *pszFname,
9063 bool initialize_globals)
9065 return lp_load_ex(pszFname,
9070 true, /* allow_include_registry */
9071 true); /* load_all_shares*/
9074 /***************************************************************************
9075 Return the max number of services.
9076 ***************************************************************************/
9078 int lp_numservices(void)
9080 return (iNumServices);
9083 /***************************************************************************
9084 Display the contents of the services array in human-readable form.
9085 ***************************************************************************/
9087 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9092 defaults_saved = false;
9096 dump_a_service(&sDefault, f);
9098 for (iService = 0; iService < maxtoprint; iService++) {
9100 lp_dump_one(f, show_defaults, iService);
9104 /***************************************************************************
9105 Display the contents of one service in human-readable form.
9106 ***************************************************************************/
9108 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9111 if (ServicePtrs[snum]->szService[0] == '\0')
9113 dump_a_service(ServicePtrs[snum], f);
9117 /***************************************************************************
9118 Return the number of the service with the given name, or -1 if it doesn't
9119 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9120 getservicebyname()! This works ONLY if all services have been loaded, and
9121 does not copy the found service.
9122 ***************************************************************************/
9124 int lp_servicenumber(const char *pszServiceName)
9127 fstring serviceName;
9129 if (!pszServiceName) {
9130 return GLOBAL_SECTION_SNUM;
9133 for (iService = iNumServices - 1; iService >= 0; iService--) {
9134 if (VALID(iService) && ServicePtrs[iService]->szService) {
9136 * The substitution here is used to support %U is
9139 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9140 standard_sub_basic(get_current_username(),
9141 current_user_info.domain,
9142 serviceName,sizeof(serviceName));
9143 if (strequal(serviceName, pszServiceName)) {
9149 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9150 struct timespec last_mod;
9152 if (!usershare_exists(iService, &last_mod)) {
9153 /* Remove the share security tdb entry for it. */
9154 delete_share_security(lp_servicename(talloc_tos(), iService));
9155 /* Remove it from the array. */
9156 free_service_byindex(iService);
9157 /* Doesn't exist anymore. */
9158 return GLOBAL_SECTION_SNUM;
9161 /* Has it been modified ? If so delete and reload. */
9162 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9164 /* Remove it from the array. */
9165 free_service_byindex(iService);
9166 /* and now reload it. */
9167 iService = load_usershare_service(pszServiceName);
9172 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9173 return GLOBAL_SECTION_SNUM;
9179 /*******************************************************************
9180 A useful volume label function.
9181 ********************************************************************/
9183 const char *volume_label(TALLOC_CTX *ctx, int snum)
9186 const char *label = lp_volume(ctx, snum);
9188 label = lp_servicename(ctx, snum);
9191 /* This returns a 33 byte guarenteed null terminated string. */
9192 ret = talloc_strndup(ctx, label, 32);
9199 /*******************************************************************
9200 Get the default server type we will announce as via nmbd.
9201 ********************************************************************/
9203 int lp_default_server_announce(void)
9205 int default_server_announce = 0;
9206 default_server_announce |= SV_TYPE_WORKSTATION;
9207 default_server_announce |= SV_TYPE_SERVER;
9208 default_server_announce |= SV_TYPE_SERVER_UNIX;
9210 /* note that the flag should be set only if we have a
9211 printer service but nmbd doesn't actually load the
9212 services so we can't tell --jerry */
9214 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9216 default_server_announce |= SV_TYPE_SERVER_NT;
9217 default_server_announce |= SV_TYPE_NT;
9219 switch (lp_server_role()) {
9220 case ROLE_DOMAIN_MEMBER:
9221 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9223 case ROLE_DOMAIN_PDC:
9224 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9226 case ROLE_DOMAIN_BDC:
9227 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9229 case ROLE_STANDALONE:
9233 if (lp_time_server())
9234 default_server_announce |= SV_TYPE_TIME_SOURCE;
9236 if (lp_host_msdfs())
9237 default_server_announce |= SV_TYPE_DFS_SERVER;
9239 return default_server_announce;
9242 /***********************************************************
9243 If we are PDC then prefer us as DMB
9244 ************************************************************/
9246 bool lp_domain_master(void)
9248 if (Globals.domain_master == Auto)
9249 return (lp_server_role() == ROLE_DOMAIN_PDC);
9251 return (bool)Globals.domain_master;
9254 /***********************************************************
9255 If we are PDC then prefer us as DMB
9256 ************************************************************/
9258 static bool lp_domain_master_true_or_auto(void)
9260 if (Globals.domain_master) /* auto or yes */
9266 /***********************************************************
9267 If we are DMB then prefer us as LMB
9268 ************************************************************/
9270 bool lp_preferred_master(void)
9272 if (Globals.iPreferredMaster == Auto)
9273 return (lp_local_master() && lp_domain_master());
9275 return (bool)Globals.iPreferredMaster;
9278 /*******************************************************************
9280 ********************************************************************/
9282 void lp_remove_service(int snum)
9284 ServicePtrs[snum]->valid = false;
9285 invalid_services[num_invalid_services++] = snum;
9288 /*******************************************************************
9290 ********************************************************************/
9292 void lp_copy_service(int snum, const char *new_name)
9294 do_section(new_name, NULL);
9296 snum = lp_servicenumber(new_name);
9298 char *name = lp_servicename(talloc_tos(), snum);
9299 lp_do_parameter(snum, "copy", name);
9304 const char *lp_printername(TALLOC_CTX *ctx, int snum)
9306 const char *ret = lp__printername(talloc_tos(), snum);
9307 if (ret == NULL || *ret == '\0') {
9308 ret = lp_const_servicename(snum);
9315 /***********************************************************
9316 Allow daemons such as winbindd to fix their logfile name.
9317 ************************************************************/
9319 void lp_set_logfile(const char *name)
9321 string_set(&Globals.logfile, name);
9322 debug_set_logfile(name);
9325 /*******************************************************************
9326 Return the max print jobs per queue.
9327 ********************************************************************/
9329 int lp_maxprintjobs(int snum)
9331 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9332 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9333 maxjobs = PRINT_MAX_JOBID - 1;
9338 const char *lp_printcapname(void)
9340 if ((Globals.szPrintcapname != NULL) &&
9341 (Globals.szPrintcapname[0] != '\0'))
9342 return Globals.szPrintcapname;
9344 if (sDefault.iPrinting == PRINT_CUPS) {
9352 if (sDefault.iPrinting == PRINT_BSD)
9353 return "/etc/printcap";
9355 return PRINTCAP_NAME;
9358 static uint32 spoolss_state;
9360 bool lp_disable_spoolss( void )
9362 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9363 spoolss_state = lp__disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9365 return spoolss_state == SVCCTL_STOPPED ? true : false;
9368 void lp_set_spoolss_state( uint32 state )
9370 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9372 spoolss_state = state;
9375 uint32 lp_get_spoolss_state( void )
9377 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9380 /*******************************************************************
9381 Ensure we don't use sendfile if server smb signing is active.
9382 ********************************************************************/
9384 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9386 bool sign_active = false;
9388 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9389 if (get_Protocol() < PROTOCOL_NT1) {
9392 if (signing_state) {
9393 sign_active = smb_signing_is_active(signing_state);
9395 return (lp__use_sendfile(snum) &&
9396 (get_remote_arch() != RA_WIN95) &&
9400 /*******************************************************************
9401 Turn off sendfile if we find the underlying OS doesn't support it.
9402 ********************************************************************/
9404 void set_use_sendfile(int snum, bool val)
9406 if (LP_SNUM_OK(snum))
9407 ServicePtrs[snum]->bUseSendfile = val;
9409 sDefault.bUseSendfile = val;
9412 /*******************************************************************
9413 Turn off storing DOS attributes if this share doesn't support it.
9414 ********************************************************************/
9416 void set_store_dos_attributes(int snum, bool val)
9418 if (!LP_SNUM_OK(snum))
9420 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9423 void lp_set_mangling_method(const char *new_method)
9425 string_set(&Globals.szManglingMethod, new_method);
9428 /*******************************************************************
9429 Global state for POSIX pathname processing.
9430 ********************************************************************/
9432 static bool posix_pathnames;
9434 bool lp_posix_pathnames(void)
9436 return posix_pathnames;
9439 /*******************************************************************
9440 Change everything needed to ensure POSIX pathname processing (currently
9442 ********************************************************************/
9444 void lp_set_posix_pathnames(void)
9446 posix_pathnames = true;
9449 /*******************************************************************
9450 Global state for POSIX lock processing - CIFS unix extensions.
9451 ********************************************************************/
9453 bool posix_default_lock_was_set;
9454 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9456 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9458 if (posix_default_lock_was_set) {
9459 return posix_cifsx_locktype;
9461 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9465 /*******************************************************************
9466 ********************************************************************/
9468 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9470 posix_default_lock_was_set = true;
9471 posix_cifsx_locktype = val;
9474 int lp_min_receive_file_size(void)
9476 if (Globals.iminreceivefile < 0) {
9479 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9482 /*******************************************************************
9483 If socket address is an empty character string, it is necessary to
9484 define it as "0.0.0.0".
9485 ********************************************************************/
9487 const char *lp_socket_address(void)
9489 char *sock_addr = Globals.szSocketAddress;
9491 if (sock_addr[0] == '\0'){
9492 string_set(&Globals.szSocketAddress, "0.0.0.0");
9494 return Globals.szSocketAddress;
9497 /*******************************************************************
9498 Safe wide links checks.
9499 This helper function always verify the validity of wide links,
9500 even after a configuration file reload.
9501 ********************************************************************/
9503 static bool lp_widelinks_internal(int snum)
9505 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9506 sDefault.bWidelinks);
9509 void widelinks_warning(int snum)
9511 if (lp_allow_insecure_widelinks()) {
9515 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9516 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9517 "These parameters are incompatible. "
9518 "Wide links will be disabled for this share.\n",
9519 lp_servicename(talloc_tos(), snum) ));
9523 bool lp_widelinks(int snum)
9525 /* wide links is always incompatible with unix extensions */
9526 if (lp_unix_extensions()) {
9528 * Unless we have "allow insecure widelinks"
9531 if (!lp_allow_insecure_widelinks()) {
9536 return lp_widelinks_internal(snum);
9539 bool lp_writeraw(void)
9541 if (lp_async_smb_echo_handler()) {
9544 return lp__writeraw();
9547 bool lp_readraw(void)
9549 if (lp_async_smb_echo_handler()) {
9552 return lp__readraw();
9555 int lp_server_role(void)
9557 return lp_find_server_role(lp__server_role(),
9560 lp_domain_master_true_or_auto());