libsmbconf: Convert smbconf_get_share() to sbcErr.
[Samba.git] / source3 / param / loadparm.c
blobd13f0baef27bd3d2970c1fe010b3464a31d1fd27
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
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 3 of the License, or
17 (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>.
29 * Load parameters.
31 * This module provides suitable callback functions for the params
32 * module. It builds the internal table of service details which is
33 * then used by the rest of the server.
35 * To add a parameter:
37 * 1) add it to the global or service structure definition
38 * 2) add it to the parm_table
39 * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
40 * 4) If it's a global then initialise it in init_globals. If a local
41 * (ie. service) parameter then initialise it in the sDefault structure
44 * Notes:
45 * The configuration file is processed sequentially for speed. It is NOT
46 * accessed randomly as happens in 'real' Windows. For this reason, there
47 * is a fair bit of sequence-dependent code here - ie., code which assumes
48 * that certain things happen before others. In particular, the code which
49 * happens at the boundary between sections is delicately poised, so be
50 * careful!
54 #include "includes.h"
55 #include "system/filesys.h"
56 #include "printing.h"
57 #include "lib/smbconf/smbconf.h"
58 #include "lib/smbconf/smbconf_init.h"
59 #include "lib/smbconf/smbconf_reg.h"
61 #include "ads.h"
62 #include "../librpc/gen_ndr/svcctl.h"
63 #include "intl.h"
64 #include "smb_signing.h"
65 #include "dbwrap.h"
66 #include "smbldap.h"
68 #ifdef HAVE_SYS_SYSCTL_H
69 #include <sys/sysctl.h>
70 #endif
72 #ifdef HAVE_HTTPCONNECTENCRYPT
73 #include <cups/http.h>
74 #endif
76 bool bLoaded = False;
78 extern userdom_struct current_user_info;
80 #ifndef GLOBAL_NAME
81 #define GLOBAL_NAME "global"
82 #endif
84 #ifndef PRINTERS_NAME
85 #define PRINTERS_NAME "printers"
86 #endif
88 #ifndef HOMES_NAME
89 #define HOMES_NAME "homes"
90 #endif
92 /* the special value for the include parameter
93 * to be interpreted not as a file name but to
94 * trigger loading of the global smb.conf options
95 * from registry. */
96 #ifndef INCLUDE_REGISTRY_NAME
97 #define INCLUDE_REGISTRY_NAME "registry"
98 #endif
100 static bool in_client = False; /* Not in the client by default */
101 static struct smbconf_csn conf_last_csn;
103 #define CONFIG_BACKEND_FILE 0
104 #define CONFIG_BACKEND_REGISTRY 1
106 static int config_backend = CONFIG_BACKEND_FILE;
108 /* some helpful bits */
109 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
110 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
112 #define USERSHARE_VALID 1
113 #define USERSHARE_PENDING_DELETE 2
115 static bool defaults_saved = False;
117 struct param_opt_struct {
118 struct param_opt_struct *prev, *next;
119 char *key;
120 char *value;
121 char **list;
122 unsigned flags;
126 * This structure describes global (ie., server-wide) parameters.
128 struct global {
129 int ConfigBackend;
130 char *smb_ports;
131 char *dos_charset;
132 char *unix_charset;
133 char *display_charset;
134 char *szPrintcapname;
135 char *szAddPortCommand;
136 char *szEnumPortsCommand;
137 char *szAddPrinterCommand;
138 char *szDeletePrinterCommand;
139 char *szOs2DriverMap;
140 char *szLockDir;
141 char *szStateDir;
142 char *szCacheDir;
143 char *szPidDir;
144 char *szRootdir;
145 char *szDefaultService;
146 char *szGetQuota;
147 char *szSetQuota;
148 char *szMsgCommand;
149 char *szServerString;
150 char *szAutoServices;
151 char *szPasswdProgram;
152 char *szPasswdChat;
153 char *szLogFile;
154 char *szConfigFile;
155 char *szSMBPasswdFile;
156 char *szPrivateDir;
157 char *szPassdbBackend;
158 char **szPreloadModules;
159 char *szPasswordServer;
160 char *szSocketOptions;
161 char *szRealm;
162 char *szAfsUsernameMap;
163 int iAfsTokenLifetime;
164 char *szLogNtTokenCommand;
165 char *szUsernameMap;
166 char *szLogonScript;
167 char *szLogonPath;
168 char *szLogonDrive;
169 char *szLogonHome;
170 char **szWINSservers;
171 char **szInterfaces;
172 char *szRemoteAnnounce;
173 char *szRemoteBrowseSync;
174 char *szSocketAddress;
175 bool bNmbdBindExplicitBroadcast;
176 char *szNISHomeMapName;
177 char *szAnnounceVersion; /* This is initialised in init_globals */
178 char *szWorkgroup;
179 char *szNetbiosName;
180 char **szNetbiosAliases;
181 char *szNetbiosScope;
182 char *szNameResolveOrder;
183 char *szPanicAction;
184 char *szAddUserScript;
185 char *szRenameUserScript;
186 char *szDelUserScript;
187 char *szAddGroupScript;
188 char *szDelGroupScript;
189 char *szAddUserToGroupScript;
190 char *szDelUserFromGroupScript;
191 char *szSetPrimaryGroupScript;
192 char *szAddMachineScript;
193 char *szShutdownScript;
194 char *szAbortShutdownScript;
195 char *szUsernameMapScript;
196 int iUsernameMapCacheTime;
197 char *szCheckPasswordScript;
198 char *szWINSHook;
199 char *szUtmpDir;
200 char *szWtmpDir;
201 bool bUtmp;
202 char *szIdmapUID;
203 char *szIdmapGID;
204 bool bPassdbExpandExplicit;
205 int AlgorithmicRidBase;
206 char *szTemplateHomedir;
207 char *szTemplateShell;
208 char *szWinbindSeparator;
209 bool bWinbindEnumUsers;
210 bool bWinbindEnumGroups;
211 bool bWinbindUseDefaultDomain;
212 bool bWinbindTrustedDomainsOnly;
213 bool bWinbindNestedGroups;
214 int winbind_expand_groups;
215 bool bWinbindRefreshTickets;
216 bool bWinbindOfflineLogon;
217 bool bWinbindNormalizeNames;
218 bool bWinbindRpcOnly;
219 bool bCreateKrb5Conf;
220 int winbindMaxDomainConnections;
221 char *szIdmapBackend;
222 bool bIdmapReadOnly;
223 char *szAddShareCommand;
224 char *szChangeShareCommand;
225 char *szDeleteShareCommand;
226 char **szEventLogs;
227 char *szGuestaccount;
228 char *szManglingMethod;
229 char **szServicesList;
230 char *szUsersharePath;
231 char *szUsershareTemplateShare;
232 char **szUsersharePrefixAllowList;
233 char **szUsersharePrefixDenyList;
234 int mangle_prefix;
235 int max_log_size;
236 char *szLogLevel;
237 int max_xmit;
238 int max_mux;
239 int max_open_files;
240 int open_files_db_hash_size;
241 int pwordlevel;
242 int unamelevel;
243 int deadtime;
244 bool getwd_cache;
245 int maxprotocol;
246 int minprotocol;
247 int security;
248 char **AuthMethods;
249 bool paranoid_server_security;
250 int maxdisksize;
251 int lpqcachetime;
252 int iMaxSmbdProcesses;
253 bool bDisableSpoolss;
254 int syslog;
255 int os_level;
256 bool enhanced_browsing;
257 int max_ttl;
258 int max_wins_ttl;
259 int min_wins_ttl;
260 int lm_announce;
261 int lm_interval;
262 int announce_as; /* This is initialised in init_globals */
263 int machine_password_timeout;
264 int map_to_guest;
265 int oplock_break_wait_time;
266 int winbind_cache_time;
267 int winbind_reconnect_delay;
268 int winbind_max_clients;
269 char **szWinbindNssInfo;
270 int iLockSpinTime;
271 char *szLdapMachineSuffix;
272 char *szLdapUserSuffix;
273 char *szLdapIdmapSuffix;
274 char *szLdapGroupSuffix;
275 int ldap_ssl;
276 bool ldap_ssl_ads;
277 int ldap_deref;
278 int ldap_follow_referral;
279 char *szLdapSuffix;
280 char *szLdapAdminDn;
281 int ldap_debug_level;
282 int ldap_debug_threshold;
283 int iAclCompat;
284 char *szCupsServer;
285 int CupsEncrypt;
286 char *szIPrintServer;
287 char *ctdbdSocket;
288 char **szClusterAddresses;
289 bool clustering;
290 int ctdb_timeout;
291 int ctdb_locktime_warn_threshold;
292 int ldap_passwd_sync;
293 int ldap_replication_sleep;
294 int ldap_timeout; /* This is initialised in init_globals */
295 int ldap_connection_timeout;
296 int ldap_page_size;
297 bool ldap_delete_dn;
298 bool bMsAddPrinterWizard;
299 bool bDNSproxy;
300 bool bWINSsupport;
301 bool bWINSproxy;
302 bool bLocalMaster;
303 int iPreferredMaster;
304 int iDomainMaster;
305 bool bDomainLogons;
306 char **szInitLogonDelayedHosts;
307 int InitLogonDelay;
308 bool bEncryptPasswords;
309 bool bUpdateEncrypt;
310 int clientSchannel;
311 int serverSchannel;
312 bool bNullPasswords;
313 bool bObeyPamRestrictions;
314 bool bLoadPrinters;
315 int PrintcapCacheTime;
316 bool bLargeReadwrite;
317 bool bReadRaw;
318 bool bWriteRaw;
319 bool bSyslogOnly;
320 bool bBrowseList;
321 bool bNISHomeMap;
322 bool bTimeServer;
323 bool bBindInterfacesOnly;
324 bool bPamPasswordChange;
325 bool bUnixPasswdSync;
326 bool bPasswdChatDebug;
327 int iPasswdChatTimeout;
328 bool bTimestampLogs;
329 bool bNTSmbSupport;
330 bool bNTPipeSupport;
331 bool bNTStatusSupport;
332 bool bStatCache;
333 int iMaxStatCacheSize;
334 bool bKernelOplocks;
335 bool bAllowTrustedDomains;
336 bool bLanmanAuth;
337 bool bNTLMAuth;
338 bool bUseSpnego;
339 bool bClientLanManAuth;
340 bool bClientNTLMv2Auth;
341 bool bClientPlaintextAuth;
342 bool bClientUseSpnego;
343 bool client_use_spnego_principal;
344 bool send_spnego_principal;
345 bool bDebugPrefixTimestamp;
346 bool bDebugHiresTimestamp;
347 bool bDebugPid;
348 bool bDebugUid;
349 bool bDebugClass;
350 bool bEnableCoreFiles;
351 bool bHostMSDfs;
352 bool bUseMmap;
353 bool bHostnameLookups;
354 bool bUnixExtensions;
355 bool bDisableNetbios;
356 char * szDedicatedKeytabFile;
357 int iKerberosMethod;
358 bool bDeferSharingViolations;
359 bool bEnablePrivileges;
360 bool bASUSupport;
361 bool bUsershareOwnerOnly;
362 bool bUsershareAllowGuests;
363 bool bRegistryShares;
364 int restrict_anonymous;
365 int name_cache_timeout;
366 int client_signing;
367 int server_signing;
368 int client_ldap_sasl_wrapping;
369 int iUsershareMaxShares;
370 int iIdmapCacheTime;
371 int iIdmapNegativeCacheTime;
372 bool bResetOnZeroVC;
373 bool bLogWriteableFilesOnExit;
374 int iKeepalive;
375 int iminreceivefile;
376 struct param_opt_struct *param_opt;
377 int cups_connection_timeout;
378 char *szSMBPerfcountModule;
379 bool bMapUntrustedToDomain;
380 bool bAsyncSMBEchoHandler;
381 bool bMulticastDnsRegister;
382 int ismb2_max_read;
383 int ismb2_max_write;
384 int ismb2_max_trans;
385 int ismb2_max_credits;
386 char *ncalrpc_dir;
389 static struct global Globals;
392 * This structure describes a single service.
394 struct service {
395 bool valid;
396 bool autoloaded;
397 int usershare;
398 struct timespec usershare_last_mod;
399 char *szService;
400 char *szPath;
401 char *szUsername;
402 char **szInvalidUsers;
403 char **szValidUsers;
404 char **szAdminUsers;
405 char *szCopy;
406 char *szInclude;
407 char *szPreExec;
408 char *szPostExec;
409 char *szRootPreExec;
410 char *szRootPostExec;
411 char *szCupsOptions;
412 char *szPrintcommand;
413 char *szLpqcommand;
414 char *szLprmcommand;
415 char *szLppausecommand;
416 char *szLpresumecommand;
417 char *szQueuepausecommand;
418 char *szQueueresumecommand;
419 char *szPrintername;
420 char *szPrintjobUsername;
421 char *szDontdescend;
422 char **szHostsallow;
423 char **szHostsdeny;
424 char *szMagicScript;
425 char *szMagicOutput;
426 char *szVetoFiles;
427 char *szHideFiles;
428 char *szVetoOplockFiles;
429 char *comment;
430 char *force_user;
431 char *force_group;
432 char **readlist;
433 char **writelist;
434 char **printer_admin;
435 char *volume;
436 char *fstype;
437 char **szVfsObjects;
438 char *szMSDfsProxy;
439 char *szAioWriteBehind;
440 char *szDfree;
441 int iMinPrintSpace;
442 int iMaxPrintJobs;
443 int iMaxReportedPrintJobs;
444 int iWriteCacheSize;
445 int iCreate_mask;
446 int iCreate_force_mode;
447 int iSecurity_mask;
448 int iSecurity_force_mode;
449 int iDir_mask;
450 int iDir_force_mode;
451 int iDir_Security_mask;
452 int iDir_Security_force_mode;
453 int iMaxConnections;
454 int iDefaultCase;
455 int iPrinting;
456 int iOplockContentionLimit;
457 int iCSCPolicy;
458 int iBlock_size;
459 int iDfreeCacheTime;
460 bool bPreexecClose;
461 bool bRootpreexecClose;
462 int iCaseSensitive;
463 bool bCasePreserve;
464 bool bShortCasePreserve;
465 bool bHideDotFiles;
466 bool bHideSpecialFiles;
467 bool bHideUnReadable;
468 bool bHideUnWriteableFiles;
469 bool bBrowseable;
470 bool bAccessBasedShareEnum;
471 bool bAvailable;
472 bool bRead_only;
473 bool bNo_set_dir;
474 bool bGuest_only;
475 bool bAdministrative_share;
476 bool bGuest_ok;
477 bool bPrint_ok;
478 bool bPrintNotifyBackchannel;
479 bool bMap_system;
480 bool bMap_hidden;
481 bool bMap_archive;
482 bool bStoreDosAttributes;
483 bool bDmapiSupport;
484 bool bLocking;
485 int iStrictLocking;
486 bool bPosixLocking;
487 bool bShareModes;
488 bool bOpLocks;
489 bool bLevel2OpLocks;
490 bool bOnlyUser;
491 bool bMangledNames;
492 bool bWidelinks;
493 bool bSymlinks;
494 bool bSyncAlways;
495 bool bStrictAllocate;
496 bool bStrictSync;
497 char magic_char;
498 struct bitmap *copymap;
499 bool bDeleteReadonly;
500 bool bFakeOplocks;
501 bool bDeleteVetoFiles;
502 bool bDosFilemode;
503 bool bDosFiletimes;
504 bool bDosFiletimeResolution;
505 bool bFakeDirCreateTimes;
506 bool bBlockingLocks;
507 bool bInheritPerms;
508 bool bInheritACLS;
509 bool bInheritOwner;
510 bool bMSDfsRoot;
511 bool bUseClientDriver;
512 bool bDefaultDevmode;
513 bool bForcePrintername;
514 bool bNTAclSupport;
515 bool bForceUnknownAclUser;
516 bool bUseSendfile;
517 bool bProfileAcls;
518 bool bMap_acl_inherit;
519 bool bAfs_Share;
520 bool bEASupport;
521 bool bAclCheckPermissions;
522 bool bAclMapFullControl;
523 bool bAclGroupControl;
524 bool bChangeNotify;
525 bool bKernelChangeNotify;
526 int iallocation_roundup_size;
527 int iAioReadSize;
528 int iAioWriteSize;
529 int iMap_readonly;
530 int iDirectoryNameCacheSize;
531 int ismb_encrypt;
532 struct param_opt_struct *param_opt;
534 char dummy[3]; /* for alignment */
538 /* This is a default service used to prime a services structure */
539 static struct service sDefault = {
540 True, /* valid */
541 False, /* not autoloaded */
542 0, /* not a usershare */
543 {0, }, /* No last mod time */
544 NULL, /* szService */
545 NULL, /* szPath */
546 NULL, /* szUsername */
547 NULL, /* szInvalidUsers */
548 NULL, /* szValidUsers */
549 NULL, /* szAdminUsers */
550 NULL, /* szCopy */
551 NULL, /* szInclude */
552 NULL, /* szPreExec */
553 NULL, /* szPostExec */
554 NULL, /* szRootPreExec */
555 NULL, /* szRootPostExec */
556 NULL, /* szCupsOptions */
557 NULL, /* szPrintcommand */
558 NULL, /* szLpqcommand */
559 NULL, /* szLprmcommand */
560 NULL, /* szLppausecommand */
561 NULL, /* szLpresumecommand */
562 NULL, /* szQueuepausecommand */
563 NULL, /* szQueueresumecommand */
564 NULL, /* szPrintername */
565 NULL, /* szPrintjobUsername */
566 NULL, /* szDontdescend */
567 NULL, /* szHostsallow */
568 NULL, /* szHostsdeny */
569 NULL, /* szMagicScript */
570 NULL, /* szMagicOutput */
571 NULL, /* szVetoFiles */
572 NULL, /* szHideFiles */
573 NULL, /* szVetoOplockFiles */
574 NULL, /* comment */
575 NULL, /* force user */
576 NULL, /* force group */
577 NULL, /* readlist */
578 NULL, /* writelist */
579 NULL, /* printer admin */
580 NULL, /* volume */
581 NULL, /* fstype */
582 NULL, /* vfs objects */
583 NULL, /* szMSDfsProxy */
584 NULL, /* szAioWriteBehind */
585 NULL, /* szDfree */
586 0, /* iMinPrintSpace */
587 1000, /* iMaxPrintJobs */
588 0, /* iMaxReportedPrintJobs */
589 0, /* iWriteCacheSize */
590 0744, /* iCreate_mask */
591 0000, /* iCreate_force_mode */
592 0777, /* iSecurity_mask */
593 0, /* iSecurity_force_mode */
594 0755, /* iDir_mask */
595 0000, /* iDir_force_mode */
596 0777, /* iDir_Security_mask */
597 0, /* iDir_Security_force_mode */
598 0, /* iMaxConnections */
599 CASE_LOWER, /* iDefaultCase */
600 DEFAULT_PRINTING, /* iPrinting */
601 2, /* iOplockContentionLimit */
602 0, /* iCSCPolicy */
603 1024, /* iBlock_size */
604 0, /* iDfreeCacheTime */
605 False, /* bPreexecClose */
606 False, /* bRootpreexecClose */
607 Auto, /* case sensitive */
608 True, /* case preserve */
609 True, /* short case preserve */
610 True, /* bHideDotFiles */
611 False, /* bHideSpecialFiles */
612 False, /* bHideUnReadable */
613 False, /* bHideUnWriteableFiles */
614 True, /* bBrowseable */
615 False, /* bAccessBasedShareEnum */
616 True, /* bAvailable */
617 True, /* bRead_only */
618 True, /* bNo_set_dir */
619 False, /* bGuest_only */
620 False, /* bAdministrative_share */
621 False, /* bGuest_ok */
622 False, /* bPrint_ok */
623 True, /* bPrintNotifyBackchannel */
624 False, /* bMap_system */
625 False, /* bMap_hidden */
626 True, /* bMap_archive */
627 False, /* bStoreDosAttributes */
628 False, /* bDmapiSupport */
629 True, /* bLocking */
630 Auto, /* iStrictLocking */
631 True, /* bPosixLocking */
632 True, /* bShareModes */
633 True, /* bOpLocks */
634 True, /* bLevel2OpLocks */
635 False, /* bOnlyUser */
636 True, /* bMangledNames */
637 false, /* bWidelinks */
638 True, /* bSymlinks */
639 False, /* bSyncAlways */
640 False, /* bStrictAllocate */
641 False, /* bStrictSync */
642 '~', /* magic char */
643 NULL, /* copymap */
644 False, /* bDeleteReadonly */
645 False, /* bFakeOplocks */
646 False, /* bDeleteVetoFiles */
647 False, /* bDosFilemode */
648 True, /* bDosFiletimes */
649 False, /* bDosFiletimeResolution */
650 False, /* bFakeDirCreateTimes */
651 True, /* bBlockingLocks */
652 False, /* bInheritPerms */
653 False, /* bInheritACLS */
654 False, /* bInheritOwner */
655 False, /* bMSDfsRoot */
656 False, /* bUseClientDriver */
657 True, /* bDefaultDevmode */
658 False, /* bForcePrintername */
659 True, /* bNTAclSupport */
660 False, /* bForceUnknownAclUser */
661 False, /* bUseSendfile */
662 False, /* bProfileAcls */
663 False, /* bMap_acl_inherit */
664 False, /* bAfs_Share */
665 False, /* bEASupport */
666 True, /* bAclCheckPermissions */
667 True, /* bAclMapFullControl */
668 False, /* bAclGroupControl */
669 True, /* bChangeNotify */
670 True, /* bKernelChangeNotify */
671 SMB_ROUNDUP_ALLOCATION_SIZE, /* iallocation_roundup_size */
672 0, /* iAioReadSize */
673 0, /* iAioWriteSize */
674 MAP_READONLY_YES, /* iMap_readonly */
675 #ifdef BROKEN_DIRECTORY_HANDLING
676 0, /* iDirectoryNameCacheSize */
677 #else
678 100, /* iDirectoryNameCacheSize */
679 #endif
680 Auto, /* ismb_encrypt */
681 NULL, /* Parametric options */
683 "" /* dummy */
686 /* local variables */
687 static struct service **ServicePtrs = NULL;
688 static int iNumServices = 0;
689 static int iServiceIndex = 0;
690 static struct db_context *ServiceHash;
691 static int *invalid_services = NULL;
692 static int num_invalid_services = 0;
693 static bool bInGlobalSection = True;
694 static bool bGlobalOnly = False;
695 static int default_server_announce;
697 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
699 /* prototypes for the special type handlers */
700 static bool handle_include( int snum, const char *pszParmValue, char **ptr);
701 static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
702 static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
703 static bool handle_idmap_backend(int snum, const char *pszParmValue, char **ptr);
704 static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
705 static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
706 static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
707 static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
708 static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
709 static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
710 static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
711 static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
712 static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
714 static void set_default_server_announce_type(void);
715 static void set_allowed_client_auth(void);
717 static void *lp_local_ptr(struct service *service, void *ptr);
719 static void add_to_file_list(const char *fname, const char *subfname);
720 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
722 static const struct enum_list enum_protocol[] = {
723 {PROTOCOL_SMB2, "SMB2"},
724 {PROTOCOL_NT1, "NT1"},
725 {PROTOCOL_LANMAN2, "LANMAN2"},
726 {PROTOCOL_LANMAN1, "LANMAN1"},
727 {PROTOCOL_CORE, "CORE"},
728 {PROTOCOL_COREPLUS, "COREPLUS"},
729 {PROTOCOL_COREPLUS, "CORE+"},
730 {-1, NULL}
733 static const struct enum_list enum_security[] = {
734 {SEC_SHARE, "SHARE"},
735 {SEC_USER, "USER"},
736 {SEC_SERVER, "SERVER"},
737 {SEC_DOMAIN, "DOMAIN"},
738 #ifdef HAVE_ADS
739 {SEC_ADS, "ADS"},
740 #endif
741 {-1, NULL}
744 static const struct enum_list enum_printing[] = {
745 {PRINT_SYSV, "sysv"},
746 {PRINT_AIX, "aix"},
747 {PRINT_HPUX, "hpux"},
748 {PRINT_BSD, "bsd"},
749 {PRINT_QNX, "qnx"},
750 {PRINT_PLP, "plp"},
751 {PRINT_LPRNG, "lprng"},
752 {PRINT_CUPS, "cups"},
753 {PRINT_IPRINT, "iprint"},
754 {PRINT_LPRNT, "nt"},
755 {PRINT_LPROS2, "os2"},
756 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
757 {PRINT_TEST, "test"},
758 {PRINT_VLP, "vlp"},
759 #endif /* DEVELOPER */
760 {-1, NULL}
763 static const struct enum_list enum_ldap_sasl_wrapping[] = {
764 {0, "plain"},
765 {ADS_AUTH_SASL_SIGN, "sign"},
766 {ADS_AUTH_SASL_SEAL, "seal"},
767 {-1, NULL}
770 static const struct enum_list enum_ldap_ssl[] = {
771 {LDAP_SSL_OFF, "no"},
772 {LDAP_SSL_OFF, "off"},
773 {LDAP_SSL_START_TLS, "start tls"},
774 {LDAP_SSL_START_TLS, "start_tls"},
775 {-1, NULL}
778 /* LDAP Dereferencing Alias types */
779 #define SAMBA_LDAP_DEREF_NEVER 0
780 #define SAMBA_LDAP_DEREF_SEARCHING 1
781 #define SAMBA_LDAP_DEREF_FINDING 2
782 #define SAMBA_LDAP_DEREF_ALWAYS 3
784 static const struct enum_list enum_ldap_deref[] = {
785 {SAMBA_LDAP_DEREF_NEVER, "never"},
786 {SAMBA_LDAP_DEREF_SEARCHING, "searching"},
787 {SAMBA_LDAP_DEREF_FINDING, "finding"},
788 {SAMBA_LDAP_DEREF_ALWAYS, "always"},
789 {-1, "auto"}
792 static const struct enum_list enum_ldap_passwd_sync[] = {
793 {LDAP_PASSWD_SYNC_OFF, "no"},
794 {LDAP_PASSWD_SYNC_OFF, "off"},
795 {LDAP_PASSWD_SYNC_ON, "yes"},
796 {LDAP_PASSWD_SYNC_ON, "on"},
797 {LDAP_PASSWD_SYNC_ONLY, "only"},
798 {-1, NULL}
801 /* Types of machine we can announce as. */
802 #define ANNOUNCE_AS_NT_SERVER 1
803 #define ANNOUNCE_AS_WIN95 2
804 #define ANNOUNCE_AS_WFW 3
805 #define ANNOUNCE_AS_NT_WORKSTATION 4
807 static const struct enum_list enum_announce_as[] = {
808 {ANNOUNCE_AS_NT_SERVER, "NT"},
809 {ANNOUNCE_AS_NT_SERVER, "NT Server"},
810 {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
811 {ANNOUNCE_AS_WIN95, "win95"},
812 {ANNOUNCE_AS_WFW, "WfW"},
813 {-1, NULL}
816 static const struct enum_list enum_map_readonly[] = {
817 {MAP_READONLY_NO, "no"},
818 {MAP_READONLY_NO, "false"},
819 {MAP_READONLY_NO, "0"},
820 {MAP_READONLY_YES, "yes"},
821 {MAP_READONLY_YES, "true"},
822 {MAP_READONLY_YES, "1"},
823 {MAP_READONLY_PERMISSIONS, "permissions"},
824 {MAP_READONLY_PERMISSIONS, "perms"},
825 {-1, NULL}
828 static const struct enum_list enum_case[] = {
829 {CASE_LOWER, "lower"},
830 {CASE_UPPER, "upper"},
831 {-1, NULL}
836 static const struct enum_list enum_bool_auto[] = {
837 {False, "No"},
838 {False, "False"},
839 {False, "0"},
840 {True, "Yes"},
841 {True, "True"},
842 {True, "1"},
843 {Auto, "Auto"},
844 {-1, NULL}
847 static const struct enum_list enum_csc_policy[] = {
848 {CSC_POLICY_MANUAL, "manual"},
849 {CSC_POLICY_DOCUMENTS, "documents"},
850 {CSC_POLICY_PROGRAMS, "programs"},
851 {CSC_POLICY_DISABLE, "disable"},
852 {-1, NULL}
855 /* SMB signing types. */
856 static const struct enum_list enum_smb_signing_vals[] = {
857 {False, "No"},
858 {False, "False"},
859 {False, "0"},
860 {False, "Off"},
861 {False, "disabled"},
862 {True, "Yes"},
863 {True, "True"},
864 {True, "1"},
865 {True, "On"},
866 {True, "enabled"},
867 {Auto, "auto"},
868 {Required, "required"},
869 {Required, "mandatory"},
870 {Required, "force"},
871 {Required, "forced"},
872 {Required, "enforced"},
873 {-1, NULL}
876 /* ACL compatibility options. */
877 static const struct enum_list enum_acl_compat_vals[] = {
878 { ACL_COMPAT_AUTO, "auto" },
879 { ACL_COMPAT_WINNT, "winnt" },
880 { ACL_COMPAT_WIN2K, "win2k" },
881 { -1, NULL}
885 Do you want session setups at user level security with a invalid
886 password to be rejected or allowed in as guest? WinNT rejects them
887 but it can be a pain as it means "net view" needs to use a password
889 You have 3 choices in the setting of map_to_guest:
891 "Never" means session setups with an invalid password
892 are rejected. This is the default.
894 "Bad User" means session setups with an invalid password
895 are rejected, unless the username does not exist, in which case it
896 is treated as a guest login
898 "Bad Password" means session setups with an invalid password
899 are treated as a guest login
901 Note that map_to_guest only has an effect in user or server
902 level security.
905 static const struct enum_list enum_map_to_guest[] = {
906 {NEVER_MAP_TO_GUEST, "Never"},
907 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
908 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
909 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
910 {-1, NULL}
913 /* Config backend options */
915 static const struct enum_list enum_config_backend[] = {
916 {CONFIG_BACKEND_FILE, "file"},
917 {CONFIG_BACKEND_REGISTRY, "registry"},
918 {-1, NULL}
921 /* ADS kerberos ticket verification options */
923 static const struct enum_list enum_kerberos_method[] = {
924 {KERBEROS_VERIFY_SECRETS, "default"},
925 {KERBEROS_VERIFY_SECRETS, "secrets only"},
926 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
927 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
928 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
929 {-1, NULL}
932 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
934 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
935 * screen in SWAT. This is used to exclude parameters as well as to squash all
936 * parameters that have been duplicated by pseudonyms.
938 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
939 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
940 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
941 * respective views.
943 * NOTE2: Handling of duplicated (synonym) parameters:
944 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
945 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
946 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
947 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
950 static struct parm_struct parm_table[] = {
951 {N_("Base Options"), P_SEP, P_SEPARATOR},
954 .label = "dos charset",
955 .type = P_STRING,
956 .p_class = P_GLOBAL,
957 .ptr = &Globals.dos_charset,
958 .special = handle_charset,
959 .enum_list = NULL,
960 .flags = FLAG_ADVANCED
963 .label = "unix charset",
964 .type = P_STRING,
965 .p_class = P_GLOBAL,
966 .ptr = &Globals.unix_charset,
967 .special = handle_charset,
968 .enum_list = NULL,
969 .flags = FLAG_ADVANCED
972 .label = "display charset",
973 .type = P_STRING,
974 .p_class = P_GLOBAL,
975 .ptr = &Globals.display_charset,
976 .special = handle_charset,
977 .enum_list = NULL,
978 .flags = FLAG_ADVANCED
981 .label = "comment",
982 .type = P_STRING,
983 .p_class = P_LOCAL,
984 .ptr = &sDefault.comment,
985 .special = NULL,
986 .enum_list = NULL,
987 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
990 .label = "path",
991 .type = P_STRING,
992 .p_class = P_LOCAL,
993 .ptr = &sDefault.szPath,
994 .special = NULL,
995 .enum_list = NULL,
996 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
999 .label = "directory",
1000 .type = P_STRING,
1001 .p_class = P_LOCAL,
1002 .ptr = &sDefault.szPath,
1003 .special = NULL,
1004 .enum_list = NULL,
1005 .flags = FLAG_HIDE,
1008 .label = "workgroup",
1009 .type = P_USTRING,
1010 .p_class = P_GLOBAL,
1011 .ptr = &Globals.szWorkgroup,
1012 .special = handle_workgroup,
1013 .enum_list = NULL,
1014 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1016 #ifdef WITH_ADS
1018 .label = "realm",
1019 .type = P_USTRING,
1020 .p_class = P_GLOBAL,
1021 .ptr = &Globals.szRealm,
1022 .special = NULL,
1023 .enum_list = NULL,
1024 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1026 #endif
1028 .label = "netbios name",
1029 .type = P_USTRING,
1030 .p_class = P_GLOBAL,
1031 .ptr = &Globals.szNetbiosName,
1032 .special = handle_netbios_name,
1033 .enum_list = NULL,
1034 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1037 .label = "netbios aliases",
1038 .type = P_LIST,
1039 .p_class = P_GLOBAL,
1040 .ptr = &Globals.szNetbiosAliases,
1041 .special = handle_netbios_aliases,
1042 .enum_list = NULL,
1043 .flags = FLAG_ADVANCED,
1046 .label = "netbios scope",
1047 .type = P_USTRING,
1048 .p_class = P_GLOBAL,
1049 .ptr = &Globals.szNetbiosScope,
1050 .special = handle_netbios_scope,
1051 .enum_list = NULL,
1052 .flags = FLAG_ADVANCED,
1055 .label = "server string",
1056 .type = P_STRING,
1057 .p_class = P_GLOBAL,
1058 .ptr = &Globals.szServerString,
1059 .special = NULL,
1060 .enum_list = NULL,
1061 .flags = FLAG_BASIC | FLAG_ADVANCED,
1064 .label = "interfaces",
1065 .type = P_LIST,
1066 .p_class = P_GLOBAL,
1067 .ptr = &Globals.szInterfaces,
1068 .special = NULL,
1069 .enum_list = NULL,
1070 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1073 .label = "bind interfaces only",
1074 .type = P_BOOL,
1075 .p_class = P_GLOBAL,
1076 .ptr = &Globals.bBindInterfacesOnly,
1077 .special = NULL,
1078 .enum_list = NULL,
1079 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1082 .label = "config backend",
1083 .type = P_ENUM,
1084 .p_class = P_GLOBAL,
1085 .ptr = &Globals.ConfigBackend,
1086 .special = NULL,
1087 .enum_list = enum_config_backend,
1088 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
1091 {N_("Security Options"), P_SEP, P_SEPARATOR},
1094 .label = "security",
1095 .type = P_ENUM,
1096 .p_class = P_GLOBAL,
1097 .ptr = &Globals.security,
1098 .special = NULL,
1099 .enum_list = enum_security,
1100 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1103 .label = "auth methods",
1104 .type = P_LIST,
1105 .p_class = P_GLOBAL,
1106 .ptr = &Globals.AuthMethods,
1107 .special = NULL,
1108 .enum_list = NULL,
1109 .flags = FLAG_ADVANCED,
1112 .label = "encrypt passwords",
1113 .type = P_BOOL,
1114 .p_class = P_GLOBAL,
1115 .ptr = &Globals.bEncryptPasswords,
1116 .special = NULL,
1117 .enum_list = NULL,
1118 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1121 .label = "client schannel",
1122 .type = P_ENUM,
1123 .p_class = P_GLOBAL,
1124 .ptr = &Globals.clientSchannel,
1125 .special = NULL,
1126 .enum_list = enum_bool_auto,
1127 .flags = FLAG_BASIC | FLAG_ADVANCED,
1130 .label = "server schannel",
1131 .type = P_ENUM,
1132 .p_class = P_GLOBAL,
1133 .ptr = &Globals.serverSchannel,
1134 .special = NULL,
1135 .enum_list = enum_bool_auto,
1136 .flags = FLAG_BASIC | FLAG_ADVANCED,
1139 .label = "allow trusted domains",
1140 .type = P_BOOL,
1141 .p_class = P_GLOBAL,
1142 .ptr = &Globals.bAllowTrustedDomains,
1143 .special = NULL,
1144 .enum_list = NULL,
1145 .flags = FLAG_ADVANCED,
1148 .label = "map to guest",
1149 .type = P_ENUM,
1150 .p_class = P_GLOBAL,
1151 .ptr = &Globals.map_to_guest,
1152 .special = NULL,
1153 .enum_list = enum_map_to_guest,
1154 .flags = FLAG_ADVANCED,
1157 .label = "null passwords",
1158 .type = P_BOOL,
1159 .p_class = P_GLOBAL,
1160 .ptr = &Globals.bNullPasswords,
1161 .special = NULL,
1162 .enum_list = NULL,
1163 .flags = FLAG_ADVANCED,
1166 .label = "obey pam restrictions",
1167 .type = P_BOOL,
1168 .p_class = P_GLOBAL,
1169 .ptr = &Globals.bObeyPamRestrictions,
1170 .special = NULL,
1171 .enum_list = NULL,
1172 .flags = FLAG_ADVANCED,
1175 .label = "password server",
1176 .type = P_STRING,
1177 .p_class = P_GLOBAL,
1178 .ptr = &Globals.szPasswordServer,
1179 .special = NULL,
1180 .enum_list = NULL,
1181 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1184 .label = "smb passwd file",
1185 .type = P_STRING,
1186 .p_class = P_GLOBAL,
1187 .ptr = &Globals.szSMBPasswdFile,
1188 .special = NULL,
1189 .enum_list = NULL,
1190 .flags = FLAG_ADVANCED,
1193 .label = "private dir",
1194 .type = P_STRING,
1195 .p_class = P_GLOBAL,
1196 .ptr = &Globals.szPrivateDir,
1197 .special = NULL,
1198 .enum_list = NULL,
1199 .flags = FLAG_ADVANCED,
1202 .label = "passdb backend",
1203 .type = P_STRING,
1204 .p_class = P_GLOBAL,
1205 .ptr = &Globals.szPassdbBackend,
1206 .special = NULL,
1207 .enum_list = NULL,
1208 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1211 .label = "algorithmic rid base",
1212 .type = P_INTEGER,
1213 .p_class = P_GLOBAL,
1214 .ptr = &Globals.AlgorithmicRidBase,
1215 .special = NULL,
1216 .enum_list = NULL,
1217 .flags = FLAG_ADVANCED,
1220 .label = "root directory",
1221 .type = P_STRING,
1222 .p_class = P_GLOBAL,
1223 .ptr = &Globals.szRootdir,
1224 .special = NULL,
1225 .enum_list = NULL,
1226 .flags = FLAG_ADVANCED,
1229 .label = "root dir",
1230 .type = P_STRING,
1231 .p_class = P_GLOBAL,
1232 .ptr = &Globals.szRootdir,
1233 .special = NULL,
1234 .enum_list = NULL,
1235 .flags = FLAG_HIDE,
1238 .label = "root",
1239 .type = P_STRING,
1240 .p_class = P_GLOBAL,
1241 .ptr = &Globals.szRootdir,
1242 .special = NULL,
1243 .enum_list = NULL,
1244 .flags = FLAG_HIDE,
1247 .label = "guest account",
1248 .type = P_STRING,
1249 .p_class = P_GLOBAL,
1250 .ptr = &Globals.szGuestaccount,
1251 .special = NULL,
1252 .enum_list = NULL,
1253 .flags = FLAG_BASIC | FLAG_ADVANCED,
1256 .label = "enable privileges",
1257 .type = P_BOOL,
1258 .p_class = P_GLOBAL,
1259 .ptr = &Globals.bEnablePrivileges,
1260 .special = NULL,
1261 .enum_list = NULL,
1262 .flags = FLAG_ADVANCED,
1266 .label = "pam password change",
1267 .type = P_BOOL,
1268 .p_class = P_GLOBAL,
1269 .ptr = &Globals.bPamPasswordChange,
1270 .special = NULL,
1271 .enum_list = NULL,
1272 .flags = FLAG_ADVANCED,
1275 .label = "passwd program",
1276 .type = P_STRING,
1277 .p_class = P_GLOBAL,
1278 .ptr = &Globals.szPasswdProgram,
1279 .special = NULL,
1280 .enum_list = NULL,
1281 .flags = FLAG_ADVANCED,
1284 .label = "passwd chat",
1285 .type = P_STRING,
1286 .p_class = P_GLOBAL,
1287 .ptr = &Globals.szPasswdChat,
1288 .special = NULL,
1289 .enum_list = NULL,
1290 .flags = FLAG_ADVANCED,
1293 .label = "passwd chat debug",
1294 .type = P_BOOL,
1295 .p_class = P_GLOBAL,
1296 .ptr = &Globals.bPasswdChatDebug,
1297 .special = NULL,
1298 .enum_list = NULL,
1299 .flags = FLAG_ADVANCED,
1302 .label = "passwd chat timeout",
1303 .type = P_INTEGER,
1304 .p_class = P_GLOBAL,
1305 .ptr = &Globals.iPasswdChatTimeout,
1306 .special = NULL,
1307 .enum_list = NULL,
1308 .flags = FLAG_ADVANCED,
1311 .label = "check password script",
1312 .type = P_STRING,
1313 .p_class = P_GLOBAL,
1314 .ptr = &Globals.szCheckPasswordScript,
1315 .special = NULL,
1316 .enum_list = NULL,
1317 .flags = FLAG_ADVANCED,
1320 .label = "username map",
1321 .type = P_STRING,
1322 .p_class = P_GLOBAL,
1323 .ptr = &Globals.szUsernameMap,
1324 .special = NULL,
1325 .enum_list = NULL,
1326 .flags = FLAG_ADVANCED,
1329 .label = "password level",
1330 .type = P_INTEGER,
1331 .p_class = P_GLOBAL,
1332 .ptr = &Globals.pwordlevel,
1333 .special = NULL,
1334 .enum_list = NULL,
1335 .flags = FLAG_ADVANCED,
1338 .label = "username level",
1339 .type = P_INTEGER,
1340 .p_class = P_GLOBAL,
1341 .ptr = &Globals.unamelevel,
1342 .special = NULL,
1343 .enum_list = NULL,
1344 .flags = FLAG_ADVANCED,
1347 .label = "unix password sync",
1348 .type = P_BOOL,
1349 .p_class = P_GLOBAL,
1350 .ptr = &Globals.bUnixPasswdSync,
1351 .special = NULL,
1352 .enum_list = NULL,
1353 .flags = FLAG_ADVANCED,
1356 .label = "restrict anonymous",
1357 .type = P_INTEGER,
1358 .p_class = P_GLOBAL,
1359 .ptr = &Globals.restrict_anonymous,
1360 .special = NULL,
1361 .enum_list = NULL,
1362 .flags = FLAG_ADVANCED,
1365 .label = "lanman auth",
1366 .type = P_BOOL,
1367 .p_class = P_GLOBAL,
1368 .ptr = &Globals.bLanmanAuth,
1369 .special = NULL,
1370 .enum_list = NULL,
1371 .flags = FLAG_ADVANCED,
1374 .label = "ntlm auth",
1375 .type = P_BOOL,
1376 .p_class = P_GLOBAL,
1377 .ptr = &Globals.bNTLMAuth,
1378 .special = NULL,
1379 .enum_list = NULL,
1380 .flags = FLAG_ADVANCED,
1383 .label = "client NTLMv2 auth",
1384 .type = P_BOOL,
1385 .p_class = P_GLOBAL,
1386 .ptr = &Globals.bClientNTLMv2Auth,
1387 .special = NULL,
1388 .enum_list = NULL,
1389 .flags = FLAG_ADVANCED,
1392 .label = "client lanman auth",
1393 .type = P_BOOL,
1394 .p_class = P_GLOBAL,
1395 .ptr = &Globals.bClientLanManAuth,
1396 .special = NULL,
1397 .enum_list = NULL,
1398 .flags = FLAG_ADVANCED,
1401 .label = "client plaintext auth",
1402 .type = P_BOOL,
1403 .p_class = P_GLOBAL,
1404 .ptr = &Globals.bClientPlaintextAuth,
1405 .special = NULL,
1406 .enum_list = NULL,
1407 .flags = FLAG_ADVANCED,
1410 .label = "client use spnego principal",
1411 .type = P_BOOL,
1412 .p_class = P_GLOBAL,
1413 .ptr = &Globals.client_use_spnego_principal,
1414 .special = NULL,
1415 .enum_list = NULL,
1416 .flags = FLAG_ADVANCED,
1419 .label = "send spnego principal",
1420 .type = P_BOOL,
1421 .p_class = P_GLOBAL,
1422 .ptr = &Globals.send_spnego_principal,
1423 .special = NULL,
1424 .enum_list = NULL,
1425 .flags = FLAG_ADVANCED,
1428 .label = "username",
1429 .type = P_STRING,
1430 .p_class = P_LOCAL,
1431 .ptr = &sDefault.szUsername,
1432 .special = NULL,
1433 .enum_list = NULL,
1434 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1437 .label = "user",
1438 .type = P_STRING,
1439 .p_class = P_LOCAL,
1440 .ptr = &sDefault.szUsername,
1441 .special = NULL,
1442 .enum_list = NULL,
1443 .flags = FLAG_HIDE,
1446 .label = "users",
1447 .type = P_STRING,
1448 .p_class = P_LOCAL,
1449 .ptr = &sDefault.szUsername,
1450 .special = NULL,
1451 .enum_list = NULL,
1452 .flags = FLAG_HIDE,
1455 .label = "invalid users",
1456 .type = P_LIST,
1457 .p_class = P_LOCAL,
1458 .ptr = &sDefault.szInvalidUsers,
1459 .special = NULL,
1460 .enum_list = NULL,
1461 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1464 .label = "valid users",
1465 .type = P_LIST,
1466 .p_class = P_LOCAL,
1467 .ptr = &sDefault.szValidUsers,
1468 .special = NULL,
1469 .enum_list = NULL,
1470 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1473 .label = "admin users",
1474 .type = P_LIST,
1475 .p_class = P_LOCAL,
1476 .ptr = &sDefault.szAdminUsers,
1477 .special = NULL,
1478 .enum_list = NULL,
1479 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1482 .label = "read list",
1483 .type = P_LIST,
1484 .p_class = P_LOCAL,
1485 .ptr = &sDefault.readlist,
1486 .special = NULL,
1487 .enum_list = NULL,
1488 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1491 .label = "write list",
1492 .type = P_LIST,
1493 .p_class = P_LOCAL,
1494 .ptr = &sDefault.writelist,
1495 .special = NULL,
1496 .enum_list = NULL,
1497 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1500 .label = "printer admin",
1501 .type = P_LIST,
1502 .p_class = P_LOCAL,
1503 .ptr = &sDefault.printer_admin,
1504 .special = NULL,
1505 .enum_list = NULL,
1506 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1509 .label = "force user",
1510 .type = P_STRING,
1511 .p_class = P_LOCAL,
1512 .ptr = &sDefault.force_user,
1513 .special = NULL,
1514 .enum_list = NULL,
1515 .flags = FLAG_ADVANCED | FLAG_SHARE,
1518 .label = "force group",
1519 .type = P_STRING,
1520 .p_class = P_LOCAL,
1521 .ptr = &sDefault.force_group,
1522 .special = NULL,
1523 .enum_list = NULL,
1524 .flags = FLAG_ADVANCED | FLAG_SHARE,
1527 .label = "group",
1528 .type = P_STRING,
1529 .p_class = P_LOCAL,
1530 .ptr = &sDefault.force_group,
1531 .special = NULL,
1532 .enum_list = NULL,
1533 .flags = FLAG_ADVANCED,
1536 .label = "read only",
1537 .type = P_BOOL,
1538 .p_class = P_LOCAL,
1539 .ptr = &sDefault.bRead_only,
1540 .special = NULL,
1541 .enum_list = NULL,
1542 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1545 .label = "write ok",
1546 .type = P_BOOLREV,
1547 .p_class = P_LOCAL,
1548 .ptr = &sDefault.bRead_only,
1549 .special = NULL,
1550 .enum_list = NULL,
1551 .flags = FLAG_HIDE,
1554 .label = "writeable",
1555 .type = P_BOOLREV,
1556 .p_class = P_LOCAL,
1557 .ptr = &sDefault.bRead_only,
1558 .special = NULL,
1559 .enum_list = NULL,
1560 .flags = FLAG_HIDE,
1563 .label = "writable",
1564 .type = P_BOOLREV,
1565 .p_class = P_LOCAL,
1566 .ptr = &sDefault.bRead_only,
1567 .special = NULL,
1568 .enum_list = NULL,
1569 .flags = FLAG_HIDE,
1572 .label = "acl check permissions",
1573 .type = P_BOOL,
1574 .p_class = P_LOCAL,
1575 .ptr = &sDefault.bAclCheckPermissions,
1576 .special = NULL,
1577 .enum_list = NULL,
1578 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1581 .label = "acl group control",
1582 .type = P_BOOL,
1583 .p_class = P_LOCAL,
1584 .ptr = &sDefault.bAclGroupControl,
1585 .special = NULL,
1586 .enum_list = NULL,
1587 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1590 .label = "acl map full control",
1591 .type = P_BOOL,
1592 .p_class = P_LOCAL,
1593 .ptr = &sDefault.bAclMapFullControl,
1594 .special = NULL,
1595 .enum_list = NULL,
1596 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1599 .label = "create mask",
1600 .type = P_OCTAL,
1601 .p_class = P_LOCAL,
1602 .ptr = &sDefault.iCreate_mask,
1603 .special = NULL,
1604 .enum_list = NULL,
1605 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1608 .label = "create mode",
1609 .type = P_OCTAL,
1610 .p_class = P_LOCAL,
1611 .ptr = &sDefault.iCreate_mask,
1612 .special = NULL,
1613 .enum_list = NULL,
1614 .flags = FLAG_HIDE,
1617 .label = "force create mode",
1618 .type = P_OCTAL,
1619 .p_class = P_LOCAL,
1620 .ptr = &sDefault.iCreate_force_mode,
1621 .special = NULL,
1622 .enum_list = NULL,
1623 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1626 .label = "security mask",
1627 .type = P_OCTAL,
1628 .p_class = P_LOCAL,
1629 .ptr = &sDefault.iSecurity_mask,
1630 .special = NULL,
1631 .enum_list = NULL,
1632 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1635 .label = "force security mode",
1636 .type = P_OCTAL,
1637 .p_class = P_LOCAL,
1638 .ptr = &sDefault.iSecurity_force_mode,
1639 .special = NULL,
1640 .enum_list = NULL,
1641 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1644 .label = "directory mask",
1645 .type = P_OCTAL,
1646 .p_class = P_LOCAL,
1647 .ptr = &sDefault.iDir_mask,
1648 .special = NULL,
1649 .enum_list = NULL,
1650 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1653 .label = "directory mode",
1654 .type = P_OCTAL,
1655 .p_class = P_LOCAL,
1656 .ptr = &sDefault.iDir_mask,
1657 .special = NULL,
1658 .enum_list = NULL,
1659 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1662 .label = "force directory mode",
1663 .type = P_OCTAL,
1664 .p_class = P_LOCAL,
1665 .ptr = &sDefault.iDir_force_mode,
1666 .special = NULL,
1667 .enum_list = NULL,
1668 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1671 .label = "directory security mask",
1672 .type = P_OCTAL,
1673 .p_class = P_LOCAL,
1674 .ptr = &sDefault.iDir_Security_mask,
1675 .special = NULL,
1676 .enum_list = NULL,
1677 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1680 .label = "force directory security mode",
1681 .type = P_OCTAL,
1682 .p_class = P_LOCAL,
1683 .ptr = &sDefault.iDir_Security_force_mode,
1684 .special = NULL,
1685 .enum_list = NULL,
1686 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1689 .label = "force unknown acl user",
1690 .type = P_BOOL,
1691 .p_class = P_LOCAL,
1692 .ptr = &sDefault.bForceUnknownAclUser,
1693 .special = NULL,
1694 .enum_list = NULL,
1695 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1698 .label = "inherit permissions",
1699 .type = P_BOOL,
1700 .p_class = P_LOCAL,
1701 .ptr = &sDefault.bInheritPerms,
1702 .special = NULL,
1703 .enum_list = NULL,
1704 .flags = FLAG_ADVANCED | FLAG_SHARE,
1707 .label = "inherit acls",
1708 .type = P_BOOL,
1709 .p_class = P_LOCAL,
1710 .ptr = &sDefault.bInheritACLS,
1711 .special = NULL,
1712 .enum_list = NULL,
1713 .flags = FLAG_ADVANCED | FLAG_SHARE,
1716 .label = "inherit owner",
1717 .type = P_BOOL,
1718 .p_class = P_LOCAL,
1719 .ptr = &sDefault.bInheritOwner,
1720 .special = NULL,
1721 .enum_list = NULL,
1722 .flags = FLAG_ADVANCED | FLAG_SHARE,
1725 .label = "guest only",
1726 .type = P_BOOL,
1727 .p_class = P_LOCAL,
1728 .ptr = &sDefault.bGuest_only,
1729 .special = NULL,
1730 .enum_list = NULL,
1731 .flags = FLAG_ADVANCED | FLAG_SHARE,
1734 .label = "only guest",
1735 .type = P_BOOL,
1736 .p_class = P_LOCAL,
1737 .ptr = &sDefault.bGuest_only,
1738 .special = NULL,
1739 .enum_list = NULL,
1740 .flags = FLAG_HIDE,
1743 .label = "administrative share",
1744 .type = P_BOOL,
1745 .p_class = P_LOCAL,
1746 .ptr = &sDefault.bAdministrative_share,
1747 .special = NULL,
1748 .enum_list = NULL,
1749 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1753 .label = "guest ok",
1754 .type = P_BOOL,
1755 .p_class = P_LOCAL,
1756 .ptr = &sDefault.bGuest_ok,
1757 .special = NULL,
1758 .enum_list = NULL,
1759 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1762 .label = "public",
1763 .type = P_BOOL,
1764 .p_class = P_LOCAL,
1765 .ptr = &sDefault.bGuest_ok,
1766 .special = NULL,
1767 .enum_list = NULL,
1768 .flags = FLAG_HIDE,
1771 .label = "only user",
1772 .type = P_BOOL,
1773 .p_class = P_LOCAL,
1774 .ptr = &sDefault.bOnlyUser,
1775 .special = NULL,
1776 .enum_list = NULL,
1777 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1780 .label = "hosts allow",
1781 .type = P_LIST,
1782 .p_class = P_LOCAL,
1783 .ptr = &sDefault.szHostsallow,
1784 .special = NULL,
1785 .enum_list = NULL,
1786 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1789 .label = "allow hosts",
1790 .type = P_LIST,
1791 .p_class = P_LOCAL,
1792 .ptr = &sDefault.szHostsallow,
1793 .special = NULL,
1794 .enum_list = NULL,
1795 .flags = FLAG_HIDE,
1798 .label = "hosts deny",
1799 .type = P_LIST,
1800 .p_class = P_LOCAL,
1801 .ptr = &sDefault.szHostsdeny,
1802 .special = NULL,
1803 .enum_list = NULL,
1804 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1807 .label = "deny hosts",
1808 .type = P_LIST,
1809 .p_class = P_LOCAL,
1810 .ptr = &sDefault.szHostsdeny,
1811 .special = NULL,
1812 .enum_list = NULL,
1813 .flags = FLAG_HIDE,
1816 .label = "preload modules",
1817 .type = P_LIST,
1818 .p_class = P_GLOBAL,
1819 .ptr = &Globals.szPreloadModules,
1820 .special = NULL,
1821 .enum_list = NULL,
1822 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1825 .label = "dedicated keytab file",
1826 .type = P_STRING,
1827 .p_class = P_GLOBAL,
1828 .ptr = &Globals.szDedicatedKeytabFile,
1829 .special = NULL,
1830 .enum_list = NULL,
1831 .flags = FLAG_ADVANCED,
1834 .label = "kerberos method",
1835 .type = P_ENUM,
1836 .p_class = P_GLOBAL,
1837 .ptr = &Globals.iKerberosMethod,
1838 .special = NULL,
1839 .enum_list = enum_kerberos_method,
1840 .flags = FLAG_ADVANCED,
1843 .label = "map untrusted to domain",
1844 .type = P_BOOL,
1845 .p_class = P_GLOBAL,
1846 .ptr = &Globals.bMapUntrustedToDomain,
1847 .special = NULL,
1848 .enum_list = NULL,
1849 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1853 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1856 .label = "log level",
1857 .type = P_STRING,
1858 .p_class = P_GLOBAL,
1859 .ptr = &Globals.szLogLevel,
1860 .special = handle_debug_list,
1861 .enum_list = NULL,
1862 .flags = FLAG_ADVANCED,
1865 .label = "debuglevel",
1866 .type = P_STRING,
1867 .p_class = P_GLOBAL,
1868 .ptr = &Globals.szLogLevel,
1869 .special = handle_debug_list,
1870 .enum_list = NULL,
1871 .flags = FLAG_HIDE,
1874 .label = "syslog",
1875 .type = P_INTEGER,
1876 .p_class = P_GLOBAL,
1877 .ptr = &Globals.syslog,
1878 .special = NULL,
1879 .enum_list = NULL,
1880 .flags = FLAG_ADVANCED,
1883 .label = "syslog only",
1884 .type = P_BOOL,
1885 .p_class = P_GLOBAL,
1886 .ptr = &Globals.bSyslogOnly,
1887 .special = NULL,
1888 .enum_list = NULL,
1889 .flags = FLAG_ADVANCED,
1892 .label = "log file",
1893 .type = P_STRING,
1894 .p_class = P_GLOBAL,
1895 .ptr = &Globals.szLogFile,
1896 .special = NULL,
1897 .enum_list = NULL,
1898 .flags = FLAG_ADVANCED,
1901 .label = "max log size",
1902 .type = P_INTEGER,
1903 .p_class = P_GLOBAL,
1904 .ptr = &Globals.max_log_size,
1905 .special = NULL,
1906 .enum_list = NULL,
1907 .flags = FLAG_ADVANCED,
1910 .label = "debug timestamp",
1911 .type = P_BOOL,
1912 .p_class = P_GLOBAL,
1913 .ptr = &Globals.bTimestampLogs,
1914 .special = NULL,
1915 .enum_list = NULL,
1916 .flags = FLAG_ADVANCED,
1919 .label = "timestamp logs",
1920 .type = P_BOOL,
1921 .p_class = P_GLOBAL,
1922 .ptr = &Globals.bTimestampLogs,
1923 .special = NULL,
1924 .enum_list = NULL,
1925 .flags = FLAG_ADVANCED,
1928 .label = "debug prefix timestamp",
1929 .type = P_BOOL,
1930 .p_class = P_GLOBAL,
1931 .ptr = &Globals.bDebugPrefixTimestamp,
1932 .special = NULL,
1933 .enum_list = NULL,
1934 .flags = FLAG_ADVANCED,
1937 .label = "debug hires timestamp",
1938 .type = P_BOOL,
1939 .p_class = P_GLOBAL,
1940 .ptr = &Globals.bDebugHiresTimestamp,
1941 .special = NULL,
1942 .enum_list = NULL,
1943 .flags = FLAG_ADVANCED,
1946 .label = "debug pid",
1947 .type = P_BOOL,
1948 .p_class = P_GLOBAL,
1949 .ptr = &Globals.bDebugPid,
1950 .special = NULL,
1951 .enum_list = NULL,
1952 .flags = FLAG_ADVANCED,
1955 .label = "debug uid",
1956 .type = P_BOOL,
1957 .p_class = P_GLOBAL,
1958 .ptr = &Globals.bDebugUid,
1959 .special = NULL,
1960 .enum_list = NULL,
1961 .flags = FLAG_ADVANCED,
1964 .label = "debug class",
1965 .type = P_BOOL,
1966 .p_class = P_GLOBAL,
1967 .ptr = &Globals.bDebugClass,
1968 .special = NULL,
1969 .enum_list = NULL,
1970 .flags = FLAG_ADVANCED,
1973 .label = "enable core files",
1974 .type = P_BOOL,
1975 .p_class = P_GLOBAL,
1976 .ptr = &Globals.bEnableCoreFiles,
1977 .special = NULL,
1978 .enum_list = NULL,
1979 .flags = FLAG_ADVANCED,
1982 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1985 .label = "allocation roundup size",
1986 .type = P_INTEGER,
1987 .p_class = P_LOCAL,
1988 .ptr = &sDefault.iallocation_roundup_size,
1989 .special = NULL,
1990 .enum_list = NULL,
1991 .flags = FLAG_ADVANCED,
1994 .label = "aio read size",
1995 .type = P_INTEGER,
1996 .p_class = P_LOCAL,
1997 .ptr = &sDefault.iAioReadSize,
1998 .special = NULL,
1999 .enum_list = NULL,
2000 .flags = FLAG_ADVANCED,
2003 .label = "aio write size",
2004 .type = P_INTEGER,
2005 .p_class = P_LOCAL,
2006 .ptr = &sDefault.iAioWriteSize,
2007 .special = NULL,
2008 .enum_list = NULL,
2009 .flags = FLAG_ADVANCED,
2012 .label = "aio write behind",
2013 .type = P_STRING,
2014 .p_class = P_LOCAL,
2015 .ptr = &sDefault.szAioWriteBehind,
2016 .special = NULL,
2017 .enum_list = NULL,
2018 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2021 .label = "smb ports",
2022 .type = P_STRING,
2023 .p_class = P_GLOBAL,
2024 .ptr = &Globals.smb_ports,
2025 .special = NULL,
2026 .enum_list = NULL,
2027 .flags = FLAG_ADVANCED,
2030 .label = "large readwrite",
2031 .type = P_BOOL,
2032 .p_class = P_GLOBAL,
2033 .ptr = &Globals.bLargeReadwrite,
2034 .special = NULL,
2035 .enum_list = NULL,
2036 .flags = FLAG_ADVANCED,
2039 .label = "max protocol",
2040 .type = P_ENUM,
2041 .p_class = P_GLOBAL,
2042 .ptr = &Globals.maxprotocol,
2043 .special = NULL,
2044 .enum_list = enum_protocol,
2045 .flags = FLAG_ADVANCED,
2048 .label = "protocol",
2049 .type = P_ENUM,
2050 .p_class = P_GLOBAL,
2051 .ptr = &Globals.maxprotocol,
2052 .special = NULL,
2053 .enum_list = enum_protocol,
2054 .flags = FLAG_ADVANCED,
2057 .label = "min protocol",
2058 .type = P_ENUM,
2059 .p_class = P_GLOBAL,
2060 .ptr = &Globals.minprotocol,
2061 .special = NULL,
2062 .enum_list = enum_protocol,
2063 .flags = FLAG_ADVANCED,
2066 .label = "min receivefile size",
2067 .type = P_INTEGER,
2068 .p_class = P_GLOBAL,
2069 .ptr = &Globals.iminreceivefile,
2070 .special = NULL,
2071 .enum_list = NULL,
2072 .flags = FLAG_ADVANCED,
2075 .label = "read raw",
2076 .type = P_BOOL,
2077 .p_class = P_GLOBAL,
2078 .ptr = &Globals.bReadRaw,
2079 .special = NULL,
2080 .enum_list = NULL,
2081 .flags = FLAG_ADVANCED,
2084 .label = "write raw",
2085 .type = P_BOOL,
2086 .p_class = P_GLOBAL,
2087 .ptr = &Globals.bWriteRaw,
2088 .special = NULL,
2089 .enum_list = NULL,
2090 .flags = FLAG_ADVANCED,
2093 .label = "disable netbios",
2094 .type = P_BOOL,
2095 .p_class = P_GLOBAL,
2096 .ptr = &Globals.bDisableNetbios,
2097 .special = NULL,
2098 .enum_list = NULL,
2099 .flags = FLAG_ADVANCED,
2102 .label = "reset on zero vc",
2103 .type = P_BOOL,
2104 .p_class = P_GLOBAL,
2105 .ptr = &Globals.bResetOnZeroVC,
2106 .special = NULL,
2107 .enum_list = NULL,
2108 .flags = FLAG_ADVANCED,
2111 .label = "log writeable files on exit",
2112 .type = P_BOOL,
2113 .p_class = P_GLOBAL,
2114 .ptr = &Globals.bLogWriteableFilesOnExit,
2115 .special = NULL,
2116 .enum_list = NULL,
2117 .flags = FLAG_ADVANCED,
2120 .label = "acl compatibility",
2121 .type = P_ENUM,
2122 .p_class = P_GLOBAL,
2123 .ptr = &Globals.iAclCompat,
2124 .special = NULL,
2125 .enum_list = enum_acl_compat_vals,
2126 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2129 .label = "defer sharing violations",
2130 .type = P_BOOL,
2131 .p_class = P_GLOBAL,
2132 .ptr = &Globals.bDeferSharingViolations,
2133 .special = NULL,
2134 .enum_list = NULL,
2135 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2138 .label = "ea support",
2139 .type = P_BOOL,
2140 .p_class = P_LOCAL,
2141 .ptr = &sDefault.bEASupport,
2142 .special = NULL,
2143 .enum_list = NULL,
2144 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2147 .label = "nt acl support",
2148 .type = P_BOOL,
2149 .p_class = P_LOCAL,
2150 .ptr = &sDefault.bNTAclSupport,
2151 .special = NULL,
2152 .enum_list = NULL,
2153 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2156 .label = "nt pipe support",
2157 .type = P_BOOL,
2158 .p_class = P_GLOBAL,
2159 .ptr = &Globals.bNTPipeSupport,
2160 .special = NULL,
2161 .enum_list = NULL,
2162 .flags = FLAG_ADVANCED,
2165 .label = "nt status support",
2166 .type = P_BOOL,
2167 .p_class = P_GLOBAL,
2168 .ptr = &Globals.bNTStatusSupport,
2169 .special = NULL,
2170 .enum_list = NULL,
2171 .flags = FLAG_ADVANCED,
2174 .label = "profile acls",
2175 .type = P_BOOL,
2176 .p_class = P_LOCAL,
2177 .ptr = &sDefault.bProfileAcls,
2178 .special = NULL,
2179 .enum_list = NULL,
2180 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
2183 .label = "announce version",
2184 .type = P_STRING,
2185 .p_class = P_GLOBAL,
2186 .ptr = &Globals.szAnnounceVersion,
2187 .special = NULL,
2188 .enum_list = NULL,
2189 .flags = FLAG_ADVANCED,
2192 .label = "announce as",
2193 .type = P_ENUM,
2194 .p_class = P_GLOBAL,
2195 .ptr = &Globals.announce_as,
2196 .special = NULL,
2197 .enum_list = enum_announce_as,
2198 .flags = FLAG_ADVANCED,
2201 .label = "map acl inherit",
2202 .type = P_BOOL,
2203 .p_class = P_LOCAL,
2204 .ptr = &sDefault.bMap_acl_inherit,
2205 .special = NULL,
2206 .enum_list = NULL,
2207 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2210 .label = "afs share",
2211 .type = P_BOOL,
2212 .p_class = P_LOCAL,
2213 .ptr = &sDefault.bAfs_Share,
2214 .special = NULL,
2215 .enum_list = NULL,
2216 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2219 .label = "max mux",
2220 .type = P_INTEGER,
2221 .p_class = P_GLOBAL,
2222 .ptr = &Globals.max_mux,
2223 .special = NULL,
2224 .enum_list = NULL,
2225 .flags = FLAG_ADVANCED,
2228 .label = "max xmit",
2229 .type = P_INTEGER,
2230 .p_class = P_GLOBAL,
2231 .ptr = &Globals.max_xmit,
2232 .special = NULL,
2233 .enum_list = NULL,
2234 .flags = FLAG_ADVANCED,
2237 .label = "name resolve order",
2238 .type = P_STRING,
2239 .p_class = P_GLOBAL,
2240 .ptr = &Globals.szNameResolveOrder,
2241 .special = NULL,
2242 .enum_list = NULL,
2243 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2246 .label = "max ttl",
2247 .type = P_INTEGER,
2248 .p_class = P_GLOBAL,
2249 .ptr = &Globals.max_ttl,
2250 .special = NULL,
2251 .enum_list = NULL,
2252 .flags = FLAG_ADVANCED,
2255 .label = "max wins ttl",
2256 .type = P_INTEGER,
2257 .p_class = P_GLOBAL,
2258 .ptr = &Globals.max_wins_ttl,
2259 .special = NULL,
2260 .enum_list = NULL,
2261 .flags = FLAG_ADVANCED,
2264 .label = "min wins ttl",
2265 .type = P_INTEGER,
2266 .p_class = P_GLOBAL,
2267 .ptr = &Globals.min_wins_ttl,
2268 .special = NULL,
2269 .enum_list = NULL,
2270 .flags = FLAG_ADVANCED,
2273 .label = "time server",
2274 .type = P_BOOL,
2275 .p_class = P_GLOBAL,
2276 .ptr = &Globals.bTimeServer,
2277 .special = NULL,
2278 .enum_list = NULL,
2279 .flags = FLAG_ADVANCED,
2282 .label = "unix extensions",
2283 .type = P_BOOL,
2284 .p_class = P_GLOBAL,
2285 .ptr = &Globals.bUnixExtensions,
2286 .special = NULL,
2287 .enum_list = NULL,
2288 .flags = FLAG_ADVANCED,
2291 .label = "use spnego",
2292 .type = P_BOOL,
2293 .p_class = P_GLOBAL,
2294 .ptr = &Globals.bUseSpnego,
2295 .special = NULL,
2296 .enum_list = NULL,
2297 .flags = FLAG_ADVANCED,
2300 .label = "client signing",
2301 .type = P_ENUM,
2302 .p_class = P_GLOBAL,
2303 .ptr = &Globals.client_signing,
2304 .special = NULL,
2305 .enum_list = enum_smb_signing_vals,
2306 .flags = FLAG_ADVANCED,
2309 .label = "server signing",
2310 .type = P_ENUM,
2311 .p_class = P_GLOBAL,
2312 .ptr = &Globals.server_signing,
2313 .special = NULL,
2314 .enum_list = enum_smb_signing_vals,
2315 .flags = FLAG_ADVANCED,
2318 .label = "smb encrypt",
2319 .type = P_ENUM,
2320 .p_class = P_LOCAL,
2321 .ptr = &sDefault.ismb_encrypt,
2322 .special = NULL,
2323 .enum_list = enum_smb_signing_vals,
2324 .flags = FLAG_ADVANCED,
2327 .label = "client use spnego",
2328 .type = P_BOOL,
2329 .p_class = P_GLOBAL,
2330 .ptr = &Globals.bClientUseSpnego,
2331 .special = NULL,
2332 .enum_list = NULL,
2333 .flags = FLAG_ADVANCED,
2336 .label = "client ldap sasl wrapping",
2337 .type = P_ENUM,
2338 .p_class = P_GLOBAL,
2339 .ptr = &Globals.client_ldap_sasl_wrapping,
2340 .special = NULL,
2341 .enum_list = enum_ldap_sasl_wrapping,
2342 .flags = FLAG_ADVANCED,
2345 .label = "enable asu support",
2346 .type = P_BOOL,
2347 .p_class = P_GLOBAL,
2348 .ptr = &Globals.bASUSupport,
2349 .special = NULL,
2350 .enum_list = NULL,
2351 .flags = FLAG_ADVANCED,
2354 .label = "svcctl list",
2355 .type = P_LIST,
2356 .p_class = P_GLOBAL,
2357 .ptr = &Globals.szServicesList,
2358 .special = NULL,
2359 .enum_list = NULL,
2360 .flags = FLAG_ADVANCED,
2363 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
2366 .label = "block size",
2367 .type = P_INTEGER,
2368 .p_class = P_LOCAL,
2369 .ptr = &sDefault.iBlock_size,
2370 .special = NULL,
2371 .enum_list = NULL,
2372 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2375 .label = "deadtime",
2376 .type = P_INTEGER,
2377 .p_class = P_GLOBAL,
2378 .ptr = &Globals.deadtime,
2379 .special = NULL,
2380 .enum_list = NULL,
2381 .flags = FLAG_ADVANCED,
2384 .label = "getwd cache",
2385 .type = P_BOOL,
2386 .p_class = P_GLOBAL,
2387 .ptr = &Globals.getwd_cache,
2388 .special = NULL,
2389 .enum_list = NULL,
2390 .flags = FLAG_ADVANCED,
2393 .label = "keepalive",
2394 .type = P_INTEGER,
2395 .p_class = P_GLOBAL,
2396 .ptr = &Globals.iKeepalive,
2397 .special = NULL,
2398 .enum_list = NULL,
2399 .flags = FLAG_ADVANCED,
2402 .label = "change notify",
2403 .type = P_BOOL,
2404 .p_class = P_LOCAL,
2405 .ptr = &sDefault.bChangeNotify,
2406 .special = NULL,
2407 .enum_list = NULL,
2408 .flags = FLAG_ADVANCED | FLAG_SHARE,
2411 .label = "directory name cache size",
2412 .type = P_INTEGER,
2413 .p_class = P_LOCAL,
2414 .ptr = &sDefault.iDirectoryNameCacheSize,
2415 .special = NULL,
2416 .enum_list = NULL,
2417 .flags = FLAG_ADVANCED | FLAG_SHARE,
2420 .label = "kernel change notify",
2421 .type = P_BOOL,
2422 .p_class = P_LOCAL,
2423 .ptr = &sDefault.bKernelChangeNotify,
2424 .special = NULL,
2425 .enum_list = NULL,
2426 .flags = FLAG_ADVANCED | FLAG_SHARE,
2429 .label = "lpq cache time",
2430 .type = P_INTEGER,
2431 .p_class = P_GLOBAL,
2432 .ptr = &Globals.lpqcachetime,
2433 .special = NULL,
2434 .enum_list = NULL,
2435 .flags = FLAG_ADVANCED,
2438 .label = "max smbd processes",
2439 .type = P_INTEGER,
2440 .p_class = P_GLOBAL,
2441 .ptr = &Globals.iMaxSmbdProcesses,
2442 .special = NULL,
2443 .enum_list = NULL,
2444 .flags = FLAG_ADVANCED,
2447 .label = "max connections",
2448 .type = P_INTEGER,
2449 .p_class = P_LOCAL,
2450 .ptr = &sDefault.iMaxConnections,
2451 .special = NULL,
2452 .enum_list = NULL,
2453 .flags = FLAG_ADVANCED | FLAG_SHARE,
2456 .label = "paranoid server security",
2457 .type = P_BOOL,
2458 .p_class = P_GLOBAL,
2459 .ptr = &Globals.paranoid_server_security,
2460 .special = NULL,
2461 .enum_list = NULL,
2462 .flags = FLAG_ADVANCED,
2465 .label = "max disk size",
2466 .type = P_INTEGER,
2467 .p_class = P_GLOBAL,
2468 .ptr = &Globals.maxdisksize,
2469 .special = NULL,
2470 .enum_list = NULL,
2471 .flags = FLAG_ADVANCED,
2474 .label = "max open files",
2475 .type = P_INTEGER,
2476 .p_class = P_GLOBAL,
2477 .ptr = &Globals.max_open_files,
2478 .special = NULL,
2479 .enum_list = NULL,
2480 .flags = FLAG_ADVANCED,
2483 .label = "min print space",
2484 .type = P_INTEGER,
2485 .p_class = P_LOCAL,
2486 .ptr = &sDefault.iMinPrintSpace,
2487 .special = NULL,
2488 .enum_list = NULL,
2489 .flags = FLAG_ADVANCED | FLAG_PRINT,
2492 .label = "socket options",
2493 .type = P_STRING,
2494 .p_class = P_GLOBAL,
2495 .ptr = &Globals.szSocketOptions,
2496 .special = NULL,
2497 .enum_list = NULL,
2498 .flags = FLAG_ADVANCED,
2501 .label = "strict allocate",
2502 .type = P_BOOL,
2503 .p_class = P_LOCAL,
2504 .ptr = &sDefault.bStrictAllocate,
2505 .special = NULL,
2506 .enum_list = NULL,
2507 .flags = FLAG_ADVANCED | FLAG_SHARE,
2510 .label = "strict sync",
2511 .type = P_BOOL,
2512 .p_class = P_LOCAL,
2513 .ptr = &sDefault.bStrictSync,
2514 .special = NULL,
2515 .enum_list = NULL,
2516 .flags = FLAG_ADVANCED | FLAG_SHARE,
2519 .label = "sync always",
2520 .type = P_BOOL,
2521 .p_class = P_LOCAL,
2522 .ptr = &sDefault.bSyncAlways,
2523 .special = NULL,
2524 .enum_list = NULL,
2525 .flags = FLAG_ADVANCED | FLAG_SHARE,
2528 .label = "use mmap",
2529 .type = P_BOOL,
2530 .p_class = P_GLOBAL,
2531 .ptr = &Globals.bUseMmap,
2532 .special = NULL,
2533 .enum_list = NULL,
2534 .flags = FLAG_ADVANCED,
2537 .label = "use sendfile",
2538 .type = P_BOOL,
2539 .p_class = P_LOCAL,
2540 .ptr = &sDefault.bUseSendfile,
2541 .special = NULL,
2542 .enum_list = NULL,
2543 .flags = FLAG_ADVANCED | FLAG_SHARE,
2546 .label = "hostname lookups",
2547 .type = P_BOOL,
2548 .p_class = P_GLOBAL,
2549 .ptr = &Globals.bHostnameLookups,
2550 .special = NULL,
2551 .enum_list = NULL,
2552 .flags = FLAG_ADVANCED,
2555 .label = "write cache size",
2556 .type = P_INTEGER,
2557 .p_class = P_LOCAL,
2558 .ptr = &sDefault.iWriteCacheSize,
2559 .special = NULL,
2560 .enum_list = NULL,
2561 .flags = FLAG_ADVANCED | FLAG_SHARE,
2564 .label = "name cache timeout",
2565 .type = P_INTEGER,
2566 .p_class = P_GLOBAL,
2567 .ptr = &Globals.name_cache_timeout,
2568 .special = NULL,
2569 .enum_list = NULL,
2570 .flags = FLAG_ADVANCED,
2573 .label = "ctdbd socket",
2574 .type = P_STRING,
2575 .p_class = P_GLOBAL,
2576 .ptr = &Globals.ctdbdSocket,
2577 .special = NULL,
2578 .enum_list = NULL,
2579 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2582 .label = "cluster addresses",
2583 .type = P_LIST,
2584 .p_class = P_GLOBAL,
2585 .ptr = &Globals.szClusterAddresses,
2586 .special = NULL,
2587 .enum_list = NULL,
2588 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2591 .label = "clustering",
2592 .type = P_BOOL,
2593 .p_class = P_GLOBAL,
2594 .ptr = &Globals.clustering,
2595 .special = NULL,
2596 .enum_list = NULL,
2597 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2600 .label = "ctdb timeout",
2601 .type = P_INTEGER,
2602 .p_class = P_GLOBAL,
2603 .ptr = &Globals.ctdb_timeout,
2604 .special = NULL,
2605 .enum_list = NULL,
2606 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2609 .label = "ctdb locktime warn threshold",
2610 .type = P_INTEGER,
2611 .p_class = P_GLOBAL,
2612 .ptr = &Globals.ctdb_locktime_warn_threshold,
2613 .special = NULL,
2614 .enum_list = NULL,
2615 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2618 .label = "smb2 max read",
2619 .type = P_INTEGER,
2620 .p_class = P_GLOBAL,
2621 .ptr = &Globals.ismb2_max_read,
2622 .special = NULL,
2623 .enum_list = NULL,
2624 .flags = FLAG_ADVANCED,
2627 .label = "smb2 max write",
2628 .type = P_INTEGER,
2629 .p_class = P_GLOBAL,
2630 .ptr = &Globals.ismb2_max_write,
2631 .special = NULL,
2632 .enum_list = NULL,
2633 .flags = FLAG_ADVANCED,
2636 .label = "smb2 max trans",
2637 .type = P_INTEGER,
2638 .p_class = P_GLOBAL,
2639 .ptr = &Globals.ismb2_max_trans,
2640 .special = NULL,
2641 .enum_list = NULL,
2642 .flags = FLAG_ADVANCED,
2645 .label = "smb2 max credits",
2646 .type = P_INTEGER,
2647 .p_class = P_GLOBAL,
2648 .ptr = &Globals.ismb2_max_credits,
2649 .special = NULL,
2650 .enum_list = NULL,
2651 .flags = FLAG_ADVANCED,
2654 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2657 .label = "max reported print jobs",
2658 .type = P_INTEGER,
2659 .p_class = P_LOCAL,
2660 .ptr = &sDefault.iMaxReportedPrintJobs,
2661 .special = NULL,
2662 .enum_list = NULL,
2663 .flags = FLAG_ADVANCED | FLAG_PRINT,
2666 .label = "max print jobs",
2667 .type = P_INTEGER,
2668 .p_class = P_LOCAL,
2669 .ptr = &sDefault.iMaxPrintJobs,
2670 .special = NULL,
2671 .enum_list = NULL,
2672 .flags = FLAG_ADVANCED | FLAG_PRINT,
2675 .label = "load printers",
2676 .type = P_BOOL,
2677 .p_class = P_GLOBAL,
2678 .ptr = &Globals.bLoadPrinters,
2679 .special = NULL,
2680 .enum_list = NULL,
2681 .flags = FLAG_ADVANCED | FLAG_PRINT,
2684 .label = "printcap cache time",
2685 .type = P_INTEGER,
2686 .p_class = P_GLOBAL,
2687 .ptr = &Globals.PrintcapCacheTime,
2688 .special = NULL,
2689 .enum_list = NULL,
2690 .flags = FLAG_ADVANCED | FLAG_PRINT,
2693 .label = "printcap name",
2694 .type = P_STRING,
2695 .p_class = P_GLOBAL,
2696 .ptr = &Globals.szPrintcapname,
2697 .special = NULL,
2698 .enum_list = NULL,
2699 .flags = FLAG_ADVANCED | FLAG_PRINT,
2702 .label = "printcap",
2703 .type = P_STRING,
2704 .p_class = P_GLOBAL,
2705 .ptr = &Globals.szPrintcapname,
2706 .special = NULL,
2707 .enum_list = NULL,
2708 .flags = FLAG_HIDE,
2711 .label = "printable",
2712 .type = P_BOOL,
2713 .p_class = P_LOCAL,
2714 .ptr = &sDefault.bPrint_ok,
2715 .special = NULL,
2716 .enum_list = NULL,
2717 .flags = FLAG_ADVANCED | FLAG_PRINT,
2720 .label = "print notify backchannel",
2721 .type = P_BOOL,
2722 .p_class = P_LOCAL,
2723 .ptr = &sDefault.bPrintNotifyBackchannel,
2724 .special = NULL,
2725 .enum_list = NULL,
2726 .flags = FLAG_ADVANCED,
2729 .label = "print ok",
2730 .type = P_BOOL,
2731 .p_class = P_LOCAL,
2732 .ptr = &sDefault.bPrint_ok,
2733 .special = NULL,
2734 .enum_list = NULL,
2735 .flags = FLAG_HIDE,
2738 .label = "printing",
2739 .type = P_ENUM,
2740 .p_class = P_LOCAL,
2741 .ptr = &sDefault.iPrinting,
2742 .special = handle_printing,
2743 .enum_list = enum_printing,
2744 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2747 .label = "cups options",
2748 .type = P_STRING,
2749 .p_class = P_LOCAL,
2750 .ptr = &sDefault.szCupsOptions,
2751 .special = NULL,
2752 .enum_list = NULL,
2753 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2756 .label = "cups server",
2757 .type = P_STRING,
2758 .p_class = P_GLOBAL,
2759 .ptr = &Globals.szCupsServer,
2760 .special = NULL,
2761 .enum_list = NULL,
2762 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2765 .label = "cups encrypt",
2766 .type = P_ENUM,
2767 .p_class = P_GLOBAL,
2768 .ptr = &Globals.CupsEncrypt,
2769 .special = NULL,
2770 .enum_list = enum_bool_auto,
2771 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2775 .label = "cups connection timeout",
2776 .type = P_INTEGER,
2777 .p_class = P_GLOBAL,
2778 .ptr = &Globals.cups_connection_timeout,
2779 .special = NULL,
2780 .enum_list = NULL,
2781 .flags = FLAG_ADVANCED,
2784 .label = "iprint server",
2785 .type = P_STRING,
2786 .p_class = P_GLOBAL,
2787 .ptr = &Globals.szIPrintServer,
2788 .special = NULL,
2789 .enum_list = NULL,
2790 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2793 .label = "print command",
2794 .type = P_STRING,
2795 .p_class = P_LOCAL,
2796 .ptr = &sDefault.szPrintcommand,
2797 .special = NULL,
2798 .enum_list = NULL,
2799 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2802 .label = "disable spoolss",
2803 .type = P_BOOL,
2804 .p_class = P_GLOBAL,
2805 .ptr = &Globals.bDisableSpoolss,
2806 .special = NULL,
2807 .enum_list = NULL,
2808 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2811 .label = "enable spoolss",
2812 .type = P_BOOLREV,
2813 .p_class = P_GLOBAL,
2814 .ptr = &Globals.bDisableSpoolss,
2815 .special = NULL,
2816 .enum_list = NULL,
2817 .flags = FLAG_HIDE,
2820 .label = "lpq command",
2821 .type = P_STRING,
2822 .p_class = P_LOCAL,
2823 .ptr = &sDefault.szLpqcommand,
2824 .special = NULL,
2825 .enum_list = NULL,
2826 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2829 .label = "lprm command",
2830 .type = P_STRING,
2831 .p_class = P_LOCAL,
2832 .ptr = &sDefault.szLprmcommand,
2833 .special = NULL,
2834 .enum_list = NULL,
2835 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2838 .label = "lppause command",
2839 .type = P_STRING,
2840 .p_class = P_LOCAL,
2841 .ptr = &sDefault.szLppausecommand,
2842 .special = NULL,
2843 .enum_list = NULL,
2844 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2847 .label = "lpresume command",
2848 .type = P_STRING,
2849 .p_class = P_LOCAL,
2850 .ptr = &sDefault.szLpresumecommand,
2851 .special = NULL,
2852 .enum_list = NULL,
2853 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2856 .label = "queuepause command",
2857 .type = P_STRING,
2858 .p_class = P_LOCAL,
2859 .ptr = &sDefault.szQueuepausecommand,
2860 .special = NULL,
2861 .enum_list = NULL,
2862 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2865 .label = "queueresume command",
2866 .type = P_STRING,
2867 .p_class = P_LOCAL,
2868 .ptr = &sDefault.szQueueresumecommand,
2869 .special = NULL,
2870 .enum_list = NULL,
2871 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2874 .label = "addport command",
2875 .type = P_STRING,
2876 .p_class = P_GLOBAL,
2877 .ptr = &Globals.szAddPortCommand,
2878 .special = NULL,
2879 .enum_list = NULL,
2880 .flags = FLAG_ADVANCED,
2883 .label = "enumports command",
2884 .type = P_STRING,
2885 .p_class = P_GLOBAL,
2886 .ptr = &Globals.szEnumPortsCommand,
2887 .special = NULL,
2888 .enum_list = NULL,
2889 .flags = FLAG_ADVANCED,
2892 .label = "addprinter command",
2893 .type = P_STRING,
2894 .p_class = P_GLOBAL,
2895 .ptr = &Globals.szAddPrinterCommand,
2896 .special = NULL,
2897 .enum_list = NULL,
2898 .flags = FLAG_ADVANCED,
2901 .label = "deleteprinter command",
2902 .type = P_STRING,
2903 .p_class = P_GLOBAL,
2904 .ptr = &Globals.szDeletePrinterCommand,
2905 .special = NULL,
2906 .enum_list = NULL,
2907 .flags = FLAG_ADVANCED,
2910 .label = "show add printer wizard",
2911 .type = P_BOOL,
2912 .p_class = P_GLOBAL,
2913 .ptr = &Globals.bMsAddPrinterWizard,
2914 .special = NULL,
2915 .enum_list = NULL,
2916 .flags = FLAG_ADVANCED,
2919 .label = "os2 driver map",
2920 .type = P_STRING,
2921 .p_class = P_GLOBAL,
2922 .ptr = &Globals.szOs2DriverMap,
2923 .special = NULL,
2924 .enum_list = NULL,
2925 .flags = FLAG_ADVANCED,
2929 .label = "printer name",
2930 .type = P_STRING,
2931 .p_class = P_LOCAL,
2932 .ptr = &sDefault.szPrintername,
2933 .special = NULL,
2934 .enum_list = NULL,
2935 .flags = FLAG_ADVANCED | FLAG_PRINT,
2938 .label = "printer",
2939 .type = P_STRING,
2940 .p_class = P_LOCAL,
2941 .ptr = &sDefault.szPrintername,
2942 .special = NULL,
2943 .enum_list = NULL,
2944 .flags = FLAG_HIDE,
2947 .label = "use client driver",
2948 .type = P_BOOL,
2949 .p_class = P_LOCAL,
2950 .ptr = &sDefault.bUseClientDriver,
2951 .special = NULL,
2952 .enum_list = NULL,
2953 .flags = FLAG_ADVANCED | FLAG_PRINT,
2956 .label = "default devmode",
2957 .type = P_BOOL,
2958 .p_class = P_LOCAL,
2959 .ptr = &sDefault.bDefaultDevmode,
2960 .special = NULL,
2961 .enum_list = NULL,
2962 .flags = FLAG_ADVANCED | FLAG_PRINT,
2965 .label = "force printername",
2966 .type = P_BOOL,
2967 .p_class = P_LOCAL,
2968 .ptr = &sDefault.bForcePrintername,
2969 .special = NULL,
2970 .enum_list = NULL,
2971 .flags = FLAG_ADVANCED | FLAG_PRINT,
2974 .label = "printjob username",
2975 .type = P_STRING,
2976 .p_class = P_LOCAL,
2977 .ptr = &sDefault.szPrintjobUsername,
2978 .special = NULL,
2979 .enum_list = NULL,
2980 .flags = FLAG_ADVANCED | FLAG_PRINT,
2983 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2986 .label = "mangling method",
2987 .type = P_STRING,
2988 .p_class = P_GLOBAL,
2989 .ptr = &Globals.szManglingMethod,
2990 .special = NULL,
2991 .enum_list = NULL,
2992 .flags = FLAG_ADVANCED,
2995 .label = "mangle prefix",
2996 .type = P_INTEGER,
2997 .p_class = P_GLOBAL,
2998 .ptr = &Globals.mangle_prefix,
2999 .special = NULL,
3000 .enum_list = NULL,
3001 .flags = FLAG_ADVANCED,
3005 .label = "default case",
3006 .type = P_ENUM,
3007 .p_class = P_LOCAL,
3008 .ptr = &sDefault.iDefaultCase,
3009 .special = NULL,
3010 .enum_list = enum_case,
3011 .flags = FLAG_ADVANCED | FLAG_SHARE,
3014 .label = "case sensitive",
3015 .type = P_ENUM,
3016 .p_class = P_LOCAL,
3017 .ptr = &sDefault.iCaseSensitive,
3018 .special = NULL,
3019 .enum_list = enum_bool_auto,
3020 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3023 .label = "casesignames",
3024 .type = P_ENUM,
3025 .p_class = P_LOCAL,
3026 .ptr = &sDefault.iCaseSensitive,
3027 .special = NULL,
3028 .enum_list = enum_bool_auto,
3029 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
3032 .label = "preserve case",
3033 .type = P_BOOL,
3034 .p_class = P_LOCAL,
3035 .ptr = &sDefault.bCasePreserve,
3036 .special = NULL,
3037 .enum_list = NULL,
3038 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3041 .label = "short preserve case",
3042 .type = P_BOOL,
3043 .p_class = P_LOCAL,
3044 .ptr = &sDefault.bShortCasePreserve,
3045 .special = NULL,
3046 .enum_list = NULL,
3047 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3050 .label = "mangling char",
3051 .type = P_CHAR,
3052 .p_class = P_LOCAL,
3053 .ptr = &sDefault.magic_char,
3054 .special = NULL,
3055 .enum_list = NULL,
3056 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3059 .label = "hide dot files",
3060 .type = P_BOOL,
3061 .p_class = P_LOCAL,
3062 .ptr = &sDefault.bHideDotFiles,
3063 .special = NULL,
3064 .enum_list = NULL,
3065 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3068 .label = "hide special files",
3069 .type = P_BOOL,
3070 .p_class = P_LOCAL,
3071 .ptr = &sDefault.bHideSpecialFiles,
3072 .special = NULL,
3073 .enum_list = NULL,
3074 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3077 .label = "hide unreadable",
3078 .type = P_BOOL,
3079 .p_class = P_LOCAL,
3080 .ptr = &sDefault.bHideUnReadable,
3081 .special = NULL,
3082 .enum_list = NULL,
3083 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3086 .label = "hide unwriteable files",
3087 .type = P_BOOL,
3088 .p_class = P_LOCAL,
3089 .ptr = &sDefault.bHideUnWriteableFiles,
3090 .special = NULL,
3091 .enum_list = NULL,
3092 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3095 .label = "delete veto files",
3096 .type = P_BOOL,
3097 .p_class = P_LOCAL,
3098 .ptr = &sDefault.bDeleteVetoFiles,
3099 .special = NULL,
3100 .enum_list = NULL,
3101 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3104 .label = "veto files",
3105 .type = P_STRING,
3106 .p_class = P_LOCAL,
3107 .ptr = &sDefault.szVetoFiles,
3108 .special = NULL,
3109 .enum_list = NULL,
3110 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3113 .label = "hide files",
3114 .type = P_STRING,
3115 .p_class = P_LOCAL,
3116 .ptr = &sDefault.szHideFiles,
3117 .special = NULL,
3118 .enum_list = NULL,
3119 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3122 .label = "veto oplock files",
3123 .type = P_STRING,
3124 .p_class = P_LOCAL,
3125 .ptr = &sDefault.szVetoOplockFiles,
3126 .special = NULL,
3127 .enum_list = NULL,
3128 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3131 .label = "map archive",
3132 .type = P_BOOL,
3133 .p_class = P_LOCAL,
3134 .ptr = &sDefault.bMap_archive,
3135 .special = NULL,
3136 .enum_list = NULL,
3137 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3140 .label = "map hidden",
3141 .type = P_BOOL,
3142 .p_class = P_LOCAL,
3143 .ptr = &sDefault.bMap_hidden,
3144 .special = NULL,
3145 .enum_list = NULL,
3146 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3149 .label = "map system",
3150 .type = P_BOOL,
3151 .p_class = P_LOCAL,
3152 .ptr = &sDefault.bMap_system,
3153 .special = NULL,
3154 .enum_list = NULL,
3155 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3158 .label = "map readonly",
3159 .type = P_ENUM,
3160 .p_class = P_LOCAL,
3161 .ptr = &sDefault.iMap_readonly,
3162 .special = NULL,
3163 .enum_list = enum_map_readonly,
3164 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3167 .label = "mangled names",
3168 .type = P_BOOL,
3169 .p_class = P_LOCAL,
3170 .ptr = &sDefault.bMangledNames,
3171 .special = NULL,
3172 .enum_list = NULL,
3173 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3176 .label = "max stat cache size",
3177 .type = P_INTEGER,
3178 .p_class = P_GLOBAL,
3179 .ptr = &Globals.iMaxStatCacheSize,
3180 .special = NULL,
3181 .enum_list = NULL,
3182 .flags = FLAG_ADVANCED,
3185 .label = "stat cache",
3186 .type = P_BOOL,
3187 .p_class = P_GLOBAL,
3188 .ptr = &Globals.bStatCache,
3189 .special = NULL,
3190 .enum_list = NULL,
3191 .flags = FLAG_ADVANCED,
3194 .label = "store dos attributes",
3195 .type = P_BOOL,
3196 .p_class = P_LOCAL,
3197 .ptr = &sDefault.bStoreDosAttributes,
3198 .special = NULL,
3199 .enum_list = NULL,
3200 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3203 .label = "dmapi support",
3204 .type = P_BOOL,
3205 .p_class = P_LOCAL,
3206 .ptr = &sDefault.bDmapiSupport,
3207 .special = NULL,
3208 .enum_list = NULL,
3209 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3213 {N_("Domain Options"), P_SEP, P_SEPARATOR},
3216 .label = "machine password timeout",
3217 .type = P_INTEGER,
3218 .p_class = P_GLOBAL,
3219 .ptr = &Globals.machine_password_timeout,
3220 .special = NULL,
3221 .enum_list = NULL,
3222 .flags = FLAG_ADVANCED | FLAG_WIZARD,
3225 {N_("Logon Options"), P_SEP, P_SEPARATOR},
3228 .label = "add user script",
3229 .type = P_STRING,
3230 .p_class = P_GLOBAL,
3231 .ptr = &Globals.szAddUserScript,
3232 .special = NULL,
3233 .enum_list = NULL,
3234 .flags = FLAG_ADVANCED,
3237 .label = "rename user script",
3238 .type = P_STRING,
3239 .p_class = P_GLOBAL,
3240 .ptr = &Globals.szRenameUserScript,
3241 .special = NULL,
3242 .enum_list = NULL,
3243 .flags = FLAG_ADVANCED,
3246 .label = "delete user script",
3247 .type = P_STRING,
3248 .p_class = P_GLOBAL,
3249 .ptr = &Globals.szDelUserScript,
3250 .special = NULL,
3251 .enum_list = NULL,
3252 .flags = FLAG_ADVANCED,
3255 .label = "add group script",
3256 .type = P_STRING,
3257 .p_class = P_GLOBAL,
3258 .ptr = &Globals.szAddGroupScript,
3259 .special = NULL,
3260 .enum_list = NULL,
3261 .flags = FLAG_ADVANCED,
3264 .label = "delete group script",
3265 .type = P_STRING,
3266 .p_class = P_GLOBAL,
3267 .ptr = &Globals.szDelGroupScript,
3268 .special = NULL,
3269 .enum_list = NULL,
3270 .flags = FLAG_ADVANCED,
3273 .label = "add user to group script",
3274 .type = P_STRING,
3275 .p_class = P_GLOBAL,
3276 .ptr = &Globals.szAddUserToGroupScript,
3277 .special = NULL,
3278 .enum_list = NULL,
3279 .flags = FLAG_ADVANCED,
3282 .label = "delete user from group script",
3283 .type = P_STRING,
3284 .p_class = P_GLOBAL,
3285 .ptr = &Globals.szDelUserFromGroupScript,
3286 .special = NULL,
3287 .enum_list = NULL,
3288 .flags = FLAG_ADVANCED,
3291 .label = "set primary group script",
3292 .type = P_STRING,
3293 .p_class = P_GLOBAL,
3294 .ptr = &Globals.szSetPrimaryGroupScript,
3295 .special = NULL,
3296 .enum_list = NULL,
3297 .flags = FLAG_ADVANCED,
3300 .label = "add machine script",
3301 .type = P_STRING,
3302 .p_class = P_GLOBAL,
3303 .ptr = &Globals.szAddMachineScript,
3304 .special = NULL,
3305 .enum_list = NULL,
3306 .flags = FLAG_ADVANCED,
3309 .label = "shutdown script",
3310 .type = P_STRING,
3311 .p_class = P_GLOBAL,
3312 .ptr = &Globals.szShutdownScript,
3313 .special = NULL,
3314 .enum_list = NULL,
3315 .flags = FLAG_ADVANCED,
3318 .label = "abort shutdown script",
3319 .type = P_STRING,
3320 .p_class = P_GLOBAL,
3321 .ptr = &Globals.szAbortShutdownScript,
3322 .special = NULL,
3323 .enum_list = NULL,
3324 .flags = FLAG_ADVANCED,
3327 .label = "username map script",
3328 .type = P_STRING,
3329 .p_class = P_GLOBAL,
3330 .ptr = &Globals.szUsernameMapScript,
3331 .special = NULL,
3332 .enum_list = NULL,
3333 .flags = FLAG_ADVANCED,
3336 .label = "username map cache time",
3337 .type = P_INTEGER,
3338 .p_class = P_GLOBAL,
3339 .ptr = &Globals.iUsernameMapCacheTime,
3340 .special = NULL,
3341 .enum_list = NULL,
3342 .flags = FLAG_ADVANCED,
3345 .label = "logon script",
3346 .type = P_STRING,
3347 .p_class = P_GLOBAL,
3348 .ptr = &Globals.szLogonScript,
3349 .special = NULL,
3350 .enum_list = NULL,
3351 .flags = FLAG_ADVANCED,
3354 .label = "logon path",
3355 .type = P_STRING,
3356 .p_class = P_GLOBAL,
3357 .ptr = &Globals.szLogonPath,
3358 .special = NULL,
3359 .enum_list = NULL,
3360 .flags = FLAG_ADVANCED,
3363 .label = "logon drive",
3364 .type = P_STRING,
3365 .p_class = P_GLOBAL,
3366 .ptr = &Globals.szLogonDrive,
3367 .special = NULL,
3368 .enum_list = NULL,
3369 .flags = FLAG_ADVANCED,
3372 .label = "logon home",
3373 .type = P_STRING,
3374 .p_class = P_GLOBAL,
3375 .ptr = &Globals.szLogonHome,
3376 .special = NULL,
3377 .enum_list = NULL,
3378 .flags = FLAG_ADVANCED,
3381 .label = "domain logons",
3382 .type = P_BOOL,
3383 .p_class = P_GLOBAL,
3384 .ptr = &Globals.bDomainLogons,
3385 .special = NULL,
3386 .enum_list = NULL,
3387 .flags = FLAG_ADVANCED,
3391 .label = "init logon delayed hosts",
3392 .type = P_LIST,
3393 .p_class = P_GLOBAL,
3394 .ptr = &Globals.szInitLogonDelayedHosts,
3395 .special = NULL,
3396 .enum_list = NULL,
3397 .flags = FLAG_ADVANCED,
3401 .label = "init logon delay",
3402 .type = P_INTEGER,
3403 .p_class = P_GLOBAL,
3404 .ptr = &Globals.InitLogonDelay,
3405 .special = NULL,
3406 .enum_list = NULL,
3407 .flags = FLAG_ADVANCED,
3411 {N_("Browse Options"), P_SEP, P_SEPARATOR},
3414 .label = "os level",
3415 .type = P_INTEGER,
3416 .p_class = P_GLOBAL,
3417 .ptr = &Globals.os_level,
3418 .special = NULL,
3419 .enum_list = NULL,
3420 .flags = FLAG_BASIC | FLAG_ADVANCED,
3423 .label = "lm announce",
3424 .type = P_ENUM,
3425 .p_class = P_GLOBAL,
3426 .ptr = &Globals.lm_announce,
3427 .special = NULL,
3428 .enum_list = enum_bool_auto,
3429 .flags = FLAG_ADVANCED,
3432 .label = "lm interval",
3433 .type = P_INTEGER,
3434 .p_class = P_GLOBAL,
3435 .ptr = &Globals.lm_interval,
3436 .special = NULL,
3437 .enum_list = NULL,
3438 .flags = FLAG_ADVANCED,
3441 .label = "preferred master",
3442 .type = P_ENUM,
3443 .p_class = P_GLOBAL,
3444 .ptr = &Globals.iPreferredMaster,
3445 .special = NULL,
3446 .enum_list = enum_bool_auto,
3447 .flags = FLAG_BASIC | FLAG_ADVANCED,
3450 .label = "prefered master",
3451 .type = P_ENUM,
3452 .p_class = P_GLOBAL,
3453 .ptr = &Globals.iPreferredMaster,
3454 .special = NULL,
3455 .enum_list = enum_bool_auto,
3456 .flags = FLAG_HIDE,
3459 .label = "local master",
3460 .type = P_BOOL,
3461 .p_class = P_GLOBAL,
3462 .ptr = &Globals.bLocalMaster,
3463 .special = NULL,
3464 .enum_list = NULL,
3465 .flags = FLAG_BASIC | FLAG_ADVANCED,
3468 .label = "domain master",
3469 .type = P_ENUM,
3470 .p_class = P_GLOBAL,
3471 .ptr = &Globals.iDomainMaster,
3472 .special = NULL,
3473 .enum_list = enum_bool_auto,
3474 .flags = FLAG_BASIC | FLAG_ADVANCED,
3477 .label = "browse list",
3478 .type = P_BOOL,
3479 .p_class = P_GLOBAL,
3480 .ptr = &Globals.bBrowseList,
3481 .special = NULL,
3482 .enum_list = NULL,
3483 .flags = FLAG_ADVANCED,
3486 .label = "browseable",
3487 .type = P_BOOL,
3488 .p_class = P_LOCAL,
3489 .ptr = &sDefault.bBrowseable,
3490 .special = NULL,
3491 .enum_list = NULL,
3492 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3495 .label = "browsable",
3496 .type = P_BOOL,
3497 .p_class = P_LOCAL,
3498 .ptr = &sDefault.bBrowseable,
3499 .special = NULL,
3500 .enum_list = NULL,
3501 .flags = FLAG_HIDE,
3504 .label = "access based share enum",
3505 .type = P_BOOL,
3506 .p_class = P_LOCAL,
3507 .ptr = &sDefault.bAccessBasedShareEnum,
3508 .special = NULL,
3509 .enum_list = NULL,
3510 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3513 .label = "enhanced browsing",
3514 .type = P_BOOL,
3515 .p_class = P_GLOBAL,
3516 .ptr = &Globals.enhanced_browsing,
3517 .special = NULL,
3518 .enum_list = NULL,
3519 .flags = FLAG_ADVANCED,
3522 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3525 .label = "dns proxy",
3526 .type = P_BOOL,
3527 .p_class = P_GLOBAL,
3528 .ptr = &Globals.bDNSproxy,
3529 .special = NULL,
3530 .enum_list = NULL,
3531 .flags = FLAG_ADVANCED,
3534 .label = "wins proxy",
3535 .type = P_BOOL,
3536 .p_class = P_GLOBAL,
3537 .ptr = &Globals.bWINSproxy,
3538 .special = NULL,
3539 .enum_list = NULL,
3540 .flags = FLAG_ADVANCED,
3543 .label = "wins server",
3544 .type = P_LIST,
3545 .p_class = P_GLOBAL,
3546 .ptr = &Globals.szWINSservers,
3547 .special = NULL,
3548 .enum_list = NULL,
3549 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3552 .label = "wins support",
3553 .type = P_BOOL,
3554 .p_class = P_GLOBAL,
3555 .ptr = &Globals.bWINSsupport,
3556 .special = NULL,
3557 .enum_list = NULL,
3558 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3561 .label = "wins hook",
3562 .type = P_STRING,
3563 .p_class = P_GLOBAL,
3564 .ptr = &Globals.szWINSHook,
3565 .special = NULL,
3566 .enum_list = NULL,
3567 .flags = FLAG_ADVANCED,
3570 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3573 .label = "blocking locks",
3574 .type = P_BOOL,
3575 .p_class = P_LOCAL,
3576 .ptr = &sDefault.bBlockingLocks,
3577 .special = NULL,
3578 .enum_list = NULL,
3579 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3582 .label = "csc policy",
3583 .type = P_ENUM,
3584 .p_class = P_LOCAL,
3585 .ptr = &sDefault.iCSCPolicy,
3586 .special = NULL,
3587 .enum_list = enum_csc_policy,
3588 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3591 .label = "fake oplocks",
3592 .type = P_BOOL,
3593 .p_class = P_LOCAL,
3594 .ptr = &sDefault.bFakeOplocks,
3595 .special = NULL,
3596 .enum_list = NULL,
3597 .flags = FLAG_ADVANCED | FLAG_SHARE,
3600 .label = "kernel oplocks",
3601 .type = P_BOOL,
3602 .p_class = P_GLOBAL,
3603 .ptr = &Globals.bKernelOplocks,
3604 .special = NULL,
3605 .enum_list = NULL,
3606 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3609 .label = "locking",
3610 .type = P_BOOL,
3611 .p_class = P_LOCAL,
3612 .ptr = &sDefault.bLocking,
3613 .special = NULL,
3614 .enum_list = NULL,
3615 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3618 .label = "lock spin time",
3619 .type = P_INTEGER,
3620 .p_class = P_GLOBAL,
3621 .ptr = &Globals.iLockSpinTime,
3622 .special = NULL,
3623 .enum_list = NULL,
3624 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3627 .label = "oplocks",
3628 .type = P_BOOL,
3629 .p_class = P_LOCAL,
3630 .ptr = &sDefault.bOpLocks,
3631 .special = NULL,
3632 .enum_list = NULL,
3633 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3636 .label = "level2 oplocks",
3637 .type = P_BOOL,
3638 .p_class = P_LOCAL,
3639 .ptr = &sDefault.bLevel2OpLocks,
3640 .special = NULL,
3641 .enum_list = NULL,
3642 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3645 .label = "oplock break wait time",
3646 .type = P_INTEGER,
3647 .p_class = P_GLOBAL,
3648 .ptr = &Globals.oplock_break_wait_time,
3649 .special = NULL,
3650 .enum_list = NULL,
3651 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3654 .label = "oplock contention limit",
3655 .type = P_INTEGER,
3656 .p_class = P_LOCAL,
3657 .ptr = &sDefault.iOplockContentionLimit,
3658 .special = NULL,
3659 .enum_list = NULL,
3660 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3663 .label = "posix locking",
3664 .type = P_BOOL,
3665 .p_class = P_LOCAL,
3666 .ptr = &sDefault.bPosixLocking,
3667 .special = NULL,
3668 .enum_list = NULL,
3669 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3672 .label = "strict locking",
3673 .type = P_ENUM,
3674 .p_class = P_LOCAL,
3675 .ptr = &sDefault.iStrictLocking,
3676 .special = NULL,
3677 .enum_list = enum_bool_auto,
3678 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3681 .label = "share modes",
3682 .type = P_BOOL,
3683 .p_class = P_LOCAL,
3684 .ptr = &sDefault.bShareModes,
3685 .special = NULL,
3686 .enum_list = NULL,
3687 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3690 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3693 .label = "ldap admin dn",
3694 .type = P_STRING,
3695 .p_class = P_GLOBAL,
3696 .ptr = &Globals.szLdapAdminDn,
3697 .special = NULL,
3698 .enum_list = NULL,
3699 .flags = FLAG_ADVANCED,
3702 .label = "ldap delete dn",
3703 .type = P_BOOL,
3704 .p_class = P_GLOBAL,
3705 .ptr = &Globals.ldap_delete_dn,
3706 .special = NULL,
3707 .enum_list = NULL,
3708 .flags = FLAG_ADVANCED,
3711 .label = "ldap group suffix",
3712 .type = P_STRING,
3713 .p_class = P_GLOBAL,
3714 .ptr = &Globals.szLdapGroupSuffix,
3715 .special = NULL,
3716 .enum_list = NULL,
3717 .flags = FLAG_ADVANCED,
3720 .label = "ldap idmap suffix",
3721 .type = P_STRING,
3722 .p_class = P_GLOBAL,
3723 .ptr = &Globals.szLdapIdmapSuffix,
3724 .special = NULL,
3725 .enum_list = NULL,
3726 .flags = FLAG_ADVANCED,
3729 .label = "ldap machine suffix",
3730 .type = P_STRING,
3731 .p_class = P_GLOBAL,
3732 .ptr = &Globals.szLdapMachineSuffix,
3733 .special = NULL,
3734 .enum_list = NULL,
3735 .flags = FLAG_ADVANCED,
3738 .label = "ldap passwd sync",
3739 .type = P_ENUM,
3740 .p_class = P_GLOBAL,
3741 .ptr = &Globals.ldap_passwd_sync,
3742 .special = NULL,
3743 .enum_list = enum_ldap_passwd_sync,
3744 .flags = FLAG_ADVANCED,
3747 .label = "ldap password sync",
3748 .type = P_ENUM,
3749 .p_class = P_GLOBAL,
3750 .ptr = &Globals.ldap_passwd_sync,
3751 .special = NULL,
3752 .enum_list = enum_ldap_passwd_sync,
3753 .flags = FLAG_HIDE,
3756 .label = "ldap replication sleep",
3757 .type = P_INTEGER,
3758 .p_class = P_GLOBAL,
3759 .ptr = &Globals.ldap_replication_sleep,
3760 .special = NULL,
3761 .enum_list = NULL,
3762 .flags = FLAG_ADVANCED,
3765 .label = "ldap suffix",
3766 .type = P_STRING,
3767 .p_class = P_GLOBAL,
3768 .ptr = &Globals.szLdapSuffix,
3769 .special = NULL,
3770 .enum_list = NULL,
3771 .flags = FLAG_ADVANCED,
3774 .label = "ldap ssl",
3775 .type = P_ENUM,
3776 .p_class = P_GLOBAL,
3777 .ptr = &Globals.ldap_ssl,
3778 .special = NULL,
3779 .enum_list = enum_ldap_ssl,
3780 .flags = FLAG_ADVANCED,
3783 .label = "ldap ssl ads",
3784 .type = P_BOOL,
3785 .p_class = P_GLOBAL,
3786 .ptr = &Globals.ldap_ssl_ads,
3787 .special = NULL,
3788 .enum_list = NULL,
3789 .flags = FLAG_ADVANCED,
3792 .label = "ldap deref",
3793 .type = P_ENUM,
3794 .p_class = P_GLOBAL,
3795 .ptr = &Globals.ldap_deref,
3796 .special = NULL,
3797 .enum_list = enum_ldap_deref,
3798 .flags = FLAG_ADVANCED,
3801 .label = "ldap follow referral",
3802 .type = P_ENUM,
3803 .p_class = P_GLOBAL,
3804 .ptr = &Globals.ldap_follow_referral,
3805 .special = NULL,
3806 .enum_list = enum_bool_auto,
3807 .flags = FLAG_ADVANCED,
3810 .label = "ldap timeout",
3811 .type = P_INTEGER,
3812 .p_class = P_GLOBAL,
3813 .ptr = &Globals.ldap_timeout,
3814 .special = NULL,
3815 .enum_list = NULL,
3816 .flags = FLAG_ADVANCED,
3819 .label = "ldap connection timeout",
3820 .type = P_INTEGER,
3821 .p_class = P_GLOBAL,
3822 .ptr = &Globals.ldap_connection_timeout,
3823 .special = NULL,
3824 .enum_list = NULL,
3825 .flags = FLAG_ADVANCED,
3828 .label = "ldap page size",
3829 .type = P_INTEGER,
3830 .p_class = P_GLOBAL,
3831 .ptr = &Globals.ldap_page_size,
3832 .special = NULL,
3833 .enum_list = NULL,
3834 .flags = FLAG_ADVANCED,
3837 .label = "ldap user suffix",
3838 .type = P_STRING,
3839 .p_class = P_GLOBAL,
3840 .ptr = &Globals.szLdapUserSuffix,
3841 .special = NULL,
3842 .enum_list = NULL,
3843 .flags = FLAG_ADVANCED,
3846 .label = "ldap debug level",
3847 .type = P_INTEGER,
3848 .p_class = P_GLOBAL,
3849 .ptr = &Globals.ldap_debug_level,
3850 .special = handle_ldap_debug_level,
3851 .enum_list = NULL,
3852 .flags = FLAG_ADVANCED,
3855 .label = "ldap debug threshold",
3856 .type = P_INTEGER,
3857 .p_class = P_GLOBAL,
3858 .ptr = &Globals.ldap_debug_threshold,
3859 .special = NULL,
3860 .enum_list = NULL,
3861 .flags = FLAG_ADVANCED,
3864 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3867 .label = "eventlog list",
3868 .type = P_LIST,
3869 .p_class = P_GLOBAL,
3870 .ptr = &Globals.szEventLogs,
3871 .special = NULL,
3872 .enum_list = NULL,
3873 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3876 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3879 .label = "add share command",
3880 .type = P_STRING,
3881 .p_class = P_GLOBAL,
3882 .ptr = &Globals.szAddShareCommand,
3883 .special = NULL,
3884 .enum_list = NULL,
3885 .flags = FLAG_ADVANCED,
3888 .label = "change share command",
3889 .type = P_STRING,
3890 .p_class = P_GLOBAL,
3891 .ptr = &Globals.szChangeShareCommand,
3892 .special = NULL,
3893 .enum_list = NULL,
3894 .flags = FLAG_ADVANCED,
3897 .label = "delete share command",
3898 .type = P_STRING,
3899 .p_class = P_GLOBAL,
3900 .ptr = &Globals.szDeleteShareCommand,
3901 .special = NULL,
3902 .enum_list = NULL,
3903 .flags = FLAG_ADVANCED,
3906 .label = "config file",
3907 .type = P_STRING,
3908 .p_class = P_GLOBAL,
3909 .ptr = &Globals.szConfigFile,
3910 .special = NULL,
3911 .enum_list = NULL,
3912 .flags = FLAG_HIDE|FLAG_META,
3915 .label = "preload",
3916 .type = P_STRING,
3917 .p_class = P_GLOBAL,
3918 .ptr = &Globals.szAutoServices,
3919 .special = NULL,
3920 .enum_list = NULL,
3921 .flags = FLAG_ADVANCED,
3924 .label = "auto services",
3925 .type = P_STRING,
3926 .p_class = P_GLOBAL,
3927 .ptr = &Globals.szAutoServices,
3928 .special = NULL,
3929 .enum_list = NULL,
3930 .flags = FLAG_ADVANCED,
3933 .label = "lock directory",
3934 .type = P_STRING,
3935 .p_class = P_GLOBAL,
3936 .ptr = &Globals.szLockDir,
3937 .special = NULL,
3938 .enum_list = NULL,
3939 .flags = FLAG_ADVANCED,
3942 .label = "lock dir",
3943 .type = P_STRING,
3944 .p_class = P_GLOBAL,
3945 .ptr = &Globals.szLockDir,
3946 .special = NULL,
3947 .enum_list = NULL,
3948 .flags = FLAG_HIDE,
3951 .label = "state directory",
3952 .type = P_STRING,
3953 .p_class = P_GLOBAL,
3954 .ptr = &Globals.szStateDir,
3955 .special = NULL,
3956 .enum_list = NULL,
3957 .flags = FLAG_ADVANCED,
3960 .label = "cache directory",
3961 .type = P_STRING,
3962 .p_class = P_GLOBAL,
3963 .ptr = &Globals.szCacheDir,
3964 .special = NULL,
3965 .enum_list = NULL,
3966 .flags = FLAG_ADVANCED,
3969 .label = "pid directory",
3970 .type = P_STRING,
3971 .p_class = P_GLOBAL,
3972 .ptr = &Globals.szPidDir,
3973 .special = NULL,
3974 .enum_list = NULL,
3975 .flags = FLAG_ADVANCED,
3977 #ifdef WITH_UTMP
3979 .label = "utmp directory",
3980 .type = P_STRING,
3981 .p_class = P_GLOBAL,
3982 .ptr = &Globals.szUtmpDir,
3983 .special = NULL,
3984 .enum_list = NULL,
3985 .flags = FLAG_ADVANCED,
3988 .label = "wtmp directory",
3989 .type = P_STRING,
3990 .p_class = P_GLOBAL,
3991 .ptr = &Globals.szWtmpDir,
3992 .special = NULL,
3993 .enum_list = NULL,
3994 .flags = FLAG_ADVANCED,
3997 .label = "utmp",
3998 .type = P_BOOL,
3999 .p_class = P_GLOBAL,
4000 .ptr = &Globals.bUtmp,
4001 .special = NULL,
4002 .enum_list = NULL,
4003 .flags = FLAG_ADVANCED,
4005 #endif
4007 .label = "default service",
4008 .type = P_STRING,
4009 .p_class = P_GLOBAL,
4010 .ptr = &Globals.szDefaultService,
4011 .special = NULL,
4012 .enum_list = NULL,
4013 .flags = FLAG_ADVANCED,
4016 .label = "default",
4017 .type = P_STRING,
4018 .p_class = P_GLOBAL,
4019 .ptr = &Globals.szDefaultService,
4020 .special = NULL,
4021 .enum_list = NULL,
4022 .flags = FLAG_ADVANCED,
4025 .label = "message command",
4026 .type = P_STRING,
4027 .p_class = P_GLOBAL,
4028 .ptr = &Globals.szMsgCommand,
4029 .special = NULL,
4030 .enum_list = NULL,
4031 .flags = FLAG_ADVANCED,
4034 .label = "dfree cache time",
4035 .type = P_INTEGER,
4036 .p_class = P_LOCAL,
4037 .ptr = &sDefault.iDfreeCacheTime,
4038 .special = NULL,
4039 .enum_list = NULL,
4040 .flags = FLAG_ADVANCED,
4043 .label = "dfree command",
4044 .type = P_STRING,
4045 .p_class = P_LOCAL,
4046 .ptr = &sDefault.szDfree,
4047 .special = NULL,
4048 .enum_list = NULL,
4049 .flags = FLAG_ADVANCED,
4052 .label = "get quota command",
4053 .type = P_STRING,
4054 .p_class = P_GLOBAL,
4055 .ptr = &Globals.szGetQuota,
4056 .special = NULL,
4057 .enum_list = NULL,
4058 .flags = FLAG_ADVANCED,
4061 .label = "set quota command",
4062 .type = P_STRING,
4063 .p_class = P_GLOBAL,
4064 .ptr = &Globals.szSetQuota,
4065 .special = NULL,
4066 .enum_list = NULL,
4067 .flags = FLAG_ADVANCED,
4070 .label = "remote announce",
4071 .type = P_STRING,
4072 .p_class = P_GLOBAL,
4073 .ptr = &Globals.szRemoteAnnounce,
4074 .special = NULL,
4075 .enum_list = NULL,
4076 .flags = FLAG_ADVANCED,
4079 .label = "remote browse sync",
4080 .type = P_STRING,
4081 .p_class = P_GLOBAL,
4082 .ptr = &Globals.szRemoteBrowseSync,
4083 .special = NULL,
4084 .enum_list = NULL,
4085 .flags = FLAG_ADVANCED,
4088 .label = "socket address",
4089 .type = P_STRING,
4090 .p_class = P_GLOBAL,
4091 .ptr = &Globals.szSocketAddress,
4092 .special = NULL,
4093 .enum_list = NULL,
4094 .flags = FLAG_ADVANCED,
4097 .label = "nmbd bind explicit broadcast",
4098 .type = P_BOOL,
4099 .p_class = P_GLOBAL,
4100 .ptr = &Globals.bNmbdBindExplicitBroadcast,
4101 .special = NULL,
4102 .enum_list = NULL,
4103 .flags = FLAG_ADVANCED,
4106 .label = "homedir map",
4107 .type = P_STRING,
4108 .p_class = P_GLOBAL,
4109 .ptr = &Globals.szNISHomeMapName,
4110 .special = NULL,
4111 .enum_list = NULL,
4112 .flags = FLAG_ADVANCED,
4115 .label = "afs username map",
4116 .type = P_STRING,
4117 .p_class = P_GLOBAL,
4118 .ptr = &Globals.szAfsUsernameMap,
4119 .special = NULL,
4120 .enum_list = NULL,
4121 .flags = FLAG_ADVANCED,
4124 .label = "afs token lifetime",
4125 .type = P_INTEGER,
4126 .p_class = P_GLOBAL,
4127 .ptr = &Globals.iAfsTokenLifetime,
4128 .special = NULL,
4129 .enum_list = NULL,
4130 .flags = FLAG_ADVANCED,
4133 .label = "log nt token command",
4134 .type = P_STRING,
4135 .p_class = P_GLOBAL,
4136 .ptr = &Globals.szLogNtTokenCommand,
4137 .special = NULL,
4138 .enum_list = NULL,
4139 .flags = FLAG_ADVANCED,
4142 .label = "time offset",
4143 .type = P_INTEGER,
4144 .p_class = P_GLOBAL,
4145 .ptr = &extra_time_offset,
4146 .special = NULL,
4147 .enum_list = NULL,
4148 .flags = FLAG_ADVANCED,
4151 .label = "NIS homedir",
4152 .type = P_BOOL,
4153 .p_class = P_GLOBAL,
4154 .ptr = &Globals.bNISHomeMap,
4155 .special = NULL,
4156 .enum_list = NULL,
4157 .flags = FLAG_ADVANCED,
4160 .label = "-valid",
4161 .type = P_BOOL,
4162 .p_class = P_LOCAL,
4163 .ptr = &sDefault.valid,
4164 .special = NULL,
4165 .enum_list = NULL,
4166 .flags = FLAG_HIDE,
4169 .label = "copy",
4170 .type = P_STRING,
4171 .p_class = P_LOCAL,
4172 .ptr = &sDefault.szCopy,
4173 .special = handle_copy,
4174 .enum_list = NULL,
4175 .flags = FLAG_HIDE,
4178 .label = "include",
4179 .type = P_STRING,
4180 .p_class = P_LOCAL,
4181 .ptr = &sDefault.szInclude,
4182 .special = handle_include,
4183 .enum_list = NULL,
4184 .flags = FLAG_HIDE|FLAG_META,
4187 .label = "preexec",
4188 .type = P_STRING,
4189 .p_class = P_LOCAL,
4190 .ptr = &sDefault.szPreExec,
4191 .special = NULL,
4192 .enum_list = NULL,
4193 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4196 .label = "exec",
4197 .type = P_STRING,
4198 .p_class = P_LOCAL,
4199 .ptr = &sDefault.szPreExec,
4200 .special = NULL,
4201 .enum_list = NULL,
4202 .flags = FLAG_ADVANCED,
4205 .label = "preexec close",
4206 .type = P_BOOL,
4207 .p_class = P_LOCAL,
4208 .ptr = &sDefault.bPreexecClose,
4209 .special = NULL,
4210 .enum_list = NULL,
4211 .flags = FLAG_ADVANCED | FLAG_SHARE,
4214 .label = "postexec",
4215 .type = P_STRING,
4216 .p_class = P_LOCAL,
4217 .ptr = &sDefault.szPostExec,
4218 .special = NULL,
4219 .enum_list = NULL,
4220 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4223 .label = "root preexec",
4224 .type = P_STRING,
4225 .p_class = P_LOCAL,
4226 .ptr = &sDefault.szRootPreExec,
4227 .special = NULL,
4228 .enum_list = NULL,
4229 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4232 .label = "root preexec close",
4233 .type = P_BOOL,
4234 .p_class = P_LOCAL,
4235 .ptr = &sDefault.bRootpreexecClose,
4236 .special = NULL,
4237 .enum_list = NULL,
4238 .flags = FLAG_ADVANCED | FLAG_SHARE,
4241 .label = "root postexec",
4242 .type = P_STRING,
4243 .p_class = P_LOCAL,
4244 .ptr = &sDefault.szRootPostExec,
4245 .special = NULL,
4246 .enum_list = NULL,
4247 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4250 .label = "available",
4251 .type = P_BOOL,
4252 .p_class = P_LOCAL,
4253 .ptr = &sDefault.bAvailable,
4254 .special = NULL,
4255 .enum_list = NULL,
4256 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4259 .label = "registry shares",
4260 .type = P_BOOL,
4261 .p_class = P_GLOBAL,
4262 .ptr = &Globals.bRegistryShares,
4263 .special = NULL,
4264 .enum_list = NULL,
4265 .flags = FLAG_ADVANCED,
4268 .label = "usershare allow guests",
4269 .type = P_BOOL,
4270 .p_class = P_GLOBAL,
4271 .ptr = &Globals.bUsershareAllowGuests,
4272 .special = NULL,
4273 .enum_list = NULL,
4274 .flags = FLAG_ADVANCED,
4277 .label = "usershare max shares",
4278 .type = P_INTEGER,
4279 .p_class = P_GLOBAL,
4280 .ptr = &Globals.iUsershareMaxShares,
4281 .special = NULL,
4282 .enum_list = NULL,
4283 .flags = FLAG_ADVANCED,
4286 .label = "usershare owner only",
4287 .type = P_BOOL,
4288 .p_class = P_GLOBAL,
4289 .ptr = &Globals.bUsershareOwnerOnly,
4290 .special = NULL,
4291 .enum_list = NULL,
4292 .flags = FLAG_ADVANCED,
4295 .label = "usershare path",
4296 .type = P_STRING,
4297 .p_class = P_GLOBAL,
4298 .ptr = &Globals.szUsersharePath,
4299 .special = NULL,
4300 .enum_list = NULL,
4301 .flags = FLAG_ADVANCED,
4304 .label = "usershare prefix allow list",
4305 .type = P_LIST,
4306 .p_class = P_GLOBAL,
4307 .ptr = &Globals.szUsersharePrefixAllowList,
4308 .special = NULL,
4309 .enum_list = NULL,
4310 .flags = FLAG_ADVANCED,
4313 .label = "usershare prefix deny list",
4314 .type = P_LIST,
4315 .p_class = P_GLOBAL,
4316 .ptr = &Globals.szUsersharePrefixDenyList,
4317 .special = NULL,
4318 .enum_list = NULL,
4319 .flags = FLAG_ADVANCED,
4322 .label = "usershare template share",
4323 .type = P_STRING,
4324 .p_class = P_GLOBAL,
4325 .ptr = &Globals.szUsershareTemplateShare,
4326 .special = NULL,
4327 .enum_list = NULL,
4328 .flags = FLAG_ADVANCED,
4331 .label = "volume",
4332 .type = P_STRING,
4333 .p_class = P_LOCAL,
4334 .ptr = &sDefault.volume,
4335 .special = NULL,
4336 .enum_list = NULL,
4337 .flags = FLAG_ADVANCED | FLAG_SHARE,
4340 .label = "fstype",
4341 .type = P_STRING,
4342 .p_class = P_LOCAL,
4343 .ptr = &sDefault.fstype,
4344 .special = NULL,
4345 .enum_list = NULL,
4346 .flags = FLAG_ADVANCED | FLAG_SHARE,
4349 .label = "set directory",
4350 .type = P_BOOLREV,
4351 .p_class = P_LOCAL,
4352 .ptr = &sDefault.bNo_set_dir,
4353 .special = NULL,
4354 .enum_list = NULL,
4355 .flags = FLAG_ADVANCED | FLAG_SHARE,
4358 .label = "wide links",
4359 .type = P_BOOL,
4360 .p_class = P_LOCAL,
4361 .ptr = &sDefault.bWidelinks,
4362 .special = NULL,
4363 .enum_list = NULL,
4364 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4367 .label = "follow symlinks",
4368 .type = P_BOOL,
4369 .p_class = P_LOCAL,
4370 .ptr = &sDefault.bSymlinks,
4371 .special = NULL,
4372 .enum_list = NULL,
4373 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4376 .label = "dont descend",
4377 .type = P_STRING,
4378 .p_class = P_LOCAL,
4379 .ptr = &sDefault.szDontdescend,
4380 .special = NULL,
4381 .enum_list = NULL,
4382 .flags = FLAG_ADVANCED | FLAG_SHARE,
4385 .label = "magic script",
4386 .type = P_STRING,
4387 .p_class = P_LOCAL,
4388 .ptr = &sDefault.szMagicScript,
4389 .special = NULL,
4390 .enum_list = NULL,
4391 .flags = FLAG_ADVANCED | FLAG_SHARE,
4394 .label = "magic output",
4395 .type = P_STRING,
4396 .p_class = P_LOCAL,
4397 .ptr = &sDefault.szMagicOutput,
4398 .special = NULL,
4399 .enum_list = NULL,
4400 .flags = FLAG_ADVANCED | FLAG_SHARE,
4403 .label = "delete readonly",
4404 .type = P_BOOL,
4405 .p_class = P_LOCAL,
4406 .ptr = &sDefault.bDeleteReadonly,
4407 .special = NULL,
4408 .enum_list = NULL,
4409 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4412 .label = "dos filemode",
4413 .type = P_BOOL,
4414 .p_class = P_LOCAL,
4415 .ptr = &sDefault.bDosFilemode,
4416 .special = NULL,
4417 .enum_list = NULL,
4418 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4421 .label = "dos filetimes",
4422 .type = P_BOOL,
4423 .p_class = P_LOCAL,
4424 .ptr = &sDefault.bDosFiletimes,
4425 .special = NULL,
4426 .enum_list = NULL,
4427 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4430 .label = "dos filetime resolution",
4431 .type = P_BOOL,
4432 .p_class = P_LOCAL,
4433 .ptr = &sDefault.bDosFiletimeResolution,
4434 .special = NULL,
4435 .enum_list = NULL,
4436 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4439 .label = "fake directory create times",
4440 .type = P_BOOL,
4441 .p_class = P_LOCAL,
4442 .ptr = &sDefault.bFakeDirCreateTimes,
4443 .special = NULL,
4444 .enum_list = NULL,
4445 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4448 .label = "async smb echo handler",
4449 .type = P_BOOL,
4450 .p_class = P_GLOBAL,
4451 .ptr = &Globals.bAsyncSMBEchoHandler,
4452 .special = NULL,
4453 .enum_list = NULL,
4454 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4457 .label = "multicast dns register",
4458 .type = P_BOOL,
4459 .p_class = P_GLOBAL,
4460 .ptr = &Globals.bMulticastDnsRegister,
4461 .special = NULL,
4462 .enum_list = NULL,
4463 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4466 .label = "panic action",
4467 .type = P_STRING,
4468 .p_class = P_GLOBAL,
4469 .ptr = &Globals.szPanicAction,
4470 .special = NULL,
4471 .enum_list = NULL,
4472 .flags = FLAG_ADVANCED,
4475 .label = "perfcount module",
4476 .type = P_STRING,
4477 .p_class = P_GLOBAL,
4478 .ptr = &Globals.szSMBPerfcountModule,
4479 .special = NULL,
4480 .enum_list = NULL,
4481 .flags = FLAG_ADVANCED,
4484 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4487 .label = "vfs objects",
4488 .type = P_LIST,
4489 .p_class = P_LOCAL,
4490 .ptr = &sDefault.szVfsObjects,
4491 .special = NULL,
4492 .enum_list = NULL,
4493 .flags = FLAG_ADVANCED | FLAG_SHARE,
4496 .label = "vfs object",
4497 .type = P_LIST,
4498 .p_class = P_LOCAL,
4499 .ptr = &sDefault.szVfsObjects,
4500 .special = NULL,
4501 .enum_list = NULL,
4502 .flags = FLAG_HIDE,
4506 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4509 .label = "msdfs root",
4510 .type = P_BOOL,
4511 .p_class = P_LOCAL,
4512 .ptr = &sDefault.bMSDfsRoot,
4513 .special = NULL,
4514 .enum_list = NULL,
4515 .flags = FLAG_ADVANCED | FLAG_SHARE,
4518 .label = "msdfs proxy",
4519 .type = P_STRING,
4520 .p_class = P_LOCAL,
4521 .ptr = &sDefault.szMSDfsProxy,
4522 .special = NULL,
4523 .enum_list = NULL,
4524 .flags = FLAG_ADVANCED | FLAG_SHARE,
4527 .label = "host msdfs",
4528 .type = P_BOOL,
4529 .p_class = P_GLOBAL,
4530 .ptr = &Globals.bHostMSDfs,
4531 .special = NULL,
4532 .enum_list = NULL,
4533 .flags = FLAG_ADVANCED,
4536 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4539 .label = "passdb expand explicit",
4540 .type = P_BOOL,
4541 .p_class = P_GLOBAL,
4542 .ptr = &Globals.bPassdbExpandExplicit,
4543 .special = NULL,
4544 .enum_list = NULL,
4545 .flags = FLAG_ADVANCED,
4548 .label = "idmap backend",
4549 .type = P_STRING,
4550 .p_class = P_GLOBAL,
4551 .ptr = &Globals.szIdmapBackend,
4552 .special = handle_idmap_backend,
4553 .enum_list = NULL,
4554 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4557 .label = "idmap cache time",
4558 .type = P_INTEGER,
4559 .p_class = P_GLOBAL,
4560 .ptr = &Globals.iIdmapCacheTime,
4561 .special = NULL,
4562 .enum_list = NULL,
4563 .flags = FLAG_ADVANCED,
4566 .label = "idmap negative cache time",
4567 .type = P_INTEGER,
4568 .p_class = P_GLOBAL,
4569 .ptr = &Globals.iIdmapNegativeCacheTime,
4570 .special = NULL,
4571 .enum_list = NULL,
4572 .flags = FLAG_ADVANCED,
4575 .label = "idmap uid",
4576 .type = P_STRING,
4577 .p_class = P_GLOBAL,
4578 .ptr = &Globals.szIdmapUID,
4579 .special = handle_idmap_uid,
4580 .enum_list = NULL,
4581 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4584 .label = "winbind uid",
4585 .type = P_STRING,
4586 .p_class = P_GLOBAL,
4587 .ptr = &Globals.szIdmapUID,
4588 .special = handle_idmap_uid,
4589 .enum_list = NULL,
4590 .flags = FLAG_HIDE,
4593 .label = "idmap gid",
4594 .type = P_STRING,
4595 .p_class = P_GLOBAL,
4596 .ptr = &Globals.szIdmapGID,
4597 .special = handle_idmap_gid,
4598 .enum_list = NULL,
4599 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
4602 .label = "winbind gid",
4603 .type = P_STRING,
4604 .p_class = P_GLOBAL,
4605 .ptr = &Globals.szIdmapGID,
4606 .special = handle_idmap_gid,
4607 .enum_list = NULL,
4608 .flags = FLAG_HIDE,
4611 .label = "template homedir",
4612 .type = P_STRING,
4613 .p_class = P_GLOBAL,
4614 .ptr = &Globals.szTemplateHomedir,
4615 .special = NULL,
4616 .enum_list = NULL,
4617 .flags = FLAG_ADVANCED,
4620 .label = "template shell",
4621 .type = P_STRING,
4622 .p_class = P_GLOBAL,
4623 .ptr = &Globals.szTemplateShell,
4624 .special = NULL,
4625 .enum_list = NULL,
4626 .flags = FLAG_ADVANCED,
4629 .label = "winbind separator",
4630 .type = P_STRING,
4631 .p_class = P_GLOBAL,
4632 .ptr = &Globals.szWinbindSeparator,
4633 .special = NULL,
4634 .enum_list = NULL,
4635 .flags = FLAG_ADVANCED,
4638 .label = "winbind cache time",
4639 .type = P_INTEGER,
4640 .p_class = P_GLOBAL,
4641 .ptr = &Globals.winbind_cache_time,
4642 .special = NULL,
4643 .enum_list = NULL,
4644 .flags = FLAG_ADVANCED,
4647 .label = "winbind reconnect delay",
4648 .type = P_INTEGER,
4649 .p_class = P_GLOBAL,
4650 .ptr = &Globals.winbind_reconnect_delay,
4651 .special = NULL,
4652 .enum_list = NULL,
4653 .flags = FLAG_ADVANCED,
4656 .label = "winbind max clients",
4657 .type = P_INTEGER,
4658 .p_class = P_GLOBAL,
4659 .ptr = &Globals.winbind_max_clients,
4660 .special = NULL,
4661 .enum_list = NULL,
4662 .flags = FLAG_ADVANCED,
4665 .label = "winbind enum users",
4666 .type = P_BOOL,
4667 .p_class = P_GLOBAL,
4668 .ptr = &Globals.bWinbindEnumUsers,
4669 .special = NULL,
4670 .enum_list = NULL,
4671 .flags = FLAG_ADVANCED,
4674 .label = "winbind enum groups",
4675 .type = P_BOOL,
4676 .p_class = P_GLOBAL,
4677 .ptr = &Globals.bWinbindEnumGroups,
4678 .special = NULL,
4679 .enum_list = NULL,
4680 .flags = FLAG_ADVANCED,
4683 .label = "winbind use default domain",
4684 .type = P_BOOL,
4685 .p_class = P_GLOBAL,
4686 .ptr = &Globals.bWinbindUseDefaultDomain,
4687 .special = NULL,
4688 .enum_list = NULL,
4689 .flags = FLAG_ADVANCED,
4692 .label = "winbind trusted domains only",
4693 .type = P_BOOL,
4694 .p_class = P_GLOBAL,
4695 .ptr = &Globals.bWinbindTrustedDomainsOnly,
4696 .special = NULL,
4697 .enum_list = NULL,
4698 .flags = FLAG_ADVANCED,
4701 .label = "winbind nested groups",
4702 .type = P_BOOL,
4703 .p_class = P_GLOBAL,
4704 .ptr = &Globals.bWinbindNestedGroups,
4705 .special = NULL,
4706 .enum_list = NULL,
4707 .flags = FLAG_ADVANCED,
4710 .label = "winbind expand groups",
4711 .type = P_INTEGER,
4712 .p_class = P_GLOBAL,
4713 .ptr = &Globals.winbind_expand_groups,
4714 .special = NULL,
4715 .enum_list = NULL,
4716 .flags = FLAG_ADVANCED,
4719 .label = "winbind nss info",
4720 .type = P_LIST,
4721 .p_class = P_GLOBAL,
4722 .ptr = &Globals.szWinbindNssInfo,
4723 .special = NULL,
4724 .enum_list = NULL,
4725 .flags = FLAG_ADVANCED,
4728 .label = "winbind refresh tickets",
4729 .type = P_BOOL,
4730 .p_class = P_GLOBAL,
4731 .ptr = &Globals.bWinbindRefreshTickets,
4732 .special = NULL,
4733 .enum_list = NULL,
4734 .flags = FLAG_ADVANCED,
4737 .label = "winbind offline logon",
4738 .type = P_BOOL,
4739 .p_class = P_GLOBAL,
4740 .ptr = &Globals.bWinbindOfflineLogon,
4741 .special = NULL,
4742 .enum_list = NULL,
4743 .flags = FLAG_ADVANCED,
4746 .label = "winbind normalize names",
4747 .type = P_BOOL,
4748 .p_class = P_GLOBAL,
4749 .ptr = &Globals.bWinbindNormalizeNames,
4750 .special = NULL,
4751 .enum_list = NULL,
4752 .flags = FLAG_ADVANCED,
4755 .label = "winbind rpc only",
4756 .type = P_BOOL,
4757 .p_class = P_GLOBAL,
4758 .ptr = &Globals.bWinbindRpcOnly,
4759 .special = NULL,
4760 .enum_list = NULL,
4761 .flags = FLAG_ADVANCED,
4764 .label = "create krb5 conf",
4765 .type = P_BOOL,
4766 .p_class = P_GLOBAL,
4767 .ptr = &Globals.bCreateKrb5Conf,
4768 .special = NULL,
4769 .enum_list = NULL,
4770 .flags = FLAG_ADVANCED,
4773 .label = "ncalrpc dir",
4774 .type = P_STRING,
4775 .p_class = P_GLOBAL,
4776 .ptr = &Globals.ncalrpc_dir,
4777 .special = NULL,
4778 .enum_list = NULL,
4779 .flags = FLAG_ADVANCED,
4782 .label = "winbind max domain connections",
4783 .type = P_INTEGER,
4784 .p_class = P_GLOBAL,
4785 .ptr = &Globals.winbindMaxDomainConnections,
4786 .special = NULL,
4787 .enum_list = NULL,
4788 .flags = FLAG_ADVANCED,
4791 {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
4794 /***************************************************************************
4795 Initialise the sDefault parameter structure for the printer values.
4796 ***************************************************************************/
4798 static void init_printer_values(struct service *pService)
4800 /* choose defaults depending on the type of printing */
4801 switch (pService->iPrinting) {
4802 case PRINT_BSD:
4803 case PRINT_AIX:
4804 case PRINT_LPRNT:
4805 case PRINT_LPROS2:
4806 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4807 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4808 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4809 break;
4811 case PRINT_LPRNG:
4812 case PRINT_PLP:
4813 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4814 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4815 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4816 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4817 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4818 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4819 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4820 break;
4822 case PRINT_CUPS:
4823 case PRINT_IPRINT:
4824 #ifdef HAVE_CUPS
4825 /* set the lpq command to contain the destination printer
4826 name only. This is used by cups_queue_get() */
4827 string_set(&pService->szLpqcommand, "%p");
4828 string_set(&pService->szLprmcommand, "");
4829 string_set(&pService->szPrintcommand, "");
4830 string_set(&pService->szLppausecommand, "");
4831 string_set(&pService->szLpresumecommand, "");
4832 string_set(&pService->szQueuepausecommand, "");
4833 string_set(&pService->szQueueresumecommand, "");
4834 #else
4835 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4836 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4837 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4838 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4839 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4840 string_set(&pService->szQueuepausecommand, "disable '%p'");
4841 string_set(&pService->szQueueresumecommand, "enable '%p'");
4842 #endif /* HAVE_CUPS */
4843 break;
4845 case PRINT_SYSV:
4846 case PRINT_HPUX:
4847 string_set(&pService->szLpqcommand, "lpstat -o%p");
4848 string_set(&pService->szLprmcommand, "cancel %p-%j");
4849 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4850 string_set(&pService->szQueuepausecommand, "disable %p");
4851 string_set(&pService->szQueueresumecommand, "enable %p");
4852 #ifndef HPUX
4853 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4854 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4855 #endif /* HPUX */
4856 break;
4858 case PRINT_QNX:
4859 string_set(&pService->szLpqcommand, "lpq -P%p");
4860 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4861 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4862 break;
4864 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
4866 case PRINT_TEST:
4867 case PRINT_VLP: {
4868 const char *tdbfile;
4869 char *tmp;
4871 tdbfile = talloc_asprintf(
4872 talloc_tos(), "tdbfile=%s",
4873 lp_parm_const_string(-1, "vlp", "tdbfile",
4874 "/tmp/vlp.tdb"));
4875 if (tdbfile == NULL) {
4876 tdbfile="tdbfile=/tmp/vlp.tdb";
4879 tmp = talloc_asprintf(talloc_tos(), "vlp %s print %%p %%s",
4880 tdbfile);
4881 string_set(&pService->szPrintcommand,
4882 tmp ? tmp : "vlp print %p %s");
4883 TALLOC_FREE(tmp);
4885 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpq %%p",
4886 tdbfile);
4887 string_set(&pService->szLpqcommand,
4888 tmp ? tmp : "vlp lpq %p");
4889 TALLOC_FREE(tmp);
4891 tmp = talloc_asprintf(talloc_tos(), "vlp %s lprm %%p %%j",
4892 tdbfile);
4893 string_set(&pService->szLprmcommand,
4894 tmp ? tmp : "vlp lprm %p %j");
4895 TALLOC_FREE(tmp);
4897 tmp = talloc_asprintf(talloc_tos(), "vlp %s lppause %%p %%j",
4898 tdbfile);
4899 string_set(&pService->szLppausecommand,
4900 tmp ? tmp : "vlp lppause %p %j");
4901 TALLOC_FREE(tmp);
4903 tmp = talloc_asprintf(talloc_tos(), "vlp %s lpresume %%p %%j",
4904 tdbfile);
4905 string_set(&pService->szLpresumecommand,
4906 tmp ? tmp : "vlp lpresume %p %j");
4907 TALLOC_FREE(tmp);
4909 tmp = talloc_asprintf(talloc_tos(), "vlp %s queuepause %%p",
4910 tdbfile);
4911 string_set(&pService->szQueuepausecommand,
4912 tmp ? tmp : "vlp queuepause %p");
4913 TALLOC_FREE(tmp);
4915 tmp = talloc_asprintf(talloc_tos(), "vlp %s queueresume %%p",
4916 tdbfile);
4917 string_set(&pService->szQueueresumecommand,
4918 tmp ? tmp : "vlp queueresume %p");
4919 TALLOC_FREE(tmp);
4921 break;
4923 #endif /* DEVELOPER */
4928 * Function to return the default value for the maximum number of open
4929 * file descriptors permitted. This function tries to consult the
4930 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4931 * the smaller of those.
4933 static int max_open_files(void)
4935 int sysctl_max = MAX_OPEN_FILES;
4936 int rlimit_max = MAX_OPEN_FILES;
4938 #ifdef HAVE_SYSCTLBYNAME
4940 size_t size = sizeof(sysctl_max);
4941 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4944 #endif
4946 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4948 struct rlimit rl;
4950 ZERO_STRUCT(rl);
4952 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4953 rlimit_max = rl.rlim_cur;
4955 #if defined(RLIM_INFINITY)
4956 if(rl.rlim_cur == RLIM_INFINITY)
4957 rlimit_max = MAX_OPEN_FILES;
4958 #endif
4960 #endif
4962 if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4963 DEBUG(2,("max_open_files: increasing sysctl_max (%d) to "
4964 "minimum Windows limit (%d)\n",
4965 sysctl_max,
4966 MIN_OPEN_FILES_WINDOWS));
4967 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4970 if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4971 DEBUG(2,("rlimit_max: increasing rlimit_max (%d) to "
4972 "minimum Windows limit (%d)\n",
4973 rlimit_max,
4974 MIN_OPEN_FILES_WINDOWS));
4975 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4978 return MIN(sysctl_max, rlimit_max);
4982 * Common part of freeing allocated data for one parameter.
4984 static void free_one_parameter_common(void *parm_ptr,
4985 struct parm_struct parm)
4987 if ((parm.type == P_STRING) ||
4988 (parm.type == P_USTRING))
4990 string_free((char**)parm_ptr);
4991 } else if (parm.type == P_LIST) {
4992 TALLOC_FREE(*((char***)parm_ptr));
4997 * Free the allocated data for one parameter for a share
4998 * given as a service struct.
5000 static void free_one_parameter(struct service *service,
5001 struct parm_struct parm)
5003 void *parm_ptr;
5005 if (parm.p_class != P_LOCAL) {
5006 return;
5009 parm_ptr = lp_local_ptr(service, parm.ptr);
5011 free_one_parameter_common(parm_ptr, parm);
5015 * Free the allocated parameter data of a share given
5016 * as a service struct.
5018 static void free_parameters(struct service *service)
5020 uint32_t i;
5022 for (i=0; parm_table[i].label; i++) {
5023 free_one_parameter(service, parm_table[i]);
5028 * Free the allocated data for one parameter for a given share
5029 * specified by an snum.
5031 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
5033 void *parm_ptr;
5035 if (parm.ptr == NULL) {
5036 return;
5039 if (snum < 0) {
5040 parm_ptr = parm.ptr;
5041 } else if (parm.p_class != P_LOCAL) {
5042 return;
5043 } else {
5044 parm_ptr = lp_local_ptr_by_snum(snum, parm.ptr);
5047 free_one_parameter_common(parm_ptr, parm);
5051 * Free the allocated parameter data for a share specified
5052 * by an snum.
5054 static void free_parameters_by_snum(int snum)
5056 uint32_t i;
5058 for (i=0; parm_table[i].label; i++) {
5059 free_one_parameter_by_snum(snum, parm_table[i]);
5064 * Free the allocated global parameters.
5066 static void free_global_parameters(void)
5068 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
5071 static int map_parameter(const char *pszParmName);
5073 struct lp_stored_option {
5074 struct lp_stored_option *prev, *next;
5075 const char *label;
5076 const char *value;
5079 static struct lp_stored_option *stored_options;
5082 save options set by lp_set_cmdline() into a list. This list is
5083 re-applied when we do a globals reset, so that cmdline set options
5084 are sticky across reloads of smb.conf
5086 static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
5088 struct lp_stored_option *entry, *entry_next;
5089 for (entry = stored_options; entry != NULL; entry = entry_next) {
5090 entry_next = entry->next;
5091 if (strcmp(pszParmName, entry->label) == 0) {
5092 DLIST_REMOVE(stored_options, entry);
5093 talloc_free(entry);
5094 break;
5098 entry = talloc(NULL, struct lp_stored_option);
5099 if (!entry) {
5100 return false;
5103 entry->label = talloc_strdup(entry, pszParmName);
5104 if (!entry->label) {
5105 talloc_free(entry);
5106 return false;
5109 entry->value = talloc_strdup(entry, pszParmValue);
5110 if (!entry->value) {
5111 talloc_free(entry);
5112 return false;
5115 DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
5117 return true;
5120 static bool apply_lp_set_cmdline(void)
5122 struct lp_stored_option *entry = NULL;
5123 for (entry = stored_options; entry != NULL; entry = entry->next) {
5124 if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
5125 DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
5126 entry->label, entry->value));
5127 return false;
5130 return true;
5133 /***************************************************************************
5134 Initialise the global parameter structure.
5135 ***************************************************************************/
5137 static void init_globals(bool reinit_globals)
5139 static bool done_init = False;
5140 char *s = NULL;
5141 int i;
5143 /* If requested to initialize only once and we've already done it... */
5144 if (!reinit_globals && done_init) {
5145 /* ... then we have nothing more to do */
5146 return;
5149 if (!done_init) {
5150 /* The logfile can be set before this is invoked. Free it if so. */
5151 if (Globals.szLogFile != NULL) {
5152 string_free(&Globals.szLogFile);
5153 Globals.szLogFile = NULL;
5155 done_init = True;
5156 } else {
5157 free_global_parameters();
5160 /* This memset and the free_global_parameters() above will
5161 * wipe out smb.conf options set with lp_set_cmdline(). The
5162 * apply_lp_set_cmdline() call puts these values back in the
5163 * table once the defaults are set */
5164 memset((void *)&Globals, '\0', sizeof(Globals));
5166 for (i = 0; parm_table[i].label; i++) {
5167 if ((parm_table[i].type == P_STRING ||
5168 parm_table[i].type == P_USTRING) &&
5169 parm_table[i].ptr)
5171 string_set((char **)parm_table[i].ptr, "");
5175 string_set(&sDefault.fstype, FSTYPE_STRING);
5176 string_set(&sDefault.szPrintjobUsername, "%U");
5178 init_printer_values(&sDefault);
5181 DEBUG(3, ("Initialising global parameters\n"));
5183 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
5184 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
5186 /* use the new 'hash2' method by default, with a prefix of 1 */
5187 string_set(&Globals.szManglingMethod, "hash2");
5188 Globals.mangle_prefix = 1;
5190 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
5192 /* using UTF8 by default allows us to support all chars */
5193 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
5195 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
5196 /* If the system supports nl_langinfo(), try to grab the value
5197 from the user's locale */
5198 string_set(&Globals.display_charset, "LOCALE");
5199 #else
5200 string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
5201 #endif
5203 /* Use codepage 850 as a default for the dos character set */
5204 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
5207 * Allow the default PASSWD_CHAT to be overridden in local.h.
5209 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
5211 set_global_myname(myhostname());
5212 string_set(&Globals.szNetbiosName,global_myname());
5214 set_global_myworkgroup(WORKGROUP);
5215 string_set(&Globals.szWorkgroup, lp_workgroup());
5217 string_set(&Globals.szPasswdProgram, "");
5218 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
5219 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
5220 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
5221 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
5222 string_set(&Globals.szSocketAddress, "0.0.0.0");
5224 * By default support explicit binding to broadcast
5225 * addresses.
5227 Globals.bNmbdBindExplicitBroadcast = true;
5229 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
5230 smb_panic("init_globals: ENOMEM");
5232 string_set(&Globals.szServerString, s);
5233 SAFE_FREE(s);
5234 if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
5235 DEFAULT_MINOR_VERSION) < 0) {
5236 smb_panic("init_globals: ENOMEM");
5238 string_set(&Globals.szAnnounceVersion, s);
5239 SAFE_FREE(s);
5240 #ifdef DEVELOPER
5241 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
5242 #endif
5244 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
5246 string_set(&Globals.szLogonDrive, "");
5247 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
5248 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
5249 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
5251 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
5252 string_set(&Globals.szPasswordServer, "*");
5254 Globals.AlgorithmicRidBase = BASE_RID;
5256 Globals.bLoadPrinters = True;
5257 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
5259 Globals.ConfigBackend = config_backend;
5261 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
5262 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
5263 Globals.max_xmit = 0x4104;
5264 Globals.max_mux = 50; /* This is *needed* for profile support. */
5265 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
5266 Globals.bDisableSpoolss = False;
5267 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
5268 Globals.pwordlevel = 0;
5269 Globals.unamelevel = 0;
5270 Globals.deadtime = 0;
5271 Globals.getwd_cache = true;
5272 Globals.bLargeReadwrite = True;
5273 Globals.max_log_size = 5000;
5274 Globals.max_open_files = max_open_files();
5275 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
5276 Globals.maxprotocol = PROTOCOL_NT1;
5277 Globals.minprotocol = PROTOCOL_CORE;
5278 Globals.security = SEC_USER;
5279 Globals.paranoid_server_security = True;
5280 Globals.bEncryptPasswords = True;
5281 Globals.bUpdateEncrypt = False;
5282 Globals.clientSchannel = Auto;
5283 Globals.serverSchannel = Auto;
5284 Globals.bReadRaw = True;
5285 Globals.bWriteRaw = True;
5286 Globals.bNullPasswords = False;
5287 Globals.bObeyPamRestrictions = False;
5288 Globals.syslog = 1;
5289 Globals.bSyslogOnly = False;
5290 Globals.bTimestampLogs = True;
5291 string_set(&Globals.szLogLevel, "0");
5292 Globals.bDebugPrefixTimestamp = False;
5293 Globals.bDebugHiresTimestamp = true;
5294 Globals.bDebugPid = False;
5295 Globals.bDebugUid = False;
5296 Globals.bDebugClass = False;
5297 Globals.bEnableCoreFiles = True;
5298 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
5299 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
5300 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
5301 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
5302 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
5303 Globals.lm_interval = 60;
5304 Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
5305 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
5306 Globals.bNISHomeMap = False;
5307 #ifdef WITH_NISPLUS_HOME
5308 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
5309 #else
5310 string_set(&Globals.szNISHomeMapName, "auto.home");
5311 #endif
5312 #endif
5313 Globals.bTimeServer = False;
5314 Globals.bBindInterfacesOnly = False;
5315 Globals.bUnixPasswdSync = False;
5316 Globals.bPamPasswordChange = False;
5317 Globals.bPasswdChatDebug = False;
5318 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
5319 Globals.bNTPipeSupport = True; /* Do NT pipes by default. */
5320 Globals.bNTStatusSupport = True; /* Use NT status by default. */
5321 Globals.bStatCache = True; /* use stat cache by default */
5322 Globals.iMaxStatCacheSize = 256; /* 256k by default */
5323 Globals.restrict_anonymous = 0;
5324 Globals.bClientLanManAuth = False; /* Do NOT use the LanMan hash if it is available */
5325 Globals.bClientPlaintextAuth = False; /* Do NOT use a plaintext password even if is requested by the server */
5326 Globals.bLanmanAuth = False; /* Do NOT use the LanMan hash, even if it is supplied */
5327 Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
5328 Globals.bClientNTLMv2Auth = True; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
5329 /* Note, that we will also use NTLM2 session security (which is different), if it is available */
5331 Globals.map_to_guest = 0; /* By Default, "Never" */
5332 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
5333 Globals.enhanced_browsing = true;
5334 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
5335 #ifdef MMAP_BLACKLIST
5336 Globals.bUseMmap = False;
5337 #else
5338 Globals.bUseMmap = True;
5339 #endif
5340 Globals.bUnixExtensions = True;
5341 Globals.bResetOnZeroVC = False;
5342 Globals.bLogWriteableFilesOnExit = False;
5343 Globals.bCreateKrb5Conf = true;
5344 Globals.winbindMaxDomainConnections = 1;
5346 /* hostname lookups can be very expensive and are broken on
5347 a large number of sites (tridge) */
5348 Globals.bHostnameLookups = False;
5350 string_set(&Globals.szPassdbBackend, "tdbsam");
5351 string_set(&Globals.szLdapSuffix, "");
5352 string_set(&Globals.szLdapMachineSuffix, "");
5353 string_set(&Globals.szLdapUserSuffix, "");
5354 string_set(&Globals.szLdapGroupSuffix, "");
5355 string_set(&Globals.szLdapIdmapSuffix, "");
5357 string_set(&Globals.szLdapAdminDn, "");
5358 Globals.ldap_ssl = LDAP_SSL_START_TLS;
5359 Globals.ldap_ssl_ads = False;
5360 Globals.ldap_deref = -1;
5361 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
5362 Globals.ldap_delete_dn = False;
5363 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
5364 Globals.ldap_follow_referral = Auto;
5365 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
5366 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
5367 Globals.ldap_page_size = LDAP_PAGE_SIZE;
5369 Globals.ldap_debug_level = 0;
5370 Globals.ldap_debug_threshold = 10;
5372 /* This is what we tell the afs client. in reality we set the token
5373 * to never expire, though, when this runs out the afs client will
5374 * forget the token. Set to 0 to get NEVERDATE.*/
5375 Globals.iAfsTokenLifetime = 604800;
5376 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
5378 /* these parameters are set to defaults that are more appropriate
5379 for the increasing samba install base:
5381 as a member of the workgroup, that will possibly become a
5382 _local_ master browser (lm = True). this is opposed to a forced
5383 local master browser startup (pm = True).
5385 doesn't provide WINS server service by default (wsupp = False),
5386 and doesn't provide domain master browser services by default, either.
5390 Globals.bMsAddPrinterWizard = True;
5391 Globals.os_level = 20;
5392 Globals.bLocalMaster = True;
5393 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
5394 Globals.bDomainLogons = False;
5395 Globals.bBrowseList = True;
5396 Globals.bWINSsupport = False;
5397 Globals.bWINSproxy = False;
5399 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
5400 Globals.InitLogonDelay = 100; /* 100 ms default delay */
5402 Globals.bDNSproxy = True;
5404 /* this just means to use them if they exist */
5405 Globals.bKernelOplocks = True;
5407 Globals.bAllowTrustedDomains = True;
5408 string_set(&Globals.szIdmapBackend, "tdb");
5409 Globals.bIdmapReadOnly = false;
5411 string_set(&Globals.szTemplateShell, "/bin/false");
5412 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
5413 string_set(&Globals.szWinbindSeparator, "\\");
5415 string_set(&Globals.szCupsServer, "");
5416 string_set(&Globals.szIPrintServer, "");
5418 string_set(&Globals.ctdbdSocket, "");
5419 Globals.szClusterAddresses = NULL;
5420 Globals.clustering = False;
5421 Globals.ctdb_timeout = 0;
5422 Globals.ctdb_locktime_warn_threshold = 0;
5424 Globals.winbind_cache_time = 300; /* 5 minutes */
5425 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
5426 Globals.winbind_max_clients = 200;
5427 Globals.bWinbindEnumUsers = False;
5428 Globals.bWinbindEnumGroups = False;
5429 Globals.bWinbindUseDefaultDomain = False;
5430 Globals.bWinbindTrustedDomainsOnly = False;
5431 Globals.bWinbindNestedGroups = True;
5432 Globals.winbind_expand_groups = 1;
5433 Globals.szWinbindNssInfo = str_list_make_v3(NULL, "template", NULL);
5434 Globals.bWinbindRefreshTickets = False;
5435 Globals.bWinbindOfflineLogon = False;
5437 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
5438 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
5440 Globals.bPassdbExpandExplicit = False;
5442 Globals.name_cache_timeout = 660; /* In seconds */
5444 Globals.bUseSpnego = True;
5445 Globals.bClientUseSpnego = True;
5447 Globals.client_signing = Auto;
5448 Globals.server_signing = False;
5450 Globals.bDeferSharingViolations = True;
5451 string_set(&Globals.smb_ports, SMB_PORTS);
5453 Globals.bEnablePrivileges = True;
5454 Globals.bHostMSDfs = True;
5455 Globals.bASUSupport = False;
5457 /* User defined shares. */
5458 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5459 smb_panic("init_globals: ENOMEM");
5461 string_set(&Globals.szUsersharePath, s);
5462 SAFE_FREE(s);
5463 string_set(&Globals.szUsershareTemplateShare, "");
5464 Globals.iUsershareMaxShares = 0;
5465 /* By default disallow sharing of directories not owned by the sharer. */
5466 Globals.bUsershareOwnerOnly = True;
5467 /* By default disallow guest access to usershares. */
5468 Globals.bUsershareAllowGuests = False;
5470 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5472 /* By default no shares out of the registry */
5473 Globals.bRegistryShares = False;
5475 Globals.iminreceivefile = 0;
5477 Globals.bMapUntrustedToDomain = false;
5478 Globals.bMulticastDnsRegister = true;
5480 Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ;
5481 Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE;
5482 Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT;
5483 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5485 string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
5487 /* Now put back the settings that were set with lp_set_cmdline() */
5488 apply_lp_set_cmdline();
5491 /*******************************************************************
5492 Convenience routine to grab string parameters into temporary memory
5493 and run standard_sub_basic on them. The buffers can be written to by
5494 callers without affecting the source string.
5495 ********************************************************************/
5497 static char *lp_string(const char *s)
5499 char *ret;
5500 TALLOC_CTX *ctx = talloc_tos();
5502 /* The follow debug is useful for tracking down memory problems
5503 especially if you have an inner loop that is calling a lp_*()
5504 function that returns a string. Perhaps this debug should be
5505 present all the time? */
5507 #if 0
5508 DEBUG(10, ("lp_string(%s)\n", s));
5509 #endif
5510 if (!s) {
5511 return NULL;
5514 ret = talloc_sub_basic(ctx,
5515 get_current_username(),
5516 current_user_info.domain,
5518 if (trim_char(ret, '\"', '\"')) {
5519 if (strchr(ret,'\"') != NULL) {
5520 TALLOC_FREE(ret);
5521 ret = talloc_sub_basic(ctx,
5522 get_current_username(),
5523 current_user_info.domain,
5527 return ret;
5531 In this section all the functions that are used to access the
5532 parameters from the rest of the program are defined
5535 #define FN_GLOBAL_STRING(fn_name,ptr) \
5536 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
5537 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5538 const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
5539 #define FN_GLOBAL_LIST(fn_name,ptr) \
5540 const char **fn_name(void) {return(*(const char ***)(ptr));}
5541 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5542 bool fn_name(void) {return(*(bool *)(ptr));}
5543 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5544 char fn_name(void) {return(*(char *)(ptr));}
5545 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5546 int fn_name(void) {return(*(int *)(ptr));}
5548 #define FN_LOCAL_STRING(fn_name,val) \
5549 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5550 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5551 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5552 #define FN_LOCAL_LIST(fn_name,val) \
5553 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5554 #define FN_LOCAL_BOOL(fn_name,val) \
5555 bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5556 #define FN_LOCAL_INTEGER(fn_name,val) \
5557 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5559 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5560 bool fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5561 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5562 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5563 #define FN_LOCAL_CHAR(fn_name,val) \
5564 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5566 FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
5567 FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
5568 FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
5569 FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
5570 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
5571 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
5572 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
5573 FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
5574 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
5575 FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
5576 FN_GLOBAL_STRING(lp_addport_cmd, &Globals.szAddPortCommand)
5577 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
5578 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
5579 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
5580 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
5581 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
5582 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5583 * build process or in smb.conf, we use that value. Otherwise they
5584 * default to the value of lp_lockdir(). */
5585 char *lp_statedir(void) {
5586 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5587 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5588 return(lp_string(*(char **)(&Globals.szStateDir) ?
5589 *(char **)(&Globals.szStateDir) : ""));
5590 else
5591 return(lp_string(*(char **)(&Globals.szLockDir) ?
5592 *(char **)(&Globals.szLockDir) : ""));
5594 char *lp_cachedir(void) {
5595 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5596 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5597 return(lp_string(*(char **)(&Globals.szCacheDir) ?
5598 *(char **)(&Globals.szCacheDir) : ""));
5599 else
5600 return(lp_string(*(char **)(&Globals.szLockDir) ?
5601 *(char **)(&Globals.szLockDir) : ""));
5603 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
5604 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
5605 FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
5606 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
5607 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
5608 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
5609 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
5610 FN_GLOBAL_STRING(lp_perfcount_module, &Globals.szSMBPerfcountModule)
5611 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
5612 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
5613 FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
5614 FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
5615 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
5616 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
5617 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
5618 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
5619 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
5620 FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
5621 FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
5622 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
5623 FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
5624 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
5625 FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
5626 FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
5627 FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
5628 FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
5629 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
5630 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
5631 FN_GLOBAL_BOOL(lp_nmbd_bind_explicit_broadcast, &Globals.bNmbdBindExplicitBroadcast)
5632 FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
5633 FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
5634 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
5635 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
5636 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
5637 /* FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
5638 * lp_passdb_backend() should be replace by the this macro again after
5639 * some releases.
5640 * */
5641 const char *lp_passdb_backend(void)
5643 char *delim, *quote;
5645 delim = strchr( Globals.szPassdbBackend, ' ');
5646 /* no space at all */
5647 if (delim == NULL) {
5648 goto out;
5651 quote = strchr(Globals.szPassdbBackend, '"');
5652 /* no quote char or non in the first part */
5653 if (quote == NULL || quote > delim) {
5654 *delim = '\0';
5655 goto warn;
5658 quote = strchr(quote+1, '"');
5659 if (quote == NULL) {
5660 DEBUG(0, ("WARNING: Your 'passdb backend' configuration is invalid due to a missing second \" char.\n"));
5661 goto out;
5662 } else if (*(quote+1) == '\0') {
5663 /* space, fitting quote char, and one backend only */
5664 goto out;
5665 } else {
5666 /* terminate string after the fitting quote char */
5667 *(quote+1) = '\0';
5670 warn:
5671 DEBUG(0, ("WARNING: Your 'passdb backend' configuration includes multiple backends. This\n"
5672 "is deprecated since Samba 3.0.23. Please check WHATSNEW.txt or the section 'Passdb\n"
5673 "Changes' from the ChangeNotes as part of the Samba HOWTO collection. Only the first\n"
5674 "backend (%s) is used. The rest is ignored.\n", Globals.szPassdbBackend));
5676 out:
5677 return Globals.szPassdbBackend;
5679 FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
5680 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
5681 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
5682 FN_GLOBAL_STRING(lp_renameuser_script, &Globals.szRenameUserScript)
5683 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
5685 FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
5686 FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
5687 FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
5688 FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
5689 FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
5690 FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
5692 FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
5694 FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
5695 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
5696 FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
5697 FN_GLOBAL_INTEGER(lp_username_map_cache_time, &Globals.iUsernameMapCacheTime)
5699 FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
5701 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
5702 FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
5703 FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
5704 FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
5705 FN_GLOBAL_INTEGER(lp_acl_compatibility, &Globals.iAclCompat)
5706 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
5707 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
5708 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
5709 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
5710 FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
5711 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups)
5712 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets)
5713 FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon)
5714 FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames)
5715 FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
5716 FN_GLOBAL_BOOL(lp_create_krb5_conf, &Globals.bCreateKrb5Conf)
5717 static FN_GLOBAL_INTEGER(lp_winbind_max_domain_connections_int,
5718 &Globals.winbindMaxDomainConnections)
5720 int lp_winbind_max_domain_connections(void)
5722 if (lp_winbind_offline_logon() &&
5723 lp_winbind_max_domain_connections_int() > 1) {
5724 DEBUG(1, ("offline logons active, restricting max domain "
5725 "connections to 1\n"));
5726 return 1;
5728 return MAX(1, lp_winbind_max_domain_connections_int());
5731 FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
5732 FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
5733 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
5734 FN_GLOBAL_INTEGER(lp_keepalive, &Globals.iKeepalive)
5735 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit)
5737 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
5738 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
5739 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
5740 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, &Globals.ldap_ssl_ads)
5741 FN_GLOBAL_INTEGER(lp_ldap_deref, &Globals.ldap_deref)
5742 FN_GLOBAL_INTEGER(lp_ldap_follow_referral, &Globals.ldap_follow_referral)
5743 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
5744 FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
5745 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
5746 FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
5747 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, &Globals.ldap_connection_timeout)
5748 FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
5749 FN_GLOBAL_INTEGER(lp_ldap_debug_level, &Globals.ldap_debug_level)
5750 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, &Globals.ldap_debug_threshold)
5751 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
5752 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
5753 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
5754 FN_GLOBAL_STRING(lp_usershare_path, &Globals.szUsersharePath)
5755 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, &Globals.szUsersharePrefixAllowList)
5756 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, &Globals.szUsersharePrefixDenyList)
5758 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
5760 FN_GLOBAL_BOOL(lp_registry_shares, &Globals.bRegistryShares)
5761 FN_GLOBAL_BOOL(lp_usershare_allow_guests, &Globals.bUsershareAllowGuests)
5762 FN_GLOBAL_BOOL(lp_usershare_owner_only, &Globals.bUsershareOwnerOnly)
5763 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
5764 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
5765 FN_GLOBAL_BOOL(lp_log_writeable_files_on_exit,
5766 &Globals.bLogWriteableFilesOnExit)
5767 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
5768 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
5769 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
5770 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
5771 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
5772 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
5773 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
5774 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, &Globals.szInitLogonDelayedHosts)
5775 FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
5776 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
5777 FN_GLOBAL_BOOL(_lp_readraw, &Globals.bReadRaw)
5778 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
5779 FN_GLOBAL_BOOL(_lp_writeraw, &Globals.bWriteRaw)
5780 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
5781 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
5782 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
5783 FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
5784 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
5785 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
5786 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
5787 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
5788 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
5789 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
5790 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
5791 FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
5792 FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
5793 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
5794 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
5795 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
5796 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
5797 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
5798 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
5799 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
5800 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
5801 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
5802 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
5803 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
5804 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
5805 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
5806 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, &Globals.bMapUntrustedToDomain)
5807 FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
5808 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
5809 FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
5810 FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
5811 FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
5812 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
5813 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
5814 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
5815 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
5816 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
5817 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
5818 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
5819 FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
5820 FN_GLOBAL_BOOL(lp_client_use_spnego_principal, &Globals.client_use_spnego_principal)
5821 FN_GLOBAL_BOOL(lp_send_spnego_principal, &Globals.send_spnego_principal)
5822 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
5823 FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
5824 FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
5825 FN_GLOBAL_STRING(lp_dedicated_keytab_file, &Globals.szDedicatedKeytabFile)
5826 FN_GLOBAL_INTEGER(lp_kerberos_method, &Globals.iKerberosMethod)
5827 FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
5828 FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
5829 FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport)
5830 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
5831 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
5832 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
5833 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
5834 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
5835 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
5836 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, &Globals.open_files_db_hash_size)
5837 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
5838 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
5839 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
5840 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
5841 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
5842 FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
5843 static FN_GLOBAL_INTEGER(_lp_maxprotocol, &Globals.maxprotocol)
5844 int lp_maxprotocol(void)
5846 int ret = _lp_maxprotocol();
5847 if ((ret == PROTOCOL_SMB2) && (lp_security() == SEC_SHARE)) {
5848 DEBUG(2,("WARNING!!: \"security = share\" is incompatible "
5849 "with the SMB2 protocol. Resetting to SMB1.\n" ));
5850 lp_do_parameter(-1, "max protocol", "NT1");
5851 return PROTOCOL_NT1;
5853 return ret;
5855 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
5856 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
5857 FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
5858 FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
5859 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
5860 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
5861 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
5862 FN_GLOBAL_BOOL(_lp_disable_spoolss, &Globals.bDisableSpoolss)
5863 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
5864 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
5865 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
5866 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
5867 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
5868 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
5869 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
5870 FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
5871 FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
5872 FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
5873 FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
5874 FN_GLOBAL_INTEGER(lp_smb2_max_read, &Globals.ismb2_max_read)
5875 FN_GLOBAL_INTEGER(lp_smb2_max_write, &Globals.ismb2_max_write)
5876 FN_GLOBAL_INTEGER(lp_smb2_max_trans, &Globals.ismb2_max_trans)
5877 int lp_smb2_max_credits(void)
5879 if (Globals.ismb2_max_credits == 0) {
5880 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
5882 return Globals.ismb2_max_credits;
5884 FN_LOCAL_STRING(lp_preexec, szPreExec)
5885 FN_LOCAL_STRING(lp_postexec, szPostExec)
5886 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
5887 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
5888 FN_LOCAL_STRING(lp_servicename, szService)
5889 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
5890 FN_LOCAL_STRING(lp_pathname, szPath)
5891 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
5892 FN_LOCAL_STRING(lp_username, szUsername)
5893 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
5894 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
5895 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
5896 FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
5897 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
5898 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
5899 int lp_cups_encrypt(void)
5901 int result = 0;
5902 #ifdef HAVE_HTTPCONNECTENCRYPT
5903 switch (Globals.CupsEncrypt) {
5904 case Auto:
5905 result = HTTP_ENCRYPT_REQUIRED;
5906 break;
5907 case True:
5908 result = HTTP_ENCRYPT_ALWAYS;
5909 break;
5910 case False:
5911 result = HTTP_ENCRYPT_NEVER;
5912 break;
5914 #endif
5915 return result;
5917 FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
5918 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
5919 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
5920 FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
5921 FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
5922 FN_GLOBAL_INTEGER(lp_ctdb_timeout, &Globals.ctdb_timeout)
5923 FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, &Globals.ctdb_locktime_warn_threshold)
5924 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
5925 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
5926 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
5927 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
5928 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
5929 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
5930 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
5931 static FN_LOCAL_STRING(_lp_printername, szPrintername)
5932 FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
5933 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
5934 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
5935 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
5936 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
5937 FN_LOCAL_STRING(lp_comment, comment)
5938 FN_LOCAL_STRING(lp_force_user, force_user)
5939 FN_LOCAL_STRING(lp_force_group, force_group)
5940 FN_LOCAL_LIST(lp_readlist, readlist)
5941 FN_LOCAL_LIST(lp_writelist, writelist)
5942 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
5943 FN_LOCAL_STRING(lp_fstype, fstype)
5944 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
5945 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
5946 static FN_LOCAL_STRING(lp_volume, volume)
5947 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
5948 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
5949 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
5950 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
5951 FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
5952 FN_LOCAL_STRING(lp_dfree_command, szDfree)
5953 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
5954 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
5955 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
5956 FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
5957 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
5958 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
5959 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
5960 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
5961 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
5962 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
5963 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
5964 FN_LOCAL_BOOL(lp_access_based_share_enum, bAccessBasedShareEnum)
5965 FN_LOCAL_BOOL(lp_readonly, bRead_only)
5966 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
5967 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
5968 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
5969 FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
5970 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
5971 FN_LOCAL_BOOL(lp_print_notify_backchannel, bPrintNotifyBackchannel)
5972 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
5973 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
5974 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
5975 FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
5976 FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
5977 FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
5978 FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
5979 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
5980 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
5981 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
5982 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
5983 FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames)
5984 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
5985 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
5986 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
5987 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
5988 FN_LOCAL_BOOL(lp_map_system, bMap_system)
5989 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
5990 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
5991 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
5992 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
5993 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
5994 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
5995 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
5996 FN_GLOBAL_BOOL(lp_async_smb_echo_handler, &Globals.bAsyncSMBEchoHandler)
5997 FN_GLOBAL_BOOL(lp_multicast_dns_register, &Globals.bMulticastDnsRegister)
5998 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
5999 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
6000 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
6001 FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
6002 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
6003 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
6004 FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
6005 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
6006 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
6007 FN_LOCAL_BOOL(lp_ea_support, bEASupport)
6008 FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
6009 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
6010 FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
6011 FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
6012 FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
6013 FN_LOCAL_BOOL(lp_acl_group_control, bAclGroupControl)
6014 FN_LOCAL_BOOL(lp_acl_map_full_control, bAclMapFullControl)
6015 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
6016 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
6017 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
6018 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
6019 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
6020 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
6021 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
6022 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
6023 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
6024 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
6025 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
6026 FN_LOCAL_INTEGER(lp_printing, iPrinting)
6027 FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
6028 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
6029 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
6030 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
6031 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
6032 FN_LOCAL_INTEGER(lp_dfree_cache_time, iDfreeCacheTime)
6033 FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
6034 FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
6035 FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
6036 FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
6037 FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
6038 FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
6039 FN_LOCAL_CHAR(lp_magicchar, magic_char)
6040 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
6041 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
6042 FN_GLOBAL_INTEGER(lp_winbind_max_clients, &Globals.winbind_max_clients)
6043 FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
6044 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
6045 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
6046 FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
6047 FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
6048 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
6050 FN_GLOBAL_STRING(lp_ncalrpc_dir, &Globals.ncalrpc_dir)
6052 /* local prototypes */
6054 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
6055 static const char *get_boolean(bool bool_value);
6056 static int getservicebyname(const char *pszServiceName,
6057 struct service *pserviceDest);
6058 static void copy_service(struct service *pserviceDest,
6059 struct service *pserviceSource,
6060 struct bitmap *pcopymapDest);
6061 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
6062 void *userdata);
6063 static bool do_section(const char *pszSectionName, void *userdata);
6064 static void init_copymap(struct service *pservice);
6065 static bool hash_a_service(const char *name, int number);
6066 static void free_service_byindex(int iService);
6067 static void free_param_opts(struct param_opt_struct **popts);
6068 static void show_parameter(int parmIndex);
6069 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
6072 * This is a helper function for parametrical options support. It returns a
6073 * pointer to parametrical option value if it exists or NULL otherwise. Actual
6074 * parametrical functions are quite simple
6076 static struct param_opt_struct *get_parametrics(int snum, const char *type,
6077 const char *option)
6079 bool global_section = False;
6080 char* param_key;
6081 struct param_opt_struct *data;
6083 if (snum >= iNumServices) return NULL;
6085 if (snum < 0) {
6086 data = Globals.param_opt;
6087 global_section = True;
6088 } else {
6089 data = ServicePtrs[snum]->param_opt;
6092 if (asprintf(&param_key, "%s:%s", type, option) == -1) {
6093 DEBUG(0,("asprintf failed!\n"));
6094 return NULL;
6097 while (data) {
6098 if (strwicmp(data->key, param_key) == 0) {
6099 string_free(&param_key);
6100 return data;
6102 data = data->next;
6105 if (!global_section) {
6106 /* Try to fetch the same option but from globals */
6107 /* but only if we are not already working with Globals */
6108 data = Globals.param_opt;
6109 while (data) {
6110 if (strwicmp(data->key, param_key) == 0) {
6111 string_free(&param_key);
6112 return data;
6114 data = data->next;
6118 string_free(&param_key);
6120 return NULL;
6124 #define MISSING_PARAMETER(name) \
6125 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
6127 /*******************************************************************
6128 convenience routine to return int parameters.
6129 ********************************************************************/
6130 static int lp_int(const char *s)
6133 if (!s || !*s) {
6134 MISSING_PARAMETER(lp_int);
6135 return (-1);
6138 return (int)strtol(s, NULL, 0);
6141 /*******************************************************************
6142 convenience routine to return unsigned long parameters.
6143 ********************************************************************/
6144 static unsigned long lp_ulong(const char *s)
6147 if (!s || !*s) {
6148 MISSING_PARAMETER(lp_ulong);
6149 return (0);
6152 return strtoul(s, NULL, 0);
6155 /*******************************************************************
6156 convenience routine to return boolean parameters.
6157 ********************************************************************/
6158 static bool lp_bool(const char *s)
6160 bool ret = False;
6162 if (!s || !*s) {
6163 MISSING_PARAMETER(lp_bool);
6164 return False;
6167 if (!set_boolean(s, &ret)) {
6168 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
6169 return False;
6172 return ret;
6175 /*******************************************************************
6176 convenience routine to return enum parameters.
6177 ********************************************************************/
6178 static int lp_enum(const char *s,const struct enum_list *_enum)
6180 int i;
6182 if (!s || !*s || !_enum) {
6183 MISSING_PARAMETER(lp_enum);
6184 return (-1);
6187 for (i=0; _enum[i].name; i++) {
6188 if (strequal(_enum[i].name,s))
6189 return _enum[i].value;
6192 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
6193 return (-1);
6196 #undef MISSING_PARAMETER
6198 /* DO NOT USE lp_parm_string ANYMORE!!!!
6199 * use lp_parm_const_string or lp_parm_talloc_string
6201 * lp_parm_string is only used to let old modules find this symbol
6203 #undef lp_parm_string
6204 char *lp_parm_string(const char *servicename, const char *type, const char *option);
6205 char *lp_parm_string(const char *servicename, const char *type, const char *option)
6207 return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
6210 /* Return parametric option from a given service. Type is a part of option before ':' */
6211 /* Parametric option has following syntax: 'Type: option = value' */
6212 /* the returned value is talloced on the talloc_tos() */
6213 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
6215 struct param_opt_struct *data = get_parametrics(snum, type, option);
6217 if (data == NULL||data->value==NULL) {
6218 if (def) {
6219 return lp_string(def);
6220 } else {
6221 return NULL;
6225 return lp_string(data->value);
6228 /* Return parametric option from a given service. Type is a part of option before ':' */
6229 /* Parametric option has following syntax: 'Type: option = value' */
6230 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
6232 struct param_opt_struct *data = get_parametrics(snum, type, option);
6234 if (data == NULL||data->value==NULL)
6235 return def;
6237 return data->value;
6240 /* Return parametric option from a given service. Type is a part of option before ':' */
6241 /* Parametric option has following syntax: 'Type: option = value' */
6243 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
6245 struct param_opt_struct *data = get_parametrics(snum, type, option);
6247 if (data == NULL||data->value==NULL)
6248 return (const char **)def;
6250 if (data->list==NULL) {
6251 data->list = str_list_make_v3(NULL, data->value, NULL);
6254 return (const char **)data->list;
6257 /* Return parametric option from a given service. Type is a part of option before ':' */
6258 /* Parametric option has following syntax: 'Type: option = value' */
6260 int lp_parm_int(int snum, const char *type, const char *option, int def)
6262 struct param_opt_struct *data = get_parametrics(snum, type, option);
6264 if (data && data->value && *data->value)
6265 return lp_int(data->value);
6267 return def;
6270 /* Return parametric option from a given service. Type is a part of option before ':' */
6271 /* Parametric option has following syntax: 'Type: option = value' */
6273 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
6275 struct param_opt_struct *data = get_parametrics(snum, type, option);
6277 if (data && data->value && *data->value)
6278 return lp_ulong(data->value);
6280 return def;
6283 /* Return parametric option from a given service. Type is a part of option before ':' */
6284 /* Parametric option has following syntax: 'Type: option = value' */
6286 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
6288 struct param_opt_struct *data = get_parametrics(snum, type, option);
6290 if (data && data->value && *data->value)
6291 return lp_bool(data->value);
6293 return def;
6296 /* Return parametric option from a given service. Type is a part of option before ':' */
6297 /* Parametric option has following syntax: 'Type: option = value' */
6299 int lp_parm_enum(int snum, const char *type, const char *option,
6300 const struct enum_list *_enum, int def)
6302 struct param_opt_struct *data = get_parametrics(snum, type, option);
6304 if (data && data->value && *data->value && _enum)
6305 return lp_enum(data->value, _enum);
6307 return def;
6311 /***************************************************************************
6312 Initialise a service to the defaults.
6313 ***************************************************************************/
6315 static void init_service(struct service *pservice)
6317 memset((char *)pservice, '\0', sizeof(struct service));
6318 copy_service(pservice, &sDefault, NULL);
6323 * free a param_opts structure.
6324 * param_opts handling should be moved to talloc;
6325 * then this whole functions reduces to a TALLOC_FREE().
6328 static void free_param_opts(struct param_opt_struct **popts)
6330 struct param_opt_struct *opt, *next_opt;
6332 if (popts == NULL) {
6333 return;
6336 if (*popts != NULL) {
6337 DEBUG(5, ("Freeing parametrics:\n"));
6339 opt = *popts;
6340 while (opt != NULL) {
6341 string_free(&opt->key);
6342 string_free(&opt->value);
6343 TALLOC_FREE(opt->list);
6344 next_opt = opt->next;
6345 SAFE_FREE(opt);
6346 opt = next_opt;
6348 *popts = NULL;
6351 /***************************************************************************
6352 Free the dynamically allocated parts of a service struct.
6353 ***************************************************************************/
6355 static void free_service(struct service *pservice)
6357 if (!pservice)
6358 return;
6360 if (pservice->szService)
6361 DEBUG(5, ("free_service: Freeing service %s\n",
6362 pservice->szService));
6364 free_parameters(pservice);
6366 string_free(&pservice->szService);
6367 TALLOC_FREE(pservice->copymap);
6369 free_param_opts(&pservice->param_opt);
6371 ZERO_STRUCTP(pservice);
6375 /***************************************************************************
6376 remove a service indexed in the ServicePtrs array from the ServiceHash
6377 and free the dynamically allocated parts
6378 ***************************************************************************/
6380 static void free_service_byindex(int idx)
6382 if ( !LP_SNUM_OK(idx) )
6383 return;
6385 ServicePtrs[idx]->valid = False;
6386 invalid_services[num_invalid_services++] = idx;
6388 /* we have to cleanup the hash record */
6390 if (ServicePtrs[idx]->szService) {
6391 char *canon_name = canonicalize_servicename(
6392 talloc_tos(),
6393 ServicePtrs[idx]->szService );
6395 dbwrap_delete_bystring(ServiceHash, canon_name );
6396 TALLOC_FREE(canon_name);
6399 free_service(ServicePtrs[idx]);
6402 /***************************************************************************
6403 Add a new service to the services array initialising it with the given
6404 service.
6405 ***************************************************************************/
6407 static int add_a_service(const struct service *pservice, const char *name)
6409 int i;
6410 struct service tservice;
6411 int num_to_alloc = iNumServices + 1;
6413 tservice = *pservice;
6415 /* it might already exist */
6416 if (name) {
6417 i = getservicebyname(name, NULL);
6418 if (i >= 0) {
6419 return (i);
6423 /* find an invalid one */
6424 i = iNumServices;
6425 if (num_invalid_services > 0) {
6426 i = invalid_services[--num_invalid_services];
6429 /* if not, then create one */
6430 if (i == iNumServices) {
6431 struct service **tsp;
6432 int *tinvalid;
6434 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
6435 if (tsp == NULL) {
6436 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
6437 return (-1);
6439 ServicePtrs = tsp;
6440 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct service);
6441 if (!ServicePtrs[iNumServices]) {
6442 DEBUG(0,("add_a_service: out of memory!\n"));
6443 return (-1);
6445 iNumServices++;
6447 /* enlarge invalid_services here for now... */
6448 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
6449 num_to_alloc);
6450 if (tinvalid == NULL) {
6451 DEBUG(0,("add_a_service: failed to enlarge "
6452 "invalid_services!\n"));
6453 return (-1);
6455 invalid_services = tinvalid;
6456 } else {
6457 free_service_byindex(i);
6460 ServicePtrs[i]->valid = True;
6462 init_service(ServicePtrs[i]);
6463 copy_service(ServicePtrs[i], &tservice, NULL);
6464 if (name)
6465 string_set(&ServicePtrs[i]->szService, name);
6467 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
6468 i, ServicePtrs[i]->szService));
6470 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
6471 return (-1);
6474 return (i);
6477 /***************************************************************************
6478 Convert a string to uppercase and remove whitespaces.
6479 ***************************************************************************/
6481 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
6483 char *result;
6485 if ( !src ) {
6486 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
6487 return NULL;
6490 result = talloc_strdup(ctx, src);
6491 SMB_ASSERT(result != NULL);
6493 strlower_m(result);
6494 return result;
6497 /***************************************************************************
6498 Add a name/index pair for the services array to the hash table.
6499 ***************************************************************************/
6501 static bool hash_a_service(const char *name, int idx)
6503 char *canon_name;
6505 if ( !ServiceHash ) {
6506 DEBUG(10,("hash_a_service: creating servicehash\n"));
6507 ServiceHash = db_open_rbt(NULL);
6508 if ( !ServiceHash ) {
6509 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
6510 return False;
6514 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
6515 idx, name));
6517 canon_name = canonicalize_servicename(talloc_tos(), name );
6519 dbwrap_store_bystring(ServiceHash, canon_name,
6520 make_tdb_data((uint8 *)&idx, sizeof(idx)),
6521 TDB_REPLACE);
6523 TALLOC_FREE(canon_name);
6525 return True;
6528 /***************************************************************************
6529 Add a new home service, with the specified home directory, defaults coming
6530 from service ifrom.
6531 ***************************************************************************/
6533 bool lp_add_home(const char *pszHomename, int iDefaultService,
6534 const char *user, const char *pszHomedir)
6536 int i;
6538 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
6539 pszHomedir[0] == '\0') {
6540 return false;
6543 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
6545 if (i < 0)
6546 return (False);
6548 if (!(*(ServicePtrs[iDefaultService]->szPath))
6549 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
6550 string_set(&ServicePtrs[i]->szPath, pszHomedir);
6553 if (!(*(ServicePtrs[i]->comment))) {
6554 char *comment = NULL;
6555 if (asprintf(&comment, "Home directory of %s", user) < 0) {
6556 return false;
6558 string_set(&ServicePtrs[i]->comment, comment);
6559 SAFE_FREE(comment);
6562 /* set the browseable flag from the global default */
6564 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6565 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
6567 ServicePtrs[i]->autoloaded = True;
6569 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
6570 user, ServicePtrs[i]->szPath ));
6572 return (True);
6575 /***************************************************************************
6576 Add a new service, based on an old one.
6577 ***************************************************************************/
6579 int lp_add_service(const char *pszService, int iDefaultService)
6581 if (iDefaultService < 0) {
6582 return add_a_service(&sDefault, pszService);
6585 return (add_a_service(ServicePtrs[iDefaultService], pszService));
6588 /***************************************************************************
6589 Add the IPC service.
6590 ***************************************************************************/
6592 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
6594 char *comment = NULL;
6595 int i = add_a_service(&sDefault, ipc_name);
6597 if (i < 0)
6598 return (False);
6600 if (asprintf(&comment, "IPC Service (%s)",
6601 Globals.szServerString) < 0) {
6602 return (False);
6605 string_set(&ServicePtrs[i]->szPath, tmpdir());
6606 string_set(&ServicePtrs[i]->szUsername, "");
6607 string_set(&ServicePtrs[i]->comment, comment);
6608 string_set(&ServicePtrs[i]->fstype, "IPC");
6609 ServicePtrs[i]->iMaxConnections = 0;
6610 ServicePtrs[i]->bAvailable = True;
6611 ServicePtrs[i]->bRead_only = True;
6612 ServicePtrs[i]->bGuest_only = False;
6613 ServicePtrs[i]->bAdministrative_share = True;
6614 ServicePtrs[i]->bGuest_ok = guest_ok;
6615 ServicePtrs[i]->bPrint_ok = False;
6616 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6618 DEBUG(3, ("adding IPC service\n"));
6620 SAFE_FREE(comment);
6621 return (True);
6624 /***************************************************************************
6625 Add a new printer service, with defaults coming from service iFrom.
6626 ***************************************************************************/
6628 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
6630 const char *comment = "From Printcap";
6631 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6633 if (i < 0)
6634 return (False);
6636 /* note that we do NOT default the availability flag to True - */
6637 /* we take it from the default service passed. This allows all */
6638 /* dynamic printers to be disabled by disabling the [printers] */
6639 /* entry (if/when the 'available' keyword is implemented!). */
6641 /* the printer name is set to the service name. */
6642 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6643 string_set(&ServicePtrs[i]->comment, comment);
6645 /* set the browseable flag from the gloabl default */
6646 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6648 /* Printers cannot be read_only. */
6649 ServicePtrs[i]->bRead_only = False;
6650 /* No share modes on printer services. */
6651 ServicePtrs[i]->bShareModes = False;
6652 /* No oplocks on printer services. */
6653 ServicePtrs[i]->bOpLocks = False;
6654 /* Printer services must be printable. */
6655 ServicePtrs[i]->bPrint_ok = True;
6657 DEBUG(3, ("adding printer service %s\n", pszPrintername));
6659 return (True);
6663 /***************************************************************************
6664 Check whether the given parameter name is valid.
6665 Parametric options (names containing a colon) are considered valid.
6666 ***************************************************************************/
6668 bool lp_parameter_is_valid(const char *pszParmName)
6670 return ((map_parameter(pszParmName) != -1) ||
6671 (strchr(pszParmName, ':') != NULL));
6674 /***************************************************************************
6675 Check whether the given name is the name of a global parameter.
6676 Returns True for strings belonging to parameters of class
6677 P_GLOBAL, False for all other strings, also for parametric options
6678 and strings not belonging to any option.
6679 ***************************************************************************/
6681 bool lp_parameter_is_global(const char *pszParmName)
6683 int num = map_parameter(pszParmName);
6685 if (num >= 0) {
6686 return (parm_table[num].p_class == P_GLOBAL);
6689 return False;
6692 /**************************************************************************
6693 Check whether the given name is the canonical name of a parameter.
6694 Returns False if it is not a valid parameter Name.
6695 For parametric options, True is returned.
6696 **************************************************************************/
6698 bool lp_parameter_is_canonical(const char *parm_name)
6700 if (!lp_parameter_is_valid(parm_name)) {
6701 return False;
6704 return (map_parameter(parm_name) ==
6705 map_parameter_canonical(parm_name, NULL));
6708 /**************************************************************************
6709 Determine the canonical name for a parameter.
6710 Indicate when it is an inverse (boolean) synonym instead of a
6711 "usual" synonym.
6712 **************************************************************************/
6714 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6715 bool *inverse)
6717 int num;
6719 if (!lp_parameter_is_valid(parm_name)) {
6720 *canon_parm = NULL;
6721 return False;
6724 num = map_parameter_canonical(parm_name, inverse);
6725 if (num < 0) {
6726 /* parametric option */
6727 *canon_parm = parm_name;
6728 } else {
6729 *canon_parm = parm_table[num].label;
6732 return True;
6736 /**************************************************************************
6737 Determine the canonical name for a parameter.
6738 Turn the value given into the inverse boolean expression when
6739 the synonym is an invers boolean synonym.
6741 Return True if parm_name is a valid parameter name and
6742 in case it is an invers boolean synonym, if the val string could
6743 successfully be converted to the reverse bool.
6744 Return false in all other cases.
6745 **************************************************************************/
6747 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6748 const char *val,
6749 const char **canon_parm,
6750 const char **canon_val)
6752 int num;
6753 bool inverse;
6755 if (!lp_parameter_is_valid(parm_name)) {
6756 *canon_parm = NULL;
6757 *canon_val = NULL;
6758 return False;
6761 num = map_parameter_canonical(parm_name, &inverse);
6762 if (num < 0) {
6763 /* parametric option */
6764 *canon_parm = parm_name;
6765 *canon_val = val;
6766 } else {
6767 *canon_parm = parm_table[num].label;
6768 if (inverse) {
6769 if (!lp_invert_boolean(val, canon_val)) {
6770 *canon_val = NULL;
6771 return False;
6773 } else {
6774 *canon_val = val;
6778 return True;
6781 /***************************************************************************
6782 Map a parameter's string representation to something we can use.
6783 Returns False if the parameter string is not recognised, else TRUE.
6784 ***************************************************************************/
6786 static int map_parameter(const char *pszParmName)
6788 int iIndex;
6790 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6791 return (-1);
6793 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6794 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6795 return (iIndex);
6797 /* Warn only if it isn't parametric option */
6798 if (strchr(pszParmName, ':') == NULL)
6799 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6800 /* We do return 'fail' for parametric options as well because they are
6801 stored in different storage
6803 return (-1);
6806 /***************************************************************************
6807 Map a parameter's string representation to the index of the canonical
6808 form of the parameter (it might be a synonym).
6809 Returns -1 if the parameter string is not recognised.
6810 ***************************************************************************/
6812 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6814 int parm_num, canon_num;
6815 bool loc_inverse = False;
6817 parm_num = map_parameter(pszParmName);
6818 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6819 /* invalid, parametric or no canidate for synonyms ... */
6820 goto done;
6823 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6824 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6825 parm_num = canon_num;
6826 goto done;
6830 done:
6831 if (inverse != NULL) {
6832 *inverse = loc_inverse;
6834 return parm_num;
6837 /***************************************************************************
6838 return true if parameter number parm1 is a synonym of parameter
6839 number parm2 (parm2 being the principal name).
6840 set inverse to True if parm1 is P_BOOLREV and parm2 is P_BOOL,
6841 False otherwise.
6842 ***************************************************************************/
6844 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6846 if ((parm_table[parm1].ptr == parm_table[parm2].ptr) &&
6847 (parm_table[parm1].flags & FLAG_HIDE) &&
6848 !(parm_table[parm2].flags & FLAG_HIDE))
6850 if (inverse != NULL) {
6851 if ((parm_table[parm1].type == P_BOOLREV) &&
6852 (parm_table[parm2].type == P_BOOL))
6854 *inverse = True;
6855 } else {
6856 *inverse = False;
6859 return True;
6861 return False;
6864 /***************************************************************************
6865 Show one parameter's name, type, [values,] and flags.
6866 (helper functions for show_parameter_list)
6867 ***************************************************************************/
6869 static void show_parameter(int parmIndex)
6871 int enumIndex, flagIndex;
6872 int parmIndex2;
6873 bool hadFlag;
6874 bool hadSyn;
6875 bool inverse;
6876 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6877 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6878 "P_ENUM", "P_SEP"};
6879 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6880 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6881 FLAG_HIDE, FLAG_DOS_STRING};
6882 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6883 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6884 "FLAG_DEPRECATED", "FLAG_HIDE", "FLAG_DOS_STRING", NULL};
6886 printf("%s=%s", parm_table[parmIndex].label,
6887 type[parm_table[parmIndex].type]);
6888 if (parm_table[parmIndex].type == P_ENUM) {
6889 printf(",");
6890 for (enumIndex=0;
6891 parm_table[parmIndex].enum_list[enumIndex].name;
6892 enumIndex++)
6894 printf("%s%s",
6895 enumIndex ? "|" : "",
6896 parm_table[parmIndex].enum_list[enumIndex].name);
6899 printf(",");
6900 hadFlag = False;
6901 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6902 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6903 printf("%s%s",
6904 hadFlag ? "|" : "",
6905 flag_names[flagIndex]);
6906 hadFlag = True;
6910 /* output synonyms */
6911 hadSyn = False;
6912 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6913 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6914 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6915 parm_table[parmIndex2].label);
6916 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6917 if (!hadSyn) {
6918 printf(" (synonyms: ");
6919 hadSyn = True;
6920 } else {
6921 printf(", ");
6923 printf("%s%s", parm_table[parmIndex2].label,
6924 inverse ? "[i]" : "");
6927 if (hadSyn) {
6928 printf(")");
6931 printf("\n");
6934 /***************************************************************************
6935 Show all parameter's name, type, [values,] and flags.
6936 ***************************************************************************/
6938 void show_parameter_list(void)
6940 int classIndex, parmIndex;
6941 const char *section_names[] = { "local", "global", NULL};
6943 for (classIndex=0; section_names[classIndex]; classIndex++) {
6944 printf("[%s]\n", section_names[classIndex]);
6945 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6946 if (parm_table[parmIndex].p_class == classIndex) {
6947 show_parameter(parmIndex);
6953 /***************************************************************************
6954 Check if a given string correctly represents a boolean value.
6955 ***************************************************************************/
6957 bool lp_string_is_valid_boolean(const char *parm_value)
6959 return set_boolean(parm_value, NULL);
6962 /***************************************************************************
6963 Get the standard string representation of a boolean value ("yes" or "no")
6964 ***************************************************************************/
6966 static const char *get_boolean(bool bool_value)
6968 static const char *yes_str = "yes";
6969 static const char *no_str = "no";
6971 return (bool_value ? yes_str : no_str);
6974 /***************************************************************************
6975 Provide the string of the negated boolean value associated to the boolean
6976 given as a string. Returns False if the passed string does not correctly
6977 represent a boolean.
6978 ***************************************************************************/
6980 bool lp_invert_boolean(const char *str, const char **inverse_str)
6982 bool val;
6984 if (!set_boolean(str, &val)) {
6985 return False;
6988 *inverse_str = get_boolean(!val);
6989 return True;
6992 /***************************************************************************
6993 Provide the canonical string representation of a boolean value given
6994 as a string. Return True on success, False if the string given does
6995 not correctly represent a boolean.
6996 ***************************************************************************/
6998 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
7000 bool val;
7002 if (!set_boolean(str, &val)) {
7003 return False;
7006 *canon_str = get_boolean(val);
7007 return True;
7010 /***************************************************************************
7011 Find a service by name. Otherwise works like get_service.
7012 ***************************************************************************/
7014 static int getservicebyname(const char *pszServiceName, struct service *pserviceDest)
7016 int iService = -1;
7017 char *canon_name;
7018 TDB_DATA data;
7020 if (ServiceHash == NULL) {
7021 return -1;
7024 canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
7026 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
7028 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
7029 iService = *(int *)data.dptr;
7032 TALLOC_FREE(canon_name);
7034 if ((iService != -1) && (LP_SNUM_OK(iService))
7035 && (pserviceDest != NULL)) {
7036 copy_service(pserviceDest, ServicePtrs[iService], NULL);
7039 return (iService);
7042 /***************************************************************************
7043 Copy a service structure to another.
7044 If pcopymapDest is NULL then copy all fields
7045 ***************************************************************************/
7048 * Add a parametric option to a param_opt_struct,
7049 * replacing old value, if already present.
7051 static void set_param_opt(struct param_opt_struct **opt_list,
7052 const char *opt_name,
7053 const char *opt_value,
7054 unsigned flags)
7056 struct param_opt_struct *new_opt, *opt;
7057 bool not_added;
7059 if (opt_list == NULL) {
7060 return;
7063 opt = *opt_list;
7064 not_added = true;
7066 /* Traverse destination */
7067 while (opt) {
7068 /* If we already have same option, override it */
7069 if (strwicmp(opt->key, opt_name) == 0) {
7070 if ((opt->flags & FLAG_CMDLINE) &&
7071 !(flags & FLAG_CMDLINE)) {
7072 /* it's been marked as not to be
7073 overridden */
7074 return;
7076 string_free(&opt->value);
7077 TALLOC_FREE(opt->list);
7078 opt->value = SMB_STRDUP(opt_value);
7079 opt->flags = flags;
7080 not_added = false;
7081 break;
7083 opt = opt->next;
7085 if (not_added) {
7086 new_opt = SMB_XMALLOC_P(struct param_opt_struct);
7087 new_opt->key = SMB_STRDUP(opt_name);
7088 new_opt->value = SMB_STRDUP(opt_value);
7089 new_opt->list = NULL;
7090 new_opt->flags = flags;
7091 DLIST_ADD(*opt_list, new_opt);
7095 static void copy_service(struct service *pserviceDest, struct service *pserviceSource,
7096 struct bitmap *pcopymapDest)
7098 int i;
7099 bool bcopyall = (pcopymapDest == NULL);
7100 struct param_opt_struct *data;
7102 for (i = 0; parm_table[i].label; i++)
7103 if (parm_table[i].ptr && parm_table[i].p_class == P_LOCAL &&
7104 (bcopyall || bitmap_query(pcopymapDest,i))) {
7105 void *def_ptr = parm_table[i].ptr;
7106 void *src_ptr =
7107 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
7108 &sDefault);
7109 void *dest_ptr =
7110 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
7111 &sDefault);
7113 switch (parm_table[i].type) {
7114 case P_BOOL:
7115 case P_BOOLREV:
7116 *(bool *)dest_ptr = *(bool *)src_ptr;
7117 break;
7119 case P_INTEGER:
7120 case P_ENUM:
7121 case P_OCTAL:
7122 *(int *)dest_ptr = *(int *)src_ptr;
7123 break;
7125 case P_CHAR:
7126 *(char *)dest_ptr = *(char *)src_ptr;
7127 break;
7129 case P_STRING:
7130 string_set((char **)dest_ptr,
7131 *(char **)src_ptr);
7132 break;
7134 case P_USTRING:
7135 string_set((char **)dest_ptr,
7136 *(char **)src_ptr);
7137 strupper_m(*(char **)dest_ptr);
7138 break;
7139 case P_LIST:
7140 TALLOC_FREE(*((char ***)dest_ptr));
7141 *((char ***)dest_ptr) = str_list_copy(NULL,
7142 *(const char ***)src_ptr);
7143 break;
7144 default:
7145 break;
7149 if (bcopyall) {
7150 init_copymap(pserviceDest);
7151 if (pserviceSource->copymap)
7152 bitmap_copy(pserviceDest->copymap,
7153 pserviceSource->copymap);
7156 data = pserviceSource->param_opt;
7157 while (data) {
7158 set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->flags);
7159 data = data->next;
7163 /***************************************************************************
7164 Check a service for consistency. Return False if the service is in any way
7165 incomplete or faulty, else True.
7166 ***************************************************************************/
7168 bool service_ok(int iService)
7170 bool bRetval;
7172 bRetval = True;
7173 if (ServicePtrs[iService]->szService[0] == '\0') {
7174 DEBUG(0, ("The following message indicates an internal error:\n"));
7175 DEBUG(0, ("No service name in service entry.\n"));
7176 bRetval = False;
7179 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
7180 /* I can't see why you'd want a non-printable printer service... */
7181 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
7182 if (!ServicePtrs[iService]->bPrint_ok) {
7183 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
7184 ServicePtrs[iService]->szService));
7185 ServicePtrs[iService]->bPrint_ok = True;
7187 /* [printers] service must also be non-browsable. */
7188 if (ServicePtrs[iService]->bBrowseable)
7189 ServicePtrs[iService]->bBrowseable = False;
7192 if (ServicePtrs[iService]->szPath[0] == '\0' &&
7193 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
7194 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
7196 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
7197 ServicePtrs[iService]->szService));
7198 ServicePtrs[iService]->bAvailable = False;
7201 /* If a service is flagged unavailable, log the fact at level 1. */
7202 if (!ServicePtrs[iService]->bAvailable)
7203 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
7204 ServicePtrs[iService]->szService));
7206 return (bRetval);
7209 static struct smbconf_ctx *lp_smbconf_ctx(void)
7211 sbcErr err;
7212 static struct smbconf_ctx *conf_ctx = NULL;
7214 if (conf_ctx == NULL) {
7215 err = smbconf_init(NULL, &conf_ctx, "registry:");
7216 if (!SBC_ERROR_IS_OK(err)) {
7217 DEBUG(1, ("error initializing registry configuration: "
7218 "%s\n", sbcErrorString(err)));
7219 conf_ctx = NULL;
7223 return conf_ctx;
7226 static bool process_smbconf_service(struct smbconf_service *service)
7228 uint32_t count;
7229 bool ret;
7231 if (service == NULL) {
7232 return false;
7235 ret = do_section(service->name, NULL);
7236 if (ret != true) {
7237 return false;
7239 for (count = 0; count < service->num_params; count++) {
7240 ret = do_parameter(service->param_names[count],
7241 service->param_values[count],
7242 NULL);
7243 if (ret != true) {
7244 return false;
7247 if (iServiceIndex >= 0) {
7248 return service_ok(iServiceIndex);
7250 return true;
7254 * load a service from registry and activate it
7256 bool process_registry_service(const char *service_name)
7258 sbcErr err;
7259 struct smbconf_service *service = NULL;
7260 TALLOC_CTX *mem_ctx = talloc_stackframe();
7261 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7262 bool ret = false;
7264 if (conf_ctx == NULL) {
7265 goto done;
7268 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
7270 if (!smbconf_share_exists(conf_ctx, service_name)) {
7272 * Registry does not contain data for this service (yet),
7273 * but make sure lp_load doesn't return false.
7275 ret = true;
7276 goto done;
7279 err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
7280 if (!SBC_ERROR_IS_OK(err)) {
7281 goto done;
7284 ret = process_smbconf_service(service);
7285 if (!ret) {
7286 goto done;
7289 /* store the csn */
7290 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
7292 done:
7293 TALLOC_FREE(mem_ctx);
7294 return ret;
7298 * process_registry_globals
7300 static bool process_registry_globals(void)
7302 bool ret;
7304 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
7306 ret = do_parameter("registry shares", "yes", NULL);
7307 if (!ret) {
7308 return ret;
7311 return process_registry_service(GLOBAL_NAME);
7314 bool process_registry_shares(void)
7316 WERROR werr;
7317 uint32_t count;
7318 struct smbconf_service **service = NULL;
7319 uint32_t num_shares = 0;
7320 TALLOC_CTX *mem_ctx = talloc_stackframe();
7321 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7322 bool ret = false;
7324 if (conf_ctx == NULL) {
7325 goto done;
7328 werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
7329 if (!W_ERROR_IS_OK(werr)) {
7330 goto done;
7333 ret = true;
7335 for (count = 0; count < num_shares; count++) {
7336 if (strequal(service[count]->name, GLOBAL_NAME)) {
7337 continue;
7339 ret = process_smbconf_service(service[count]);
7340 if (!ret) {
7341 goto done;
7345 /* store the csn */
7346 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
7348 done:
7349 TALLOC_FREE(mem_ctx);
7350 return ret;
7353 #define MAX_INCLUDE_DEPTH 100
7355 static uint8_t include_depth;
7357 static struct file_lists {
7358 struct file_lists *next;
7359 char *name;
7360 char *subfname;
7361 time_t modtime;
7362 } *file_lists = NULL;
7364 /*******************************************************************
7365 Keep a linked list of all config files so we know when one has changed
7366 it's date and needs to be reloaded.
7367 ********************************************************************/
7369 static void add_to_file_list(const char *fname, const char *subfname)
7371 struct file_lists *f = file_lists;
7373 while (f) {
7374 if (f->name && !strcmp(f->name, fname))
7375 break;
7376 f = f->next;
7379 if (!f) {
7380 f = SMB_MALLOC_P(struct file_lists);
7381 if (!f)
7382 return;
7383 f->next = file_lists;
7384 f->name = SMB_STRDUP(fname);
7385 if (!f->name) {
7386 SAFE_FREE(f);
7387 return;
7389 f->subfname = SMB_STRDUP(subfname);
7390 if (!f->subfname) {
7391 SAFE_FREE(f->name);
7392 SAFE_FREE(f);
7393 return;
7395 file_lists = f;
7396 f->modtime = file_modtime(subfname);
7397 } else {
7398 time_t t = file_modtime(subfname);
7399 if (t)
7400 f->modtime = t;
7402 return;
7406 * Free the file lists
7408 static void free_file_list(void)
7410 struct file_lists *f;
7411 struct file_lists *next;
7413 f = file_lists;
7414 while( f ) {
7415 next = f->next;
7416 SAFE_FREE( f->name );
7417 SAFE_FREE( f->subfname );
7418 SAFE_FREE( f );
7419 f = next;
7421 file_lists = NULL;
7426 * Utility function for outsiders to check if we're running on registry.
7428 bool lp_config_backend_is_registry(void)
7430 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
7434 * Utility function to check if the config backend is FILE.
7436 bool lp_config_backend_is_file(void)
7438 return (lp_config_backend() == CONFIG_BACKEND_FILE);
7441 /*******************************************************************
7442 Check if a config file has changed date.
7443 ********************************************************************/
7445 bool lp_file_list_changed(void)
7447 struct file_lists *f = file_lists;
7449 DEBUG(6, ("lp_file_list_changed()\n"));
7451 while (f) {
7452 time_t mod_time;
7454 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
7455 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7457 if (conf_ctx == NULL) {
7458 return false;
7460 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
7461 NULL))
7463 DEBUGADD(6, ("registry config changed\n"));
7464 return true;
7466 } else {
7467 char *n2 = NULL;
7468 n2 = talloc_sub_basic(talloc_tos(),
7469 get_current_username(),
7470 current_user_info.domain,
7471 f->name);
7472 if (!n2) {
7473 return false;
7475 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
7476 f->name, n2, ctime(&f->modtime)));
7478 mod_time = file_modtime(n2);
7480 if (mod_time &&
7481 ((f->modtime != mod_time) ||
7482 (f->subfname == NULL) ||
7483 (strcmp(n2, f->subfname) != 0)))
7485 DEBUGADD(6,
7486 ("file %s modified: %s\n", n2,
7487 ctime(&mod_time)));
7488 f->modtime = mod_time;
7489 SAFE_FREE(f->subfname);
7490 f->subfname = SMB_STRDUP(n2);
7491 TALLOC_FREE(n2);
7492 return true;
7494 TALLOC_FREE(n2);
7496 f = f->next;
7498 return (False);
7502 /***************************************************************************
7503 Run standard_sub_basic on netbios name... needed because global_myname
7504 is not accessed through any lp_ macro.
7505 Note: We must *NOT* use string_set() here as ptr points to global_myname.
7506 ***************************************************************************/
7508 static bool handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
7510 bool ret;
7511 char *netbios_name = talloc_sub_basic(
7512 talloc_tos(), get_current_username(), current_user_info.domain,
7513 pszParmValue);
7515 ret = set_global_myname(netbios_name);
7516 TALLOC_FREE(netbios_name);
7517 string_set(&Globals.szNetbiosName,global_myname());
7519 DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
7520 global_myname()));
7522 return ret;
7525 static bool handle_charset(int snum, const char *pszParmValue, char **ptr)
7527 if (strcmp(*ptr, pszParmValue) != 0) {
7528 string_set(ptr, pszParmValue);
7529 init_iconv();
7531 return True;
7536 static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
7538 bool ret;
7540 ret = set_global_myworkgroup(pszParmValue);
7541 string_set(&Globals.szWorkgroup,lp_workgroup());
7543 return ret;
7546 static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
7548 bool ret;
7550 ret = set_global_scope(pszParmValue);
7551 string_set(&Globals.szNetbiosScope,global_scope());
7553 return ret;
7556 static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
7558 TALLOC_FREE(Globals.szNetbiosAliases);
7559 Globals.szNetbiosAliases = str_list_make_v3(NULL, pszParmValue, NULL);
7560 return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
7563 /***************************************************************************
7564 Handle the include operation.
7565 ***************************************************************************/
7566 static bool bAllowIncludeRegistry = true;
7568 static bool handle_include(int snum, const char *pszParmValue, char **ptr)
7570 char *fname;
7572 if (include_depth >= MAX_INCLUDE_DEPTH) {
7573 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
7574 include_depth));
7575 return false;
7578 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
7579 if (!bAllowIncludeRegistry) {
7580 return true;
7582 if (bInGlobalSection) {
7583 bool ret;
7584 include_depth++;
7585 ret = process_registry_globals();
7586 include_depth--;
7587 return ret;
7588 } else {
7589 DEBUG(1, ("\"include = registry\" only effective "
7590 "in %s section\n", GLOBAL_NAME));
7591 return false;
7595 fname = talloc_sub_basic(talloc_tos(), get_current_username(),
7596 current_user_info.domain,
7597 pszParmValue);
7599 add_to_file_list(pszParmValue, fname);
7601 string_set(ptr, fname);
7603 if (file_exist(fname)) {
7604 bool ret;
7605 include_depth++;
7606 ret = pm_process(fname, do_section, do_parameter, NULL);
7607 include_depth--;
7608 TALLOC_FREE(fname);
7609 return ret;
7612 DEBUG(2, ("Can't find include file %s\n", fname));
7613 TALLOC_FREE(fname);
7614 return true;
7617 /***************************************************************************
7618 Handle the interpretation of the copy parameter.
7619 ***************************************************************************/
7621 static bool handle_copy(int snum, const char *pszParmValue, char **ptr)
7623 bool bRetval;
7624 int iTemp;
7625 struct service serviceTemp;
7627 string_set(ptr, pszParmValue);
7629 init_service(&serviceTemp);
7631 bRetval = False;
7633 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7635 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7636 if (iTemp == iServiceIndex) {
7637 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7638 } else {
7639 copy_service(ServicePtrs[iServiceIndex],
7640 &serviceTemp,
7641 ServicePtrs[iServiceIndex]->copymap);
7642 bRetval = True;
7644 } else {
7645 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7646 bRetval = False;
7649 free_service(&serviceTemp);
7650 return (bRetval);
7653 static bool handle_ldap_debug_level(int snum, const char *pszParmValue, char **ptr)
7655 Globals.ldap_debug_level = lp_int(pszParmValue);
7656 init_ldap_debugging();
7657 return true;
7660 /***************************************************************************
7661 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7662 parameters is:
7664 [global]
7666 idmap uid = 1000-1999
7667 idmap gid = 700-899
7669 We only do simple parsing checks here. The strings are parsed into useful
7670 structures in the idmap daemon code.
7672 ***************************************************************************/
7674 /* Some lp_ routines to return idmap [ug]id information */
7676 static uid_t idmap_uid_low, idmap_uid_high;
7677 static gid_t idmap_gid_low, idmap_gid_high;
7679 bool lp_idmap_uid(uid_t *low, uid_t *high)
7681 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7682 return False;
7684 if (low)
7685 *low = idmap_uid_low;
7687 if (high)
7688 *high = idmap_uid_high;
7690 return True;
7693 bool lp_idmap_gid(gid_t *low, gid_t *high)
7695 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7696 return False;
7698 if (low)
7699 *low = idmap_gid_low;
7701 if (high)
7702 *high = idmap_gid_high;
7704 return True;
7707 static bool handle_idmap_backend(int snum, const char *pszParmValue, char **ptr)
7709 lp_do_parameter(snum, "idmap config * : backend", pszParmValue);
7711 return true;
7714 /* Do some simple checks on "idmap [ug]id" parameter values */
7716 static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
7718 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7720 return True;
7723 static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
7725 lp_do_parameter(snum, "idmap config * : range", pszParmValue);
7727 return True;
7730 /***************************************************************************
7731 Handle the DEBUG level list.
7732 ***************************************************************************/
7734 static bool handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
7736 string_set(ptr, pszParmValueIn);
7737 return debug_parse_levels(pszParmValueIn);
7740 /***************************************************************************
7741 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7742 ***************************************************************************/
7744 static const char *append_ldap_suffix( const char *str )
7746 const char *suffix_string;
7749 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7750 Globals.szLdapSuffix );
7751 if ( !suffix_string ) {
7752 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7753 return "";
7756 return suffix_string;
7759 const char *lp_ldap_machine_suffix(void)
7761 if (Globals.szLdapMachineSuffix[0])
7762 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7764 return lp_string(Globals.szLdapSuffix);
7767 const char *lp_ldap_user_suffix(void)
7769 if (Globals.szLdapUserSuffix[0])
7770 return append_ldap_suffix(Globals.szLdapUserSuffix);
7772 return lp_string(Globals.szLdapSuffix);
7775 const char *lp_ldap_group_suffix(void)
7777 if (Globals.szLdapGroupSuffix[0])
7778 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7780 return lp_string(Globals.szLdapSuffix);
7783 const char *lp_ldap_idmap_suffix(void)
7785 if (Globals.szLdapIdmapSuffix[0])
7786 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7788 return lp_string(Globals.szLdapSuffix);
7791 /****************************************************************************
7792 set the value for a P_ENUM
7793 ***************************************************************************/
7795 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7796 int *ptr )
7798 int i;
7800 for (i = 0; parm->enum_list[i].name; i++) {
7801 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7802 *ptr = parm->enum_list[i].value;
7803 return;
7806 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7807 pszParmValue, parm->label));
7810 /***************************************************************************
7811 ***************************************************************************/
7813 static bool handle_printing(int snum, const char *pszParmValue, char **ptr)
7815 static int parm_num = -1;
7816 struct service *s;
7818 if ( parm_num == -1 )
7819 parm_num = map_parameter( "printing" );
7821 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7823 if ( snum < 0 )
7824 s = &sDefault;
7825 else
7826 s = ServicePtrs[snum];
7828 init_printer_values( s );
7830 return True;
7834 /***************************************************************************
7835 Initialise a copymap.
7836 ***************************************************************************/
7838 static void init_copymap(struct service *pservice)
7840 int i;
7842 TALLOC_FREE(pservice->copymap);
7844 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
7845 if (!pservice->copymap)
7846 DEBUG(0,
7847 ("Couldn't allocate copymap!! (size %d)\n",
7848 (int)NUMPARAMETERS));
7849 else
7850 for (i = 0; i < NUMPARAMETERS; i++)
7851 bitmap_set(pservice->copymap, i);
7854 /***************************************************************************
7855 Return the local pointer to a parameter given a service struct and the
7856 pointer into the default structure.
7857 ***************************************************************************/
7859 static void *lp_local_ptr(struct service *service, void *ptr)
7861 return (void *)(((char *)service) + PTR_DIFF(ptr, &sDefault));
7864 /***************************************************************************
7865 Return the local pointer to a parameter given the service number and the
7866 pointer into the default structure.
7867 ***************************************************************************/
7869 void *lp_local_ptr_by_snum(int snum, void *ptr)
7871 return lp_local_ptr(ServicePtrs[snum], ptr);
7874 /***************************************************************************
7875 Process a parameter for a particular service number. If snum < 0
7876 then assume we are in the globals.
7877 ***************************************************************************/
7879 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7881 int parmnum, i;
7882 void *parm_ptr = NULL; /* where we are going to store the result */
7883 void *def_ptr = NULL;
7884 struct param_opt_struct **opt_list;
7886 parmnum = map_parameter(pszParmName);
7888 if (parmnum < 0) {
7889 if (strchr(pszParmName, ':') == NULL) {
7890 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7891 pszParmName));
7892 return (True);
7896 * We've got a parametric option
7899 opt_list = (snum < 0)
7900 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7901 set_param_opt(opt_list, pszParmName, pszParmValue, 0);
7903 return (True);
7906 /* if it's already been set by the command line, then we don't
7907 override here */
7908 if (parm_table[parmnum].flags & FLAG_CMDLINE) {
7909 return true;
7912 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7913 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7914 pszParmName));
7917 def_ptr = parm_table[parmnum].ptr;
7919 /* we might point at a service, the default service or a global */
7920 if (snum < 0) {
7921 parm_ptr = def_ptr;
7922 } else {
7923 if (parm_table[parmnum].p_class == P_GLOBAL) {
7924 DEBUG(0,
7925 ("Global parameter %s found in service section!\n",
7926 pszParmName));
7927 return (True);
7929 parm_ptr = lp_local_ptr_by_snum(snum, def_ptr);
7932 if (snum >= 0) {
7933 if (!ServicePtrs[snum]->copymap)
7934 init_copymap(ServicePtrs[snum]);
7936 /* this handles the aliases - set the copymap for other entries with
7937 the same data pointer */
7938 for (i = 0; parm_table[i].label; i++)
7939 if (parm_table[i].ptr == parm_table[parmnum].ptr)
7940 bitmap_clear(ServicePtrs[snum]->copymap, i);
7943 /* if it is a special case then go ahead */
7944 if (parm_table[parmnum].special) {
7945 return parm_table[parmnum].special(snum, pszParmValue,
7946 (char **)parm_ptr);
7949 /* now switch on the type of variable it is */
7950 switch (parm_table[parmnum].type)
7952 case P_BOOL:
7953 *(bool *)parm_ptr = lp_bool(pszParmValue);
7954 break;
7956 case P_BOOLREV:
7957 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7958 break;
7960 case P_INTEGER:
7961 *(int *)parm_ptr = lp_int(pszParmValue);
7962 break;
7964 case P_CHAR:
7965 *(char *)parm_ptr = *pszParmValue;
7966 break;
7968 case P_OCTAL:
7969 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7970 if ( i != 1 ) {
7971 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7973 break;
7975 case P_LIST:
7976 TALLOC_FREE(*((char ***)parm_ptr));
7977 *(char ***)parm_ptr = str_list_make_v3(
7978 NULL, pszParmValue, NULL);
7979 break;
7981 case P_STRING:
7982 string_set((char **)parm_ptr, pszParmValue);
7983 break;
7985 case P_USTRING:
7986 string_set((char **)parm_ptr, pszParmValue);
7987 strupper_m(*(char **)parm_ptr);
7988 break;
7990 case P_ENUM:
7991 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7992 break;
7993 case P_SEP:
7994 break;
7997 return (True);
8000 /***************************************************************************
8001 set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
8002 FLAG_CMDLINE won't be overridden by loads from smb.conf.
8003 ***************************************************************************/
8005 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
8007 int parmnum, i;
8008 parmnum = map_parameter(pszParmName);
8009 if (parmnum >= 0) {
8010 parm_table[parmnum].flags &= ~FLAG_CMDLINE;
8011 if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
8012 return false;
8014 parm_table[parmnum].flags |= FLAG_CMDLINE;
8016 /* we have to also set FLAG_CMDLINE on aliases. Aliases must
8017 * be grouped in the table, so we don't have to search the
8018 * whole table */
8019 for (i=parmnum-1;i>=0 && parm_table[i].ptr == parm_table[parmnum].ptr;i--) {
8020 parm_table[i].flags |= FLAG_CMDLINE;
8022 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].ptr == parm_table[parmnum].ptr;i++) {
8023 parm_table[i].flags |= FLAG_CMDLINE;
8026 if (store_values) {
8027 store_lp_set_cmdline(pszParmName, pszParmValue);
8029 return true;
8032 /* it might be parametric */
8033 if (strchr(pszParmName, ':') != NULL) {
8034 set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
8035 if (store_values) {
8036 store_lp_set_cmdline(pszParmName, pszParmValue);
8038 return true;
8041 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
8042 return true;
8045 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
8047 return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
8050 /***************************************************************************
8051 Process a parameter.
8052 ***************************************************************************/
8054 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
8055 void *userdata)
8057 if (!bInGlobalSection && bGlobalOnly)
8058 return (True);
8060 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
8062 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
8063 pszParmName, pszParmValue));
8067 set a option from the commandline in 'a=b' format. Use to support --option
8069 bool lp_set_option(const char *option)
8071 char *p, *s;
8072 bool ret;
8074 s = talloc_strdup(NULL, option);
8075 if (!s) {
8076 return false;
8079 p = strchr(s, '=');
8080 if (!p) {
8081 talloc_free(s);
8082 return false;
8085 *p = 0;
8087 /* skip white spaces after the = sign */
8088 do {
8089 p++;
8090 } while (*p == ' ');
8092 ret = lp_set_cmdline(s, p);
8093 talloc_free(s);
8094 return ret;
8097 /**************************************************************************
8098 Print a parameter of the specified type.
8099 ***************************************************************************/
8101 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
8103 int i;
8104 switch (p->type)
8106 case P_ENUM:
8107 for (i = 0; p->enum_list[i].name; i++) {
8108 if (*(int *)ptr == p->enum_list[i].value) {
8109 fprintf(f, "%s",
8110 p->enum_list[i].name);
8111 break;
8114 break;
8116 case P_BOOL:
8117 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
8118 break;
8120 case P_BOOLREV:
8121 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
8122 break;
8124 case P_INTEGER:
8125 fprintf(f, "%d", *(int *)ptr);
8126 break;
8128 case P_CHAR:
8129 fprintf(f, "%c", *(char *)ptr);
8130 break;
8132 case P_OCTAL: {
8133 char *o = octal_string(*(int *)ptr);
8134 fprintf(f, "%s", o);
8135 TALLOC_FREE(o);
8136 break;
8139 case P_LIST:
8140 if ((char ***)ptr && *(char ***)ptr) {
8141 char **list = *(char ***)ptr;
8142 for (; *list; list++) {
8143 /* surround strings with whitespace in double quotes */
8144 if ( strchr_m( *list, ' ' ) )
8145 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
8146 else
8147 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
8150 break;
8152 case P_STRING:
8153 case P_USTRING:
8154 if (*(char **)ptr) {
8155 fprintf(f, "%s", *(char **)ptr);
8157 break;
8158 case P_SEP:
8159 break;
8163 /***************************************************************************
8164 Check if two parameters are equal.
8165 ***************************************************************************/
8167 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
8169 switch (type) {
8170 case P_BOOL:
8171 case P_BOOLREV:
8172 return (*((bool *)ptr1) == *((bool *)ptr2));
8174 case P_INTEGER:
8175 case P_ENUM:
8176 case P_OCTAL:
8177 return (*((int *)ptr1) == *((int *)ptr2));
8179 case P_CHAR:
8180 return (*((char *)ptr1) == *((char *)ptr2));
8182 case P_LIST:
8183 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
8185 case P_STRING:
8186 case P_USTRING:
8188 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
8189 if (p1 && !*p1)
8190 p1 = NULL;
8191 if (p2 && !*p2)
8192 p2 = NULL;
8193 return (p1 == p2 || strequal(p1, p2));
8195 case P_SEP:
8196 break;
8198 return (False);
8201 /***************************************************************************
8202 Initialize any local varients in the sDefault table.
8203 ***************************************************************************/
8205 void init_locals(void)
8207 /* None as yet. */
8210 /***************************************************************************
8211 Process a new section (service). At this stage all sections are services.
8212 Later we'll have special sections that permit server parameters to be set.
8213 Returns True on success, False on failure.
8214 ***************************************************************************/
8216 static bool do_section(const char *pszSectionName, void *userdata)
8218 bool bRetval;
8219 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
8220 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
8221 bRetval = False;
8223 /* if we were in a global section then do the local inits */
8224 if (bInGlobalSection && !isglobal)
8225 init_locals();
8227 /* if we've just struck a global section, note the fact. */
8228 bInGlobalSection = isglobal;
8230 /* check for multiple global sections */
8231 if (bInGlobalSection) {
8232 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
8233 return (True);
8236 if (!bInGlobalSection && bGlobalOnly)
8237 return (True);
8239 /* if we have a current service, tidy it up before moving on */
8240 bRetval = True;
8242 if (iServiceIndex >= 0)
8243 bRetval = service_ok(iServiceIndex);
8245 /* if all is still well, move to the next record in the services array */
8246 if (bRetval) {
8247 /* We put this here to avoid an odd message order if messages are */
8248 /* issued by the post-processing of a previous section. */
8249 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
8251 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
8252 < 0) {
8253 DEBUG(0, ("Failed to add a new service\n"));
8254 return (False);
8256 /* Clean all parametric options for service */
8257 /* They will be added during parsing again */
8258 free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
8261 return (bRetval);
8265 /***************************************************************************
8266 Determine if a partcular base parameter is currentl set to the default value.
8267 ***************************************************************************/
8269 static bool is_default(int i)
8271 if (!defaults_saved)
8272 return False;
8273 switch (parm_table[i].type) {
8274 case P_LIST:
8275 return str_list_equal((const char **)parm_table[i].def.lvalue,
8276 *(const char ***)parm_table[i].ptr);
8277 case P_STRING:
8278 case P_USTRING:
8279 return strequal(parm_table[i].def.svalue,
8280 *(char **)parm_table[i].ptr);
8281 case P_BOOL:
8282 case P_BOOLREV:
8283 return parm_table[i].def.bvalue ==
8284 *(bool *)parm_table[i].ptr;
8285 case P_CHAR:
8286 return parm_table[i].def.cvalue ==
8287 *(char *)parm_table[i].ptr;
8288 case P_INTEGER:
8289 case P_OCTAL:
8290 case P_ENUM:
8291 return parm_table[i].def.ivalue ==
8292 *(int *)parm_table[i].ptr;
8293 case P_SEP:
8294 break;
8296 return False;
8299 /***************************************************************************
8300 Display the contents of the global structure.
8301 ***************************************************************************/
8303 static void dump_globals(FILE *f)
8305 int i;
8306 struct param_opt_struct *data;
8308 fprintf(f, "[global]\n");
8310 for (i = 0; parm_table[i].label; i++)
8311 if (parm_table[i].p_class == P_GLOBAL &&
8312 !(parm_table[i].flags & FLAG_META) &&
8313 parm_table[i].ptr &&
8314 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
8315 if (defaults_saved && is_default(i))
8316 continue;
8317 fprintf(f, "\t%s = ", parm_table[i].label);
8318 print_parameter(&parm_table[i], parm_table[i].ptr, f);
8319 fprintf(f, "\n");
8321 if (Globals.param_opt != NULL) {
8322 data = Globals.param_opt;
8323 while(data) {
8324 fprintf(f, "\t%s = %s\n", data->key, data->value);
8325 data = data->next;
8331 /***************************************************************************
8332 Return True if a local parameter is currently set to the global default.
8333 ***************************************************************************/
8335 bool lp_is_default(int snum, struct parm_struct *parm)
8337 int pdiff = PTR_DIFF(parm->ptr, &sDefault);
8339 return equal_parameter(parm->type,
8340 ((char *)ServicePtrs[snum]) + pdiff,
8341 ((char *)&sDefault) + pdiff);
8344 /***************************************************************************
8345 Display the contents of a single services record.
8346 ***************************************************************************/
8348 static void dump_a_service(struct service *pService, FILE * f)
8350 int i;
8351 struct param_opt_struct *data;
8353 if (pService != &sDefault)
8354 fprintf(f, "[%s]\n", pService->szService);
8356 for (i = 0; parm_table[i].label; i++) {
8358 if (parm_table[i].p_class == P_LOCAL &&
8359 !(parm_table[i].flags & FLAG_META) &&
8360 parm_table[i].ptr &&
8361 (*parm_table[i].label != '-') &&
8362 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8364 int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
8366 if (pService == &sDefault) {
8367 if (defaults_saved && is_default(i))
8368 continue;
8369 } else {
8370 if (equal_parameter(parm_table[i].type,
8371 ((char *)pService) +
8372 pdiff,
8373 ((char *)&sDefault) +
8374 pdiff))
8375 continue;
8378 fprintf(f, "\t%s = ", parm_table[i].label);
8379 print_parameter(&parm_table[i],
8380 ((char *)pService) + pdiff, f);
8381 fprintf(f, "\n");
8385 if (pService->param_opt != NULL) {
8386 data = pService->param_opt;
8387 while(data) {
8388 fprintf(f, "\t%s = %s\n", data->key, data->value);
8389 data = data->next;
8394 /***************************************************************************
8395 Display the contents of a parameter of a single services record.
8396 ***************************************************************************/
8398 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
8400 int i;
8401 bool result = False;
8402 parm_class p_class;
8403 unsigned flag = 0;
8404 fstring local_parm_name;
8405 char *parm_opt;
8406 const char *parm_opt_value;
8408 /* check for parametrical option */
8409 fstrcpy( local_parm_name, parm_name);
8410 parm_opt = strchr( local_parm_name, ':');
8412 if (parm_opt) {
8413 *parm_opt = '\0';
8414 parm_opt++;
8415 if (strlen(parm_opt)) {
8416 parm_opt_value = lp_parm_const_string( snum,
8417 local_parm_name, parm_opt, NULL);
8418 if (parm_opt_value) {
8419 printf( "%s\n", parm_opt_value);
8420 result = True;
8423 return result;
8426 /* check for a key and print the value */
8427 if (isGlobal) {
8428 p_class = P_GLOBAL;
8429 flag = FLAG_GLOBAL;
8430 } else
8431 p_class = P_LOCAL;
8433 for (i = 0; parm_table[i].label; i++) {
8434 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
8435 !(parm_table[i].flags & FLAG_META) &&
8436 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
8437 parm_table[i].ptr &&
8438 (*parm_table[i].label != '-') &&
8439 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8441 void *ptr;
8443 if (isGlobal) {
8444 ptr = parm_table[i].ptr;
8445 } else {
8446 struct service *pService = ServicePtrs[snum];
8447 ptr = ((char *)pService) +
8448 PTR_DIFF(parm_table[i].ptr, &sDefault);
8451 print_parameter(&parm_table[i],
8452 ptr, f);
8453 fprintf(f, "\n");
8454 result = True;
8455 break;
8459 return result;
8462 /***************************************************************************
8463 Return info about the requested parameter (given as a string).
8464 Return NULL when the string is not a valid parameter name.
8465 ***************************************************************************/
8467 struct parm_struct *lp_get_parameter(const char *param_name)
8469 int num = map_parameter(param_name);
8471 if (num < 0) {
8472 return NULL;
8475 return &parm_table[num];
8478 /***************************************************************************
8479 Return info about the next parameter in a service.
8480 snum==GLOBAL_SECTION_SNUM gives the globals.
8481 Return NULL when out of parameters.
8482 ***************************************************************************/
8484 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
8486 if (snum < 0) {
8487 /* do the globals */
8488 for (; parm_table[*i].label; (*i)++) {
8489 if (parm_table[*i].p_class == P_SEPARATOR)
8490 return &parm_table[(*i)++];
8492 if (!parm_table[*i].ptr
8493 || (*parm_table[*i].label == '-'))
8494 continue;
8496 if ((*i) > 0
8497 && (parm_table[*i].ptr ==
8498 parm_table[(*i) - 1].ptr))
8499 continue;
8501 if (is_default(*i) && !allparameters)
8502 continue;
8504 return &parm_table[(*i)++];
8506 } else {
8507 struct service *pService = ServicePtrs[snum];
8509 for (; parm_table[*i].label; (*i)++) {
8510 if (parm_table[*i].p_class == P_SEPARATOR)
8511 return &parm_table[(*i)++];
8513 if (parm_table[*i].p_class == P_LOCAL &&
8514 parm_table[*i].ptr &&
8515 (*parm_table[*i].label != '-') &&
8516 ((*i) == 0 ||
8517 (parm_table[*i].ptr !=
8518 parm_table[(*i) - 1].ptr)))
8520 int pdiff =
8521 PTR_DIFF(parm_table[*i].ptr,
8522 &sDefault);
8524 if (allparameters ||
8525 !equal_parameter(parm_table[*i].type,
8526 ((char *)pService) +
8527 pdiff,
8528 ((char *)&sDefault) +
8529 pdiff))
8531 return &parm_table[(*i)++];
8537 return NULL;
8541 #if 0
8542 /***************************************************************************
8543 Display the contents of a single copy structure.
8544 ***************************************************************************/
8545 static void dump_copy_map(bool *pcopymap)
8547 int i;
8548 if (!pcopymap)
8549 return;
8551 printf("\n\tNon-Copied parameters:\n");
8553 for (i = 0; parm_table[i].label; i++)
8554 if (parm_table[i].p_class == P_LOCAL &&
8555 parm_table[i].ptr && !pcopymap[i] &&
8556 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8558 printf("\t\t%s\n", parm_table[i].label);
8561 #endif
8563 /***************************************************************************
8564 Return TRUE if the passed service number is within range.
8565 ***************************************************************************/
8567 bool lp_snum_ok(int iService)
8569 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8572 /***************************************************************************
8573 Auto-load some home services.
8574 ***************************************************************************/
8576 static void lp_add_auto_services(char *str)
8578 char *s;
8579 char *p;
8580 int homes;
8581 char *saveptr;
8583 if (!str)
8584 return;
8586 s = SMB_STRDUP(str);
8587 if (!s)
8588 return;
8590 homes = lp_servicenumber(HOMES_NAME);
8592 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8593 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8594 char *home;
8596 if (lp_servicenumber(p) >= 0)
8597 continue;
8599 home = get_user_home_dir(talloc_tos(), p);
8601 if (home && home[0] && homes >= 0)
8602 lp_add_home(p, homes, p, home);
8604 TALLOC_FREE(home);
8606 SAFE_FREE(s);
8609 /***************************************************************************
8610 Auto-load one printer.
8611 ***************************************************************************/
8613 void lp_add_one_printer(const char *name, const char *comment, void *pdata)
8615 int printers = lp_servicenumber(PRINTERS_NAME);
8616 int i;
8618 if (lp_servicenumber(name) < 0) {
8619 lp_add_printer(name, printers);
8620 if ((i = lp_servicenumber(name)) >= 0) {
8621 string_set(&ServicePtrs[i]->comment, comment);
8622 ServicePtrs[i]->autoloaded = True;
8627 /***************************************************************************
8628 Have we loaded a services file yet?
8629 ***************************************************************************/
8631 bool lp_loaded(void)
8633 return (bLoaded);
8636 /***************************************************************************
8637 Unload unused services.
8638 ***************************************************************************/
8640 void lp_killunused(bool (*snumused) (int))
8642 int i;
8643 for (i = 0; i < iNumServices; i++) {
8644 if (!VALID(i))
8645 continue;
8647 /* don't kill autoloaded or usershare services */
8648 if ( ServicePtrs[i]->autoloaded ||
8649 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8650 continue;
8653 if (!snumused || !snumused(i)) {
8654 free_service_byindex(i);
8660 * Kill all except autoloaded and usershare services - convenience wrapper
8662 void lp_kill_all_services(void)
8664 lp_killunused(NULL);
8667 /***************************************************************************
8668 Unload a service.
8669 ***************************************************************************/
8671 void lp_killservice(int iServiceIn)
8673 if (VALID(iServiceIn)) {
8674 free_service_byindex(iServiceIn);
8678 /***************************************************************************
8679 Save the curent values of all global and sDefault parameters into the
8680 defaults union. This allows swat and testparm to show only the
8681 changed (ie. non-default) parameters.
8682 ***************************************************************************/
8684 static void lp_save_defaults(void)
8686 int i;
8687 for (i = 0; parm_table[i].label; i++) {
8688 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
8689 continue;
8690 switch (parm_table[i].type) {
8691 case P_LIST:
8692 parm_table[i].def.lvalue = str_list_copy(
8693 NULL, *(const char ***)parm_table[i].ptr);
8694 break;
8695 case P_STRING:
8696 case P_USTRING:
8697 if (parm_table[i].ptr) {
8698 parm_table[i].def.svalue = SMB_STRDUP(*(char **)parm_table[i].ptr);
8699 } else {
8700 parm_table[i].def.svalue = NULL;
8702 break;
8703 case P_BOOL:
8704 case P_BOOLREV:
8705 parm_table[i].def.bvalue =
8706 *(bool *)parm_table[i].ptr;
8707 break;
8708 case P_CHAR:
8709 parm_table[i].def.cvalue =
8710 *(char *)parm_table[i].ptr;
8711 break;
8712 case P_INTEGER:
8713 case P_OCTAL:
8714 case P_ENUM:
8715 parm_table[i].def.ivalue =
8716 *(int *)parm_table[i].ptr;
8717 break;
8718 case P_SEP:
8719 break;
8722 defaults_saved = True;
8725 /***********************************************************
8726 If we should send plaintext/LANMAN passwords in the clinet
8727 ************************************************************/
8729 static void set_allowed_client_auth(void)
8731 if (Globals.bClientNTLMv2Auth) {
8732 Globals.bClientLanManAuth = False;
8734 if (!Globals.bClientLanManAuth) {
8735 Globals.bClientPlaintextAuth = False;
8739 /***************************************************************************
8740 JRA.
8741 The following code allows smbd to read a user defined share file.
8742 Yes, this is my intent. Yes, I'm comfortable with that...
8744 THE FOLLOWING IS SECURITY CRITICAL CODE.
8746 It washes your clothes, it cleans your house, it guards you while you sleep...
8747 Do not f%^k with it....
8748 ***************************************************************************/
8750 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8752 /***************************************************************************
8753 Check allowed stat state of a usershare file.
8754 Ensure we print out who is dicking with us so the admin can
8755 get their sorry ass fired.
8756 ***************************************************************************/
8758 static bool check_usershare_stat(const char *fname,
8759 const SMB_STRUCT_STAT *psbuf)
8761 if (!S_ISREG(psbuf->st_ex_mode)) {
8762 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8763 "not a regular file\n",
8764 fname, (unsigned int)psbuf->st_ex_uid ));
8765 return False;
8768 /* Ensure this doesn't have the other write bit set. */
8769 if (psbuf->st_ex_mode & S_IWOTH) {
8770 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8771 "public write. Refusing to allow as a usershare file.\n",
8772 fname, (unsigned int)psbuf->st_ex_uid ));
8773 return False;
8776 /* Should be 10k or less. */
8777 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8778 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8779 "too large (%u) to be a user share file.\n",
8780 fname, (unsigned int)psbuf->st_ex_uid,
8781 (unsigned int)psbuf->st_ex_size ));
8782 return False;
8785 return True;
8788 /***************************************************************************
8789 Parse the contents of a usershare file.
8790 ***************************************************************************/
8792 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8793 SMB_STRUCT_STAT *psbuf,
8794 const char *servicename,
8795 int snum,
8796 char **lines,
8797 int numlines,
8798 char **pp_sharepath,
8799 char **pp_comment,
8800 char **pp_cp_servicename,
8801 struct security_descriptor **ppsd,
8802 bool *pallow_guest)
8804 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8805 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8806 int us_vers;
8807 SMB_STRUCT_DIR *dp;
8808 SMB_STRUCT_STAT sbuf;
8809 char *sharepath = NULL;
8810 char *comment = NULL;
8812 *pp_sharepath = NULL;
8813 *pp_comment = NULL;
8815 *pallow_guest = False;
8817 if (numlines < 4) {
8818 return USERSHARE_MALFORMED_FILE;
8821 if (strcmp(lines[0], "#VERSION 1") == 0) {
8822 us_vers = 1;
8823 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8824 us_vers = 2;
8825 if (numlines < 5) {
8826 return USERSHARE_MALFORMED_FILE;
8828 } else {
8829 return USERSHARE_BAD_VERSION;
8832 if (strncmp(lines[1], "path=", 5) != 0) {
8833 return USERSHARE_MALFORMED_PATH;
8836 sharepath = talloc_strdup(ctx, &lines[1][5]);
8837 if (!sharepath) {
8838 return USERSHARE_POSIX_ERR;
8840 trim_string(sharepath, " ", " ");
8842 if (strncmp(lines[2], "comment=", 8) != 0) {
8843 return USERSHARE_MALFORMED_COMMENT_DEF;
8846 comment = talloc_strdup(ctx, &lines[2][8]);
8847 if (!comment) {
8848 return USERSHARE_POSIX_ERR;
8850 trim_string(comment, " ", " ");
8851 trim_char(comment, '"', '"');
8853 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8854 return USERSHARE_MALFORMED_ACL_DEF;
8857 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8858 return USERSHARE_ACL_ERR;
8861 if (us_vers == 2) {
8862 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8863 return USERSHARE_MALFORMED_ACL_DEF;
8865 if (lines[4][9] == 'y') {
8866 *pallow_guest = True;
8869 /* Backwards compatible extension to file version #2. */
8870 if (numlines > 5) {
8871 if (strncmp(lines[5], "sharename=", 10) != 0) {
8872 return USERSHARE_MALFORMED_SHARENAME_DEF;
8874 if (!strequal(&lines[5][10], servicename)) {
8875 return USERSHARE_BAD_SHARENAME;
8877 *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
8878 if (!*pp_cp_servicename) {
8879 return USERSHARE_POSIX_ERR;
8884 if (*pp_cp_servicename == NULL) {
8885 *pp_cp_servicename = talloc_strdup(ctx, servicename);
8886 if (!*pp_cp_servicename) {
8887 return USERSHARE_POSIX_ERR;
8891 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8892 /* Path didn't change, no checks needed. */
8893 *pp_sharepath = sharepath;
8894 *pp_comment = comment;
8895 return USERSHARE_OK;
8898 /* The path *must* be absolute. */
8899 if (sharepath[0] != '/') {
8900 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8901 servicename, sharepath));
8902 return USERSHARE_PATH_NOT_ABSOLUTE;
8905 /* If there is a usershare prefix deny list ensure one of these paths
8906 doesn't match the start of the user given path. */
8907 if (prefixdenylist) {
8908 int i;
8909 for ( i=0; prefixdenylist[i]; i++ ) {
8910 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8911 servicename, i, prefixdenylist[i], sharepath ));
8912 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8913 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8914 "usershare prefix deny list entries.\n",
8915 servicename, sharepath));
8916 return USERSHARE_PATH_IS_DENIED;
8921 /* If there is a usershare prefix allow list ensure one of these paths
8922 does match the start of the user given path. */
8924 if (prefixallowlist) {
8925 int i;
8926 for ( i=0; prefixallowlist[i]; i++ ) {
8927 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8928 servicename, i, prefixallowlist[i], sharepath ));
8929 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8930 break;
8933 if (prefixallowlist[i] == NULL) {
8934 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8935 "usershare prefix allow list entries.\n",
8936 servicename, sharepath));
8937 return USERSHARE_PATH_NOT_ALLOWED;
8941 /* Ensure this is pointing to a directory. */
8942 dp = sys_opendir(sharepath);
8944 if (!dp) {
8945 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8946 servicename, sharepath));
8947 return USERSHARE_PATH_NOT_DIRECTORY;
8950 /* Ensure the owner of the usershare file has permission to share
8951 this directory. */
8953 if (sys_stat(sharepath, &sbuf, false) == -1) {
8954 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8955 servicename, sharepath, strerror(errno) ));
8956 sys_closedir(dp);
8957 return USERSHARE_POSIX_ERR;
8960 sys_closedir(dp);
8962 if (!S_ISDIR(sbuf.st_ex_mode)) {
8963 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8964 servicename, sharepath ));
8965 return USERSHARE_PATH_NOT_DIRECTORY;
8968 /* Check if sharing is restricted to owner-only. */
8969 /* psbuf is the stat of the usershare definition file,
8970 sbuf is the stat of the target directory to be shared. */
8972 if (lp_usershare_owner_only()) {
8973 /* root can share anything. */
8974 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8975 return USERSHARE_PATH_NOT_ALLOWED;
8979 *pp_sharepath = sharepath;
8980 *pp_comment = comment;
8981 return USERSHARE_OK;
8984 /***************************************************************************
8985 Deal with a usershare file.
8986 Returns:
8987 >= 0 - snum
8988 -1 - Bad name, invalid contents.
8989 - service name already existed and not a usershare, problem
8990 with permissions to share directory etc.
8991 ***************************************************************************/
8993 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8995 SMB_STRUCT_STAT sbuf;
8996 SMB_STRUCT_STAT lsbuf;
8997 char *fname = NULL;
8998 char *sharepath = NULL;
8999 char *comment = NULL;
9000 char *cp_service_name = NULL;
9001 char **lines = NULL;
9002 int numlines = 0;
9003 int fd = -1;
9004 int iService = -1;
9005 TALLOC_CTX *ctx = talloc_stackframe();
9006 struct security_descriptor *psd = NULL;
9007 bool guest_ok = False;
9008 char *canon_name = NULL;
9009 bool added_service = false;
9010 int ret = -1;
9012 /* Ensure share name doesn't contain invalid characters. */
9013 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
9014 DEBUG(0,("process_usershare_file: share name %s contains "
9015 "invalid characters (any of %s)\n",
9016 file_name, INVALID_SHARENAME_CHARS ));
9017 goto out;
9020 canon_name = canonicalize_servicename(ctx, file_name);
9021 if (!canon_name) {
9022 goto out;
9025 fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
9026 if (!fname) {
9027 goto out;
9030 /* Minimize the race condition by doing an lstat before we
9031 open and fstat. Ensure this isn't a symlink link. */
9033 if (sys_lstat(fname, &lsbuf, false) != 0) {
9034 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
9035 fname, strerror(errno) ));
9036 goto out;
9039 /* This must be a regular file, not a symlink, directory or
9040 other strange filetype. */
9041 if (!check_usershare_stat(fname, &lsbuf)) {
9042 goto out;
9046 TDB_DATA data = dbwrap_fetch_bystring(
9047 ServiceHash, canon_name, canon_name);
9049 iService = -1;
9051 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
9052 iService = *(int *)data.dptr;
9056 if (iService != -1 &&
9057 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9058 &lsbuf.st_ex_mtime) == 0) {
9059 /* Nothing changed - Mark valid and return. */
9060 DEBUG(10,("process_usershare_file: service %s not changed.\n",
9061 canon_name ));
9062 ServicePtrs[iService]->usershare = USERSHARE_VALID;
9063 ret = iService;
9064 goto out;
9067 /* Try and open the file read only - no symlinks allowed. */
9068 #ifdef O_NOFOLLOW
9069 fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
9070 #else
9071 fd = sys_open(fname, O_RDONLY, 0);
9072 #endif
9074 if (fd == -1) {
9075 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
9076 fname, strerror(errno) ));
9077 goto out;
9080 /* Now fstat to be *SURE* it's a regular file. */
9081 if (sys_fstat(fd, &sbuf, false) != 0) {
9082 close(fd);
9083 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
9084 fname, strerror(errno) ));
9085 goto out;
9088 /* Is it the same dev/inode as was lstated ? */
9089 if (lsbuf.st_ex_dev != sbuf.st_ex_dev || lsbuf.st_ex_ino != sbuf.st_ex_ino) {
9090 close(fd);
9091 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
9092 "Symlink spoofing going on ?\n", fname ));
9093 goto out;
9096 /* This must be a regular file, not a symlink, directory or
9097 other strange filetype. */
9098 if (!check_usershare_stat(fname, &sbuf)) {
9099 goto out;
9102 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
9104 close(fd);
9105 if (lines == NULL) {
9106 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
9107 fname, (unsigned int)sbuf.st_ex_uid ));
9108 goto out;
9111 if (parse_usershare_file(ctx, &sbuf, file_name,
9112 iService, lines, numlines, &sharepath,
9113 &comment, &cp_service_name,
9114 &psd, &guest_ok) != USERSHARE_OK) {
9115 goto out;
9118 /* Everything ok - add the service possibly using a template. */
9119 if (iService < 0) {
9120 const struct service *sp = &sDefault;
9121 if (snum_template != -1) {
9122 sp = ServicePtrs[snum_template];
9125 if ((iService = add_a_service(sp, cp_service_name)) < 0) {
9126 DEBUG(0, ("process_usershare_file: Failed to add "
9127 "new service %s\n", cp_service_name));
9128 goto out;
9131 added_service = true;
9133 /* Read only is controlled by usershare ACL below. */
9134 ServicePtrs[iService]->bRead_only = False;
9137 /* Write the ACL of the new/modified share. */
9138 if (!set_share_security(canon_name, psd)) {
9139 DEBUG(0, ("process_usershare_file: Failed to set share "
9140 "security for user share %s\n",
9141 canon_name ));
9142 goto out;
9145 /* If from a template it may be marked invalid. */
9146 ServicePtrs[iService]->valid = True;
9148 /* Set the service as a valid usershare. */
9149 ServicePtrs[iService]->usershare = USERSHARE_VALID;
9151 /* Set guest access. */
9152 if (lp_usershare_allow_guests()) {
9153 ServicePtrs[iService]->bGuest_ok = guest_ok;
9156 /* And note when it was loaded. */
9157 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
9158 string_set(&ServicePtrs[iService]->szPath, sharepath);
9159 string_set(&ServicePtrs[iService]->comment, comment);
9161 ret = iService;
9163 out:
9165 if (ret == -1 && iService != -1 && added_service) {
9166 lp_remove_service(iService);
9169 TALLOC_FREE(lines);
9170 TALLOC_FREE(ctx);
9171 return ret;
9174 /***************************************************************************
9175 Checks if a usershare entry has been modified since last load.
9176 ***************************************************************************/
9178 static bool usershare_exists(int iService, struct timespec *last_mod)
9180 SMB_STRUCT_STAT lsbuf;
9181 const char *usersharepath = Globals.szUsersharePath;
9182 char *fname;
9184 if (asprintf(&fname, "%s/%s",
9185 usersharepath,
9186 ServicePtrs[iService]->szService) < 0) {
9187 return false;
9190 if (sys_lstat(fname, &lsbuf, false) != 0) {
9191 SAFE_FREE(fname);
9192 return false;
9195 if (!S_ISREG(lsbuf.st_ex_mode)) {
9196 SAFE_FREE(fname);
9197 return false;
9200 SAFE_FREE(fname);
9201 *last_mod = lsbuf.st_ex_mtime;
9202 return true;
9205 /***************************************************************************
9206 Load a usershare service by name. Returns a valid servicenumber or -1.
9207 ***************************************************************************/
9209 int load_usershare_service(const char *servicename)
9211 SMB_STRUCT_STAT sbuf;
9212 const char *usersharepath = Globals.szUsersharePath;
9213 int max_user_shares = Globals.iUsershareMaxShares;
9214 int snum_template = -1;
9216 if (*usersharepath == 0 || max_user_shares == 0) {
9217 return -1;
9220 if (sys_stat(usersharepath, &sbuf, false) != 0) {
9221 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
9222 usersharepath, strerror(errno) ));
9223 return -1;
9226 if (!S_ISDIR(sbuf.st_ex_mode)) {
9227 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
9228 usersharepath ));
9229 return -1;
9233 * This directory must be owned by root, and have the 't' bit set.
9234 * It also must not be writable by "other".
9237 #ifdef S_ISVTX
9238 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
9239 #else
9240 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
9241 #endif
9242 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
9243 "or does not have the sticky bit 't' set or is writable by anyone.\n",
9244 usersharepath ));
9245 return -1;
9248 /* Ensure the template share exists if it's set. */
9249 if (Globals.szUsershareTemplateShare[0]) {
9250 /* We can't use lp_servicenumber here as we are recommending that
9251 template shares have -valid=False set. */
9252 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
9253 if (ServicePtrs[snum_template]->szService &&
9254 strequal(ServicePtrs[snum_template]->szService,
9255 Globals.szUsershareTemplateShare)) {
9256 break;
9260 if (snum_template == -1) {
9261 DEBUG(0,("load_usershare_service: usershare template share %s "
9262 "does not exist.\n",
9263 Globals.szUsershareTemplateShare ));
9264 return -1;
9268 return process_usershare_file(usersharepath, servicename, snum_template);
9271 /***************************************************************************
9272 Load all user defined shares from the user share directory.
9273 We only do this if we're enumerating the share list.
9274 This is the function that can delete usershares that have
9275 been removed.
9276 ***************************************************************************/
9278 int load_usershare_shares(void)
9280 SMB_STRUCT_DIR *dp;
9281 SMB_STRUCT_STAT sbuf;
9282 SMB_STRUCT_DIRENT *de;
9283 int num_usershares = 0;
9284 int max_user_shares = Globals.iUsershareMaxShares;
9285 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
9286 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
9287 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
9288 int iService;
9289 int snum_template = -1;
9290 const char *usersharepath = Globals.szUsersharePath;
9291 int ret = lp_numservices();
9293 if (max_user_shares == 0 || *usersharepath == '\0') {
9294 return lp_numservices();
9297 if (sys_stat(usersharepath, &sbuf, false) != 0) {
9298 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
9299 usersharepath, strerror(errno) ));
9300 return ret;
9304 * This directory must be owned by root, and have the 't' bit set.
9305 * It also must not be writable by "other".
9308 #ifdef S_ISVTX
9309 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
9310 #else
9311 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
9312 #endif
9313 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
9314 "or does not have the sticky bit 't' set or is writable by anyone.\n",
9315 usersharepath ));
9316 return ret;
9319 /* Ensure the template share exists if it's set. */
9320 if (Globals.szUsershareTemplateShare[0]) {
9321 /* We can't use lp_servicenumber here as we are recommending that
9322 template shares have -valid=False set. */
9323 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
9324 if (ServicePtrs[snum_template]->szService &&
9325 strequal(ServicePtrs[snum_template]->szService,
9326 Globals.szUsershareTemplateShare)) {
9327 break;
9331 if (snum_template == -1) {
9332 DEBUG(0,("load_usershare_shares: usershare template share %s "
9333 "does not exist.\n",
9334 Globals.szUsershareTemplateShare ));
9335 return ret;
9339 /* Mark all existing usershares as pending delete. */
9340 for (iService = iNumServices - 1; iService >= 0; iService--) {
9341 if (VALID(iService) && ServicePtrs[iService]->usershare) {
9342 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
9346 dp = sys_opendir(usersharepath);
9347 if (!dp) {
9348 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
9349 usersharepath, strerror(errno) ));
9350 return ret;
9353 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
9354 (de = sys_readdir(dp));
9355 num_dir_entries++ ) {
9356 int r;
9357 const char *n = de->d_name;
9359 /* Ignore . and .. */
9360 if (*n == '.') {
9361 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
9362 continue;
9366 if (n[0] == ':') {
9367 /* Temporary file used when creating a share. */
9368 num_tmp_dir_entries++;
9371 /* Allow 20% tmp entries. */
9372 if (num_tmp_dir_entries > allowed_tmp_entries) {
9373 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
9374 "in directory %s\n",
9375 num_tmp_dir_entries, usersharepath));
9376 break;
9379 r = process_usershare_file(usersharepath, n, snum_template);
9380 if (r == 0) {
9381 /* Update the services count. */
9382 num_usershares++;
9383 if (num_usershares >= max_user_shares) {
9384 DEBUG(0,("load_usershare_shares: max user shares reached "
9385 "on file %s in directory %s\n",
9386 n, usersharepath ));
9387 break;
9389 } else if (r == -1) {
9390 num_bad_dir_entries++;
9393 /* Allow 20% bad entries. */
9394 if (num_bad_dir_entries > allowed_bad_entries) {
9395 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
9396 "in directory %s\n",
9397 num_bad_dir_entries, usersharepath));
9398 break;
9401 /* Allow 20% bad entries. */
9402 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
9403 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
9404 "in directory %s\n",
9405 num_dir_entries, usersharepath));
9406 break;
9410 sys_closedir(dp);
9412 /* Sweep through and delete any non-refreshed usershares that are
9413 not currently in use. */
9414 for (iService = iNumServices - 1; iService >= 0; iService--) {
9415 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
9416 if (conn_snum_used(iService)) {
9417 continue;
9419 /* Remove from the share ACL db. */
9420 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
9421 lp_servicename(iService) ));
9422 delete_share_security(lp_servicename(iService));
9423 free_service_byindex(iService);
9427 return lp_numservices();
9430 /********************************************************
9431 Destroy global resources allocated in this file
9432 ********************************************************/
9434 void gfree_loadparm(void)
9436 int i;
9438 free_file_list();
9440 /* Free resources allocated to services */
9442 for ( i = 0; i < iNumServices; i++ ) {
9443 if ( VALID(i) ) {
9444 free_service_byindex(i);
9448 SAFE_FREE( ServicePtrs );
9449 iNumServices = 0;
9451 /* Now release all resources allocated to global
9452 parameters and the default service */
9454 free_global_parameters();
9458 /***************************************************************************
9459 Allow client apps to specify that they are a client
9460 ***************************************************************************/
9461 void lp_set_in_client(bool b)
9463 in_client = b;
9467 /***************************************************************************
9468 Determine if we're running in a client app
9469 ***************************************************************************/
9470 bool lp_is_in_client(void)
9472 return in_client;
9475 /***************************************************************************
9476 Load the services array from the services file. Return True on success,
9477 False on failure.
9478 ***************************************************************************/
9480 static bool lp_load_ex(const char *pszFname,
9481 bool global_only,
9482 bool save_defaults,
9483 bool add_ipc,
9484 bool initialize_globals,
9485 bool allow_include_registry,
9486 bool allow_registry_shares)
9488 char *n2 = NULL;
9489 bool bRetval;
9491 bRetval = False;
9493 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
9495 bInGlobalSection = True;
9496 bGlobalOnly = global_only;
9497 bAllowIncludeRegistry = allow_include_registry;
9499 init_globals(initialize_globals);
9501 free_file_list();
9503 if (save_defaults) {
9504 init_locals();
9505 lp_save_defaults();
9508 free_param_opts(&Globals.param_opt);
9510 lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
9512 /* We get sections first, so have to start 'behind' to make up */
9513 iServiceIndex = -1;
9515 if (lp_config_backend_is_file()) {
9516 n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
9517 current_user_info.domain,
9518 pszFname);
9519 if (!n2) {
9520 smb_panic("lp_load_ex: out of memory");
9523 add_to_file_list(pszFname, n2);
9525 bRetval = pm_process(n2, do_section, do_parameter, NULL);
9526 TALLOC_FREE(n2);
9528 /* finish up the last section */
9529 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
9530 if (bRetval) {
9531 if (iServiceIndex >= 0) {
9532 bRetval = service_ok(iServiceIndex);
9536 if (lp_config_backend_is_registry()) {
9537 /* config backend changed to registry in config file */
9539 * We need to use this extra global variable here to
9540 * survive restart: init_globals uses this as a default
9541 * for ConfigBackend. Otherwise, init_globals would
9542 * send us into an endless loop here.
9544 config_backend = CONFIG_BACKEND_REGISTRY;
9545 /* start over */
9546 DEBUG(1, ("lp_load_ex: changing to config backend "
9547 "registry\n"));
9548 init_globals(true);
9549 lp_kill_all_services();
9550 return lp_load_ex(pszFname, global_only, save_defaults,
9551 add_ipc, initialize_globals,
9552 allow_include_registry,
9553 allow_registry_shares);
9555 } else if (lp_config_backend_is_registry()) {
9556 bRetval = process_registry_globals();
9557 } else {
9558 DEBUG(0, ("Illegal config backend given: %d\n",
9559 lp_config_backend()));
9560 bRetval = false;
9563 if (bRetval && lp_registry_shares() && allow_registry_shares) {
9564 bRetval = process_registry_shares();
9567 lp_add_auto_services(lp_auto_services());
9569 if (add_ipc) {
9570 /* When 'restrict anonymous = 2' guest connections to ipc$
9571 are denied */
9572 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9573 if ( lp_enable_asu_support() ) {
9574 lp_add_ipc("ADMIN$", false);
9578 set_server_role();
9579 set_default_server_announce_type();
9580 set_allowed_client_auth();
9582 bLoaded = True;
9584 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9585 /* if bWINSsupport is true and we are in the client */
9586 if (lp_is_in_client() && Globals.bWINSsupport) {
9587 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9590 init_iconv();
9592 bAllowIncludeRegistry = true;
9594 return (bRetval);
9597 bool lp_load(const char *pszFname,
9598 bool global_only,
9599 bool save_defaults,
9600 bool add_ipc,
9601 bool initialize_globals)
9603 return lp_load_ex(pszFname,
9604 global_only,
9605 save_defaults,
9606 add_ipc,
9607 initialize_globals,
9608 true, /* allow_include_registry */
9609 false); /* allow_registry_shares*/
9612 bool lp_load_initial_only(const char *pszFname)
9614 return lp_load_ex(pszFname,
9615 true, /* global only */
9616 false, /* save_defaults */
9617 false, /* add_ipc */
9618 true, /* initialize_globals */
9619 false, /* allow_include_registry */
9620 false); /* allow_registry_shares*/
9623 bool lp_load_with_registry_shares(const char *pszFname,
9624 bool global_only,
9625 bool save_defaults,
9626 bool add_ipc,
9627 bool initialize_globals)
9629 return lp_load_ex(pszFname,
9630 global_only,
9631 save_defaults,
9632 add_ipc,
9633 initialize_globals,
9634 true, /* allow_include_registry */
9635 true); /* allow_registry_shares*/
9638 /***************************************************************************
9639 Return the max number of services.
9640 ***************************************************************************/
9642 int lp_numservices(void)
9644 return (iNumServices);
9647 /***************************************************************************
9648 Display the contents of the services array in human-readable form.
9649 ***************************************************************************/
9651 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9653 int iService;
9655 if (show_defaults)
9656 defaults_saved = False;
9658 dump_globals(f);
9660 dump_a_service(&sDefault, f);
9662 for (iService = 0; iService < maxtoprint; iService++) {
9663 fprintf(f,"\n");
9664 lp_dump_one(f, show_defaults, iService);
9668 /***************************************************************************
9669 Display the contents of one service in human-readable form.
9670 ***************************************************************************/
9672 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9674 if (VALID(snum)) {
9675 if (ServicePtrs[snum]->szService[0] == '\0')
9676 return;
9677 dump_a_service(ServicePtrs[snum], f);
9681 /***************************************************************************
9682 Return the number of the service with the given name, or -1 if it doesn't
9683 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9684 getservicebyname()! This works ONLY if all services have been loaded, and
9685 does not copy the found service.
9686 ***************************************************************************/
9688 int lp_servicenumber(const char *pszServiceName)
9690 int iService;
9691 fstring serviceName;
9693 if (!pszServiceName) {
9694 return GLOBAL_SECTION_SNUM;
9697 for (iService = iNumServices - 1; iService >= 0; iService--) {
9698 if (VALID(iService) && ServicePtrs[iService]->szService) {
9700 * The substitution here is used to support %U is
9701 * service names
9703 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9704 standard_sub_basic(get_current_username(),
9705 current_user_info.domain,
9706 serviceName,sizeof(serviceName));
9707 if (strequal(serviceName, pszServiceName)) {
9708 break;
9713 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9714 struct timespec last_mod;
9716 if (!usershare_exists(iService, &last_mod)) {
9717 /* Remove the share security tdb entry for it. */
9718 delete_share_security(lp_servicename(iService));
9719 /* Remove it from the array. */
9720 free_service_byindex(iService);
9721 /* Doesn't exist anymore. */
9722 return GLOBAL_SECTION_SNUM;
9725 /* Has it been modified ? If so delete and reload. */
9726 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9727 &last_mod) < 0) {
9728 /* Remove it from the array. */
9729 free_service_byindex(iService);
9730 /* and now reload it. */
9731 iService = load_usershare_service(pszServiceName);
9735 if (iService < 0) {
9736 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9737 return GLOBAL_SECTION_SNUM;
9740 return (iService);
9743 bool share_defined(const char *service_name)
9745 return (lp_servicenumber(service_name) != -1);
9748 struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
9749 const char *sharename)
9751 struct share_params *result;
9752 char *sname = NULL;
9753 int snum;
9755 snum = find_service(mem_ctx, sharename, &sname);
9756 if (snum < 0 || sname == NULL) {
9757 return NULL;
9760 if (!(result = TALLOC_P(mem_ctx, struct share_params))) {
9761 DEBUG(0, ("talloc failed\n"));
9762 return NULL;
9765 result->service = snum;
9766 return result;
9769 struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx)
9771 struct share_iterator *result;
9773 if (!(result = TALLOC_P(mem_ctx, struct share_iterator))) {
9774 DEBUG(0, ("talloc failed\n"));
9775 return NULL;
9778 result->next_id = 0;
9779 return result;
9782 struct share_params *next_share(struct share_iterator *list)
9784 struct share_params *result;
9786 while (!lp_snum_ok(list->next_id) &&
9787 (list->next_id < lp_numservices())) {
9788 list->next_id += 1;
9791 if (list->next_id >= lp_numservices()) {
9792 return NULL;
9795 if (!(result = TALLOC_P(list, struct share_params))) {
9796 DEBUG(0, ("talloc failed\n"));
9797 return NULL;
9800 result->service = list->next_id;
9801 list->next_id += 1;
9802 return result;
9805 struct share_params *next_printer(struct share_iterator *list)
9807 struct share_params *result;
9809 while ((result = next_share(list)) != NULL) {
9810 if (lp_print_ok(result->service)) {
9811 break;
9814 return result;
9818 * This is a hack for a transition period until we transformed all code from
9819 * service numbers to struct share_params.
9822 struct share_params *snum2params_static(int snum)
9824 static struct share_params result;
9825 result.service = snum;
9826 return &result;
9829 /*******************************************************************
9830 A useful volume label function.
9831 ********************************************************************/
9833 const char *volume_label(int snum)
9835 char *ret;
9836 const char *label = lp_volume(snum);
9837 if (!*label) {
9838 label = lp_servicename(snum);
9841 /* This returns a 33 byte guarenteed null terminated string. */
9842 ret = talloc_strndup(talloc_tos(), label, 32);
9843 if (!ret) {
9844 return "";
9846 return ret;
9849 /*******************************************************************
9850 Set the server type we will announce as via nmbd.
9851 ********************************************************************/
9853 static void set_default_server_announce_type(void)
9855 default_server_announce = 0;
9856 default_server_announce |= SV_TYPE_WORKSTATION;
9857 default_server_announce |= SV_TYPE_SERVER;
9858 default_server_announce |= SV_TYPE_SERVER_UNIX;
9860 /* note that the flag should be set only if we have a
9861 printer service but nmbd doesn't actually load the
9862 services so we can't tell --jerry */
9864 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9866 switch (lp_announce_as()) {
9867 case ANNOUNCE_AS_NT_SERVER:
9868 default_server_announce |= SV_TYPE_SERVER_NT;
9869 /* fall through... */
9870 case ANNOUNCE_AS_NT_WORKSTATION:
9871 default_server_announce |= SV_TYPE_NT;
9872 break;
9873 case ANNOUNCE_AS_WIN95:
9874 default_server_announce |= SV_TYPE_WIN95_PLUS;
9875 break;
9876 case ANNOUNCE_AS_WFW:
9877 default_server_announce |= SV_TYPE_WFW;
9878 break;
9879 default:
9880 break;
9883 switch (lp_server_role()) {
9884 case ROLE_DOMAIN_MEMBER:
9885 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9886 break;
9887 case ROLE_DOMAIN_PDC:
9888 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9889 break;
9890 case ROLE_DOMAIN_BDC:
9891 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9892 break;
9893 case ROLE_STANDALONE:
9894 default:
9895 break;
9897 if (lp_time_server())
9898 default_server_announce |= SV_TYPE_TIME_SOURCE;
9900 if (lp_host_msdfs())
9901 default_server_announce |= SV_TYPE_DFS_SERVER;
9904 /***********************************************************
9905 If we are PDC then prefer us as DMB
9906 ************************************************************/
9908 bool lp_domain_master(void)
9910 if (Globals.iDomainMaster == Auto)
9911 return (lp_server_role() == ROLE_DOMAIN_PDC);
9913 return (bool)Globals.iDomainMaster;
9916 /***********************************************************
9917 If we are PDC then prefer us as DMB
9918 ************************************************************/
9920 bool lp_domain_master_true_or_auto(void)
9922 if (Globals.iDomainMaster) /* auto or yes */
9923 return true;
9925 return false;
9928 /***********************************************************
9929 If we are DMB then prefer us as LMB
9930 ************************************************************/
9932 bool lp_preferred_master(void)
9934 if (Globals.iPreferredMaster == Auto)
9935 return (lp_local_master() && lp_domain_master());
9937 return (bool)Globals.iPreferredMaster;
9940 /*******************************************************************
9941 Remove a service.
9942 ********************************************************************/
9944 void lp_remove_service(int snum)
9946 ServicePtrs[snum]->valid = False;
9947 invalid_services[num_invalid_services++] = snum;
9950 /*******************************************************************
9951 Copy a service.
9952 ********************************************************************/
9954 void lp_copy_service(int snum, const char *new_name)
9956 do_section(new_name, NULL);
9957 if (snum >= 0) {
9958 snum = lp_servicenumber(new_name);
9959 if (snum >= 0)
9960 lp_do_parameter(snum, "copy", lp_servicename(snum));
9965 /*******************************************************************
9966 Get the default server type we will announce as via nmbd.
9967 ********************************************************************/
9969 int lp_default_server_announce(void)
9971 return default_server_announce;
9974 /*******************************************************************
9975 Split the announce version into major and minor numbers.
9976 ********************************************************************/
9978 int lp_major_announce_version(void)
9980 static bool got_major = False;
9981 static int major_version = DEFAULT_MAJOR_VERSION;
9982 char *vers;
9983 char *p;
9985 if (got_major)
9986 return major_version;
9988 got_major = True;
9989 if ((vers = lp_announce_version()) == NULL)
9990 return major_version;
9992 if ((p = strchr_m(vers, '.')) == 0)
9993 return major_version;
9995 *p = '\0';
9996 major_version = atoi(vers);
9997 return major_version;
10000 int lp_minor_announce_version(void)
10002 static bool got_minor = False;
10003 static int minor_version = DEFAULT_MINOR_VERSION;
10004 char *vers;
10005 char *p;
10007 if (got_minor)
10008 return minor_version;
10010 got_minor = True;
10011 if ((vers = lp_announce_version()) == NULL)
10012 return minor_version;
10014 if ((p = strchr_m(vers, '.')) == 0)
10015 return minor_version;
10017 p++;
10018 minor_version = atoi(p);
10019 return minor_version;
10022 /***********************************************************
10023 Set the global name resolution order (used in smbclient).
10024 ************************************************************/
10026 void lp_set_name_resolve_order(const char *new_order)
10028 string_set(&Globals.szNameResolveOrder, new_order);
10031 const char *lp_printername(int snum)
10033 const char *ret = _lp_printername(snum);
10034 if (ret == NULL || (ret != NULL && *ret == '\0'))
10035 ret = lp_const_servicename(snum);
10037 return ret;
10041 /***********************************************************
10042 Allow daemons such as winbindd to fix their logfile name.
10043 ************************************************************/
10045 void lp_set_logfile(const char *name)
10047 string_set(&Globals.szLogFile, name);
10048 debug_set_logfile(name);
10051 /*******************************************************************
10052 Return the max print jobs per queue.
10053 ********************************************************************/
10055 int lp_maxprintjobs(int snum)
10057 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
10058 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
10059 maxjobs = PRINT_MAX_JOBID - 1;
10061 return maxjobs;
10064 const char *lp_printcapname(void)
10066 if ((Globals.szPrintcapname != NULL) &&
10067 (Globals.szPrintcapname[0] != '\0'))
10068 return Globals.szPrintcapname;
10070 if (sDefault.iPrinting == PRINT_CUPS) {
10071 #ifdef HAVE_CUPS
10072 return "cups";
10073 #else
10074 return "lpstat";
10075 #endif
10078 if (sDefault.iPrinting == PRINT_BSD)
10079 return "/etc/printcap";
10081 return PRINTCAP_NAME;
10084 static uint32 spoolss_state;
10086 bool lp_disable_spoolss( void )
10088 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
10089 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
10091 return spoolss_state == SVCCTL_STOPPED ? True : False;
10094 void lp_set_spoolss_state( uint32 state )
10096 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
10098 spoolss_state = state;
10101 uint32 lp_get_spoolss_state( void )
10103 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
10106 /*******************************************************************
10107 Ensure we don't use sendfile if server smb signing is active.
10108 ********************************************************************/
10110 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
10112 bool sign_active = false;
10114 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
10115 if (get_Protocol() < PROTOCOL_NT1) {
10116 return false;
10118 if (signing_state) {
10119 sign_active = smb_signing_is_active(signing_state);
10121 return (_lp_use_sendfile(snum) &&
10122 (get_remote_arch() != RA_WIN95) &&
10123 !sign_active);
10126 /*******************************************************************
10127 Turn off sendfile if we find the underlying OS doesn't support it.
10128 ********************************************************************/
10130 void set_use_sendfile(int snum, bool val)
10132 if (LP_SNUM_OK(snum))
10133 ServicePtrs[snum]->bUseSendfile = val;
10134 else
10135 sDefault.bUseSendfile = val;
10138 /*******************************************************************
10139 Turn off storing DOS attributes if this share doesn't support it.
10140 ********************************************************************/
10142 void set_store_dos_attributes(int snum, bool val)
10144 if (!LP_SNUM_OK(snum))
10145 return;
10146 ServicePtrs[(snum)]->bStoreDosAttributes = val;
10149 void lp_set_mangling_method(const char *new_method)
10151 string_set(&Globals.szManglingMethod, new_method);
10154 /*******************************************************************
10155 Global state for POSIX pathname processing.
10156 ********************************************************************/
10158 static bool posix_pathnames;
10160 bool lp_posix_pathnames(void)
10162 return posix_pathnames;
10165 /*******************************************************************
10166 Change everything needed to ensure POSIX pathname processing (currently
10167 not much).
10168 ********************************************************************/
10170 void lp_set_posix_pathnames(void)
10172 posix_pathnames = True;
10175 /*******************************************************************
10176 Global state for POSIX lock processing - CIFS unix extensions.
10177 ********************************************************************/
10179 bool posix_default_lock_was_set;
10180 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
10182 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
10184 if (posix_default_lock_was_set) {
10185 return posix_cifsx_locktype;
10186 } else {
10187 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
10191 /*******************************************************************
10192 ********************************************************************/
10194 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
10196 posix_default_lock_was_set = True;
10197 posix_cifsx_locktype = val;
10200 int lp_min_receive_file_size(void)
10202 if (Globals.iminreceivefile < 0) {
10203 return 0;
10205 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
10208 /*******************************************************************
10209 If socket address is an empty character string, it is necessary to
10210 define it as "0.0.0.0".
10211 ********************************************************************/
10213 const char *lp_socket_address(void)
10215 char *sock_addr = Globals.szSocketAddress;
10217 if (sock_addr[0] == '\0'){
10218 string_set(&Globals.szSocketAddress, "0.0.0.0");
10220 return Globals.szSocketAddress;
10223 void lp_set_passdb_backend(const char *backend)
10225 string_set(&Globals.szPassdbBackend, backend);
10228 /*******************************************************************
10229 Safe wide links checks.
10230 This helper function always verify the validity of wide links,
10231 even after a configuration file reload.
10232 ********************************************************************/
10234 static bool lp_widelinks_internal(int snum)
10236 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
10237 sDefault.bWidelinks);
10240 void widelinks_warning(int snum)
10242 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
10243 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
10244 "These parameters are incompatible. "
10245 "Wide links will be disabled for this share.\n",
10246 lp_servicename(snum) ));
10250 bool lp_widelinks(int snum)
10252 /* wide links is always incompatible with unix extensions */
10253 if (lp_unix_extensions()) {
10254 return false;
10257 return lp_widelinks_internal(snum);
10260 bool lp_writeraw(void)
10262 if (lp_async_smb_echo_handler()) {
10263 return false;
10265 return _lp_writeraw();
10268 bool lp_readraw(void)
10270 if (lp_async_smb_echo_handler()) {
10271 return false;
10273 return _lp_readraw();