libcli/smb: add SMB2_HDR_CHANNEL_SEQUENCE
[Samba/gebeck_regimport.git] / source3 / param / loadparm.c
blob39097395de08f1954cfcf74041c0277614e3ec31
1 /*
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/>.
31 * Load parameters.
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.
37 * To add a parameter:
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
46 * Notes:
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
52 * careful!
56 #include "includes.h"
57 #include "system/filesys.h"
58 #include "util_tdb.h"
59 #include "lib/param/loadparm.h"
60 #include "printing.h"
61 #include "lib/smbconf/smbconf.h"
62 #include "lib/smbconf/smbconf_init.h"
64 #include "ads.h"
65 #include "../librpc/gen_ndr/svcctl.h"
66 #include "intl.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>
75 #endif
77 #ifdef HAVE_HTTPCONNECTENCRYPT
78 #include <cups/http.h>
79 #endif
81 #ifdef CLUSTER_SUPPORT
82 #include "ctdb_private.h"
83 #endif
85 bool bLoaded = false;
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
92 * from registry. */
93 #ifndef INCLUDE_REGISTRY_NAME
94 #define INCLUDE_REGISTRY_NAME "registry"
95 #endif
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; \
113 char *szRealm; \
114 char *loglevel; \
115 int iminreceivefile; \
116 char *szPrintcapname; \
117 int CupsEncrypt; \
118 int iPreferredMaster; \
119 char *szLdapMachineSuffix; \
120 char *szLdapUserSuffix; \
121 char *szLdapIdmapSuffix; \
122 char *szLdapGroupSuffix; \
123 char *szStateDir; \
124 char *szCacheDir; \
125 char *szSocketAddress; \
126 char *szUsershareTemplateShare; \
127 char *szIdmapUID; \
128 char *szIdmapGID; \
129 int winbindMaxDomainConnections; \
130 int ismb2_max_credits; \
131 char *tls_keyfile; \
132 char *tls_certfile; \
133 char *tls_cafile; \
134 char *tls_crlfile; \
135 char *tls_dhpfile; \
136 char *panic_action; \
137 int bPreferredMaster;
139 #include "param/param_global.h"
141 static struct loadparm_global Globals;
143 /* This is a default service used to prime a services structure */
144 static struct loadparm_service sDefault =
146 .valid = true,
147 .autoloaded = false,
148 .usershare = 0,
149 .usershare_last_mod = {0, 0},
150 .szService = NULL,
151 .szPath = NULL,
152 .szUsername = NULL,
153 .szInvalidUsers = NULL,
154 .szValidUsers = NULL,
155 .szAdminUsers = NULL,
156 .szCopy = NULL,
157 .szInclude = NULL,
158 .szPreExec = NULL,
159 .szPostExec = NULL,
160 .szRootPreExec = NULL,
161 .szRootPostExec = NULL,
162 .szCupsOptions = NULL,
163 .szPrintcommand = NULL,
164 .szLpqcommand = NULL,
165 .szLprmcommand = NULL,
166 .szLppausecommand = NULL,
167 .szLpresumecommand = NULL,
168 .szQueuepausecommand = NULL,
169 .szQueueresumecommand = NULL,
170 .szPrintername = NULL,
171 .szPrintjobUsername = NULL,
172 .szDontdescend = NULL,
173 .szHostsallow = NULL,
174 .szHostsdeny = NULL,
175 .szMagicScript = NULL,
176 .szMagicOutput = NULL,
177 .szVetoFiles = NULL,
178 .szHideFiles = NULL,
179 .szVetoOplockFiles = NULL,
180 .comment = NULL,
181 .force_user = NULL,
182 .force_group = NULL,
183 .readlist = NULL,
184 .writelist = NULL,
185 .volume = NULL,
186 .fstype = NULL,
187 .szVfsObjects = NULL,
188 .szMSDfsProxy = NULL,
189 .szAioWriteBehind = NULL,
190 .szDfree = NULL,
191 .iMinPrintSpace = 0,
192 .iMaxPrintJobs = 1000,
193 .iMaxReportedPrintJobs = 0,
194 .iWriteCacheSize = 0,
195 .iCreate_mask = 0744,
196 .iCreate_force_mode = 0,
197 .iSecurity_mask = 0777,
198 .iSecurity_force_mode = 0,
199 .iDir_mask = 0755,
200 .iDir_force_mode = 0,
201 .iDir_Security_mask = 0777,
202 .iDir_Security_force_mode = 0,
203 .iMaxConnections = 0,
204 .iDefaultCase = CASE_LOWER,
205 .iPrinting = DEFAULT_PRINTING,
206 .iOplockContentionLimit = 2,
207 .iCSCPolicy = 0,
208 .iBlock_size = 1024,
209 .iDfreeCacheTime = 0,
210 .bPreexecClose = false,
211 .bRootpreexecClose = false,
212 .iCaseSensitive = Auto,
213 .bCasePreserve = true,
214 .bShortCasePreserve = true,
215 .bHideDotFiles = true,
216 .bHideSpecialFiles = false,
217 .bHideUnReadable = false,
218 .bHideUnWriteableFiles = false,
219 .bBrowseable = true,
220 .bAccessBasedShareEnum = false,
221 .bAvailable = true,
222 .bRead_only = true,
223 .bNo_set_dir = true,
224 .bGuest_only = false,
225 .bAdministrative_share = false,
226 .bGuest_ok = false,
227 .bPrint_ok = false,
228 .bPrintNotifyBackchannel = true,
229 .bMap_system = false,
230 .bMap_hidden = false,
231 .bMap_archive = true,
232 .bStoreDosAttributes = false,
233 .bDmapiSupport = false,
234 .bLocking = true,
235 .iStrictLocking = Auto,
236 .bPosixLocking = true,
237 .bShareModes = true,
238 .bOpLocks = true,
239 .bKernelOplocks = false,
240 .bLevel2OpLocks = true,
241 .bOnlyUser = false,
242 .bMangledNames = true,
243 .bWidelinks = false,
244 .bSymlinks = true,
245 .bSyncAlways = false,
246 .bStrictAllocate = false,
247 .bStrictSync = false,
248 .magic_char = '~',
249 .copymap = NULL,
250 .bDeleteReadonly = false,
251 .bFakeOplocks = false,
252 .bDeleteVetoFiles = false,
253 .bDosFilemode = false,
254 .bDosFiletimes = true,
255 .bDosFiletimeResolution = false,
256 .bFakeDirCreateTimes = false,
257 .bBlockingLocks = true,
258 .bInheritPerms = false,
259 .bInheritACLS = false,
260 .bInheritOwner = false,
261 .bMSDfsRoot = false,
262 .bUseClientDriver = false,
263 .bDefaultDevmode = true,
264 .bForcePrintername = false,
265 .bNTAclSupport = true,
266 .bForceUnknownAclUser = false,
267 .bUseSendfile = false,
268 .bProfileAcls = false,
269 .bMap_acl_inherit = false,
270 .bAfs_Share = false,
271 .bEASupport = false,
272 .bAclCheckPermissions = true,
273 .bAclMapFullControl = true,
274 .bAclGroupControl = false,
275 .bChangeNotify = true,
276 .bKernelChangeNotify = true,
277 .iallocation_roundup_size = SMB_ROUNDUP_ALLOCATION_SIZE,
278 .iAioReadSize = 0,
279 .iAioWriteSize = 0,
280 .iMap_readonly = MAP_READONLY_YES,
281 #ifdef BROKEN_DIRECTORY_HANDLING
282 .iDirectoryNameCacheSize = 0,
283 #else
284 .iDirectoryNameCacheSize = 100,
285 #endif
286 .ismb_encrypt = Auto,
287 .param_opt = NULL,
288 .dummy = ""
291 /* local variables */
292 static struct loadparm_service **ServicePtrs = NULL;
293 static int iNumServices = 0;
294 static int iServiceIndex = 0;
295 static struct db_context *ServiceHash;
296 static int *invalid_services = NULL;
297 static int num_invalid_services = 0;
298 static bool bInGlobalSection = true;
299 static bool bGlobalOnly = false;
301 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
303 /* prototypes for the special type handlers */
304 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
305 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
306 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
307 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
308 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
309 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
310 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
311 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
312 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
313 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr );
314 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
315 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr);
317 static void set_allowed_client_auth(void);
319 static void add_to_file_list(const char *fname, const char *subfname);
320 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
321 static void free_param_opts(struct parmlist_entry **popts);
323 #include "lib/param/param_table.c"
325 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
327 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
328 * screen in SWAT. This is used to exclude parameters as well as to squash all
329 * parameters that have been duplicated by pseudonyms.
331 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
332 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
333 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
334 * respective views.
336 * NOTE2: Handling of duplicated (synonym) parameters:
337 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
338 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
339 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
340 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
343 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
344 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
347 static struct parm_struct parm_table[] = {
348 {N_("Base Options"), P_SEP, P_SEPARATOR},
351 .label = "dos charset",
352 .type = P_STRING,
353 .p_class = P_GLOBAL,
354 .offset = GLOBAL_VAR(dos_charset),
355 .special = handle_dos_charset,
356 .enum_list = NULL,
357 .flags = FLAG_ADVANCED
360 .label = "unix charset",
361 .type = P_STRING,
362 .p_class = P_GLOBAL,
363 .offset = GLOBAL_VAR(unix_charset),
364 .special = handle_charset,
365 .enum_list = NULL,
366 .flags = FLAG_ADVANCED
369 .label = "comment",
370 .type = P_STRING,
371 .p_class = P_LOCAL,
372 .offset = LOCAL_VAR(comment),
373 .special = NULL,
374 .enum_list = NULL,
375 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
378 .label = "path",
379 .type = P_STRING,
380 .p_class = P_LOCAL,
381 .offset = LOCAL_VAR(szPath),
382 .special = NULL,
383 .enum_list = NULL,
384 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
387 .label = "directory",
388 .type = P_STRING,
389 .p_class = P_LOCAL,
390 .offset = LOCAL_VAR(szPath),
391 .special = NULL,
392 .enum_list = NULL,
393 .flags = FLAG_HIDE,
396 .label = "workgroup",
397 .type = P_USTRING,
398 .p_class = P_GLOBAL,
399 .offset = GLOBAL_VAR(szWorkgroup),
400 .special = NULL,
401 .enum_list = NULL,
402 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
405 .label = "realm",
406 .type = P_STRING,
407 .p_class = P_GLOBAL,
408 .offset = GLOBAL_VAR(szRealm),
409 .special = handle_realm,
410 .enum_list = NULL,
411 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
414 .label = "netbios name",
415 .type = P_USTRING,
416 .p_class = P_GLOBAL,
417 .offset = GLOBAL_VAR(szNetbiosName),
418 .special = NULL,
419 .enum_list = NULL,
420 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
423 .label = "netbios aliases",
424 .type = P_LIST,
425 .p_class = P_GLOBAL,
426 .offset = GLOBAL_VAR(szNetbiosAliases),
427 .special = handle_netbios_aliases,
428 .enum_list = NULL,
429 .flags = FLAG_ADVANCED,
432 .label = "netbios scope",
433 .type = P_USTRING,
434 .p_class = P_GLOBAL,
435 .offset = GLOBAL_VAR(szNetbiosScope),
436 .special = NULL,
437 .enum_list = NULL,
438 .flags = FLAG_ADVANCED,
441 .label = "server string",
442 .type = P_STRING,
443 .p_class = P_GLOBAL,
444 .offset = GLOBAL_VAR(szServerString),
445 .special = NULL,
446 .enum_list = NULL,
447 .flags = FLAG_BASIC | FLAG_ADVANCED,
450 .label = "interfaces",
451 .type = P_LIST,
452 .p_class = P_GLOBAL,
453 .offset = GLOBAL_VAR(szInterfaces),
454 .special = NULL,
455 .enum_list = NULL,
456 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
459 .label = "bind interfaces only",
460 .type = P_BOOL,
461 .p_class = P_GLOBAL,
462 .offset = GLOBAL_VAR(bBindInterfacesOnly),
463 .special = NULL,
464 .enum_list = NULL,
465 .flags = FLAG_ADVANCED | FLAG_WIZARD,
468 .label = "config backend",
469 .type = P_ENUM,
470 .p_class = P_GLOBAL,
471 .offset = GLOBAL_VAR(ConfigBackend),
472 .special = NULL,
473 .enum_list = enum_config_backend,
474 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
477 .label = "server role",
478 .type = P_ENUM,
479 .p_class = P_GLOBAL,
480 .offset = GLOBAL_VAR(server_role),
481 .special = NULL,
482 .enum_list = enum_server_role,
483 .flags = FLAG_BASIC | FLAG_ADVANCED,
486 {N_("Security Options"), P_SEP, P_SEPARATOR},
489 .label = "security",
490 .type = P_ENUM,
491 .p_class = P_GLOBAL,
492 .offset = GLOBAL_VAR(security),
493 .special = NULL,
494 .enum_list = enum_security,
495 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
498 .label = "auth methods",
499 .type = P_LIST,
500 .p_class = P_GLOBAL,
501 .offset = GLOBAL_VAR(AuthMethods),
502 .special = NULL,
503 .enum_list = NULL,
504 .flags = FLAG_ADVANCED,
507 .label = "encrypt passwords",
508 .type = P_BOOL,
509 .p_class = P_GLOBAL,
510 .offset = GLOBAL_VAR(bEncryptPasswords),
511 .special = NULL,
512 .enum_list = NULL,
513 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
516 .label = "client schannel",
517 .type = P_ENUM,
518 .p_class = P_GLOBAL,
519 .offset = GLOBAL_VAR(clientSchannel),
520 .special = NULL,
521 .enum_list = enum_bool_auto,
522 .flags = FLAG_BASIC | FLAG_ADVANCED,
525 .label = "server schannel",
526 .type = P_ENUM,
527 .p_class = P_GLOBAL,
528 .offset = GLOBAL_VAR(serverSchannel),
529 .special = NULL,
530 .enum_list = enum_bool_auto,
531 .flags = FLAG_BASIC | FLAG_ADVANCED,
534 .label = "allow trusted domains",
535 .type = P_BOOL,
536 .p_class = P_GLOBAL,
537 .offset = GLOBAL_VAR(bAllowTrustedDomains),
538 .special = NULL,
539 .enum_list = NULL,
540 .flags = FLAG_ADVANCED,
543 .label = "map to guest",
544 .type = P_ENUM,
545 .p_class = P_GLOBAL,
546 .offset = GLOBAL_VAR(map_to_guest),
547 .special = NULL,
548 .enum_list = enum_map_to_guest,
549 .flags = FLAG_ADVANCED,
552 .label = "null passwords",
553 .type = P_BOOL,
554 .p_class = P_GLOBAL,
555 .offset = GLOBAL_VAR(bNullPasswords),
556 .special = NULL,
557 .enum_list = NULL,
558 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
561 .label = "obey pam restrictions",
562 .type = P_BOOL,
563 .p_class = P_GLOBAL,
564 .offset = GLOBAL_VAR(bObeyPamRestrictions),
565 .special = NULL,
566 .enum_list = NULL,
567 .flags = FLAG_ADVANCED,
570 .label = "password server",
571 .type = P_STRING,
572 .p_class = P_GLOBAL,
573 .offset = GLOBAL_VAR(szPasswordServer),
574 .special = NULL,
575 .enum_list = NULL,
576 .flags = FLAG_ADVANCED | FLAG_WIZARD,
579 .label = "smb passwd file",
580 .type = P_STRING,
581 .p_class = P_GLOBAL,
582 .offset = GLOBAL_VAR(szSMBPasswdFile),
583 .special = NULL,
584 .enum_list = NULL,
585 .flags = FLAG_ADVANCED,
588 .label = "private dir",
589 .type = P_STRING,
590 .p_class = P_GLOBAL,
591 .offset = GLOBAL_VAR(szPrivateDir),
592 .special = NULL,
593 .enum_list = NULL,
594 .flags = FLAG_ADVANCED,
597 .label = "private directory",
598 .type = P_STRING,
599 .p_class = P_GLOBAL,
600 .offset = GLOBAL_VAR(szPrivateDir),
601 .special = NULL,
602 .enum_list = NULL,
603 .flags = FLAG_HIDE,
606 .label = "passdb backend",
607 .type = P_STRING,
608 .p_class = P_GLOBAL,
609 .offset = GLOBAL_VAR(passdb_backend),
610 .special = NULL,
611 .enum_list = NULL,
612 .flags = FLAG_ADVANCED | FLAG_WIZARD,
615 .label = "algorithmic rid base",
616 .type = P_INTEGER,
617 .p_class = P_GLOBAL,
618 .offset = GLOBAL_VAR(AlgorithmicRidBase),
619 .special = NULL,
620 .enum_list = NULL,
621 .flags = FLAG_ADVANCED,
624 .label = "root directory",
625 .type = P_STRING,
626 .p_class = P_GLOBAL,
627 .offset = GLOBAL_VAR(szRootdir),
628 .special = NULL,
629 .enum_list = NULL,
630 .flags = FLAG_ADVANCED,
633 .label = "root dir",
634 .type = P_STRING,
635 .p_class = P_GLOBAL,
636 .offset = GLOBAL_VAR(szRootdir),
637 .special = NULL,
638 .enum_list = NULL,
639 .flags = FLAG_HIDE,
642 .label = "root",
643 .type = P_STRING,
644 .p_class = P_GLOBAL,
645 .offset = GLOBAL_VAR(szRootdir),
646 .special = NULL,
647 .enum_list = NULL,
648 .flags = FLAG_HIDE,
651 .label = "guest account",
652 .type = P_STRING,
653 .p_class = P_GLOBAL,
654 .offset = GLOBAL_VAR(szGuestaccount),
655 .special = NULL,
656 .enum_list = NULL,
657 .flags = FLAG_BASIC | FLAG_ADVANCED,
660 .label = "enable privileges",
661 .type = P_BOOL,
662 .p_class = P_GLOBAL,
663 .offset = GLOBAL_VAR(bEnablePrivileges),
664 .special = NULL,
665 .enum_list = NULL,
666 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
670 .label = "pam password change",
671 .type = P_BOOL,
672 .p_class = P_GLOBAL,
673 .offset = GLOBAL_VAR(bPamPasswordChange),
674 .special = NULL,
675 .enum_list = NULL,
676 .flags = FLAG_ADVANCED,
679 .label = "passwd program",
680 .type = P_STRING,
681 .p_class = P_GLOBAL,
682 .offset = GLOBAL_VAR(szPasswdProgram),
683 .special = NULL,
684 .enum_list = NULL,
685 .flags = FLAG_ADVANCED,
688 .label = "passwd chat",
689 .type = P_STRING,
690 .p_class = P_GLOBAL,
691 .offset = GLOBAL_VAR(szPasswdChat),
692 .special = NULL,
693 .enum_list = NULL,
694 .flags = FLAG_ADVANCED,
697 .label = "passwd chat debug",
698 .type = P_BOOL,
699 .p_class = P_GLOBAL,
700 .offset = GLOBAL_VAR(bPasswdChatDebug),
701 .special = NULL,
702 .enum_list = NULL,
703 .flags = FLAG_ADVANCED,
706 .label = "passwd chat timeout",
707 .type = P_INTEGER,
708 .p_class = P_GLOBAL,
709 .offset = GLOBAL_VAR(iPasswdChatTimeout),
710 .special = NULL,
711 .enum_list = NULL,
712 .flags = FLAG_ADVANCED,
715 .label = "check password script",
716 .type = P_STRING,
717 .p_class = P_GLOBAL,
718 .offset = GLOBAL_VAR(szCheckPasswordScript),
719 .special = NULL,
720 .enum_list = NULL,
721 .flags = FLAG_ADVANCED,
724 .label = "username map",
725 .type = P_STRING,
726 .p_class = P_GLOBAL,
727 .offset = GLOBAL_VAR(szUsernameMap),
728 .special = NULL,
729 .enum_list = NULL,
730 .flags = FLAG_ADVANCED,
733 .label = "password level",
734 .type = P_INTEGER,
735 .p_class = P_GLOBAL,
736 .offset = GLOBAL_VAR(pwordlevel),
737 .special = NULL,
738 .enum_list = NULL,
739 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
742 .label = "username level",
743 .type = P_INTEGER,
744 .p_class = P_GLOBAL,
745 .offset = GLOBAL_VAR(unamelevel),
746 .special = NULL,
747 .enum_list = NULL,
748 .flags = FLAG_ADVANCED,
751 .label = "unix password sync",
752 .type = P_BOOL,
753 .p_class = P_GLOBAL,
754 .offset = GLOBAL_VAR(bUnixPasswdSync),
755 .special = NULL,
756 .enum_list = NULL,
757 .flags = FLAG_ADVANCED,
760 .label = "restrict anonymous",
761 .type = P_INTEGER,
762 .p_class = P_GLOBAL,
763 .offset = GLOBAL_VAR(restrict_anonymous),
764 .special = NULL,
765 .enum_list = NULL,
766 .flags = FLAG_ADVANCED,
769 .label = "lanman auth",
770 .type = P_BOOL,
771 .p_class = P_GLOBAL,
772 .offset = GLOBAL_VAR(bLanmanAuth),
773 .special = NULL,
774 .enum_list = NULL,
775 .flags = FLAG_ADVANCED,
778 .label = "ntlm auth",
779 .type = P_BOOL,
780 .p_class = P_GLOBAL,
781 .offset = GLOBAL_VAR(bNTLMAuth),
782 .special = NULL,
783 .enum_list = NULL,
784 .flags = FLAG_ADVANCED,
787 .label = "client NTLMv2 auth",
788 .type = P_BOOL,
789 .p_class = P_GLOBAL,
790 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
791 .special = NULL,
792 .enum_list = NULL,
793 .flags = FLAG_ADVANCED,
796 .label = "client lanman auth",
797 .type = P_BOOL,
798 .p_class = P_GLOBAL,
799 .offset = GLOBAL_VAR(bClientLanManAuth),
800 .special = NULL,
801 .enum_list = NULL,
802 .flags = FLAG_ADVANCED,
805 .label = "client plaintext auth",
806 .type = P_BOOL,
807 .p_class = P_GLOBAL,
808 .offset = GLOBAL_VAR(bClientPlaintextAuth),
809 .special = NULL,
810 .enum_list = NULL,
811 .flags = FLAG_ADVANCED,
814 .label = "client use spnego principal",
815 .type = P_BOOL,
816 .p_class = P_GLOBAL,
817 .offset = GLOBAL_VAR(client_use_spnego_principal),
818 .special = NULL,
819 .enum_list = NULL,
820 .flags = FLAG_ADVANCED,
823 .label = "username",
824 .type = P_STRING,
825 .p_class = P_LOCAL,
826 .offset = LOCAL_VAR(szUsername),
827 .special = NULL,
828 .enum_list = NULL,
829 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
832 .label = "user",
833 .type = P_STRING,
834 .p_class = P_LOCAL,
835 .offset = LOCAL_VAR(szUsername),
836 .special = NULL,
837 .enum_list = NULL,
838 .flags = FLAG_HIDE,
841 .label = "users",
842 .type = P_STRING,
843 .p_class = P_LOCAL,
844 .offset = LOCAL_VAR(szUsername),
845 .special = NULL,
846 .enum_list = NULL,
847 .flags = FLAG_HIDE,
850 .label = "invalid users",
851 .type = P_LIST,
852 .p_class = P_LOCAL,
853 .offset = LOCAL_VAR(szInvalidUsers),
854 .special = NULL,
855 .enum_list = NULL,
856 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
859 .label = "valid users",
860 .type = P_LIST,
861 .p_class = P_LOCAL,
862 .offset = LOCAL_VAR(szValidUsers),
863 .special = NULL,
864 .enum_list = NULL,
865 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
868 .label = "admin users",
869 .type = P_LIST,
870 .p_class = P_LOCAL,
871 .offset = LOCAL_VAR(szAdminUsers),
872 .special = NULL,
873 .enum_list = NULL,
874 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
877 .label = "read list",
878 .type = P_LIST,
879 .p_class = P_LOCAL,
880 .offset = LOCAL_VAR(readlist),
881 .special = NULL,
882 .enum_list = NULL,
883 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
886 .label = "write list",
887 .type = P_LIST,
888 .p_class = P_LOCAL,
889 .offset = LOCAL_VAR(writelist),
890 .special = NULL,
891 .enum_list = NULL,
892 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
895 .label = "force user",
896 .type = P_STRING,
897 .p_class = P_LOCAL,
898 .offset = LOCAL_VAR(force_user),
899 .special = NULL,
900 .enum_list = NULL,
901 .flags = FLAG_ADVANCED | FLAG_SHARE,
904 .label = "force group",
905 .type = P_STRING,
906 .p_class = P_LOCAL,
907 .offset = LOCAL_VAR(force_group),
908 .special = NULL,
909 .enum_list = NULL,
910 .flags = FLAG_ADVANCED | FLAG_SHARE,
913 .label = "group",
914 .type = P_STRING,
915 .p_class = P_LOCAL,
916 .offset = LOCAL_VAR(force_group),
917 .special = NULL,
918 .enum_list = NULL,
919 .flags = FLAG_ADVANCED,
922 .label = "read only",
923 .type = P_BOOL,
924 .p_class = P_LOCAL,
925 .offset = LOCAL_VAR(bRead_only),
926 .special = NULL,
927 .enum_list = NULL,
928 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
931 .label = "write ok",
932 .type = P_BOOLREV,
933 .p_class = P_LOCAL,
934 .offset = LOCAL_VAR(bRead_only),
935 .special = NULL,
936 .enum_list = NULL,
937 .flags = FLAG_HIDE,
940 .label = "writeable",
941 .type = P_BOOLREV,
942 .p_class = P_LOCAL,
943 .offset = LOCAL_VAR(bRead_only),
944 .special = NULL,
945 .enum_list = NULL,
946 .flags = FLAG_HIDE,
949 .label = "writable",
950 .type = P_BOOLREV,
951 .p_class = P_LOCAL,
952 .offset = LOCAL_VAR(bRead_only),
953 .special = NULL,
954 .enum_list = NULL,
955 .flags = FLAG_HIDE,
958 .label = "acl check permissions",
959 .type = P_BOOL,
960 .p_class = P_LOCAL,
961 .offset = LOCAL_VAR(bAclCheckPermissions),
962 .special = NULL,
963 .enum_list = NULL,
964 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
967 .label = "acl group control",
968 .type = P_BOOL,
969 .p_class = P_LOCAL,
970 .offset = LOCAL_VAR(bAclGroupControl),
971 .special = NULL,
972 .enum_list = NULL,
973 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
976 .label = "acl map full control",
977 .type = P_BOOL,
978 .p_class = P_LOCAL,
979 .offset = LOCAL_VAR(bAclMapFullControl),
980 .special = NULL,
981 .enum_list = NULL,
982 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
985 .label = "create mask",
986 .type = P_OCTAL,
987 .p_class = P_LOCAL,
988 .offset = LOCAL_VAR(iCreate_mask),
989 .special = NULL,
990 .enum_list = NULL,
991 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
994 .label = "create mode",
995 .type = P_OCTAL,
996 .p_class = P_LOCAL,
997 .offset = LOCAL_VAR(iCreate_mask),
998 .special = NULL,
999 .enum_list = NULL,
1000 .flags = FLAG_HIDE,
1003 .label = "force create mode",
1004 .type = P_OCTAL,
1005 .p_class = P_LOCAL,
1006 .offset = LOCAL_VAR(iCreate_force_mode),
1007 .special = NULL,
1008 .enum_list = NULL,
1009 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1012 .label = "security mask",
1013 .type = P_OCTAL,
1014 .p_class = P_LOCAL,
1015 .offset = LOCAL_VAR(iSecurity_mask),
1016 .special = NULL,
1017 .enum_list = NULL,
1018 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1021 .label = "force security mode",
1022 .type = P_OCTAL,
1023 .p_class = P_LOCAL,
1024 .offset = LOCAL_VAR(iSecurity_force_mode),
1025 .special = NULL,
1026 .enum_list = NULL,
1027 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1030 .label = "directory mask",
1031 .type = P_OCTAL,
1032 .p_class = P_LOCAL,
1033 .offset = LOCAL_VAR(iDir_mask),
1034 .special = NULL,
1035 .enum_list = NULL,
1036 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1039 .label = "directory mode",
1040 .type = P_OCTAL,
1041 .p_class = P_LOCAL,
1042 .offset = LOCAL_VAR(iDir_mask),
1043 .special = NULL,
1044 .enum_list = NULL,
1045 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1048 .label = "force directory mode",
1049 .type = P_OCTAL,
1050 .p_class = P_LOCAL,
1051 .offset = LOCAL_VAR(iDir_force_mode),
1052 .special = NULL,
1053 .enum_list = NULL,
1054 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1057 .label = "directory security mask",
1058 .type = P_OCTAL,
1059 .p_class = P_LOCAL,
1060 .offset = LOCAL_VAR(iDir_Security_mask),
1061 .special = NULL,
1062 .enum_list = NULL,
1063 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1066 .label = "force directory security mode",
1067 .type = P_OCTAL,
1068 .p_class = P_LOCAL,
1069 .offset = LOCAL_VAR(iDir_Security_force_mode),
1070 .special = NULL,
1071 .enum_list = NULL,
1072 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1075 .label = "force unknown acl user",
1076 .type = P_BOOL,
1077 .p_class = P_LOCAL,
1078 .offset = LOCAL_VAR(bForceUnknownAclUser),
1079 .special = NULL,
1080 .enum_list = NULL,
1081 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1084 .label = "inherit permissions",
1085 .type = P_BOOL,
1086 .p_class = P_LOCAL,
1087 .offset = LOCAL_VAR(bInheritPerms),
1088 .special = NULL,
1089 .enum_list = NULL,
1090 .flags = FLAG_ADVANCED | FLAG_SHARE,
1093 .label = "inherit acls",
1094 .type = P_BOOL,
1095 .p_class = P_LOCAL,
1096 .offset = LOCAL_VAR(bInheritACLS),
1097 .special = NULL,
1098 .enum_list = NULL,
1099 .flags = FLAG_ADVANCED | FLAG_SHARE,
1102 .label = "inherit owner",
1103 .type = P_BOOL,
1104 .p_class = P_LOCAL,
1105 .offset = LOCAL_VAR(bInheritOwner),
1106 .special = NULL,
1107 .enum_list = NULL,
1108 .flags = FLAG_ADVANCED | FLAG_SHARE,
1111 .label = "guest only",
1112 .type = P_BOOL,
1113 .p_class = P_LOCAL,
1114 .offset = LOCAL_VAR(bGuest_only),
1115 .special = NULL,
1116 .enum_list = NULL,
1117 .flags = FLAG_ADVANCED | FLAG_SHARE,
1120 .label = "only guest",
1121 .type = P_BOOL,
1122 .p_class = P_LOCAL,
1123 .offset = LOCAL_VAR(bGuest_only),
1124 .special = NULL,
1125 .enum_list = NULL,
1126 .flags = FLAG_HIDE,
1129 .label = "administrative share",
1130 .type = P_BOOL,
1131 .p_class = P_LOCAL,
1132 .offset = LOCAL_VAR(bAdministrative_share),
1133 .special = NULL,
1134 .enum_list = NULL,
1135 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1139 .label = "guest ok",
1140 .type = P_BOOL,
1141 .p_class = P_LOCAL,
1142 .offset = LOCAL_VAR(bGuest_ok),
1143 .special = NULL,
1144 .enum_list = NULL,
1145 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1148 .label = "public",
1149 .type = P_BOOL,
1150 .p_class = P_LOCAL,
1151 .offset = LOCAL_VAR(bGuest_ok),
1152 .special = NULL,
1153 .enum_list = NULL,
1154 .flags = FLAG_HIDE,
1157 .label = "only user",
1158 .type = P_BOOL,
1159 .p_class = P_LOCAL,
1160 .offset = LOCAL_VAR(bOnlyUser),
1161 .special = NULL,
1162 .enum_list = NULL,
1163 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1166 .label = "hosts allow",
1167 .type = P_LIST,
1168 .p_class = P_LOCAL,
1169 .offset = LOCAL_VAR(szHostsallow),
1170 .special = NULL,
1171 .enum_list = NULL,
1172 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1175 .label = "allow hosts",
1176 .type = P_LIST,
1177 .p_class = P_LOCAL,
1178 .offset = LOCAL_VAR(szHostsallow),
1179 .special = NULL,
1180 .enum_list = NULL,
1181 .flags = FLAG_HIDE,
1184 .label = "hosts deny",
1185 .type = P_LIST,
1186 .p_class = P_LOCAL,
1187 .offset = LOCAL_VAR(szHostsdeny),
1188 .special = NULL,
1189 .enum_list = NULL,
1190 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1193 .label = "deny hosts",
1194 .type = P_LIST,
1195 .p_class = P_LOCAL,
1196 .offset = LOCAL_VAR(szHostsdeny),
1197 .special = NULL,
1198 .enum_list = NULL,
1199 .flags = FLAG_HIDE,
1202 .label = "preload modules",
1203 .type = P_LIST,
1204 .p_class = P_GLOBAL,
1205 .offset = GLOBAL_VAR(szPreloadModules),
1206 .special = NULL,
1207 .enum_list = NULL,
1208 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1211 .label = "dedicated keytab file",
1212 .type = P_STRING,
1213 .p_class = P_GLOBAL,
1214 .offset = GLOBAL_VAR(szDedicatedKeytabFile),
1215 .special = NULL,
1216 .enum_list = NULL,
1217 .flags = FLAG_ADVANCED,
1220 .label = "kerberos method",
1221 .type = P_ENUM,
1222 .p_class = P_GLOBAL,
1223 .offset = GLOBAL_VAR(iKerberosMethod),
1224 .special = NULL,
1225 .enum_list = enum_kerberos_method,
1226 .flags = FLAG_ADVANCED,
1229 .label = "map untrusted to domain",
1230 .type = P_BOOL,
1231 .p_class = P_GLOBAL,
1232 .offset = GLOBAL_VAR(bMapUntrustedToDomain),
1233 .special = NULL,
1234 .enum_list = NULL,
1235 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1239 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1242 .label = "log level",
1243 .type = P_STRING,
1244 .p_class = P_GLOBAL,
1245 .offset = GLOBAL_VAR(loglevel),
1246 .special = handle_debug_list,
1247 .enum_list = NULL,
1248 .flags = FLAG_ADVANCED,
1251 .label = "debuglevel",
1252 .type = P_STRING,
1253 .p_class = P_GLOBAL,
1254 .offset = GLOBAL_VAR(loglevel),
1255 .special = handle_debug_list,
1256 .enum_list = NULL,
1257 .flags = FLAG_HIDE,
1260 .label = "syslog",
1261 .type = P_INTEGER,
1262 .p_class = P_GLOBAL,
1263 .offset = GLOBAL_VAR(syslog),
1264 .special = NULL,
1265 .enum_list = NULL,
1266 .flags = FLAG_ADVANCED,
1269 .label = "syslog only",
1270 .type = P_BOOL,
1271 .p_class = P_GLOBAL,
1272 .offset = GLOBAL_VAR(bSyslogOnly),
1273 .special = NULL,
1274 .enum_list = NULL,
1275 .flags = FLAG_ADVANCED,
1278 .label = "log file",
1279 .type = P_STRING,
1280 .p_class = P_GLOBAL,
1281 .offset = GLOBAL_VAR(logfile),
1282 .special = NULL,
1283 .enum_list = NULL,
1284 .flags = FLAG_ADVANCED,
1287 .label = "max log size",
1288 .type = P_BYTES,
1289 .p_class = P_GLOBAL,
1290 .offset = GLOBAL_VAR(max_log_size),
1291 .special = NULL,
1292 .enum_list = NULL,
1293 .flags = FLAG_ADVANCED,
1296 .label = "debug timestamp",
1297 .type = P_BOOL,
1298 .p_class = P_GLOBAL,
1299 .offset = GLOBAL_VAR(bTimestampLogs),
1300 .special = NULL,
1301 .enum_list = NULL,
1302 .flags = FLAG_ADVANCED,
1305 .label = "timestamp logs",
1306 .type = P_BOOL,
1307 .p_class = P_GLOBAL,
1308 .offset = GLOBAL_VAR(bTimestampLogs),
1309 .special = NULL,
1310 .enum_list = NULL,
1311 .flags = FLAG_ADVANCED,
1314 .label = "debug prefix timestamp",
1315 .type = P_BOOL,
1316 .p_class = P_GLOBAL,
1317 .offset = GLOBAL_VAR(bDebugPrefixTimestamp),
1318 .special = NULL,
1319 .enum_list = NULL,
1320 .flags = FLAG_ADVANCED,
1323 .label = "debug hires timestamp",
1324 .type = P_BOOL,
1325 .p_class = P_GLOBAL,
1326 .offset = GLOBAL_VAR(bDebugHiresTimestamp),
1327 .special = NULL,
1328 .enum_list = NULL,
1329 .flags = FLAG_ADVANCED,
1332 .label = "debug pid",
1333 .type = P_BOOL,
1334 .p_class = P_GLOBAL,
1335 .offset = GLOBAL_VAR(bDebugPid),
1336 .special = NULL,
1337 .enum_list = NULL,
1338 .flags = FLAG_ADVANCED,
1341 .label = "debug uid",
1342 .type = P_BOOL,
1343 .p_class = P_GLOBAL,
1344 .offset = GLOBAL_VAR(bDebugUid),
1345 .special = NULL,
1346 .enum_list = NULL,
1347 .flags = FLAG_ADVANCED,
1350 .label = "debug class",
1351 .type = P_BOOL,
1352 .p_class = P_GLOBAL,
1353 .offset = GLOBAL_VAR(bDebugClass),
1354 .special = NULL,
1355 .enum_list = NULL,
1356 .flags = FLAG_ADVANCED,
1359 .label = "enable core files",
1360 .type = P_BOOL,
1361 .p_class = P_GLOBAL,
1362 .offset = GLOBAL_VAR(bEnableCoreFiles),
1363 .special = NULL,
1364 .enum_list = NULL,
1365 .flags = FLAG_ADVANCED,
1368 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1371 .label = "allocation roundup size",
1372 .type = P_BYTES,
1373 .p_class = P_LOCAL,
1374 .offset = LOCAL_VAR(iallocation_roundup_size),
1375 .special = NULL,
1376 .enum_list = NULL,
1377 .flags = FLAG_ADVANCED,
1380 .label = "aio read size",
1381 .type = P_BYTES,
1382 .p_class = P_LOCAL,
1383 .offset = LOCAL_VAR(iAioReadSize),
1384 .special = NULL,
1385 .enum_list = NULL,
1386 .flags = FLAG_ADVANCED,
1389 .label = "aio write size",
1390 .type = P_BYTES,
1391 .p_class = P_LOCAL,
1392 .offset = LOCAL_VAR(iAioWriteSize),
1393 .special = NULL,
1394 .enum_list = NULL,
1395 .flags = FLAG_ADVANCED,
1398 .label = "aio write behind",
1399 .type = P_STRING,
1400 .p_class = P_LOCAL,
1401 .offset = LOCAL_VAR(szAioWriteBehind),
1402 .special = NULL,
1403 .enum_list = NULL,
1404 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1407 .label = "smb ports",
1408 .type = P_LIST,
1409 .p_class = P_GLOBAL,
1410 .offset = GLOBAL_VAR(smb_ports),
1411 .special = NULL,
1412 .enum_list = NULL,
1413 .flags = FLAG_ADVANCED,
1416 .label = "large readwrite",
1417 .type = P_BOOL,
1418 .p_class = P_GLOBAL,
1419 .offset = GLOBAL_VAR(bLargeReadwrite),
1420 .special = NULL,
1421 .enum_list = NULL,
1422 .flags = FLAG_ADVANCED,
1425 .label = "server max protocol",
1426 .type = P_ENUM,
1427 .p_class = P_GLOBAL,
1428 .offset = GLOBAL_VAR(srv_maxprotocol),
1429 .special = NULL,
1430 .enum_list = enum_protocol,
1431 .flags = FLAG_ADVANCED,
1434 .label = "max protocol",
1435 .type = P_ENUM,
1436 .p_class = P_GLOBAL,
1437 .offset = GLOBAL_VAR(srv_maxprotocol),
1438 .special = NULL,
1439 .enum_list = enum_protocol,
1440 .flags = FLAG_ADVANCED,
1443 .label = "protocol",
1444 .type = P_ENUM,
1445 .p_class = P_GLOBAL,
1446 .offset = GLOBAL_VAR(srv_maxprotocol),
1447 .special = NULL,
1448 .enum_list = enum_protocol,
1449 .flags = FLAG_ADVANCED,
1452 .label = "server min protocol",
1453 .type = P_ENUM,
1454 .p_class = P_GLOBAL,
1455 .offset = GLOBAL_VAR(srv_minprotocol),
1456 .special = NULL,
1457 .enum_list = enum_protocol,
1458 .flags = FLAG_ADVANCED,
1461 .label = "min protocol",
1462 .type = P_ENUM,
1463 .p_class = P_GLOBAL,
1464 .offset = GLOBAL_VAR(srv_minprotocol),
1465 .special = NULL,
1466 .enum_list = enum_protocol,
1467 .flags = FLAG_ADVANCED,
1470 .label = "client max protocol",
1471 .type = P_ENUM,
1472 .p_class = P_GLOBAL,
1473 .offset = GLOBAL_VAR(cli_maxprotocol),
1474 .special = NULL,
1475 .enum_list = enum_protocol,
1476 .flags = FLAG_ADVANCED,
1479 .label = "client min protocol",
1480 .type = P_ENUM,
1481 .p_class = P_GLOBAL,
1482 .offset = GLOBAL_VAR(cli_minprotocol),
1483 .special = NULL,
1484 .enum_list = enum_protocol,
1485 .flags = FLAG_ADVANCED,
1488 .label = "unicode",
1489 .type = P_BOOL,
1490 .p_class = P_GLOBAL,
1491 .offset = GLOBAL_VAR(bUnicode),
1492 .special = NULL,
1493 .enum_list = NULL
1496 .label = "min receivefile size",
1497 .type = P_BYTES,
1498 .p_class = P_GLOBAL,
1499 .offset = GLOBAL_VAR(iminreceivefile),
1500 .special = NULL,
1501 .enum_list = NULL,
1502 .flags = FLAG_ADVANCED,
1505 .label = "read raw",
1506 .type = P_BOOL,
1507 .p_class = P_GLOBAL,
1508 .offset = GLOBAL_VAR(bReadRaw),
1509 .special = NULL,
1510 .enum_list = NULL,
1511 .flags = FLAG_ADVANCED,
1514 .label = "write raw",
1515 .type = P_BOOL,
1516 .p_class = P_GLOBAL,
1517 .offset = GLOBAL_VAR(bWriteRaw),
1518 .special = NULL,
1519 .enum_list = NULL,
1520 .flags = FLAG_ADVANCED,
1523 .label = "disable netbios",
1524 .type = P_BOOL,
1525 .p_class = P_GLOBAL,
1526 .offset = GLOBAL_VAR(bDisableNetbios),
1527 .special = NULL,
1528 .enum_list = NULL,
1529 .flags = FLAG_ADVANCED,
1532 .label = "reset on zero vc",
1533 .type = P_BOOL,
1534 .p_class = P_GLOBAL,
1535 .offset = GLOBAL_VAR(bResetOnZeroVC),
1536 .special = NULL,
1537 .enum_list = NULL,
1538 .flags = FLAG_ADVANCED,
1541 .label = "log writeable files on exit",
1542 .type = P_BOOL,
1543 .p_class = P_GLOBAL,
1544 .offset = GLOBAL_VAR(bLogWriteableFilesOnExit),
1545 .special = NULL,
1546 .enum_list = NULL,
1547 .flags = FLAG_ADVANCED,
1550 .label = "acl compatibility",
1551 .type = P_ENUM,
1552 .p_class = P_GLOBAL,
1553 .offset = GLOBAL_VAR(iAclCompat),
1554 .special = NULL,
1555 .enum_list = enum_acl_compat_vals,
1556 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1559 .label = "defer sharing violations",
1560 .type = P_BOOL,
1561 .p_class = P_GLOBAL,
1562 .offset = GLOBAL_VAR(bDeferSharingViolations),
1563 .special = NULL,
1564 .enum_list = NULL,
1565 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1568 .label = "ea support",
1569 .type = P_BOOL,
1570 .p_class = P_LOCAL,
1571 .offset = LOCAL_VAR(bEASupport),
1572 .special = NULL,
1573 .enum_list = NULL,
1574 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1577 .label = "nt acl support",
1578 .type = P_BOOL,
1579 .p_class = P_LOCAL,
1580 .offset = LOCAL_VAR(bNTAclSupport),
1581 .special = NULL,
1582 .enum_list = NULL,
1583 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1586 .label = "nt pipe support",
1587 .type = P_BOOL,
1588 .p_class = P_GLOBAL,
1589 .offset = GLOBAL_VAR(bNTPipeSupport),
1590 .special = NULL,
1591 .enum_list = NULL,
1592 .flags = FLAG_ADVANCED,
1595 .label = "nt status support",
1596 .type = P_BOOL,
1597 .p_class = P_GLOBAL,
1598 .offset = GLOBAL_VAR(bNTStatusSupport),
1599 .special = NULL,
1600 .enum_list = NULL,
1601 .flags = FLAG_ADVANCED,
1604 .label = "profile acls",
1605 .type = P_BOOL,
1606 .p_class = P_LOCAL,
1607 .offset = LOCAL_VAR(bProfileAcls),
1608 .special = NULL,
1609 .enum_list = NULL,
1610 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1613 .label = "map acl inherit",
1614 .type = P_BOOL,
1615 .p_class = P_LOCAL,
1616 .offset = LOCAL_VAR(bMap_acl_inherit),
1617 .special = NULL,
1618 .enum_list = NULL,
1619 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1622 .label = "afs share",
1623 .type = P_BOOL,
1624 .p_class = P_LOCAL,
1625 .offset = LOCAL_VAR(bAfs_Share),
1626 .special = NULL,
1627 .enum_list = NULL,
1628 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1631 .label = "max mux",
1632 .type = P_INTEGER,
1633 .p_class = P_GLOBAL,
1634 .offset = GLOBAL_VAR(max_mux),
1635 .special = NULL,
1636 .enum_list = NULL,
1637 .flags = FLAG_ADVANCED,
1640 .label = "max xmit",
1641 .type = P_BYTES,
1642 .p_class = P_GLOBAL,
1643 .offset = GLOBAL_VAR(max_xmit),
1644 .special = NULL,
1645 .enum_list = NULL,
1646 .flags = FLAG_ADVANCED,
1649 .label = "name resolve order",
1650 .type = P_LIST,
1651 .p_class = P_GLOBAL,
1652 .offset = GLOBAL_VAR(szNameResolveOrder),
1653 .special = NULL,
1654 .enum_list = NULL,
1655 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1658 .label = "max ttl",
1659 .type = P_INTEGER,
1660 .p_class = P_GLOBAL,
1661 .offset = GLOBAL_VAR(max_ttl),
1662 .special = NULL,
1663 .enum_list = NULL,
1664 .flags = FLAG_ADVANCED,
1667 .label = "max wins ttl",
1668 .type = P_INTEGER,
1669 .p_class = P_GLOBAL,
1670 .offset = GLOBAL_VAR(max_wins_ttl),
1671 .special = NULL,
1672 .enum_list = NULL,
1673 .flags = FLAG_ADVANCED,
1676 .label = "min wins ttl",
1677 .type = P_INTEGER,
1678 .p_class = P_GLOBAL,
1679 .offset = GLOBAL_VAR(min_wins_ttl),
1680 .special = NULL,
1681 .enum_list = NULL,
1682 .flags = FLAG_ADVANCED,
1685 .label = "time server",
1686 .type = P_BOOL,
1687 .p_class = P_GLOBAL,
1688 .offset = GLOBAL_VAR(bTimeServer),
1689 .special = NULL,
1690 .enum_list = NULL,
1691 .flags = FLAG_ADVANCED,
1694 .label = "unix extensions",
1695 .type = P_BOOL,
1696 .p_class = P_GLOBAL,
1697 .offset = GLOBAL_VAR(bUnixExtensions),
1698 .special = NULL,
1699 .enum_list = NULL,
1700 .flags = FLAG_ADVANCED,
1703 .label = "use spnego",
1704 .type = P_BOOL,
1705 .p_class = P_GLOBAL,
1706 .offset = GLOBAL_VAR(bUseSpnego),
1707 .special = NULL,
1708 .enum_list = NULL,
1709 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
1712 .label = "client signing",
1713 .type = P_ENUM,
1714 .p_class = P_GLOBAL,
1715 .offset = GLOBAL_VAR(client_signing),
1716 .special = NULL,
1717 .enum_list = enum_smb_signing_vals,
1718 .flags = FLAG_ADVANCED,
1721 .label = "server signing",
1722 .type = P_ENUM,
1723 .p_class = P_GLOBAL,
1724 .offset = GLOBAL_VAR(server_signing),
1725 .special = NULL,
1726 .enum_list = enum_smb_signing_vals,
1727 .flags = FLAG_ADVANCED,
1730 .label = "smb encrypt",
1731 .type = P_ENUM,
1732 .p_class = P_LOCAL,
1733 .offset = LOCAL_VAR(ismb_encrypt),
1734 .special = NULL,
1735 .enum_list = enum_smb_signing_vals,
1736 .flags = FLAG_ADVANCED,
1739 .label = "client use spnego",
1740 .type = P_BOOL,
1741 .p_class = P_GLOBAL,
1742 .offset = GLOBAL_VAR(bClientUseSpnego),
1743 .special = NULL,
1744 .enum_list = NULL,
1745 .flags = FLAG_ADVANCED,
1748 .label = "client ldap sasl wrapping",
1749 .type = P_ENUM,
1750 .p_class = P_GLOBAL,
1751 .offset = GLOBAL_VAR(client_ldap_sasl_wrapping),
1752 .special = NULL,
1753 .enum_list = enum_ldap_sasl_wrapping,
1754 .flags = FLAG_ADVANCED,
1757 .label = "enable asu support",
1758 .type = P_BOOL,
1759 .p_class = P_GLOBAL,
1760 .offset = GLOBAL_VAR(bASUSupport),
1761 .special = NULL,
1762 .enum_list = NULL,
1763 .flags = FLAG_ADVANCED,
1766 .label = "svcctl list",
1767 .type = P_LIST,
1768 .p_class = P_GLOBAL,
1769 .offset = GLOBAL_VAR(szServicesList),
1770 .special = NULL,
1771 .enum_list = NULL,
1772 .flags = FLAG_ADVANCED,
1775 .label = "cldap port",
1776 .type = P_INTEGER,
1777 .p_class = P_GLOBAL,
1778 .offset = GLOBAL_VAR(cldap_port),
1779 .special = NULL,
1780 .enum_list = NULL
1783 .label = "dgram port",
1784 .type = P_INTEGER,
1785 .p_class = P_GLOBAL,
1786 .offset = GLOBAL_VAR(dgram_port),
1787 .special = NULL,
1788 .enum_list = NULL
1791 .label = "nbt port",
1792 .type = P_INTEGER,
1793 .p_class = P_GLOBAL,
1794 .offset = GLOBAL_VAR(nbt_port),
1795 .special = NULL,
1796 .enum_list = NULL
1799 .label = "krb5 port",
1800 .type = P_INTEGER,
1801 .p_class = P_GLOBAL,
1802 .offset = GLOBAL_VAR(krb5_port),
1803 .special = NULL,
1804 .enum_list = NULL
1807 .label = "kpasswd port",
1808 .type = P_INTEGER,
1809 .p_class = P_GLOBAL,
1810 .offset = GLOBAL_VAR(kpasswd_port),
1811 .special = NULL,
1812 .enum_list = NULL
1815 .label = "web port",
1816 .type = P_INTEGER,
1817 .p_class = P_GLOBAL,
1818 .offset = GLOBAL_VAR(web_port),
1819 .special = NULL,
1820 .enum_list = NULL
1823 .label = "rpc big endian",
1824 .type = P_BOOL,
1825 .p_class = P_GLOBAL,
1826 .offset = GLOBAL_VAR(bRpcBigEndian),
1827 .special = NULL,
1828 .enum_list = NULL
1831 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
1834 .label = "block size",
1835 .type = P_BYTES,
1836 .p_class = P_LOCAL,
1837 .offset = LOCAL_VAR(iBlock_size),
1838 .special = NULL,
1839 .enum_list = NULL,
1840 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1843 .label = "deadtime",
1844 .type = P_INTEGER,
1845 .p_class = P_GLOBAL,
1846 .offset = GLOBAL_VAR(deadtime),
1847 .special = NULL,
1848 .enum_list = NULL,
1849 .flags = FLAG_ADVANCED,
1852 .label = "getwd cache",
1853 .type = P_BOOL,
1854 .p_class = P_GLOBAL,
1855 .offset = GLOBAL_VAR(getwd_cache),
1856 .special = NULL,
1857 .enum_list = NULL,
1858 .flags = FLAG_ADVANCED,
1861 .label = "keepalive",
1862 .type = P_INTEGER,
1863 .p_class = P_GLOBAL,
1864 .offset = GLOBAL_VAR(iKeepalive),
1865 .special = NULL,
1866 .enum_list = NULL,
1867 .flags = FLAG_ADVANCED,
1870 .label = "change notify",
1871 .type = P_BOOL,
1872 .p_class = P_LOCAL,
1873 .offset = LOCAL_VAR(bChangeNotify),
1874 .special = NULL,
1875 .enum_list = NULL,
1876 .flags = FLAG_ADVANCED | FLAG_SHARE,
1879 .label = "directory name cache size",
1880 .type = P_INTEGER,
1881 .p_class = P_LOCAL,
1882 .offset = LOCAL_VAR(iDirectoryNameCacheSize),
1883 .special = NULL,
1884 .enum_list = NULL,
1885 .flags = FLAG_ADVANCED | FLAG_SHARE,
1888 .label = "kernel change notify",
1889 .type = P_BOOL,
1890 .p_class = P_LOCAL,
1891 .offset = LOCAL_VAR(bKernelChangeNotify),
1892 .special = NULL,
1893 .enum_list = NULL,
1894 .flags = FLAG_ADVANCED | FLAG_SHARE,
1897 .label = "lpq cache time",
1898 .type = P_INTEGER,
1899 .p_class = P_GLOBAL,
1900 .offset = GLOBAL_VAR(lpqcachetime),
1901 .special = NULL,
1902 .enum_list = NULL,
1903 .flags = FLAG_ADVANCED,
1906 .label = "max smbd processes",
1907 .type = P_INTEGER,
1908 .p_class = P_GLOBAL,
1909 .offset = GLOBAL_VAR(iMaxSmbdProcesses),
1910 .special = NULL,
1911 .enum_list = NULL,
1912 .flags = FLAG_ADVANCED,
1915 .label = "max connections",
1916 .type = P_INTEGER,
1917 .p_class = P_LOCAL,
1918 .offset = LOCAL_VAR(iMaxConnections),
1919 .special = NULL,
1920 .enum_list = NULL,
1921 .flags = FLAG_ADVANCED | FLAG_SHARE,
1924 .label = "paranoid server security",
1925 .type = P_BOOL,
1926 .p_class = P_GLOBAL,
1927 .offset = GLOBAL_VAR(paranoid_server_security),
1928 .special = NULL,
1929 .enum_list = NULL,
1930 .flags = FLAG_ADVANCED,
1933 .label = "max disk size",
1934 .type = P_BYTES,
1935 .p_class = P_GLOBAL,
1936 .offset = GLOBAL_VAR(maxdisksize),
1937 .special = NULL,
1938 .enum_list = NULL,
1939 .flags = FLAG_ADVANCED,
1942 .label = "max open files",
1943 .type = P_INTEGER,
1944 .p_class = P_GLOBAL,
1945 .offset = GLOBAL_VAR(max_open_files),
1946 .special = NULL,
1947 .enum_list = NULL,
1948 .flags = FLAG_ADVANCED,
1951 .label = "min print space",
1952 .type = P_INTEGER,
1953 .p_class = P_LOCAL,
1954 .offset = LOCAL_VAR(iMinPrintSpace),
1955 .special = NULL,
1956 .enum_list = NULL,
1957 .flags = FLAG_ADVANCED | FLAG_PRINT,
1960 .label = "socket options",
1961 .type = P_STRING,
1962 .p_class = P_GLOBAL,
1963 .offset = GLOBAL_VAR(socket_options),
1964 .special = NULL,
1965 .enum_list = NULL,
1966 .flags = FLAG_ADVANCED,
1969 .label = "strict allocate",
1970 .type = P_BOOL,
1971 .p_class = P_LOCAL,
1972 .offset = LOCAL_VAR(bStrictAllocate),
1973 .special = NULL,
1974 .enum_list = NULL,
1975 .flags = FLAG_ADVANCED | FLAG_SHARE,
1978 .label = "strict sync",
1979 .type = P_BOOL,
1980 .p_class = P_LOCAL,
1981 .offset = LOCAL_VAR(bStrictSync),
1982 .special = NULL,
1983 .enum_list = NULL,
1984 .flags = FLAG_ADVANCED | FLAG_SHARE,
1987 .label = "sync always",
1988 .type = P_BOOL,
1989 .p_class = P_LOCAL,
1990 .offset = LOCAL_VAR(bSyncAlways),
1991 .special = NULL,
1992 .enum_list = NULL,
1993 .flags = FLAG_ADVANCED | FLAG_SHARE,
1996 .label = "use mmap",
1997 .type = P_BOOL,
1998 .p_class = P_GLOBAL,
1999 .offset = GLOBAL_VAR(bUseMmap),
2000 .special = NULL,
2001 .enum_list = NULL,
2002 .flags = FLAG_ADVANCED,
2005 .label = "use sendfile",
2006 .type = P_BOOL,
2007 .p_class = P_LOCAL,
2008 .offset = LOCAL_VAR(bUseSendfile),
2009 .special = NULL,
2010 .enum_list = NULL,
2011 .flags = FLAG_ADVANCED | FLAG_SHARE,
2014 .label = "hostname lookups",
2015 .type = P_BOOL,
2016 .p_class = P_GLOBAL,
2017 .offset = GLOBAL_VAR(bHostnameLookups),
2018 .special = NULL,
2019 .enum_list = NULL,
2020 .flags = FLAG_ADVANCED,
2023 .label = "write cache size",
2024 .type = P_BYTES,
2025 .p_class = P_LOCAL,
2026 .offset = LOCAL_VAR(iWriteCacheSize),
2027 .special = NULL,
2028 .enum_list = NULL,
2029 .flags = FLAG_ADVANCED | FLAG_SHARE,
2032 .label = "name cache timeout",
2033 .type = P_INTEGER,
2034 .p_class = P_GLOBAL,
2035 .offset = GLOBAL_VAR(name_cache_timeout),
2036 .special = NULL,
2037 .enum_list = NULL,
2038 .flags = FLAG_ADVANCED,
2041 .label = "ctdbd socket",
2042 .type = P_STRING,
2043 .p_class = P_GLOBAL,
2044 .offset = GLOBAL_VAR(ctdbdSocket),
2045 .special = NULL,
2046 .enum_list = NULL,
2047 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2050 .label = "cluster addresses",
2051 .type = P_LIST,
2052 .p_class = P_GLOBAL,
2053 .offset = GLOBAL_VAR(szClusterAddresses),
2054 .special = NULL,
2055 .enum_list = NULL,
2056 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2059 .label = "clustering",
2060 .type = P_BOOL,
2061 .p_class = P_GLOBAL,
2062 .offset = GLOBAL_VAR(clustering),
2063 .special = NULL,
2064 .enum_list = NULL,
2065 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2068 .label = "ctdb timeout",
2069 .type = P_INTEGER,
2070 .p_class = P_GLOBAL,
2071 .offset = GLOBAL_VAR(ctdb_timeout),
2072 .special = NULL,
2073 .enum_list = NULL,
2074 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2077 .label = "ctdb locktime warn threshold",
2078 .type = P_INTEGER,
2079 .p_class = P_GLOBAL,
2080 .offset = GLOBAL_VAR(ctdb_locktime_warn_threshold),
2081 .special = NULL,
2082 .enum_list = NULL,
2083 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2086 .label = "smb2 max read",
2087 .type = P_BYTES,
2088 .p_class = P_GLOBAL,
2089 .offset = GLOBAL_VAR(ismb2_max_read),
2090 .special = NULL,
2091 .enum_list = NULL,
2092 .flags = FLAG_ADVANCED,
2095 .label = "smb2 max write",
2096 .type = P_BYTES,
2097 .p_class = P_GLOBAL,
2098 .offset = GLOBAL_VAR(ismb2_max_write),
2099 .special = NULL,
2100 .enum_list = NULL,
2101 .flags = FLAG_ADVANCED,
2104 .label = "smb2 max trans",
2105 .type = P_BYTES,
2106 .p_class = P_GLOBAL,
2107 .offset = GLOBAL_VAR(ismb2_max_trans),
2108 .special = NULL,
2109 .enum_list = NULL,
2110 .flags = FLAG_ADVANCED,
2113 .label = "smb2 max credits",
2114 .type = P_INTEGER,
2115 .p_class = P_GLOBAL,
2116 .offset = GLOBAL_VAR(ismb2_max_credits),
2117 .special = NULL,
2118 .enum_list = NULL,
2119 .flags = FLAG_ADVANCED,
2122 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2125 .label = "max reported print jobs",
2126 .type = P_INTEGER,
2127 .p_class = P_LOCAL,
2128 .offset = LOCAL_VAR(iMaxReportedPrintJobs),
2129 .special = NULL,
2130 .enum_list = NULL,
2131 .flags = FLAG_ADVANCED | FLAG_PRINT,
2134 .label = "max print jobs",
2135 .type = P_INTEGER,
2136 .p_class = P_LOCAL,
2137 .offset = LOCAL_VAR(iMaxPrintJobs),
2138 .special = NULL,
2139 .enum_list = NULL,
2140 .flags = FLAG_ADVANCED | FLAG_PRINT,
2143 .label = "load printers",
2144 .type = P_BOOL,
2145 .p_class = P_GLOBAL,
2146 .offset = GLOBAL_VAR(bLoadPrinters),
2147 .special = NULL,
2148 .enum_list = NULL,
2149 .flags = FLAG_ADVANCED | FLAG_PRINT,
2152 .label = "printcap cache time",
2153 .type = P_INTEGER,
2154 .p_class = P_GLOBAL,
2155 .offset = GLOBAL_VAR(PrintcapCacheTime),
2156 .special = NULL,
2157 .enum_list = NULL,
2158 .flags = FLAG_ADVANCED | FLAG_PRINT,
2161 .label = "printcap name",
2162 .type = P_STRING,
2163 .p_class = P_GLOBAL,
2164 .offset = GLOBAL_VAR(szPrintcapname),
2165 .special = NULL,
2166 .enum_list = NULL,
2167 .flags = FLAG_ADVANCED | FLAG_PRINT,
2170 .label = "printcap",
2171 .type = P_STRING,
2172 .p_class = P_GLOBAL,
2173 .offset = GLOBAL_VAR(szPrintcapname),
2174 .special = NULL,
2175 .enum_list = NULL,
2176 .flags = FLAG_HIDE,
2179 .label = "printable",
2180 .type = P_BOOL,
2181 .p_class = P_LOCAL,
2182 .offset = LOCAL_VAR(bPrint_ok),
2183 .special = NULL,
2184 .enum_list = NULL,
2185 .flags = FLAG_ADVANCED | FLAG_PRINT,
2188 .label = "print notify backchannel",
2189 .type = P_BOOL,
2190 .p_class = P_LOCAL,
2191 .offset = LOCAL_VAR(bPrintNotifyBackchannel),
2192 .special = NULL,
2193 .enum_list = NULL,
2194 .flags = FLAG_ADVANCED,
2197 .label = "print ok",
2198 .type = P_BOOL,
2199 .p_class = P_LOCAL,
2200 .offset = LOCAL_VAR(bPrint_ok),
2201 .special = NULL,
2202 .enum_list = NULL,
2203 .flags = FLAG_HIDE,
2206 .label = "printing",
2207 .type = P_ENUM,
2208 .p_class = P_LOCAL,
2209 .offset = LOCAL_VAR(iPrinting),
2210 .special = handle_printing,
2211 .enum_list = enum_printing,
2212 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2215 .label = "cups options",
2216 .type = P_STRING,
2217 .p_class = P_LOCAL,
2218 .offset = LOCAL_VAR(szCupsOptions),
2219 .special = NULL,
2220 .enum_list = NULL,
2221 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2224 .label = "cups server",
2225 .type = P_STRING,
2226 .p_class = P_GLOBAL,
2227 .offset = GLOBAL_VAR(szCupsServer),
2228 .special = NULL,
2229 .enum_list = NULL,
2230 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2233 .label = "cups encrypt",
2234 .type = P_ENUM,
2235 .p_class = P_GLOBAL,
2236 .offset = GLOBAL_VAR(CupsEncrypt),
2237 .special = NULL,
2238 .enum_list = enum_bool_auto,
2239 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2243 .label = "cups connection timeout",
2244 .type = P_INTEGER,
2245 .p_class = P_GLOBAL,
2246 .offset = GLOBAL_VAR(cups_connection_timeout),
2247 .special = NULL,
2248 .enum_list = NULL,
2249 .flags = FLAG_ADVANCED,
2252 .label = "iprint server",
2253 .type = P_STRING,
2254 .p_class = P_GLOBAL,
2255 .offset = GLOBAL_VAR(szIPrintServer),
2256 .special = NULL,
2257 .enum_list = NULL,
2258 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2261 .label = "print command",
2262 .type = P_STRING,
2263 .p_class = P_LOCAL,
2264 .offset = LOCAL_VAR(szPrintcommand),
2265 .special = NULL,
2266 .enum_list = NULL,
2267 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2270 .label = "disable spoolss",
2271 .type = P_BOOL,
2272 .p_class = P_GLOBAL,
2273 .offset = GLOBAL_VAR(bDisableSpoolss),
2274 .special = NULL,
2275 .enum_list = NULL,
2276 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2279 .label = "enable spoolss",
2280 .type = P_BOOLREV,
2281 .p_class = P_GLOBAL,
2282 .offset = GLOBAL_VAR(bDisableSpoolss),
2283 .special = NULL,
2284 .enum_list = NULL,
2285 .flags = FLAG_HIDE,
2288 .label = "lpq command",
2289 .type = P_STRING,
2290 .p_class = P_LOCAL,
2291 .offset = LOCAL_VAR(szLpqcommand),
2292 .special = NULL,
2293 .enum_list = NULL,
2294 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2297 .label = "lprm command",
2298 .type = P_STRING,
2299 .p_class = P_LOCAL,
2300 .offset = LOCAL_VAR(szLprmcommand),
2301 .special = NULL,
2302 .enum_list = NULL,
2303 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2306 .label = "lppause command",
2307 .type = P_STRING,
2308 .p_class = P_LOCAL,
2309 .offset = LOCAL_VAR(szLppausecommand),
2310 .special = NULL,
2311 .enum_list = NULL,
2312 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2315 .label = "lpresume command",
2316 .type = P_STRING,
2317 .p_class = P_LOCAL,
2318 .offset = LOCAL_VAR(szLpresumecommand),
2319 .special = NULL,
2320 .enum_list = NULL,
2321 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2324 .label = "queuepause command",
2325 .type = P_STRING,
2326 .p_class = P_LOCAL,
2327 .offset = LOCAL_VAR(szQueuepausecommand),
2328 .special = NULL,
2329 .enum_list = NULL,
2330 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2333 .label = "queueresume command",
2334 .type = P_STRING,
2335 .p_class = P_LOCAL,
2336 .offset = LOCAL_VAR(szQueueresumecommand),
2337 .special = NULL,
2338 .enum_list = NULL,
2339 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2342 .label = "addport command",
2343 .type = P_STRING,
2344 .p_class = P_GLOBAL,
2345 .offset = GLOBAL_VAR(szAddPortCommand),
2346 .special = NULL,
2347 .enum_list = NULL,
2348 .flags = FLAG_ADVANCED,
2351 .label = "enumports command",
2352 .type = P_STRING,
2353 .p_class = P_GLOBAL,
2354 .offset = GLOBAL_VAR(szEnumPortsCommand),
2355 .special = NULL,
2356 .enum_list = NULL,
2357 .flags = FLAG_ADVANCED,
2360 .label = "addprinter command",
2361 .type = P_STRING,
2362 .p_class = P_GLOBAL,
2363 .offset = GLOBAL_VAR(szAddPrinterCommand),
2364 .special = NULL,
2365 .enum_list = NULL,
2366 .flags = FLAG_ADVANCED,
2369 .label = "deleteprinter command",
2370 .type = P_STRING,
2371 .p_class = P_GLOBAL,
2372 .offset = GLOBAL_VAR(szDeletePrinterCommand),
2373 .special = NULL,
2374 .enum_list = NULL,
2375 .flags = FLAG_ADVANCED,
2378 .label = "show add printer wizard",
2379 .type = P_BOOL,
2380 .p_class = P_GLOBAL,
2381 .offset = GLOBAL_VAR(bMsAddPrinterWizard),
2382 .special = NULL,
2383 .enum_list = NULL,
2384 .flags = FLAG_ADVANCED,
2387 .label = "os2 driver map",
2388 .type = P_STRING,
2389 .p_class = P_GLOBAL,
2390 .offset = GLOBAL_VAR(szOs2DriverMap),
2391 .special = NULL,
2392 .enum_list = NULL,
2393 .flags = FLAG_ADVANCED,
2397 .label = "printer name",
2398 .type = P_STRING,
2399 .p_class = P_LOCAL,
2400 .offset = LOCAL_VAR(szPrintername),
2401 .special = NULL,
2402 .enum_list = NULL,
2403 .flags = FLAG_ADVANCED | FLAG_PRINT,
2406 .label = "printer",
2407 .type = P_STRING,
2408 .p_class = P_LOCAL,
2409 .offset = LOCAL_VAR(szPrintername),
2410 .special = NULL,
2411 .enum_list = NULL,
2412 .flags = FLAG_HIDE,
2415 .label = "use client driver",
2416 .type = P_BOOL,
2417 .p_class = P_LOCAL,
2418 .offset = LOCAL_VAR(bUseClientDriver),
2419 .special = NULL,
2420 .enum_list = NULL,
2421 .flags = FLAG_ADVANCED | FLAG_PRINT,
2424 .label = "default devmode",
2425 .type = P_BOOL,
2426 .p_class = P_LOCAL,
2427 .offset = LOCAL_VAR(bDefaultDevmode),
2428 .special = NULL,
2429 .enum_list = NULL,
2430 .flags = FLAG_ADVANCED | FLAG_PRINT,
2433 .label = "force printername",
2434 .type = P_BOOL,
2435 .p_class = P_LOCAL,
2436 .offset = LOCAL_VAR(bForcePrintername),
2437 .special = NULL,
2438 .enum_list = NULL,
2439 .flags = FLAG_ADVANCED | FLAG_PRINT,
2442 .label = "printjob username",
2443 .type = P_STRING,
2444 .p_class = P_LOCAL,
2445 .offset = LOCAL_VAR(szPrintjobUsername),
2446 .special = NULL,
2447 .enum_list = NULL,
2448 .flags = FLAG_ADVANCED | FLAG_PRINT,
2451 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2454 .label = "mangling method",
2455 .type = P_STRING,
2456 .p_class = P_GLOBAL,
2457 .offset = GLOBAL_VAR(szManglingMethod),
2458 .special = NULL,
2459 .enum_list = NULL,
2460 .flags = FLAG_ADVANCED,
2463 .label = "mangle prefix",
2464 .type = P_INTEGER,
2465 .p_class = P_GLOBAL,
2466 .offset = GLOBAL_VAR(mangle_prefix),
2467 .special = NULL,
2468 .enum_list = NULL,
2469 .flags = FLAG_ADVANCED,
2473 .label = "default case",
2474 .type = P_ENUM,
2475 .p_class = P_LOCAL,
2476 .offset = LOCAL_VAR(iDefaultCase),
2477 .special = NULL,
2478 .enum_list = enum_case,
2479 .flags = FLAG_ADVANCED | FLAG_SHARE,
2482 .label = "case sensitive",
2483 .type = P_ENUM,
2484 .p_class = P_LOCAL,
2485 .offset = LOCAL_VAR(iCaseSensitive),
2486 .special = NULL,
2487 .enum_list = enum_bool_auto,
2488 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2491 .label = "casesignames",
2492 .type = P_ENUM,
2493 .p_class = P_LOCAL,
2494 .offset = LOCAL_VAR(iCaseSensitive),
2495 .special = NULL,
2496 .enum_list = enum_bool_auto,
2497 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2500 .label = "preserve case",
2501 .type = P_BOOL,
2502 .p_class = P_LOCAL,
2503 .offset = LOCAL_VAR(bCasePreserve),
2504 .special = NULL,
2505 .enum_list = NULL,
2506 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2509 .label = "short preserve case",
2510 .type = P_BOOL,
2511 .p_class = P_LOCAL,
2512 .offset = LOCAL_VAR(bShortCasePreserve),
2513 .special = NULL,
2514 .enum_list = NULL,
2515 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2518 .label = "mangling char",
2519 .type = P_CHAR,
2520 .p_class = P_LOCAL,
2521 .offset = LOCAL_VAR(magic_char),
2522 .special = NULL,
2523 .enum_list = NULL,
2524 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2527 .label = "hide dot files",
2528 .type = P_BOOL,
2529 .p_class = P_LOCAL,
2530 .offset = LOCAL_VAR(bHideDotFiles),
2531 .special = NULL,
2532 .enum_list = NULL,
2533 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2536 .label = "hide special files",
2537 .type = P_BOOL,
2538 .p_class = P_LOCAL,
2539 .offset = LOCAL_VAR(bHideSpecialFiles),
2540 .special = NULL,
2541 .enum_list = NULL,
2542 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2545 .label = "hide unreadable",
2546 .type = P_BOOL,
2547 .p_class = P_LOCAL,
2548 .offset = LOCAL_VAR(bHideUnReadable),
2549 .special = NULL,
2550 .enum_list = NULL,
2551 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2554 .label = "hide unwriteable files",
2555 .type = P_BOOL,
2556 .p_class = P_LOCAL,
2557 .offset = LOCAL_VAR(bHideUnWriteableFiles),
2558 .special = NULL,
2559 .enum_list = NULL,
2560 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2563 .label = "delete veto files",
2564 .type = P_BOOL,
2565 .p_class = P_LOCAL,
2566 .offset = LOCAL_VAR(bDeleteVetoFiles),
2567 .special = NULL,
2568 .enum_list = NULL,
2569 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2572 .label = "veto files",
2573 .type = P_STRING,
2574 .p_class = P_LOCAL,
2575 .offset = LOCAL_VAR(szVetoFiles),
2576 .special = NULL,
2577 .enum_list = NULL,
2578 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2581 .label = "hide files",
2582 .type = P_STRING,
2583 .p_class = P_LOCAL,
2584 .offset = LOCAL_VAR(szHideFiles),
2585 .special = NULL,
2586 .enum_list = NULL,
2587 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2590 .label = "veto oplock files",
2591 .type = P_STRING,
2592 .p_class = P_LOCAL,
2593 .offset = LOCAL_VAR(szVetoOplockFiles),
2594 .special = NULL,
2595 .enum_list = NULL,
2596 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2599 .label = "map archive",
2600 .type = P_BOOL,
2601 .p_class = P_LOCAL,
2602 .offset = LOCAL_VAR(bMap_archive),
2603 .special = NULL,
2604 .enum_list = NULL,
2605 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2608 .label = "map hidden",
2609 .type = P_BOOL,
2610 .p_class = P_LOCAL,
2611 .offset = LOCAL_VAR(bMap_hidden),
2612 .special = NULL,
2613 .enum_list = NULL,
2614 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2617 .label = "map system",
2618 .type = P_BOOL,
2619 .p_class = P_LOCAL,
2620 .offset = LOCAL_VAR(bMap_system),
2621 .special = NULL,
2622 .enum_list = NULL,
2623 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2626 .label = "map readonly",
2627 .type = P_ENUM,
2628 .p_class = P_LOCAL,
2629 .offset = LOCAL_VAR(iMap_readonly),
2630 .special = NULL,
2631 .enum_list = enum_map_readonly,
2632 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2635 .label = "mangled names",
2636 .type = P_BOOL,
2637 .p_class = P_LOCAL,
2638 .offset = LOCAL_VAR(bMangledNames),
2639 .special = NULL,
2640 .enum_list = NULL,
2641 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2644 .label = "max stat cache size",
2645 .type = P_INTEGER,
2646 .p_class = P_GLOBAL,
2647 .offset = GLOBAL_VAR(iMaxStatCacheSize),
2648 .special = NULL,
2649 .enum_list = NULL,
2650 .flags = FLAG_ADVANCED,
2653 .label = "stat cache",
2654 .type = P_BOOL,
2655 .p_class = P_GLOBAL,
2656 .offset = GLOBAL_VAR(bStatCache),
2657 .special = NULL,
2658 .enum_list = NULL,
2659 .flags = FLAG_ADVANCED,
2662 .label = "store dos attributes",
2663 .type = P_BOOL,
2664 .p_class = P_LOCAL,
2665 .offset = LOCAL_VAR(bStoreDosAttributes),
2666 .special = NULL,
2667 .enum_list = NULL,
2668 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2671 .label = "dmapi support",
2672 .type = P_BOOL,
2673 .p_class = P_LOCAL,
2674 .offset = LOCAL_VAR(bDmapiSupport),
2675 .special = NULL,
2676 .enum_list = NULL,
2677 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2681 {N_("Domain Options"), P_SEP, P_SEPARATOR},
2684 .label = "machine password timeout",
2685 .type = P_INTEGER,
2686 .p_class = P_GLOBAL,
2687 .offset = GLOBAL_VAR(machine_password_timeout),
2688 .special = NULL,
2689 .enum_list = NULL,
2690 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2693 {N_("Logon Options"), P_SEP, P_SEPARATOR},
2696 .label = "add user script",
2697 .type = P_STRING,
2698 .p_class = P_GLOBAL,
2699 .offset = GLOBAL_VAR(szAddUserScript),
2700 .special = NULL,
2701 .enum_list = NULL,
2702 .flags = FLAG_ADVANCED,
2705 .label = "rename user script",
2706 .type = P_STRING,
2707 .p_class = P_GLOBAL,
2708 .offset = GLOBAL_VAR(szRenameUserScript),
2709 .special = NULL,
2710 .enum_list = NULL,
2711 .flags = FLAG_ADVANCED,
2714 .label = "delete user script",
2715 .type = P_STRING,
2716 .p_class = P_GLOBAL,
2717 .offset = GLOBAL_VAR(szDelUserScript),
2718 .special = NULL,
2719 .enum_list = NULL,
2720 .flags = FLAG_ADVANCED,
2723 .label = "add group script",
2724 .type = P_STRING,
2725 .p_class = P_GLOBAL,
2726 .offset = GLOBAL_VAR(szAddGroupScript),
2727 .special = NULL,
2728 .enum_list = NULL,
2729 .flags = FLAG_ADVANCED,
2732 .label = "delete group script",
2733 .type = P_STRING,
2734 .p_class = P_GLOBAL,
2735 .offset = GLOBAL_VAR(szDelGroupScript),
2736 .special = NULL,
2737 .enum_list = NULL,
2738 .flags = FLAG_ADVANCED,
2741 .label = "add user to group script",
2742 .type = P_STRING,
2743 .p_class = P_GLOBAL,
2744 .offset = GLOBAL_VAR(szAddUserToGroupScript),
2745 .special = NULL,
2746 .enum_list = NULL,
2747 .flags = FLAG_ADVANCED,
2750 .label = "delete user from group script",
2751 .type = P_STRING,
2752 .p_class = P_GLOBAL,
2753 .offset = GLOBAL_VAR(szDelUserFromGroupScript),
2754 .special = NULL,
2755 .enum_list = NULL,
2756 .flags = FLAG_ADVANCED,
2759 .label = "set primary group script",
2760 .type = P_STRING,
2761 .p_class = P_GLOBAL,
2762 .offset = GLOBAL_VAR(szSetPrimaryGroupScript),
2763 .special = NULL,
2764 .enum_list = NULL,
2765 .flags = FLAG_ADVANCED,
2768 .label = "add machine script",
2769 .type = P_STRING,
2770 .p_class = P_GLOBAL,
2771 .offset = GLOBAL_VAR(szAddMachineScript),
2772 .special = NULL,
2773 .enum_list = NULL,
2774 .flags = FLAG_ADVANCED,
2777 .label = "shutdown script",
2778 .type = P_STRING,
2779 .p_class = P_GLOBAL,
2780 .offset = GLOBAL_VAR(szShutdownScript),
2781 .special = NULL,
2782 .enum_list = NULL,
2783 .flags = FLAG_ADVANCED,
2786 .label = "abort shutdown script",
2787 .type = P_STRING,
2788 .p_class = P_GLOBAL,
2789 .offset = GLOBAL_VAR(szAbortShutdownScript),
2790 .special = NULL,
2791 .enum_list = NULL,
2792 .flags = FLAG_ADVANCED,
2795 .label = "username map script",
2796 .type = P_STRING,
2797 .p_class = P_GLOBAL,
2798 .offset = GLOBAL_VAR(szUsernameMapScript),
2799 .special = NULL,
2800 .enum_list = NULL,
2801 .flags = FLAG_ADVANCED,
2804 .label = "username map cache time",
2805 .type = P_INTEGER,
2806 .p_class = P_GLOBAL,
2807 .offset = GLOBAL_VAR(iUsernameMapCacheTime),
2808 .special = NULL,
2809 .enum_list = NULL,
2810 .flags = FLAG_ADVANCED,
2813 .label = "logon script",
2814 .type = P_STRING,
2815 .p_class = P_GLOBAL,
2816 .offset = GLOBAL_VAR(szLogonScript),
2817 .special = NULL,
2818 .enum_list = NULL,
2819 .flags = FLAG_ADVANCED,
2822 .label = "logon path",
2823 .type = P_STRING,
2824 .p_class = P_GLOBAL,
2825 .offset = GLOBAL_VAR(szLogonPath),
2826 .special = NULL,
2827 .enum_list = NULL,
2828 .flags = FLAG_ADVANCED,
2831 .label = "logon drive",
2832 .type = P_STRING,
2833 .p_class = P_GLOBAL,
2834 .offset = GLOBAL_VAR(szLogonDrive),
2835 .special = NULL,
2836 .enum_list = NULL,
2837 .flags = FLAG_ADVANCED,
2840 .label = "logon home",
2841 .type = P_STRING,
2842 .p_class = P_GLOBAL,
2843 .offset = GLOBAL_VAR(szLogonHome),
2844 .special = NULL,
2845 .enum_list = NULL,
2846 .flags = FLAG_ADVANCED,
2849 .label = "domain logons",
2850 .type = P_BOOL,
2851 .p_class = P_GLOBAL,
2852 .offset = GLOBAL_VAR(bDomainLogons),
2853 .special = NULL,
2854 .enum_list = NULL,
2855 .flags = FLAG_ADVANCED,
2859 .label = "init logon delayed hosts",
2860 .type = P_LIST,
2861 .p_class = P_GLOBAL,
2862 .offset = GLOBAL_VAR(szInitLogonDelayedHosts),
2863 .special = NULL,
2864 .enum_list = NULL,
2865 .flags = FLAG_ADVANCED,
2869 .label = "init logon delay",
2870 .type = P_INTEGER,
2871 .p_class = P_GLOBAL,
2872 .offset = GLOBAL_VAR(InitLogonDelay),
2873 .special = NULL,
2874 .enum_list = NULL,
2875 .flags = FLAG_ADVANCED,
2879 {N_("Browse Options"), P_SEP, P_SEPARATOR},
2882 .label = "os level",
2883 .type = P_INTEGER,
2884 .p_class = P_GLOBAL,
2885 .offset = GLOBAL_VAR(os_level),
2886 .special = NULL,
2887 .enum_list = NULL,
2888 .flags = FLAG_BASIC | FLAG_ADVANCED,
2891 .label = "lm announce",
2892 .type = P_ENUM,
2893 .p_class = P_GLOBAL,
2894 .offset = GLOBAL_VAR(lm_announce),
2895 .special = NULL,
2896 .enum_list = enum_bool_auto,
2897 .flags = FLAG_ADVANCED,
2900 .label = "lm interval",
2901 .type = P_INTEGER,
2902 .p_class = P_GLOBAL,
2903 .offset = GLOBAL_VAR(lm_interval),
2904 .special = NULL,
2905 .enum_list = NULL,
2906 .flags = FLAG_ADVANCED,
2909 .label = "preferred master",
2910 .type = P_ENUM,
2911 .p_class = P_GLOBAL,
2912 .offset = GLOBAL_VAR(iPreferredMaster),
2913 .special = NULL,
2914 .enum_list = enum_bool_auto,
2915 .flags = FLAG_BASIC | FLAG_ADVANCED,
2918 .label = "prefered master",
2919 .type = P_ENUM,
2920 .p_class = P_GLOBAL,
2921 .offset = GLOBAL_VAR(iPreferredMaster),
2922 .special = NULL,
2923 .enum_list = enum_bool_auto,
2924 .flags = FLAG_HIDE,
2927 .label = "local master",
2928 .type = P_BOOL,
2929 .p_class = P_GLOBAL,
2930 .offset = GLOBAL_VAR(bLocalMaster),
2931 .special = NULL,
2932 .enum_list = NULL,
2933 .flags = FLAG_BASIC | FLAG_ADVANCED,
2936 .label = "domain master",
2937 .type = P_ENUM,
2938 .p_class = P_GLOBAL,
2939 .offset = GLOBAL_VAR(domain_master),
2940 .special = NULL,
2941 .enum_list = enum_bool_auto,
2942 .flags = FLAG_BASIC | FLAG_ADVANCED,
2945 .label = "browse list",
2946 .type = P_BOOL,
2947 .p_class = P_GLOBAL,
2948 .offset = GLOBAL_VAR(bBrowseList),
2949 .special = NULL,
2950 .enum_list = NULL,
2951 .flags = FLAG_ADVANCED,
2954 .label = "browseable",
2955 .type = P_BOOL,
2956 .p_class = P_LOCAL,
2957 .offset = LOCAL_VAR(bBrowseable),
2958 .special = NULL,
2959 .enum_list = NULL,
2960 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
2963 .label = "browsable",
2964 .type = P_BOOL,
2965 .p_class = P_LOCAL,
2966 .offset = LOCAL_VAR(bBrowseable),
2967 .special = NULL,
2968 .enum_list = NULL,
2969 .flags = FLAG_HIDE,
2972 .label = "access based share enum",
2973 .type = P_BOOL,
2974 .p_class = P_LOCAL,
2975 .offset = LOCAL_VAR(bAccessBasedShareEnum),
2976 .special = NULL,
2977 .enum_list = NULL,
2978 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
2981 .label = "enhanced browsing",
2982 .type = P_BOOL,
2983 .p_class = P_GLOBAL,
2984 .offset = GLOBAL_VAR(enhanced_browsing),
2985 .special = NULL,
2986 .enum_list = NULL,
2987 .flags = FLAG_ADVANCED,
2990 {N_("WINS Options"), P_SEP, P_SEPARATOR},
2993 .label = "dns proxy",
2994 .type = P_BOOL,
2995 .p_class = P_GLOBAL,
2996 .offset = GLOBAL_VAR(bWINSdnsProxy),
2997 .special = NULL,
2998 .enum_list = NULL,
2999 .flags = FLAG_ADVANCED,
3002 .label = "wins proxy",
3003 .type = P_BOOL,
3004 .p_class = P_GLOBAL,
3005 .offset = GLOBAL_VAR(bWINSproxy),
3006 .special = NULL,
3007 .enum_list = NULL,
3008 .flags = FLAG_ADVANCED,
3011 .label = "wins server",
3012 .type = P_LIST,
3013 .p_class = P_GLOBAL,
3014 .offset = GLOBAL_VAR(szWINSservers),
3015 .special = NULL,
3016 .enum_list = NULL,
3017 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3020 .label = "wins support",
3021 .type = P_BOOL,
3022 .p_class = P_GLOBAL,
3023 .offset = GLOBAL_VAR(bWINSsupport),
3024 .special = NULL,
3025 .enum_list = NULL,
3026 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3029 .label = "wins hook",
3030 .type = P_STRING,
3031 .p_class = P_GLOBAL,
3032 .offset = GLOBAL_VAR(szWINSHook),
3033 .special = NULL,
3034 .enum_list = NULL,
3035 .flags = FLAG_ADVANCED,
3038 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3041 .label = "blocking locks",
3042 .type = P_BOOL,
3043 .p_class = P_LOCAL,
3044 .offset = LOCAL_VAR(bBlockingLocks),
3045 .special = NULL,
3046 .enum_list = NULL,
3047 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3050 .label = "csc policy",
3051 .type = P_ENUM,
3052 .p_class = P_LOCAL,
3053 .offset = LOCAL_VAR(iCSCPolicy),
3054 .special = NULL,
3055 .enum_list = enum_csc_policy,
3056 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3059 .label = "fake oplocks",
3060 .type = P_BOOL,
3061 .p_class = P_LOCAL,
3062 .offset = LOCAL_VAR(bFakeOplocks),
3063 .special = NULL,
3064 .enum_list = NULL,
3065 .flags = FLAG_ADVANCED | FLAG_SHARE,
3068 .label = "kernel oplocks",
3069 .type = P_BOOL,
3070 .p_class = P_LOCAL,
3071 .offset = LOCAL_VAR(bKernelOplocks),
3072 .special = NULL,
3073 .enum_list = NULL,
3074 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3077 .label = "locking",
3078 .type = P_BOOL,
3079 .p_class = P_LOCAL,
3080 .offset = LOCAL_VAR(bLocking),
3081 .special = NULL,
3082 .enum_list = NULL,
3083 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3086 .label = "lock spin time",
3087 .type = P_INTEGER,
3088 .p_class = P_GLOBAL,
3089 .offset = GLOBAL_VAR(iLockSpinTime),
3090 .special = NULL,
3091 .enum_list = NULL,
3092 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3095 .label = "oplocks",
3096 .type = P_BOOL,
3097 .p_class = P_LOCAL,
3098 .offset = LOCAL_VAR(bOpLocks),
3099 .special = NULL,
3100 .enum_list = NULL,
3101 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3104 .label = "level2 oplocks",
3105 .type = P_BOOL,
3106 .p_class = P_LOCAL,
3107 .offset = LOCAL_VAR(bLevel2OpLocks),
3108 .special = NULL,
3109 .enum_list = NULL,
3110 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3113 .label = "oplock break wait time",
3114 .type = P_INTEGER,
3115 .p_class = P_GLOBAL,
3116 .offset = GLOBAL_VAR(oplock_break_wait_time),
3117 .special = NULL,
3118 .enum_list = NULL,
3119 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3122 .label = "oplock contention limit",
3123 .type = P_INTEGER,
3124 .p_class = P_LOCAL,
3125 .offset = LOCAL_VAR(iOplockContentionLimit),
3126 .special = NULL,
3127 .enum_list = NULL,
3128 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3131 .label = "posix locking",
3132 .type = P_BOOL,
3133 .p_class = P_LOCAL,
3134 .offset = LOCAL_VAR(bPosixLocking),
3135 .special = NULL,
3136 .enum_list = NULL,
3137 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3140 .label = "strict locking",
3141 .type = P_ENUM,
3142 .p_class = P_LOCAL,
3143 .offset = LOCAL_VAR(iStrictLocking),
3144 .special = NULL,
3145 .enum_list = enum_bool_auto,
3146 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3149 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3152 .label = "ldap admin dn",
3153 .type = P_STRING,
3154 .p_class = P_GLOBAL,
3155 .offset = GLOBAL_VAR(szLdapAdminDn),
3156 .special = NULL,
3157 .enum_list = NULL,
3158 .flags = FLAG_ADVANCED,
3161 .label = "ldap delete dn",
3162 .type = P_BOOL,
3163 .p_class = P_GLOBAL,
3164 .offset = GLOBAL_VAR(ldap_delete_dn),
3165 .special = NULL,
3166 .enum_list = NULL,
3167 .flags = FLAG_ADVANCED,
3170 .label = "ldap group suffix",
3171 .type = P_STRING,
3172 .p_class = P_GLOBAL,
3173 .offset = GLOBAL_VAR(szLdapGroupSuffix),
3174 .special = NULL,
3175 .enum_list = NULL,
3176 .flags = FLAG_ADVANCED,
3179 .label = "ldap idmap suffix",
3180 .type = P_STRING,
3181 .p_class = P_GLOBAL,
3182 .offset = GLOBAL_VAR(szLdapIdmapSuffix),
3183 .special = NULL,
3184 .enum_list = NULL,
3185 .flags = FLAG_ADVANCED,
3188 .label = "ldap machine suffix",
3189 .type = P_STRING,
3190 .p_class = P_GLOBAL,
3191 .offset = GLOBAL_VAR(szLdapMachineSuffix),
3192 .special = NULL,
3193 .enum_list = NULL,
3194 .flags = FLAG_ADVANCED,
3197 .label = "ldap passwd sync",
3198 .type = P_ENUM,
3199 .p_class = P_GLOBAL,
3200 .offset = GLOBAL_VAR(ldap_passwd_sync),
3201 .special = NULL,
3202 .enum_list = enum_ldap_passwd_sync,
3203 .flags = FLAG_ADVANCED,
3206 .label = "ldap password sync",
3207 .type = P_ENUM,
3208 .p_class = P_GLOBAL,
3209 .offset = GLOBAL_VAR(ldap_passwd_sync),
3210 .special = NULL,
3211 .enum_list = enum_ldap_passwd_sync,
3212 .flags = FLAG_HIDE,
3215 .label = "ldap replication sleep",
3216 .type = P_INTEGER,
3217 .p_class = P_GLOBAL,
3218 .offset = GLOBAL_VAR(ldap_replication_sleep),
3219 .special = NULL,
3220 .enum_list = NULL,
3221 .flags = FLAG_ADVANCED,
3224 .label = "ldap suffix",
3225 .type = P_STRING,
3226 .p_class = P_GLOBAL,
3227 .offset = GLOBAL_VAR(szLdapSuffix),
3228 .special = NULL,
3229 .enum_list = NULL,
3230 .flags = FLAG_ADVANCED,
3233 .label = "ldap ssl",
3234 .type = P_ENUM,
3235 .p_class = P_GLOBAL,
3236 .offset = GLOBAL_VAR(ldap_ssl),
3237 .special = NULL,
3238 .enum_list = enum_ldap_ssl,
3239 .flags = FLAG_ADVANCED,
3242 .label = "ldap ssl ads",
3243 .type = P_BOOL,
3244 .p_class = P_GLOBAL,
3245 .offset = GLOBAL_VAR(ldap_ssl_ads),
3246 .special = NULL,
3247 .enum_list = NULL,
3248 .flags = FLAG_ADVANCED,
3251 .label = "ldap deref",
3252 .type = P_ENUM,
3253 .p_class = P_GLOBAL,
3254 .offset = GLOBAL_VAR(ldap_deref),
3255 .special = NULL,
3256 .enum_list = enum_ldap_deref,
3257 .flags = FLAG_ADVANCED,
3260 .label = "ldap follow referral",
3261 .type = P_ENUM,
3262 .p_class = P_GLOBAL,
3263 .offset = GLOBAL_VAR(ldap_follow_referral),
3264 .special = NULL,
3265 .enum_list = enum_bool_auto,
3266 .flags = FLAG_ADVANCED,
3269 .label = "ldap timeout",
3270 .type = P_INTEGER,
3271 .p_class = P_GLOBAL,
3272 .offset = GLOBAL_VAR(ldap_timeout),
3273 .special = NULL,
3274 .enum_list = NULL,
3275 .flags = FLAG_ADVANCED,
3278 .label = "ldap connection timeout",
3279 .type = P_INTEGER,
3280 .p_class = P_GLOBAL,
3281 .offset = GLOBAL_VAR(ldap_connection_timeout),
3282 .special = NULL,
3283 .enum_list = NULL,
3284 .flags = FLAG_ADVANCED,
3287 .label = "ldap page size",
3288 .type = P_INTEGER,
3289 .p_class = P_GLOBAL,
3290 .offset = GLOBAL_VAR(ldap_page_size),
3291 .special = NULL,
3292 .enum_list = NULL,
3293 .flags = FLAG_ADVANCED,
3296 .label = "ldap user suffix",
3297 .type = P_STRING,
3298 .p_class = P_GLOBAL,
3299 .offset = GLOBAL_VAR(szLdapUserSuffix),
3300 .special = NULL,
3301 .enum_list = NULL,
3302 .flags = FLAG_ADVANCED,
3305 .label = "ldap debug level",
3306 .type = P_INTEGER,
3307 .p_class = P_GLOBAL,
3308 .offset = GLOBAL_VAR(ldap_debug_level),
3309 .special = handle_ldap_debug_level,
3310 .enum_list = NULL,
3311 .flags = FLAG_ADVANCED,
3314 .label = "ldap debug threshold",
3315 .type = P_INTEGER,
3316 .p_class = P_GLOBAL,
3317 .offset = GLOBAL_VAR(ldap_debug_threshold),
3318 .special = NULL,
3319 .enum_list = NULL,
3320 .flags = FLAG_ADVANCED,
3323 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3326 .label = "eventlog list",
3327 .type = P_LIST,
3328 .p_class = P_GLOBAL,
3329 .offset = GLOBAL_VAR(szEventLogs),
3330 .special = NULL,
3331 .enum_list = NULL,
3332 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3335 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3338 .label = "add share command",
3339 .type = P_STRING,
3340 .p_class = P_GLOBAL,
3341 .offset = GLOBAL_VAR(szAddShareCommand),
3342 .special = NULL,
3343 .enum_list = NULL,
3344 .flags = FLAG_ADVANCED,
3347 .label = "change share command",
3348 .type = P_STRING,
3349 .p_class = P_GLOBAL,
3350 .offset = GLOBAL_VAR(szChangeShareCommand),
3351 .special = NULL,
3352 .enum_list = NULL,
3353 .flags = FLAG_ADVANCED,
3356 .label = "delete share command",
3357 .type = P_STRING,
3358 .p_class = P_GLOBAL,
3359 .offset = GLOBAL_VAR(szDeleteShareCommand),
3360 .special = NULL,
3361 .enum_list = NULL,
3362 .flags = FLAG_ADVANCED,
3365 .label = "config file",
3366 .type = P_STRING,
3367 .p_class = P_GLOBAL,
3368 .offset = GLOBAL_VAR(szConfigFile),
3369 .special = NULL,
3370 .enum_list = NULL,
3371 .flags = FLAG_HIDE|FLAG_META,
3374 .label = "preload",
3375 .type = P_STRING,
3376 .p_class = P_GLOBAL,
3377 .offset = GLOBAL_VAR(szAutoServices),
3378 .special = NULL,
3379 .enum_list = NULL,
3380 .flags = FLAG_ADVANCED,
3383 .label = "auto services",
3384 .type = P_STRING,
3385 .p_class = P_GLOBAL,
3386 .offset = GLOBAL_VAR(szAutoServices),
3387 .special = NULL,
3388 .enum_list = NULL,
3389 .flags = FLAG_ADVANCED,
3392 .label = "lock directory",
3393 .type = P_STRING,
3394 .p_class = P_GLOBAL,
3395 .offset = GLOBAL_VAR(szLockDir),
3396 .special = NULL,
3397 .enum_list = NULL,
3398 .flags = FLAG_ADVANCED,
3401 .label = "lock dir",
3402 .type = P_STRING,
3403 .p_class = P_GLOBAL,
3404 .offset = GLOBAL_VAR(szLockDir),
3405 .special = NULL,
3406 .enum_list = NULL,
3407 .flags = FLAG_HIDE,
3410 .label = "state directory",
3411 .type = P_STRING,
3412 .p_class = P_GLOBAL,
3413 .offset = GLOBAL_VAR(szStateDir),
3414 .special = NULL,
3415 .enum_list = NULL,
3416 .flags = FLAG_ADVANCED,
3419 .label = "cache directory",
3420 .type = P_STRING,
3421 .p_class = P_GLOBAL,
3422 .offset = GLOBAL_VAR(szCacheDir),
3423 .special = NULL,
3424 .enum_list = NULL,
3425 .flags = FLAG_ADVANCED,
3428 .label = "pid directory",
3429 .type = P_STRING,
3430 .p_class = P_GLOBAL,
3431 .offset = GLOBAL_VAR(szPidDir),
3432 .special = NULL,
3433 .enum_list = NULL,
3434 .flags = FLAG_ADVANCED,
3437 .label = "ntp signd socket directory",
3438 .type = P_STRING,
3439 .p_class = P_GLOBAL,
3440 .offset = GLOBAL_VAR(szNTPSignDSocketDirectory),
3441 .special = NULL,
3442 .enum_list = NULL,
3443 .flags = FLAG_ADVANCED,
3446 #ifdef WITH_UTMP
3448 .label = "utmp directory",
3449 .type = P_STRING,
3450 .p_class = P_GLOBAL,
3451 .offset = GLOBAL_VAR(szUtmpDir),
3452 .special = NULL,
3453 .enum_list = NULL,
3454 .flags = FLAG_ADVANCED,
3457 .label = "wtmp directory",
3458 .type = P_STRING,
3459 .p_class = P_GLOBAL,
3460 .offset = GLOBAL_VAR(szWtmpDir),
3461 .special = NULL,
3462 .enum_list = NULL,
3463 .flags = FLAG_ADVANCED,
3466 .label = "utmp",
3467 .type = P_BOOL,
3468 .p_class = P_GLOBAL,
3469 .offset = GLOBAL_VAR(bUtmp),
3470 .special = NULL,
3471 .enum_list = NULL,
3472 .flags = FLAG_ADVANCED,
3474 #endif
3476 .label = "default service",
3477 .type = P_STRING,
3478 .p_class = P_GLOBAL,
3479 .offset = GLOBAL_VAR(szDefaultService),
3480 .special = NULL,
3481 .enum_list = NULL,
3482 .flags = FLAG_ADVANCED,
3485 .label = "default",
3486 .type = P_STRING,
3487 .p_class = P_GLOBAL,
3488 .offset = GLOBAL_VAR(szDefaultService),
3489 .special = NULL,
3490 .enum_list = NULL,
3491 .flags = FLAG_ADVANCED,
3494 .label = "message command",
3495 .type = P_STRING,
3496 .p_class = P_GLOBAL,
3497 .offset = GLOBAL_VAR(szMsgCommand),
3498 .special = NULL,
3499 .enum_list = NULL,
3500 .flags = FLAG_ADVANCED,
3503 .label = "dfree cache time",
3504 .type = P_INTEGER,
3505 .p_class = P_LOCAL,
3506 .offset = LOCAL_VAR(iDfreeCacheTime),
3507 .special = NULL,
3508 .enum_list = NULL,
3509 .flags = FLAG_ADVANCED,
3512 .label = "dfree command",
3513 .type = P_STRING,
3514 .p_class = P_LOCAL,
3515 .offset = LOCAL_VAR(szDfree),
3516 .special = NULL,
3517 .enum_list = NULL,
3518 .flags = FLAG_ADVANCED,
3521 .label = "get quota command",
3522 .type = P_STRING,
3523 .p_class = P_GLOBAL,
3524 .offset = GLOBAL_VAR(szGetQuota),
3525 .special = NULL,
3526 .enum_list = NULL,
3527 .flags = FLAG_ADVANCED,
3530 .label = "set quota command",
3531 .type = P_STRING,
3532 .p_class = P_GLOBAL,
3533 .offset = GLOBAL_VAR(szSetQuota),
3534 .special = NULL,
3535 .enum_list = NULL,
3536 .flags = FLAG_ADVANCED,
3539 .label = "remote announce",
3540 .type = P_STRING,
3541 .p_class = P_GLOBAL,
3542 .offset = GLOBAL_VAR(szRemoteAnnounce),
3543 .special = NULL,
3544 .enum_list = NULL,
3545 .flags = FLAG_ADVANCED,
3548 .label = "remote browse sync",
3549 .type = P_STRING,
3550 .p_class = P_GLOBAL,
3551 .offset = GLOBAL_VAR(szRemoteBrowseSync),
3552 .special = NULL,
3553 .enum_list = NULL,
3554 .flags = FLAG_ADVANCED,
3557 .label = "socket address",
3558 .type = P_STRING,
3559 .p_class = P_GLOBAL,
3560 .offset = GLOBAL_VAR(szSocketAddress),
3561 .special = NULL,
3562 .enum_list = NULL,
3563 .flags = FLAG_ADVANCED,
3566 .label = "nmbd bind explicit broadcast",
3567 .type = P_BOOL,
3568 .p_class = P_GLOBAL,
3569 .offset = GLOBAL_VAR(bNmbdBindExplicitBroadcast),
3570 .special = NULL,
3571 .enum_list = NULL,
3572 .flags = FLAG_ADVANCED,
3575 .label = "homedir map",
3576 .type = P_STRING,
3577 .p_class = P_GLOBAL,
3578 .offset = GLOBAL_VAR(szNISHomeMapName),
3579 .special = NULL,
3580 .enum_list = NULL,
3581 .flags = FLAG_ADVANCED,
3584 .label = "afs username map",
3585 .type = P_STRING,
3586 .p_class = P_GLOBAL,
3587 .offset = GLOBAL_VAR(szAfsUsernameMap),
3588 .special = NULL,
3589 .enum_list = NULL,
3590 .flags = FLAG_ADVANCED,
3593 .label = "afs token lifetime",
3594 .type = P_INTEGER,
3595 .p_class = P_GLOBAL,
3596 .offset = GLOBAL_VAR(iAfsTokenLifetime),
3597 .special = NULL,
3598 .enum_list = NULL,
3599 .flags = FLAG_ADVANCED,
3602 .label = "log nt token command",
3603 .type = P_STRING,
3604 .p_class = P_GLOBAL,
3605 .offset = GLOBAL_VAR(szLogNtTokenCommand),
3606 .special = NULL,
3607 .enum_list = NULL,
3608 .flags = FLAG_ADVANCED,
3611 .label = "NIS homedir",
3612 .type = P_BOOL,
3613 .p_class = P_GLOBAL,
3614 .offset = GLOBAL_VAR(bNISHomeMap),
3615 .special = NULL,
3616 .enum_list = NULL,
3617 .flags = FLAG_ADVANCED,
3620 .label = "-valid",
3621 .type = P_BOOL,
3622 .p_class = P_LOCAL,
3623 .offset = LOCAL_VAR(valid),
3624 .special = NULL,
3625 .enum_list = NULL,
3626 .flags = FLAG_HIDE,
3629 .label = "copy",
3630 .type = P_STRING,
3631 .p_class = P_LOCAL,
3632 .offset = LOCAL_VAR(szCopy),
3633 .special = handle_copy,
3634 .enum_list = NULL,
3635 .flags = FLAG_HIDE,
3638 .label = "include",
3639 .type = P_STRING,
3640 .p_class = P_LOCAL,
3641 .offset = LOCAL_VAR(szInclude),
3642 .special = handle_include,
3643 .enum_list = NULL,
3644 .flags = FLAG_HIDE|FLAG_META,
3647 .label = "preexec",
3648 .type = P_STRING,
3649 .p_class = P_LOCAL,
3650 .offset = LOCAL_VAR(szPreExec),
3651 .special = NULL,
3652 .enum_list = NULL,
3653 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3656 .label = "exec",
3657 .type = P_STRING,
3658 .p_class = P_LOCAL,
3659 .offset = LOCAL_VAR(szPreExec),
3660 .special = NULL,
3661 .enum_list = NULL,
3662 .flags = FLAG_ADVANCED,
3665 .label = "preexec close",
3666 .type = P_BOOL,
3667 .p_class = P_LOCAL,
3668 .offset = LOCAL_VAR(bPreexecClose),
3669 .special = NULL,
3670 .enum_list = NULL,
3671 .flags = FLAG_ADVANCED | FLAG_SHARE,
3674 .label = "postexec",
3675 .type = P_STRING,
3676 .p_class = P_LOCAL,
3677 .offset = LOCAL_VAR(szPostExec),
3678 .special = NULL,
3679 .enum_list = NULL,
3680 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3683 .label = "root preexec",
3684 .type = P_STRING,
3685 .p_class = P_LOCAL,
3686 .offset = LOCAL_VAR(szRootPreExec),
3687 .special = NULL,
3688 .enum_list = NULL,
3689 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3692 .label = "root preexec close",
3693 .type = P_BOOL,
3694 .p_class = P_LOCAL,
3695 .offset = LOCAL_VAR(bRootpreexecClose),
3696 .special = NULL,
3697 .enum_list = NULL,
3698 .flags = FLAG_ADVANCED | FLAG_SHARE,
3701 .label = "root postexec",
3702 .type = P_STRING,
3703 .p_class = P_LOCAL,
3704 .offset = LOCAL_VAR(szRootPostExec),
3705 .special = NULL,
3706 .enum_list = NULL,
3707 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3710 .label = "available",
3711 .type = P_BOOL,
3712 .p_class = P_LOCAL,
3713 .offset = LOCAL_VAR(bAvailable),
3714 .special = NULL,
3715 .enum_list = NULL,
3716 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3719 .label = "registry shares",
3720 .type = P_BOOL,
3721 .p_class = P_GLOBAL,
3722 .offset = GLOBAL_VAR(bRegistryShares),
3723 .special = NULL,
3724 .enum_list = NULL,
3725 .flags = FLAG_ADVANCED,
3728 .label = "usershare allow guests",
3729 .type = P_BOOL,
3730 .p_class = P_GLOBAL,
3731 .offset = GLOBAL_VAR(bUsershareAllowGuests),
3732 .special = NULL,
3733 .enum_list = NULL,
3734 .flags = FLAG_ADVANCED,
3737 .label = "usershare max shares",
3738 .type = P_INTEGER,
3739 .p_class = P_GLOBAL,
3740 .offset = GLOBAL_VAR(iUsershareMaxShares),
3741 .special = NULL,
3742 .enum_list = NULL,
3743 .flags = FLAG_ADVANCED,
3746 .label = "usershare owner only",
3747 .type = P_BOOL,
3748 .p_class = P_GLOBAL,
3749 .offset = GLOBAL_VAR(bUsershareOwnerOnly),
3750 .special = NULL,
3751 .enum_list = NULL,
3752 .flags = FLAG_ADVANCED,
3755 .label = "usershare path",
3756 .type = P_STRING,
3757 .p_class = P_GLOBAL,
3758 .offset = GLOBAL_VAR(szUsersharePath),
3759 .special = NULL,
3760 .enum_list = NULL,
3761 .flags = FLAG_ADVANCED,
3764 .label = "usershare prefix allow list",
3765 .type = P_LIST,
3766 .p_class = P_GLOBAL,
3767 .offset = GLOBAL_VAR(szUsersharePrefixAllowList),
3768 .special = NULL,
3769 .enum_list = NULL,
3770 .flags = FLAG_ADVANCED,
3773 .label = "usershare prefix deny list",
3774 .type = P_LIST,
3775 .p_class = P_GLOBAL,
3776 .offset = GLOBAL_VAR(szUsersharePrefixDenyList),
3777 .special = NULL,
3778 .enum_list = NULL,
3779 .flags = FLAG_ADVANCED,
3782 .label = "usershare template share",
3783 .type = P_STRING,
3784 .p_class = P_GLOBAL,
3785 .offset = GLOBAL_VAR(szUsershareTemplateShare),
3786 .special = NULL,
3787 .enum_list = NULL,
3788 .flags = FLAG_ADVANCED,
3791 .label = "volume",
3792 .type = P_STRING,
3793 .p_class = P_LOCAL,
3794 .offset = LOCAL_VAR(volume),
3795 .special = NULL,
3796 .enum_list = NULL,
3797 .flags = FLAG_ADVANCED | FLAG_SHARE,
3800 .label = "fstype",
3801 .type = P_STRING,
3802 .p_class = P_LOCAL,
3803 .offset = LOCAL_VAR(fstype),
3804 .special = NULL,
3805 .enum_list = NULL,
3806 .flags = FLAG_ADVANCED | FLAG_SHARE,
3809 .label = "set directory",
3810 .type = P_BOOLREV,
3811 .p_class = P_LOCAL,
3812 .offset = LOCAL_VAR(bNo_set_dir),
3813 .special = NULL,
3814 .enum_list = NULL,
3815 .flags = FLAG_ADVANCED | FLAG_SHARE,
3818 .label = "allow insecure wide links",
3819 .type = P_BOOL,
3820 .p_class = P_GLOBAL,
3821 .offset = GLOBAL_VAR(bAllowInsecureWidelinks),
3822 .special = NULL,
3823 .enum_list = NULL,
3824 .flags = FLAG_ADVANCED,
3827 .label = "wide links",
3828 .type = P_BOOL,
3829 .p_class = P_LOCAL,
3830 .offset = LOCAL_VAR(bWidelinks),
3831 .special = NULL,
3832 .enum_list = NULL,
3833 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3836 .label = "follow symlinks",
3837 .type = P_BOOL,
3838 .p_class = P_LOCAL,
3839 .offset = LOCAL_VAR(bSymlinks),
3840 .special = NULL,
3841 .enum_list = NULL,
3842 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3845 .label = "dont descend",
3846 .type = P_STRING,
3847 .p_class = P_LOCAL,
3848 .offset = LOCAL_VAR(szDontdescend),
3849 .special = NULL,
3850 .enum_list = NULL,
3851 .flags = FLAG_ADVANCED | FLAG_SHARE,
3854 .label = "magic script",
3855 .type = P_STRING,
3856 .p_class = P_LOCAL,
3857 .offset = LOCAL_VAR(szMagicScript),
3858 .special = NULL,
3859 .enum_list = NULL,
3860 .flags = FLAG_ADVANCED | FLAG_SHARE,
3863 .label = "magic output",
3864 .type = P_STRING,
3865 .p_class = P_LOCAL,
3866 .offset = LOCAL_VAR(szMagicOutput),
3867 .special = NULL,
3868 .enum_list = NULL,
3869 .flags = FLAG_ADVANCED | FLAG_SHARE,
3872 .label = "delete readonly",
3873 .type = P_BOOL,
3874 .p_class = P_LOCAL,
3875 .offset = LOCAL_VAR(bDeleteReadonly),
3876 .special = NULL,
3877 .enum_list = NULL,
3878 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3881 .label = "dos filemode",
3882 .type = P_BOOL,
3883 .p_class = P_LOCAL,
3884 .offset = LOCAL_VAR(bDosFilemode),
3885 .special = NULL,
3886 .enum_list = NULL,
3887 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3890 .label = "dos filetimes",
3891 .type = P_BOOL,
3892 .p_class = P_LOCAL,
3893 .offset = LOCAL_VAR(bDosFiletimes),
3894 .special = NULL,
3895 .enum_list = NULL,
3896 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3899 .label = "dos filetime resolution",
3900 .type = P_BOOL,
3901 .p_class = P_LOCAL,
3902 .offset = LOCAL_VAR(bDosFiletimeResolution),
3903 .special = NULL,
3904 .enum_list = NULL,
3905 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3908 .label = "fake directory create times",
3909 .type = P_BOOL,
3910 .p_class = P_LOCAL,
3911 .offset = LOCAL_VAR(bFakeDirCreateTimes),
3912 .special = NULL,
3913 .enum_list = NULL,
3914 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3917 .label = "async smb echo handler",
3918 .type = P_BOOL,
3919 .p_class = P_GLOBAL,
3920 .offset = GLOBAL_VAR(bAsyncSMBEchoHandler),
3921 .special = NULL,
3922 .enum_list = NULL,
3923 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3926 .label = "panic action",
3927 .type = P_STRING,
3928 .p_class = P_GLOBAL,
3929 .offset = GLOBAL_VAR(szPanicAction),
3930 .special = NULL,
3931 .enum_list = NULL,
3932 .flags = FLAG_ADVANCED,
3935 .label = "perfcount module",
3936 .type = P_STRING,
3937 .p_class = P_GLOBAL,
3938 .offset = GLOBAL_VAR(szSMBPerfcountModule),
3939 .special = NULL,
3940 .enum_list = NULL,
3941 .flags = FLAG_ADVANCED,
3944 {N_("VFS module options"), P_SEP, P_SEPARATOR},
3947 .label = "vfs objects",
3948 .type = P_LIST,
3949 .p_class = P_LOCAL,
3950 .offset = LOCAL_VAR(szVfsObjects),
3951 .special = NULL,
3952 .enum_list = NULL,
3953 .flags = FLAG_ADVANCED | FLAG_SHARE,
3956 .label = "vfs object",
3957 .type = P_LIST,
3958 .p_class = P_LOCAL,
3959 .offset = LOCAL_VAR(szVfsObjects),
3960 .special = NULL,
3961 .enum_list = NULL,
3962 .flags = FLAG_HIDE,
3966 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
3969 .label = "msdfs root",
3970 .type = P_BOOL,
3971 .p_class = P_LOCAL,
3972 .offset = LOCAL_VAR(bMSDfsRoot),
3973 .special = NULL,
3974 .enum_list = NULL,
3975 .flags = FLAG_ADVANCED | FLAG_SHARE,
3978 .label = "msdfs proxy",
3979 .type = P_STRING,
3980 .p_class = P_LOCAL,
3981 .offset = LOCAL_VAR(szMSDfsProxy),
3982 .special = NULL,
3983 .enum_list = NULL,
3984 .flags = FLAG_ADVANCED | FLAG_SHARE,
3987 .label = "host msdfs",
3988 .type = P_BOOL,
3989 .p_class = P_GLOBAL,
3990 .offset = GLOBAL_VAR(bHostMSDfs),
3991 .special = NULL,
3992 .enum_list = NULL,
3993 .flags = FLAG_ADVANCED,
3996 {N_("Winbind options"), P_SEP, P_SEPARATOR},
3999 .label = "passdb expand explicit",
4000 .type = P_BOOL,
4001 .p_class = P_GLOBAL,
4002 .offset = GLOBAL_VAR(bPassdbExpandExplicit),
4003 .special = NULL,
4004 .enum_list = NULL,
4005 .flags = FLAG_ADVANCED,
4008 .label = "idmap backend",
4009 .type = P_STRING,
4010 .p_class = P_GLOBAL,
4011 .offset = GLOBAL_VAR(szIdmapBackend),
4012 .special = handle_idmap_backend,
4013 .enum_list = NULL,
4014 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4017 .label = "idmap cache time",
4018 .type = P_INTEGER,
4019 .p_class = P_GLOBAL,
4020 .offset = GLOBAL_VAR(iIdmapCacheTime),
4021 .special = NULL,
4022 .enum_list = NULL,
4023 .flags = FLAG_ADVANCED,
4026 .label = "idmap negative cache time",
4027 .type = P_INTEGER,
4028 .p_class = P_GLOBAL,
4029 .offset = GLOBAL_VAR(iIdmapNegativeCacheTime),
4030 .special = NULL,
4031 .enum_list = NULL,
4032 .flags = FLAG_ADVANCED,
4035 .label = "idmap uid",
4036 .type = P_STRING,
4037 .p_class = P_GLOBAL,
4038 .offset = GLOBAL_VAR(szIdmapUID),
4039 .special = handle_idmap_uid,
4040 .enum_list = NULL,
4041 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4044 .label = "winbind uid",
4045 .type = P_STRING,
4046 .p_class = P_GLOBAL,
4047 .offset = GLOBAL_VAR(szIdmapUID),
4048 .special = handle_idmap_uid,
4049 .enum_list = NULL,
4050 .flags = FLAG_HIDE,
4053 .label = "idmap gid",
4054 .type = P_STRING,
4055 .p_class = P_GLOBAL,
4056 .offset = GLOBAL_VAR(szIdmapGID),
4057 .special = handle_idmap_gid,
4058 .enum_list = NULL,
4059 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4062 .label = "winbind gid",
4063 .type = P_STRING,
4064 .p_class = P_GLOBAL,
4065 .offset = GLOBAL_VAR(szIdmapGID),
4066 .special = handle_idmap_gid,
4067 .enum_list = NULL,
4068 .flags = FLAG_HIDE,
4071 .label = "template homedir",
4072 .type = P_STRING,
4073 .p_class = P_GLOBAL,
4074 .offset = GLOBAL_VAR(szTemplateHomedir),
4075 .special = NULL,
4076 .enum_list = NULL,
4077 .flags = FLAG_ADVANCED,
4080 .label = "template shell",
4081 .type = P_STRING,
4082 .p_class = P_GLOBAL,
4083 .offset = GLOBAL_VAR(szTemplateShell),
4084 .special = NULL,
4085 .enum_list = NULL,
4086 .flags = FLAG_ADVANCED,
4089 .label = "winbind separator",
4090 .type = P_STRING,
4091 .p_class = P_GLOBAL,
4092 .offset = GLOBAL_VAR(szWinbindSeparator),
4093 .special = NULL,
4094 .enum_list = NULL,
4095 .flags = FLAG_ADVANCED,
4098 .label = "winbind cache time",
4099 .type = P_INTEGER,
4100 .p_class = P_GLOBAL,
4101 .offset = GLOBAL_VAR(winbind_cache_time),
4102 .special = NULL,
4103 .enum_list = NULL,
4104 .flags = FLAG_ADVANCED,
4107 .label = "winbind reconnect delay",
4108 .type = P_INTEGER,
4109 .p_class = P_GLOBAL,
4110 .offset = GLOBAL_VAR(winbind_reconnect_delay),
4111 .special = NULL,
4112 .enum_list = NULL,
4113 .flags = FLAG_ADVANCED,
4116 .label = "winbind max clients",
4117 .type = P_INTEGER,
4118 .p_class = P_GLOBAL,
4119 .offset = GLOBAL_VAR(winbind_max_clients),
4120 .special = NULL,
4121 .enum_list = NULL,
4122 .flags = FLAG_ADVANCED,
4125 .label = "winbind enum users",
4126 .type = P_BOOL,
4127 .p_class = P_GLOBAL,
4128 .offset = GLOBAL_VAR(bWinbindEnumUsers),
4129 .special = NULL,
4130 .enum_list = NULL,
4131 .flags = FLAG_ADVANCED,
4134 .label = "winbind enum groups",
4135 .type = P_BOOL,
4136 .p_class = P_GLOBAL,
4137 .offset = GLOBAL_VAR(bWinbindEnumGroups),
4138 .special = NULL,
4139 .enum_list = NULL,
4140 .flags = FLAG_ADVANCED,
4143 .label = "winbind use default domain",
4144 .type = P_BOOL,
4145 .p_class = P_GLOBAL,
4146 .offset = GLOBAL_VAR(bWinbindUseDefaultDomain),
4147 .special = NULL,
4148 .enum_list = NULL,
4149 .flags = FLAG_ADVANCED,
4152 .label = "winbind trusted domains only",
4153 .type = P_BOOL,
4154 .p_class = P_GLOBAL,
4155 .offset = GLOBAL_VAR(bWinbindTrustedDomainsOnly),
4156 .special = NULL,
4157 .enum_list = NULL,
4158 .flags = FLAG_ADVANCED,
4161 .label = "winbind nested groups",
4162 .type = P_BOOL,
4163 .p_class = P_GLOBAL,
4164 .offset = GLOBAL_VAR(bWinbindNestedGroups),
4165 .special = NULL,
4166 .enum_list = NULL,
4167 .flags = FLAG_ADVANCED,
4170 .label = "winbind expand groups",
4171 .type = P_INTEGER,
4172 .p_class = P_GLOBAL,
4173 .offset = GLOBAL_VAR(winbind_expand_groups),
4174 .special = NULL,
4175 .enum_list = NULL,
4176 .flags = FLAG_ADVANCED,
4179 .label = "winbind nss info",
4180 .type = P_LIST,
4181 .p_class = P_GLOBAL,
4182 .offset = GLOBAL_VAR(szWinbindNssInfo),
4183 .special = NULL,
4184 .enum_list = NULL,
4185 .flags = FLAG_ADVANCED,
4188 .label = "winbind refresh tickets",
4189 .type = P_BOOL,
4190 .p_class = P_GLOBAL,
4191 .offset = GLOBAL_VAR(bWinbindRefreshTickets),
4192 .special = NULL,
4193 .enum_list = NULL,
4194 .flags = FLAG_ADVANCED,
4197 .label = "winbind offline logon",
4198 .type = P_BOOL,
4199 .p_class = P_GLOBAL,
4200 .offset = GLOBAL_VAR(bWinbindOfflineLogon),
4201 .special = NULL,
4202 .enum_list = NULL,
4203 .flags = FLAG_ADVANCED,
4206 .label = "winbind normalize names",
4207 .type = P_BOOL,
4208 .p_class = P_GLOBAL,
4209 .offset = GLOBAL_VAR(bWinbindNormalizeNames),
4210 .special = NULL,
4211 .enum_list = NULL,
4212 .flags = FLAG_ADVANCED,
4215 .label = "winbind rpc only",
4216 .type = P_BOOL,
4217 .p_class = P_GLOBAL,
4218 .offset = GLOBAL_VAR(bWinbindRpcOnly),
4219 .special = NULL,
4220 .enum_list = NULL,
4221 .flags = FLAG_ADVANCED,
4224 .label = "create krb5 conf",
4225 .type = P_BOOL,
4226 .p_class = P_GLOBAL,
4227 .offset = GLOBAL_VAR(bCreateKrb5Conf),
4228 .special = NULL,
4229 .enum_list = NULL,
4230 .flags = FLAG_ADVANCED,
4233 .label = "ncalrpc dir",
4234 .type = P_STRING,
4235 .p_class = P_GLOBAL,
4236 .offset = GLOBAL_VAR(ncalrpc_dir),
4237 .special = NULL,
4238 .enum_list = NULL,
4239 .flags = FLAG_ADVANCED,
4242 .label = "winbind max domain connections",
4243 .type = P_INTEGER,
4244 .p_class = P_GLOBAL,
4245 .offset = GLOBAL_VAR(winbindMaxDomainConnections),
4246 .special = NULL,
4247 .enum_list = NULL,
4248 .flags = FLAG_ADVANCED,
4251 .label = "winbindd socket directory",
4252 .type = P_STRING,
4253 .p_class = P_GLOBAL,
4254 .offset = GLOBAL_VAR(szWinbinddSocketDirectory),
4255 .special = NULL,
4256 .enum_list = NULL,
4257 .flags = FLAG_ADVANCED,
4260 .label = "winbindd privileged socket directory",
4261 .type = P_STRING,
4262 .p_class = P_GLOBAL,
4263 .offset = GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory),
4264 .special = NULL,
4265 .enum_list = NULL,
4266 .flags = FLAG_ADVANCED,
4269 .label = "winbind sealed pipes",
4270 .type = P_BOOL,
4271 .p_class = P_GLOBAL,
4272 .offset = GLOBAL_VAR(bWinbindSealedPipes),
4273 .special = NULL,
4274 .enum_list = NULL,
4275 .flags = FLAG_ADVANCED,
4278 {N_("DNS options"), P_SEP, P_SEPARATOR},
4280 .label = "allow dns updates",
4281 .type = P_ENUM,
4282 .p_class = P_GLOBAL,
4283 .offset = GLOBAL_VAR(allow_dns_updates),
4284 .special = NULL,
4285 .enum_list = enum_dns_update_settings,
4286 .flags = FLAG_ADVANCED,
4289 .label = "dns forwarder",
4290 .type = P_STRING,
4291 .p_class = P_GLOBAL,
4292 .offset = GLOBAL_VAR(dns_forwarder),
4293 .special = NULL,
4294 .enum_list = NULL,
4295 .flags = FLAG_ADVANCED,
4298 .label = "dns recursive queries",
4299 .type = P_BOOL,
4300 .p_class = P_GLOBAL,
4301 .offset = GLOBAL_VAR(dns_recursive_queries),
4302 .special = NULL,
4303 .enum_list = NULL
4306 .label = "dns update command",
4307 .type = P_CMDLIST,
4308 .p_class = P_GLOBAL,
4309 .offset = GLOBAL_VAR(szDNSUpdateCommand),
4310 .special = NULL,
4311 .enum_list = NULL,
4312 .flags = FLAG_ADVANCED,
4315 .label = "nsupdate command",
4316 .type = P_CMDLIST,
4317 .p_class = P_GLOBAL,
4318 .offset = GLOBAL_VAR(szNSUpdateCommand),
4319 .special = NULL,
4320 .enum_list = NULL,
4321 .flags = FLAG_ADVANCED,
4324 .label = "rndc command",
4325 .type = P_CMDLIST,
4326 .p_class = P_GLOBAL,
4327 .offset = GLOBAL_VAR(szRNDCCommand),
4328 .special = NULL,
4329 .enum_list = NULL,
4330 .flags = FLAG_ADVANCED,
4333 .label = "multicast dns register",
4334 .type = P_BOOL,
4335 .p_class = P_GLOBAL,
4336 .offset = GLOBAL_VAR(bMulticastDnsRegister),
4337 .special = NULL,
4338 .enum_list = NULL,
4339 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4342 {N_("AD DC options"), P_SEP, P_SEPARATOR},
4345 .label = "samba kcc command",
4346 .type = P_CMDLIST,
4347 .p_class = P_GLOBAL,
4348 .offset = GLOBAL_VAR(szSambaKCCCommand),
4349 .special = NULL,
4350 .enum_list = NULL,
4351 .flags = FLAG_ADVANCED,
4354 .label = "server services",
4355 .type = P_LIST,
4356 .p_class = P_GLOBAL,
4357 .offset = GLOBAL_VAR(server_services),
4358 .special = NULL,
4359 .enum_list = NULL
4362 .label = "dcerpc endpoint servers",
4363 .type = P_LIST,
4364 .p_class = P_GLOBAL,
4365 .offset = GLOBAL_VAR(dcerpc_ep_servers),
4366 .special = NULL,
4367 .enum_list = NULL
4370 .label = "spn update command",
4371 .type = P_CMDLIST,
4372 .p_class = P_GLOBAL,
4373 .offset = GLOBAL_VAR(szSPNUpdateCommand),
4374 .special = NULL,
4375 .enum_list = NULL,
4376 .flags = FLAG_ADVANCED,
4379 .label = "share backend",
4380 .type = P_STRING,
4381 .p_class = P_GLOBAL,
4382 .offset = GLOBAL_VAR(szShareBackend),
4383 .special = NULL,
4384 .enum_list = NULL
4387 .label = "ntvfs handler",
4388 .type = P_LIST,
4389 .p_class = P_LOCAL,
4390 .offset = LOCAL_VAR(ntvfs_handler),
4391 .special = NULL,
4392 .enum_list = NULL
4395 {N_("TLS options"), P_SEP, P_SEPARATOR},
4398 .label = "tls enabled",
4399 .type = P_BOOL,
4400 .p_class = P_GLOBAL,
4401 .offset = GLOBAL_VAR(tls_enabled),
4402 .special = NULL,
4403 .enum_list = NULL
4406 .label = "tls keyfile",
4407 .type = P_STRING,
4408 .p_class = P_GLOBAL,
4409 .offset = GLOBAL_VAR(tls_keyfile),
4410 .special = NULL,
4411 .enum_list = NULL
4414 .label = "tls certfile",
4415 .type = P_STRING,
4416 .p_class = P_GLOBAL,
4417 .offset = GLOBAL_VAR(tls_certfile),
4418 .special = NULL,
4419 .enum_list = NULL
4422 .label = "tls cafile",
4423 .type = P_STRING,
4424 .p_class = P_GLOBAL,
4425 .offset = GLOBAL_VAR(tls_cafile),
4426 .special = NULL,
4427 .enum_list = NULL
4430 .label = "tls crlfile",
4431 .type = P_STRING,
4432 .p_class = P_GLOBAL,
4433 .offset = GLOBAL_VAR(tls_crlfile),
4434 .special = NULL,
4435 .enum_list = NULL
4438 .label = "tls dh params file",
4439 .type = P_STRING,
4440 .p_class = P_GLOBAL,
4441 .offset = GLOBAL_VAR(tls_dhpfile),
4442 .special = NULL,
4443 .enum_list = NULL
4446 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
4449 /***************************************************************************
4450 Initialise the sDefault parameter structure for the printer values.
4451 ***************************************************************************/
4453 static void init_printer_values(struct loadparm_service *pService)
4455 /* choose defaults depending on the type of printing */
4456 switch (pService->iPrinting) {
4457 case PRINT_BSD:
4458 case PRINT_AIX:
4459 case PRINT_LPRNT:
4460 case PRINT_LPROS2:
4461 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4462 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4463 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4464 break;
4466 case PRINT_LPRNG:
4467 case PRINT_PLP:
4468 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4469 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4470 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4471 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4472 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4473 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4474 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4475 break;
4477 case PRINT_CUPS:
4478 case PRINT_IPRINT:
4479 #ifdef HAVE_CUPS
4480 /* set the lpq command to contain the destination printer
4481 name only. This is used by cups_queue_get() */
4482 string_set(&pService->szLpqcommand, "%p");
4483 string_set(&pService->szLprmcommand, "");
4484 string_set(&pService->szPrintcommand, "");
4485 string_set(&pService->szLppausecommand, "");
4486 string_set(&pService->szLpresumecommand, "");
4487 string_set(&pService->szQueuepausecommand, "");
4488 string_set(&pService->szQueueresumecommand, "");
4489 #else
4490 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4491 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4492 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4493 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4494 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4495 string_set(&pService->szQueuepausecommand, "disable '%p'");
4496 string_set(&pService->szQueueresumecommand, "enable '%p'");
4497 #endif /* HAVE_CUPS */
4498 break;
4500 case PRINT_SYSV:
4501 case PRINT_HPUX:
4502 string_set(&pService->szLpqcommand, "lpstat -o%p");
4503 string_set(&pService->szLprmcommand, "cancel %p-%j");
4504 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4505 string_set(&pService->szQueuepausecommand, "disable %p");
4506 string_set(&pService->szQueueresumecommand, "enable %p");
4507 #ifndef HPUX
4508 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4509 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4510 #endif /* HPUX */
4511 break;
4513 case PRINT_QNX:
4514 string_set(&pService->szLpqcommand, "lpq -P%p");
4515 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4516 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4517 break;
4519 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
4521 case PRINT_TEST:
4522 case PRINT_VLP: {
4523 const char *tdbfile;
4524 TALLOC_CTX *tmp_ctx = talloc_stackframe();
4525 char *tmp;
4527 tdbfile = talloc_asprintf(
4528 tmp_ctx, "tdbfile=%s",
4529 lp_parm_const_string(-1, "vlp", "tdbfile",
4530 "/tmp/vlp.tdb"));
4531 if (tdbfile == NULL) {
4532 tdbfile="tdbfile=/tmp/vlp.tdb";
4535 tmp = talloc_asprintf(tmp_ctx, "vlp %s print %%p %%s",
4536 tdbfile);
4537 string_set(&pService->szPrintcommand,
4538 tmp ? tmp : "vlp print %p %s");
4540 tmp = talloc_asprintf(tmp_ctx, "vlp %s lpq %%p",
4541 tdbfile);
4542 string_set(&pService->szLpqcommand,
4543 tmp ? tmp : "vlp lpq %p");
4545 tmp = talloc_asprintf(tmp_ctx, "vlp %s lprm %%p %%j",
4546 tdbfile);
4547 string_set(&pService->szLprmcommand,
4548 tmp ? tmp : "vlp lprm %p %j");
4550 tmp = talloc_asprintf(tmp_ctx, "vlp %s lppause %%p %%j",
4551 tdbfile);
4552 string_set(&pService->szLppausecommand,
4553 tmp ? tmp : "vlp lppause %p %j");
4555 tmp = talloc_asprintf(tmp_ctx, "vlp %s lpresume %%p %%j",
4556 tdbfile);
4557 string_set(&pService->szLpresumecommand,
4558 tmp ? tmp : "vlp lpresume %p %j");
4560 tmp = talloc_asprintf(tmp_ctx, "vlp %s queuepause %%p",
4561 tdbfile);
4562 string_set(&pService->szQueuepausecommand,
4563 tmp ? tmp : "vlp queuepause %p");
4565 tmp = talloc_asprintf(tmp_ctx, "vlp %s queueresume %%p",
4566 tdbfile);
4567 string_set(&pService->szQueueresumecommand,
4568 tmp ? tmp : "vlp queueresume %p");
4569 TALLOC_FREE(tmp_ctx);
4571 break;
4573 #endif /* DEVELOPER */
4578 * Function to return the default value for the maximum number of open
4579 * file descriptors permitted. This function tries to consult the
4580 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4581 * the smaller of those.
4583 static int max_open_files(void)
4585 int sysctl_max = MAX_OPEN_FILES;
4586 int rlimit_max = MAX_OPEN_FILES;
4588 #ifdef HAVE_SYSCTLBYNAME
4590 size_t size = sizeof(sysctl_max);
4591 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4594 #endif
4596 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4598 struct rlimit rl;
4600 ZERO_STRUCT(rl);
4602 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4603 rlimit_max = rl.rlim_cur;
4605 #if defined(RLIM_INFINITY)
4606 if(rl.rlim_cur == RLIM_INFINITY)
4607 rlimit_max = MAX_OPEN_FILES;
4608 #endif
4610 #endif
4612 if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4613 DEBUG(2,("max_open_files: increasing sysctl_max (%d) to "
4614 "minimum Windows limit (%d)\n",
4615 sysctl_max,
4616 MIN_OPEN_FILES_WINDOWS));
4617 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4620 if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4621 DEBUG(2,("rlimit_max: increasing rlimit_max (%d) to "
4622 "minimum Windows limit (%d)\n",
4623 rlimit_max,
4624 MIN_OPEN_FILES_WINDOWS));
4625 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4628 return MIN(sysctl_max, rlimit_max);
4632 * Common part of freeing allocated data for one parameter.
4634 static void free_one_parameter_common(void *parm_ptr,
4635 struct parm_struct parm)
4637 if ((parm.type == P_STRING) ||
4638 (parm.type == P_USTRING))
4640 string_free((char**)parm_ptr);
4641 } else if (parm.type == P_LIST) {
4642 TALLOC_FREE(*((char***)parm_ptr));
4647 * Free the allocated data for one parameter for a share
4648 * given as a service struct.
4650 static void free_one_parameter(struct loadparm_service *service,
4651 struct parm_struct parm)
4653 void *parm_ptr;
4655 if (parm.p_class != P_LOCAL) {
4656 return;
4659 parm_ptr = lp_parm_ptr(service, &parm);
4661 free_one_parameter_common(parm_ptr, parm);
4665 * Free the allocated parameter data of a share given
4666 * as a service struct.
4668 static void free_parameters(struct loadparm_service *service)
4670 uint32_t i;
4672 for (i=0; parm_table[i].label; i++) {
4673 free_one_parameter(service, parm_table[i]);
4678 * Free the allocated data for one parameter for a given share
4679 * specified by an snum.
4681 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4683 void *parm_ptr;
4685 if (snum < 0) {
4686 parm_ptr = lp_parm_ptr(NULL, &parm);
4687 } else if (parm.p_class != P_LOCAL) {
4688 return;
4689 } else {
4690 parm_ptr = lp_local_ptr_by_snum(snum, &parm);
4693 free_one_parameter_common(parm_ptr, parm);
4697 * Free the allocated parameter data for a share specified
4698 * by an snum.
4700 static void free_parameters_by_snum(int snum)
4702 uint32_t i;
4704 for (i=0; parm_table[i].label; i++) {
4705 free_one_parameter_by_snum(snum, parm_table[i]);
4710 * Free the allocated global parameters.
4712 static void free_global_parameters(void)
4714 free_param_opts(&Globals.param_opt);
4715 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4718 static int map_parameter(const char *pszParmName);
4720 struct lp_stored_option {
4721 struct lp_stored_option *prev, *next;
4722 const char *label;
4723 const char *value;
4726 static struct lp_stored_option *stored_options;
4729 save options set by lp_set_cmdline() into a list. This list is
4730 re-applied when we do a globals reset, so that cmdline set options
4731 are sticky across reloads of smb.conf
4733 static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
4735 struct lp_stored_option *entry, *entry_next;
4736 for (entry = stored_options; entry != NULL; entry = entry_next) {
4737 entry_next = entry->next;
4738 if (strcmp(pszParmName, entry->label) == 0) {
4739 DLIST_REMOVE(stored_options, entry);
4740 talloc_free(entry);
4741 break;
4745 entry = talloc(NULL, struct lp_stored_option);
4746 if (!entry) {
4747 return false;
4750 entry->label = talloc_strdup(entry, pszParmName);
4751 if (!entry->label) {
4752 talloc_free(entry);
4753 return false;
4756 entry->value = talloc_strdup(entry, pszParmValue);
4757 if (!entry->value) {
4758 talloc_free(entry);
4759 return false;
4762 DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
4764 return true;
4767 static bool apply_lp_set_cmdline(void)
4769 struct lp_stored_option *entry = NULL;
4770 for (entry = stored_options; entry != NULL; entry = entry->next) {
4771 if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
4772 DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
4773 entry->label, entry->value));
4774 return false;
4777 return true;
4780 /***************************************************************************
4781 Initialise the global parameter structure.
4782 ***************************************************************************/
4784 static void init_globals(bool reinit_globals)
4786 static bool done_init = false;
4787 char *s = NULL;
4788 int i;
4790 /* If requested to initialize only once and we've already done it... */
4791 if (!reinit_globals && done_init) {
4792 /* ... then we have nothing more to do */
4793 return;
4796 if (!done_init) {
4797 /* The logfile can be set before this is invoked. Free it if so. */
4798 if (Globals.logfile != NULL) {
4799 string_free(&Globals.logfile);
4800 Globals.logfile = NULL;
4802 done_init = true;
4803 } else {
4804 free_global_parameters();
4807 /* This memset and the free_global_parameters() above will
4808 * wipe out smb.conf options set with lp_set_cmdline(). The
4809 * apply_lp_set_cmdline() call puts these values back in the
4810 * table once the defaults are set */
4811 ZERO_STRUCT(Globals);
4813 for (i = 0; parm_table[i].label; i++) {
4814 if ((parm_table[i].type == P_STRING ||
4815 parm_table[i].type == P_USTRING))
4817 string_set((char **)lp_parm_ptr(NULL, &parm_table[i]), "");
4822 string_set(&sDefault.fstype, FSTYPE_STRING);
4823 string_set(&sDefault.szPrintjobUsername, "%U");
4825 init_printer_values(&sDefault);
4828 DEBUG(3, ("Initialising global parameters\n"));
4830 /* Must manually force to upper case here, as this does not go via the handler */
4831 string_set(&Globals.szNetbiosName, myhostname_upper());
4833 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4834 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4836 /* use the new 'hash2' method by default, with a prefix of 1 */
4837 string_set(&Globals.szManglingMethod, "hash2");
4838 Globals.mangle_prefix = 1;
4840 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4842 /* using UTF8 by default allows us to support all chars */
4843 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4845 /* Use codepage 850 as a default for the dos character set */
4846 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4849 * Allow the default PASSWD_CHAT to be overridden in local.h.
4851 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4853 string_set(&Globals.szWorkgroup, DEFAULT_WORKGROUP);
4855 string_set(&Globals.szPasswdProgram, "");
4856 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4857 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4858 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4859 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4860 string_set(&Globals.szSocketAddress, "0.0.0.0");
4862 * By default support explicit binding to broadcast
4863 * addresses.
4865 Globals.bNmbdBindExplicitBroadcast = true;
4867 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4868 smb_panic("init_globals: ENOMEM");
4870 string_set(&Globals.szServerString, s);
4871 SAFE_FREE(s);
4872 #ifdef DEVELOPER
4873 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4874 #endif
4876 string_set(&Globals.socket_options, DEFAULT_SOCKET_OPTIONS);
4878 string_set(&Globals.szLogonDrive, "");
4879 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4880 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4881 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4883 Globals.szNameResolveOrder = (const char **)str_list_make_v3(NULL, "lmhosts wins host bcast", NULL);
4884 string_set(&Globals.szPasswordServer, "*");
4886 Globals.AlgorithmicRidBase = BASE_RID;
4888 Globals.bLoadPrinters = true;
4889 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4891 Globals.ConfigBackend = config_backend;
4892 Globals.server_role = ROLE_AUTO;
4894 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4895 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4896 Globals.max_xmit = 0x4104;
4897 Globals.max_mux = 50; /* This is *needed* for profile support. */
4898 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4899 Globals.bDisableSpoolss = false;
4900 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4901 Globals.pwordlevel = 0;
4902 Globals.unamelevel = 0;
4903 Globals.deadtime = 0;
4904 Globals.getwd_cache = true;
4905 Globals.bLargeReadwrite = true;
4906 Globals.max_log_size = 5000;
4907 Globals.max_open_files = max_open_files();
4908 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4909 Globals.srv_maxprotocol = PROTOCOL_SMB2_10;
4910 Globals.srv_minprotocol = PROTOCOL_LANMAN1;
4911 Globals.security = SEC_USER;
4912 Globals.paranoid_server_security = true;
4913 Globals.bEncryptPasswords = true;
4914 Globals.clientSchannel = Auto;
4915 Globals.serverSchannel = Auto;
4916 Globals.bReadRaw = true;
4917 Globals.bWriteRaw = true;
4918 Globals.bNullPasswords = false;
4919 Globals.bObeyPamRestrictions = false;
4920 Globals.syslog = 1;
4921 Globals.bSyslogOnly = false;
4922 Globals.bTimestampLogs = true;
4923 string_set(&Globals.loglevel, "0");
4924 Globals.bDebugPrefixTimestamp = false;
4925 Globals.bDebugHiresTimestamp = true;
4926 Globals.bDebugPid = false;
4927 Globals.bDebugUid = false;
4928 Globals.bDebugClass = false;
4929 Globals.bEnableCoreFiles = true;
4930 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4931 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4932 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4933 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4934 Globals.lm_announce = Auto; /* = Auto: send only if LM clients found */
4935 Globals.lm_interval = 60;
4936 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4937 Globals.bNISHomeMap = false;
4938 #ifdef WITH_NISPLUS_HOME
4939 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4940 #else
4941 string_set(&Globals.szNISHomeMapName, "auto.home");
4942 #endif
4943 #endif
4944 Globals.bTimeServer = false;
4945 Globals.bBindInterfacesOnly = false;
4946 Globals.bUnixPasswdSync = false;
4947 Globals.bPamPasswordChange = false;
4948 Globals.bPasswdChatDebug = false;
4949 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4950 Globals.bNTPipeSupport = true; /* Do NT pipes by default. */
4951 Globals.bNTStatusSupport = true; /* Use NT status by default. */
4952 Globals.bStatCache = true; /* use stat cache by default */
4953 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4954 Globals.restrict_anonymous = 0;
4955 Globals.bClientLanManAuth = false; /* Do NOT use the LanMan hash if it is available */
4956 Globals.bClientPlaintextAuth = false; /* Do NOT use a plaintext password even if is requested by the server */
4957 Globals.bLanmanAuth = false; /* Do NOT use the LanMan hash, even if it is supplied */
4958 Globals.bNTLMAuth = true; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4959 Globals.bClientNTLMv2Auth = true; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
4960 /* Note, that we will also use NTLM2 session security (which is different), if it is available */
4962 Globals.map_to_guest = 0; /* By Default, "Never" */
4963 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4964 Globals.enhanced_browsing = true;
4965 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4966 #ifdef MMAP_BLACKLIST
4967 Globals.bUseMmap = false;
4968 #else
4969 Globals.bUseMmap = true;
4970 #endif
4971 Globals.bUnicode = true;
4972 Globals.bUnixExtensions = true;
4973 Globals.bResetOnZeroVC = false;
4974 Globals.bLogWriteableFilesOnExit = false;
4975 Globals.bCreateKrb5Conf = true;
4976 Globals.winbindMaxDomainConnections = 1;
4978 /* hostname lookups can be very expensive and are broken on
4979 a large number of sites (tridge) */
4980 Globals.bHostnameLookups = false;
4982 string_set(&Globals.passdb_backend, "tdbsam");
4983 string_set(&Globals.szLdapSuffix, "");
4984 string_set(&Globals.szLdapMachineSuffix, "");
4985 string_set(&Globals.szLdapUserSuffix, "");
4986 string_set(&Globals.szLdapGroupSuffix, "");
4987 string_set(&Globals.szLdapIdmapSuffix, "");
4989 string_set(&Globals.szLdapAdminDn, "");
4990 Globals.ldap_ssl = LDAP_SSL_START_TLS;
4991 Globals.ldap_ssl_ads = false;
4992 Globals.ldap_deref = -1;
4993 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
4994 Globals.ldap_delete_dn = false;
4995 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
4996 Globals.ldap_follow_referral = Auto;
4997 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
4998 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
4999 Globals.ldap_page_size = LDAP_PAGE_SIZE;
5001 Globals.ldap_debug_level = 0;
5002 Globals.ldap_debug_threshold = 10;
5004 /* This is what we tell the afs client. in reality we set the token
5005 * to never expire, though, when this runs out the afs client will
5006 * forget the token. Set to 0 to get NEVERDATE.*/
5007 Globals.iAfsTokenLifetime = 604800;
5008 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
5010 /* these parameters are set to defaults that are more appropriate
5011 for the increasing samba install base:
5013 as a member of the workgroup, that will possibly become a
5014 _local_ master browser (lm = true). this is opposed to a forced
5015 local master browser startup (pm = true).
5017 doesn't provide WINS server service by default (wsupp = false),
5018 and doesn't provide domain master browser services by default, either.
5022 Globals.bMsAddPrinterWizard = true;
5023 Globals.os_level = 20;
5024 Globals.bLocalMaster = true;
5025 Globals.domain_master = Auto; /* depending on bDomainLogons */
5026 Globals.bDomainLogons = false;
5027 Globals.bBrowseList = true;
5028 Globals.bWINSsupport = false;
5029 Globals.bWINSproxy = false;
5031 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
5032 Globals.InitLogonDelay = 100; /* 100 ms default delay */
5034 Globals.bWINSdnsProxy = true;
5036 Globals.bAllowTrustedDomains = true;
5037 string_set(&Globals.szIdmapBackend, "tdb");
5039 string_set(&Globals.szTemplateShell, "/bin/false");
5040 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
5041 string_set(&Globals.szWinbindSeparator, "\\");
5043 string_set(&Globals.szCupsServer, "");
5044 string_set(&Globals.szIPrintServer, "");
5046 #ifdef CLUSTER_SUPPORT
5047 string_set(&Globals.ctdbdSocket, CTDB_PATH);
5048 #else
5049 string_set(&Globals.ctdbdSocket, "");
5050 #endif
5052 Globals.szClusterAddresses = NULL;
5053 Globals.clustering = false;
5054 Globals.ctdb_timeout = 0;
5055 Globals.ctdb_locktime_warn_threshold = 0;
5057 Globals.winbind_cache_time = 300; /* 5 minutes */
5058 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
5059 Globals.winbind_max_clients = 200;
5060 Globals.bWinbindEnumUsers = false;
5061 Globals.bWinbindEnumGroups = false;
5062 Globals.bWinbindUseDefaultDomain = false;
5063 Globals.bWinbindTrustedDomainsOnly = false;
5064 Globals.bWinbindNestedGroups = true;
5065 Globals.winbind_expand_groups = 1;
5066 Globals.szWinbindNssInfo = (const char **)str_list_make_v3(NULL, "template", NULL);
5067 Globals.bWinbindRefreshTickets = false;
5068 Globals.bWinbindOfflineLogon = false;
5070 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
5071 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
5073 Globals.bPassdbExpandExplicit = false;
5075 Globals.name_cache_timeout = 660; /* In seconds */
5077 Globals.bUseSpnego = true;
5078 Globals.bClientUseSpnego = true;
5080 Globals.client_signing = SMB_SIGNING_DEFAULT;
5081 Globals.server_signing = SMB_SIGNING_DEFAULT;
5083 Globals.bDeferSharingViolations = true;
5084 Globals.smb_ports = (const char **)str_list_make_v3(NULL, SMB_PORTS, NULL);
5086 Globals.bEnablePrivileges = true;
5087 Globals.bHostMSDfs = true;
5088 Globals.bASUSupport = false;
5090 /* User defined shares. */
5091 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5092 smb_panic("init_globals: ENOMEM");
5094 string_set(&Globals.szUsersharePath, s);
5095 SAFE_FREE(s);
5096 string_set(&Globals.szUsershareTemplateShare, "");
5097 Globals.iUsershareMaxShares = 0;
5098 /* By default disallow sharing of directories not owned by the sharer. */
5099 Globals.bUsershareOwnerOnly = true;
5100 /* By default disallow guest access to usershares. */
5101 Globals.bUsershareAllowGuests = false;
5103 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5105 /* By default no shares out of the registry */
5106 Globals.bRegistryShares = false;
5108 Globals.iminreceivefile = 0;
5110 Globals.bMapUntrustedToDomain = false;
5111 Globals.bMulticastDnsRegister = true;
5113 Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ;
5114 Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE;
5115 Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT;
5116 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5118 string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
5120 /* Now put back the settings that were set with lp_set_cmdline() */
5121 apply_lp_set_cmdline();
5124 /*******************************************************************
5125 Convenience routine to grab string parameters into talloced memory
5126 and run standard_sub_basic on them. The buffers can be written to by
5127 callers without affecting the source string.
5128 ********************************************************************/
5130 static char *lp_string(TALLOC_CTX *ctx, const char *s)
5132 char *ret;
5134 /* The follow debug is useful for tracking down memory problems
5135 especially if you have an inner loop that is calling a lp_*()
5136 function that returns a string. Perhaps this debug should be
5137 present all the time? */
5139 #if 0
5140 DEBUG(10, ("lp_string(%s)\n", s));
5141 #endif
5142 if (!s) {
5143 return NULL;
5146 ret = talloc_sub_basic(ctx,
5147 get_current_username(),
5148 current_user_info.domain,
5150 if (trim_char(ret, '\"', '\"')) {
5151 if (strchr(ret,'\"') != NULL) {
5152 TALLOC_FREE(ret);
5153 ret = talloc_sub_basic(ctx,
5154 get_current_username(),
5155 current_user_info.domain,
5159 return ret;
5163 In this section all the functions that are used to access the
5164 parameters from the rest of the program are defined
5167 #define FN_GLOBAL_STRING(fn_name,ptr) \
5168 char *lp_ ## fn_name(TALLOC_CTX *ctx) {return(lp_string((ctx), *(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : ""));}
5169 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5170 const char *lp_ ## fn_name(void) {return(*(const char **)(&Globals.ptr) ? *(const char **)(&Globals.ptr) : "");}
5171 #define FN_GLOBAL_LIST(fn_name,ptr) \
5172 const char **lp_ ## fn_name(void) {return(*(const char ***)(&Globals.ptr));}
5173 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5174 bool lp_ ## fn_name(void) {return(*(bool *)(&Globals.ptr));}
5175 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5176 char lp_ ## fn_name(void) {return(*(char *)(&Globals.ptr));}
5177 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5178 int lp_ ## fn_name(void) {return(*(int *)(&Globals.ptr));}
5180 #define FN_LOCAL_STRING(fn_name,val) \
5181 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));}
5182 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5183 const char *lp_ ## fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5184 #define FN_LOCAL_LIST(fn_name,val) \
5185 const char **lp_ ## fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5186 #define FN_LOCAL_BOOL(fn_name,val) \
5187 bool lp_ ## fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5188 #define FN_LOCAL_INTEGER(fn_name,val) \
5189 int lp_ ## fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5191 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5192 bool lp_ ## fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5193 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5194 int lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5195 #define FN_LOCAL_CHAR(fn_name,val) \
5196 char lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5199 static FN_GLOBAL_BOOL(_readraw, bReadRaw)
5200 static FN_GLOBAL_BOOL(_writeraw, bWriteRaw)
5202 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5203 * build process or in smb.conf, we use that value. Otherwise they
5204 * default to the value of lp_lockdir(). */
5205 const char *lp_statedir(void) {
5206 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5207 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5208 return(*(char **)(&Globals.szStateDir) ?
5209 *(char **)(&Globals.szStateDir) : "");
5210 else
5211 return(*(char **)(&Globals.szLockDir) ?
5212 *(char **)(&Globals.szLockDir) : "");
5214 const char *lp_cachedir(void) {
5215 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5216 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5217 return(*(char **)(&Globals.szCacheDir) ?
5218 *(char **)(&Globals.szCacheDir) : "");
5219 else
5220 return(*(char **)(&Globals.szLockDir) ?
5221 *(char **)(&Globals.szLockDir) : "");
5223 static FN_GLOBAL_INTEGER(winbind_max_domain_connections_int,
5224 winbindMaxDomainConnections)
5226 int lp_winbind_max_domain_connections(void)
5228 if (lp_winbind_offline_logon() &&
5229 lp_winbind_max_domain_connections_int() > 1) {
5230 DEBUG(1, ("offline logons active, restricting max domain "
5231 "connections to 1\n"));
5232 return 1;
5234 return MAX(1, lp_winbind_max_domain_connections_int());
5237 int lp_smb2_max_credits(void)
5239 if (Globals.ismb2_max_credits == 0) {
5240 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5242 return Globals.ismb2_max_credits;
5244 int lp_cups_encrypt(void)
5246 int result = 0;
5247 #ifdef HAVE_HTTPCONNECTENCRYPT
5248 switch (Globals.CupsEncrypt) {
5249 case Auto:
5250 result = HTTP_ENCRYPT_REQUIRED;
5251 break;
5252 case true:
5253 result = HTTP_ENCRYPT_ALWAYS;
5254 break;
5255 case false:
5256 result = HTTP_ENCRYPT_NEVER;
5257 break;
5259 #endif
5260 return result;
5263 /* These functions remain in source3/param for now */
5265 FN_GLOBAL_STRING(configfile, szConfigFile)
5267 #include "lib/param/param_functions.c"
5269 FN_LOCAL_STRING(servicename, szService)
5270 FN_LOCAL_CONST_STRING(const_servicename, szService)
5272 /* local prototypes */
5274 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5275 static const char *get_boolean(bool bool_value);
5276 static int getservicebyname(const char *pszServiceName,
5277 struct loadparm_service *pserviceDest);
5278 static void copy_service(struct loadparm_service *pserviceDest,
5279 struct loadparm_service *pserviceSource,
5280 struct bitmap *pcopymapDest);
5281 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5282 void *userdata);
5283 static bool do_section(const char *pszSectionName, void *userdata);
5284 static void init_copymap(struct loadparm_service *pservice);
5285 static bool hash_a_service(const char *name, int number);
5286 static void free_service_byindex(int iService);
5287 static void show_parameter(int parmIndex);
5288 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5291 * This is a helper function for parametrical options support. It returns a
5292 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5293 * parametrical functions are quite simple
5295 static struct parmlist_entry *get_parametrics_by_service(struct loadparm_service *service, const char *type,
5296 const char *option)
5298 bool global_section = false;
5299 char* param_key;
5300 struct parmlist_entry *data;
5302 if (service == NULL) {
5303 data = Globals.param_opt;
5304 global_section = true;
5305 } else {
5306 data = service->param_opt;
5309 if (asprintf(&param_key, "%s:%s", type, option) == -1) {
5310 DEBUG(0,("asprintf failed!\n"));
5311 return NULL;
5314 while (data) {
5315 if (strwicmp(data->key, param_key) == 0) {
5316 string_free(&param_key);
5317 return data;
5319 data = data->next;
5322 if (!global_section) {
5323 /* Try to fetch the same option but from globals */
5324 /* but only if we are not already working with Globals */
5325 data = Globals.param_opt;
5326 while (data) {
5327 if (strwicmp(data->key, param_key) == 0) {
5328 string_free(&param_key);
5329 return data;
5331 data = data->next;
5335 string_free(&param_key);
5337 return NULL;
5341 * This is a helper function for parametrical options support. It returns a
5342 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5343 * parametrical functions are quite simple
5345 static struct parmlist_entry *get_parametrics(int snum, const char *type,
5346 const char *option)
5348 if (snum >= iNumServices) return NULL;
5350 if (snum < 0) {
5351 return get_parametrics_by_service(NULL, type, option);
5352 } else {
5353 return get_parametrics_by_service(ServicePtrs[snum], type, option);
5358 #define MISSING_PARAMETER(name) \
5359 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5361 /*******************************************************************
5362 convenience routine to return int parameters.
5363 ********************************************************************/
5364 static int lp_int(const char *s)
5367 if (!s || !*s) {
5368 MISSING_PARAMETER(lp_int);
5369 return (-1);
5372 return (int)strtol(s, NULL, 0);
5375 /*******************************************************************
5376 convenience routine to return unsigned long parameters.
5377 ********************************************************************/
5378 static unsigned long lp_ulong(const char *s)
5381 if (!s || !*s) {
5382 MISSING_PARAMETER(lp_ulong);
5383 return (0);
5386 return strtoul(s, NULL, 0);
5389 /*******************************************************************
5390 convenience routine to return boolean parameters.
5391 ********************************************************************/
5392 static bool lp_bool(const char *s)
5394 bool ret = false;
5396 if (!s || !*s) {
5397 MISSING_PARAMETER(lp_bool);
5398 return false;
5401 if (!set_boolean(s, &ret)) {
5402 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5403 return false;
5406 return ret;
5409 /*******************************************************************
5410 convenience routine to return enum parameters.
5411 ********************************************************************/
5412 static int lp_enum(const char *s,const struct enum_list *_enum)
5414 int i;
5416 if (!s || !*s || !_enum) {
5417 MISSING_PARAMETER(lp_enum);
5418 return (-1);
5421 for (i=0; _enum[i].name; i++) {
5422 if (strequal(_enum[i].name,s))
5423 return _enum[i].value;
5426 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5427 return (-1);
5430 #undef MISSING_PARAMETER
5432 /* Return parametric option from a given service. Type is a part of option before ':' */
5433 /* Parametric option has following syntax: 'Type: option = value' */
5434 char *lp_parm_talloc_string(TALLOC_CTX *ctx, int snum, const char *type, const char *option, const char *def)
5436 struct parmlist_entry *data = get_parametrics(snum, type, option);
5438 if (data == NULL||data->value==NULL) {
5439 if (def) {
5440 return lp_string(ctx, def);
5441 } else {
5442 return NULL;
5446 return lp_string(ctx, data->value);
5449 /* Return parametric option from a given service. Type is a part of option before ':' */
5450 /* Parametric option has following syntax: 'Type: option = value' */
5451 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5453 struct parmlist_entry *data = get_parametrics(snum, type, option);
5455 if (data == NULL||data->value==NULL)
5456 return def;
5458 return data->value;
5461 const char *lp_parm_const_string_service(struct loadparm_service *service, const char *type, const char *option)
5463 struct parmlist_entry *data = get_parametrics_by_service(service, type, option);
5465 if (data == NULL||data->value==NULL)
5466 return NULL;
5468 return data->value;
5472 /* Return parametric option from a given service. Type is a part of option before ':' */
5473 /* Parametric option has following syntax: 'Type: option = value' */
5475 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5477 struct parmlist_entry *data = get_parametrics(snum, type, option);
5479 if (data == NULL||data->value==NULL)
5480 return (const char **)def;
5482 if (data->list==NULL) {
5483 data->list = str_list_make_v3(NULL, data->value, NULL);
5486 return (const char **)data->list;
5489 /* Return parametric option from a given service. Type is a part of option before ':' */
5490 /* Parametric option has following syntax: 'Type: option = value' */
5492 int lp_parm_int(int snum, const char *type, const char *option, int def)
5494 struct parmlist_entry *data = get_parametrics(snum, type, option);
5496 if (data && data->value && *data->value)
5497 return lp_int(data->value);
5499 return def;
5502 /* Return parametric option from a given service. Type is a part of option before ':' */
5503 /* Parametric option has following syntax: 'Type: option = value' */
5505 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5507 struct parmlist_entry *data = get_parametrics(snum, type, option);
5509 if (data && data->value && *data->value)
5510 return lp_ulong(data->value);
5512 return def;
5515 /* Return parametric option from a given service. Type is a part of option before ':' */
5516 /* Parametric option has following syntax: 'Type: option = value' */
5518 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5520 struct parmlist_entry *data = get_parametrics(snum, type, option);
5522 if (data && data->value && *data->value)
5523 return lp_bool(data->value);
5525 return def;
5528 /* Return parametric option from a given service. Type is a part of option before ':' */
5529 /* Parametric option has following syntax: 'Type: option = value' */
5531 int lp_parm_enum(int snum, const char *type, const char *option,
5532 const struct enum_list *_enum, int def)
5534 struct parmlist_entry *data = get_parametrics(snum, type, option);
5536 if (data && data->value && *data->value && _enum)
5537 return lp_enum(data->value, _enum);
5539 return def;
5543 /***************************************************************************
5544 Initialise a service to the defaults.
5545 ***************************************************************************/
5547 static void init_service(struct loadparm_service *pservice)
5549 memset((char *)pservice, '\0', sizeof(struct loadparm_service));
5550 copy_service(pservice, &sDefault, NULL);
5555 * free a param_opts structure.
5556 * param_opts handling should be moved to talloc;
5557 * then this whole functions reduces to a TALLOC_FREE().
5560 static void free_param_opts(struct parmlist_entry **popts)
5562 struct parmlist_entry *opt, *next_opt;
5564 if (popts == NULL) {
5565 return;
5568 if (*popts != NULL) {
5569 DEBUG(5, ("Freeing parametrics:\n"));
5571 opt = *popts;
5572 while (opt != NULL) {
5573 string_free(&opt->key);
5574 string_free(&opt->value);
5575 TALLOC_FREE(opt->list);
5576 next_opt = opt->next;
5577 SAFE_FREE(opt);
5578 opt = next_opt;
5580 *popts = NULL;
5583 /***************************************************************************
5584 Free the dynamically allocated parts of a service struct.
5585 ***************************************************************************/
5587 static void free_service(struct loadparm_service *pservice)
5589 if (!pservice)
5590 return;
5592 if (pservice->szService)
5593 DEBUG(5, ("free_service: Freeing service %s\n",
5594 pservice->szService));
5596 free_parameters(pservice);
5598 string_free(&pservice->szService);
5599 TALLOC_FREE(pservice->copymap);
5601 free_param_opts(&pservice->param_opt);
5603 ZERO_STRUCTP(pservice);
5607 /***************************************************************************
5608 remove a service indexed in the ServicePtrs array from the ServiceHash
5609 and free the dynamically allocated parts
5610 ***************************************************************************/
5612 static void free_service_byindex(int idx)
5614 if ( !LP_SNUM_OK(idx) )
5615 return;
5617 ServicePtrs[idx]->valid = false;
5618 invalid_services[num_invalid_services++] = idx;
5620 /* we have to cleanup the hash record */
5622 if (ServicePtrs[idx]->szService) {
5623 char *canon_name = canonicalize_servicename(
5624 talloc_tos(),
5625 ServicePtrs[idx]->szService );
5627 dbwrap_delete_bystring(ServiceHash, canon_name );
5628 TALLOC_FREE(canon_name);
5631 free_service(ServicePtrs[idx]);
5634 /***************************************************************************
5635 Add a new service to the services array initialising it with the given
5636 service.
5637 ***************************************************************************/
5639 static int add_a_service(const struct loadparm_service *pservice, const char *name)
5641 int i;
5642 struct loadparm_service tservice;
5643 int num_to_alloc = iNumServices + 1;
5645 tservice = *pservice;
5647 /* it might already exist */
5648 if (name) {
5649 i = getservicebyname(name, NULL);
5650 if (i >= 0) {
5651 return (i);
5655 /* find an invalid one */
5656 i = iNumServices;
5657 if (num_invalid_services > 0) {
5658 i = invalid_services[--num_invalid_services];
5661 /* if not, then create one */
5662 if (i == iNumServices) {
5663 struct loadparm_service **tsp;
5664 int *tinvalid;
5666 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct loadparm_service *, num_to_alloc);
5667 if (tsp == NULL) {
5668 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
5669 return (-1);
5671 ServicePtrs = tsp;
5672 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct loadparm_service);
5673 if (!ServicePtrs[iNumServices]) {
5674 DEBUG(0,("add_a_service: out of memory!\n"));
5675 return (-1);
5677 iNumServices++;
5679 /* enlarge invalid_services here for now... */
5680 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
5681 num_to_alloc);
5682 if (tinvalid == NULL) {
5683 DEBUG(0,("add_a_service: failed to enlarge "
5684 "invalid_services!\n"));
5685 return (-1);
5687 invalid_services = tinvalid;
5688 } else {
5689 free_service_byindex(i);
5692 ServicePtrs[i]->valid = true;
5694 init_service(ServicePtrs[i]);
5695 copy_service(ServicePtrs[i], &tservice, NULL);
5696 if (name)
5697 string_set(&ServicePtrs[i]->szService, name);
5699 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
5700 i, ServicePtrs[i]->szService));
5702 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
5703 return (-1);
5706 return (i);
5709 /***************************************************************************
5710 Convert a string to uppercase and remove whitespaces.
5711 ***************************************************************************/
5713 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
5715 char *result;
5717 if ( !src ) {
5718 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
5719 return NULL;
5722 result = talloc_strdup(ctx, src);
5723 SMB_ASSERT(result != NULL);
5725 strlower_m(result);
5726 return result;
5729 /***************************************************************************
5730 Add a name/index pair for the services array to the hash table.
5731 ***************************************************************************/
5733 static bool hash_a_service(const char *name, int idx)
5735 char *canon_name;
5737 if ( !ServiceHash ) {
5738 DEBUG(10,("hash_a_service: creating servicehash\n"));
5739 ServiceHash = db_open_rbt(NULL);
5740 if ( !ServiceHash ) {
5741 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
5742 return false;
5746 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
5747 idx, name));
5749 canon_name = canonicalize_servicename(talloc_tos(), name );
5751 dbwrap_store_bystring(ServiceHash, canon_name,
5752 make_tdb_data((uint8 *)&idx, sizeof(idx)),
5753 TDB_REPLACE);
5755 TALLOC_FREE(canon_name);
5757 return true;
5760 /***************************************************************************
5761 Add a new home service, with the specified home directory, defaults coming
5762 from service ifrom.
5763 ***************************************************************************/
5765 bool lp_add_home(const char *pszHomename, int iDefaultService,
5766 const char *user, const char *pszHomedir)
5768 int i;
5770 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
5771 pszHomedir[0] == '\0') {
5772 return false;
5775 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
5777 if (i < 0)
5778 return false;
5780 if (!(*(ServicePtrs[iDefaultService]->szPath))
5781 || strequal(ServicePtrs[iDefaultService]->szPath,
5782 lp_pathname(talloc_tos(), GLOBAL_SECTION_SNUM))) {
5783 string_set(&ServicePtrs[i]->szPath, pszHomedir);
5786 if (!(*(ServicePtrs[i]->comment))) {
5787 char *comment = NULL;
5788 if (asprintf(&comment, "Home directory of %s", user) < 0) {
5789 return false;
5791 string_set(&ServicePtrs[i]->comment, comment);
5792 SAFE_FREE(comment);
5795 /* set the browseable flag from the global default */
5797 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5798 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
5800 ServicePtrs[i]->autoloaded = true;
5802 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
5803 user, ServicePtrs[i]->szPath ));
5805 return true;
5808 /***************************************************************************
5809 Add a new service, based on an old one.
5810 ***************************************************************************/
5812 int lp_add_service(const char *pszService, int iDefaultService)
5814 if (iDefaultService < 0) {
5815 return add_a_service(&sDefault, pszService);
5818 return (add_a_service(ServicePtrs[iDefaultService], pszService));
5821 /***************************************************************************
5822 Add the IPC service.
5823 ***************************************************************************/
5825 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
5827 char *comment = NULL;
5828 int i = add_a_service(&sDefault, ipc_name);
5830 if (i < 0)
5831 return false;
5833 if (asprintf(&comment, "IPC Service (%s)",
5834 Globals.szServerString) < 0) {
5835 return false;
5838 string_set(&ServicePtrs[i]->szPath, tmpdir());
5839 string_set(&ServicePtrs[i]->szUsername, "");
5840 string_set(&ServicePtrs[i]->comment, comment);
5841 string_set(&ServicePtrs[i]->fstype, "IPC");
5842 ServicePtrs[i]->iMaxConnections = 0;
5843 ServicePtrs[i]->bAvailable = true;
5844 ServicePtrs[i]->bRead_only = true;
5845 ServicePtrs[i]->bGuest_only = false;
5846 ServicePtrs[i]->bAdministrative_share = true;
5847 ServicePtrs[i]->bGuest_ok = guest_ok;
5848 ServicePtrs[i]->bPrint_ok = false;
5849 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5851 DEBUG(3, ("adding IPC service\n"));
5853 SAFE_FREE(comment);
5854 return true;
5857 /***************************************************************************
5858 Add a new printer service, with defaults coming from service iFrom.
5859 ***************************************************************************/
5861 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
5863 const char *comment = "From Printcap";
5864 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
5866 if (i < 0)
5867 return false;
5869 /* note that we do NOT default the availability flag to true - */
5870 /* we take it from the default service passed. This allows all */
5871 /* dynamic printers to be disabled by disabling the [printers] */
5872 /* entry (if/when the 'available' keyword is implemented!). */
5874 /* the printer name is set to the service name. */
5875 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
5876 string_set(&ServicePtrs[i]->comment, comment);
5878 /* set the browseable flag from the gloabl default */
5879 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5881 /* Printers cannot be read_only. */
5882 ServicePtrs[i]->bRead_only = false;
5883 /* No share modes on printer services. */
5884 ServicePtrs[i]->bShareModes = false;
5885 /* No oplocks on printer services. */
5886 ServicePtrs[i]->bOpLocks = false;
5887 /* Printer services must be printable. */
5888 ServicePtrs[i]->bPrint_ok = true;
5890 DEBUG(3, ("adding printer service %s\n", pszPrintername));
5892 return true;
5896 /***************************************************************************
5897 Check whether the given parameter name is valid.
5898 Parametric options (names containing a colon) are considered valid.
5899 ***************************************************************************/
5901 bool lp_parameter_is_valid(const char *pszParmName)
5903 return ((map_parameter(pszParmName) != -1) ||
5904 (strchr(pszParmName, ':') != NULL));
5907 /***************************************************************************
5908 Check whether the given name is the name of a global parameter.
5909 Returns true for strings belonging to parameters of class
5910 P_GLOBAL, false for all other strings, also for parametric options
5911 and strings not belonging to any option.
5912 ***************************************************************************/
5914 bool lp_parameter_is_global(const char *pszParmName)
5916 int num = map_parameter(pszParmName);
5918 if (num >= 0) {
5919 return (parm_table[num].p_class == P_GLOBAL);
5922 return false;
5925 /**************************************************************************
5926 Check whether the given name is the canonical name of a parameter.
5927 Returns false if it is not a valid parameter Name.
5928 For parametric options, true is returned.
5929 **************************************************************************/
5931 bool lp_parameter_is_canonical(const char *parm_name)
5933 if (!lp_parameter_is_valid(parm_name)) {
5934 return false;
5937 return (map_parameter(parm_name) ==
5938 map_parameter_canonical(parm_name, NULL));
5941 /**************************************************************************
5942 Determine the canonical name for a parameter.
5943 Indicate when it is an inverse (boolean) synonym instead of a
5944 "usual" synonym.
5945 **************************************************************************/
5947 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
5948 bool *inverse)
5950 int num;
5952 if (!lp_parameter_is_valid(parm_name)) {
5953 *canon_parm = NULL;
5954 return false;
5957 num = map_parameter_canonical(parm_name, inverse);
5958 if (num < 0) {
5959 /* parametric option */
5960 *canon_parm = parm_name;
5961 } else {
5962 *canon_parm = parm_table[num].label;
5965 return true;
5969 /**************************************************************************
5970 Determine the canonical name for a parameter.
5971 Turn the value given into the inverse boolean expression when
5972 the synonym is an invers boolean synonym.
5974 Return true if parm_name is a valid parameter name and
5975 in case it is an invers boolean synonym, if the val string could
5976 successfully be converted to the reverse bool.
5977 Return false in all other cases.
5978 **************************************************************************/
5980 bool lp_canonicalize_parameter_with_value(const char *parm_name,
5981 const char *val,
5982 const char **canon_parm,
5983 const char **canon_val)
5985 int num;
5986 bool inverse;
5988 if (!lp_parameter_is_valid(parm_name)) {
5989 *canon_parm = NULL;
5990 *canon_val = NULL;
5991 return false;
5994 num = map_parameter_canonical(parm_name, &inverse);
5995 if (num < 0) {
5996 /* parametric option */
5997 *canon_parm = parm_name;
5998 *canon_val = val;
5999 } else {
6000 *canon_parm = parm_table[num].label;
6001 if (inverse) {
6002 if (!lp_invert_boolean(val, canon_val)) {
6003 *canon_val = NULL;
6004 return false;
6006 } else {
6007 *canon_val = val;
6011 return true;
6014 /***************************************************************************
6015 Map a parameter's string representation to something we can use.
6016 Returns false if the parameter string is not recognised, else TRUE.
6017 ***************************************************************************/
6019 static int map_parameter(const char *pszParmName)
6021 int iIndex;
6023 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6024 return (-1);
6026 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6027 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6028 return (iIndex);
6030 /* Warn only if it isn't parametric option */
6031 if (strchr(pszParmName, ':') == NULL)
6032 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6033 /* We do return 'fail' for parametric options as well because they are
6034 stored in different storage
6036 return (-1);
6039 /***************************************************************************
6040 Map a parameter's string representation to the index of the canonical
6041 form of the parameter (it might be a synonym).
6042 Returns -1 if the parameter string is not recognised.
6043 ***************************************************************************/
6045 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6047 int parm_num, canon_num;
6048 bool loc_inverse = false;
6050 parm_num = map_parameter(pszParmName);
6051 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6052 /* invalid, parametric or no canidate for synonyms ... */
6053 goto done;
6056 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6057 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6058 parm_num = canon_num;
6059 goto done;
6063 done:
6064 if (inverse != NULL) {
6065 *inverse = loc_inverse;
6067 return parm_num;
6070 /***************************************************************************
6071 return true if parameter number parm1 is a synonym of parameter
6072 number parm2 (parm2 being the principal name).
6073 set inverse to true if parm1 is P_BOOLREV and parm2 is P_BOOL,
6074 false otherwise.
6075 ***************************************************************************/
6077 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6079 if ((parm_table[parm1].offset == parm_table[parm2].offset) &&
6080 (parm_table[parm1].p_class == parm_table[parm2].p_class) &&
6081 (parm_table[parm1].flags & FLAG_HIDE) &&
6082 !(parm_table[parm2].flags & FLAG_HIDE))
6084 if (inverse != NULL) {
6085 if ((parm_table[parm1].type == P_BOOLREV) &&
6086 (parm_table[parm2].type == P_BOOL))
6088 *inverse = true;
6089 } else {
6090 *inverse = false;
6093 return true;
6095 return false;
6098 /***************************************************************************
6099 Show one parameter's name, type, [values,] and flags.
6100 (helper functions for show_parameter_list)
6101 ***************************************************************************/
6103 static void show_parameter(int parmIndex)
6105 int enumIndex, flagIndex;
6106 int parmIndex2;
6107 bool hadFlag;
6108 bool hadSyn;
6109 bool inverse;
6110 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6111 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6112 "P_ENUM", "P_SEP"};
6113 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6114 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6115 FLAG_HIDE};
6116 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6117 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6118 "FLAG_DEPRECATED", "FLAG_HIDE", NULL};
6120 printf("%s=%s", parm_table[parmIndex].label,
6121 type[parm_table[parmIndex].type]);
6122 if (parm_table[parmIndex].type == P_ENUM) {
6123 printf(",");
6124 for (enumIndex=0;
6125 parm_table[parmIndex].enum_list[enumIndex].name;
6126 enumIndex++)
6128 printf("%s%s",
6129 enumIndex ? "|" : "",
6130 parm_table[parmIndex].enum_list[enumIndex].name);
6133 printf(",");
6134 hadFlag = false;
6135 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6136 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6137 printf("%s%s",
6138 hadFlag ? "|" : "",
6139 flag_names[flagIndex]);
6140 hadFlag = true;
6144 /* output synonyms */
6145 hadSyn = false;
6146 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6147 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6148 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6149 parm_table[parmIndex2].label);
6150 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6151 if (!hadSyn) {
6152 printf(" (synonyms: ");
6153 hadSyn = true;
6154 } else {
6155 printf(", ");
6157 printf("%s%s", parm_table[parmIndex2].label,
6158 inverse ? "[i]" : "");
6161 if (hadSyn) {
6162 printf(")");
6165 printf("\n");
6168 /***************************************************************************
6169 Show all parameter's name, type, [values,] and flags.
6170 ***************************************************************************/
6172 void show_parameter_list(void)
6174 int classIndex, parmIndex;
6175 const char *section_names[] = { "local", "global", NULL};
6177 for (classIndex=0; section_names[classIndex]; classIndex++) {
6178 printf("[%s]\n", section_names[classIndex]);
6179 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6180 if (parm_table[parmIndex].p_class == classIndex) {
6181 show_parameter(parmIndex);
6187 /***************************************************************************
6188 Check if a given string correctly represents a boolean value.
6189 ***************************************************************************/
6191 bool lp_string_is_valid_boolean(const char *parm_value)
6193 return set_boolean(parm_value, NULL);
6196 /***************************************************************************
6197 Get the standard string representation of a boolean value ("yes" or "no")
6198 ***************************************************************************/
6200 static const char *get_boolean(bool bool_value)
6202 static const char *yes_str = "yes";
6203 static const char *no_str = "no";
6205 return (bool_value ? yes_str : no_str);
6208 /***************************************************************************
6209 Provide the string of the negated boolean value associated to the boolean
6210 given as a string. Returns false if the passed string does not correctly
6211 represent a boolean.
6212 ***************************************************************************/
6214 bool lp_invert_boolean(const char *str, const char **inverse_str)
6216 bool val;
6218 if (!set_boolean(str, &val)) {
6219 return false;
6222 *inverse_str = get_boolean(!val);
6223 return true;
6226 /***************************************************************************
6227 Provide the canonical string representation of a boolean value given
6228 as a string. Return true on success, false if the string given does
6229 not correctly represent a boolean.
6230 ***************************************************************************/
6232 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6234 bool val;
6236 if (!set_boolean(str, &val)) {
6237 return false;
6240 *canon_str = get_boolean(val);
6241 return true;
6244 /***************************************************************************
6245 Find a service by name. Otherwise works like get_service.
6246 ***************************************************************************/
6248 static int getservicebyname(const char *pszServiceName, struct loadparm_service *pserviceDest)
6250 int iService = -1;
6251 char *canon_name;
6252 TDB_DATA data;
6253 NTSTATUS status;
6255 if (ServiceHash == NULL) {
6256 return -1;
6259 canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
6261 status = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name,
6262 &data);
6264 if (NT_STATUS_IS_OK(status) &&
6265 (data.dptr != NULL) &&
6266 (data.dsize == sizeof(iService)))
6268 iService = *(int *)data.dptr;
6271 TALLOC_FREE(canon_name);
6273 if ((iService != -1) && (LP_SNUM_OK(iService))
6274 && (pserviceDest != NULL)) {
6275 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6278 return (iService);
6281 /* Return a pointer to a service by name. Unlike getservicebyname, it does not copy the service */
6282 struct loadparm_service *lp_service(const char *pszServiceName)
6284 int iService = getservicebyname(pszServiceName, NULL);
6285 if (iService == -1 || !LP_SNUM_OK(iService)) {
6286 return NULL;
6288 return ServicePtrs[iService];
6291 struct loadparm_service *lp_servicebynum(int snum)
6293 if ((snum == -1) || !LP_SNUM_OK(snum)) {
6294 return NULL;
6296 return ServicePtrs[snum];
6299 struct loadparm_service *lp_default_loadparm_service()
6301 return &sDefault;
6305 /***************************************************************************
6306 Copy a service structure to another.
6307 If pcopymapDest is NULL then copy all fields
6308 ***************************************************************************/
6311 * Add a parametric option to a parmlist_entry,
6312 * replacing old value, if already present.
6314 static void set_param_opt(struct parmlist_entry **opt_list,
6315 const char *opt_name,
6316 const char *opt_value,
6317 unsigned priority)
6319 struct parmlist_entry *new_opt, *opt;
6320 bool not_added;
6322 if (opt_list == NULL) {
6323 return;
6326 opt = *opt_list;
6327 not_added = true;
6329 /* Traverse destination */
6330 while (opt) {
6331 /* If we already have same option, override it */
6332 if (strwicmp(opt->key, opt_name) == 0) {
6333 if ((opt->priority & FLAG_CMDLINE) &&
6334 !(priority & FLAG_CMDLINE)) {
6335 /* it's been marked as not to be
6336 overridden */
6337 return;
6339 string_free(&opt->value);
6340 TALLOC_FREE(opt->list);
6341 opt->value = SMB_STRDUP(opt_value);
6342 opt->priority = priority;
6343 not_added = false;
6344 break;
6346 opt = opt->next;
6348 if (not_added) {
6349 new_opt = SMB_XMALLOC_P(struct parmlist_entry);
6350 new_opt->key = SMB_STRDUP(opt_name);
6351 new_opt->value = SMB_STRDUP(opt_value);
6352 new_opt->list = NULL;
6353 new_opt->priority = priority;
6354 DLIST_ADD(*opt_list, new_opt);
6358 static void copy_service(struct loadparm_service *pserviceDest, struct loadparm_service *pserviceSource,
6359 struct bitmap *pcopymapDest)
6361 int i;
6362 bool bcopyall = (pcopymapDest == NULL);
6363 struct parmlist_entry *data;
6365 for (i = 0; parm_table[i].label; i++)
6366 if (parm_table[i].p_class == P_LOCAL &&
6367 (bcopyall || bitmap_query(pcopymapDest,i))) {
6368 void *src_ptr = lp_parm_ptr(pserviceSource, &parm_table[i]);
6369 void *dest_ptr = lp_parm_ptr(pserviceDest, &parm_table[i]);
6371 switch (parm_table[i].type) {
6372 case P_BOOL:
6373 case P_BOOLREV:
6374 *(bool *)dest_ptr = *(bool *)src_ptr;
6375 break;
6377 case P_INTEGER:
6378 case P_ENUM:
6379 case P_OCTAL:
6380 case P_BYTES:
6381 *(int *)dest_ptr = *(int *)src_ptr;
6382 break;
6384 case P_CHAR:
6385 *(char *)dest_ptr = *(char *)src_ptr;
6386 break;
6388 case P_STRING:
6389 string_set((char **)dest_ptr,
6390 *(char **)src_ptr);
6391 break;
6393 case P_USTRING:
6395 char *upper_string = strupper_talloc(talloc_tos(),
6396 *(char **)src_ptr);
6397 string_set((char **)dest_ptr,
6398 upper_string);
6399 TALLOC_FREE(upper_string);
6400 break;
6402 case P_LIST:
6403 TALLOC_FREE(*((char ***)dest_ptr));
6404 *((char ***)dest_ptr) = str_list_copy(NULL,
6405 *(const char ***)src_ptr);
6406 break;
6407 default:
6408 break;
6412 if (bcopyall) {
6413 init_copymap(pserviceDest);
6414 if (pserviceSource->copymap)
6415 bitmap_copy(pserviceDest->copymap,
6416 pserviceSource->copymap);
6419 data = pserviceSource->param_opt;
6420 while (data) {
6421 set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->priority);
6422 data = data->next;
6426 /***************************************************************************
6427 Check a service for consistency. Return false if the service is in any way
6428 incomplete or faulty, else true.
6429 ***************************************************************************/
6431 bool service_ok(int iService)
6433 bool bRetval;
6435 bRetval = true;
6436 if (ServicePtrs[iService]->szService[0] == '\0') {
6437 DEBUG(0, ("The following message indicates an internal error:\n"));
6438 DEBUG(0, ("No service name in service entry.\n"));
6439 bRetval = false;
6442 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6443 /* I can't see why you'd want a non-printable printer service... */
6444 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6445 if (!ServicePtrs[iService]->bPrint_ok) {
6446 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6447 ServicePtrs[iService]->szService));
6448 ServicePtrs[iService]->bPrint_ok = true;
6450 /* [printers] service must also be non-browsable. */
6451 if (ServicePtrs[iService]->bBrowseable)
6452 ServicePtrs[iService]->bBrowseable = false;
6455 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6456 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6457 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6459 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6460 ServicePtrs[iService]->szService));
6461 ServicePtrs[iService]->bAvailable = false;
6464 /* If a service is flagged unavailable, log the fact at level 1. */
6465 if (!ServicePtrs[iService]->bAvailable)
6466 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6467 ServicePtrs[iService]->szService));
6469 return (bRetval);
6472 static struct smbconf_ctx *lp_smbconf_ctx(void)
6474 sbcErr err;
6475 static struct smbconf_ctx *conf_ctx = NULL;
6477 if (conf_ctx == NULL) {
6478 err = smbconf_init(NULL, &conf_ctx, "registry:");
6479 if (!SBC_ERROR_IS_OK(err)) {
6480 DEBUG(1, ("error initializing registry configuration: "
6481 "%s\n", sbcErrorString(err)));
6482 conf_ctx = NULL;
6486 return conf_ctx;
6489 static bool process_smbconf_service(struct smbconf_service *service)
6491 uint32_t count;
6492 bool ret;
6494 if (service == NULL) {
6495 return false;
6498 ret = do_section(service->name, NULL);
6499 if (ret != true) {
6500 return false;
6502 for (count = 0; count < service->num_params; count++) {
6503 ret = do_parameter(service->param_names[count],
6504 service->param_values[count],
6505 NULL);
6506 if (ret != true) {
6507 return false;
6510 if (iServiceIndex >= 0) {
6511 return service_ok(iServiceIndex);
6513 return true;
6517 * load a service from registry and activate it
6519 bool process_registry_service(const char *service_name)
6521 sbcErr err;
6522 struct smbconf_service *service = NULL;
6523 TALLOC_CTX *mem_ctx = talloc_stackframe();
6524 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6525 bool ret = false;
6527 if (conf_ctx == NULL) {
6528 goto done;
6531 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6533 if (!smbconf_share_exists(conf_ctx, service_name)) {
6535 * Registry does not contain data for this service (yet),
6536 * but make sure lp_load doesn't return false.
6538 ret = true;
6539 goto done;
6542 err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6543 if (!SBC_ERROR_IS_OK(err)) {
6544 goto done;
6547 ret = process_smbconf_service(service);
6548 if (!ret) {
6549 goto done;
6552 /* store the csn */
6553 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6555 done:
6556 TALLOC_FREE(mem_ctx);
6557 return ret;
6561 * process_registry_globals
6563 static bool process_registry_globals(void)
6565 bool ret;
6567 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6569 ret = do_parameter("registry shares", "yes", NULL);
6570 if (!ret) {
6571 return ret;
6574 return process_registry_service(GLOBAL_NAME);
6577 bool process_registry_shares(void)
6579 sbcErr err;
6580 uint32_t count;
6581 struct smbconf_service **service = NULL;
6582 uint32_t num_shares = 0;
6583 TALLOC_CTX *mem_ctx = talloc_stackframe();
6584 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6585 bool ret = false;
6587 if (conf_ctx == NULL) {
6588 goto done;
6591 err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6592 if (!SBC_ERROR_IS_OK(err)) {
6593 goto done;
6596 ret = true;
6598 for (count = 0; count < num_shares; count++) {
6599 if (strequal(service[count]->name, GLOBAL_NAME)) {
6600 continue;
6602 ret = process_smbconf_service(service[count]);
6603 if (!ret) {
6604 goto done;
6608 /* store the csn */
6609 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6611 done:
6612 TALLOC_FREE(mem_ctx);
6613 return ret;
6617 * reload those shares from registry that are already
6618 * activated in the services array.
6620 static bool reload_registry_shares(void)
6622 int i;
6623 bool ret = true;
6625 for (i = 0; i < iNumServices; i++) {
6626 if (!VALID(i)) {
6627 continue;
6630 if (ServicePtrs[i]->usershare == USERSHARE_VALID) {
6631 continue;
6634 ret = process_registry_service(ServicePtrs[i]->szService);
6635 if (!ret) {
6636 goto done;
6640 done:
6641 return ret;
6645 #define MAX_INCLUDE_DEPTH 100
6647 static uint8_t include_depth;
6649 static struct file_lists {
6650 struct file_lists *next;
6651 char *name;
6652 char *subfname;
6653 time_t modtime;
6654 } *file_lists = NULL;
6656 /*******************************************************************
6657 Keep a linked list of all config files so we know when one has changed
6658 it's date and needs to be reloaded.
6659 ********************************************************************/
6661 static void add_to_file_list(const char *fname, const char *subfname)
6663 struct file_lists *f = file_lists;
6665 while (f) {
6666 if (f->name && !strcmp(f->name, fname))
6667 break;
6668 f = f->next;
6671 if (!f) {
6672 f = SMB_MALLOC_P(struct file_lists);
6673 if (!f)
6674 return;
6675 f->next = file_lists;
6676 f->name = SMB_STRDUP(fname);
6677 if (!f->name) {
6678 SAFE_FREE(f);
6679 return;
6681 f->subfname = SMB_STRDUP(subfname);
6682 if (!f->subfname) {
6683 SAFE_FREE(f->name);
6684 SAFE_FREE(f);
6685 return;
6687 file_lists = f;
6688 f->modtime = file_modtime(subfname);
6689 } else {
6690 time_t t = file_modtime(subfname);
6691 if (t)
6692 f->modtime = t;
6694 return;
6698 * Free the file lists
6700 static void free_file_list(void)
6702 struct file_lists *f;
6703 struct file_lists *next;
6705 f = file_lists;
6706 while( f ) {
6707 next = f->next;
6708 SAFE_FREE( f->name );
6709 SAFE_FREE( f->subfname );
6710 SAFE_FREE( f );
6711 f = next;
6713 file_lists = NULL;
6718 * Utility function for outsiders to check if we're running on registry.
6720 bool lp_config_backend_is_registry(void)
6722 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
6726 * Utility function to check if the config backend is FILE.
6728 bool lp_config_backend_is_file(void)
6730 return (lp_config_backend() == CONFIG_BACKEND_FILE);
6733 /*******************************************************************
6734 Check if a config file has changed date.
6735 ********************************************************************/
6737 bool lp_file_list_changed(void)
6739 struct file_lists *f = file_lists;
6741 DEBUG(6, ("lp_file_list_changed()\n"));
6743 while (f) {
6744 time_t mod_time;
6746 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
6747 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6749 if (conf_ctx == NULL) {
6750 return false;
6752 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
6753 NULL))
6755 DEBUGADD(6, ("registry config changed\n"));
6756 return true;
6758 } else {
6759 char *n2 = NULL;
6760 n2 = talloc_sub_basic(talloc_tos(),
6761 get_current_username(),
6762 current_user_info.domain,
6763 f->name);
6764 if (!n2) {
6765 return false;
6767 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
6768 f->name, n2, ctime(&f->modtime)));
6770 mod_time = file_modtime(n2);
6772 if (mod_time &&
6773 ((f->modtime != mod_time) ||
6774 (f->subfname == NULL) ||
6775 (strcmp(n2, f->subfname) != 0)))
6777 DEBUGADD(6,
6778 ("file %s modified: %s\n", n2,
6779 ctime(&mod_time)));
6780 f->modtime = mod_time;
6781 SAFE_FREE(f->subfname);
6782 f->subfname = SMB_STRDUP(n2);
6783 TALLOC_FREE(n2);
6784 return true;
6786 TALLOC_FREE(n2);
6788 f = f->next;
6790 return false;
6795 * Initialize iconv conversion descriptors.
6797 * This is called the first time it is needed, and also called again
6798 * every time the configuration is reloaded, because the charset or
6799 * codepage might have changed.
6801 static void init_iconv(void)
6803 global_iconv_handle = smb_iconv_handle_reinit(NULL, lp_dos_charset(),
6804 lp_unix_charset(),
6805 true, global_iconv_handle);
6808 static bool handle_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6810 if (strcmp(*ptr, pszParmValue) != 0) {
6811 string_set(ptr, pszParmValue);
6812 init_iconv();
6814 return true;
6817 static bool handle_dos_charset(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6819 bool is_utf8 = false;
6820 size_t len = strlen(pszParmValue);
6822 if (len == 4 || len == 5) {
6823 /* Don't use StrCaseCmp here as we don't want to
6824 initialize iconv. */
6825 if ((toupper_m(pszParmValue[0]) == 'U') &&
6826 (toupper_m(pszParmValue[1]) == 'T') &&
6827 (toupper_m(pszParmValue[2]) == 'F')) {
6828 if (len == 4) {
6829 if (pszParmValue[3] == '8') {
6830 is_utf8 = true;
6832 } else {
6833 if (pszParmValue[3] == '-' &&
6834 pszParmValue[4] == '8') {
6835 is_utf8 = true;
6841 if (strcmp(*ptr, pszParmValue) != 0) {
6842 if (is_utf8) {
6843 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
6844 "be UTF8, using (default value) %s instead.\n",
6845 DEFAULT_DOS_CHARSET));
6846 pszParmValue = DEFAULT_DOS_CHARSET;
6848 string_set(ptr, pszParmValue);
6849 init_iconv();
6851 return true;
6854 static bool handle_realm(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6856 bool ret = true;
6857 char *realm = strupper_talloc(talloc_tos(), pszParmValue);
6858 char *dnsdomain = strlower_talloc(realm, pszParmValue);
6860 ret &= string_set(&Globals.szRealm, pszParmValue);
6861 ret &= string_set(&Globals.szRealm_upper, realm);
6862 ret &= string_set(&Globals.szRealm_lower, dnsdomain);
6863 TALLOC_FREE(realm);
6865 return ret;
6868 static bool handle_netbios_aliases(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6870 TALLOC_FREE(Globals.szNetbiosAliases);
6871 Globals.szNetbiosAliases = (const char **)str_list_make_v3(NULL, pszParmValue, NULL);
6872 return set_netbios_aliases(Globals.szNetbiosAliases);
6875 /***************************************************************************
6876 Handle the include operation.
6877 ***************************************************************************/
6878 static bool bAllowIncludeRegistry = true;
6880 static bool handle_include(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6882 char *fname;
6884 if (include_depth >= MAX_INCLUDE_DEPTH) {
6885 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
6886 include_depth));
6887 return false;
6890 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
6891 if (!bAllowIncludeRegistry) {
6892 return true;
6894 if (bInGlobalSection) {
6895 bool ret;
6896 include_depth++;
6897 ret = process_registry_globals();
6898 include_depth--;
6899 return ret;
6900 } else {
6901 DEBUG(1, ("\"include = registry\" only effective "
6902 "in %s section\n", GLOBAL_NAME));
6903 return false;
6907 fname = talloc_sub_basic(talloc_tos(), get_current_username(),
6908 current_user_info.domain,
6909 pszParmValue);
6911 add_to_file_list(pszParmValue, fname);
6913 string_set(ptr, fname);
6915 if (file_exist(fname)) {
6916 bool ret;
6917 include_depth++;
6918 ret = pm_process(fname, do_section, do_parameter, NULL);
6919 include_depth--;
6920 TALLOC_FREE(fname);
6921 return ret;
6924 DEBUG(2, ("Can't find include file %s\n", fname));
6925 TALLOC_FREE(fname);
6926 return true;
6929 /***************************************************************************
6930 Handle the interpretation of the copy parameter.
6931 ***************************************************************************/
6933 static bool handle_copy(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6935 bool bRetval;
6936 int iTemp;
6937 struct loadparm_service serviceTemp;
6939 string_set(ptr, pszParmValue);
6941 init_service(&serviceTemp);
6943 bRetval = false;
6945 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
6947 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
6948 if (iTemp == iServiceIndex) {
6949 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
6950 } else {
6951 copy_service(ServicePtrs[iServiceIndex],
6952 &serviceTemp,
6953 ServicePtrs[iServiceIndex]->copymap);
6954 bRetval = true;
6956 } else {
6957 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
6958 bRetval = false;
6961 free_service(&serviceTemp);
6962 return (bRetval);
6965 static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
6967 Globals.ldap_debug_level = lp_int(pszParmValue);
6968 init_ldap_debugging();
6969 return true;
6972 /***************************************************************************
6973 Handle idmap/non unix account uid and gid allocation parameters. The format of these
6974 parameters is:
6976 [global]
6978 idmap uid = 1000-1999
6979 idmap gid = 700-899
6981 We only do simple parsing checks here. The strings are parsed into useful
6982 structures in the idmap daemon code.
6984 ***************************************************************************/
6986 /* Some lp_ routines to return idmap [ug]id information */
6988 static uid_t idmap_uid_low, idmap_uid_high;
6989 static gid_t idmap_gid_low, idmap_gid_high;
6991 bool lp_idmap_uid(uid_t *low, uid_t *high)
6993 if (idmap_uid_low == 0 || idmap_uid_high == 0)
6994 return false;
6996 if (low)
6997 *low = idmap_uid_low;
6999 if (high)
7000 *high = idmap_uid_high;
7002 return true;
7005 bool lp_idmap_gid(gid_t *low, gid_t *high)
7007 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7008 return false;
7010 if (low)
7011 *low = idmap_gid_low;
7013 if (high)
7014 *high = idmap_gid_high;
7016 return true;
7019 static bool handle_idmap_backend(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7021 lp_do_parameter(snum, "idmap config * : backend", pszParmValue);
7023 return true;
7026 /* Do some simple checks on "idmap [ug]id" parameter values */
7028 static bool handle_idmap_uid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7030 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7032 return true;
7035 static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7037 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7039 return true;
7042 /***************************************************************************
7043 Handle the DEBUG level list.
7044 ***************************************************************************/
7046 static bool handle_debug_list(struct loadparm_context *unused, int snum, const char *pszParmValueIn, char **ptr )
7048 string_set(ptr, pszParmValueIn);
7049 return debug_parse_levels(pszParmValueIn);
7052 /***************************************************************************
7053 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7054 ***************************************************************************/
7056 static const char *append_ldap_suffix(TALLOC_CTX *ctx, const char *str )
7058 const char *suffix_string;
7060 suffix_string = talloc_asprintf(ctx, "%s,%s", str,
7061 Globals.szLdapSuffix );
7062 if ( !suffix_string ) {
7063 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7064 return "";
7067 return suffix_string;
7070 const char *lp_ldap_machine_suffix(TALLOC_CTX *ctx)
7072 if (Globals.szLdapMachineSuffix[0])
7073 return append_ldap_suffix(ctx, Globals.szLdapMachineSuffix);
7075 return lp_string(ctx, Globals.szLdapSuffix);
7078 const char *lp_ldap_user_suffix(TALLOC_CTX *ctx)
7080 if (Globals.szLdapUserSuffix[0])
7081 return append_ldap_suffix(ctx, Globals.szLdapUserSuffix);
7083 return lp_string(ctx, Globals.szLdapSuffix);
7086 const char *lp_ldap_group_suffix(TALLOC_CTX *ctx)
7088 if (Globals.szLdapGroupSuffix[0])
7089 return append_ldap_suffix(ctx, Globals.szLdapGroupSuffix);
7091 return lp_string(ctx, Globals.szLdapSuffix);
7094 const char *lp_ldap_idmap_suffix(TALLOC_CTX *ctx)
7096 if (Globals.szLdapIdmapSuffix[0])
7097 return append_ldap_suffix(ctx, Globals.szLdapIdmapSuffix);
7099 return lp_string(ctx, Globals.szLdapSuffix);
7102 /****************************************************************************
7103 set the value for a P_ENUM
7104 ***************************************************************************/
7106 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7107 int *ptr )
7109 int i;
7111 for (i = 0; parm->enum_list[i].name; i++) {
7112 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7113 *ptr = parm->enum_list[i].value;
7114 return;
7117 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7118 pszParmValue, parm->label));
7121 /***************************************************************************
7122 ***************************************************************************/
7124 static bool handle_printing(struct loadparm_context *unused, int snum, const char *pszParmValue, char **ptr)
7126 static int parm_num = -1;
7127 struct loadparm_service *s;
7129 if ( parm_num == -1 )
7130 parm_num = map_parameter( "printing" );
7132 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7134 if ( snum < 0 )
7135 s = &sDefault;
7136 else
7137 s = ServicePtrs[snum];
7139 init_printer_values( s );
7141 return true;
7145 /***************************************************************************
7146 Initialise a copymap.
7147 ***************************************************************************/
7149 static void init_copymap(struct loadparm_service *pservice)
7151 int i;
7153 TALLOC_FREE(pservice->copymap);
7155 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
7156 if (!pservice->copymap)
7157 DEBUG(0,
7158 ("Couldn't allocate copymap!! (size %d)\n",
7159 (int)NUMPARAMETERS));
7160 else
7161 for (i = 0; i < NUMPARAMETERS; i++)
7162 bitmap_set(pservice->copymap, i);
7166 return the parameter pointer for a parameter
7168 void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm)
7170 if (service == NULL) {
7171 if (parm->p_class == P_LOCAL)
7172 return (void *)(((char *)&sDefault)+parm->offset);
7173 else if (parm->p_class == P_GLOBAL)
7174 return (void *)(((char *)&Globals)+parm->offset);
7175 else return NULL;
7176 } else {
7177 return (void *)(((char *)service) + parm->offset);
7181 /***************************************************************************
7182 Return the local pointer to a parameter given the service number and parameter
7183 ***************************************************************************/
7185 void *lp_local_ptr_by_snum(int snum, struct parm_struct *parm)
7187 return lp_parm_ptr(ServicePtrs[snum], parm);
7190 /***************************************************************************
7191 Process a parameter for a particular service number. If snum < 0
7192 then assume we are in the globals.
7193 ***************************************************************************/
7195 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7197 int parmnum, i;
7198 void *parm_ptr = NULL; /* where we are going to store the result */
7199 struct parmlist_entry **opt_list;
7201 parmnum = map_parameter(pszParmName);
7203 if (parmnum < 0) {
7204 if (strchr(pszParmName, ':') == NULL) {
7205 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7206 pszParmName));
7207 return true;
7211 * We've got a parametric option
7214 opt_list = (snum < 0)
7215 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7216 set_param_opt(opt_list, pszParmName, pszParmValue, 0);
7218 return true;
7221 /* if it's already been set by the command line, then we don't
7222 override here */
7223 if (parm_table[parmnum].flags & FLAG_CMDLINE) {
7224 return true;
7227 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7228 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7229 pszParmName));
7232 /* we might point at a service, the default service or a global */
7233 if (snum < 0) {
7234 parm_ptr = lp_parm_ptr(NULL, &parm_table[parmnum]);
7235 } else {
7236 if (parm_table[parmnum].p_class == P_GLOBAL) {
7237 DEBUG(0,
7238 ("Global parameter %s found in service section!\n",
7239 pszParmName));
7240 return true;
7242 parm_ptr = lp_local_ptr_by_snum(snum, &parm_table[parmnum]);
7245 if (snum >= 0) {
7246 if (!ServicePtrs[snum]->copymap)
7247 init_copymap(ServicePtrs[snum]);
7249 /* this handles the aliases - set the copymap for other entries with
7250 the same data pointer */
7251 for (i = 0; parm_table[i].label; i++) {
7252 if ((parm_table[i].offset == parm_table[parmnum].offset)
7253 && (parm_table[i].p_class == parm_table[parmnum].p_class)) {
7254 bitmap_clear(ServicePtrs[snum]->copymap, i);
7259 /* if it is a special case then go ahead */
7260 if (parm_table[parmnum].special) {
7261 return parm_table[parmnum].special(NULL, snum, pszParmValue,
7262 (char **)parm_ptr);
7265 /* now switch on the type of variable it is */
7266 switch (parm_table[parmnum].type)
7268 case P_BOOL:
7269 *(bool *)parm_ptr = lp_bool(pszParmValue);
7270 break;
7272 case P_BOOLREV:
7273 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7274 break;
7276 case P_INTEGER:
7277 *(int *)parm_ptr = lp_int(pszParmValue);
7278 break;
7280 case P_CHAR:
7281 *(char *)parm_ptr = *pszParmValue;
7282 break;
7284 case P_OCTAL:
7285 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7286 if ( i != 1 ) {
7287 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7289 break;
7291 case P_BYTES:
7293 uint64_t val;
7294 if (conv_str_size_error(pszParmValue, &val)) {
7295 if (val <= INT_MAX) {
7296 *(int *)parm_ptr = (int)val;
7297 break;
7301 DEBUG(0,("lp_do_parameter(%s): value is not "
7302 "a valid size specifier!\n", pszParmValue));
7303 return false;
7306 case P_LIST:
7307 case P_CMDLIST:
7308 TALLOC_FREE(*((char ***)parm_ptr));
7309 *(char ***)parm_ptr = str_list_make_v3(
7310 NULL, pszParmValue, NULL);
7311 break;
7313 case P_STRING:
7314 string_set((char **)parm_ptr, pszParmValue);
7315 break;
7317 case P_USTRING:
7319 char *upper_string = strupper_talloc(talloc_tos(),
7320 pszParmValue);
7321 string_set((char **)parm_ptr, upper_string);
7322 TALLOC_FREE(upper_string);
7323 break;
7325 case P_ENUM:
7326 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7327 break;
7328 case P_SEP:
7329 break;
7332 return true;
7335 /***************************************************************************
7336 set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
7337 FLAG_CMDLINE won't be overridden by loads from smb.conf.
7338 ***************************************************************************/
7340 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
7342 int parmnum, i;
7343 parmnum = map_parameter(pszParmName);
7344 if (parmnum >= 0) {
7345 parm_table[parmnum].flags &= ~FLAG_CMDLINE;
7346 if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
7347 return false;
7349 parm_table[parmnum].flags |= FLAG_CMDLINE;
7351 /* we have to also set FLAG_CMDLINE on aliases. Aliases must
7352 * be grouped in the table, so we don't have to search the
7353 * whole table */
7354 for (i=parmnum-1;
7355 i>=0 && parm_table[i].offset == parm_table[parmnum].offset
7356 && parm_table[i].p_class == parm_table[parmnum].p_class;
7357 i--) {
7358 parm_table[i].flags |= FLAG_CMDLINE;
7360 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset
7361 && parm_table[i].p_class == parm_table[parmnum].p_class;i++) {
7362 parm_table[i].flags |= FLAG_CMDLINE;
7365 if (store_values) {
7366 store_lp_set_cmdline(pszParmName, pszParmValue);
7368 return true;
7371 /* it might be parametric */
7372 if (strchr(pszParmName, ':') != NULL) {
7373 set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
7374 if (store_values) {
7375 store_lp_set_cmdline(pszParmName, pszParmValue);
7377 return true;
7380 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
7381 return true;
7384 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
7386 return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
7389 /***************************************************************************
7390 Process a parameter.
7391 ***************************************************************************/
7393 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7394 void *userdata)
7396 if (!bInGlobalSection && bGlobalOnly)
7397 return true;
7399 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7401 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7402 pszParmName, pszParmValue));
7406 set a option from the commandline in 'a=b' format. Use to support --option
7408 bool lp_set_option(const char *option)
7410 char *p, *s;
7411 bool ret;
7413 s = talloc_strdup(NULL, option);
7414 if (!s) {
7415 return false;
7418 p = strchr(s, '=');
7419 if (!p) {
7420 talloc_free(s);
7421 return false;
7424 *p = 0;
7426 /* skip white spaces after the = sign */
7427 do {
7428 p++;
7429 } while (*p == ' ');
7431 ret = lp_set_cmdline(s, p);
7432 talloc_free(s);
7433 return ret;
7436 /**************************************************************************
7437 Print a parameter of the specified type.
7438 ***************************************************************************/
7440 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7442 /* For the seperation of lists values that we print below */
7443 const char *list_sep = ", ";
7444 int i;
7445 switch (p->type)
7447 case P_ENUM:
7448 for (i = 0; p->enum_list[i].name; i++) {
7449 if (*(int *)ptr == p->enum_list[i].value) {
7450 fprintf(f, "%s",
7451 p->enum_list[i].name);
7452 break;
7455 break;
7457 case P_BOOL:
7458 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7459 break;
7461 case P_BOOLREV:
7462 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7463 break;
7465 case P_INTEGER:
7466 case P_BYTES:
7467 fprintf(f, "%d", *(int *)ptr);
7468 break;
7470 case P_CHAR:
7471 fprintf(f, "%c", *(char *)ptr);
7472 break;
7474 case P_OCTAL: {
7475 int val = *(int *)ptr;
7476 if (val == -1) {
7477 fprintf(f, "-1");
7478 } else {
7479 fprintf(f, "0%o", val);
7481 break;
7484 case P_CMDLIST:
7485 list_sep = " ";
7486 /* fall through */
7487 case P_LIST:
7488 if ((char ***)ptr && *(char ***)ptr) {
7489 char **list = *(char ***)ptr;
7490 for (; *list; list++) {
7491 /* surround strings with whitespace in double quotes */
7492 if (*(list+1) == NULL) {
7493 /* last item, no extra separator */
7494 list_sep = "";
7496 if ( strchr_m( *list, ' ' ) ) {
7497 fprintf(f, "\"%s\"%s", *list, list_sep);
7498 } else {
7499 fprintf(f, "%s%s", *list, list_sep);
7503 break;
7505 case P_STRING:
7506 case P_USTRING:
7507 if (*(char **)ptr) {
7508 fprintf(f, "%s", *(char **)ptr);
7510 break;
7511 case P_SEP:
7512 break;
7516 /***************************************************************************
7517 Check if two parameters are equal.
7518 ***************************************************************************/
7520 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7522 switch (type) {
7523 case P_BOOL:
7524 case P_BOOLREV:
7525 return (*((bool *)ptr1) == *((bool *)ptr2));
7527 case P_INTEGER:
7528 case P_ENUM:
7529 case P_OCTAL:
7530 case P_BYTES:
7531 return (*((int *)ptr1) == *((int *)ptr2));
7533 case P_CHAR:
7534 return (*((char *)ptr1) == *((char *)ptr2));
7536 case P_LIST:
7537 case P_CMDLIST:
7538 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7540 case P_STRING:
7541 case P_USTRING:
7543 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7544 if (p1 && !*p1)
7545 p1 = NULL;
7546 if (p2 && !*p2)
7547 p2 = NULL;
7548 return (p1 == p2 || strequal(p1, p2));
7550 case P_SEP:
7551 break;
7553 return false;
7556 /***************************************************************************
7557 Initialize any local varients in the sDefault table.
7558 ***************************************************************************/
7560 void init_locals(void)
7562 /* None as yet. */
7565 /***************************************************************************
7566 Process a new section (service). At this stage all sections are services.
7567 Later we'll have special sections that permit server parameters to be set.
7568 Returns true on success, false on failure.
7569 ***************************************************************************/
7571 static bool do_section(const char *pszSectionName, void *userdata)
7573 bool bRetval;
7574 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7575 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7576 bRetval = false;
7578 /* if we were in a global section then do the local inits */
7579 if (bInGlobalSection && !isglobal)
7580 init_locals();
7582 /* if we've just struck a global section, note the fact. */
7583 bInGlobalSection = isglobal;
7585 /* check for multiple global sections */
7586 if (bInGlobalSection) {
7587 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7588 return true;
7591 if (!bInGlobalSection && bGlobalOnly)
7592 return true;
7594 /* if we have a current service, tidy it up before moving on */
7595 bRetval = true;
7597 if (iServiceIndex >= 0)
7598 bRetval = service_ok(iServiceIndex);
7600 /* if all is still well, move to the next record in the services array */
7601 if (bRetval) {
7602 /* We put this here to avoid an odd message order if messages are */
7603 /* issued by the post-processing of a previous section. */
7604 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7606 iServiceIndex = add_a_service(&sDefault, pszSectionName);
7607 if (iServiceIndex < 0) {
7608 DEBUG(0, ("Failed to add a new service\n"));
7609 return false;
7611 /* Clean all parametric options for service */
7612 /* They will be added during parsing again */
7613 free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
7616 return bRetval;
7620 /***************************************************************************
7621 Determine if a partcular base parameter is currentl set to the default value.
7622 ***************************************************************************/
7624 static bool is_default(int i)
7626 if (!defaults_saved)
7627 return false;
7628 switch (parm_table[i].type) {
7629 case P_LIST:
7630 case P_CMDLIST:
7631 return str_list_equal((const char **)parm_table[i].def.lvalue,
7632 *(const char ***)lp_parm_ptr(NULL,
7633 &parm_table[i]));
7634 case P_STRING:
7635 case P_USTRING:
7636 return strequal(parm_table[i].def.svalue,
7637 *(char **)lp_parm_ptr(NULL,
7638 &parm_table[i]));
7639 case P_BOOL:
7640 case P_BOOLREV:
7641 return parm_table[i].def.bvalue ==
7642 *(bool *)lp_parm_ptr(NULL,
7643 &parm_table[i]);
7644 case P_CHAR:
7645 return parm_table[i].def.cvalue ==
7646 *(char *)lp_parm_ptr(NULL,
7647 &parm_table[i]);
7648 case P_INTEGER:
7649 case P_OCTAL:
7650 case P_ENUM:
7651 case P_BYTES:
7652 return parm_table[i].def.ivalue ==
7653 *(int *)lp_parm_ptr(NULL,
7654 &parm_table[i]);
7655 case P_SEP:
7656 break;
7658 return false;
7661 /***************************************************************************
7662 Display the contents of the global structure.
7663 ***************************************************************************/
7665 static void dump_globals(FILE *f)
7667 int i;
7668 struct parmlist_entry *data;
7670 fprintf(f, "[global]\n");
7672 for (i = 0; parm_table[i].label; i++)
7673 if (parm_table[i].p_class == P_GLOBAL &&
7674 !(parm_table[i].flags & FLAG_META) &&
7675 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
7676 if (defaults_saved && is_default(i))
7677 continue;
7678 fprintf(f, "\t%s = ", parm_table[i].label);
7679 print_parameter(&parm_table[i], lp_parm_ptr(NULL,
7680 &parm_table[i]),
7682 fprintf(f, "\n");
7684 if (Globals.param_opt != NULL) {
7685 data = Globals.param_opt;
7686 while(data) {
7687 fprintf(f, "\t%s = %s\n", data->key, data->value);
7688 data = data->next;
7694 /***************************************************************************
7695 Return true if a local parameter is currently set to the global default.
7696 ***************************************************************************/
7698 bool lp_is_default(int snum, struct parm_struct *parm)
7700 return equal_parameter(parm->type,
7701 lp_parm_ptr(ServicePtrs[snum], parm),
7702 lp_parm_ptr(NULL, parm));
7705 /***************************************************************************
7706 Display the contents of a single services record.
7707 ***************************************************************************/
7709 static void dump_a_service(struct loadparm_service *pService, FILE * f)
7711 int i;
7712 struct parmlist_entry *data;
7714 if (pService != &sDefault)
7715 fprintf(f, "[%s]\n", pService->szService);
7717 for (i = 0; parm_table[i].label; i++) {
7719 if (parm_table[i].p_class == P_LOCAL &&
7720 !(parm_table[i].flags & FLAG_META) &&
7721 (*parm_table[i].label != '-') &&
7722 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7724 if (pService == &sDefault) {
7725 if (defaults_saved && is_default(i))
7726 continue;
7727 } else {
7728 if (equal_parameter(parm_table[i].type,
7729 lp_parm_ptr(pService, &parm_table[i]),
7730 lp_parm_ptr(NULL, &parm_table[i])))
7731 continue;
7734 fprintf(f, "\t%s = ", parm_table[i].label);
7735 print_parameter(&parm_table[i],
7736 lp_parm_ptr(pService, &parm_table[i]),
7738 fprintf(f, "\n");
7742 if (pService->param_opt != NULL) {
7743 data = pService->param_opt;
7744 while(data) {
7745 fprintf(f, "\t%s = %s\n", data->key, data->value);
7746 data = data->next;
7751 /***************************************************************************
7752 Display the contents of a parameter of a single services record.
7753 ***************************************************************************/
7755 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7757 int i;
7758 bool result = false;
7759 parm_class p_class;
7760 unsigned flag = 0;
7761 fstring local_parm_name;
7762 char *parm_opt;
7763 const char *parm_opt_value;
7765 /* check for parametrical option */
7766 fstrcpy( local_parm_name, parm_name);
7767 parm_opt = strchr( local_parm_name, ':');
7769 if (parm_opt) {
7770 *parm_opt = '\0';
7771 parm_opt++;
7772 if (strlen(parm_opt)) {
7773 parm_opt_value = lp_parm_const_string( snum,
7774 local_parm_name, parm_opt, NULL);
7775 if (parm_opt_value) {
7776 printf( "%s\n", parm_opt_value);
7777 result = true;
7780 return result;
7783 /* check for a key and print the value */
7784 if (isGlobal) {
7785 p_class = P_GLOBAL;
7786 flag = FLAG_GLOBAL;
7787 } else
7788 p_class = P_LOCAL;
7790 for (i = 0; parm_table[i].label; i++) {
7791 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7792 !(parm_table[i].flags & FLAG_META) &&
7793 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7794 (*parm_table[i].label != '-') &&
7795 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
7797 void *ptr;
7799 if (isGlobal) {
7800 ptr = lp_parm_ptr(NULL,
7801 &parm_table[i]);
7802 } else {
7803 ptr = lp_parm_ptr(ServicePtrs[snum],
7804 &parm_table[i]);
7807 print_parameter(&parm_table[i],
7808 ptr, f);
7809 fprintf(f, "\n");
7810 result = true;
7811 break;
7815 return result;
7818 /***************************************************************************
7819 Return info about the requested parameter (given as a string).
7820 Return NULL when the string is not a valid parameter name.
7821 ***************************************************************************/
7823 struct parm_struct *lp_get_parameter(const char *param_name)
7825 int num = map_parameter(param_name);
7827 if (num < 0) {
7828 return NULL;
7831 return &parm_table[num];
7834 /***************************************************************************
7835 Return info about the next parameter in a service.
7836 snum==GLOBAL_SECTION_SNUM gives the globals.
7837 Return NULL when out of parameters.
7838 ***************************************************************************/
7840 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
7842 if (snum < 0) {
7843 /* do the globals */
7844 for (; parm_table[*i].label; (*i)++) {
7845 if (parm_table[*i].p_class == P_SEPARATOR)
7846 return &parm_table[(*i)++];
7848 if ((*parm_table[*i].label == '-'))
7849 continue;
7851 if ((*i) > 0
7852 && (parm_table[*i].offset ==
7853 parm_table[(*i) - 1].offset)
7854 && (parm_table[*i].p_class ==
7855 parm_table[(*i) - 1].p_class))
7856 continue;
7858 if (is_default(*i) && !allparameters)
7859 continue;
7861 return &parm_table[(*i)++];
7863 } else {
7864 struct loadparm_service *pService = ServicePtrs[snum];
7866 for (; parm_table[*i].label; (*i)++) {
7867 if (parm_table[*i].p_class == P_SEPARATOR)
7868 return &parm_table[(*i)++];
7870 if (parm_table[*i].p_class == P_LOCAL &&
7871 (*parm_table[*i].label != '-') &&
7872 ((*i) == 0 ||
7873 (parm_table[*i].offset !=
7874 parm_table[(*i) - 1].offset)))
7876 if (allparameters ||
7877 !equal_parameter(parm_table[*i].type,
7878 lp_parm_ptr(pService,
7879 &parm_table[*i]),
7880 lp_parm_ptr(NULL,
7881 &parm_table[*i])))
7883 return &parm_table[(*i)++];
7889 return NULL;
7893 #if 0
7894 /***************************************************************************
7895 Display the contents of a single copy structure.
7896 ***************************************************************************/
7897 static void dump_copy_map(bool *pcopymap)
7899 int i;
7900 if (!pcopymap)
7901 return;
7903 printf("\n\tNon-Copied parameters:\n");
7905 for (i = 0; parm_table[i].label; i++)
7906 if (parm_table[i].p_class == P_LOCAL &&
7907 parm_table[i].ptr && !pcopymap[i] &&
7908 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7910 printf("\t\t%s\n", parm_table[i].label);
7913 #endif
7915 /***************************************************************************
7916 Return TRUE if the passed service number is within range.
7917 ***************************************************************************/
7919 bool lp_snum_ok(int iService)
7921 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
7924 /***************************************************************************
7925 Auto-load some home services.
7926 ***************************************************************************/
7928 static void lp_add_auto_services(char *str)
7930 char *s;
7931 char *p;
7932 int homes;
7933 char *saveptr;
7935 if (!str)
7936 return;
7938 s = SMB_STRDUP(str);
7939 if (!s)
7940 return;
7942 homes = lp_servicenumber(HOMES_NAME);
7944 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
7945 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
7946 char *home;
7948 if (lp_servicenumber(p) >= 0)
7949 continue;
7951 home = get_user_home_dir(talloc_tos(), p);
7953 if (home && home[0] && homes >= 0)
7954 lp_add_home(p, homes, p, home);
7956 TALLOC_FREE(home);
7958 SAFE_FREE(s);
7961 /***************************************************************************
7962 Auto-load one printer.
7963 ***************************************************************************/
7965 void lp_add_one_printer(const char *name, const char *comment,
7966 const char *location, void *pdata)
7968 int printers = lp_servicenumber(PRINTERS_NAME);
7969 int i;
7971 if (lp_servicenumber(name) < 0) {
7972 lp_add_printer(name, printers);
7973 if ((i = lp_servicenumber(name)) >= 0) {
7974 string_set(&ServicePtrs[i]->comment, comment);
7975 ServicePtrs[i]->autoloaded = true;
7980 /***************************************************************************
7981 Have we loaded a services file yet?
7982 ***************************************************************************/
7984 bool lp_loaded(void)
7986 return (bLoaded);
7989 /***************************************************************************
7990 Unload unused services.
7991 ***************************************************************************/
7993 void lp_killunused(struct smbd_server_connection *sconn,
7994 bool (*snumused) (struct smbd_server_connection *, int))
7996 int i;
7997 for (i = 0; i < iNumServices; i++) {
7998 if (!VALID(i))
7999 continue;
8001 /* don't kill autoloaded or usershare services */
8002 if ( ServicePtrs[i]->autoloaded ||
8003 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8004 continue;
8007 if (!snumused || !snumused(sconn, i)) {
8008 free_service_byindex(i);
8014 * Kill all except autoloaded and usershare services - convenience wrapper
8016 void lp_kill_all_services(void)
8018 lp_killunused(NULL, NULL);
8021 /***************************************************************************
8022 Unload a service.
8023 ***************************************************************************/
8025 void lp_killservice(int iServiceIn)
8027 if (VALID(iServiceIn)) {
8028 free_service_byindex(iServiceIn);
8032 /***************************************************************************
8033 Save the curent values of all global and sDefault parameters into the
8034 defaults union. This allows swat and testparm to show only the
8035 changed (ie. non-default) parameters.
8036 ***************************************************************************/
8038 static void lp_save_defaults(void)
8040 int i;
8041 for (i = 0; parm_table[i].label; i++) {
8042 if (i > 0 && parm_table[i].offset == parm_table[i - 1].offset
8043 && parm_table[i].p_class == parm_table[i - 1].p_class)
8044 continue;
8045 switch (parm_table[i].type) {
8046 case P_LIST:
8047 case P_CMDLIST:
8048 parm_table[i].def.lvalue = str_list_copy(
8049 NULL, *(const char ***)lp_parm_ptr(NULL, &parm_table[i]));
8050 break;
8051 case P_STRING:
8052 case P_USTRING:
8053 parm_table[i].def.svalue = SMB_STRDUP(*(char **)lp_parm_ptr(NULL, &parm_table[i]));
8054 break;
8055 case P_BOOL:
8056 case P_BOOLREV:
8057 parm_table[i].def.bvalue =
8058 *(bool *)lp_parm_ptr(NULL, &parm_table[i]);
8059 break;
8060 case P_CHAR:
8061 parm_table[i].def.cvalue =
8062 *(char *)lp_parm_ptr(NULL, &parm_table[i]);
8063 break;
8064 case P_INTEGER:
8065 case P_OCTAL:
8066 case P_ENUM:
8067 case P_BYTES:
8068 parm_table[i].def.ivalue =
8069 *(int *)lp_parm_ptr(NULL, &parm_table[i]);
8070 break;
8071 case P_SEP:
8072 break;
8075 defaults_saved = true;
8078 /***********************************************************
8079 If we should send plaintext/LANMAN passwords in the clinet
8080 ************************************************************/
8082 static void set_allowed_client_auth(void)
8084 if (Globals.bClientNTLMv2Auth) {
8085 Globals.bClientLanManAuth = false;
8087 if (!Globals.bClientLanManAuth) {
8088 Globals.bClientPlaintextAuth = false;
8092 /***************************************************************************
8093 JRA.
8094 The following code allows smbd to read a user defined share file.
8095 Yes, this is my intent. Yes, I'm comfortable with that...
8097 THE FOLLOWING IS SECURITY CRITICAL CODE.
8099 It washes your clothes, it cleans your house, it guards you while you sleep...
8100 Do not f%^k with it....
8101 ***************************************************************************/
8103 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8105 /***************************************************************************
8106 Check allowed stat state of a usershare file.
8107 Ensure we print out who is dicking with us so the admin can
8108 get their sorry ass fired.
8109 ***************************************************************************/
8111 static bool check_usershare_stat(const char *fname,
8112 const SMB_STRUCT_STAT *psbuf)
8114 if (!S_ISREG(psbuf->st_ex_mode)) {
8115 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8116 "not a regular file\n",
8117 fname, (unsigned int)psbuf->st_ex_uid ));
8118 return false;
8121 /* Ensure this doesn't have the other write bit set. */
8122 if (psbuf->st_ex_mode & S_IWOTH) {
8123 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8124 "public write. Refusing to allow as a usershare file.\n",
8125 fname, (unsigned int)psbuf->st_ex_uid ));
8126 return false;
8129 /* Should be 10k or less. */
8130 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8131 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8132 "too large (%u) to be a user share file.\n",
8133 fname, (unsigned int)psbuf->st_ex_uid,
8134 (unsigned int)psbuf->st_ex_size ));
8135 return false;
8138 return true;
8141 /***************************************************************************
8142 Parse the contents of a usershare file.
8143 ***************************************************************************/
8145 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8146 SMB_STRUCT_STAT *psbuf,
8147 const char *servicename,
8148 int snum,
8149 char **lines,
8150 int numlines,
8151 char **pp_sharepath,
8152 char **pp_comment,
8153 char **pp_cp_servicename,
8154 struct security_descriptor **ppsd,
8155 bool *pallow_guest)
8157 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8158 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8159 int us_vers;
8160 DIR *dp;
8161 SMB_STRUCT_STAT sbuf;
8162 char *sharepath = NULL;
8163 char *comment = NULL;
8165 *pp_sharepath = NULL;
8166 *pp_comment = NULL;
8168 *pallow_guest = false;
8170 if (numlines < 4) {
8171 return USERSHARE_MALFORMED_FILE;
8174 if (strcmp(lines[0], "#VERSION 1") == 0) {
8175 us_vers = 1;
8176 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8177 us_vers = 2;
8178 if (numlines < 5) {
8179 return USERSHARE_MALFORMED_FILE;
8181 } else {
8182 return USERSHARE_BAD_VERSION;
8185 if (strncmp(lines[1], "path=", 5) != 0) {
8186 return USERSHARE_MALFORMED_PATH;
8189 sharepath = talloc_strdup(ctx, &lines[1][5]);
8190 if (!sharepath) {
8191 return USERSHARE_POSIX_ERR;
8193 trim_string(sharepath, " ", " ");
8195 if (strncmp(lines[2], "comment=", 8) != 0) {
8196 return USERSHARE_MALFORMED_COMMENT_DEF;
8199 comment = talloc_strdup(ctx, &lines[2][8]);
8200 if (!comment) {
8201 return USERSHARE_POSIX_ERR;
8203 trim_string(comment, " ", " ");
8204 trim_char(comment, '"', '"');
8206 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8207 return USERSHARE_MALFORMED_ACL_DEF;
8210 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8211 return USERSHARE_ACL_ERR;
8214 if (us_vers == 2) {
8215 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8216 return USERSHARE_MALFORMED_ACL_DEF;
8218 if (lines[4][9] == 'y') {
8219 *pallow_guest = true;
8222 /* Backwards compatible extension to file version #2. */
8223 if (numlines > 5) {
8224 if (strncmp(lines[5], "sharename=", 10) != 0) {
8225 return USERSHARE_MALFORMED_SHARENAME_DEF;
8227 if (!strequal(&lines[5][10], servicename)) {
8228 return USERSHARE_BAD_SHARENAME;
8230 *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
8231 if (!*pp_cp_servicename) {
8232 return USERSHARE_POSIX_ERR;
8237 if (*pp_cp_servicename == NULL) {
8238 *pp_cp_servicename = talloc_strdup(ctx, servicename);
8239 if (!*pp_cp_servicename) {
8240 return USERSHARE_POSIX_ERR;
8244 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8245 /* Path didn't change, no checks needed. */
8246 *pp_sharepath = sharepath;
8247 *pp_comment = comment;
8248 return USERSHARE_OK;
8251 /* The path *must* be absolute. */
8252 if (sharepath[0] != '/') {
8253 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8254 servicename, sharepath));
8255 return USERSHARE_PATH_NOT_ABSOLUTE;
8258 /* If there is a usershare prefix deny list ensure one of these paths
8259 doesn't match the start of the user given path. */
8260 if (prefixdenylist) {
8261 int i;
8262 for ( i=0; prefixdenylist[i]; i++ ) {
8263 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8264 servicename, i, prefixdenylist[i], sharepath ));
8265 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8266 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8267 "usershare prefix deny list entries.\n",
8268 servicename, sharepath));
8269 return USERSHARE_PATH_IS_DENIED;
8274 /* If there is a usershare prefix allow list ensure one of these paths
8275 does match the start of the user given path. */
8277 if (prefixallowlist) {
8278 int i;
8279 for ( i=0; prefixallowlist[i]; i++ ) {
8280 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8281 servicename, i, prefixallowlist[i], sharepath ));
8282 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8283 break;
8286 if (prefixallowlist[i] == NULL) {
8287 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8288 "usershare prefix allow list entries.\n",
8289 servicename, sharepath));
8290 return USERSHARE_PATH_NOT_ALLOWED;
8294 /* Ensure this is pointing to a directory. */
8295 dp = opendir(sharepath);
8297 if (!dp) {
8298 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8299 servicename, sharepath));
8300 return USERSHARE_PATH_NOT_DIRECTORY;
8303 /* Ensure the owner of the usershare file has permission to share
8304 this directory. */
8306 if (sys_stat(sharepath, &sbuf, false) == -1) {
8307 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8308 servicename, sharepath, strerror(errno) ));
8309 closedir(dp);
8310 return USERSHARE_POSIX_ERR;
8313 closedir(dp);
8315 if (!S_ISDIR(sbuf.st_ex_mode)) {
8316 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8317 servicename, sharepath ));
8318 return USERSHARE_PATH_NOT_DIRECTORY;
8321 /* Check if sharing is restricted to owner-only. */
8322 /* psbuf is the stat of the usershare definition file,
8323 sbuf is the stat of the target directory to be shared. */
8325 if (lp_usershare_owner_only()) {
8326 /* root can share anything. */
8327 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8328 return USERSHARE_PATH_NOT_ALLOWED;
8332 *pp_sharepath = sharepath;
8333 *pp_comment = comment;
8334 return USERSHARE_OK;
8337 /***************************************************************************
8338 Deal with a usershare file.
8339 Returns:
8340 >= 0 - snum
8341 -1 - Bad name, invalid contents.
8342 - service name already existed and not a usershare, problem
8343 with permissions to share directory etc.
8344 ***************************************************************************/
8346 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8348 SMB_STRUCT_STAT sbuf;
8349 SMB_STRUCT_STAT lsbuf;
8350 char *fname = NULL;
8351 char *sharepath = NULL;
8352 char *comment = NULL;
8353 char *cp_service_name = NULL;
8354 char **lines = NULL;
8355 int numlines = 0;
8356 int fd = -1;
8357 int iService = -1;
8358 TALLOC_CTX *ctx = talloc_stackframe();
8359 struct security_descriptor *psd = NULL;
8360 bool guest_ok = false;
8361 char *canon_name = NULL;
8362 bool added_service = false;
8363 int ret = -1;
8365 /* Ensure share name doesn't contain invalid characters. */
8366 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8367 DEBUG(0,("process_usershare_file: share name %s contains "
8368 "invalid characters (any of %s)\n",
8369 file_name, INVALID_SHARENAME_CHARS ));
8370 goto out;
8373 canon_name = canonicalize_servicename(ctx, file_name);
8374 if (!canon_name) {
8375 goto out;
8378 fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
8379 if (!fname) {
8380 goto out;
8383 /* Minimize the race condition by doing an lstat before we
8384 open and fstat. Ensure this isn't a symlink link. */
8386 if (sys_lstat(fname, &lsbuf, false) != 0) {
8387 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8388 fname, strerror(errno) ));
8389 goto out;
8392 /* This must be a regular file, not a symlink, directory or
8393 other strange filetype. */
8394 if (!check_usershare_stat(fname, &lsbuf)) {
8395 goto out;
8399 TDB_DATA data;
8400 NTSTATUS status;
8402 status = dbwrap_fetch_bystring(ServiceHash, canon_name,
8403 canon_name, &data);
8405 iService = -1;
8407 if (NT_STATUS_IS_OK(status) &&
8408 (data.dptr != NULL) &&
8409 (data.dsize == sizeof(iService))) {
8410 memcpy(&iService, data.dptr, sizeof(iService));
8414 if (iService != -1 &&
8415 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8416 &lsbuf.st_ex_mtime) == 0) {
8417 /* Nothing changed - Mark valid and return. */
8418 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8419 canon_name ));
8420 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8421 ret = iService;
8422 goto out;
8425 /* Try and open the file read only - no symlinks allowed. */
8426 #ifdef O_NOFOLLOW
8427 fd = open(fname, O_RDONLY|O_NOFOLLOW, 0);
8428 #else
8429 fd = open(fname, O_RDONLY, 0);
8430 #endif
8432 if (fd == -1) {
8433 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8434 fname, strerror(errno) ));
8435 goto out;
8438 /* Now fstat to be *SURE* it's a regular file. */
8439 if (sys_fstat(fd, &sbuf, false) != 0) {
8440 close(fd);
8441 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8442 fname, strerror(errno) ));
8443 goto out;
8446 /* Is it the same dev/inode as was lstated ? */
8447 if (!check_same_stat(&lsbuf, &sbuf)) {
8448 close(fd);
8449 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8450 "Symlink spoofing going on ?\n", fname ));
8451 goto out;
8454 /* This must be a regular file, not a symlink, directory or
8455 other strange filetype. */
8456 if (!check_usershare_stat(fname, &sbuf)) {
8457 goto out;
8460 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8462 close(fd);
8463 if (lines == NULL) {
8464 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8465 fname, (unsigned int)sbuf.st_ex_uid ));
8466 goto out;
8469 if (parse_usershare_file(ctx, &sbuf, file_name,
8470 iService, lines, numlines, &sharepath,
8471 &comment, &cp_service_name,
8472 &psd, &guest_ok) != USERSHARE_OK) {
8473 goto out;
8476 /* Everything ok - add the service possibly using a template. */
8477 if (iService < 0) {
8478 const struct loadparm_service *sp = &sDefault;
8479 if (snum_template != -1) {
8480 sp = ServicePtrs[snum_template];
8483 if ((iService = add_a_service(sp, cp_service_name)) < 0) {
8484 DEBUG(0, ("process_usershare_file: Failed to add "
8485 "new service %s\n", cp_service_name));
8486 goto out;
8489 added_service = true;
8491 /* Read only is controlled by usershare ACL below. */
8492 ServicePtrs[iService]->bRead_only = false;
8495 /* Write the ACL of the new/modified share. */
8496 if (!set_share_security(canon_name, psd)) {
8497 DEBUG(0, ("process_usershare_file: Failed to set share "
8498 "security for user share %s\n",
8499 canon_name ));
8500 goto out;
8503 /* If from a template it may be marked invalid. */
8504 ServicePtrs[iService]->valid = true;
8506 /* Set the service as a valid usershare. */
8507 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8509 /* Set guest access. */
8510 if (lp_usershare_allow_guests()) {
8511 ServicePtrs[iService]->bGuest_ok = guest_ok;
8514 /* And note when it was loaded. */
8515 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8516 string_set(&ServicePtrs[iService]->szPath, sharepath);
8517 string_set(&ServicePtrs[iService]->comment, comment);
8519 ret = iService;
8521 out:
8523 if (ret == -1 && iService != -1 && added_service) {
8524 lp_remove_service(iService);
8527 TALLOC_FREE(lines);
8528 TALLOC_FREE(ctx);
8529 return ret;
8532 /***************************************************************************
8533 Checks if a usershare entry has been modified since last load.
8534 ***************************************************************************/
8536 static bool usershare_exists(int iService, struct timespec *last_mod)
8538 SMB_STRUCT_STAT lsbuf;
8539 const char *usersharepath = Globals.szUsersharePath;
8540 char *fname;
8542 if (asprintf(&fname, "%s/%s",
8543 usersharepath,
8544 ServicePtrs[iService]->szService) < 0) {
8545 return false;
8548 if (sys_lstat(fname, &lsbuf, false) != 0) {
8549 SAFE_FREE(fname);
8550 return false;
8553 if (!S_ISREG(lsbuf.st_ex_mode)) {
8554 SAFE_FREE(fname);
8555 return false;
8558 SAFE_FREE(fname);
8559 *last_mod = lsbuf.st_ex_mtime;
8560 return true;
8563 /***************************************************************************
8564 Load a usershare service by name. Returns a valid servicenumber or -1.
8565 ***************************************************************************/
8567 int load_usershare_service(const char *servicename)
8569 SMB_STRUCT_STAT sbuf;
8570 const char *usersharepath = Globals.szUsersharePath;
8571 int max_user_shares = Globals.iUsershareMaxShares;
8572 int snum_template = -1;
8574 if (*usersharepath == 0 || max_user_shares == 0) {
8575 return -1;
8578 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8579 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8580 usersharepath, strerror(errno) ));
8581 return -1;
8584 if (!S_ISDIR(sbuf.st_ex_mode)) {
8585 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8586 usersharepath ));
8587 return -1;
8591 * This directory must be owned by root, and have the 't' bit set.
8592 * It also must not be writable by "other".
8595 #ifdef S_ISVTX
8596 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8597 #else
8598 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8599 #endif
8600 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8601 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8602 usersharepath ));
8603 return -1;
8606 /* Ensure the template share exists if it's set. */
8607 if (Globals.szUsershareTemplateShare[0]) {
8608 /* We can't use lp_servicenumber here as we are recommending that
8609 template shares have -valid=false set. */
8610 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8611 if (ServicePtrs[snum_template]->szService &&
8612 strequal(ServicePtrs[snum_template]->szService,
8613 Globals.szUsershareTemplateShare)) {
8614 break;
8618 if (snum_template == -1) {
8619 DEBUG(0,("load_usershare_service: usershare template share %s "
8620 "does not exist.\n",
8621 Globals.szUsershareTemplateShare ));
8622 return -1;
8626 return process_usershare_file(usersharepath, servicename, snum_template);
8629 /***************************************************************************
8630 Load all user defined shares from the user share directory.
8631 We only do this if we're enumerating the share list.
8632 This is the function that can delete usershares that have
8633 been removed.
8634 ***************************************************************************/
8636 int load_usershare_shares(struct smbd_server_connection *sconn,
8637 bool (*snumused) (struct smbd_server_connection *, int))
8639 DIR *dp;
8640 SMB_STRUCT_STAT sbuf;
8641 struct dirent *de;
8642 int num_usershares = 0;
8643 int max_user_shares = Globals.iUsershareMaxShares;
8644 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8645 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8646 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8647 int iService;
8648 int snum_template = -1;
8649 const char *usersharepath = Globals.szUsersharePath;
8650 int ret = lp_numservices();
8651 TALLOC_CTX *tmp_ctx;
8653 if (max_user_shares == 0 || *usersharepath == '\0') {
8654 return lp_numservices();
8657 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8658 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8659 usersharepath, strerror(errno) ));
8660 return ret;
8664 * This directory must be owned by root, and have the 't' bit set.
8665 * It also must not be writable by "other".
8668 #ifdef S_ISVTX
8669 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8670 #else
8671 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8672 #endif
8673 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8674 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8675 usersharepath ));
8676 return ret;
8679 /* Ensure the template share exists if it's set. */
8680 if (Globals.szUsershareTemplateShare[0]) {
8681 /* We can't use lp_servicenumber here as we are recommending that
8682 template shares have -valid=false set. */
8683 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8684 if (ServicePtrs[snum_template]->szService &&
8685 strequal(ServicePtrs[snum_template]->szService,
8686 Globals.szUsershareTemplateShare)) {
8687 break;
8691 if (snum_template == -1) {
8692 DEBUG(0,("load_usershare_shares: usershare template share %s "
8693 "does not exist.\n",
8694 Globals.szUsershareTemplateShare ));
8695 return ret;
8699 /* Mark all existing usershares as pending delete. */
8700 for (iService = iNumServices - 1; iService >= 0; iService--) {
8701 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8702 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8706 dp = opendir(usersharepath);
8707 if (!dp) {
8708 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8709 usersharepath, strerror(errno) ));
8710 return ret;
8713 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8714 (de = readdir(dp));
8715 num_dir_entries++ ) {
8716 int r;
8717 const char *n = de->d_name;
8719 /* Ignore . and .. */
8720 if (*n == '.') {
8721 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8722 continue;
8726 if (n[0] == ':') {
8727 /* Temporary file used when creating a share. */
8728 num_tmp_dir_entries++;
8731 /* Allow 20% tmp entries. */
8732 if (num_tmp_dir_entries > allowed_tmp_entries) {
8733 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8734 "in directory %s\n",
8735 num_tmp_dir_entries, usersharepath));
8736 break;
8739 r = process_usershare_file(usersharepath, n, snum_template);
8740 if (r == 0) {
8741 /* Update the services count. */
8742 num_usershares++;
8743 if (num_usershares >= max_user_shares) {
8744 DEBUG(0,("load_usershare_shares: max user shares reached "
8745 "on file %s in directory %s\n",
8746 n, usersharepath ));
8747 break;
8749 } else if (r == -1) {
8750 num_bad_dir_entries++;
8753 /* Allow 20% bad entries. */
8754 if (num_bad_dir_entries > allowed_bad_entries) {
8755 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8756 "in directory %s\n",
8757 num_bad_dir_entries, usersharepath));
8758 break;
8761 /* Allow 20% bad entries. */
8762 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
8763 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8764 "in directory %s\n",
8765 num_dir_entries, usersharepath));
8766 break;
8770 closedir(dp);
8772 /* Sweep through and delete any non-refreshed usershares that are
8773 not currently in use. */
8774 tmp_ctx = talloc_stackframe();
8775 for (iService = iNumServices - 1; iService >= 0; iService--) {
8776 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
8777 char *servname;
8779 if (snumused && snumused(sconn, iService)) {
8780 continue;
8783 servname = lp_servicename(tmp_ctx, iService);
8785 /* Remove from the share ACL db. */
8786 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8787 servname ));
8788 delete_share_security(servname);
8789 free_service_byindex(iService);
8792 talloc_free(tmp_ctx);
8794 return lp_numservices();
8797 /********************************************************
8798 Destroy global resources allocated in this file
8799 ********************************************************/
8801 void gfree_loadparm(void)
8803 int i;
8805 free_file_list();
8807 /* Free resources allocated to services */
8809 for ( i = 0; i < iNumServices; i++ ) {
8810 if ( VALID(i) ) {
8811 free_service_byindex(i);
8815 SAFE_FREE( ServicePtrs );
8816 iNumServices = 0;
8818 /* Now release all resources allocated to global
8819 parameters and the default service */
8821 free_global_parameters();
8825 /***************************************************************************
8826 Allow client apps to specify that they are a client
8827 ***************************************************************************/
8828 static void lp_set_in_client(bool b)
8830 in_client = b;
8834 /***************************************************************************
8835 Determine if we're running in a client app
8836 ***************************************************************************/
8837 static bool lp_is_in_client(void)
8839 return in_client;
8842 /***************************************************************************
8843 Load the services array from the services file. Return true on success,
8844 false on failure.
8845 ***************************************************************************/
8847 static bool lp_load_ex(const char *pszFname,
8848 bool global_only,
8849 bool save_defaults,
8850 bool add_ipc,
8851 bool initialize_globals,
8852 bool allow_include_registry,
8853 bool load_all_shares)
8855 char *n2 = NULL;
8856 bool bRetval;
8858 bRetval = false;
8860 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
8862 bInGlobalSection = true;
8863 bGlobalOnly = global_only;
8864 bAllowIncludeRegistry = allow_include_registry;
8866 init_globals(initialize_globals);
8868 free_file_list();
8870 if (save_defaults) {
8871 init_locals();
8872 lp_save_defaults();
8875 if (!initialize_globals) {
8876 free_param_opts(&Globals.param_opt);
8877 apply_lp_set_cmdline();
8880 lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
8882 /* We get sections first, so have to start 'behind' to make up */
8883 iServiceIndex = -1;
8885 if (lp_config_backend_is_file()) {
8886 n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
8887 current_user_info.domain,
8888 pszFname);
8889 if (!n2) {
8890 smb_panic("lp_load_ex: out of memory");
8893 add_to_file_list(pszFname, n2);
8895 bRetval = pm_process(n2, do_section, do_parameter, NULL);
8896 TALLOC_FREE(n2);
8898 /* finish up the last section */
8899 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
8900 if (bRetval) {
8901 if (iServiceIndex >= 0) {
8902 bRetval = service_ok(iServiceIndex);
8906 if (lp_config_backend_is_registry()) {
8907 /* config backend changed to registry in config file */
8909 * We need to use this extra global variable here to
8910 * survive restart: init_globals uses this as a default
8911 * for ConfigBackend. Otherwise, init_globals would
8912 * send us into an endless loop here.
8914 config_backend = CONFIG_BACKEND_REGISTRY;
8915 /* start over */
8916 DEBUG(1, ("lp_load_ex: changing to config backend "
8917 "registry\n"));
8918 init_globals(true);
8919 lp_kill_all_services();
8920 return lp_load_ex(pszFname, global_only, save_defaults,
8921 add_ipc, initialize_globals,
8922 allow_include_registry,
8923 load_all_shares);
8925 } else if (lp_config_backend_is_registry()) {
8926 bRetval = process_registry_globals();
8927 } else {
8928 DEBUG(0, ("Illegal config backend given: %d\n",
8929 lp_config_backend()));
8930 bRetval = false;
8933 if (bRetval && lp_registry_shares()) {
8934 if (load_all_shares) {
8935 bRetval = process_registry_shares();
8936 } else {
8937 bRetval = reload_registry_shares();
8942 char *serv = lp_auto_services(talloc_tos());
8943 lp_add_auto_services(serv);
8944 TALLOC_FREE(serv);
8947 if (add_ipc) {
8948 /* When 'restrict anonymous = 2' guest connections to ipc$
8949 are denied */
8950 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
8951 if ( lp_enable_asu_support() ) {
8952 lp_add_ipc("ADMIN$", false);
8956 set_allowed_client_auth();
8958 if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) {
8959 DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
8960 lp_passwordserver()));
8963 bLoaded = true;
8965 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
8966 /* if bWINSsupport is true and we are in the client */
8967 if (lp_is_in_client() && Globals.bWINSsupport) {
8968 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
8971 init_iconv();
8973 fault_configure(smb_panic_s3);
8975 bAllowIncludeRegistry = true;
8977 return (bRetval);
8980 bool lp_load(const char *pszFname,
8981 bool global_only,
8982 bool save_defaults,
8983 bool add_ipc,
8984 bool initialize_globals)
8986 return lp_load_ex(pszFname,
8987 global_only,
8988 save_defaults,
8989 add_ipc,
8990 initialize_globals,
8991 true, /* allow_include_registry */
8992 false); /* load_all_shares*/
8995 bool lp_load_initial_only(const char *pszFname)
8997 return lp_load_ex(pszFname,
8998 true, /* global only */
8999 false, /* save_defaults */
9000 false, /* add_ipc */
9001 true, /* initialize_globals */
9002 false, /* allow_include_registry */
9003 false); /* load_all_shares*/
9007 * most common lp_load wrapper, loading only the globals
9009 bool lp_load_global(const char *file_name)
9011 return lp_load_ex(file_name,
9012 true, /* global_only */
9013 false, /* save_defaults */
9014 false, /* add_ipc */
9015 true, /* initialize_globals */
9016 true, /* allow_include_registry */
9017 false); /* load_all_shares*/
9021 * lp_load wrapper, especially for clients
9023 bool lp_load_client(const char *file_name)
9025 lp_set_in_client(true);
9027 return lp_load_global(file_name);
9031 * lp_load wrapper, loading only globals, but intended
9032 * for subsequent calls, not reinitializing the globals
9033 * to default values
9035 bool lp_load_global_no_reinit(const char *file_name)
9037 return lp_load_ex(file_name,
9038 true, /* global_only */
9039 false, /* save_defaults */
9040 false, /* add_ipc */
9041 false, /* initialize_globals */
9042 true, /* allow_include_registry */
9043 false); /* load_all_shares*/
9047 * lp_load wrapper, especially for clients, no reinitialization
9049 bool lp_load_client_no_reinit(const char *file_name)
9051 lp_set_in_client(true);
9053 return lp_load_global_no_reinit(file_name);
9056 bool lp_load_with_registry_shares(const char *pszFname,
9057 bool global_only,
9058 bool save_defaults,
9059 bool add_ipc,
9060 bool initialize_globals)
9062 return lp_load_ex(pszFname,
9063 global_only,
9064 save_defaults,
9065 add_ipc,
9066 initialize_globals,
9067 true, /* allow_include_registry */
9068 true); /* load_all_shares*/
9071 /***************************************************************************
9072 Return the max number of services.
9073 ***************************************************************************/
9075 int lp_numservices(void)
9077 return (iNumServices);
9080 /***************************************************************************
9081 Display the contents of the services array in human-readable form.
9082 ***************************************************************************/
9084 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9086 int iService;
9088 if (show_defaults)
9089 defaults_saved = false;
9091 dump_globals(f);
9093 dump_a_service(&sDefault, f);
9095 for (iService = 0; iService < maxtoprint; iService++) {
9096 fprintf(f,"\n");
9097 lp_dump_one(f, show_defaults, iService);
9101 /***************************************************************************
9102 Display the contents of one service in human-readable form.
9103 ***************************************************************************/
9105 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9107 if (VALID(snum)) {
9108 if (ServicePtrs[snum]->szService[0] == '\0')
9109 return;
9110 dump_a_service(ServicePtrs[snum], f);
9114 /***************************************************************************
9115 Return the number of the service with the given name, or -1 if it doesn't
9116 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9117 getservicebyname()! This works ONLY if all services have been loaded, and
9118 does not copy the found service.
9119 ***************************************************************************/
9121 int lp_servicenumber(const char *pszServiceName)
9123 int iService;
9124 fstring serviceName;
9126 if (!pszServiceName) {
9127 return GLOBAL_SECTION_SNUM;
9130 for (iService = iNumServices - 1; iService >= 0; iService--) {
9131 if (VALID(iService) && ServicePtrs[iService]->szService) {
9133 * The substitution here is used to support %U is
9134 * service names
9136 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9137 standard_sub_basic(get_current_username(),
9138 current_user_info.domain,
9139 serviceName,sizeof(serviceName));
9140 if (strequal(serviceName, pszServiceName)) {
9141 break;
9146 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9147 struct timespec last_mod;
9149 if (!usershare_exists(iService, &last_mod)) {
9150 /* Remove the share security tdb entry for it. */
9151 delete_share_security(lp_servicename(talloc_tos(), iService));
9152 /* Remove it from the array. */
9153 free_service_byindex(iService);
9154 /* Doesn't exist anymore. */
9155 return GLOBAL_SECTION_SNUM;
9158 /* Has it been modified ? If so delete and reload. */
9159 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9160 &last_mod) < 0) {
9161 /* Remove it from the array. */
9162 free_service_byindex(iService);
9163 /* and now reload it. */
9164 iService = load_usershare_service(pszServiceName);
9168 if (iService < 0) {
9169 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9170 return GLOBAL_SECTION_SNUM;
9173 return (iService);
9176 /*******************************************************************
9177 A useful volume label function.
9178 ********************************************************************/
9180 const char *volume_label(TALLOC_CTX *ctx, int snum)
9182 char *ret;
9183 const char *label = lp_volume(ctx, snum);
9184 if (!*label) {
9185 label = lp_servicename(ctx, snum);
9188 /* This returns a 33 byte guarenteed null terminated string. */
9189 ret = talloc_strndup(ctx, label, 32);
9190 if (!ret) {
9191 return "";
9193 return ret;
9196 /*******************************************************************
9197 Get the default server type we will announce as via nmbd.
9198 ********************************************************************/
9200 int lp_default_server_announce(void)
9202 int default_server_announce = 0;
9203 default_server_announce |= SV_TYPE_WORKSTATION;
9204 default_server_announce |= SV_TYPE_SERVER;
9205 default_server_announce |= SV_TYPE_SERVER_UNIX;
9207 /* note that the flag should be set only if we have a
9208 printer service but nmbd doesn't actually load the
9209 services so we can't tell --jerry */
9211 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9213 default_server_announce |= SV_TYPE_SERVER_NT;
9214 default_server_announce |= SV_TYPE_NT;
9216 switch (lp_server_role()) {
9217 case ROLE_DOMAIN_MEMBER:
9218 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9219 break;
9220 case ROLE_DOMAIN_PDC:
9221 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9222 break;
9223 case ROLE_DOMAIN_BDC:
9224 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9225 break;
9226 case ROLE_STANDALONE:
9227 default:
9228 break;
9230 if (lp_time_server())
9231 default_server_announce |= SV_TYPE_TIME_SOURCE;
9233 if (lp_host_msdfs())
9234 default_server_announce |= SV_TYPE_DFS_SERVER;
9236 return default_server_announce;
9239 /***********************************************************
9240 If we are PDC then prefer us as DMB
9241 ************************************************************/
9243 bool lp_domain_master(void)
9245 if (Globals.domain_master == Auto)
9246 return (lp_server_role() == ROLE_DOMAIN_PDC);
9248 return (bool)Globals.domain_master;
9251 /***********************************************************
9252 If we are PDC then prefer us as DMB
9253 ************************************************************/
9255 static bool lp_domain_master_true_or_auto(void)
9257 if (Globals.domain_master) /* auto or yes */
9258 return true;
9260 return false;
9263 /***********************************************************
9264 If we are DMB then prefer us as LMB
9265 ************************************************************/
9267 bool lp_preferred_master(void)
9269 if (Globals.iPreferredMaster == Auto)
9270 return (lp_local_master() && lp_domain_master());
9272 return (bool)Globals.iPreferredMaster;
9275 /*******************************************************************
9276 Remove a service.
9277 ********************************************************************/
9279 void lp_remove_service(int snum)
9281 ServicePtrs[snum]->valid = false;
9282 invalid_services[num_invalid_services++] = snum;
9285 /*******************************************************************
9286 Copy a service.
9287 ********************************************************************/
9289 void lp_copy_service(int snum, const char *new_name)
9291 do_section(new_name, NULL);
9292 if (snum >= 0) {
9293 snum = lp_servicenumber(new_name);
9294 if (snum >= 0) {
9295 char *name = lp_servicename(talloc_tos(), snum);
9296 lp_do_parameter(snum, "copy", name);
9301 const char *lp_printername(TALLOC_CTX *ctx, int snum)
9303 const char *ret = lp__printername(talloc_tos(), snum);
9304 if (ret == NULL || *ret == '\0') {
9305 ret = lp_const_servicename(snum);
9308 return ret;
9312 /***********************************************************
9313 Allow daemons such as winbindd to fix their logfile name.
9314 ************************************************************/
9316 void lp_set_logfile(const char *name)
9318 string_set(&Globals.logfile, name);
9319 debug_set_logfile(name);
9322 /*******************************************************************
9323 Return the max print jobs per queue.
9324 ********************************************************************/
9326 int lp_maxprintjobs(int snum)
9328 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9329 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9330 maxjobs = PRINT_MAX_JOBID - 1;
9332 return maxjobs;
9335 const char *lp_printcapname(void)
9337 if ((Globals.szPrintcapname != NULL) &&
9338 (Globals.szPrintcapname[0] != '\0'))
9339 return Globals.szPrintcapname;
9341 if (sDefault.iPrinting == PRINT_CUPS) {
9342 #ifdef HAVE_CUPS
9343 return "cups";
9344 #else
9345 return "lpstat";
9346 #endif
9349 if (sDefault.iPrinting == PRINT_BSD)
9350 return "/etc/printcap";
9352 return PRINTCAP_NAME;
9355 static uint32 spoolss_state;
9357 bool lp_disable_spoolss( void )
9359 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9360 spoolss_state = lp__disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9362 return spoolss_state == SVCCTL_STOPPED ? true : false;
9365 void lp_set_spoolss_state( uint32 state )
9367 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9369 spoolss_state = state;
9372 uint32 lp_get_spoolss_state( void )
9374 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9377 /*******************************************************************
9378 Ensure we don't use sendfile if server smb signing is active.
9379 ********************************************************************/
9381 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9383 bool sign_active = false;
9385 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9386 if (get_Protocol() < PROTOCOL_NT1) {
9387 return false;
9389 if (signing_state) {
9390 sign_active = smb_signing_is_active(signing_state);
9392 return (lp__use_sendfile(snum) &&
9393 (get_remote_arch() != RA_WIN95) &&
9394 !sign_active);
9397 /*******************************************************************
9398 Turn off sendfile if we find the underlying OS doesn't support it.
9399 ********************************************************************/
9401 void set_use_sendfile(int snum, bool val)
9403 if (LP_SNUM_OK(snum))
9404 ServicePtrs[snum]->bUseSendfile = val;
9405 else
9406 sDefault.bUseSendfile = val;
9409 /*******************************************************************
9410 Turn off storing DOS attributes if this share doesn't support it.
9411 ********************************************************************/
9413 void set_store_dos_attributes(int snum, bool val)
9415 if (!LP_SNUM_OK(snum))
9416 return;
9417 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9420 void lp_set_mangling_method(const char *new_method)
9422 string_set(&Globals.szManglingMethod, new_method);
9425 /*******************************************************************
9426 Global state for POSIX pathname processing.
9427 ********************************************************************/
9429 static bool posix_pathnames;
9431 bool lp_posix_pathnames(void)
9433 return posix_pathnames;
9436 /*******************************************************************
9437 Change everything needed to ensure POSIX pathname processing (currently
9438 not much).
9439 ********************************************************************/
9441 void lp_set_posix_pathnames(void)
9443 posix_pathnames = true;
9446 /*******************************************************************
9447 Global state for POSIX lock processing - CIFS unix extensions.
9448 ********************************************************************/
9450 bool posix_default_lock_was_set;
9451 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9453 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9455 if (posix_default_lock_was_set) {
9456 return posix_cifsx_locktype;
9457 } else {
9458 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9462 /*******************************************************************
9463 ********************************************************************/
9465 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9467 posix_default_lock_was_set = true;
9468 posix_cifsx_locktype = val;
9471 int lp_min_receive_file_size(void)
9473 if (Globals.iminreceivefile < 0) {
9474 return 0;
9476 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9479 /*******************************************************************
9480 If socket address is an empty character string, it is necessary to
9481 define it as "0.0.0.0".
9482 ********************************************************************/
9484 const char *lp_socket_address(void)
9486 char *sock_addr = Globals.szSocketAddress;
9488 if (sock_addr[0] == '\0'){
9489 string_set(&Globals.szSocketAddress, "0.0.0.0");
9491 return Globals.szSocketAddress;
9494 /*******************************************************************
9495 Safe wide links checks.
9496 This helper function always verify the validity of wide links,
9497 even after a configuration file reload.
9498 ********************************************************************/
9500 static bool lp_widelinks_internal(int snum)
9502 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9503 sDefault.bWidelinks);
9506 void widelinks_warning(int snum)
9508 if (lp_allow_insecure_widelinks()) {
9509 return;
9512 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9513 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9514 "These parameters are incompatible. "
9515 "Wide links will be disabled for this share.\n",
9516 lp_servicename(talloc_tos(), snum) ));
9520 bool lp_widelinks(int snum)
9522 /* wide links is always incompatible with unix extensions */
9523 if (lp_unix_extensions()) {
9525 * Unless we have "allow insecure widelinks"
9526 * turned on.
9528 if (!lp_allow_insecure_widelinks()) {
9529 return false;
9533 return lp_widelinks_internal(snum);
9536 bool lp_writeraw(void)
9538 if (lp_async_smb_echo_handler()) {
9539 return false;
9541 return lp__writeraw();
9544 bool lp_readraw(void)
9546 if (lp_async_smb_echo_handler()) {
9547 return false;
9549 return lp__readraw();
9552 int lp_server_role(void)
9554 return lp_find_server_role(lp__server_role(),
9555 lp__security(),
9556 lp__domain_logons(),
9557 lp_domain_master_true_or_auto());
9560 int lp_security(void)
9562 return lp_find_security(lp__server_role(),
9563 lp__security());