s3:s3compat Allow replacement of lp_idmap_backend() and lp_idmap_alloc_backend
[abartlet/samba.git/.git] / source3 / param / loadparm.c
1 /* 
2    Unix SMB/CIFS implementation.
3    Parameter loading functions
4    Copyright (C) Karl Auer 1993-1998
5
6    Largely re-written by Andrew Tridgell, September 1994
7
8    Copyright (C) Simo Sorce 2001
9    Copyright (C) Alexander Bokovoy 2002
10    Copyright (C) Stefan (metze) Metzmacher 2002
11    Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
12    Copyright (C) Michael Adam 2008
13
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.
18
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.
23
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/>.
26 */
27
28 /*
29  *  Load parameters.
30  *
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.
34  *
35  * To add a parameter:
36  *
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
42  *  
43  *
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!
51  *
52  */
53
54 #include "includes.h"
55 #include "printing.h"
56 #include "lib/smbconf/smbconf.h"
57 #include "lib/smbconf/smbconf_init.h"
58 #include "lib/smbconf/smbconf_reg.h"
59
60 #ifdef HAVE_SYS_SYSCTL_H
61 #include <sys/sysctl.h>
62 #endif
63
64 #ifdef HAVE_HTTPCONNECTENCRYPT
65 #include <cups/http.h>
66 #endif
67
68 bool bLoaded = False;
69
70 extern userdom_struct current_user_info;
71
72 #ifndef GLOBAL_NAME
73 #define GLOBAL_NAME "global"
74 #endif
75
76 #ifndef PRINTERS_NAME
77 #define PRINTERS_NAME "printers"
78 #endif
79
80 #ifndef HOMES_NAME
81 #define HOMES_NAME "homes"
82 #endif
83
84 /* the special value for the include parameter
85  * to be interpreted not as a file name but to
86  * trigger loading of the global smb.conf options
87  * from registry. */
88 #ifndef INCLUDE_REGISTRY_NAME
89 #define INCLUDE_REGISTRY_NAME "registry"
90 #endif
91
92 static bool in_client = False;          /* Not in the client by default */
93 static struct smbconf_csn conf_last_csn;
94
95 #define CONFIG_BACKEND_FILE 0
96 #define CONFIG_BACKEND_REGISTRY 1
97
98 static int config_backend = CONFIG_BACKEND_FILE;
99
100 /* some helpful bits */
101 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
102 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
103
104 #define USERSHARE_VALID 1
105 #define USERSHARE_PENDING_DELETE 2
106
107 static bool defaults_saved = False;
108
109 struct param_opt_struct {
110         struct param_opt_struct *prev, *next;
111         char *key;
112         char *value;
113         char **list;
114 };
115
116 /*
117  * This structure describes global (ie., server-wide) parameters.
118  */
119 struct global {
120         int ConfigBackend;
121         char *smb_ports;
122         char *dos_charset;
123         char *unix_charset;
124         char *display_charset;
125         char *szPrintcapname;
126         char *szAddPortCommand;
127         char *szEnumPortsCommand;
128         char *szAddPrinterCommand;
129         char *szDeletePrinterCommand;
130         char *szOs2DriverMap;
131         char *szLockDir;
132         char *szStateDir;
133         char *szCacheDir;
134         char *szPidDir;
135         char *szRootdir;
136         char *szDefaultService;
137         char *szGetQuota;
138         char *szSetQuota;
139         char *szMsgCommand;
140         char *szServerString;
141         char *szAutoServices;
142         char *szPasswdProgram;
143         char *szPasswdChat;
144         char *szLogFile;
145         char *szConfigFile;
146         char *szSMBPasswdFile;
147         char *szPrivateDir;
148         char *szPassdbBackend;
149         char **szPreloadModules;
150         char *szPasswordServer;
151         char *szSocketOptions;
152         char *szRealm;
153         char *szAfsUsernameMap;
154         int iAfsTokenLifetime;
155         char *szLogNtTokenCommand;
156         char *szUsernameMap;
157         char *szLogonScript;
158         char *szLogonPath;
159         char *szLogonDrive;
160         char *szLogonHome;
161         char **szWINSservers;
162         char **szInterfaces;
163         char *szRemoteAnnounce;
164         char *szRemoteBrowseSync;
165         char *szSocketAddress;
166         bool bNmbdBindExplicitBroadcast;
167         char *szNISHomeMapName;
168         char *szAnnounceVersion;        /* This is initialised in init_globals */
169         char *szWorkgroup;
170         char *szNetbiosName;
171         char **szNetbiosAliases;
172         char *szNetbiosScope;
173         char *szNameResolveOrder;
174         char *szPanicAction;
175         char *szAddUserScript;
176         char *szRenameUserScript;
177         char *szDelUserScript;
178         char *szAddGroupScript;
179         char *szDelGroupScript;
180         char *szAddUserToGroupScript;
181         char *szDelUserFromGroupScript;
182         char *szSetPrimaryGroupScript;
183         char *szAddMachineScript;
184         char *szShutdownScript;
185         char *szAbortShutdownScript;
186         char *szUsernameMapScript;
187         int iUsernameMapCacheTime;
188         char *szCheckPasswordScript;
189         char *szWINSHook;
190         char *szUtmpDir;
191         char *szWtmpDir;
192         bool bUtmp;
193         char *szIdmapUID;
194         char *szIdmapGID;
195         bool bPassdbExpandExplicit;
196         int AlgorithmicRidBase;
197         char *szTemplateHomedir;
198         char *szTemplateShell;
199         char *szWinbindSeparator;
200         bool bWinbindEnumUsers;
201         bool bWinbindEnumGroups;
202         bool bWinbindUseDefaultDomain;
203         bool bWinbindTrustedDomainsOnly;
204         bool bWinbindNestedGroups;
205         int  winbind_expand_groups;
206         bool bWinbindRefreshTickets;
207         bool bWinbindOfflineLogon;
208         bool bWinbindNormalizeNames;
209         bool bWinbindRpcOnly;
210         bool bCreateKrb5Conf;
211         char *szIdmapBackend;
212         char *szIdmapAllocBackend;
213         char *szAddShareCommand;
214         char *szChangeShareCommand;
215         char *szDeleteShareCommand;
216         char **szEventLogs;
217         char *szGuestaccount;
218         char *szManglingMethod;
219         char **szServicesList;
220         char *szUsersharePath;
221         char *szUsershareTemplateShare;
222         char **szUsersharePrefixAllowList;
223         char **szUsersharePrefixDenyList;
224         int mangle_prefix;
225         int max_log_size;
226         char *szLogLevel;
227         int max_xmit;
228         int max_mux;
229         int max_open_files;
230         int open_files_db_hash_size;
231         int pwordlevel;
232         int unamelevel;
233         int deadtime;
234         bool getwd_cache;
235         int maxprotocol;
236         int minprotocol;
237         int security;
238         char **AuthMethods;
239         bool paranoid_server_security;
240         int maxdisksize;
241         int lpqcachetime;
242         int iMaxSmbdProcesses;
243         bool bDisableSpoolss;
244         int syslog;
245         int os_level;
246         bool enhanced_browsing;
247         int max_ttl;
248         int max_wins_ttl;
249         int min_wins_ttl;
250         int lm_announce;
251         int lm_interval;
252         int announce_as;        /* This is initialised in init_globals */
253         int machine_password_timeout;
254         int map_to_guest;
255         int oplock_break_wait_time;
256         int winbind_cache_time;
257         int winbind_reconnect_delay;
258         int winbind_max_idle_children;
259         char **szWinbindNssInfo;
260         int iLockSpinTime;
261         char *szLdapMachineSuffix;
262         char *szLdapUserSuffix;
263         char *szLdapIdmapSuffix;
264         char *szLdapGroupSuffix;
265         int ldap_ssl;
266         bool ldap_ssl_ads;
267         int ldap_deref;
268         int ldap_follow_referral;
269         char *szLdapSuffix;
270         char *szLdapAdminDn;
271         int ldap_debug_level;
272         int ldap_debug_threshold;
273         int iAclCompat;
274         char *szCupsServer;
275         int CupsEncrypt;
276         char *szIPrintServer;
277         char *ctdbdSocket;
278         char **szClusterAddresses;
279         bool clustering;
280         int ctdb_timeout;
281         int ctdb_locktime_warn_threshold;
282         int ldap_passwd_sync;
283         int ldap_replication_sleep;
284         int ldap_timeout; /* This is initialised in init_globals */
285         int ldap_connection_timeout;
286         int ldap_page_size;
287         bool ldap_delete_dn;
288         bool bMsAddPrinterWizard;
289         bool bDNSproxy;
290         bool bWINSsupport;
291         bool bWINSproxy;
292         bool bLocalMaster;
293         int  iPreferredMaster;
294         int iDomainMaster;
295         bool bDomainLogons;
296         char **szInitLogonDelayedHosts;
297         int InitLogonDelay;
298         bool bEncryptPasswords;
299         bool bUpdateEncrypt;
300         int  clientSchannel;
301         int  serverSchannel;
302         bool bNullPasswords;
303         bool bObeyPamRestrictions;
304         bool bLoadPrinters;
305         int PrintcapCacheTime;
306         bool bLargeReadwrite;
307         bool bReadRaw;
308         bool bWriteRaw;
309         bool bSyslogOnly;
310         bool bBrowseList;
311         bool bNISHomeMap;
312         bool bTimeServer;
313         bool bBindInterfacesOnly;
314         bool bPamPasswordChange;
315         bool bUnixPasswdSync;
316         bool bPasswdChatDebug;
317         int iPasswdChatTimeout;
318         bool bTimestampLogs;
319         bool bNTSmbSupport;
320         bool bNTPipeSupport;
321         bool bNTStatusSupport;
322         bool bStatCache;
323         int iMaxStatCacheSize;
324         bool bKernelOplocks;
325         bool bAllowTrustedDomains;
326         bool bLanmanAuth;
327         bool bNTLMAuth;
328         bool bUseSpnego;
329         bool bClientLanManAuth;
330         bool bClientNTLMv2Auth;
331         bool bClientPlaintextAuth;
332         bool bClientUseSpnego;
333         bool bDebugPrefixTimestamp;
334         bool bDebugHiresTimestamp;
335         bool bDebugPid;
336         bool bDebugUid;
337         bool bDebugClass;
338         bool bEnableCoreFiles;
339         bool bHostMSDfs;
340         bool bUseMmap;
341         bool bHostnameLookups;
342         bool bUnixExtensions;
343         bool bDisableNetbios;
344         char * szDedicatedKeytabFile;
345         int  iKerberosMethod;
346         bool bDeferSharingViolations;
347         bool bEnablePrivileges;
348         bool bASUSupport;
349         bool bUsershareOwnerOnly;
350         bool bUsershareAllowGuests;
351         bool bRegistryShares;
352         int restrict_anonymous;
353         int name_cache_timeout;
354         int client_signing;
355         int server_signing;
356         int client_ldap_sasl_wrapping;
357         int iUsershareMaxShares;
358         int iIdmapCacheTime;
359         int iIdmapNegativeCacheTime;
360         bool bResetOnZeroVC;
361         bool bLogWriteableFilesOnExit;
362         int iKeepalive;
363         int iminreceivefile;
364         struct param_opt_struct *param_opt;
365         int cups_connection_timeout;
366         char *szSMBPerfcountModule;
367         bool bMapUntrustedToDomain;
368         bool bAsyncSMBEchoHandler;
369         int ismb2_max_read;
370         int ismb2_max_write;
371         int ismb2_max_trans;
372 };
373
374 static struct global Globals;
375
376 /*
377  * This structure describes a single service.
378  */
379 struct service {
380         bool valid;
381         bool autoloaded;
382         int usershare;
383         struct timespec usershare_last_mod;
384         char *szService;
385         char *szPath;
386         char *szUsername;
387         char **szInvalidUsers;
388         char **szValidUsers;
389         char **szAdminUsers;
390         char *szCopy;
391         char *szInclude;
392         char *szPreExec;
393         char *szPostExec;
394         char *szRootPreExec;
395         char *szRootPostExec;
396         char *szCupsOptions;
397         char *szPrintcommand;
398         char *szLpqcommand;
399         char *szLprmcommand;
400         char *szLppausecommand;
401         char *szLpresumecommand;
402         char *szQueuepausecommand;
403         char *szQueueresumecommand;
404         char *szPrintername;
405         char *szPrintjobUsername;
406         char *szDontdescend;
407         char **szHostsallow;
408         char **szHostsdeny;
409         char *szMagicScript;
410         char *szMagicOutput;
411         char *szVetoFiles;
412         char *szHideFiles;
413         char *szVetoOplockFiles;
414         char *comment;
415         char *force_user;
416         char *force_group;
417         char **readlist;
418         char **writelist;
419         char **printer_admin;
420         char *volume;
421         char *fstype;
422         char **szVfsObjects;
423         char *szMSDfsProxy;
424         char *szAioWriteBehind;
425         char *szDfree;
426         int iMinPrintSpace;
427         int iMaxPrintJobs;
428         int iMaxReportedPrintJobs;
429         int iWriteCacheSize;
430         int iCreate_mask;
431         int iCreate_force_mode;
432         int iSecurity_mask;
433         int iSecurity_force_mode;
434         int iDir_mask;
435         int iDir_force_mode;
436         int iDir_Security_mask;
437         int iDir_Security_force_mode;
438         int iMaxConnections;
439         int iDefaultCase;
440         int iPrinting;
441         int iOplockContentionLimit;
442         int iCSCPolicy;
443         int iBlock_size;
444         int iDfreeCacheTime;
445         bool bPreexecClose;
446         bool bRootpreexecClose;
447         int  iCaseSensitive;
448         bool bCasePreserve;
449         bool bShortCasePreserve;
450         bool bHideDotFiles;
451         bool bHideSpecialFiles;
452         bool bHideUnReadable;
453         bool bHideUnWriteableFiles;
454         bool bBrowseable;
455         bool bAccessBasedShareEnum;
456         bool bAvailable;
457         bool bRead_only;
458         bool bNo_set_dir;
459         bool bGuest_only;
460         bool bAdministrative_share;
461         bool bGuest_ok;
462         bool bPrint_ok;
463         bool bMap_system;
464         bool bMap_hidden;
465         bool bMap_archive;
466         bool bStoreDosAttributes;
467         bool bDmapiSupport;
468         bool bLocking;
469         int iStrictLocking;
470         bool bPosixLocking;
471         bool bShareModes;
472         bool bOpLocks;
473         bool bLevel2OpLocks;
474         bool bOnlyUser;
475         bool bMangledNames;
476         bool bWidelinks;
477         bool bSymlinks;
478         bool bSyncAlways;
479         bool bStrictAllocate;
480         bool bStrictSync;
481         char magic_char;
482         struct bitmap *copymap;
483         bool bDeleteReadonly;
484         bool bFakeOplocks;
485         bool bDeleteVetoFiles;
486         bool bDosFilemode;
487         bool bDosFiletimes;
488         bool bDosFiletimeResolution;
489         bool bFakeDirCreateTimes;
490         bool bBlockingLocks;
491         bool bInheritPerms;
492         bool bInheritACLS;
493         bool bInheritOwner;
494         bool bMSDfsRoot;
495         bool bUseClientDriver;
496         bool bDefaultDevmode;
497         bool bForcePrintername;
498         bool bNTAclSupport;
499         bool bForceUnknownAclUser;
500         bool bUseSendfile;
501         bool bProfileAcls;
502         bool bMap_acl_inherit;
503         bool bAfs_Share;
504         bool bEASupport;
505         bool bAclCheckPermissions;
506         bool bAclMapFullControl;
507         bool bAclGroupControl;
508         bool bChangeNotify;
509         bool bKernelChangeNotify;
510         int iallocation_roundup_size;
511         int iAioReadSize;
512         int iAioWriteSize;
513         int iMap_readonly;
514         int iDirectoryNameCacheSize;
515         int ismb_encrypt;
516         struct param_opt_struct *param_opt;
517
518         char dummy[3];          /* for alignment */
519 };
520
521
522 /* This is a default service used to prime a services structure */
523 static struct service sDefault = {
524         True,                   /* valid */
525         False,                  /* not autoloaded */
526         0,                      /* not a usershare */
527         {0, },                  /* No last mod time */
528         NULL,                   /* szService */
529         NULL,                   /* szPath */
530         NULL,                   /* szUsername */
531         NULL,                   /* szInvalidUsers */
532         NULL,                   /* szValidUsers */
533         NULL,                   /* szAdminUsers */
534         NULL,                   /* szCopy */
535         NULL,                   /* szInclude */
536         NULL,                   /* szPreExec */
537         NULL,                   /* szPostExec */
538         NULL,                   /* szRootPreExec */
539         NULL,                   /* szRootPostExec */
540         NULL,                   /* szCupsOptions */
541         NULL,                   /* szPrintcommand */
542         NULL,                   /* szLpqcommand */
543         NULL,                   /* szLprmcommand */
544         NULL,                   /* szLppausecommand */
545         NULL,                   /* szLpresumecommand */
546         NULL,                   /* szQueuepausecommand */
547         NULL,                   /* szQueueresumecommand */
548         NULL,                   /* szPrintername */
549         NULL,                   /* szPrintjobUsername */
550         NULL,                   /* szDontdescend */
551         NULL,                   /* szHostsallow */
552         NULL,                   /* szHostsdeny */
553         NULL,                   /* szMagicScript */
554         NULL,                   /* szMagicOutput */
555         NULL,                   /* szVetoFiles */
556         NULL,                   /* szHideFiles */
557         NULL,                   /* szVetoOplockFiles */
558         NULL,                   /* comment */
559         NULL,                   /* force user */
560         NULL,                   /* force group */
561         NULL,                   /* readlist */
562         NULL,                   /* writelist */
563         NULL,                   /* printer admin */
564         NULL,                   /* volume */
565         NULL,                   /* fstype */
566         NULL,                   /* vfs objects */
567         NULL,                   /* szMSDfsProxy */
568         NULL,                   /* szAioWriteBehind */
569         NULL,                   /* szDfree */
570         0,                      /* iMinPrintSpace */
571         1000,                   /* iMaxPrintJobs */
572         0,                      /* iMaxReportedPrintJobs */
573         0,                      /* iWriteCacheSize */
574         0744,                   /* iCreate_mask */
575         0000,                   /* iCreate_force_mode */
576         0777,                   /* iSecurity_mask */
577         0,                      /* iSecurity_force_mode */
578         0755,                   /* iDir_mask */
579         0000,                   /* iDir_force_mode */
580         0777,                   /* iDir_Security_mask */
581         0,                      /* iDir_Security_force_mode */
582         0,                      /* iMaxConnections */
583         CASE_LOWER,             /* iDefaultCase */
584         DEFAULT_PRINTING,       /* iPrinting */
585         2,                      /* iOplockContentionLimit */
586         0,                      /* iCSCPolicy */
587         1024,                   /* iBlock_size */
588         0,                      /* iDfreeCacheTime */
589         False,                  /* bPreexecClose */
590         False,                  /* bRootpreexecClose */
591         Auto,                   /* case sensitive */
592         True,                   /* case preserve */
593         True,                   /* short case preserve */
594         True,                   /* bHideDotFiles */
595         False,                  /* bHideSpecialFiles */
596         False,                  /* bHideUnReadable */
597         False,                  /* bHideUnWriteableFiles */
598         True,                   /* bBrowseable */
599         False,                  /* bAccessBasedShareEnum */
600         True,                   /* bAvailable */
601         True,                   /* bRead_only */
602         True,                   /* bNo_set_dir */
603         False,                  /* bGuest_only */
604         False,                  /* bAdministrative_share */
605         False,                  /* bGuest_ok */
606         False,                  /* bPrint_ok */
607         False,                  /* bMap_system */
608         False,                  /* bMap_hidden */
609         True,                   /* bMap_archive */
610         False,                  /* bStoreDosAttributes */
611         False,                  /* bDmapiSupport */
612         True,                   /* bLocking */
613         Auto,                   /* iStrictLocking */
614         True,                   /* bPosixLocking */
615         True,                   /* bShareModes */
616         True,                   /* bOpLocks */
617         True,                   /* bLevel2OpLocks */
618         False,                  /* bOnlyUser */
619         True,                   /* bMangledNames */
620         false,                  /* bWidelinks */
621         True,                   /* bSymlinks */
622         False,                  /* bSyncAlways */
623         False,                  /* bStrictAllocate */
624         False,                  /* bStrictSync */
625         '~',                    /* magic char */
626         NULL,                   /* copymap */
627         False,                  /* bDeleteReadonly */
628         False,                  /* bFakeOplocks */
629         False,                  /* bDeleteVetoFiles */
630         False,                  /* bDosFilemode */
631         True,                   /* bDosFiletimes */
632         False,                  /* bDosFiletimeResolution */
633         False,                  /* bFakeDirCreateTimes */
634         True,                   /* bBlockingLocks */
635         False,                  /* bInheritPerms */
636         False,                  /* bInheritACLS */
637         False,                  /* bInheritOwner */
638         False,                  /* bMSDfsRoot */
639         False,                  /* bUseClientDriver */
640         True,                   /* bDefaultDevmode */
641         False,                  /* bForcePrintername */
642         True,                   /* bNTAclSupport */
643         False,                  /* bForceUnknownAclUser */
644         False,                  /* bUseSendfile */
645         False,                  /* bProfileAcls */
646         False,                  /* bMap_acl_inherit */
647         False,                  /* bAfs_Share */
648         False,                  /* bEASupport */
649         True,                   /* bAclCheckPermissions */
650         True,                   /* bAclMapFullControl */
651         False,                  /* bAclGroupControl */
652         True,                   /* bChangeNotify */
653         True,                   /* bKernelChangeNotify */
654         SMB_ROUNDUP_ALLOCATION_SIZE,            /* iallocation_roundup_size */
655         0,                      /* iAioReadSize */
656         0,                      /* iAioWriteSize */
657         MAP_READONLY_YES,       /* iMap_readonly */
658 #ifdef BROKEN_DIRECTORY_HANDLING
659         0,                      /* iDirectoryNameCacheSize */
660 #else
661         100,                    /* iDirectoryNameCacheSize */
662 #endif
663         Auto,                   /* ismb_encrypt */
664         NULL,                   /* Parametric options */
665
666         ""                      /* dummy */
667 };
668
669 /* local variables */
670 static struct service **ServicePtrs = NULL;
671 static int iNumServices = 0;
672 static int iServiceIndex = 0;
673 static struct db_context *ServiceHash;
674 static int *invalid_services = NULL;
675 static int num_invalid_services = 0;
676 static bool bInGlobalSection = True;
677 static bool bGlobalOnly = False;
678 static int default_server_announce;
679
680 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
681
682 /* prototypes for the special type handlers */
683 static bool handle_include( int snum, const char *pszParmValue, char **ptr);
684 static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
685 static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
686 static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
687 static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
688 static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
689 static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
690 static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
691 static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
692 static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
693 static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
694 static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
695
696 static void set_default_server_announce_type(void);
697 static void set_allowed_client_auth(void);
698
699 static void *lp_local_ptr(struct service *service, void *ptr);
700
701 static void add_to_file_list(const char *fname, const char *subfname);
702
703 static const struct enum_list enum_protocol[] = {
704         {PROTOCOL_SMB2, "SMB2"},
705         {PROTOCOL_NT1, "NT1"},
706         {PROTOCOL_LANMAN2, "LANMAN2"},
707         {PROTOCOL_LANMAN1, "LANMAN1"},
708         {PROTOCOL_CORE, "CORE"},
709         {PROTOCOL_COREPLUS, "COREPLUS"},
710         {PROTOCOL_COREPLUS, "CORE+"},
711         {-1, NULL}
712 };
713
714 static const struct enum_list enum_security[] = {
715         {SEC_SHARE, "SHARE"},
716         {SEC_USER, "USER"},
717         {SEC_SERVER, "SERVER"},
718         {SEC_DOMAIN, "DOMAIN"},
719 #ifdef HAVE_ADS
720         {SEC_ADS, "ADS"},
721 #endif
722         {-1, NULL}
723 };
724
725 static const struct enum_list enum_printing[] = {
726         {PRINT_SYSV, "sysv"},
727         {PRINT_AIX, "aix"},
728         {PRINT_HPUX, "hpux"},
729         {PRINT_BSD, "bsd"},
730         {PRINT_QNX, "qnx"},
731         {PRINT_PLP, "plp"},
732         {PRINT_LPRNG, "lprng"},
733         {PRINT_CUPS, "cups"},
734         {PRINT_IPRINT, "iprint"},
735         {PRINT_LPRNT, "nt"},
736         {PRINT_LPROS2, "os2"},
737 #ifdef DEVELOPER
738         {PRINT_TEST, "test"},
739         {PRINT_VLP, "vlp"},
740 #endif /* DEVELOPER */
741         {-1, NULL}
742 };
743
744 static const struct enum_list enum_ldap_sasl_wrapping[] = {
745         {0, "plain"},
746         {ADS_AUTH_SASL_SIGN, "sign"},
747         {ADS_AUTH_SASL_SEAL, "seal"},
748         {-1, NULL}
749 };
750
751 static const struct enum_list enum_ldap_ssl[] = {
752         {LDAP_SSL_OFF, "no"},
753         {LDAP_SSL_OFF, "off"},
754         {LDAP_SSL_START_TLS, "start tls"},
755         {LDAP_SSL_START_TLS, "start_tls"},
756         {-1, NULL}
757 };
758
759 /* LDAP Dereferencing Alias types */
760 #define SAMBA_LDAP_DEREF_NEVER          0
761 #define SAMBA_LDAP_DEREF_SEARCHING      1
762 #define SAMBA_LDAP_DEREF_FINDING        2
763 #define SAMBA_LDAP_DEREF_ALWAYS         3
764
765 static const struct enum_list enum_ldap_deref[] = {
766         {SAMBA_LDAP_DEREF_NEVER, "never"},
767         {SAMBA_LDAP_DEREF_SEARCHING, "searching"},
768         {SAMBA_LDAP_DEREF_FINDING, "finding"},
769         {SAMBA_LDAP_DEREF_ALWAYS, "always"},
770         {-1, "auto"}
771 };
772
773 static const struct enum_list enum_ldap_passwd_sync[] = {
774         {LDAP_PASSWD_SYNC_OFF, "no"},
775         {LDAP_PASSWD_SYNC_OFF, "off"},
776         {LDAP_PASSWD_SYNC_ON, "yes"},
777         {LDAP_PASSWD_SYNC_ON, "on"},
778         {LDAP_PASSWD_SYNC_ONLY, "only"},
779         {-1, NULL}
780 };
781
782 /* Types of machine we can announce as. */
783 #define ANNOUNCE_AS_NT_SERVER 1
784 #define ANNOUNCE_AS_WIN95 2
785 #define ANNOUNCE_AS_WFW 3
786 #define ANNOUNCE_AS_NT_WORKSTATION 4
787
788 static const struct enum_list enum_announce_as[] = {
789         {ANNOUNCE_AS_NT_SERVER, "NT"},
790         {ANNOUNCE_AS_NT_SERVER, "NT Server"},
791         {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
792         {ANNOUNCE_AS_WIN95, "win95"},
793         {ANNOUNCE_AS_WFW, "WfW"},
794         {-1, NULL}
795 };
796
797 static const struct enum_list enum_map_readonly[] = {
798         {MAP_READONLY_NO, "no"},
799         {MAP_READONLY_NO, "false"},
800         {MAP_READONLY_NO, "0"},
801         {MAP_READONLY_YES, "yes"},
802         {MAP_READONLY_YES, "true"},
803         {MAP_READONLY_YES, "1"},
804         {MAP_READONLY_PERMISSIONS, "permissions"},
805         {MAP_READONLY_PERMISSIONS, "perms"},
806         {-1, NULL}
807 };
808
809 static const struct enum_list enum_case[] = {
810         {CASE_LOWER, "lower"},
811         {CASE_UPPER, "upper"},
812         {-1, NULL}
813 };
814
815
816
817 static const struct enum_list enum_bool_auto[] = {
818         {False, "No"},
819         {False, "False"},
820         {False, "0"},
821         {True, "Yes"},
822         {True, "True"},
823         {True, "1"},
824         {Auto, "Auto"},
825         {-1, NULL}
826 };
827
828 static const struct enum_list enum_csc_policy[] = {
829         {CSC_POLICY_MANUAL, "manual"},
830         {CSC_POLICY_DOCUMENTS, "documents"},
831         {CSC_POLICY_PROGRAMS, "programs"},
832         {CSC_POLICY_DISABLE, "disable"},
833         {-1, NULL}
834 };
835
836 /* SMB signing types. */
837 static const struct enum_list enum_smb_signing_vals[] = {
838         {False, "No"},
839         {False, "False"},
840         {False, "0"},
841         {False, "Off"},
842         {False, "disabled"},
843         {True, "Yes"},
844         {True, "True"},
845         {True, "1"},
846         {True, "On"},
847         {True, "enabled"},
848         {Auto, "auto"},
849         {Required, "required"},
850         {Required, "mandatory"},
851         {Required, "force"},
852         {Required, "forced"},
853         {Required, "enforced"},
854         {-1, NULL}
855 };
856
857 /* ACL compatibility options. */
858 static const struct enum_list enum_acl_compat_vals[] = {
859     { ACL_COMPAT_AUTO, "auto" },
860     { ACL_COMPAT_WINNT, "winnt" },
861     { ACL_COMPAT_WIN2K, "win2k" },
862     { -1, NULL}
863 };
864
865 /* 
866    Do you want session setups at user level security with a invalid
867    password to be rejected or allowed in as guest? WinNT rejects them
868    but it can be a pain as it means "net view" needs to use a password
869
870    You have 3 choices in the setting of map_to_guest:
871
872    "Never" means session setups with an invalid password
873    are rejected. This is the default.
874
875    "Bad User" means session setups with an invalid password
876    are rejected, unless the username does not exist, in which case it
877    is treated as a guest login
878
879    "Bad Password" means session setups with an invalid password
880    are treated as a guest login
881
882    Note that map_to_guest only has an effect in user or server
883    level security.
884 */
885
886 static const struct enum_list enum_map_to_guest[] = {
887         {NEVER_MAP_TO_GUEST, "Never"},
888         {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
889         {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
890         {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
891         {-1, NULL}
892 };
893
894 /* Config backend options */
895
896 static const struct enum_list enum_config_backend[] = {
897         {CONFIG_BACKEND_FILE, "file"},
898         {CONFIG_BACKEND_REGISTRY, "registry"},
899         {-1, NULL}
900 };
901
902 /* ADS kerberos ticket verification options */
903
904 static const struct enum_list enum_kerberos_method[] = {
905         {KERBEROS_VERIFY_SECRETS, "default"},
906         {KERBEROS_VERIFY_SECRETS, "secrets only"},
907         {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
908         {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
909         {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
910         {-1, NULL}
911 };
912
913 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
914  *
915  * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
916  * screen in SWAT. This is used to exclude parameters as well as to squash all
917  * parameters that have been duplicated by pseudonyms.
918  *
919  * NOTE: To display a parameter in BASIC view set FLAG_BASIC
920  *       Any parameter that does NOT have FLAG_ADVANCED will not disply at all
921  *       Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
922  *        respective views.
923  *
924  * NOTE2: Handling of duplicated (synonym) parameters:
925  *      Only the first occurance of a parameter should be enabled by FLAG_BASIC
926  *      and/or FLAG_ADVANCED. All duplicates following the first mention should be
927  *      set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
928  *      name first, and all synonyms must follow it with the FLAG_HIDE attribute.
929  */
930
931 static struct parm_struct parm_table[] = {
932         {N_("Base Options"), P_SEP, P_SEPARATOR},
933
934         {
935                 .label          = "dos charset",
936                 .type           = P_STRING,
937                 .p_class        = P_GLOBAL,
938                 .ptr            = &Globals.dos_charset,
939                 .special        = handle_charset,
940                 .enum_list      = NULL,
941                 .flags          = FLAG_ADVANCED
942         },
943         {
944                 .label          = "unix charset",
945                 .type           = P_STRING,
946                 .p_class        = P_GLOBAL,
947                 .ptr            = &Globals.unix_charset,
948                 .special        = handle_charset,
949                 .enum_list      = NULL,
950                 .flags          = FLAG_ADVANCED
951         },
952         {
953                 .label          = "display charset",
954                 .type           = P_STRING,
955                 .p_class        = P_GLOBAL,
956                 .ptr            = &Globals.display_charset,
957                 .special        = handle_charset,
958                 .enum_list      = NULL,
959                 .flags          = FLAG_ADVANCED
960         },
961         {
962                 .label          = "comment",
963                 .type           = P_STRING,
964                 .p_class        = P_LOCAL,
965                 .ptr            = &sDefault.comment,
966                 .special        = NULL,
967                 .enum_list      = NULL,
968                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
969         },
970         {
971                 .label          = "path",
972                 .type           = P_STRING,
973                 .p_class        = P_LOCAL,
974                 .ptr            = &sDefault.szPath,
975                 .special        = NULL,
976                 .enum_list      = NULL,
977                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
978         },
979         {
980                 .label          = "directory",
981                 .type           = P_STRING,
982                 .p_class        = P_LOCAL,
983                 .ptr            = &sDefault.szPath,
984                 .special        = NULL,
985                 .enum_list      = NULL,
986                 .flags          = FLAG_HIDE,
987         },
988         {
989                 .label          = "workgroup",
990                 .type           = P_USTRING,
991                 .p_class        = P_GLOBAL,
992                 .ptr            = &Globals.szWorkgroup,
993                 .special        = handle_workgroup,
994                 .enum_list      = NULL,
995                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
996         },
997 #ifdef WITH_ADS
998         {
999                 .label          = "realm",
1000                 .type           = P_USTRING,
1001                 .p_class        = P_GLOBAL,
1002                 .ptr            = &Globals.szRealm,
1003                 .special        = NULL,
1004                 .enum_list      = NULL,
1005                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1006         },
1007 #endif
1008         {
1009                 .label          = "netbios name",
1010                 .type           = P_USTRING,
1011                 .p_class        = P_GLOBAL,
1012                 .ptr            = &Globals.szNetbiosName,
1013                 .special        = handle_netbios_name,
1014                 .enum_list      = NULL,
1015                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1016         },
1017         {
1018                 .label          = "netbios aliases",
1019                 .type           = P_LIST,
1020                 .p_class        = P_GLOBAL,
1021                 .ptr            = &Globals.szNetbiosAliases,
1022                 .special        = handle_netbios_aliases,
1023                 .enum_list      = NULL,
1024                 .flags          = FLAG_ADVANCED,
1025         },
1026         {
1027                 .label          = "netbios scope",
1028                 .type           = P_USTRING,
1029                 .p_class        = P_GLOBAL,
1030                 .ptr            = &Globals.szNetbiosScope,
1031                 .special        = handle_netbios_scope,
1032                 .enum_list      = NULL,
1033                 .flags          = FLAG_ADVANCED,
1034         },
1035         {
1036                 .label          = "server string",
1037                 .type           = P_STRING,
1038                 .p_class        = P_GLOBAL,
1039                 .ptr            = &Globals.szServerString,
1040                 .special        = NULL,
1041                 .enum_list      = NULL,
1042                 .flags          = FLAG_BASIC | FLAG_ADVANCED,
1043         },
1044         {
1045                 .label          = "interfaces",
1046                 .type           = P_LIST,
1047                 .p_class        = P_GLOBAL,
1048                 .ptr            = &Globals.szInterfaces,
1049                 .special        = NULL,
1050                 .enum_list      = NULL,
1051                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1052         },
1053         {
1054                 .label          = "bind interfaces only",
1055                 .type           = P_BOOL,
1056                 .p_class        = P_GLOBAL,
1057                 .ptr            = &Globals.bBindInterfacesOnly,
1058                 .special        = NULL,
1059                 .enum_list      = NULL,
1060                 .flags          = FLAG_ADVANCED | FLAG_WIZARD,
1061         },
1062         {
1063                 .label          = "config backend",
1064                 .type           = P_ENUM,
1065                 .p_class        = P_GLOBAL,
1066                 .ptr            = &Globals.ConfigBackend,
1067                 .special        = NULL,
1068                 .enum_list      = enum_config_backend,
1069                 .flags          = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
1070         },
1071
1072         {N_("Security Options"), P_SEP, P_SEPARATOR},
1073
1074         {
1075                 .label          = "security",
1076                 .type           = P_ENUM,
1077                 .p_class        = P_GLOBAL,
1078                 .ptr            = &Globals.security,
1079                 .special        = NULL,
1080                 .enum_list      = enum_security,
1081                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1082         },
1083         {
1084                 .label          = "auth methods",
1085                 .type           = P_LIST,
1086                 .p_class        = P_GLOBAL,
1087                 .ptr            = &Globals.AuthMethods,
1088                 .special        = NULL,
1089                 .enum_list      = NULL,
1090                 .flags          = FLAG_ADVANCED,
1091         },
1092         {
1093                 .label          = "encrypt passwords",
1094                 .type           = P_BOOL,
1095                 .p_class        = P_GLOBAL,
1096                 .ptr            = &Globals.bEncryptPasswords,
1097                 .special        = NULL,
1098                 .enum_list      = NULL,
1099                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1100         },
1101         {
1102                 .label          = "update encrypted",
1103                 .type           = P_BOOL,
1104                 .p_class        = P_GLOBAL,
1105                 .ptr            = &Globals.bUpdateEncrypt,
1106                 .special        = NULL,
1107                 .enum_list      = NULL,
1108                 .flags          = FLAG_ADVANCED,
1109         },
1110         {
1111                 .label          = "client schannel",
1112                 .type           = P_ENUM,
1113                 .p_class        = P_GLOBAL,
1114                 .ptr            = &Globals.clientSchannel,
1115                 .special        = NULL,
1116                 .enum_list      = enum_bool_auto,
1117                 .flags          = FLAG_BASIC | FLAG_ADVANCED,
1118         },
1119         {
1120                 .label          = "server schannel",
1121                 .type           = P_ENUM,
1122                 .p_class        = P_GLOBAL,
1123                 .ptr            = &Globals.serverSchannel,
1124                 .special        = NULL,
1125                 .enum_list      = enum_bool_auto,
1126                 .flags          = FLAG_BASIC | FLAG_ADVANCED,
1127         },
1128         {
1129                 .label          = "allow trusted domains",
1130                 .type           = P_BOOL,
1131                 .p_class        = P_GLOBAL,
1132                 .ptr            = &Globals.bAllowTrustedDomains,
1133                 .special        = NULL,
1134                 .enum_list      = NULL,
1135                 .flags          = FLAG_ADVANCED,
1136         },
1137         {
1138                 .label          = "map to guest",
1139                 .type           = P_ENUM,
1140                 .p_class        = P_GLOBAL,
1141                 .ptr            = &Globals.map_to_guest,
1142                 .special        = NULL,
1143                 .enum_list      = enum_map_to_guest,
1144                 .flags          = FLAG_ADVANCED,
1145         },
1146         {
1147                 .label          = "null passwords",
1148                 .type           = P_BOOL,
1149                 .p_class        = P_GLOBAL,
1150                 .ptr            = &Globals.bNullPasswords,
1151                 .special        = NULL,
1152                 .enum_list      = NULL,
1153                 .flags          = FLAG_ADVANCED,
1154         },
1155         {
1156                 .label          = "obey pam restrictions",
1157                 .type           = P_BOOL,
1158                 .p_class        = P_GLOBAL,
1159                 .ptr            = &Globals.bObeyPamRestrictions,
1160                 .special        = NULL,
1161                 .enum_list      = NULL,
1162                 .flags          = FLAG_ADVANCED,
1163         },
1164         {
1165                 .label          = "password server",
1166                 .type           = P_STRING,
1167                 .p_class        = P_GLOBAL,
1168                 .ptr            = &Globals.szPasswordServer,
1169                 .special        = NULL,
1170                 .enum_list      = NULL,
1171                 .flags          = FLAG_ADVANCED | FLAG_WIZARD,
1172         },
1173         {
1174                 .label          = "smb passwd file",
1175                 .type           = P_STRING,
1176                 .p_class        = P_GLOBAL,
1177                 .ptr            = &Globals.szSMBPasswdFile,
1178                 .special        = NULL,
1179                 .enum_list      = NULL,
1180                 .flags          = FLAG_ADVANCED,
1181         },
1182         {
1183                 .label          = "private dir",
1184                 .type           = P_STRING,
1185                 .p_class        = P_GLOBAL,
1186                 .ptr            = &Globals.szPrivateDir,
1187                 .special        = NULL,
1188                 .enum_list      = NULL,
1189                 .flags          = FLAG_ADVANCED,
1190         },
1191         {
1192                 .label          = "passdb backend",
1193                 .type           = P_STRING,
1194                 .p_class        = P_GLOBAL,
1195                 .ptr            = &Globals.szPassdbBackend,
1196                 .special        = NULL,
1197                 .enum_list      = NULL,
1198                 .flags          = FLAG_ADVANCED | FLAG_WIZARD,
1199         },
1200         {
1201                 .label          = "algorithmic rid base",
1202                 .type           = P_INTEGER,
1203                 .p_class        = P_GLOBAL,
1204                 .ptr            = &Globals.AlgorithmicRidBase,
1205                 .special        = NULL,
1206                 .enum_list      = NULL,
1207                 .flags          = FLAG_ADVANCED,
1208         },
1209         {
1210                 .label          = "root directory",
1211                 .type           = P_STRING,
1212                 .p_class        = P_GLOBAL,
1213                 .ptr            = &Globals.szRootdir,
1214                 .special        = NULL,
1215                 .enum_list      = NULL,
1216                 .flags          = FLAG_ADVANCED,
1217         },
1218         {
1219                 .label          = "root dir",
1220                 .type           = P_STRING,
1221                 .p_class        = P_GLOBAL,
1222                 .ptr            = &Globals.szRootdir,
1223                 .special        = NULL,
1224                 .enum_list      = NULL,
1225                 .flags          = FLAG_HIDE,
1226         },
1227         {
1228                 .label          = "root",
1229                 .type           = P_STRING,
1230                 .p_class        = P_GLOBAL,
1231                 .ptr            = &Globals.szRootdir,
1232                 .special        = NULL,
1233                 .enum_list      = NULL,
1234                 .flags          = FLAG_HIDE,
1235         },
1236         {
1237                 .label          = "guest account",
1238                 .type           = P_STRING,
1239                 .p_class        = P_GLOBAL,
1240                 .ptr            = &Globals.szGuestaccount,
1241                 .special        = NULL,
1242                 .enum_list      = NULL,
1243                 .flags          = FLAG_BASIC | FLAG_ADVANCED,
1244         },
1245         {
1246                 .label          = "enable privileges",
1247                 .type           = P_BOOL,
1248                 .p_class        = P_GLOBAL,
1249                 .ptr            = &Globals.bEnablePrivileges,
1250                 .special        = NULL,
1251                 .enum_list      = NULL,
1252                 .flags          = FLAG_ADVANCED,
1253         },
1254
1255         {
1256                 .label          = "pam password change",
1257                 .type           = P_BOOL,
1258                 .p_class        = P_GLOBAL,
1259                 .ptr            = &Globals.bPamPasswordChange,
1260                 .special        = NULL,
1261                 .enum_list      = NULL,
1262                 .flags          = FLAG_ADVANCED,
1263         },
1264         {
1265                 .label          = "passwd program",
1266                 .type           = P_STRING,
1267                 .p_class        = P_GLOBAL,
1268                 .ptr            = &Globals.szPasswdProgram,
1269                 .special        = NULL,
1270                 .enum_list      = NULL,
1271                 .flags          = FLAG_ADVANCED,
1272         },
1273         {
1274                 .label          = "passwd chat",
1275                 .type           = P_STRING,
1276                 .p_class        = P_GLOBAL,
1277                 .ptr            = &Globals.szPasswdChat,
1278                 .special        = NULL,
1279                 .enum_list      = NULL,
1280                 .flags          = FLAG_ADVANCED,
1281         },
1282         {
1283                 .label          = "passwd chat debug",
1284                 .type           = P_BOOL,
1285                 .p_class        = P_GLOBAL,
1286                 .ptr            = &Globals.bPasswdChatDebug,
1287                 .special        = NULL,
1288                 .enum_list      = NULL,
1289                 .flags          = FLAG_ADVANCED,
1290         },
1291         {
1292                 .label          = "passwd chat timeout",
1293                 .type           = P_INTEGER,
1294                 .p_class        = P_GLOBAL,
1295                 .ptr            = &Globals.iPasswdChatTimeout,
1296                 .special        = NULL,
1297                 .enum_list      = NULL,
1298                 .flags          = FLAG_ADVANCED,
1299         },
1300         {
1301                 .label          = "check password script",
1302                 .type           = P_STRING,
1303                 .p_class        = P_GLOBAL,
1304                 .ptr            = &Globals.szCheckPasswordScript,
1305                 .special        = NULL,
1306                 .enum_list      = NULL,
1307                 .flags          = FLAG_ADVANCED,
1308         },
1309         {
1310                 .label          = "username map",
1311                 .type           = P_STRING,
1312                 .p_class        = P_GLOBAL,
1313                 .ptr            = &Globals.szUsernameMap,
1314                 .special        = NULL,
1315                 .enum_list      = NULL,
1316                 .flags          = FLAG_ADVANCED,
1317         },
1318         {
1319                 .label          = "password level",
1320                 .type           = P_INTEGER,
1321                 .p_class        = P_GLOBAL,
1322                 .ptr            = &Globals.pwordlevel,
1323                 .special        = NULL,
1324                 .enum_list      = NULL,
1325                 .flags          = FLAG_ADVANCED,
1326         },
1327         {
1328                 .label          = "username level",
1329                 .type           = P_INTEGER,
1330                 .p_class        = P_GLOBAL,
1331                 .ptr            = &Globals.unamelevel,
1332                 .special        = NULL,
1333                 .enum_list      = NULL,
1334                 .flags          = FLAG_ADVANCED,
1335         },
1336         {
1337                 .label          = "unix password sync",
1338                 .type           = P_BOOL,
1339                 .p_class        = P_GLOBAL,
1340                 .ptr            = &Globals.bUnixPasswdSync,
1341                 .special        = NULL,
1342                 .enum_list      = NULL,
1343                 .flags          = FLAG_ADVANCED,
1344         },
1345         {
1346                 .label          = "restrict anonymous",
1347                 .type           = P_INTEGER,
1348                 .p_class        = P_GLOBAL,
1349                 .ptr            = &Globals.restrict_anonymous,
1350                 .special        = NULL,
1351                 .enum_list      = NULL,
1352                 .flags          = FLAG_ADVANCED,
1353         },
1354         {
1355                 .label          = "lanman auth",
1356                 .type           = P_BOOL,
1357                 .p_class        = P_GLOBAL,
1358                 .ptr            = &Globals.bLanmanAuth,
1359                 .special        = NULL,
1360                 .enum_list      = NULL,
1361                 .flags          = FLAG_ADVANCED,
1362         },
1363         {
1364                 .label          = "ntlm auth",
1365                 .type           = P_BOOL,
1366                 .p_class        = P_GLOBAL,
1367                 .ptr            = &Globals.bNTLMAuth,
1368                 .special        = NULL,
1369                 .enum_list      = NULL,
1370                 .flags          = FLAG_ADVANCED,
1371         },
1372         {
1373                 .label          = "client NTLMv2 auth",
1374                 .type           = P_BOOL,
1375                 .p_class        = P_GLOBAL,
1376                 .ptr            = &Globals.bClientNTLMv2Auth,
1377                 .special        = NULL,
1378                 .enum_list      = NULL,
1379                 .flags          = FLAG_ADVANCED,
1380         },
1381         {
1382                 .label          = "client lanman auth",
1383                 .type           = P_BOOL,
1384                 .p_class        = P_GLOBAL,
1385                 .ptr            = &Globals.bClientLanManAuth,
1386                 .special        = NULL,
1387                 .enum_list      = NULL,
1388                 .flags          = FLAG_ADVANCED,
1389         },
1390         {
1391                 .label          = "client plaintext auth",
1392                 .type           = P_BOOL,
1393                 .p_class        = P_GLOBAL,
1394                 .ptr            = &Globals.bClientPlaintextAuth,
1395                 .special        = NULL,
1396                 .enum_list      = NULL,
1397                 .flags          = FLAG_ADVANCED,
1398         },
1399         {
1400                 .label          = "username",
1401                 .type           = P_STRING,
1402                 .p_class        = P_LOCAL,
1403                 .ptr            = &sDefault.szUsername,
1404                 .special        = NULL,
1405                 .enum_list      = NULL,
1406                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1407         },
1408         {
1409                 .label          = "user",
1410                 .type           = P_STRING,
1411                 .p_class        = P_LOCAL,
1412                 .ptr            = &sDefault.szUsername,
1413                 .special        = NULL,
1414                 .enum_list      = NULL,
1415                 .flags          = FLAG_HIDE,
1416         },
1417         {
1418                 .label          = "users",
1419                 .type           = P_STRING,
1420                 .p_class        = P_LOCAL,
1421                 .ptr            = &sDefault.szUsername,
1422                 .special        = NULL,
1423                 .enum_list      = NULL,
1424                 .flags          = FLAG_HIDE,
1425         },
1426         {
1427                 .label          = "invalid users",
1428                 .type           = P_LIST,
1429                 .p_class        = P_LOCAL,
1430                 .ptr            = &sDefault.szInvalidUsers,
1431                 .special        = NULL,
1432                 .enum_list      = NULL,
1433                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1434         },
1435         {
1436                 .label          = "valid users",
1437                 .type           = P_LIST,
1438                 .p_class        = P_LOCAL,
1439                 .ptr            = &sDefault.szValidUsers,
1440                 .special        = NULL,
1441                 .enum_list      = NULL,
1442                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1443         },
1444         {
1445                 .label          = "admin users",
1446                 .type           = P_LIST,
1447                 .p_class        = P_LOCAL,
1448                 .ptr            = &sDefault.szAdminUsers,
1449                 .special        = NULL,
1450                 .enum_list      = NULL,
1451                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1452         },
1453         {
1454                 .label          = "read list",
1455                 .type           = P_LIST,
1456                 .p_class        = P_LOCAL,
1457                 .ptr            = &sDefault.readlist,
1458                 .special        = NULL,
1459                 .enum_list      = NULL,
1460                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1461         },
1462         {
1463                 .label          = "write list",
1464                 .type           = P_LIST,
1465                 .p_class        = P_LOCAL,
1466                 .ptr            = &sDefault.writelist,
1467                 .special        = NULL,
1468                 .enum_list      = NULL,
1469                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1470         },
1471         {
1472                 .label          = "printer admin",
1473                 .type           = P_LIST,
1474                 .p_class        = P_LOCAL,
1475                 .ptr            = &sDefault.printer_admin,
1476                 .special        = NULL,
1477                 .enum_list      = NULL,
1478                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1479         },
1480         {
1481                 .label          = "force user",
1482                 .type           = P_STRING,
1483                 .p_class        = P_LOCAL,
1484                 .ptr            = &sDefault.force_user,
1485                 .special        = NULL,
1486                 .enum_list      = NULL,
1487                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
1488         },
1489         {
1490                 .label          = "force group",
1491                 .type           = P_STRING,
1492                 .p_class        = P_LOCAL,
1493                 .ptr            = &sDefault.force_group,
1494                 .special        = NULL,
1495                 .enum_list      = NULL,
1496                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
1497         },
1498         {
1499                 .label          = "group",
1500                 .type           = P_STRING,
1501                 .p_class        = P_LOCAL,
1502                 .ptr            = &sDefault.force_group,
1503                 .special        = NULL,
1504                 .enum_list      = NULL,
1505                 .flags          = FLAG_ADVANCED,
1506         },
1507         {
1508                 .label          = "read only",
1509                 .type           = P_BOOL,
1510                 .p_class        = P_LOCAL,
1511                 .ptr            = &sDefault.bRead_only,
1512                 .special        = NULL,
1513                 .enum_list      = NULL,
1514                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1515         },
1516         {
1517                 .label          = "write ok",
1518                 .type           = P_BOOLREV,
1519                 .p_class        = P_LOCAL,
1520                 .ptr            = &sDefault.bRead_only,
1521                 .special        = NULL,
1522                 .enum_list      = NULL,
1523                 .flags          = FLAG_HIDE,
1524         },
1525         {
1526                 .label          = "writeable",
1527                 .type           = P_BOOLREV,
1528                 .p_class        = P_LOCAL,
1529                 .ptr            = &sDefault.bRead_only,
1530                 .special        = NULL,
1531                 .enum_list      = NULL,
1532                 .flags          = FLAG_HIDE,
1533         },
1534         {
1535                 .label          = "writable",
1536                 .type           = P_BOOLREV,
1537                 .p_class        = P_LOCAL,
1538                 .ptr            = &sDefault.bRead_only,
1539                 .special        = NULL,
1540                 .enum_list      = NULL,
1541                 .flags          = FLAG_HIDE,
1542         },
1543         {
1544                 .label          = "acl check permissions",
1545                 .type           = P_BOOL,
1546                 .p_class        = P_LOCAL,
1547                 .ptr            = &sDefault.bAclCheckPermissions,
1548                 .special        = NULL,
1549                 .enum_list      = NULL,
1550                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1551         },
1552         {
1553                 .label          = "acl group control",
1554                 .type           = P_BOOL,
1555                 .p_class        = P_LOCAL,
1556                 .ptr            = &sDefault.bAclGroupControl,
1557                 .special        = NULL,
1558                 .enum_list      = NULL,
1559                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1560         },
1561         {
1562                 .label          = "acl map full control",
1563                 .type           = P_BOOL,
1564                 .p_class        = P_LOCAL,
1565                 .ptr            = &sDefault.bAclMapFullControl,
1566                 .special        = NULL,
1567                 .enum_list      = NULL,
1568                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1569         },
1570         {
1571                 .label          = "create mask",
1572                 .type           = P_OCTAL,
1573                 .p_class        = P_LOCAL,
1574                 .ptr            = &sDefault.iCreate_mask,
1575                 .special        = NULL,
1576                 .enum_list      = NULL,
1577                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1578         },
1579         {
1580                 .label          = "create mode",
1581                 .type           = P_OCTAL,
1582                 .p_class        = P_LOCAL,
1583                 .ptr            = &sDefault.iCreate_mask,
1584                 .special        = NULL,
1585                 .enum_list      = NULL,
1586                 .flags          = FLAG_HIDE,
1587         },
1588         {
1589                 .label          = "force create mode",
1590                 .type           = P_OCTAL,
1591                 .p_class        = P_LOCAL,
1592                 .ptr            = &sDefault.iCreate_force_mode,
1593                 .special        = NULL,
1594                 .enum_list      = NULL,
1595                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1596         },
1597         {
1598                 .label          = "security mask",
1599                 .type           = P_OCTAL,
1600                 .p_class        = P_LOCAL,
1601                 .ptr            = &sDefault.iSecurity_mask,
1602                 .special        = NULL,
1603                 .enum_list      = NULL,
1604                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1605         },
1606         {
1607                 .label          = "force security mode",
1608                 .type           = P_OCTAL,
1609                 .p_class        = P_LOCAL,
1610                 .ptr            = &sDefault.iSecurity_force_mode,
1611                 .special        = NULL,
1612                 .enum_list      = NULL,
1613                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1614         },
1615         {
1616                 .label          = "directory mask",
1617                 .type           = P_OCTAL,
1618                 .p_class        = P_LOCAL,
1619                 .ptr            = &sDefault.iDir_mask,
1620                 .special        = NULL,
1621                 .enum_list      = NULL,
1622                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1623         },
1624         {
1625                 .label          = "directory mode",
1626                 .type           = P_OCTAL,
1627                 .p_class        = P_LOCAL,
1628                 .ptr            = &sDefault.iDir_mask,
1629                 .special        = NULL,
1630                 .enum_list      = NULL,
1631                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
1632         },
1633         {
1634                 .label          = "force directory mode",
1635                 .type           = P_OCTAL,
1636                 .p_class        = P_LOCAL,
1637                 .ptr            = &sDefault.iDir_force_mode,
1638                 .special        = NULL,
1639                 .enum_list      = NULL,
1640                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1641         },
1642         {
1643                 .label          = "directory security mask",
1644                 .type           = P_OCTAL,
1645                 .p_class        = P_LOCAL,
1646                 .ptr            = &sDefault.iDir_Security_mask,
1647                 .special        = NULL,
1648                 .enum_list      = NULL,
1649                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1650         },
1651         {
1652                 .label          = "force directory security mode",
1653                 .type           = P_OCTAL,
1654                 .p_class        = P_LOCAL,
1655                 .ptr            = &sDefault.iDir_Security_force_mode,
1656                 .special        = NULL,
1657                 .enum_list      = NULL,
1658                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1659         },
1660         {
1661                 .label          = "force unknown acl user",
1662                 .type           = P_BOOL,
1663                 .p_class        = P_LOCAL,
1664                 .ptr            = &sDefault.bForceUnknownAclUser,
1665                 .special        = NULL,
1666                 .enum_list      = NULL,
1667                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1668         },
1669         {
1670                 .label          = "inherit permissions",
1671                 .type           = P_BOOL,
1672                 .p_class        = P_LOCAL,
1673                 .ptr            = &sDefault.bInheritPerms,
1674                 .special        = NULL,
1675                 .enum_list      = NULL,
1676                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
1677         },
1678         {
1679                 .label          = "inherit acls",
1680                 .type           = P_BOOL,
1681                 .p_class        = P_LOCAL,
1682                 .ptr            = &sDefault.bInheritACLS,
1683                 .special        = NULL,
1684                 .enum_list      = NULL,
1685                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
1686         },
1687         {
1688                 .label          = "inherit owner",
1689                 .type           = P_BOOL,
1690                 .p_class        = P_LOCAL,
1691                 .ptr            = &sDefault.bInheritOwner,
1692                 .special        = NULL,
1693                 .enum_list      = NULL,
1694                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
1695         },
1696         {
1697                 .label          = "guest only",
1698                 .type           = P_BOOL,
1699                 .p_class        = P_LOCAL,
1700                 .ptr            = &sDefault.bGuest_only,
1701                 .special        = NULL,
1702                 .enum_list      = NULL,
1703                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
1704         },
1705         {
1706                 .label          = "only guest",
1707                 .type           = P_BOOL,
1708                 .p_class        = P_LOCAL,
1709                 .ptr            = &sDefault.bGuest_only,
1710                 .special        = NULL,
1711                 .enum_list      = NULL,
1712                 .flags          = FLAG_HIDE,
1713         },
1714         {
1715                 .label          = "administrative share",
1716                 .type           = P_BOOL,
1717                 .p_class        = P_LOCAL,
1718                 .ptr            = &sDefault.bAdministrative_share,
1719                 .special        = NULL,
1720                 .enum_list      = NULL,
1721                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1722         },
1723
1724         {
1725                 .label          = "guest ok",
1726                 .type           = P_BOOL,
1727                 .p_class        = P_LOCAL,
1728                 .ptr            = &sDefault.bGuest_ok,
1729                 .special        = NULL,
1730                 .enum_list      = NULL,
1731                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1732         },
1733         {
1734                 .label          = "public",
1735                 .type           = P_BOOL,
1736                 .p_class        = P_LOCAL,
1737                 .ptr            = &sDefault.bGuest_ok,
1738                 .special        = NULL,
1739                 .enum_list      = NULL,
1740                 .flags          = FLAG_HIDE,
1741         },
1742         {
1743                 .label          = "only user",
1744                 .type           = P_BOOL,
1745                 .p_class        = P_LOCAL,
1746                 .ptr            = &sDefault.bOnlyUser,
1747                 .special        = NULL,
1748                 .enum_list      = NULL,
1749                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1750         },
1751         {
1752                 .label          = "hosts allow",
1753                 .type           = P_LIST,
1754                 .p_class        = P_LOCAL,
1755                 .ptr            = &sDefault.szHostsallow,
1756                 .special        = NULL,
1757                 .enum_list      = NULL,
1758                 .flags          = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1759         },
1760         {
1761                 .label          = "allow hosts",
1762                 .type           = P_LIST,
1763                 .p_class        = P_LOCAL,
1764                 .ptr            = &sDefault.szHostsallow,
1765                 .special        = NULL,
1766                 .enum_list      = NULL,
1767                 .flags          = FLAG_HIDE,
1768         },
1769         {
1770                 .label          = "hosts deny",
1771                 .type           = P_LIST,
1772                 .p_class        = P_LOCAL,
1773                 .ptr            = &sDefault.szHostsdeny,
1774                 .special        = NULL,
1775                 .enum_list      = NULL,
1776                 .flags          = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1777         },
1778         {
1779                 .label          = "deny hosts",
1780                 .type           = P_LIST,
1781                 .p_class        = P_LOCAL,
1782                 .ptr            = &sDefault.szHostsdeny,
1783                 .special        = NULL,
1784                 .enum_list      = NULL,
1785                 .flags          = FLAG_HIDE,
1786         },
1787         {
1788                 .label          = "preload modules",
1789                 .type           = P_LIST,
1790                 .p_class        = P_GLOBAL,
1791                 .ptr            = &Globals.szPreloadModules,
1792                 .special        = NULL,
1793                 .enum_list      = NULL,
1794                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
1795         },
1796         {
1797                 .label          = "dedicated keytab file",
1798                 .type           = P_STRING,
1799                 .p_class        = P_GLOBAL,
1800                 .ptr            = &Globals.szDedicatedKeytabFile,
1801                 .special        = NULL,
1802                 .enum_list      = NULL,
1803                 .flags          = FLAG_ADVANCED,
1804         },
1805         {
1806                 .label          = "kerberos method",
1807                 .type           = P_ENUM,
1808                 .p_class        = P_GLOBAL,
1809                 .ptr            = &Globals.iKerberosMethod,
1810                 .special        = NULL,
1811                 .enum_list      = enum_kerberos_method,
1812                 .flags          = FLAG_ADVANCED,
1813         },
1814         {
1815                 .label          = "map untrusted to domain",
1816                 .type           = P_BOOL,
1817                 .p_class        = P_GLOBAL,
1818                 .ptr            = &Globals.bMapUntrustedToDomain,
1819                 .special        = NULL,
1820                 .enum_list      = NULL,
1821                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
1822         },
1823
1824
1825         {N_("Logging Options"), P_SEP, P_SEPARATOR},
1826
1827         {
1828                 .label          = "log level",
1829                 .type           = P_STRING,
1830                 .p_class        = P_GLOBAL,
1831                 .ptr            = &Globals.szLogLevel,
1832                 .special        = handle_debug_list,
1833                 .enum_list      = NULL,
1834                 .flags          = FLAG_ADVANCED,
1835         },
1836         {
1837                 .label          = "debuglevel",
1838                 .type           = P_STRING,
1839                 .p_class        = P_GLOBAL,
1840                 .ptr            = &Globals.szLogLevel,
1841                 .special        = handle_debug_list,
1842                 .enum_list      = NULL,
1843                 .flags          = FLAG_HIDE,
1844         },
1845         {
1846                 .label          = "syslog",
1847                 .type           = P_INTEGER,
1848                 .p_class        = P_GLOBAL,
1849                 .ptr            = &Globals.syslog,
1850                 .special        = NULL,
1851                 .enum_list      = NULL,
1852                 .flags          = FLAG_ADVANCED,
1853         },
1854         {
1855                 .label          = "syslog only",
1856                 .type           = P_BOOL,
1857                 .p_class        = P_GLOBAL,
1858                 .ptr            = &Globals.bSyslogOnly,
1859                 .special        = NULL,
1860                 .enum_list      = NULL,
1861                 .flags          = FLAG_ADVANCED,
1862         },
1863         {
1864                 .label          = "log file",
1865                 .type           = P_STRING,
1866                 .p_class        = P_GLOBAL,
1867                 .ptr            = &Globals.szLogFile,
1868                 .special        = NULL,
1869                 .enum_list      = NULL,
1870                 .flags          = FLAG_ADVANCED,
1871         },
1872         {
1873                 .label          = "max log size",
1874                 .type           = P_INTEGER,
1875                 .p_class        = P_GLOBAL,
1876                 .ptr            = &Globals.max_log_size,
1877                 .special        = NULL,
1878                 .enum_list      = NULL,
1879                 .flags          = FLAG_ADVANCED,
1880         },
1881         {
1882                 .label          = "debug timestamp",
1883                 .type           = P_BOOL,
1884                 .p_class        = P_GLOBAL,
1885                 .ptr            = &Globals.bTimestampLogs,
1886                 .special        = NULL,
1887                 .enum_list      = NULL,
1888                 .flags          = FLAG_ADVANCED,
1889         },
1890         {
1891                 .label          = "timestamp logs",
1892                 .type           = P_BOOL,
1893                 .p_class        = P_GLOBAL,
1894                 .ptr            = &Globals.bTimestampLogs,
1895                 .special        = NULL,
1896                 .enum_list      = NULL,
1897                 .flags          = FLAG_ADVANCED,
1898         },
1899         {
1900                 .label          = "debug prefix timestamp",
1901                 .type           = P_BOOL,
1902                 .p_class        = P_GLOBAL,
1903                 .ptr            = &Globals.bDebugPrefixTimestamp,
1904                 .special        = NULL,
1905                 .enum_list      = NULL,
1906                 .flags          = FLAG_ADVANCED,
1907         },
1908         {
1909                 .label          = "debug hires timestamp",
1910                 .type           = P_BOOL,
1911                 .p_class        = P_GLOBAL,
1912                 .ptr            = &Globals.bDebugHiresTimestamp,
1913                 .special        = NULL,
1914                 .enum_list      = NULL,
1915                 .flags          = FLAG_ADVANCED,
1916         },
1917         {
1918                 .label          = "debug pid",
1919                 .type           = P_BOOL,
1920                 .p_class        = P_GLOBAL,
1921                 .ptr            = &Globals.bDebugPid,
1922                 .special        = NULL,
1923                 .enum_list      = NULL,
1924                 .flags          = FLAG_ADVANCED,
1925         },
1926         {
1927                 .label          = "debug uid",
1928                 .type           = P_BOOL,
1929                 .p_class        = P_GLOBAL,
1930                 .ptr            = &Globals.bDebugUid,
1931                 .special        = NULL,
1932                 .enum_list      = NULL,
1933                 .flags          = FLAG_ADVANCED,
1934         },
1935         {
1936                 .label          = "debug class",
1937                 .type           = P_BOOL,
1938                 .p_class        = P_GLOBAL,
1939                 .ptr            = &Globals.bDebugClass,
1940                 .special        = NULL,
1941                 .enum_list      = NULL,
1942                 .flags          = FLAG_ADVANCED,
1943         },
1944         {
1945                 .label          = "enable core files",
1946                 .type           = P_BOOL,
1947                 .p_class        = P_GLOBAL,
1948                 .ptr            = &Globals.bEnableCoreFiles,
1949                 .special        = NULL,
1950                 .enum_list      = NULL,
1951                 .flags          = FLAG_ADVANCED,
1952         },
1953
1954         {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1955
1956         {
1957                 .label          = "allocation roundup size",
1958                 .type           = P_INTEGER,
1959                 .p_class        = P_LOCAL,
1960                 .ptr            = &sDefault.iallocation_roundup_size,
1961                 .special        = NULL,
1962                 .enum_list      = NULL,
1963                 .flags          = FLAG_ADVANCED,
1964         },
1965         {
1966                 .label          = "aio read size",
1967                 .type           = P_INTEGER,
1968                 .p_class        = P_LOCAL,
1969                 .ptr            = &sDefault.iAioReadSize,
1970                 .special        = NULL,
1971                 .enum_list      = NULL,
1972                 .flags          = FLAG_ADVANCED,
1973         },
1974         {
1975                 .label          = "aio write size",
1976                 .type           = P_INTEGER,
1977                 .p_class        = P_LOCAL,
1978                 .ptr            = &sDefault.iAioWriteSize,
1979                 .special        = NULL,
1980                 .enum_list      = NULL,
1981                 .flags          = FLAG_ADVANCED,
1982         },
1983         {
1984                 .label          = "aio write behind",
1985                 .type           = P_STRING,
1986                 .p_class        = P_LOCAL,
1987                 .ptr            = &sDefault.szAioWriteBehind,
1988                 .special        = NULL,
1989                 .enum_list      = NULL,
1990                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1991         },
1992         {
1993                 .label          = "smb ports",
1994                 .type           = P_STRING,
1995                 .p_class        = P_GLOBAL,
1996                 .ptr            = &Globals.smb_ports,
1997                 .special        = NULL,
1998                 .enum_list      = NULL,
1999                 .flags          = FLAG_ADVANCED,
2000         },
2001         {
2002                 .label          = "large readwrite",
2003                 .type           = P_BOOL,
2004                 .p_class        = P_GLOBAL,
2005                 .ptr            = &Globals.bLargeReadwrite,
2006                 .special        = NULL,
2007                 .enum_list      = NULL,
2008                 .flags          = FLAG_ADVANCED,
2009         },
2010         {
2011                 .label          = "max protocol",
2012                 .type           = P_ENUM,
2013                 .p_class        = P_GLOBAL,
2014                 .ptr            = &Globals.maxprotocol,
2015                 .special        = NULL,
2016                 .enum_list      = enum_protocol,
2017                 .flags          = FLAG_ADVANCED,
2018         },
2019         {
2020                 .label          = "protocol",
2021                 .type           = P_ENUM,
2022                 .p_class        = P_GLOBAL,
2023                 .ptr            = &Globals.maxprotocol,
2024                 .special        = NULL,
2025                 .enum_list      = enum_protocol,
2026                 .flags          = FLAG_ADVANCED,
2027         },
2028         {
2029                 .label          = "min protocol",
2030                 .type           = P_ENUM,
2031                 .p_class        = P_GLOBAL,
2032                 .ptr            = &Globals.minprotocol,
2033                 .special        = NULL,
2034                 .enum_list      = enum_protocol,
2035                 .flags          = FLAG_ADVANCED,
2036         },
2037         {
2038                 .label          = "min receivefile size",
2039                 .type           = P_INTEGER,
2040                 .p_class        = P_GLOBAL,
2041                 .ptr            = &Globals.iminreceivefile,
2042                 .special        = NULL,
2043                 .enum_list      = NULL,
2044                 .flags          = FLAG_ADVANCED,
2045         },
2046         {
2047                 .label          = "read raw",
2048                 .type           = P_BOOL,
2049                 .p_class        = P_GLOBAL,
2050                 .ptr            = &Globals.bReadRaw,
2051                 .special        = NULL,
2052                 .enum_list      = NULL,
2053                 .flags          = FLAG_ADVANCED,
2054         },
2055         {
2056                 .label          = "write raw",
2057                 .type           = P_BOOL,
2058                 .p_class        = P_GLOBAL,
2059                 .ptr            = &Globals.bWriteRaw,
2060                 .special        = NULL,
2061                 .enum_list      = NULL,
2062                 .flags          = FLAG_ADVANCED,
2063         },
2064         {
2065                 .label          = "disable netbios",
2066                 .type           = P_BOOL,
2067                 .p_class        = P_GLOBAL,
2068                 .ptr            = &Globals.bDisableNetbios,
2069                 .special        = NULL,
2070                 .enum_list      = NULL,
2071                 .flags          = FLAG_ADVANCED,
2072         },
2073         {
2074                 .label          = "reset on zero vc",
2075                 .type           = P_BOOL,
2076                 .p_class        = P_GLOBAL,
2077                 .ptr            = &Globals.bResetOnZeroVC,
2078                 .special        = NULL,
2079                 .enum_list      = NULL,
2080                 .flags          = FLAG_ADVANCED,
2081         },
2082         {
2083                 .label          = "log writeable files on exit",
2084                 .type           = P_BOOL,
2085                 .p_class        = P_GLOBAL,
2086                 .ptr            = &Globals.bLogWriteableFilesOnExit,
2087                 .special        = NULL,
2088                 .enum_list      = NULL,
2089                 .flags          = FLAG_ADVANCED,
2090         },
2091         {
2092                 .label          = "acl compatibility",
2093                 .type           = P_ENUM,
2094                 .p_class        = P_GLOBAL,
2095                 .ptr            = &Globals.iAclCompat,
2096                 .special        = NULL,
2097                 .enum_list      = enum_acl_compat_vals,
2098                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2099         },
2100         {
2101                 .label          = "defer sharing violations",
2102                 .type           = P_BOOL,
2103                 .p_class        = P_GLOBAL,
2104                 .ptr            = &Globals.bDeferSharingViolations,
2105                 .special        = NULL,
2106                 .enum_list      = NULL,
2107                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
2108         },
2109         {
2110                 .label          = "ea support",
2111                 .type           = P_BOOL,
2112                 .p_class        = P_LOCAL,
2113                 .ptr            = &sDefault.bEASupport,
2114                 .special        = NULL,
2115                 .enum_list      = NULL,
2116                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2117         },
2118         {
2119                 .label          = "nt acl support",
2120                 .type           = P_BOOL,
2121                 .p_class        = P_LOCAL,
2122                 .ptr            = &sDefault.bNTAclSupport,
2123                 .special        = NULL,
2124                 .enum_list      = NULL,
2125                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2126         },
2127         {
2128                 .label          = "nt pipe support",
2129                 .type           = P_BOOL,
2130                 .p_class        = P_GLOBAL,
2131                 .ptr            = &Globals.bNTPipeSupport,
2132                 .special        = NULL,
2133                 .enum_list      = NULL,
2134                 .flags          = FLAG_ADVANCED,
2135         },
2136         {
2137                 .label          = "nt status support",
2138                 .type           = P_BOOL,
2139                 .p_class        = P_GLOBAL,
2140                 .ptr            = &Globals.bNTStatusSupport,
2141                 .special        = NULL,
2142                 .enum_list      = NULL,
2143                 .flags          = FLAG_ADVANCED,
2144         },
2145         {
2146                 .label          = "profile acls",
2147                 .type           = P_BOOL,
2148                 .p_class        = P_LOCAL,
2149                 .ptr            = &sDefault.bProfileAcls,
2150                 .special        = NULL,
2151                 .enum_list      = NULL,
2152                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
2153         },
2154         {
2155                 .label          = "announce version",
2156                 .type           = P_STRING,
2157                 .p_class        = P_GLOBAL,
2158                 .ptr            = &Globals.szAnnounceVersion,
2159                 .special        = NULL,
2160                 .enum_list      = NULL,
2161                 .flags          = FLAG_ADVANCED,
2162         },
2163         {
2164                 .label          = "announce as",
2165                 .type           = P_ENUM,
2166                 .p_class        = P_GLOBAL,
2167                 .ptr            = &Globals.announce_as,
2168                 .special        = NULL,
2169                 .enum_list      = enum_announce_as,
2170                 .flags          = FLAG_ADVANCED,
2171         },
2172         {
2173                 .label          = "map acl inherit",
2174                 .type           = P_BOOL,
2175                 .p_class        = P_LOCAL,
2176                 .ptr            = &sDefault.bMap_acl_inherit,
2177                 .special        = NULL,
2178                 .enum_list      = NULL,
2179                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2180         },
2181         {
2182                 .label          = "afs share",
2183                 .type           = P_BOOL,
2184                 .p_class        = P_LOCAL,
2185                 .ptr            = &sDefault.bAfs_Share,
2186                 .special        = NULL,
2187                 .enum_list      = NULL,
2188                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2189         },
2190         {
2191                 .label          = "max mux",
2192                 .type           = P_INTEGER,
2193                 .p_class        = P_GLOBAL,
2194                 .ptr            = &Globals.max_mux,
2195                 .special        = NULL,
2196                 .enum_list      = NULL,
2197                 .flags          = FLAG_ADVANCED,
2198         },
2199         {
2200                 .label          = "max xmit",
2201                 .type           = P_INTEGER,
2202                 .p_class        = P_GLOBAL,
2203                 .ptr            = &Globals.max_xmit,
2204                 .special        = NULL,
2205                 .enum_list      = NULL,
2206                 .flags          = FLAG_ADVANCED,
2207         },
2208         {
2209                 .label          = "name resolve order",
2210                 .type           = P_STRING,
2211                 .p_class        = P_GLOBAL,
2212                 .ptr            = &Globals.szNameResolveOrder,
2213                 .special        = NULL,
2214                 .enum_list      = NULL,
2215                 .flags          = FLAG_ADVANCED | FLAG_WIZARD,
2216         },
2217         {
2218                 .label          = "max ttl",
2219                 .type           = P_INTEGER,
2220                 .p_class        = P_GLOBAL,
2221                 .ptr            = &Globals.max_ttl,
2222                 .special        = NULL,
2223                 .enum_list      = NULL,
2224                 .flags          = FLAG_ADVANCED,
2225         },
2226         {
2227                 .label          = "max wins ttl",
2228                 .type           = P_INTEGER,
2229                 .p_class        = P_GLOBAL,
2230                 .ptr            = &Globals.max_wins_ttl,
2231                 .special        = NULL,
2232                 .enum_list      = NULL,
2233                 .flags          = FLAG_ADVANCED,
2234         },
2235         {
2236                 .label          = "min wins ttl",
2237                 .type           = P_INTEGER,
2238                 .p_class        = P_GLOBAL,
2239                 .ptr            = &Globals.min_wins_ttl,
2240                 .special        = NULL,
2241                 .enum_list      = NULL,
2242                 .flags          = FLAG_ADVANCED,
2243         },
2244         {
2245                 .label          = "time server",
2246                 .type           = P_BOOL,
2247                 .p_class        = P_GLOBAL,
2248                 .ptr            = &Globals.bTimeServer,
2249                 .special        = NULL,
2250                 .enum_list      = NULL,
2251                 .flags          = FLAG_ADVANCED,
2252         },
2253         {
2254                 .label          = "unix extensions",
2255                 .type           = P_BOOL,
2256                 .p_class        = P_GLOBAL,
2257                 .ptr            = &Globals.bUnixExtensions,
2258                 .special        = NULL,
2259                 .enum_list      = NULL,
2260                 .flags          = FLAG_ADVANCED,
2261         },
2262         {
2263                 .label          = "use spnego",
2264                 .type           = P_BOOL,
2265                 .p_class        = P_GLOBAL,
2266                 .ptr            = &Globals.bUseSpnego,
2267                 .special        = NULL,
2268                 .enum_list      = NULL,
2269                 .flags          = FLAG_ADVANCED,
2270         },
2271         {
2272                 .label          = "client signing",
2273                 .type           = P_ENUM,
2274                 .p_class        = P_GLOBAL,
2275                 .ptr            = &Globals.client_signing,
2276                 .special        = NULL,
2277                 .enum_list      = enum_smb_signing_vals,
2278                 .flags          = FLAG_ADVANCED,
2279         },
2280         {
2281                 .label          = "server signing",
2282                 .type           = P_ENUM,
2283                 .p_class        = P_GLOBAL,
2284                 .ptr            = &Globals.server_signing,
2285                 .special        = NULL,
2286                 .enum_list      = enum_smb_signing_vals,
2287                 .flags          = FLAG_ADVANCED,
2288         },
2289         {
2290                 .label          = "smb encrypt",
2291                 .type           = P_ENUM,
2292                 .p_class        = P_LOCAL,
2293                 .ptr            = &sDefault.ismb_encrypt,
2294                 .special        = NULL,
2295                 .enum_list      = enum_smb_signing_vals,
2296                 .flags          = FLAG_ADVANCED,
2297         },
2298         {
2299                 .label          = "client use spnego",
2300                 .type           = P_BOOL,
2301                 .p_class        = P_GLOBAL,
2302                 .ptr            = &Globals.bClientUseSpnego,
2303                 .special        = NULL,
2304                 .enum_list      = NULL,
2305                 .flags          = FLAG_ADVANCED,
2306         },
2307         {
2308                 .label          = "client ldap sasl wrapping",
2309                 .type           = P_ENUM,
2310                 .p_class        = P_GLOBAL,
2311                 .ptr            = &Globals.client_ldap_sasl_wrapping,
2312                 .special        = NULL,
2313                 .enum_list      = enum_ldap_sasl_wrapping,
2314                 .flags          = FLAG_ADVANCED,
2315         },
2316         {
2317                 .label          = "enable asu support",
2318                 .type           = P_BOOL,
2319                 .p_class        = P_GLOBAL,
2320                 .ptr            = &Globals.bASUSupport,
2321                 .special        = NULL,
2322                 .enum_list      = NULL,
2323                 .flags          = FLAG_ADVANCED,
2324         },
2325         {
2326                 .label          = "svcctl list",
2327                 .type           = P_LIST,
2328                 .p_class        = P_GLOBAL,
2329                 .ptr            = &Globals.szServicesList,
2330                 .special        = NULL,
2331                 .enum_list      = NULL,
2332                 .flags          = FLAG_ADVANCED,
2333         },
2334
2335         {N_("Tuning Options"), P_SEP, P_SEPARATOR},
2336
2337         {
2338                 .label          = "block size",
2339                 .type           = P_INTEGER,
2340                 .p_class        = P_LOCAL,
2341                 .ptr            = &sDefault.iBlock_size,
2342                 .special        = NULL,
2343                 .enum_list      = NULL,
2344                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2345         },
2346         {
2347                 .label          = "deadtime",
2348                 .type           = P_INTEGER,
2349                 .p_class        = P_GLOBAL,
2350                 .ptr            = &Globals.deadtime,
2351                 .special        = NULL,
2352                 .enum_list      = NULL,
2353                 .flags          = FLAG_ADVANCED,
2354         },
2355         {
2356                 .label          = "getwd cache",
2357                 .type           = P_BOOL,
2358                 .p_class        = P_GLOBAL,
2359                 .ptr            = &Globals.getwd_cache,
2360                 .special        = NULL,
2361                 .enum_list      = NULL,
2362                 .flags          = FLAG_ADVANCED,
2363         },
2364         {
2365                 .label          = "keepalive",
2366                 .type           = P_INTEGER,
2367                 .p_class        = P_GLOBAL,
2368                 .ptr            = &Globals.iKeepalive,
2369                 .special        = NULL,
2370                 .enum_list      = NULL,
2371                 .flags          = FLAG_ADVANCED,
2372         },
2373         {
2374                 .label          = "change notify",
2375                 .type           = P_BOOL,
2376                 .p_class        = P_LOCAL,
2377                 .ptr            = &sDefault.bChangeNotify,
2378                 .special        = NULL,
2379                 .enum_list      = NULL,
2380                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
2381         },
2382         {
2383                 .label          = "directory name cache size",
2384                 .type           = P_INTEGER,
2385                 .p_class        = P_LOCAL,
2386                 .ptr            = &sDefault.iDirectoryNameCacheSize,
2387                 .special        = NULL,
2388                 .enum_list      = NULL,
2389                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
2390         },
2391         {
2392                 .label          = "kernel change notify",
2393                 .type           = P_BOOL,
2394                 .p_class        = P_LOCAL,
2395                 .ptr            = &sDefault.bKernelChangeNotify,
2396                 .special        = NULL,
2397                 .enum_list      = NULL,
2398                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
2399         },
2400         {
2401                 .label          = "lpq cache time",
2402                 .type           = P_INTEGER,
2403                 .p_class        = P_GLOBAL,
2404                 .ptr            = &Globals.lpqcachetime,
2405                 .special        = NULL,
2406                 .enum_list      = NULL,
2407                 .flags          = FLAG_ADVANCED,
2408         },
2409         {
2410                 .label          = "max smbd processes",
2411                 .type           = P_INTEGER,
2412                 .p_class        = P_GLOBAL,
2413                 .ptr            = &Globals.iMaxSmbdProcesses,
2414                 .special        = NULL,
2415                 .enum_list      = NULL,
2416                 .flags          = FLAG_ADVANCED,
2417         },
2418         {
2419                 .label          = "max connections",
2420                 .type           = P_INTEGER,
2421                 .p_class        = P_LOCAL,
2422                 .ptr            = &sDefault.iMaxConnections,
2423                 .special        = NULL,
2424                 .enum_list      = NULL,
2425                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
2426         },
2427         {
2428                 .label          = "paranoid server security",
2429                 .type           = P_BOOL,
2430                 .p_class        = P_GLOBAL,
2431                 .ptr            = &Globals.paranoid_server_security,
2432                 .special        = NULL,
2433                 .enum_list      = NULL,
2434                 .flags          = FLAG_ADVANCED,
2435         },
2436         {
2437                 .label          = "max disk size",
2438                 .type           = P_INTEGER,
2439                 .p_class        = P_GLOBAL,
2440                 .ptr            = &Globals.maxdisksize,
2441                 .special        = NULL,
2442                 .enum_list      = NULL,
2443                 .flags          = FLAG_ADVANCED,
2444         },
2445         {
2446                 .label          = "max open files",
2447                 .type           = P_INTEGER,
2448                 .p_class        = P_GLOBAL,
2449                 .ptr            = &Globals.max_open_files,
2450                 .special        = NULL,
2451                 .enum_list      = NULL,
2452                 .flags          = FLAG_ADVANCED,
2453         },
2454         {
2455                 .label          = "min print space",
2456                 .type           = P_INTEGER,
2457                 .p_class        = P_LOCAL,
2458                 .ptr            = &sDefault.iMinPrintSpace,
2459                 .special        = NULL,
2460                 .enum_list      = NULL,
2461                 .flags          = FLAG_ADVANCED | FLAG_PRINT,
2462         },
2463         {
2464                 .label          = "socket options",
2465                 .type           = P_STRING,
2466                 .p_class        = P_GLOBAL,
2467                 .ptr            = &Globals.szSocketOptions,
2468                 .special        = NULL,
2469                 .enum_list      = NULL,
2470                 .flags          = FLAG_ADVANCED,
2471         },
2472         {
2473                 .label          = "strict allocate",
2474                 .type           = P_BOOL,
2475                 .p_class        = P_LOCAL,
2476                 .ptr            = &sDefault.bStrictAllocate,
2477                 .special        = NULL,
2478                 .enum_list      = NULL,
2479                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
2480         },
2481         {
2482                 .label          = "strict sync",
2483                 .type           = P_BOOL,
2484                 .p_class        = P_LOCAL,
2485                 .ptr            = &sDefault.bStrictSync,
2486                 .special        = NULL,
2487                 .enum_list      = NULL,
2488                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
2489         },
2490         {
2491                 .label          = "sync always",
2492                 .type           = P_BOOL,
2493                 .p_class        = P_LOCAL,
2494                 .ptr            = &sDefault.bSyncAlways,
2495                 .special        = NULL,
2496                 .enum_list      = NULL,
2497                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
2498         },
2499         {
2500                 .label          = "use mmap",
2501                 .type           = P_BOOL,
2502                 .p_class        = P_GLOBAL,
2503                 .ptr            = &Globals.bUseMmap,
2504                 .special        = NULL,
2505                 .enum_list      = NULL,
2506                 .flags          = FLAG_ADVANCED,
2507         },
2508         {
2509                 .label          = "use sendfile",
2510                 .type           = P_BOOL,
2511                 .p_class        = P_LOCAL,
2512                 .ptr            = &sDefault.bUseSendfile,
2513                 .special        = NULL,
2514                 .enum_list      = NULL,
2515                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
2516         },
2517         {
2518                 .label          = "hostname lookups",
2519                 .type           = P_BOOL,
2520                 .p_class        = P_GLOBAL,
2521                 .ptr            = &Globals.bHostnameLookups,
2522                 .special        = NULL,
2523                 .enum_list      = NULL,
2524                 .flags          = FLAG_ADVANCED,
2525         },
2526         {
2527                 .label          = "write cache size",
2528                 .type           = P_INTEGER,
2529                 .p_class        = P_LOCAL,
2530                 .ptr            = &sDefault.iWriteCacheSize,
2531                 .special        = NULL,
2532                 .enum_list      = NULL,
2533                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
2534         },
2535         {
2536                 .label          = "name cache timeout",
2537                 .type           = P_INTEGER,
2538                 .p_class        = P_GLOBAL,
2539                 .ptr            = &Globals.name_cache_timeout,
2540                 .special        = NULL,
2541                 .enum_list      = NULL,
2542                 .flags          = FLAG_ADVANCED,
2543         },
2544         {
2545                 .label          = "ctdbd socket",
2546                 .type           = P_STRING,
2547                 .p_class        = P_GLOBAL,
2548                 .ptr            = &Globals.ctdbdSocket,
2549                 .special        = NULL,
2550                 .enum_list      = NULL,
2551                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
2552         },
2553         {
2554                 .label          = "cluster addresses",
2555                 .type           = P_LIST,
2556                 .p_class        = P_GLOBAL,
2557                 .ptr            = &Globals.szClusterAddresses,
2558                 .special        = NULL,
2559                 .enum_list      = NULL,
2560                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
2561         },
2562         {
2563                 .label          = "clustering",
2564                 .type           = P_BOOL,
2565                 .p_class        = P_GLOBAL,
2566                 .ptr            = &Globals.clustering,
2567                 .special        = NULL,
2568                 .enum_list      = NULL,
2569                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
2570         },
2571         {
2572                 .label          = "ctdb timeout",
2573                 .type           = P_INTEGER,
2574                 .p_class        = P_GLOBAL,
2575                 .ptr            = &Globals.ctdb_timeout,
2576                 .special        = NULL,
2577                 .enum_list      = NULL,
2578                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
2579         },
2580         {
2581                 .label          = "ctdb locktime warn threshold",
2582                 .type           = P_INTEGER,
2583                 .p_class        = P_GLOBAL,
2584                 .ptr            = &Globals.ctdb_locktime_warn_threshold,
2585                 .special        = NULL,
2586                 .enum_list      = NULL,
2587                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
2588         },
2589         {
2590                 .label          = "smb2 max read",
2591                 .type           = P_INTEGER,
2592                 .p_class        = P_GLOBAL,
2593                 .ptr            = &Globals.ismb2_max_read,
2594                 .special        = NULL,
2595                 .enum_list      = NULL,
2596                 .flags          = FLAG_ADVANCED,
2597         },
2598         {
2599                 .label          = "smb2 max write",
2600                 .type           = P_INTEGER,
2601                 .p_class        = P_GLOBAL,
2602                 .ptr            = &Globals.ismb2_max_write,
2603                 .special        = NULL,
2604                 .enum_list      = NULL,
2605                 .flags          = FLAG_ADVANCED,
2606         },
2607         {
2608                 .label          = "smb2 max trans",
2609                 .type           = P_INTEGER,
2610                 .p_class        = P_GLOBAL,
2611                 .ptr            = &Globals.ismb2_max_trans,
2612                 .special        = NULL,
2613                 .enum_list      = NULL,
2614                 .flags          = FLAG_ADVANCED,
2615         },
2616
2617         {N_("Printing Options"), P_SEP, P_SEPARATOR},
2618
2619         {
2620                 .label          = "max reported print jobs",
2621                 .type           = P_INTEGER,
2622                 .p_class        = P_LOCAL,
2623                 .ptr            = &sDefault.iMaxReportedPrintJobs,
2624                 .special        = NULL,
2625                 .enum_list      = NULL,
2626                 .flags          = FLAG_ADVANCED | FLAG_PRINT,
2627         },
2628         {
2629                 .label          = "max print jobs",
2630                 .type           = P_INTEGER,
2631                 .p_class        = P_LOCAL,
2632                 .ptr            = &sDefault.iMaxPrintJobs,
2633                 .special        = NULL,
2634                 .enum_list      = NULL,
2635                 .flags          = FLAG_ADVANCED | FLAG_PRINT,
2636         },
2637         {
2638                 .label          = "load printers",
2639                 .type           = P_BOOL,
2640                 .p_class        = P_GLOBAL,
2641                 .ptr            = &Globals.bLoadPrinters,
2642                 .special        = NULL,
2643                 .enum_list      = NULL,
2644                 .flags          = FLAG_ADVANCED | FLAG_PRINT,
2645         },
2646         {
2647                 .label          = "printcap cache time",
2648                 .type           = P_INTEGER,
2649                 .p_class        = P_GLOBAL,
2650                 .ptr            = &Globals.PrintcapCacheTime,
2651                 .special        = NULL,
2652                 .enum_list      = NULL,
2653                 .flags          = FLAG_ADVANCED | FLAG_PRINT,
2654         },
2655         {
2656                 .label          = "printcap name",
2657                 .type           = P_STRING,
2658                 .p_class        = P_GLOBAL,
2659                 .ptr            = &Globals.szPrintcapname,
2660                 .special        = NULL,
2661                 .enum_list      = NULL,
2662                 .flags          = FLAG_ADVANCED | FLAG_PRINT,
2663         },
2664         {
2665                 .label          = "printcap",
2666                 .type           = P_STRING,
2667                 .p_class        = P_GLOBAL,
2668                 .ptr            = &Globals.szPrintcapname,
2669                 .special        = NULL,
2670                 .enum_list      = NULL,
2671                 .flags          = FLAG_HIDE,
2672         },
2673         {
2674                 .label          = "printable",
2675                 .type           = P_BOOL,
2676                 .p_class        = P_LOCAL,
2677                 .ptr            = &sDefault.bPrint_ok,
2678                 .special        = NULL,
2679                 .enum_list      = NULL,
2680                 .flags          = FLAG_ADVANCED | FLAG_PRINT,
2681         },
2682         {
2683                 .label          = "print ok",
2684                 .type           = P_BOOL,
2685                 .p_class        = P_LOCAL,
2686                 .ptr            = &sDefault.bPrint_ok,
2687                 .special        = NULL,
2688                 .enum_list      = NULL,
2689                 .flags          = FLAG_HIDE,
2690         },
2691         {
2692                 .label          = "printing",
2693                 .type           = P_ENUM,
2694                 .p_class        = P_LOCAL,
2695                 .ptr            = &sDefault.iPrinting,
2696                 .special        = handle_printing,
2697                 .enum_list      = enum_printing,
2698                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2699         },
2700         {
2701                 .label          = "cups options",
2702                 .type           = P_STRING,
2703                 .p_class        = P_LOCAL,
2704                 .ptr            = &sDefault.szCupsOptions,
2705                 .special        = NULL,
2706                 .enum_list      = NULL,
2707                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2708         },
2709         {
2710                 .label          = "cups server",
2711                 .type           = P_STRING,
2712                 .p_class        = P_GLOBAL,
2713                 .ptr            = &Globals.szCupsServer,
2714                 .special        = NULL,
2715                 .enum_list      = NULL,
2716                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2717         },
2718         {
2719                 .label          = "cups encrypt",
2720                 .type           = P_ENUM,
2721                 .p_class        = P_GLOBAL,
2722                 .ptr            = &Globals.CupsEncrypt,
2723                 .special        = NULL,
2724                 .enum_list      = enum_bool_auto,
2725                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2726         },
2727         {
2728
2729                 .label          = "cups connection timeout",
2730                 .type           = P_INTEGER,
2731                 .p_class        = P_GLOBAL,
2732                 .ptr            = &Globals.cups_connection_timeout,
2733                 .special        = NULL,
2734                 .enum_list      = NULL,
2735                 .flags          = FLAG_ADVANCED,
2736         },
2737         {
2738                 .label          = "iprint server",
2739                 .type           = P_STRING,
2740                 .p_class        = P_GLOBAL,
2741                 .ptr            = &Globals.szIPrintServer,
2742                 .special        = NULL,
2743                 .enum_list      = NULL,
2744                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2745         },
2746         {
2747                 .label          = "print command",
2748                 .type           = P_STRING,
2749                 .p_class        = P_LOCAL,
2750                 .ptr            = &sDefault.szPrintcommand,
2751                 .special        = NULL,
2752                 .enum_list      = NULL,
2753                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2754         },
2755         {
2756                 .label          = "disable spoolss",
2757                 .type           = P_BOOL,
2758                 .p_class        = P_GLOBAL,
2759                 .ptr            = &Globals.bDisableSpoolss,
2760                 .special        = NULL,
2761                 .enum_list      = NULL,
2762                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2763         },
2764         {
2765                 .label          = "enable spoolss",
2766                 .type           = P_BOOLREV,
2767                 .p_class        = P_GLOBAL,
2768                 .ptr            = &Globals.bDisableSpoolss,
2769                 .special        = NULL,
2770                 .enum_list      = NULL,
2771                 .flags          = FLAG_HIDE,
2772         },
2773         {
2774                 .label          = "lpq command",
2775                 .type           = P_STRING,
2776                 .p_class        = P_LOCAL,
2777                 .ptr            = &sDefault.szLpqcommand,
2778                 .special        = NULL,
2779                 .enum_list      = NULL,
2780                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2781         },
2782         {
2783                 .label          = "lprm command",
2784                 .type           = P_STRING,
2785                 .p_class        = P_LOCAL,
2786                 .ptr            = &sDefault.szLprmcommand,
2787                 .special        = NULL,
2788                 .enum_list      = NULL,
2789                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2790         },
2791         {
2792                 .label          = "lppause command",
2793                 .type           = P_STRING,
2794                 .p_class        = P_LOCAL,
2795                 .ptr            = &sDefault.szLppausecommand,
2796                 .special        = NULL,
2797                 .enum_list      = NULL,
2798                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2799         },
2800         {
2801                 .label          = "lpresume command",
2802                 .type           = P_STRING,
2803                 .p_class        = P_LOCAL,
2804                 .ptr            = &sDefault.szLpresumecommand,
2805                 .special        = NULL,
2806                 .enum_list      = NULL,
2807                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2808         },
2809         {
2810                 .label          = "queuepause command",
2811                 .type           = P_STRING,
2812                 .p_class        = P_LOCAL,
2813                 .ptr            = &sDefault.szQueuepausecommand,
2814                 .special        = NULL,
2815                 .enum_list      = NULL,
2816                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2817         },
2818         {
2819                 .label          = "queueresume command",
2820                 .type           = P_STRING,
2821                 .p_class        = P_LOCAL,
2822                 .ptr            = &sDefault.szQueueresumecommand,
2823                 .special        = NULL,
2824                 .enum_list      = NULL,
2825                 .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2826         },
2827         {
2828                 .label          = "addport command",
2829                 .type           = P_STRING,
2830                 .p_class        = P_GLOBAL,
2831                 .ptr            = &Globals.szAddPortCommand,
2832                 .special        = NULL,
2833                 .enum_list      = NULL,
2834                 .flags          = FLAG_ADVANCED,
2835         },
2836         {
2837                 .label          = "enumports command",
2838                 .type           = P_STRING,
2839                 .p_class        = P_GLOBAL,
2840                 .ptr            = &Globals.szEnumPortsCommand,
2841                 .special        = NULL,
2842                 .enum_list      = NULL,
2843                 .flags          = FLAG_ADVANCED,
2844         },
2845         {
2846                 .label          = "addprinter command",
2847                 .type           = P_STRING,
2848                 .p_class        = P_GLOBAL,
2849                 .ptr            = &Globals.szAddPrinterCommand,
2850                 .special        = NULL,
2851                 .enum_list      = NULL,
2852                 .flags          = FLAG_ADVANCED,
2853         },
2854         {
2855                 .label          = "deleteprinter command",
2856                 .type           = P_STRING,
2857                 .p_class        = P_GLOBAL,
2858                 .ptr            = &Globals.szDeletePrinterCommand,
2859                 .special        = NULL,
2860                 .enum_list      = NULL,
2861                 .flags          = FLAG_ADVANCED,
2862         },
2863         {
2864                 .label          = "show add printer wizard",
2865                 .type           = P_BOOL,
2866                 .p_class        = P_GLOBAL,
2867                 .ptr            = &Globals.bMsAddPrinterWizard,
2868                 .special        = NULL,
2869                 .enum_list      = NULL,
2870                 .flags          = FLAG_ADVANCED,
2871         },
2872         {
2873                 .label          = "os2 driver map",
2874                 .type           = P_STRING,
2875                 .p_class        = P_GLOBAL,
2876                 .ptr            = &Globals.szOs2DriverMap,
2877                 .special        = NULL,
2878                 .enum_list      = NULL,
2879                 .flags          = FLAG_ADVANCED,
2880         },
2881
2882         {
2883                 .label          = "printer name",
2884                 .type           = P_STRING,
2885                 .p_class        = P_LOCAL,
2886                 .ptr            = &sDefault.szPrintername,
2887                 .special        = NULL,
2888                 .enum_list      = NULL,
2889                 .flags          = FLAG_ADVANCED | FLAG_PRINT,
2890         },
2891         {
2892                 .label          = "printer",
2893                 .type           = P_STRING,
2894                 .p_class        = P_LOCAL,
2895                 .ptr            = &sDefault.szPrintername,
2896                 .special        = NULL,
2897                 .enum_list      = NULL,
2898                 .flags          = FLAG_HIDE,
2899         },
2900         {
2901                 .label          = "use client driver",
2902                 .type           = P_BOOL,
2903                 .p_class        = P_LOCAL,
2904                 .ptr            = &sDefault.bUseClientDriver,
2905                 .special        = NULL,
2906                 .enum_list      = NULL,
2907                 .flags          = FLAG_ADVANCED | FLAG_PRINT,
2908         },
2909         {
2910                 .label          = "default devmode",
2911                 .type           = P_BOOL,
2912                 .p_class        = P_LOCAL,
2913                 .ptr            = &sDefault.bDefaultDevmode,
2914                 .special        = NULL,
2915                 .enum_list      = NULL,
2916                 .flags          = FLAG_ADVANCED | FLAG_PRINT,
2917         },
2918         {
2919                 .label          = "force printername",
2920                 .type           = P_BOOL,
2921                 .p_class        = P_LOCAL,
2922                 .ptr            = &sDefault.bForcePrintername,
2923                 .special        = NULL,
2924                 .enum_list      = NULL,
2925                 .flags          = FLAG_ADVANCED | FLAG_PRINT,
2926         },
2927         {
2928                 .label          = "printjob username",
2929                 .type           = P_STRING,
2930                 .p_class        = P_LOCAL,
2931                 .ptr            = &sDefault.szPrintjobUsername,
2932                 .special        = NULL,
2933                 .enum_list      = NULL,
2934                 .flags          = FLAG_ADVANCED | FLAG_PRINT,
2935         },
2936
2937         {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2938
2939         {
2940                 .label          = "mangling method",
2941                 .type           = P_STRING,
2942                 .p_class        = P_GLOBAL,
2943                 .ptr            = &Globals.szManglingMethod,
2944                 .special        = NULL,
2945                 .enum_list      = NULL,
2946                 .flags          = FLAG_ADVANCED,
2947         },
2948         {
2949                 .label          = "mangle prefix",
2950                 .type           = P_INTEGER,
2951                 .p_class        = P_GLOBAL,
2952                 .ptr            = &Globals.mangle_prefix,
2953                 .special        = NULL,
2954                 .enum_list      = NULL,
2955                 .flags          = FLAG_ADVANCED,
2956         },
2957
2958         {
2959                 .label          = "default case",
2960                 .type           = P_ENUM,
2961                 .p_class        = P_LOCAL,
2962                 .ptr            = &sDefault.iDefaultCase,
2963                 .special        = NULL,
2964                 .enum_list      = enum_case,
2965                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
2966         },
2967         {
2968                 .label          = "case sensitive",
2969                 .type           = P_ENUM,
2970                 .p_class        = P_LOCAL,
2971                 .ptr            = &sDefault.iCaseSensitive,
2972                 .special        = NULL,
2973                 .enum_list      = enum_bool_auto,
2974                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2975         },
2976         {
2977                 .label          = "casesignames",
2978                 .type           = P_ENUM,
2979                 .p_class        = P_LOCAL,
2980                 .ptr            = &sDefault.iCaseSensitive,
2981                 .special        = NULL,
2982                 .enum_list      = enum_bool_auto,
2983                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2984         },
2985         {
2986                 .label          = "preserve case",
2987                 .type           = P_BOOL,
2988                 .p_class        = P_LOCAL,
2989                 .ptr            = &sDefault.bCasePreserve,
2990                 .special        = NULL,
2991                 .enum_list      = NULL,
2992                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2993         },
2994         {
2995                 .label          = "short preserve case",
2996                 .type           = P_BOOL,
2997                 .p_class        = P_LOCAL,
2998                 .ptr            = &sDefault.bShortCasePreserve,
2999                 .special        = NULL,
3000                 .enum_list      = NULL,
3001                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3002         },
3003         {
3004                 .label          = "mangling char",
3005                 .type           = P_CHAR,
3006                 .p_class        = P_LOCAL,
3007                 .ptr            = &sDefault.magic_char,
3008                 .special        = NULL,
3009                 .enum_list      = NULL,
3010                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3011         },
3012         {
3013                 .label          = "hide dot files",
3014                 .type           = P_BOOL,
3015                 .p_class        = P_LOCAL,
3016                 .ptr            = &sDefault.bHideDotFiles,
3017                 .special        = NULL,
3018                 .enum_list      = NULL,
3019                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3020         },
3021         {
3022                 .label          = "hide special files",
3023                 .type           = P_BOOL,
3024                 .p_class        = P_LOCAL,
3025                 .ptr            = &sDefault.bHideSpecialFiles,
3026                 .special        = NULL,
3027                 .enum_list      = NULL,
3028                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3029         },
3030         {
3031                 .label          = "hide unreadable",
3032                 .type           = P_BOOL,
3033                 .p_class        = P_LOCAL,
3034                 .ptr            = &sDefault.bHideUnReadable,
3035                 .special        = NULL,
3036                 .enum_list      = NULL,
3037                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3038         },
3039         {
3040                 .label          = "hide unwriteable files",
3041                 .type           = P_BOOL,
3042                 .p_class        = P_LOCAL,
3043                 .ptr            = &sDefault.bHideUnWriteableFiles,
3044                 .special        = NULL,
3045                 .enum_list      = NULL,
3046                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3047         },
3048         {
3049                 .label          = "delete veto files",
3050                 .type           = P_BOOL,
3051                 .p_class        = P_LOCAL,
3052                 .ptr            = &sDefault.bDeleteVetoFiles,
3053                 .special        = NULL,
3054                 .enum_list      = NULL,
3055                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3056         },
3057         {
3058                 .label          = "veto files",
3059                 .type           = P_STRING,
3060                 .p_class        = P_LOCAL,
3061                 .ptr            = &sDefault.szVetoFiles,
3062                 .special        = NULL,
3063                 .enum_list      = NULL,
3064                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3065         },
3066         {
3067                 .label          = "hide files",
3068                 .type           = P_STRING,
3069                 .p_class        = P_LOCAL,
3070                 .ptr            = &sDefault.szHideFiles,
3071                 .special        = NULL,
3072                 .enum_list      = NULL,
3073                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3074         },
3075         {
3076                 .label          = "veto oplock files",
3077                 .type           = P_STRING,
3078                 .p_class        = P_LOCAL,
3079                 .ptr            = &sDefault.szVetoOplockFiles,
3080                 .special        = NULL,
3081                 .enum_list      = NULL,
3082                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3083         },
3084         {
3085                 .label          = "map archive",
3086                 .type           = P_BOOL,
3087                 .p_class        = P_LOCAL,
3088                 .ptr            = &sDefault.bMap_archive,
3089                 .special        = NULL,
3090                 .enum_list      = NULL,
3091                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3092         },
3093         {
3094                 .label          = "map hidden",
3095                 .type           = P_BOOL,
3096                 .p_class        = P_LOCAL,
3097                 .ptr            = &sDefault.bMap_hidden,
3098                 .special        = NULL,
3099                 .enum_list      = NULL,
3100                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3101         },
3102         {
3103                 .label          = "map system",
3104                 .type           = P_BOOL,
3105                 .p_class        = P_LOCAL,
3106                 .ptr            = &sDefault.bMap_system,
3107                 .special        = NULL,
3108                 .enum_list      = NULL,
3109                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3110         },
3111         {
3112                 .label          = "map readonly",
3113                 .type           = P_ENUM,
3114                 .p_class        = P_LOCAL,
3115                 .ptr            = &sDefault.iMap_readonly,
3116                 .special        = NULL,
3117                 .enum_list      = enum_map_readonly,
3118                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3119         },
3120         {
3121                 .label          = "mangled names",
3122                 .type           = P_BOOL,
3123                 .p_class        = P_LOCAL,
3124                 .ptr            = &sDefault.bMangledNames,
3125                 .special        = NULL,
3126                 .enum_list      = NULL,
3127                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3128         },
3129         {
3130                 .label          = "max stat cache size",
3131                 .type           = P_INTEGER,
3132                 .p_class        = P_GLOBAL,
3133                 .ptr            = &Globals.iMaxStatCacheSize,
3134                 .special        = NULL,
3135                 .enum_list      = NULL,
3136                 .flags          = FLAG_ADVANCED,
3137         },
3138         {
3139                 .label          = "stat cache",
3140                 .type           = P_BOOL,
3141                 .p_class        = P_GLOBAL,
3142                 .ptr            = &Globals.bStatCache,
3143                 .special        = NULL,
3144                 .enum_list      = NULL,
3145                 .flags          = FLAG_ADVANCED,
3146         },
3147         {
3148                 .label          = "store dos attributes",
3149                 .type           = P_BOOL,
3150                 .p_class        = P_LOCAL,
3151                 .ptr            = &sDefault.bStoreDosAttributes,
3152                 .special        = NULL,
3153                 .enum_list      = NULL,
3154                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3155         },
3156         {
3157                 .label          = "dmapi support",
3158                 .type           = P_BOOL,
3159                 .p_class        = P_LOCAL,
3160                 .ptr            = &sDefault.bDmapiSupport,
3161                 .special        = NULL,
3162                 .enum_list      = NULL,
3163                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3164         },
3165
3166
3167         {N_("Domain Options"), P_SEP, P_SEPARATOR},
3168
3169         {
3170                 .label          = "machine password timeout",
3171                 .type           = P_INTEGER,
3172                 .p_class        = P_GLOBAL,
3173                 .ptr            = &Globals.machine_password_timeout,
3174                 .special        = NULL,
3175                 .enum_list      = NULL,
3176                 .flags          = FLAG_ADVANCED | FLAG_WIZARD,
3177         },
3178
3179         {N_("Logon Options"), P_SEP, P_SEPARATOR},
3180
3181         {
3182                 .label          = "add user script",
3183                 .type           = P_STRING,
3184                 .p_class        = P_GLOBAL,
3185                 .ptr            = &Globals.szAddUserScript,
3186                 .special        = NULL,
3187                 .enum_list      = NULL,
3188                 .flags          = FLAG_ADVANCED,
3189         },
3190         {
3191                 .label          = "rename user script",
3192                 .type           = P_STRING,
3193                 .p_class        = P_GLOBAL,
3194                 .ptr            = &Globals.szRenameUserScript,
3195                 .special        = NULL,
3196                 .enum_list      = NULL,
3197                 .flags          = FLAG_ADVANCED,
3198         },
3199         {
3200                 .label          = "delete user script",
3201                 .type           = P_STRING,
3202                 .p_class        = P_GLOBAL,
3203                 .ptr            = &Globals.szDelUserScript,
3204                 .special        = NULL,
3205                 .enum_list      = NULL,
3206                 .flags          = FLAG_ADVANCED,
3207         },
3208         {
3209                 .label          = "add group script",
3210                 .type           = P_STRING,
3211                 .p_class        = P_GLOBAL,
3212                 .ptr            = &Globals.szAddGroupScript,
3213                 .special        = NULL,
3214                 .enum_list      = NULL,
3215                 .flags          = FLAG_ADVANCED,
3216         },
3217         {
3218                 .label          = "delete group script",
3219                 .type           = P_STRING,
3220                 .p_class        = P_GLOBAL,
3221                 .ptr            = &Globals.szDelGroupScript,
3222                 .special        = NULL,
3223                 .enum_list      = NULL,
3224                 .flags          = FLAG_ADVANCED,
3225         },
3226         {
3227                 .label          = "add user to group script",
3228                 .type           = P_STRING,
3229                 .p_class        = P_GLOBAL,
3230                 .ptr            = &Globals.szAddUserToGroupScript,
3231                 .special        = NULL,
3232                 .enum_list      = NULL,
3233                 .flags          = FLAG_ADVANCED,
3234         },
3235         {
3236                 .label          = "delete user from group script",
3237                 .type           = P_STRING,
3238                 .p_class        = P_GLOBAL,
3239                 .ptr            = &Globals.szDelUserFromGroupScript,
3240                 .special        = NULL,
3241                 .enum_list      = NULL,
3242                 .flags          = FLAG_ADVANCED,
3243         },
3244         {
3245                 .label          = "set primary group script",
3246                 .type           = P_STRING,
3247                 .p_class        = P_GLOBAL,
3248                 .ptr            = &Globals.szSetPrimaryGroupScript,
3249                 .special        = NULL,
3250                 .enum_list      = NULL,
3251                 .flags          = FLAG_ADVANCED,
3252         },
3253         {
3254                 .label          = "add machine script",
3255                 .type           = P_STRING,
3256                 .p_class        = P_GLOBAL,
3257                 .ptr            = &Globals.szAddMachineScript,
3258                 .special        = NULL,
3259                 .enum_list      = NULL,
3260                 .flags          = FLAG_ADVANCED,
3261         },
3262         {
3263                 .label          = "shutdown script",
3264                 .type           = P_STRING,
3265                 .p_class        = P_GLOBAL,
3266                 .ptr            = &Globals.szShutdownScript,
3267                 .special        = NULL,
3268                 .enum_list      = NULL,
3269                 .flags          = FLAG_ADVANCED,
3270         },
3271         {
3272                 .label          = "abort shutdown script",
3273                 .type           = P_STRING,
3274                 .p_class        = P_GLOBAL,
3275                 .ptr            = &Globals.szAbortShutdownScript,
3276                 .special        = NULL,
3277                 .enum_list      = NULL,
3278                 .flags          = FLAG_ADVANCED,
3279         },
3280         {
3281                 .label          = "username map script",
3282                 .type           = P_STRING,
3283                 .p_class        = P_GLOBAL,
3284                 .ptr            = &Globals.szUsernameMapScript,
3285                 .special        = NULL,
3286                 .enum_list      = NULL,
3287                 .flags          = FLAG_ADVANCED,
3288         },
3289         {
3290                 .label          = "username map cache time",
3291                 .type           = P_INTEGER,
3292                 .p_class        = P_GLOBAL,
3293                 .ptr            = &Globals.iUsernameMapCacheTime,
3294                 .special        = NULL,
3295                 .enum_list      = NULL,
3296                 .flags          = FLAG_ADVANCED,
3297         },
3298         {
3299                 .label          = "logon script",
3300                 .type           = P_STRING,
3301                 .p_class        = P_GLOBAL,
3302                 .ptr            = &Globals.szLogonScript,
3303                 .special        = NULL,
3304                 .enum_list      = NULL,
3305                 .flags          = FLAG_ADVANCED,
3306         },
3307         {
3308                 .label          = "logon path",
3309                 .type           = P_STRING,
3310                 .p_class        = P_GLOBAL,
3311                 .ptr            = &Globals.szLogonPath,
3312                 .special        = NULL,
3313                 .enum_list      = NULL,
3314                 .flags          = FLAG_ADVANCED,
3315         },
3316         {
3317                 .label          = "logon drive",
3318                 .type           = P_STRING,
3319                 .p_class        = P_GLOBAL,
3320                 .ptr            = &Globals.szLogonDrive,
3321                 .special        = NULL,
3322                 .enum_list      = NULL,
3323                 .flags          = FLAG_ADVANCED,
3324         },
3325         {
3326                 .label          = "logon home",
3327                 .type           = P_STRING,
3328                 .p_class        = P_GLOBAL,
3329                 .ptr            = &Globals.szLogonHome,
3330                 .special        = NULL,
3331                 .enum_list      = NULL,
3332                 .flags          = FLAG_ADVANCED,
3333         },
3334         {
3335                 .label          = "domain logons",
3336                 .type           = P_BOOL,
3337                 .p_class        = P_GLOBAL,
3338                 .ptr            = &Globals.bDomainLogons,
3339                 .special        = NULL,
3340                 .enum_list      = NULL,
3341                 .flags          = FLAG_ADVANCED,
3342         },
3343
3344         {
3345                 .label          = "init logon delayed hosts",
3346                 .type           = P_LIST,
3347                 .p_class        = P_GLOBAL,
3348                 .ptr            = &Globals.szInitLogonDelayedHosts,
3349                 .special        = NULL,
3350                 .enum_list      = NULL,
3351                 .flags          = FLAG_ADVANCED,
3352         },
3353
3354         {
3355                 .label          = "init logon delay",
3356                 .type           = P_INTEGER,
3357                 .p_class        = P_GLOBAL,
3358                 .ptr            = &Globals.InitLogonDelay,
3359                 .special        = NULL,
3360                 .enum_list      = NULL,
3361                 .flags          = FLAG_ADVANCED,
3362
3363         },
3364
3365         {N_("Browse Options"), P_SEP, P_SEPARATOR},
3366
3367         {
3368                 .label          = "os level",
3369                 .type           = P_INTEGER,
3370                 .p_class        = P_GLOBAL,
3371                 .ptr            = &Globals.os_level,
3372                 .special        = NULL,
3373                 .enum_list      = NULL,
3374                 .flags          = FLAG_BASIC | FLAG_ADVANCED,
3375         },
3376         {
3377                 .label          = "lm announce",
3378                 .type           = P_ENUM,
3379                 .p_class        = P_GLOBAL,
3380                 .ptr            = &Globals.lm_announce,
3381                 .special        = NULL,
3382                 .enum_list      = enum_bool_auto,
3383                 .flags          = FLAG_ADVANCED,
3384         },
3385         {
3386                 .label          = "lm interval",
3387                 .type           = P_INTEGER,
3388                 .p_class        = P_GLOBAL,
3389                 .ptr            = &Globals.lm_interval,
3390                 .special        = NULL,
3391                 .enum_list      = NULL,
3392                 .flags          = FLAG_ADVANCED,
3393         },
3394         {
3395                 .label          = "preferred master",
3396                 .type           = P_ENUM,
3397                 .p_class        = P_GLOBAL,
3398                 .ptr            = &Globals.iPreferredMaster,
3399                 .special        = NULL,
3400                 .enum_list      = enum_bool_auto,
3401                 .flags          = FLAG_BASIC | FLAG_ADVANCED,
3402         },
3403         {
3404                 .label          = "prefered master",
3405                 .type           = P_ENUM,
3406                 .p_class        = P_GLOBAL,
3407                 .ptr            = &Globals.iPreferredMaster,
3408                 .special        = NULL,
3409                 .enum_list      = enum_bool_auto,
3410                 .flags          = FLAG_HIDE,
3411         },
3412         {
3413                 .label          = "local master",
3414                 .type           = P_BOOL,
3415                 .p_class        = P_GLOBAL,
3416                 .ptr            = &Globals.bLocalMaster,
3417                 .special        = NULL,
3418                 .enum_list      = NULL,
3419                 .flags          = FLAG_BASIC | FLAG_ADVANCED,
3420         },
3421         {
3422                 .label          = "domain master",
3423                 .type           = P_ENUM,
3424                 .p_class        = P_GLOBAL,
3425                 .ptr            = &Globals.iDomainMaster,
3426                 .special        = NULL,
3427                 .enum_list      = enum_bool_auto,
3428                 .flags          = FLAG_BASIC | FLAG_ADVANCED,
3429         },
3430         {
3431                 .label          = "browse list",
3432                 .type           = P_BOOL,
3433                 .p_class        = P_GLOBAL,
3434                 .ptr            = &Globals.bBrowseList,
3435                 .special        = NULL,
3436                 .enum_list      = NULL,
3437                 .flags          = FLAG_ADVANCED,
3438         },
3439         {
3440                 .label          = "browseable",
3441                 .type           = P_BOOL,
3442                 .p_class        = P_LOCAL,
3443                 .ptr            = &sDefault.bBrowseable,
3444                 .special        = NULL,
3445                 .enum_list      = NULL,
3446                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3447         },
3448         {
3449                 .label          = "browsable",
3450                 .type           = P_BOOL,
3451                 .p_class        = P_LOCAL,
3452                 .ptr            = &sDefault.bBrowseable,
3453                 .special        = NULL,
3454                 .enum_list      = NULL,
3455                 .flags          = FLAG_HIDE,
3456         },
3457         {
3458                 .label          = "access based share enum",
3459                 .type           = P_BOOL,
3460                 .p_class        = P_LOCAL,
3461                 .ptr            = &sDefault.bAccessBasedShareEnum,
3462                 .special        = NULL,
3463                 .enum_list      = NULL,
3464                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3465         },
3466         {
3467                 .label          = "enhanced browsing",
3468                 .type           = P_BOOL,
3469                 .p_class        = P_GLOBAL,
3470                 .ptr            = &Globals.enhanced_browsing,
3471                 .special        = NULL,
3472                 .enum_list      = NULL,
3473                 .flags          = FLAG_ADVANCED,
3474         },
3475
3476         {N_("WINS Options"), P_SEP, P_SEPARATOR},
3477
3478         {
3479                 .label          = "dns proxy",
3480                 .type           = P_BOOL,
3481                 .p_class        = P_GLOBAL,
3482                 .ptr            = &Globals.bDNSproxy,
3483                 .special        = NULL,
3484                 .enum_list      = NULL,
3485                 .flags          = FLAG_ADVANCED,
3486         },
3487         {
3488                 .label          = "wins proxy",
3489                 .type           = P_BOOL,
3490                 .p_class        = P_GLOBAL,
3491                 .ptr            = &Globals.bWINSproxy,
3492                 .special        = NULL,
3493                 .enum_list      = NULL,
3494                 .flags          = FLAG_ADVANCED,
3495         },
3496         {
3497                 .label          = "wins server",
3498                 .type           = P_LIST,
3499                 .p_class        = P_GLOBAL,
3500                 .ptr            = &Globals.szWINSservers,
3501                 .special        = NULL,
3502                 .enum_list      = NULL,
3503                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3504         },
3505         {
3506                 .label          = "wins support",
3507                 .type           = P_BOOL,
3508                 .p_class        = P_GLOBAL,
3509                 .ptr            = &Globals.bWINSsupport,
3510                 .special        = NULL,
3511                 .enum_list      = NULL,
3512                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3513         },
3514         {
3515                 .label          = "wins hook",
3516                 .type           = P_STRING,
3517                 .p_class        = P_GLOBAL,
3518                 .ptr            = &Globals.szWINSHook,
3519                 .special        = NULL,
3520                 .enum_list      = NULL,
3521                 .flags          = FLAG_ADVANCED,
3522         },
3523
3524         {N_("Locking Options"), P_SEP, P_SEPARATOR},
3525
3526         {
3527                 .label          = "blocking locks",
3528                 .type           = P_BOOL,
3529                 .p_class        = P_LOCAL,
3530                 .ptr            = &sDefault.bBlockingLocks,
3531                 .special        = NULL,
3532                 .enum_list      = NULL,
3533                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3534         },
3535         {
3536                 .label          = "csc policy",
3537                 .type           = P_ENUM,
3538                 .p_class        = P_LOCAL,
3539                 .ptr            = &sDefault.iCSCPolicy,
3540                 .special        = NULL,
3541                 .enum_list      = enum_csc_policy,
3542                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3543         },
3544         {
3545                 .label          = "fake oplocks",
3546                 .type           = P_BOOL,
3547                 .p_class        = P_LOCAL,
3548                 .ptr            = &sDefault.bFakeOplocks,
3549                 .special        = NULL,
3550                 .enum_list      = NULL,
3551                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
3552         },
3553         {
3554                 .label          = "kernel oplocks",
3555                 .type           = P_BOOL,
3556                 .p_class        = P_GLOBAL,
3557                 .ptr            = &Globals.bKernelOplocks,
3558                 .special        = NULL,
3559                 .enum_list      = NULL,
3560                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
3561         },
3562         {
3563                 .label          = "locking",
3564                 .type           = P_BOOL,
3565                 .p_class        = P_LOCAL,
3566                 .ptr            = &sDefault.bLocking,
3567                 .special        = NULL,
3568                 .enum_list      = NULL,
3569                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3570         },
3571         {
3572                 .label          = "lock spin time",
3573                 .type           = P_INTEGER,
3574                 .p_class        = P_GLOBAL,
3575                 .ptr            = &Globals.iLockSpinTime,
3576                 .special        = NULL,
3577                 .enum_list      = NULL,
3578                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
3579         },
3580         {
3581                 .label          = "oplocks",
3582                 .type           = P_BOOL,
3583                 .p_class        = P_LOCAL,
3584                 .ptr            = &sDefault.bOpLocks,
3585                 .special        = NULL,
3586                 .enum_list      = NULL,
3587                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3588         },
3589         {
3590                 .label          = "level2 oplocks",
3591                 .type           = P_BOOL,
3592                 .p_class        = P_LOCAL,
3593                 .ptr            = &sDefault.bLevel2OpLocks,
3594                 .special        = NULL,
3595                 .enum_list      = NULL,
3596                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3597         },
3598         {
3599                 .label          = "oplock break wait time",
3600                 .type           = P_INTEGER,
3601                 .p_class        = P_GLOBAL,
3602                 .ptr            = &Globals.oplock_break_wait_time,
3603                 .special        = NULL,
3604                 .enum_list      = NULL,
3605                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
3606         },
3607         {
3608                 .label          = "oplock contention limit",
3609                 .type           = P_INTEGER,
3610                 .p_class        = P_LOCAL,
3611                 .ptr            = &sDefault.iOplockContentionLimit,
3612                 .special        = NULL,
3613                 .enum_list      = NULL,
3614                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3615         },
3616         {
3617                 .label          = "posix locking",
3618                 .type           = P_BOOL,
3619                 .p_class        = P_LOCAL,
3620                 .ptr            = &sDefault.bPosixLocking,
3621                 .special        = NULL,
3622                 .enum_list      = NULL,
3623                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3624         },
3625         {
3626                 .label          = "strict locking",
3627                 .type           = P_ENUM,
3628                 .p_class        = P_LOCAL,
3629                 .ptr            = &sDefault.iStrictLocking,
3630                 .special        = NULL,
3631                 .enum_list      = enum_bool_auto,
3632                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3633         },
3634         {
3635                 .label          = "share modes",
3636                 .type           = P_BOOL,
3637                 .p_class        = P_LOCAL,
3638                 .ptr            = &sDefault.bShareModes,
3639                 .special        = NULL,
3640                 .enum_list      = NULL,
3641                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3642         },
3643
3644         {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3645
3646         {
3647                 .label          = "ldap admin dn",
3648                 .type           = P_STRING,
3649                 .p_class        = P_GLOBAL,
3650                 .ptr            = &Globals.szLdapAdminDn,
3651                 .special        = NULL,
3652                 .enum_list      = NULL,
3653                 .flags          = FLAG_ADVANCED,
3654         },
3655         {
3656                 .label          = "ldap delete dn",
3657                 .type           = P_BOOL,
3658                 .p_class        = P_GLOBAL,
3659                 .ptr            = &Globals.ldap_delete_dn,
3660                 .special        = NULL,
3661                 .enum_list      = NULL,
3662                 .flags          = FLAG_ADVANCED,
3663         },
3664         {
3665                 .label          = "ldap group suffix",
3666                 .type           = P_STRING,
3667                 .p_class        = P_GLOBAL,
3668                 .ptr            = &Globals.szLdapGroupSuffix,
3669                 .special        = NULL,
3670                 .enum_list      = NULL,
3671                 .flags          = FLAG_ADVANCED,
3672         },
3673         {
3674                 .label          = "ldap idmap suffix",
3675                 .type           = P_STRING,
3676                 .p_class        = P_GLOBAL,
3677                 .ptr            = &Globals.szLdapIdmapSuffix,
3678                 .special        = NULL,
3679                 .enum_list      = NULL,
3680                 .flags          = FLAG_ADVANCED,
3681         },
3682         {
3683                 .label          = "ldap machine suffix",
3684                 .type           = P_STRING,
3685                 .p_class        = P_GLOBAL,
3686                 .ptr            = &Globals.szLdapMachineSuffix,
3687                 .special        = NULL,
3688                 .enum_list      = NULL,
3689                 .flags          = FLAG_ADVANCED,
3690         },
3691         {
3692                 .label          = "ldap passwd sync",
3693                 .type           = P_ENUM,
3694                 .p_class        = P_GLOBAL,
3695                 .ptr            = &Globals.ldap_passwd_sync,
3696                 .special        = NULL,
3697                 .enum_list      = enum_ldap_passwd_sync,
3698                 .flags          = FLAG_ADVANCED,
3699         },
3700         {
3701                 .label          = "ldap password sync",
3702                 .type           = P_ENUM,
3703                 .p_class        = P_GLOBAL,
3704                 .ptr            = &Globals.ldap_passwd_sync,
3705                 .special        = NULL,
3706                 .enum_list      = enum_ldap_passwd_sync,
3707                 .flags          = FLAG_HIDE,
3708         },
3709         {
3710                 .label          = "ldap replication sleep",
3711                 .type           = P_INTEGER,
3712                 .p_class        = P_GLOBAL,
3713                 .ptr            = &Globals.ldap_replication_sleep,
3714                 .special        = NULL,
3715                 .enum_list      = NULL,
3716                 .flags          = FLAG_ADVANCED,
3717         },
3718         {
3719                 .label          = "ldap suffix",
3720                 .type           = P_STRING,
3721                 .p_class        = P_GLOBAL,
3722                 .ptr            = &Globals.szLdapSuffix,
3723                 .special        = NULL,
3724                 .enum_list      = NULL,
3725                 .flags          = FLAG_ADVANCED,
3726         },
3727         {
3728                 .label          = "ldap ssl",
3729                 .type           = P_ENUM,
3730                 .p_class        = P_GLOBAL,
3731                 .ptr            = &Globals.ldap_ssl,
3732                 .special        = NULL,
3733                 .enum_list      = enum_ldap_ssl,
3734                 .flags          = FLAG_ADVANCED,
3735         },
3736         {
3737                 .label          = "ldap ssl ads",
3738                 .type           = P_BOOL,
3739                 .p_class        = P_GLOBAL,
3740                 .ptr            = &Globals.ldap_ssl_ads,
3741                 .special        = NULL,
3742                 .enum_list      = NULL,
3743                 .flags          = FLAG_ADVANCED,
3744         },
3745         {
3746                 .label          = "ldap deref",
3747                 .type           = P_ENUM,
3748                 .p_class        = P_GLOBAL,
3749                 .ptr            = &Globals.ldap_deref,
3750                 .special        = NULL,
3751                 .enum_list      = enum_ldap_deref,
3752                 .flags          = FLAG_ADVANCED,
3753         },
3754         {
3755                 .label          = "ldap follow referral",
3756                 .type           = P_ENUM,
3757                 .p_class        = P_GLOBAL,
3758                 .ptr            = &Globals.ldap_follow_referral,
3759                 .special        = NULL,
3760                 .enum_list      = enum_bool_auto,
3761                 .flags          = FLAG_ADVANCED,
3762         },
3763         {
3764                 .label          = "ldap timeout",
3765                 .type           = P_INTEGER,
3766                 .p_class        = P_GLOBAL,
3767                 .ptr            = &Globals.ldap_timeout,
3768                 .special        = NULL,
3769                 .enum_list      = NULL,
3770                 .flags          = FLAG_ADVANCED,
3771         },
3772         {
3773                 .label          = "ldap connection timeout",
3774                 .type           = P_INTEGER,
3775                 .p_class        = P_GLOBAL,
3776                 .ptr            = &Globals.ldap_connection_timeout,
3777                 .special        = NULL,
3778                 .enum_list      = NULL,
3779                 .flags          = FLAG_ADVANCED,
3780         },
3781         {
3782                 .label          = "ldap page size",
3783                 .type           = P_INTEGER,
3784                 .p_class        = P_GLOBAL,
3785                 .ptr            = &Globals.ldap_page_size,
3786                 .special        = NULL,
3787                 .enum_list      = NULL,
3788                 .flags          = FLAG_ADVANCED,
3789         },
3790         {
3791                 .label          = "ldap user suffix",
3792                 .type           = P_STRING,
3793                 .p_class        = P_GLOBAL,
3794                 .ptr            = &Globals.szLdapUserSuffix,
3795                 .special        = NULL,
3796                 .enum_list      = NULL,
3797                 .flags          = FLAG_ADVANCED,
3798         },
3799         {
3800                 .label          = "ldap debug level",
3801                 .type           = P_INTEGER,
3802                 .p_class        = P_GLOBAL,
3803                 .ptr            = &Globals.ldap_debug_level,
3804                 .special        = handle_ldap_debug_level,
3805                 .enum_list      = NULL,
3806                 .flags          = FLAG_ADVANCED,
3807         },
3808         {
3809                 .label          = "ldap debug threshold",
3810                 .type           = P_INTEGER,
3811                 .p_class        = P_GLOBAL,
3812                 .ptr            = &Globals.ldap_debug_threshold,
3813                 .special        = NULL,
3814                 .enum_list      = NULL,
3815                 .flags          = FLAG_ADVANCED,
3816         },
3817
3818         {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3819
3820         {
3821                 .label          = "eventlog list",
3822                 .type           = P_LIST,
3823                 .p_class        = P_GLOBAL,
3824                 .ptr            = &Globals.szEventLogs,
3825                 .special        = NULL,
3826                 .enum_list      = NULL,
3827                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3828         },
3829
3830         {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3831
3832         {
3833                 .label          = "add share command",
3834                 .type           = P_STRING,
3835                 .p_class        = P_GLOBAL,
3836                 .ptr            = &Globals.szAddShareCommand,
3837                 .special        = NULL,
3838                 .enum_list      = NULL,
3839                 .flags          = FLAG_ADVANCED,
3840         },
3841         {
3842                 .label          = "change share command",
3843                 .type           = P_STRING,
3844                 .p_class        = P_GLOBAL,
3845                 .ptr            = &Globals.szChangeShareCommand,
3846                 .special        = NULL,
3847                 .enum_list      = NULL,
3848                 .flags          = FLAG_ADVANCED,
3849         },
3850         {
3851                 .label          = "delete share command",
3852                 .type           = P_STRING,
3853                 .p_class        = P_GLOBAL,
3854                 .ptr            = &Globals.szDeleteShareCommand,
3855                 .special        = NULL,
3856                 .enum_list      = NULL,
3857                 .flags          = FLAG_ADVANCED,
3858         },
3859         {
3860                 .label          = "config file",
3861                 .type           = P_STRING,
3862                 .p_class        = P_GLOBAL,
3863                 .ptr            = &Globals.szConfigFile,
3864                 .special        = NULL,
3865                 .enum_list      = NULL,
3866                 .flags          = FLAG_HIDE|FLAG_META,
3867         },
3868         {
3869                 .label          = "preload",
3870                 .type           = P_STRING,
3871                 .p_class        = P_GLOBAL,
3872                 .ptr            = &Globals.szAutoServices,
3873                 .special        = NULL,
3874                 .enum_list      = NULL,
3875                 .flags          = FLAG_ADVANCED,
3876         },
3877         {
3878                 .label          = "auto services",
3879                 .type           = P_STRING,
3880                 .p_class        = P_GLOBAL,
3881                 .ptr            = &Globals.szAutoServices,
3882                 .special        = NULL,
3883                 .enum_list      = NULL,
3884                 .flags          = FLAG_ADVANCED,
3885         },
3886         {
3887                 .label          = "lock directory",
3888                 .type           = P_STRING,
3889                 .p_class        = P_GLOBAL,
3890                 .ptr            = &Globals.szLockDir,
3891                 .special        = NULL,
3892                 .enum_list      = NULL,
3893                 .flags          = FLAG_ADVANCED,
3894         },
3895         {
3896                 .label          = "lock dir",
3897                 .type           = P_STRING,
3898                 .p_class        = P_GLOBAL,
3899                 .ptr            = &Globals.szLockDir,
3900                 .special        = NULL,
3901                 .enum_list      = NULL,
3902                 .flags          = FLAG_HIDE,
3903         },
3904         {
3905                 .label          = "state directory",
3906                 .type           = P_STRING,
3907                 .p_class        = P_GLOBAL,
3908                 .ptr            = &Globals.szStateDir,
3909                 .special        = NULL,
3910                 .enum_list      = NULL,
3911                 .flags          = FLAG_ADVANCED,
3912         },
3913         {
3914                 .label          = "cache directory",
3915                 .type           = P_STRING,
3916                 .p_class        = P_GLOBAL,
3917                 .ptr            = &Globals.szCacheDir,
3918                 .special        = NULL,
3919                 .enum_list      = NULL,
3920                 .flags          = FLAG_ADVANCED,
3921         },
3922         {
3923                 .label          = "pid directory",
3924                 .type           = P_STRING,
3925                 .p_class        = P_GLOBAL,
3926                 .ptr            = &Globals.szPidDir,
3927                 .special        = NULL,
3928                 .enum_list      = NULL,
3929                 .flags          = FLAG_ADVANCED,
3930         },
3931 #ifdef WITH_UTMP
3932         {
3933                 .label          = "utmp directory",
3934                 .type           = P_STRING,
3935                 .p_class        = P_GLOBAL,
3936                 .ptr            = &Globals.szUtmpDir,
3937                 .special        = NULL,
3938                 .enum_list      = NULL,
3939                 .flags          = FLAG_ADVANCED,
3940         },
3941         {
3942                 .label          = "wtmp directory",
3943                 .type           = P_STRING,
3944                 .p_class        = P_GLOBAL,
3945                 .ptr            = &Globals.szWtmpDir,
3946                 .special        = NULL,
3947                 .enum_list      = NULL,
3948                 .flags          = FLAG_ADVANCED,
3949         },
3950         {
3951                 .label          = "utmp",
3952                 .type           = P_BOOL,
3953                 .p_class        = P_GLOBAL,
3954                 .ptr            = &Globals.bUtmp,
3955                 .special        = NULL,
3956                 .enum_list      = NULL,
3957                 .flags          = FLAG_ADVANCED,
3958         },
3959 #endif
3960         {
3961                 .label          = "default service",
3962                 .type           = P_STRING,
3963                 .p_class        = P_GLOBAL,
3964                 .ptr            = &Globals.szDefaultService,
3965                 .special        = NULL,
3966                 .enum_list      = NULL,
3967                 .flags          = FLAG_ADVANCED,
3968         },
3969         {
3970                 .label          = "default",
3971                 .type           = P_STRING,
3972                 .p_class        = P_GLOBAL,
3973                 .ptr            = &Globals.szDefaultService,
3974                 .special        = NULL,
3975                 .enum_list      = NULL,
3976                 .flags          = FLAG_ADVANCED,
3977         },
3978         {
3979                 .label          = "message command",
3980                 .type           = P_STRING,
3981                 .p_class        = P_GLOBAL,
3982                 .ptr            = &Globals.szMsgCommand,
3983                 .special        = NULL,
3984                 .enum_list      = NULL,
3985                 .flags          = FLAG_ADVANCED,
3986         },
3987         {
3988                 .label          = "dfree cache time",
3989                 .type           = P_INTEGER,
3990                 .p_class        = P_LOCAL,
3991                 .ptr            = &sDefault.iDfreeCacheTime,
3992                 .special        = NULL,
3993                 .enum_list      = NULL,
3994                 .flags          = FLAG_ADVANCED,
3995         },
3996         {
3997                 .label          = "dfree command",
3998                 .type           = P_STRING,
3999                 .p_class        = P_LOCAL,
4000                 .ptr            = &sDefault.szDfree,
4001                 .special        = NULL,
4002                 .enum_list      = NULL,
4003                 .flags          = FLAG_ADVANCED,
4004         },
4005         {
4006                 .label          = "get quota command",
4007                 .type           = P_STRING,
4008                 .p_class        = P_GLOBAL,
4009                 .ptr            = &Globals.szGetQuota,
4010                 .special        = NULL,
4011                 .enum_list      = NULL,
4012                 .flags          = FLAG_ADVANCED,
4013         },
4014         {
4015                 .label          = "set quota command",
4016                 .type           = P_STRING,
4017                 .p_class        = P_GLOBAL,
4018                 .ptr            = &Globals.szSetQuota,
4019                 .special        = NULL,
4020                 .enum_list      = NULL,
4021                 .flags          = FLAG_ADVANCED,
4022         },
4023         {
4024                 .label          = "remote announce",
4025                 .type           = P_STRING,
4026                 .p_class        = P_GLOBAL,
4027                 .ptr            = &Globals.szRemoteAnnounce,
4028                 .special        = NULL,
4029                 .enum_list      = NULL,
4030                 .flags          = FLAG_ADVANCED,
4031         },
4032         {
4033                 .label          = "remote browse sync",
4034                 .type           = P_STRING,
4035                 .p_class        = P_GLOBAL,
4036                 .ptr            = &Globals.szRemoteBrowseSync,
4037                 .special        = NULL,
4038                 .enum_list      = NULL,
4039                 .flags          = FLAG_ADVANCED,
4040         },
4041         {
4042                 .label          = "socket address",
4043                 .type           = P_STRING,
4044                 .p_class        = P_GLOBAL,
4045                 .ptr            = &Globals.szSocketAddress,
4046                 .special        = NULL,
4047                 .enum_list      = NULL,
4048                 .flags          = FLAG_ADVANCED,
4049         },
4050         {
4051                 .label          = "nmbd bind explicit broadcast",
4052                 .type           = P_BOOL,
4053                 .p_class        = P_GLOBAL,
4054                 .ptr            = &Globals.bNmbdBindExplicitBroadcast,
4055                 .special        = NULL,
4056                 .enum_list      = NULL,
4057                 .flags          = FLAG_ADVANCED,
4058         },
4059         {
4060                 .label          = "homedir map",
4061                 .type           = P_STRING,
4062                 .p_class        = P_GLOBAL,
4063                 .ptr            = &Globals.szNISHomeMapName,
4064                 .special        = NULL,
4065                 .enum_list      = NULL,
4066                 .flags          = FLAG_ADVANCED,
4067         },
4068         {
4069                 .label          = "afs username map",
4070                 .type           = P_STRING,
4071                 .p_class        = P_GLOBAL,
4072                 .ptr            = &Globals.szAfsUsernameMap,
4073                 .special        = NULL,
4074                 .enum_list      = NULL,
4075                 .flags          = FLAG_ADVANCED,
4076         },
4077         {
4078                 .label          = "afs token lifetime",
4079                 .type           = P_INTEGER,
4080                 .p_class        = P_GLOBAL,
4081                 .ptr            = &Globals.iAfsTokenLifetime,
4082                 .special        = NULL,
4083                 .enum_list      = NULL,
4084                 .flags          = FLAG_ADVANCED,
4085         },
4086         {
4087                 .label          = "log nt token command",
4088                 .type           = P_STRING,
4089                 .p_class        = P_GLOBAL,
4090                 .ptr            = &Globals.szLogNtTokenCommand,
4091                 .special        = NULL,
4092                 .enum_list      = NULL,
4093                 .flags          = FLAG_ADVANCED,
4094         },
4095         {
4096                 .label          = "time offset",
4097                 .type           = P_INTEGER,
4098                 .p_class        = P_GLOBAL,
4099                 .ptr            = &extra_time_offset,
4100                 .special        = NULL,
4101                 .enum_list      = NULL,
4102                 .flags          = FLAG_ADVANCED,
4103         },
4104         {
4105                 .label          = "NIS homedir",
4106                 .type           = P_BOOL,
4107                 .p_class        = P_GLOBAL,
4108                 .ptr            = &Globals.bNISHomeMap,
4109                 .special        = NULL,
4110                 .enum_list      = NULL,
4111                 .flags          = FLAG_ADVANCED,
4112         },
4113         {
4114                 .label          = "-valid",
4115                 .type           = P_BOOL,
4116                 .p_class        = P_LOCAL,
4117                 .ptr            = &sDefault.valid,
4118                 .special        = NULL,
4119                 .enum_list      = NULL,
4120                 .flags          = FLAG_HIDE,
4121         },
4122         {
4123                 .label          = "copy",
4124                 .type           = P_STRING,
4125                 .p_class        = P_LOCAL,
4126                 .ptr            = &sDefault.szCopy,
4127                 .special        = handle_copy,
4128                 .enum_list      = NULL,
4129                 .flags          = FLAG_HIDE,
4130         },
4131         {
4132                 .label          = "include",
4133                 .type           = P_STRING,
4134                 .p_class        = P_LOCAL,
4135                 .ptr            = &sDefault.szInclude,
4136                 .special        = handle_include,
4137                 .enum_list      = NULL,
4138                 .flags          = FLAG_HIDE|FLAG_META,
4139         },
4140         {
4141                 .label          = "preexec",
4142                 .type           = P_STRING,
4143                 .p_class        = P_LOCAL,
4144                 .ptr            = &sDefault.szPreExec,
4145                 .special        = NULL,
4146                 .enum_list      = NULL,
4147                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4148         },
4149         {
4150                 .label          = "exec",
4151                 .type           = P_STRING,
4152                 .p_class        = P_LOCAL,
4153                 .ptr            = &sDefault.szPreExec,
4154                 .special        = NULL,
4155                 .enum_list      = NULL,
4156                 .flags          = FLAG_ADVANCED,
4157         },
4158         {
4159                 .label          = "preexec close",
4160                 .type           = P_BOOL,
4161                 .p_class        = P_LOCAL,
4162                 .ptr            = &sDefault.bPreexecClose,
4163                 .special        = NULL,
4164                 .enum_list      = NULL,
4165                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
4166         },
4167         {
4168                 .label          = "postexec",
4169                 .type           = P_STRING,
4170                 .p_class        = P_LOCAL,
4171                 .ptr            = &sDefault.szPostExec,
4172                 .special        = NULL,
4173                 .enum_list      = NULL,
4174                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4175         },
4176         {
4177                 .label          = "root preexec",
4178                 .type           = P_STRING,
4179                 .p_class        = P_LOCAL,
4180                 .ptr            = &sDefault.szRootPreExec,
4181                 .special        = NULL,
4182                 .enum_list      = NULL,
4183                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4184         },
4185         {
4186                 .label          = "root preexec close",
4187                 .type           = P_BOOL,
4188                 .p_class        = P_LOCAL,
4189                 .ptr            = &sDefault.bRootpreexecClose,
4190                 .special        = NULL,
4191                 .enum_list      = NULL,
4192                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
4193         },
4194         {
4195                 .label          = "root postexec",
4196                 .type           = P_STRING,
4197                 .p_class        = P_LOCAL,
4198                 .ptr            = &sDefault.szRootPostExec,
4199                 .special        = NULL,
4200                 .enum_list      = NULL,
4201                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4202         },
4203         {
4204                 .label          = "available",
4205                 .type           = P_BOOL,
4206                 .p_class        = P_LOCAL,
4207                 .ptr            = &sDefault.bAvailable,
4208                 .special        = NULL,
4209                 .enum_list      = NULL,
4210                 .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4211         },
4212         {
4213                 .label          = "registry shares",
4214                 .type           = P_BOOL,
4215                 .p_class        = P_GLOBAL,
4216                 .ptr            = &Globals.bRegistryShares,
4217                 .special        = NULL,
4218                 .enum_list      = NULL,
4219                 .flags          = FLAG_ADVANCED,
4220         },
4221         {
4222                 .label          = "usershare allow guests",
4223                 .type           = P_BOOL,
4224                 .p_class        = P_GLOBAL,
4225                 .ptr            = &Globals.bUsershareAllowGuests,
4226                 .special        = NULL,
4227                 .enum_list      = NULL,
4228                 .flags          = FLAG_ADVANCED,
4229         },
4230         {
4231                 .label          = "usershare max shares",
4232                 .type           = P_INTEGER,
4233                 .p_class        = P_GLOBAL,
4234                 .ptr            = &Globals.iUsershareMaxShares,
4235                 .special        = NULL,
4236                 .enum_list      = NULL,
4237                 .flags          = FLAG_ADVANCED,
4238         },
4239         {
4240                 .label          = "usershare owner only",
4241                 .type           = P_BOOL,
4242                 .p_class        = P_GLOBAL,
4243                 .ptr            = &Globals.bUsershareOwnerOnly,
4244                 .special        = NULL,
4245                 .enum_list      = NULL,
4246                 .flags          = FLAG_ADVANCED,
4247         },
4248         {
4249                 .label          = "usershare path",
4250                 .type           = P_STRING,
4251                 .p_class        = P_GLOBAL,
4252                 .ptr            = &Globals.szUsersharePath,
4253                 .special        = NULL,
4254                 .enum_list      = NULL,
4255                 .flags          = FLAG_ADVANCED,
4256         },
4257         {
4258                 .label          = "usershare prefix allow list",
4259                 .type           = P_LIST,
4260                 .p_class        = P_GLOBAL,
4261                 .ptr            = &Globals.szUsersharePrefixAllowList,
4262                 .special        = NULL,
4263                 .enum_list      = NULL,
4264                 .flags          = FLAG_ADVANCED,
4265         },
4266         {
4267                 .label          = "usershare prefix deny list",
4268                 .type           = P_LIST,
4269                 .p_class        = P_GLOBAL,
4270                 .ptr            = &Globals.szUsersharePrefixDenyList,
4271                 .special        = NULL,
4272                 .enum_list      = NULL,
4273                 .flags          = FLAG_ADVANCED,
4274         },
4275         {
4276                 .label          = "usershare template share",
4277                 .type           = P_STRING,
4278                 .p_class        = P_GLOBAL,
4279                 .ptr            = &Globals.szUsershareTemplateShare,
4280                 .special        = NULL,
4281                 .enum_list      = NULL,
4282                 .flags          = FLAG_ADVANCED,
4283         },
4284         {
4285                 .label          = "volume",
4286                 .type           = P_STRING,
4287                 .p_class        = P_LOCAL,
4288                 .ptr            = &sDefault.volume,
4289                 .special        = NULL,
4290                 .enum_list      = NULL,
4291                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
4292         },
4293         {
4294                 .label          = "fstype",
4295                 .type           = P_STRING,
4296                 .p_class        = P_LOCAL,
4297                 .ptr            = &sDefault.fstype,
4298                 .special        = NULL,
4299                 .enum_list      = NULL,
4300                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
4301         },
4302         {
4303                 .label          = "set directory",
4304                 .type           = P_BOOLREV,
4305                 .p_class        = P_LOCAL,
4306                 .ptr            = &sDefault.bNo_set_dir,
4307                 .special        = NULL,
4308                 .enum_list      = NULL,
4309                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
4310         },
4311         {
4312                 .label          = "wide links",
4313                 .type           = P_BOOL,
4314                 .p_class        = P_LOCAL,
4315                 .ptr            = &sDefault.bWidelinks,
4316                 .special        = NULL,
4317                 .enum_list      = NULL,
4318                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4319         },
4320         {
4321                 .label          = "follow symlinks",
4322                 .type           = P_BOOL,
4323                 .p_class        = P_LOCAL,
4324                 .ptr            = &sDefault.bSymlinks,
4325                 .special        = NULL,
4326                 .enum_list      = NULL,
4327                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4328         },
4329         {
4330                 .label          = "dont descend",
4331                 .type           = P_STRING,
4332                 .p_class        = P_LOCAL,
4333                 .ptr            = &sDefault.szDontdescend,
4334                 .special        = NULL,
4335                 .enum_list      = NULL,
4336                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
4337         },
4338         {
4339                 .label          = "magic script",
4340                 .type           = P_STRING,
4341                 .p_class        = P_LOCAL,
4342                 .ptr            = &sDefault.szMagicScript,
4343                 .special        = NULL,
4344                 .enum_list      = NULL,
4345                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
4346         },
4347         {
4348                 .label          = "magic output",
4349                 .type           = P_STRING,
4350                 .p_class        = P_LOCAL,
4351                 .ptr            = &sDefault.szMagicOutput,
4352                 .special        = NULL,
4353                 .enum_list      = NULL,
4354                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
4355         },
4356         {
4357                 .label          = "delete readonly",
4358                 .type           = P_BOOL,
4359                 .p_class        = P_LOCAL,
4360                 .ptr            = &sDefault.bDeleteReadonly,
4361                 .special        = NULL,
4362                 .enum_list      = NULL,
4363                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4364         },
4365         {
4366                 .label          = "dos filemode",
4367                 .type           = P_BOOL,
4368                 .p_class        = P_LOCAL,
4369                 .ptr            = &sDefault.bDosFilemode,
4370                 .special        = NULL,
4371                 .enum_list      = NULL,
4372                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4373         },
4374         {
4375                 .label          = "dos filetimes",
4376                 .type           = P_BOOL,
4377                 .p_class        = P_LOCAL,
4378                 .ptr            = &sDefault.bDosFiletimes,
4379                 .special        = NULL,
4380                 .enum_list      = NULL,
4381                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4382         },
4383         {
4384                 .label          = "dos filetime resolution",
4385                 .type           = P_BOOL,
4386                 .p_class        = P_LOCAL,
4387                 .ptr            = &sDefault.bDosFiletimeResolution,
4388                 .special        = NULL,
4389                 .enum_list      = NULL,
4390                 .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4391         },
4392         {
4393                 .label          = "fake directory create times",
4394                 .type           = P_BOOL,
4395                 .p_class        = P_LOCAL,
4396                 .ptr            = &sDefault.bFakeDirCreateTimes,
4397                 .special        = NULL,
4398                 .enum_list      = NULL,
4399                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
4400         },
4401         {
4402                 .label          = "async smb echo handler",
4403                 .type           = P_BOOL,
4404                 .p_class        = P_GLOBAL,
4405                 .ptr            = &Globals.bAsyncSMBEchoHandler,
4406                 .special        = NULL,
4407                 .enum_list      = NULL,
4408                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
4409         },
4410         {
4411                 .label          = "panic action",
4412                 .type           = P_STRING,
4413                 .p_class        = P_GLOBAL,
4414                 .ptr            = &Globals.szPanicAction,
4415                 .special        = NULL,
4416                 .enum_list      = NULL,
4417                 .flags          = FLAG_ADVANCED,
4418         },
4419         {
4420                 .label          = "perfcount module",
4421                 .type           = P_STRING,
4422                 .p_class        = P_GLOBAL,
4423                 .ptr            = &Globals.szSMBPerfcountModule,
4424                 .special        = NULL,
4425                 .enum_list      = NULL,
4426                 .flags          = FLAG_ADVANCED,
4427         },
4428
4429         {N_("VFS module options"), P_SEP, P_SEPARATOR},
4430
4431         {
4432                 .label          = "vfs objects",
4433                 .type           = P_LIST,
4434                 .p_class        = P_LOCAL,
4435                 .ptr            = &sDefault.szVfsObjects,
4436                 .special        = NULL,
4437                 .enum_list      = NULL,
4438                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
4439         },
4440         {
4441                 .label          = "vfs object",
4442                 .type           = P_LIST,
4443                 .p_class        = P_LOCAL,
4444                 .ptr            = &sDefault.szVfsObjects,
4445                 .special        = NULL,
4446                 .enum_list      = NULL,
4447                 .flags          = FLAG_HIDE,
4448         },
4449
4450
4451         {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4452
4453         {
4454                 .label          = "msdfs root",
4455                 .type           = P_BOOL,
4456                 .p_class        = P_LOCAL,
4457                 .ptr            = &sDefault.bMSDfsRoot,
4458                 .special        = NULL,
4459                 .enum_list      = NULL,
4460                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
4461         },
4462         {
4463                 .label          = "msdfs proxy",
4464                 .type           = P_STRING,
4465                 .p_class        = P_LOCAL,
4466                 .ptr            = &sDefault.szMSDfsProxy,
4467                 .special        = NULL,
4468                 .enum_list      = NULL,
4469                 .flags          = FLAG_ADVANCED | FLAG_SHARE,
4470         },
4471         {
4472                 .label          = "host msdfs",
4473                 .type           = P_BOOL,
4474                 .p_class        = P_GLOBAL,
4475                 .ptr            = &Globals.bHostMSDfs,
4476                 .special        = NULL,
4477                 .enum_list      = NULL,
4478                 .flags          = FLAG_ADVANCED,
4479         },
4480
4481         {N_("Winbind options"), P_SEP, P_SEPARATOR},
4482
4483         {
4484                 .label          = "passdb expand explicit",
4485                 .type           = P_BOOL,
4486                 .p_class        = P_GLOBAL,
4487                 .ptr            = &Globals.bPassdbExpandExplicit,
4488                 .special        = NULL,
4489                 .enum_list      = NULL,
4490                 .flags          = FLAG_ADVANCED,
4491         },
4492         {
4493                 .label          = "idmap backend",
4494                 .type           = P_STRING,
4495                 .p_class        = P_GLOBAL,
4496                 .ptr            = &Globals.szIdmapBackend,
4497                 .special        = NULL,
4498                 .enum_list      = NULL,
4499                 .flags          = FLAG_ADVANCED,
4500         },
4501         {
4502                 .label          = "idmap alloc backend",
4503                 .type           = P_STRING,
4504                 .p_class        = P_GLOBAL,
4505                 .ptr            = &Globals.szIdmapAllocBackend,
4506                 .special        = NULL,
4507                 .enum_list      = NULL,
4508                 .flags          = FLAG_ADVANCED,
4509         },
4510         {
4511                 .label          = "idmap cache time",
4512                 .type           = P_INTEGER,
4513                 .p_class        = P_GLOBAL,
4514                 .ptr            = &Globals.iIdmapCacheTime,
4515                 .special        = NULL,
4516                 .enum_list      = NULL,
4517                 .flags          = FLAG_ADVANCED,
4518         },
4519         {
4520                 .label          = "idmap negative cache time",
4521                 .type           = P_INTEGER,
4522                 .p_class        = P_GLOBAL,
4523                 .ptr            = &Globals.iIdmapNegativeCacheTime,
4524                 .special        = NULL,
4525                 .enum_list      = NULL,
4526                 .flags          = FLAG_ADVANCED,
4527         },
4528         {
4529                 .label          = "idmap uid",
4530                 .type           = P_STRING,
4531                 .p_class        = P_GLOBAL,
4532                 .ptr            = &Globals.szIdmapUID,
4533                 .special        = handle_idmap_uid,
4534                 .enum_list      = NULL,
4535                 .flags          = FLAG_ADVANCED,
4536         },
4537         {
4538                 .label          = "winbind uid",
4539                 .type           = P_STRING,
4540                 .p_class        = P_GLOBAL,
4541                 .ptr            = &Globals.szIdmapUID,
4542                 .special        = handle_idmap_uid,
4543                 .enum_list      = NULL,
4544                 .flags          = FLAG_HIDE,
4545         },
4546         {
4547                 .label          = "idmap gid",
4548                 .type           = P_STRING,
4549                 .p_class        = P_GLOBAL,
4550                 .ptr            = &Globals.szIdmapGID,
4551                 .special        = handle_idmap_gid,
4552                 .enum_list      = NULL,
4553                 .flags          = FLAG_ADVANCED,
4554         },
4555         {
4556                 .label          = "winbind gid",
4557                 .type           = P_STRING,
4558                 .p_class        = P_GLOBAL,
4559                 .ptr            = &Globals.szIdmapGID,
4560                 .special        = handle_idmap_gid,
4561                 .enum_list      = NULL,
4562                 .flags          = FLAG_HIDE,
4563         },
4564         {
4565                 .label          = "template homedir",
4566                 .type           = P_STRING,
4567                 .p_class        = P_GLOBAL,
4568                 .ptr            = &Globals.szTemplateHomedir,
4569                 .special        = NULL,
4570                 .enum_list      = NULL,
4571                 .flags          = FLAG_ADVANCED,
4572         },
4573         {
4574                 .label          = "template shell",
4575                 .type           = P_STRING,
4576                 .p_class        = P_GLOBAL,
4577                 .ptr            = &Globals.szTemplateShell,
4578                 .special        = NULL,
4579                 .enum_list      = NULL,
4580                 .flags          = FLAG_ADVANCED,
4581         },
4582         {
4583                 .label          = "winbind separator",
4584                 .type           = P_STRING,
4585                 .p_class        = P_GLOBAL,
4586                 .ptr            = &Globals.szWinbindSeparator,
4587                 .special        = NULL,
4588                 .enum_list      = NULL,
4589                 .flags          = FLAG_ADVANCED,
4590         },
4591         {
4592                 .label          = "winbind cache time",
4593                 .type           = P_INTEGER,
4594                 .p_class        = P_GLOBAL,
4595                 .ptr            = &Globals.winbind_cache_time,
4596                 .special        = NULL,
4597                 .enum_list      = NULL,
4598                 .flags          = FLAG_ADVANCED,
4599         },
4600         {
4601                 .label          = "winbind reconnect delay",
4602                 .type           = P_INTEGER,
4603                 .p_class        = P_GLOBAL,
4604                 .ptr            = &Globals.winbind_reconnect_delay,
4605                 .special        = NULL,
4606                 .enum_list      = NULL,
4607                 .flags          = FLAG_ADVANCED,
4608         },
4609         {
4610                 .label          = "winbind enum users",
4611                 .type           = P_BOOL,
4612                 .p_class        = P_GLOBAL,
4613                 .ptr            = &Globals.bWinbindEnumUsers,
4614                 .special        = NULL,
4615                 .enum_list      = NULL,
4616                 .flags          = FLAG_ADVANCED,
4617         },
4618         {
4619                 .label          = "winbind enum groups",
4620                 .type           = P_BOOL,
4621                 .p_class        = P_GLOBAL,
4622                 .ptr            = &Globals.bWinbindEnumGroups,
4623                 .special        = NULL,
4624                 .enum_list      = NULL,
4625                 .flags          = FLAG_ADVANCED,
4626         },
4627         {
4628                 .label          = "winbind use default domain",
4629                 .type           = P_BOOL,
4630                 .p_class        = P_GLOBAL,
4631                 .ptr            = &Globals.bWinbindUseDefaultDomain,
4632                 .special        = NULL,
4633                 .enum_list      = NULL,
4634                 .flags          = FLAG_ADVANCED,
4635         },
4636         {
4637                 .label          = "winbind trusted domains only",
4638                 .type           = P_BOOL,
4639                 .p_class        = P_GLOBAL,
4640                 .ptr            = &Globals.bWinbindTrustedDomainsOnly,
4641                 .special        = NULL,
4642                 .enum_list      = NULL,
4643                 .flags          = FLAG_ADVANCED,
4644         },
4645         {
4646                 .label          = "winbind nested groups",
4647                 .type           = P_BOOL,
4648                 .p_class        = P_GLOBAL,
4649                 .ptr            = &Globals.bWinbindNestedGroups,
4650                 .special        = NULL,
4651                 .enum_list      = NULL,
4652                 .flags          = FLAG_ADVANCED,
4653         },
4654         {
4655                 .label          = "winbind expand groups",
4656                 .type           = P_INTEGER,
4657                 .p_class        = P_GLOBAL,
4658                 .ptr            = &Globals.winbind_expand_groups,
4659                 .special        = NULL,
4660                 .enum_list      = NULL,
4661                 .flags          = FLAG_ADVANCED,
4662         },
4663         {
4664                 .label          = "winbind nss info",
4665                 .type           = P_LIST,
4666                 .p_class        = P_GLOBAL,
4667                 .ptr            = &Globals.szWinbindNssInfo,
4668                 .special        = NULL,
4669                 .enum_list      = NULL,
4670                 .flags          = FLAG_ADVANCED,
4671         },
4672         {
4673                 .label          = "winbind refresh tickets",
4674                 .type           = P_BOOL,
4675                 .p_class        = P_GLOBAL,
4676                 .ptr            = &Globals.bWinbindRefreshTickets,
4677                 .special        = NULL,
4678                 .enum_list      = NULL,
4679                 .flags          = FLAG_ADVANCED,
4680         },
4681         {
4682                 .label          = "winbind offline logon",
4683                 .type           = P_BOOL,
4684                 .p_class        = P_GLOBAL,
4685                 .ptr            = &Globals.bWinbindOfflineLogon,
4686                 .special        = NULL,
4687                 .enum_list      = NULL,
4688                 .flags          = FLAG_ADVANCED,
4689         },
4690         {
4691                 .label          = "winbind normalize names",
4692                 .type           = P_BOOL,
4693                 .p_class        = P_GLOBAL,
4694                 .ptr            = &Globals.bWinbindNormalizeNames,
4695                 .special        = NULL,
4696                 .enum_list      = NULL,
4697                 .flags          = FLAG_ADVANCED,
4698         },
4699         {
4700                 .label          = "winbind rpc only",
4701                 .type           = P_BOOL,
4702                 .p_class        = P_GLOBAL,
4703                 .ptr            = &Globals.bWinbindRpcOnly,
4704                 .special        = NULL,
4705                 .enum_list      = NULL,
4706                 .flags          = FLAG_ADVANCED,
4707         },
4708         {
4709                 .label          = "create krb5 conf",
4710                 .type           = P_BOOL,
4711                 .p_class        = P_GLOBAL,
4712                 .ptr            = &Globals.bCreateKrb5Conf,
4713                 .special        = NULL,
4714                 .enum_list      = NULL,
4715                 .flags          = FLAG_ADVANCED,
4716         },
4717
4718         {NULL,  P_BOOL,  P_NONE,  NULL,  NULL,  NULL,  0}
4719 };
4720
4721 /***************************************************************************
4722  Initialise the sDefault parameter structure for the printer values.
4723 ***************************************************************************/
4724
4725 static void init_printer_values(struct service *pService)
4726 {
4727         /* choose defaults depending on the type of printing */
4728         switch (pService->iPrinting) {
4729                 case PRINT_BSD:
4730                 case PRINT_AIX:
4731                 case PRINT_LPRNT:
4732                 case PRINT_LPROS2:
4733                         string_set(&pService->szLpqcommand, "lpq -P'%p'");
4734                         string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4735                         string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4736                         break;
4737
4738                 case PRINT_LPRNG:
4739                 case PRINT_PLP:
4740                         string_set(&pService->szLpqcommand, "lpq -P'%p'");
4741                         string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4742                         string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4743                         string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4744                         string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4745                         string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4746                         string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4747                         break;
4748
4749                 case PRINT_CUPS:
4750                 case PRINT_IPRINT:
4751 #ifdef HAVE_CUPS
4752                         /* set the lpq command to contain the destination printer
4753                            name only.  This is used by cups_queue_get() */
4754                         string_set(&pService->szLpqcommand, "%p");
4755                         string_set(&pService->szLprmcommand, "");
4756                         string_set(&pService->szPrintcommand, "");
4757                         string_set(&pService->szLppausecommand, "");
4758                         string_set(&pService->szLpresumecommand, "");
4759                         string_set(&pService->szQueuepausecommand, "");
4760                         string_set(&pService->szQueueresumecommand, "");
4761 #else
4762                         string_set(&pService->szLpqcommand, "lpq -P'%p'");
4763                         string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4764                         string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4765                         string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4766                         string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4767                         string_set(&pService->szQueuepausecommand, "disable '%p'");
4768                         string_set(&pService->szQueueresumecommand, "enable '%p'");
4769 #endif /* HAVE_CUPS */
4770                         break;
4771
4772                 case PRINT_SYSV:
4773                 case PRINT_HPUX:
4774                         string_set(&pService->szLpqcommand, "lpstat -o%p");
4775                         string_set(&pService->szLprmcommand, "cancel %p-%j");
4776                         string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4777                         string_set(&pService->szQueuepausecommand, "disable %p");
4778                         string_set(&pService->szQueueresumecommand, "enable %p");
4779 #ifndef HPUX
4780                         string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4781                         string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4782 #endif /* HPUX */
4783                         break;
4784
4785                 case PRINT_QNX:
4786                         string_set(&pService->szLpqcommand, "lpq -P%p");
4787                         string_set(&pService->szLprmcommand, "lprm -P%p %j");
4788                         string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4789                         break;
4790
4791 #ifdef DEVELOPER
4792         case PRINT_TEST:
4793         case PRINT_VLP:
4794                 string_set(&pService->szPrintcommand, "vlp print %p %s");
4795                 string_set(&pService->szLpqcommand, "vlp lpq %p");
4796                 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
4797                 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
4798                 string_set(&pService->szLpresumecommand, "vlp lpresume %p %j");
4799                 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
4800                 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
4801                 break;
4802 #endif /* DEVELOPER */
4803
4804         }
4805 }
4806 /**
4807  *  Function to return the default value for the maximum number of open
4808  *  file descriptors permitted.  This function tries to consult the
4809  *  kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4810  *  the smaller of those.
4811  */
4812 static int max_open_files(void)
4813 {
4814         int sysctl_max = MAX_OPEN_FILES;
4815         int rlimit_max = MAX_OPEN_FILES;
4816
4817 #ifdef HAVE_SYSCTLBYNAME
4818         {
4819                 size_t size = sizeof(sysctl_max);
4820                 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4821                              0);
4822         }
4823 #endif
4824
4825 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4826         {
4827                 struct rlimit rl;
4828
4829                 ZERO_STRUCT(rl);
4830
4831                 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4832                         rlimit_max = rl.rlim_cur;
4833
4834 #if defined(RLIM_INFINITY)
4835                 if(rl.rlim_cur == RLIM_INFINITY)
4836                         rlimit_max = MAX_OPEN_FILES;
4837         }
4838 #endif
4839 #endif
4840
4841         if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4842                 DEBUG(2,("max_open_files: sysctl_max (%d) below "
4843                         "minimum Windows limit (%d)\n",
4844                         sysctl_max,
4845                         MIN_OPEN_FILES_WINDOWS));
4846                 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4847         }
4848
4849         if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4850                 DEBUG(2,("rlimit_max: rlimit_max (%d) below "
4851                         "minimum Windows limit (%d)\n",
4852                         rlimit_max,
4853                         MIN_OPEN_FILES_WINDOWS));
4854                 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4855         }
4856
4857         return MIN(sysctl_max, rlimit_max);
4858 }
4859
4860 /**
4861  * Common part of freeing allocated data for one parameter.
4862  */
4863 static void free_one_parameter_common(void *parm_ptr,
4864                                       struct parm_struct parm)
4865 {
4866         if ((parm.type == P_STRING) ||
4867             (parm.type == P_USTRING))
4868         {
4869                 string_free((char**)parm_ptr);
4870         } else if (parm.type == P_LIST) {
4871                 TALLOC_FREE(*((char***)parm_ptr));
4872         }
4873 }
4874
4875 /**
4876  * Free the allocated data for one parameter for a share
4877  * given as a service struct.
4878  */
4879 static void free_one_parameter(struct service *service,
4880                                struct parm_struct parm)
4881 {
4882         void *parm_ptr;
4883
4884         if (parm.p_class != P_LOCAL) {
4885                 return;
4886         }
4887
4888         parm_ptr = lp_local_ptr(service, parm.ptr);
4889
4890         free_one_parameter_common(parm_ptr, parm);
4891 }
4892
4893 /**
4894  * Free the allocated parameter data of a share given
4895  * as a service struct.
4896  */
4897 static void free_parameters(struct service *service)
4898 {
4899         uint32_t i;
4900
4901         for (i=0; parm_table[i].label; i++) {
4902                 free_one_parameter(service, parm_table[i]);
4903         }
4904 }
4905
4906 /**
4907  * Free the allocated data for one parameter for a given share
4908  * specified by an snum.
4909  */
4910 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4911 {
4912         void *parm_ptr;
4913
4914         if (parm.ptr == NULL) {
4915                 return;
4916         }
4917
4918         if (snum < 0) {
4919                 parm_ptr = parm.ptr;
4920         } else if (parm.p_class != P_LOCAL) {
4921                 return;
4922         } else {
4923                 parm_ptr = lp_local_ptr_by_snum(snum, parm.ptr);
4924         }
4925
4926         free_one_parameter_common(parm_ptr, parm);
4927 }
4928
4929 /**
4930  * Free the allocated parameter data for a share specified
4931  * by an snum.
4932  */
4933 static void free_parameters_by_snum(int snum)
4934 {
4935         uint32_t i;
4936
4937         for (i=0; parm_table[i].label; i++) {
4938                 free_one_parameter_by_snum(snum, parm_table[i]);
4939         }
4940 }
4941
4942 /**
4943  * Free the allocated global parameters.
4944  */
4945 static void free_global_parameters(void)
4946 {
4947         free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4948 }
4949
4950 /***************************************************************************
4951  Initialise the global parameter structure.
4952 ***************************************************************************/
4953
4954 static void init_globals(bool first_time_only)
4955 {
4956         static bool done_init = False;
4957         char *s = NULL;
4958         int i;
4959
4960         /* If requested to initialize only once and we've already done it... */
4961         if (first_time_only && done_init) {
4962                 /* ... then we have nothing more to do */
4963                 return;
4964         }
4965
4966         if (!done_init) {
4967                 /* The logfile can be set before this is invoked. Free it if so. */
4968                 if (Globals.szLogFile != NULL) {
4969                         string_free(&Globals.szLogFile);
4970                         Globals.szLogFile = NULL;
4971                 }
4972                 done_init = True;
4973         } else {
4974                 free_global_parameters();
4975         }
4976
4977         memset((void *)&Globals, '\0', sizeof(Globals));
4978
4979         for (i = 0; parm_table[i].label; i++) {
4980                 if ((parm_table[i].type == P_STRING ||
4981                      parm_table[i].type == P_USTRING) &&
4982                     parm_table[i].ptr)
4983                 {
4984                         string_set((char **)parm_table[i].ptr, "");
4985                 }
4986         }
4987
4988         string_set(&sDefault.fstype, FSTYPE_STRING);
4989         string_set(&sDefault.szPrintjobUsername, "%U");
4990
4991         init_printer_values(&sDefault);
4992
4993
4994         DEBUG(3, ("Initialising global parameters\n"));
4995
4996         string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4997         string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4998
4999         /* use the new 'hash2' method by default, with a prefix of 1 */
5000         string_set(&Globals.szManglingMethod, "hash2");
5001         Globals.mangle_prefix = 1;
5002
5003         string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
5004
5005         /* using UTF8 by default allows us to support all chars */
5006         string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
5007
5008 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
5009         /* If the system supports nl_langinfo(), try to grab the value
5010            from the user's locale */
5011         string_set(&Globals.display_charset, "LOCALE");
5012 #else
5013         string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
5014 #endif
5015
5016         /* Use codepage 850 as a default for the dos character set */
5017         string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
5018
5019         /*
5020          * Allow the default PASSWD_CHAT to be overridden in local.h.
5021          */
5022         string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
5023
5024         set_global_myname(myhostname());
5025         string_set(&Globals.szNetbiosName,global_myname());
5026
5027         set_global_myworkgroup(WORKGROUP);
5028         string_set(&Globals.szWorkgroup, lp_workgroup());
5029
5030         string_set(&Globals.szPasswdProgram, "");
5031         string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
5032         string_set(&Globals.szStateDir, get_dyn_STATEDIR());
5033         string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
5034         string_set(&Globals.szPidDir, get_dyn_PIDDIR());
5035         string_set(&Globals.szSocketAddress, "0.0.0.0");
5036         /*
5037          * By default support explicit binding to broadcast
5038          * addresses.
5039          */
5040         Globals.bNmbdBindExplicitBroadcast = true;
5041
5042         if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
5043                 smb_panic("init_globals: ENOMEM");
5044         }
5045         string_set(&Globals.szServerString, s);
5046         SAFE_FREE(s);
5047         if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
5048                         DEFAULT_MINOR_VERSION) < 0) {
5049                 smb_panic("init_globals: ENOMEM");
5050         }
5051         string_set(&Globals.szAnnounceVersion, s);
5052         SAFE_FREE(s);
5053 #ifdef DEVELOPER
5054         string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
5055 #endif
5056
5057         string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
5058
5059         string_set(&Globals.szLogonDrive, "");
5060         /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
5061         string_set(&Globals.szLogonHome, "\\\\%N\\%U");
5062         string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
5063
5064         string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
5065         string_set(&Globals.szPasswordServer, "*");
5066
5067         Globals.AlgorithmicRidBase = BASE_RID;
5068
5069         Globals.bLoadPrinters = True;
5070         Globals.PrintcapCacheTime = 750;        /* 12.5 minutes */
5071
5072         Globals.ConfigBackend = config_backend;
5073
5074         /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
5075         /* Discovered by 2 days of pain by Don McCall @ HP :-). */
5076         Globals.max_xmit = 0x4104;
5077         Globals.max_mux = 50;   /* This is *needed* for profile support. */
5078         Globals.lpqcachetime = 30;      /* changed to handle large print servers better -- jerry */
5079         Globals.bDisableSpoolss = False;
5080         Globals.iMaxSmbdProcesses = 0;/* no limit specified */
5081         Globals.pwordlevel = 0;
5082         Globals.unamelevel = 0;
5083         Globals.deadtime = 0;
5084         Globals.getwd_cache = true;
5085         Globals.bLargeReadwrite = True;
5086         Globals.max_log_size = 5000;
5087         Globals.max_open_files = max_open_files();
5088         Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
5089         Globals.maxprotocol = PROTOCOL_NT1;
5090         Globals.minprotocol = PROTOCOL_CORE;
5091         Globals.security = SEC_USER;
5092         Globals.paranoid_server_security = True;
5093         Globals.bEncryptPasswords = True;
5094         Globals.bUpdateEncrypt = False;
5095         Globals.clientSchannel = Auto;
5096         Globals.serverSchannel = Auto;
5097         Globals.bReadRaw = True;
5098         Globals.bWriteRaw = True;
5099         Globals.bNullPasswords = False;
5100         Globals.bObeyPamRestrictions = False;
5101         Globals.syslog = 1;
5102         Globals.bSyslogOnly = False;
5103         Globals.bTimestampLogs = True;
5104         string_set(&Globals.szLogLevel, "0");
5105         Globals.bDebugPrefixTimestamp = False;
5106         Globals.bDebugHiresTimestamp = true;
5107         Globals.bDebugPid = False;
5108         Globals.bDebugUid = False;
5109         Globals.bDebugClass = False;
5110         Globals.bEnableCoreFiles = True;
5111         Globals.max_ttl = 60 * 60 * 24 * 3;     /* 3 days default. */
5112         Globals.max_wins_ttl = 60 * 60 * 24 * 6;        /* 6 days default. */
5113         Globals.min_wins_ttl = 60 * 60 * 6;     /* 6 hours default. */
5114         Globals.machine_password_timeout = 60 * 60 * 24 * 7;    /* 7 days default. */
5115         Globals.lm_announce = 2;        /* = Auto: send only if LM clients found */
5116         Globals.lm_interval = 60;
5117         Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
5118 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
5119         Globals.bNISHomeMap = False;
5120 #ifdef WITH_NISPLUS_HOME
5121         string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
5122 #else
5123         string_set(&Globals.szNISHomeMapName, "auto.home");
5124 #endif
5125 #endif
5126         Globals.bTimeServer = False;
5127         Globals.bBindInterfacesOnly = False;
5128         Globals.bUnixPasswdSync = False;
5129         Globals.bPamPasswordChange = False;
5130         Globals.bPasswdChatDebug = False;
5131         Globals.iPasswdChatTimeout = 2; /* 2 second default. */
5132         Globals.bNTPipeSupport = True;  /* Do NT pipes by default. */
5133         Globals.bNTStatusSupport = True; /* Use NT status by default. */
5134         Globals.bStatCache = True;      /* use stat cache by default */
5135         Globals.iMaxStatCacheSize = 256; /* 256k by default */
5136         Globals.restrict_anonymous = 0;
5137         Globals.bClientLanManAuth = False;      /* Do NOT use the LanMan hash if it is available */
5138         Globals.bClientPlaintextAuth = False;   /* Do NOT use a plaintext password even if is requested by the server */
5139         Globals.bLanmanAuth = False;    /* Do NOT use the LanMan hash, even if it is supplied */
5140         Globals.bNTLMAuth = True;       /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
5141         Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
5142         /* Note, that we will use NTLM2 session security (which is different), if it is available */
5143
5144         Globals.map_to_guest = 0;       /* By Default, "Never" */
5145         Globals.oplock_break_wait_time = 0;     /* By Default, 0 msecs. */
5146         Globals.enhanced_browsing = true;
5147         Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
5148 #ifdef MMAP_BLACKLIST
5149         Globals.bUseMmap = False;
5150 #else
5151         Globals.bUseMmap = True;
5152 #endif
5153         Globals.bUnixExtensions = True;
5154         Globals.bResetOnZeroVC = False;
5155         Globals.bLogWriteableFilesOnExit = False;
5156         Globals.bCreateKrb5Conf = true;
5157
5158         /* hostname lookups can be very expensive and are broken on
5159            a large number of sites (tridge) */
5160         Globals.bHostnameLookups = False;
5161
5162         string_set(&Globals.szPassdbBackend, "tdbsam");
5163         string_set(&Globals.szLdapSuffix, "");
5164         string_set(&Globals.szLdapMachineSuffix, "");
5165         string_set(&Globals.szLdapUserSuffix, "");
5166         string_set(&Globals.szLdapGroupSuffix, "");
5167         string_set(&Globals.szLdapIdmapSuffix, "");
5168
5169         string_set(&Globals.szLdapAdminDn, "");
5170         Globals.ldap_ssl = LDAP_SSL_START_TLS;
5171         Globals.ldap_ssl_ads = False;
5172         Globals.ldap_deref = -1;
5173         Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
5174         Globals.ldap_delete_dn = False;
5175         Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
5176         Globals.ldap_follow_referral = Auto;
5177         Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
5178         Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
5179         Globals.ldap_page_size = LDAP_PAGE_SIZE;
5180
5181         Globals.ldap_debug_level = 0;
5182         Globals.ldap_debug_threshold = 10;
5183
5184         /* This is what we tell the afs client. in reality we set the token 
5185          * to never expire, though, when this runs out the afs client will 
5186          * forget the token. Set to 0 to get NEVERDATE.*/
5187         Globals.iAfsTokenLifetime = 604800;
5188         Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
5189
5190 /* these parameters are set to defaults that are more appropriate
5191    for the increasing samba install base:
5192
5193    as a member of the workgroup, that will possibly become a
5194    _local_ master browser (lm = True).  this is opposed to a forced
5195    local master browser startup (pm = True).
5196
5197    doesn't provide WINS server service by default (wsupp = False),
5198    and doesn't provide domain master browser services by default, either.
5199
5200 */
5201
5202         Globals.bMsAddPrinterWizard = True;
5203         Globals.os_level = 20;
5204         Globals.bLocalMaster = True;
5205         Globals.iDomainMaster = Auto;   /* depending on bDomainLogons */
5206         Globals.bDomainLogons = False;
5207         Globals.bBrowseList = True;
5208         Globals.bWINSsupport = False;
5209         Globals.bWINSproxy = False;
5210
5211         TALLOC_FREE(Globals.szInitLogonDelayedHosts);
5212         Globals.InitLogonDelay = 100; /* 100 ms default delay */
5213
5214         Globals.bDNSproxy = True;
5215
5216         /* this just means to use them if they exist */
5217         Globals.bKernelOplocks = True;
5218
5219         Globals.bAllowTrustedDomains = True;
5220         string_set(&Globals.szIdmapBackend, "tdb");
5221
5222         string_set(&Globals.szTemplateShell, "/bin/false");
5223         string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
5224         string_set(&Globals.szWinbindSeparator, "\\");
5225
5226         string_set(&Globals.szCupsServer, "");
5227         string_set(&Globals.szIPrintServer, "");
5228
5229         string_set(&Globals.ctdbdSocket, "");
5230         Globals.szClusterAddresses = NULL;
5231         Globals.clustering = False;
5232         Globals.ctdb_timeout = 0;
5233         Globals.ctdb_locktime_warn_threshold = 0;
5234
5235         Globals.winbind_cache_time = 300;       /* 5 minutes */
5236         Globals.winbind_reconnect_delay = 30;   /* 30 seconds */
5237         Globals.bWinbindEnumUsers = False;
5238         Globals.bWinbindEnumGroups = False;
5239         Globals.bWinbindUseDefaultDomain = False;
5240         Globals.bWinbindTrustedDomainsOnly = False;
5241         Globals.bWinbindNestedGroups = True;
5242         Globals.winbind_expand_groups = 1;
5243         Globals.szWinbindNssInfo = str_list_make_v3(talloc_autofree_context(), "template", NULL);
5244         Globals.bWinbindRefreshTickets = False;
5245         Globals.bWinbindOfflineLogon = False;
5246
5247         Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
5248         Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
5249
5250         Globals.bPassdbExpandExplicit = False;
5251
5252         Globals.name_cache_timeout = 660; /* In seconds */
5253
5254         Globals.bUseSpnego = True;
5255         Globals.bClientUseSpnego = True;
5256
5257         Globals.client_signing = Auto;
5258         Globals.server_signing = False;
5259
5260         Globals.bDeferSharingViolations = True;
5261         string_set(&Globals.smb_ports, SMB_PORTS);
5262
5263         Globals.bEnablePrivileges = True;
5264         Globals.bHostMSDfs        = True;
5265         Globals.bASUSupport       = False;
5266
5267         /* User defined shares. */
5268         if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5269                 smb_panic("init_globals: ENOMEM");
5270         }
5271         string_set(&Globals.szUsersharePath, s);
5272         SAFE_FREE(s);
5273         string_set(&Globals.szUsershareTemplateShare, "");
5274         Globals.iUsershareMaxShares = 0;
5275         /* By default disallow sharing of directories not owned by the sharer. */
5276         Globals.bUsershareOwnerOnly = True;
5277         /* By default disallow guest access to usershares. */
5278         Globals.bUsershareAllowGuests = False;
5279
5280         Globals.iKeepalive = DEFAULT_KEEPALIVE;
5281
5282         /* By default no shares out of the registry */
5283         Globals.bRegistryShares = False;
5284
5285         Globals.iminreceivefile = 0;
5286
5287         Globals.bMapUntrustedToDomain = false;
5288
5289         Globals.ismb2_max_read = 1024*1024;
5290         Globals.ismb2_max_write = 1024*1024;
5291         Globals.ismb2_max_trans = 1024*1024;
5292 }
5293
5294 /*******************************************************************
5295  Convenience routine to grab string parameters into temporary memory
5296  and run standard_sub_basic on them. The buffers can be written to by
5297  callers without affecting the source string.
5298 ********************************************************************/
5299
5300 static char *lp_string(const char *s)
5301 {
5302         char *ret;
5303         TALLOC_CTX *ctx = talloc_tos();
5304
5305         /* The follow debug is useful for tracking down memory problems
5306            especially if you have an inner loop that is calling a lp_*()
5307            function that returns a string.  Perhaps this debug should be
5308            present all the time? */
5309
5310 #if 0
5311         DEBUG(10, ("lp_string(%s)\n", s));
5312 #endif
5313         if (!s) {
5314                 return NULL;
5315         }
5316
5317         ret = talloc_sub_basic(ctx,
5318                         get_current_username(),
5319                         current_user_info.domain,
5320                         s);
5321         if (trim_char(ret, '\"', '\"')) {
5322                 if (strchr(ret,'\"') != NULL) {
5323                         TALLOC_FREE(ret);
5324                         ret = talloc_sub_basic(ctx,
5325                                         get_current_username(),
5326                                         current_user_info.domain,
5327                                         s);
5328                 }
5329         }
5330         return ret;
5331 }
5332
5333 /*
5334    In this section all the functions that are used to access the
5335    parameters from the rest of the program are defined
5336 */
5337
5338 #define FN_GLOBAL_STRING(fn_name,ptr) \
5339  char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
5340 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5341  const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
5342 #define FN_GLOBAL_LIST(fn_name,ptr) \
5343  const char **fn_name(void) {return(*(const char ***)(ptr));}
5344 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5345  bool fn_name(void) {return(*(bool *)(ptr));}
5346 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5347  char fn_name(void) {return(*(char *)(ptr));}
5348 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5349  int fn_name(void) {return(*(int *)(ptr));}
5350
5351 #define FN_LOCAL_STRING(fn_name,val) \
5352  char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5353 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5354  const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5355 #define FN_LOCAL_LIST(fn_name,val) \
5356  const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5357 #define FN_LOCAL_BOOL(fn_name,val) \
5358  bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5359 #define FN_LOCAL_INTEGER(fn_name,val) \
5360  int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5361
5362 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5363  bool fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5364 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5365  int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5366 #define FN_LOCAL_PARM_STRING(fn_name,val) \
5367  char *fn_name(const struct share_params *p) {return(lp_string((LP_SNUM_OK(p->service) && ServicePtrs[(p->service)]->val) ? ServicePtrs[(p->service)]->val : sDefault.val));}
5368 #define FN_LOCAL_CHAR(fn_name,val) \
5369  char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5370
5371 FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
5372 FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
5373 FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
5374 FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
5375 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
5376 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
5377 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
5378 FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
5379 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
5380 FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
5381 FN_GLOBAL_STRING(lp_addport_cmd, &Globals.szAddPortCommand)
5382 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
5383 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
5384 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
5385 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
5386 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
5387 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5388  * build process or in smb.conf, we use that value.  Otherwise they
5389  * default to the value of lp_lockdir(). */
5390 char *lp_statedir(void) {
5391         if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5392             (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5393                 return(lp_string(*(char **)(&Globals.szStateDir) ?
5394                     *(char **)(&Globals.szStateDir) : ""));
5395         else
5396                 return(lp_string(*(char **)(&Globals.szLockDir) ?
5397                     *(char **)(&Globals.szLockDir) : ""));
5398 }
5399 char *lp_cachedir(void) {
5400         if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5401             (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5402                 return(lp_string(*(char **)(&Globals.szCacheDir) ?
5403                     *(char **)(&Globals.szCacheDir) : ""));
5404         else
5405                 return(lp_string(*(char **)(&Globals.szLockDir) ?
5406                     *(char **)(&Globals.szLockDir) : ""));
5407 }
5408 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
5409 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
5410 FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
5411 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
5412 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
5413 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
5414 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
5415 FN_GLOBAL_STRING(lp_perfcount_module, &Globals.szSMBPerfcountModule)
5416 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
5417 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
5418 FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
5419 FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
5420 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
5421 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
5422 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
5423 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
5424 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
5425 FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
5426 FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
5427 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
5428 FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
5429 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
5430 FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
5431 FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
5432 FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
5433 FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
5434 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
5435 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
5436 FN_GLOBAL_BOOL(lp_nmbd_bind_explicit_broadcast, &Globals.bNmbdBindExplicitBroadcast)
5437 FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
5438 FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
5439 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
5440 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
5441 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
5442 /* FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
5443  * lp_passdb_backend() should be replace by the this macro again after
5444  * some releases.
5445  * */
5446 #ifndef ENABLE_S3COMPAT
5447 const char *lp_passdb_backend(void)
5448 {
5449         char *delim, *quote;
5450
5451         delim = strchr( Globals.szPassdbBackend, ' ');
5452         /* no space at all */
5453         if (delim == NULL) {
5454                 goto out;
5455         }
5456
5457         quote = strchr(Globals.szPassdbBackend, '"');
5458         /* no quote char or non in the first part */
5459         if (quote == NULL || quote > delim) {
5460                 *delim = '\0';
5461                 goto warn;
5462         }
5463
5464         quote = strchr(quote+1, '"');
5465         if (quote == NULL) {
5466                 DEBUG(0, ("WARNING: Your 'passdb backend' configuration is invalid due to a missing second \" char.\n"));
5467                 goto out;
5468         } else if (*(quote+1) == '\0') {
5469                 /* space, fitting quote char, and one backend only */
5470                 goto out;
5471         } else {
5472                 /* terminate string after the fitting quote char */
5473                 *(quote+1) = '\0';
5474         }
5475
5476 warn:
5477         DEBUG(0, ("WARNING: Your 'passdb backend' configuration includes multiple backends.  This\n"
5478                 "is deprecated since Samba 3.0.23.  Please check WHATSNEW.txt or the section 'Passdb\n"
5479                 "Changes' from the ChangeNotes as part of the Samba HOWTO collection.  Only the first\n"
5480                 "backend (%s) is used.  The rest is ignored.\n", Globals.szPassdbBackend));
5481
5482 out:
5483         return Globals.szPassdbBackend;
5484 }
5485 #endif
5486 FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
5487 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
5488 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
5489 FN_GLOBAL_STRING(lp_renameuser_script, &Globals.szRenameUserScript)
5490 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
5491
5492 FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
5493 FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
5494 FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
5495 FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
5496 FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
5497 FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
5498
5499 FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
5500
5501 FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
5502 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
5503 FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
5504 FN_GLOBAL_INTEGER(lp_username_map_cache_time, &Globals.iUsernameMapCacheTime)
5505
5506 FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
5507
5508 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
5509 FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
5510 FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
5511 FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
5512 FN_GLOBAL_INTEGER(lp_acl_compatibility, &Globals.iAclCompat)
5513 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
5514 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
5515 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
5516 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
5517 FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
5518 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups)
5519 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets)
5520 FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon)
5521 FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames)
5522 FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
5523 FN_GLOBAL_BOOL(lp_create_krb5_conf, &Globals.bCreateKrb5Conf)
5524
5525 #ifndef ENABLE_S3COMPAT
5526 FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
5527 FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)
5528 #endif
5529 FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
5530 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
5531 FN_GLOBAL_INTEGER(lp_keepalive, &Globals.iKeepalive)
5532 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit)
5533
5534 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
5535 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
5536 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
5537 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, &Globals.ldap_ssl_ads)
5538 FN_GLOBAL_INTEGER(lp_ldap_deref, &Globals.ldap_deref)
5539 FN_GLOBAL_INTEGER(lp_ldap_follow_referral, &Globals.ldap_follow_referral)
5540 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
5541 FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
5542 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
5543 FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
5544 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, &Globals.ldap_connection_timeout)
5545 FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
5546 FN_GLOBAL_INTEGER(lp_ldap_debug_level, &Globals.ldap_debug_level)
5547 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, &Globals.ldap_debug_threshold)
5548 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
5549 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
5550 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
5551 FN_GLOBAL_STRING(lp_usershare_path, &Globals.szUsersharePath)
5552 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, &Globals.szUsersharePrefixAllowList)
5553 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, &Globals.szUsersharePrefixDenyList)
5554
5555 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
5556
5557 FN_GLOBAL_BOOL(lp_registry_shares, &Globals.bRegistryShares)
5558 FN_GLOBAL_BOOL(lp_usershare_allow_guests, &Globals.bUsershareAllowGuests)
5559 FN_GLOBAL_BOOL(lp_usershare_owner_only, &Globals.bUsershareOwnerOnly)
5560 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
5561 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
5562 FN_GLOBAL_BOOL(lp_log_writeable_files_on_exit,
5563                &Globals.bLogWriteableFilesOnExit)
5564 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
5565 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
5566 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
5567 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
5568 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
5569 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
5570 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
5571 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, &Globals.szInitLogonDelayedHosts)
5572 FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
5573 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
5574 FN_GLOBAL_BOOL(_lp_readraw, &Globals.bReadRaw)
5575 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
5576 FN_GLOBAL_BOOL(_lp_writeraw, &Globals.bWriteRaw)
5577 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
5578 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
5579 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
5580 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
5581 FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
5582 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
5583 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
5584 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
5585 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
5586 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
5587 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
5588 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
5589 FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
5590 FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
5591 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
5592 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
5593 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
5594 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
5595 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
5596 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
5597 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
5598 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
5599 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
5600 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
5601 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
5602 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
5603 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
5604 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, &Globals.bMapUntrustedToDomain)
5605 FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
5606 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
5607 FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
5608 FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
5609 FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
5610 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
5611 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
5612 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
5613 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
5614 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
5615 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
5616 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
5617 FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
5618 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
5619 FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
5620 FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
5621 FN_GLOBAL_STRING(lp_dedicated_keytab_file, &Globals.szDedicatedKeytabFile)
5622 FN_GLOBAL_INTEGER(lp_kerberos_method, &Globals.iKerberosMethod)
5623 FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
5624 FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
5625 FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport)
5626 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
5627 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
5628 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
5629 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
5630 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
5631 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
5632 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, &Globals.open_files_db_hash_size)
5633 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
5634 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
5635 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
5636 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
5637 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
5638 FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
5639 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
5640 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
5641 #ifndef ENABLE_S3COMPAT
5642 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
5643 #endif
5644 FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
5645 FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
5646 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
5647 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
5648 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
5649 FN_GLOBAL_BOOL(_lp_disable_spoolss, &Globals.bDisableSpoolss)
5650 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
5651 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
5652 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
5653 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
5654 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
5655 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
5656 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
5657 FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
5658 FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
5659 FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
5660 FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
5661 FN_GLOBAL_INTEGER(lp_smb2_max_read, &Globals.ismb2_max_read)
5662 FN_GLOBAL_INTEGER(lp_smb2_max_write, &Globals.ismb2_max_write)
5663 FN_GLOBAL_INTEGER(lp_smb2_max_trans, &Globals.ismb2_max_trans)
5664
5665 FN_LOCAL_STRING(lp_preexec, szPreExec)
5666 FN_LOCAL_STRING(lp_postexec, szPostExec)
5667 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
5668 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
5669 FN_LOCAL_STRING(lp_servicename, szService)
5670 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
5671 FN_LOCAL_STRING(lp_pathname, szPath)
5672 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
5673 FN_LOCAL_STRING(lp_username, szUsername)
5674 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
5675 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
5676 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
5677 FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
5678 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
5679 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
5680 int lp_cups_encrypt(void)
5681 {
5682         int result = 0;
5683 #ifdef HAVE_HTTPCONNECTENCRYPT
5684         switch (Globals.CupsEncrypt) {
5685                 case Auto:
5686                         result = HTTP_ENCRYPT_REQUIRED;
5687                         break;
5688                 case True:
5689                         result = HTTP_ENCRYPT_ALWAYS;
5690                         break;
5691                 case False:
5692                         result = HTTP_ENCRYPT_NEVER;
5693                         break;
5694         }
5695 #endif
5696         return result;
5697 }
5698 FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
5699 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
5700 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
5701 FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
5702 FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
5703 FN_GLOBAL_INTEGER(lp_ctdb_timeout, &Globals.ctdb_timeout)
5704 FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, &Globals.ctdb_locktime_warn_threshold)
5705 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
5706 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
5707 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
5708 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
5709 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
5710 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
5711 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
5712 static FN_LOCAL_STRING(_lp_printername, szPrintername)
5713 FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
5714 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
5715 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
5716 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
5717 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
5718 FN_LOCAL_STRING(lp_comment, comment)
5719 FN_LOCAL_STRING(lp_force_user, force_user)
5720 FN_LOCAL_STRING(lp_force_group, force_group)
5721 FN_LOCAL_LIST(lp_readlist, readlist)
5722 FN_LOCAL_LIST(lp_writelist, writelist)
5723 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
5724 FN_LOCAL_STRING(lp_fstype, fstype)
5725 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
5726 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
5727 static FN_LOCAL_STRING(lp_volume, volume)
5728 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
5729 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
5730 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
5731 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
5732 FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
5733 FN_LOCAL_STRING(lp_dfree_command, szDfree)
5734 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
5735 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
5736 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
5737 FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
5738 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
5739 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
5740 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
5741 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
5742 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
5743 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
5744 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
5745 FN_LOCAL_BOOL(lp_access_based_share_enum, bAccessBasedShareEnum)
5746 FN_LOCAL_BOOL(lp_readonly, bRead_only)
5747 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
5748 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
5749 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
5750 FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
5751 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
5752 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
5753 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
5754 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
5755 FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
5756 FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
5757 FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
5758 FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
5759 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
5760 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
5761 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
5762 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
5763 FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames)
5764 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
5765 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
5766 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
5767 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
5768 FN_LOCAL_BOOL(lp_map_system, bMap_system)
5769 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
5770 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
5771 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
5772 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
5773 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
5774 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
5775 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
5776 FN_GLOBAL_BOOL(lp_async_smb_echo_handler, &Globals.bAsyncSMBEchoHandler)
5777 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
5778 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
5779 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
5780 FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
5781 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
5782 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
5783 FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
5784 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
5785 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
5786 FN_LOCAL_BOOL(lp_ea_support, bEASupport)
5787 FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
5788 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
5789 FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
5790 FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
5791 FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
5792 FN_LOCAL_BOOL(lp_acl_group_control, bAclGroupControl)
5793 FN_LOCAL_BOOL(lp_acl_map_full_control, bAclMapFullControl)
5794 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
5795 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
5796 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
5797 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
5798 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
5799 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
5800 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
5801 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
5802 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
5803 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
5804 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
5805 FN_LOCAL_INTEGER(lp_printing, iPrinting)
5806 FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
5807 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
5808 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
5809 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
5810 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
5811 FN_LOCAL_INTEGER(lp_dfree_cache_time, iDfreeCacheTime)
5812 FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
5813 FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
5814 FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
5815 FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
5816 FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
5817 FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
5818 FN_LOCAL_CHAR(lp_magicchar, magic_char)
5819 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
5820 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
5821 FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
5822 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
5823 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
5824 FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
5825 FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
5826 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
5827
5828 /* local prototypes */
5829
5830 static int map_parameter(const char *pszParmName);
5831 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5832 static const char *get_boolean(bool bool_value);
5833 static int getservicebyname(const char *pszServiceName,
5834                             struct service *pserviceDest);
5835 static void copy_service(struct service *pserviceDest,
5836                          struct service *pserviceSource,
5837                          struct bitmap *pcopymapDest);
5838 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5839                          void *userdata);
5840 static bool do_section(const char *pszSectionName, void *userdata);
5841 static void init_copymap(struct service *pservice);
5842 static bool hash_a_service(const char *name, int number);
5843 static void free_service_byindex(int iService);
5844 static void free_param_opts(struct param_opt_struct **popts);
5845 static void show_parameter(int parmIndex);
5846 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5847
5848 /*
5849  * This is a helper function for parametrical options support.  It returns a
5850  * pointer to parametrical option value if it exists or NULL otherwise. Actual
5851  * parametrical functions are quite simple
5852  */
5853 static struct param_opt_struct *get_parametrics(int snum, const char *type,
5854                                                 const char *option)
5855 {
5856         bool global_section = False;
5857         char* param_key;
5858         struct param_opt_struct *data;
5859
5860         if (snum >= iNumServices) return NULL;
5861
5862         if (snum < 0) { 
5863                 data = Globals.param_opt;
5864                 global_section = True;
5865         } else {
5866                 data = ServicePtrs[snum]->param_opt;
5867         }
5868
5869         if (asprintf(&param_key, "%s:%s", type, option) == -1) {
5870                 DEBUG(0,("asprintf failed!\n"));
5871                 return NULL;
5872         }
5873
5874         while (data) {
5875                 if (strwicmp(data->key, param_key) == 0) {
5876                         string_free(&param_key);
5877                         return data;
5878                 }
5879                 data = data->next;
5880         }
5881
5882         if (!global_section) {
5883                 /* Try to fetch the same option but from globals */
5884                 /* but only if we are not already working with Globals */
5885                 data = Globals.param_opt;
5886                 while (data) {
5887                         if (strwicmp(data->key, param_key) == 0) {
5888                                 string_free(&param_key);
5889                                 return data;
5890                         }
5891                         data = data->next;
5892                 }
5893         }
5894
5895         string_free(&param_key);
5896
5897         return NULL;
5898 }
5899
5900
5901 #define MISSING_PARAMETER(name) \
5902     DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5903
5904 /*******************************************************************
5905 convenience routine to return int parameters.
5906 ********************************************************************/
5907 static int lp_int(const char *s)
5908 {
5909
5910         if (!s || !*s) {
5911                 MISSING_PARAMETER(lp_int);
5912                 return (-1);
5913         }
5914
5915         return (int)strtol(s, NULL, 0);
5916 }
5917
5918 /*******************************************************************
5919 convenience routine to return unsigned long parameters.
5920 ********************************************************************/
5921 static unsigned long lp_ulong(const char *s)
5922 {
5923
5924         if (!s || !*s) {
5925                 MISSING_PARAMETER(lp_ulong);
5926                 return (0);
5927         }
5928
5929         return strtoul(s, NULL, 0);
5930 }
5931
5932 /*******************************************************************
5933 convenience routine to return boolean parameters.
5934 ********************************************************************/
5935 static bool lp_bool(const char *s)
5936 {
5937         bool ret = False;
5938
5939         if (!s || !*s) {
5940                 MISSING_PARAMETER(lp_bool);
5941                 return False;
5942         }
5943
5944         if (!set_boolean(s, &ret)) {
5945                 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5946                 return False;
5947         }
5948
5949         return ret;
5950 }
5951
5952 /*******************************************************************
5953 convenience routine to return enum parameters.
5954 ********************************************************************/
5955 static int lp_enum(const char *s,const struct enum_list *_enum)
5956 {
5957         int i;
5958
5959         if (!s || !*s || !_enum) {
5960                 MISSING_PARAMETER(lp_enum);
5961                 return (-1);
5962         }
5963
5964         for (i=0; _enum[i].name; i++) {
5965                 if (strequal(_enum[i].name,s))
5966                         return _enum[i].value;
5967         }
5968
5969         DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5970         return (-1);
5971 }
5972
5973 #undef MISSING_PARAMETER
5974
5975 /* DO NOT USE lp_parm_string ANYMORE!!!!
5976  * use lp_parm_const_string or lp_parm_talloc_string
5977  *
5978  * lp_parm_string is only used to let old modules find this symbol
5979  */
5980 #undef lp_parm_string
5981  char *lp_parm_string(const char *servicename, const char *type, const char *option);
5982  char *lp_parm_string(const char *servicename, const char *type, const char *option)
5983 {
5984         return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
5985 }
5986
5987 /* Return parametric option from a given service. Type is a part of option before ':' */
5988 /* Parametric option has following syntax: 'Type: option = value' */
5989 /* the returned value is talloced on the talloc_tos() */
5990 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5991 {
5992         struct param_opt_struct *data = get_parametrics(snum, type, option);
5993
5994         if (data == NULL||data->value==NULL) {
5995                 if (def) {
5996                         return lp_string(def);
5997                 } else {
5998                         return NULL;
5999                 }
6000         }
6001
6002         return lp_string(data->value);
6003 }
6004
6005 /* Return parametric option from a given service. Type is a part of option before ':' */
6006 /* Parametric option has following syntax: 'Type: option = value' */
6007 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
6008 {
6009         struct param_opt_struct *data = get_parametrics(snum, type, option);
6010
6011         if (data == NULL||data->value==NULL)
6012                 return def;
6013
6014         return data->value;
6015 }
6016
6017 /* Return parametric option from a given service. Type is a part of option before ':' */
6018 /* Parametric option has following syntax: 'Type: option = value' */
6019
6020 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
6021 {
6022         struct param_opt_struct *data = get_parametrics(snum, type, option);
6023
6024         if (data == NULL||data->value==NULL)
6025                 return (const char **)def;
6026
6027         if (data->list==NULL) {
6028                 data->list = str_list_make_v3(talloc_autofree_context(), data->value, NULL);
6029         }
6030
6031         return (const char **)data->list;
6032 }
6033
6034 /* Return parametric option from a given service. Type is a part of option before ':' */
6035 /* Parametric option has following syntax: 'Type: option = value' */
6036
6037 int lp_parm_int(int snum, const char *type, const char *option, int def)
6038 {
6039         struct param_opt_struct *data = get_parametrics(snum, type, option);
6040
6041         if (data && data->value && *data->value)
6042                 return lp_int(data->value);
6043
6044         return def;
6045 }
6046
6047 /* Return parametric option from a given service. Type is a part of option before ':' */
6048 /* Parametric option has following syntax: 'Type: option = value' */
6049
6050 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
6051 {
6052         struct param_opt_struct *data = get_parametrics(snum, type, option);
6053
6054         if (data && data->value && *data->value)
6055                 return lp_ulong(data->value);
6056
6057         return def;
6058 }
6059
6060 /* Return parametric option from a given service. Type is a part of option before ':' */
6061 /* Parametric option has following syntax: 'Type: option = value' */
6062
6063 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
6064 {
6065         struct param_opt_struct *data = get_parametrics(snum, type, option);
6066
6067         if (data && data->value && *data->value)
6068                 return lp_bool(data->value);
6069
6070         return def;
6071 }
6072
6073 /* Return parametric option from a given service. Type is a part of option before ':' */
6074 /* Parametric option has following syntax: 'Type: option = value' */
6075
6076 int lp_parm_enum(int snum, const char *type, const char *option,
6077                  const struct enum_list *_enum, int def)
6078 {
6079         struct param_opt_struct *data = get_parametrics(snum, type, option);
6080
6081         if (data && data->value && *data->value && _enum)
6082                 return lp_enum(data->value, _enum);
6083
6084         return def;
6085 }
6086
6087
6088 /***************************************************************************
6089  Initialise a service to the defaults.
6090 ***************************************************************************/
6091
6092 static void init_service(struct service *pservice)
6093 {
6094         memset((char *)pservice, '\0', sizeof(struct service));
6095         copy_service(pservice, &sDefault, NULL);
6096 }
6097
6098
6099 /**
6100  * free a param_opts structure.
6101  * param_opts handling should be moved to talloc;
6102  * then this whole functions reduces to a TALLOC_FREE().
6103  */
6104
6105 static void free_param_opts(struct param_opt_struct **popts)
6106 {
6107         struct param_opt_struct *opt, *next_opt;
6108
6109         if (popts == NULL) {
6110                 return;
6111         }
6112
6113         if (*popts != NULL) {
6114                 DEBUG(5, ("Freeing parametrics:\n"));
6115         }
6116         opt = *popts;
6117         while (opt != NULL) {
6118                 string_free(&opt->key);
6119                 string_free(&opt->value);
6120                 TALLOC_FREE(opt->list);
6121                 next_opt = opt->next;
6122                 SAFE_FREE(opt);
6123                 opt = next_opt;
6124         }
6125         *popts = NULL;
6126 }
6127
6128 /***************************************************************************
6129  Free the dynamically allocated parts of a service struct.
6130 ***************************************************************************/
6131
6132 static void free_service(struct service *pservice)
6133 {
6134         if (!pservice)
6135                 return;
6136
6137         if (pservice->szService)
6138                 DEBUG(5, ("free_service: Freeing service %s\n",
6139                        pservice->szService));
6140
6141         free_parameters(pservice);
6142
6143         string_free(&pservice->szService);
6144         TALLOC_FREE(pservice->copymap);
6145
6146         free_param_opts(&pservice->param_opt);
6147
6148         ZERO_STRUCTP(pservice);
6149 }
6150
6151
6152 /***************************************************************************
6153  remove a service indexed in the ServicePtrs array from the ServiceHash
6154  and free the dynamically allocated parts
6155 ***************************************************************************/
6156
6157 static void free_service_byindex(int idx)
6158 {
6159         if ( !LP_SNUM_OK(idx) ) 
6160                 return;
6161
6162         ServicePtrs[idx]->valid = False;
6163         invalid_services[num_invalid_services++] = idx;
6164
6165         /* we have to cleanup the hash record */
6166
6167         if (ServicePtrs[idx]->szService) {
6168                 char *canon_name = canonicalize_servicename(
6169                         talloc_tos(),
6170                         ServicePtrs[idx]->szService );
6171
6172                 dbwrap_delete_bystring(ServiceHash, canon_name );
6173                 TALLOC_FREE(canon_name);
6174         }
6175
6176         free_service(ServicePtrs[idx]);
6177 }
6178
6179 /***************************************************************************
6180  Add a new service to the services array initialising it with the given 
6181  service. 
6182 ***************************************************************************/
6183
6184 static int add_a_service(const struct service *pservice, const char *name)
6185 {
6186         int i;
6187         struct service tservice;
6188         int num_to_alloc = iNumServices + 1;
6189
6190         tservice = *pservice;
6191
6192         /* it might already exist */
6193         if (name) {
6194                 i = getservicebyname(name, NULL);
6195                 if (i >= 0) {
6196                         /* Clean all parametric options for service */
6197                         /* They will be added during parsing again */
6198                         free_param_opts(&ServicePtrs[i]->param_opt);
6199                         return (i);
6200                 }
6201         }
6202
6203         /* find an invalid one */
6204         i = iNumServices;
6205         if (num_invalid_services > 0) {
6206                 i = invalid_services[--num_invalid_services];
6207         }
6208
6209         /* if not, then create one */
6210         if (i == iNumServices) {
6211                 struct service **tsp;
6212                 int *tinvalid;
6213
6214                 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
6215                 if (tsp == NULL) {
6216                         DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
6217                         return (-1);
6218                 }
6219                 ServicePtrs = tsp;
6220                 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct service);
6221                 if (!ServicePtrs[iNumServices]) {
6222                         DEBUG(0,("add_a_service: out of memory!\n"));
6223                         return (-1);
6224                 }
6225                 iNumServices++;
6226
6227                 /* enlarge invalid_services here for now... */
6228                 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
6229                                              num_to_alloc);
6230                 if (tinvalid == NULL) {
6231                         DEBUG(0,("add_a_service: failed to enlarge "
6232                                  "invalid_services!\n"));
6233                         return (-1);
6234                 }
6235                 invalid_services = tinvalid;
6236         } else {
6237                 free_service_byindex(i);
6238         }
6239
6240         ServicePtrs[i]->valid = True;
6241
6242         init_service(ServicePtrs[i]);
6243         copy_service(ServicePtrs[i], &tservice, NULL);
6244         if (name)
6245                 string_set(&ServicePtrs[i]->szService, name);
6246
6247         DEBUG(8,("add_a_service: Creating snum = %d for %s\n", 
6248                 i, ServicePtrs[i]->szService));
6249
6250         if (!hash_a_service(ServicePtrs[i]->szService, i)) {
6251                 return (-1);
6252         }
6253
6254         return (i);
6255 }
6256
6257 /***************************************************************************
6258   Convert a string to uppercase and remove whitespaces.
6259 ***************************************************************************/
6260
6261 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
6262 {
6263         char *result;
6264
6265         if ( !src ) {
6266                 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
6267                 return NULL;
6268         }
6269
6270         result = talloc_strdup(ctx, src);
6271         SMB_ASSERT(result != NULL);
6272
6273         strlower_m(result);
6274         return result;
6275 }
6276
6277 /***************************************************************************
6278   Add a name/index pair for the services array to the hash table.
6279 ***************************************************************************/
6280
6281 static bool hash_a_service(const char *name, int idx)
6282 {
6283         char *canon_name;
6284
6285         if ( !ServiceHash ) {
6286                 DEBUG(10,("hash_a_service: creating servicehash\n"));
6287                 ServiceHash = db_open_rbt(NULL);
6288                 if ( !ServiceHash ) {
6289                         DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
6290                         return False;
6291                 }
6292         }
6293
6294         DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
6295                 idx, name));
6296
6297         canon_name = canonicalize_servicename(talloc_tos(), name );
6298
6299         dbwrap_store_bystring(ServiceHash, canon_name,
6300                               make_tdb_data((uint8 *)&idx, sizeof(idx)),
6301                               TDB_REPLACE);
6302
6303         TALLOC_FREE(canon_name);
6304
6305         return True;
6306 }
6307
6308 /***************************************************************************
6309  Add a new home service, with the specified home directory, defaults coming
6310  from service ifrom.
6311 ***************************************************************************/
6312
6313 bool lp_add_home(const char *pszHomename, int iDefaultService,
6314                  const char *user, const char *pszHomedir)
6315 {
6316         int i;
6317
6318         if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
6319                         pszHomedir[0] == '\0') {
6320                 return false;
6321         }
6322
6323         i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
6324
6325         if (i < 0)
6326                 return (False);
6327
6328         if (!(*(ServicePtrs[iDefaultService]->szPath))
6329             || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
6330                 string_set(&ServicePtrs[i]->szPath, pszHomedir);
6331         }
6332
6333         if (!(*(ServicePtrs[i]->comment))) {
6334                 char *comment = NULL;
6335                 if (asprintf(&comment, "Home directory of %s", user) < 0) {
6336                         return false;
6337                 }
6338                 string_set(&ServicePtrs[i]->comment, comment);
6339                 SAFE_FREE(comment);
6340         }
6341
6342         /* set the browseable flag from the global default */
6343
6344         ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6345         ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
6346
6347         ServicePtrs[i]->autoloaded = True;
6348
6349         DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename, 
6350                user, ServicePtrs[i]->szPath ));
6351
6352         return (True);
6353 }
6354
6355 /***************************************************************************
6356  Add a new service, based on an old one.
6357 ***************************************************************************/
6358
6359 int lp_add_service(const char *pszService, int iDefaultService)
6360 {
6361         if (iDefaultService < 0) {
6362                 return add_a_service(&sDefault, pszService);
6363         }
6364
6365         return (add_a_service(ServicePtrs[iDefaultService], pszService));
6366 }
6367
6368 /***************************************************************************
6369  Add the IPC service.
6370 ***************************************************************************/
6371
6372 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
6373 {
6374         char *comment = NULL;
6375         int i = add_a_service(&sDefault, ipc_name);
6376
6377         if (i < 0)
6378                 return (False);
6379
6380         if (asprintf(&comment, "IPC Service (%s)",
6381                                 Globals.szServerString) < 0) {
6382                 return (False);
6383         }
6384
6385         string_set(&ServicePtrs[i]->szPath, tmpdir());
6386         string_set(&ServicePtrs[i]->szUsername, "");
6387         string_set(&ServicePtrs[i]->comment, comment);
6388         string_set(&ServicePtrs[i]->fstype, "IPC");
6389         ServicePtrs[i]->iMaxConnections = 0;
6390         ServicePtrs[i]->bAvailable = True;
6391         ServicePtrs[i]->bRead_only = True;
6392         ServicePtrs[i]->bGuest_only = False;
6393         ServicePtrs[i]->bAdministrative_share = True;
6394         ServicePtrs[i]->bGuest_ok = guest_ok;
6395         ServicePtrs[i]->bPrint_ok = False;
6396         ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6397
6398         DEBUG(3, ("adding IPC service\n"));
6399
6400         SAFE_FREE(comment);
6401         return (True);
6402 }
6403
6404 /***************************************************************************
6405  Add a new printer service, with defaults coming from service iFrom.
6406 ***************************************************************************/
6407
6408 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
6409 {
6410         const char *comment = "From Printcap";
6411         int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6412
6413         if (i < 0)
6414                 return (False);
6415
6416         /* note that we do NOT default the availability flag to True - */
6417         /* we take it from the default service passed. This allows all */
6418         /* dynamic printers to be disabled by disabling the [printers] */
6419         /* entry (if/when the 'available' keyword is implemented!).    */
6420
6421         /* the printer name is set to the service name. */
6422         string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6423         string_set(&ServicePtrs[i]->comment, comment);
6424
6425         /* set the browseable flag from the gloabl default */
6426         ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6427
6428         /* Printers cannot be read_only. */
6429         ServicePtrs[i]->bRead_only = False;
6430         /* No share modes on printer services. */
6431         ServicePtrs[i]->bShareModes = False;
6432         /* No oplocks on printer services. */
6433         ServicePtrs[i]->bOpLocks = False;
6434         /* Printer services must be printable. */
6435         ServicePtrs[i]->bPrint_ok = True;
6436
6437         DEBUG(3, ("adding printer service %s\n", pszPrintername));
6438
6439         return (True);
6440 }
6441
6442
6443 /***************************************************************************
6444  Check whether the given parameter name is valid.
6445  Parametric options (names containing a colon) are considered valid.
6446 ***************************************************************************/
6447
6448 bool lp_parameter_is_valid(const char *pszParmName)
6449 {
6450         return ((map_parameter(pszParmName) != -1) ||
6451                 (strchr(pszParmName, ':') != NULL));
6452 }
6453
6454 /***************************************************************************
6455  Check whether the given name is the name of a global parameter.
6456  Returns True for strings belonging to parameters of class
6457  P_GLOBAL, False for all other strings, also for parametric options
6458  and strings not belonging to any option.
6459 ***************************************************************************/
6460
6461 bool lp_parameter_is_global(const char *pszParmName)
6462 {
6463         int num = map_parameter(pszParmName);
6464
6465         if (num >= 0) {
6466                 return (parm_table[num].p_class == P_GLOBAL);
6467         }
6468
6469         return False;
6470 }
6471
6472 /**************************************************************************
6473  Check whether the given name is the canonical name of a parameter.
6474  Returns False if it is not a valid parameter Name.
6475  For parametric options, True is returned.
6476 **************************************************************************/
6477
6478 bool lp_parameter_is_canonical(const char *parm_name)
6479 {
6480         if (!lp_parameter_is_valid(parm_name)) {
6481                 return False;
6482         }
6483
6484         return (map_parameter(parm_name) ==
6485                 map_parameter_canonical(parm_name, NULL));
6486 }
6487
6488 /**************************************************************************
6489  Determine the canonical name for a parameter.
6490  Indicate when it is an inverse (boolean) synonym instead of a
6491  "usual" synonym.
6492 **************************************************************************/
6493
6494 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6495                                bool *inverse)
6496 {
6497         int num;
6498
6499         if (!lp_parameter_is_valid(parm_name)) {
6500                 *canon_parm = NULL;
6501                 return False;
6502         }
6503
6504         num = map_parameter_canonical(parm_name, inverse);
6505         if (num < 0) {
6506                 /* parametric option */
6507                 *canon_parm = parm_name;
6508         } else {
6509                 *canon_parm = parm_table[num].label;
6510         }
6511
6512         return True;
6513
6514 }
6515
6516 /**************************************************************************
6517  Determine the canonical name for a parameter.
6518  Turn the value given into the inverse boolean expression when
6519  the synonym is an invers boolean synonym.
6520
6521  Return True if parm_name is a valid parameter name and
6522  in case it is an invers boolean synonym, if the val string could
6523  successfully be converted to the reverse bool.
6524  Return false in all other cases.
6525 **************************************************************************/
6526
6527 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6528                                           const char *val,
6529                                           const char **canon_parm,
6530                                           const char **canon_val)
6531 {
6532         int num;
6533         bool inverse;
6534
6535         if (!lp_parameter_is_valid(parm_name)) {
6536                 *canon_parm = NULL;
6537                 *canon_val = NULL;
6538                 return False;
6539         }
6540
6541         num = map_parameter_canonical(parm_name, &inverse);
6542         if (num < 0) {
6543                 /* parametric option */
6544                 *canon_parm = parm_name;
6545                 *canon_val = val;
6546         } else {
6547                 *canon_parm = parm_table[num].label;
6548                 if (inverse) {
6549                         if (!lp_invert_boolean(val, canon_val)) {
6550                                 *canon_val = NULL;
6551                                 return False;
6552                         }
6553                 } else {
6554                         *canon_val = val;
6555                 }
6556         }
6557
6558         return True;
6559 }
6560
6561 /***************************************************************************
6562  Map a parameter's string representation to something we can use. 
6563  Returns False if the parameter string is not recognised, else TRUE.
6564 ***************************************************************************/
6565
6566 static int map_parameter(const char *pszParmName)
6567 {
6568         int iIndex;
6569
6570         if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6571                 return (-1);
6572
6573         for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6574                 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6575                         return (iIndex);
6576
6577         /* Warn only if it isn't parametric option */
6578         if (strchr(pszParmName, ':') == NULL)
6579                 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6580         /* We do return 'fail' for parametric options as well because they are
6581            stored in different storage
6582          */
6583         return (-1);
6584 }
6585
6586 /***************************************************************************
6587  Map a parameter's string representation to the index of the canonical
6588  form of the parameter (it might be a synonym).
6589  Returns -1 if the parameter string is not recognised.
6590 ***************************************************************************/
6591
6592 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6593 {
6594         int parm_num, canon_num;
6595         bool loc_inverse = False;
6596
6597         parm_num = map_parameter(pszParmName);
6598         if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6599                 /* invalid, parametric or no canidate for synonyms ... */
6600                 goto done;
6601         }
6602
6603         for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6604                 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6605                         parm_num = canon_num;
6606                         goto done;
6607                 }
6608         }
6609
6610 done:
6611         if (inverse != NULL) {
6612                 *inverse = loc_inverse;
6613         }
6614         return parm_num;
6615 }
6616
6617 /***************************************************************************
6618  return true if parameter number parm1 is a synonym of parameter
6619  number parm2 (parm2 being the principal name).
6620  set inverse to True if parm1 is P_BOOLREV and parm2 is P_BOOL,
6621  False otherwise.
6622 ***************************************************************************/
6623
6624 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6625 {
6626         if ((parm_table[parm1].ptr == parm_table[parm2].ptr) &&
6627             (parm_table[parm1].flags & FLAG_HIDE) &&
6628             !(parm_table[parm2].flags & FLAG_HIDE))
6629         {
6630                 if (inverse != NULL) {
6631                         if ((parm_table[parm1].type == P_BOOLREV) &&
6632                             (parm_table[parm2].type == P_BOOL))
6633                         {
6634                                 *inverse = True;
6635                         } else {
6636                                 *inverse = False;
6637                         }
6638                 }
6639                 return True;
6640         }
6641         return False;
6642 }
6643
6644 /***************************************************************************
6645  Show one parameter's name, type, [values,] and flags.
6646  (helper functions for show_parameter_list)
6647 ***************************************************************************/
6648
6649 static void show_parameter(int parmIndex)
6650 {
6651         int enumIndex, flagIndex;
6652         int parmIndex2;
6653         bool hadFlag;
6654         bool hadSyn;
6655         bool inverse;
6656         const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6657                 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6658                 "P_ENUM", "P_SEP"};
6659         unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6660                 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6661                 FLAG_HIDE, FLAG_DOS_STRING};
6662         const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6663                 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6664                 "FLAG_DEPRECATED", "FLAG_HIDE", "FLAG_DOS_STRING", NULL};
6665
6666         printf("%s=%s", parm_table[parmIndex].label,
6667                type[parm_table[parmIndex].type]);
6668         if (parm_table[parmIndex].type == P_ENUM) {
6669                 printf(",");
6670                 for (enumIndex=0;
6671                      parm_table[parmIndex].enum_list[enumIndex].name;
6672                      enumIndex++)
6673                 {
6674                         printf("%s%s",
6675                                enumIndex ? "|" : "",
6676                                parm_table[parmIndex].enum_list[enumIndex].name);
6677                 }
6678         }
6679         printf(",");
6680         hadFlag = False;
6681         for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6682                 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6683                         printf("%s%s",
6684                                 hadFlag ? "|" : "",
6685                                 flag_names[flagIndex]);
6686                         hadFlag = True;
6687                 }
6688         }
6689
6690         /* output synonyms */
6691         hadSyn = False;
6692         for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6693                 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6694                         printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6695                                parm_table[parmIndex2].label);
6696                 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6697                         if (!hadSyn) {
6698                                 printf(" (synonyms: ");
6699                                 hadSyn = True;
6700                         } else {
6701                                 printf(", ");
6702                         }
6703                         printf("%s%s", parm_table[parmIndex2].label,
6704                                inverse ? "[i]" : "");
6705                 }
6706         }
6707         if (hadSyn) {
6708                 printf(")");
6709         }
6710
6711         printf("\n");
6712 }
6713
6714 /***************************************************************************
6715  Show all parameter's name, type, [values,] and flags.
6716 ***************************************************************************/
6717
6718 void show_parameter_list(void)
6719 {
6720         int classIndex, parmIndex;
6721         const char *section_names[] = { "local", "global", NULL};
6722
6723         for (classIndex=0; section_names[classIndex]; classIndex++) {
6724                 printf("[%s]\n", section_names[classIndex]);
6725                 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6726                         if (parm_table[parmIndex].p_class == classIndex) {
6727                                 show_parameter(parmIndex);
6728                         }
6729                 }
6730         }
6731 }
6732
6733 /***************************************************************************
6734  Check if a given string correctly represents a boolean value.
6735 ***************************************************************************/
6736
6737 bool lp_string_is_valid_boolean(const char *parm_value)
6738 {
6739         return set_boolean(parm_value, NULL);
6740 }
6741
6742 /***************************************************************************
6743  Get the standard string representation of a boolean value ("yes" or "no")
6744 ***************************************************************************/
6745
6746 static const char *get_boolean(bool bool_value)
6747 {
6748         static const char *yes_str = "yes";
6749         static const char *no_str = "no";
6750
6751         return (bool_value ? yes_str : no_str);
6752 }
6753
6754 /***************************************************************************
6755  Provide the string of the negated boolean value associated to the boolean
6756  given as a string. Returns False if the passed string does not correctly
6757  represent a boolean.
6758 ***************************************************************************/
6759
6760 bool lp_invert_boolean(const char *str, const char **inverse_str)
6761 {
6762         bool val;
6763
6764         if (!set_boolean(str, &val)) {
6765                 return False;
6766         }
6767
6768         *inverse_str = get_boolean(!val);
6769         return True;
6770 }
6771
6772 /***************************************************************************
6773  Provide the canonical string representation of a boolean value given
6774  as a string. Return True on success, False if the string given does
6775  not correctly represent a boolean.
6776 ***************************************************************************/
6777
6778 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6779 {
6780         bool val;
6781
6782         if (!set_boolean(str, &val)) {
6783                 return False;
6784         }
6785
6786         *canon_str = get_boolean(val);
6787         return True;
6788 }
6789
6790 /***************************************************************************
6791 Find a service by name. Otherwise works like get_service.
6792 ***************************************************************************/
6793
6794 static int getservicebyname(const char *pszServiceName, struct service *pserviceDest)
6795 {
6796         int iService = -1;
6797         char *canon_name;
6798         TDB_DATA data;
6799
6800         if (ServiceHash == NULL) {
6801                 return -1;
6802         }
6803
6804         canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
6805
6806         data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
6807
6808         if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
6809                 iService = *(int *)data.dptr;
6810         }
6811
6812         TALLOC_FREE(canon_name);
6813
6814         if ((iService != -1) && (LP_SNUM_OK(iService))
6815             && (pserviceDest != NULL)) {
6816                 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6817         }
6818
6819         return (iService);
6820 }
6821
6822 /***************************************************************************
6823  Copy a service structure to another.
6824  If pcopymapDest is NULL then copy all fields
6825 ***************************************************************************/
6826
6827 /**
6828  * Add a parametric option to a param_opt_struct,
6829  * replacing old value, if already present.
6830  */
6831 static void set_param_opt(struct param_opt_struct **opt_list,
6832                           const char *opt_name,
6833                           const char *opt_value)
6834 {
6835         struct param_opt_struct *new_opt, *opt;
6836         bool not_added;
6837
6838         if (opt_list == NULL) {
6839                 return;
6840         }
6841
6842         opt = *opt_list;
6843         not_added = true;
6844
6845         /* Traverse destination */
6846         while (opt) {
6847                 /* If we already have same option, override it */
6848                 if (strwicmp(opt->key, opt_name) == 0) {
6849                         string_free(&opt->value);
6850                         TALLOC_FREE(opt->list);
6851                         opt->value = SMB_STRDUP(opt_value);
6852                         not_added = false;
6853                         break;
6854                 }
6855                 opt = opt->next;
6856         }
6857         if (not_added) {
6858             new_opt = SMB_XMALLOC_P(struct param_opt_struct);
6859             new_opt->key = SMB_STRDUP(opt_name);
6860             new_opt->value = SMB_STRDUP(opt_value);
6861             new_opt->list = NULL;
6862             DLIST_ADD(*opt_list, new_opt);
6863         }
6864 }
6865
6866 static void copy_service(struct service *pserviceDest, struct service *pserviceSource,
6867                          struct bitmap *pcopymapDest)
6868 {
6869         int i;
6870         bool bcopyall = (pcopymapDest == NULL);
6871         struct param_opt_struct *data;
6872
6873         for (i = 0; parm_table[i].label; i++)
6874                 if (parm_table[i].ptr && parm_table[i].p_class == P_LOCAL &&
6875                     (bcopyall || bitmap_query(pcopymapDest,i))) {
6876                         void *def_ptr = parm_table[i].ptr;
6877                         void *src_ptr =
6878                                 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
6879                                                                     &sDefault);
6880                         void *dest_ptr =
6881                                 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
6882                                                                   &sDefault);
6883
6884                         switch (parm_table[i].type) {
6885                                 case P_BOOL:
6886                                 case P_BOOLREV:
6887                                         *(bool *)dest_ptr = *(bool *)src_ptr;
6888                                         break;
6889
6890                                 case P_INTEGER:
6891                                 case P_ENUM:
6892                                 case P_OCTAL:
6893                                         *(int *)dest_ptr = *(int *)src_ptr;
6894                                         break;
6895
6896                                 case P_CHAR:
6897                                         *(char *)dest_ptr = *(char *)src_ptr;
6898                                         break;
6899
6900                                 case P_STRING:
6901                                         string_set((char **)dest_ptr,
6902                                                    *(char **)src_ptr);
6903                                         break;
6904
6905                                 case P_USTRING:
6906                                         string_set((char **)dest_ptr,
6907                                                    *(char **)src_ptr);
6908                                         strupper_m(*(char **)dest_ptr);
6909                                         break;
6910                                 case P_LIST:
6911                                         TALLOC_FREE(*((char ***)dest_ptr));
6912                                         *((char ***)dest_ptr) = str_list_copy(NULL, 
6913                                                       *(const char ***)src_ptr);
6914                                         break;
6915                                 default:
6916                                         break;
6917                         }
6918                 }
6919
6920         if (bcopyall) {
6921                 init_copymap(pserviceDest);
6922                 if (pserviceSource->copymap)
6923                         bitmap_copy(pserviceDest->copymap,
6924                                     pserviceSource->copymap);
6925         }
6926
6927         data = pserviceSource->param_opt;
6928         while (data) {
6929                 set_param_opt(&pserviceDest->param_opt, data->key, data->value);
6930                 data = data->next;
6931         }
6932 }
6933
6934 /***************************************************************************
6935 Check a service for consistency. Return False if the service is in any way
6936 incomplete or faulty, else True.
6937 ***************************************************************************/
6938
6939 bool service_ok(int iService)
6940 {
6941         bool bRetval;
6942
6943         bRetval = True;
6944         if (ServicePtrs[iService]->szService[0] == '\0') {
6945                 DEBUG(0, ("The following message indicates an internal error:\n"));
6946                 DEBUG(0, ("No service name in service entry.\n"));
6947                 bRetval = False;
6948         }
6949
6950         /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6951         /* I can't see why you'd want a non-printable printer service...        */
6952         if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6953                 if (!ServicePtrs[iService]->bPrint_ok) {
6954                         DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6955                                ServicePtrs[iService]->szService));
6956                         ServicePtrs[iService]->bPrint_ok = True;
6957                 }
6958                 /* [printers] service must also be non-browsable. */
6959                 if (ServicePtrs[iService]->bBrowseable)
6960                         ServicePtrs[iService]->bBrowseable = False;
6961         }
6962
6963         if (ServicePtrs[iService]->szPath[0] == '\0' &&
6964             strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6965             ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6966             ) {
6967                 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6968                         ServicePtrs[iService]->szService));
6969                 ServicePtrs[iService]->bAvailable = False;
6970         }
6971
6972         /* If a service is flagged unavailable, log the fact at level 1. */
6973         if (!ServicePtrs[iService]->bAvailable)
6974                 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6975                           ServicePtrs[iService]->szService));
6976
6977         return (bRetval);
6978 }
6979
6980 static struct smbconf_ctx *lp_smbconf_ctx(void)
6981 {
6982         WERROR werr;
6983         static struct smbconf_ctx *conf_ctx = NULL;
6984
6985         if (conf_ctx == NULL) {
6986                 werr = smbconf_init(NULL, &conf_ctx, "registry:");
6987                 if (!W_ERROR_IS_OK(werr)) {
6988                         DEBUG(1, ("error initializing registry configuration: "
6989                                   "%s\n", win_errstr(werr)));
6990                         conf_ctx = NULL;
6991                 }
6992         }
6993
6994         return conf_ctx;
6995 }
6996
6997 static bool process_smbconf_service(struct smbconf_service *service)
6998 {
6999         uint32_t count;
7000         bool ret;
7001
7002         if (service == NULL) {
7003                 return false;
7004         }
7005
7006         ret = do_section(service->name, NULL);
7007         if (ret != true) {
7008                 return false;
7009         }
7010         for (count = 0; count < service->num_params; count++) {
7011                 ret = do_parameter(service->param_names[count],
7012                                    service->param_values[count],
7013                                    NULL);
7014                 if (ret != true) {
7015                         return false;
7016                 }
7017         }
7018         if (iServiceIndex >= 0) {
7019                 return service_ok(iServiceIndex);
7020         }
7021         return true;
7022 }
7023
7024 /**
7025  * load a service from registry and activate it
7026  */
7027 bool process_registry_service(const char *service_name)
7028 {
7029         WERROR werr;
7030         struct smbconf_service *service = NULL;
7031         TALLOC_CTX *mem_ctx = talloc_stackframe();
7032         struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7033         bool ret = false;
7034
7035         if (conf_ctx == NULL) {
7036                 goto done;
7037         }
7038
7039         DEBUG(5, ("process_registry_service: service name %s\n", service_name));
7040
7041         if (!smbconf_share_exists(conf_ctx, service_name)) {
7042                 /*
7043                  * Registry does not contain data for this service (yet),
7044                  * but make sure lp_load doesn't return false.
7045                  */
7046                 ret = true;
7047                 goto done;
7048         }
7049
7050         werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
7051         if (!W_ERROR_IS_OK(werr)) {
7052                 goto done;
7053         }
7054
7055         ret = process_smbconf_service(service);
7056         if (!ret) {
7057                 goto done;
7058         }
7059
7060         /* store the csn */
7061         smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
7062
7063 done:
7064         TALLOC_FREE(mem_ctx);
7065         return ret;
7066 }
7067
7068 /*
7069  * process_registry_globals
7070  */
7071 static bool process_registry_globals(void)
7072 {
7073         bool ret;
7074
7075         add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
7076
7077         ret = do_parameter("registry shares", "yes", NULL);
7078         if (!ret) {
7079                 return ret;
7080         }
7081
7082         return process_registry_service(GLOBAL_NAME);
7083 }
7084
7085 bool process_registry_shares(void)
7086 {
7087         WERROR werr;
7088         uint32_t count;
7089         struct smbconf_service **service = NULL;
7090         uint32_t num_shares = 0;
7091         TALLOC_CTX *mem_ctx = talloc_stackframe();
7092         struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7093         bool ret = false;
7094
7095         if (conf_ctx == NULL) {
7096                 goto done;
7097         }
7098
7099         werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
7100         if (!W_ERROR_IS_OK(werr)) {
7101                 goto done;
7102         }
7103
7104         ret = true;
7105
7106         for (count = 0; count < num_shares; count++) {
7107                 if (strequal(service[count]->name, GLOBAL_NAME)) {
7108                         continue;
7109                 }
7110                 ret = process_smbconf_service(service[count]);
7111                 if (!ret) {
7112                         goto done;
7113                 }
7114         }
7115
7116         /* store the csn */
7117         smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
7118
7119 done:
7120         TALLOC_FREE(mem_ctx);
7121         return ret;
7122 }
7123
7124 #define MAX_INCLUDE_DEPTH 100
7125
7126 static uint8_t include_depth;
7127
7128 static struct file_lists {
7129         struct file_lists *next;
7130         char *name;
7131         char *subfname;
7132         time_t modtime;
7133 } *file_lists = NULL;
7134
7135 /*******************************************************************
7136  Keep a linked list of all config files so we know when one has changed 
7137  it's date and needs to be reloaded.
7138 ********************************************************************/
7139
7140 static void add_to_file_list(const char *fname, const char *subfname)
7141 {
7142         struct file_lists *f = file_lists;
7143
7144         while (f) {
7145                 if (f->name && !strcmp(f->name, fname))
7146                         break;
7147                 f = f->next;
7148         }
7149
7150         if (!f) {
7151                 f = SMB_MALLOC_P(struct file_lists);
7152                 if (!f)
7153                         return;
7154                 f->next = file_lists;
7155                 f->name = SMB_STRDUP(fname);
7156                 if (!f->name) {
7157                         SAFE_FREE(f);
7158                         return;
7159                 }
7160                 f->subfname = SMB_STRDUP(subfname);
7161                 if (!f->subfname) {
7162                         SAFE_FREE(f->name);
7163                         SAFE_FREE(f);
7164                         return;
7165                 }
7166                 file_lists = f;
7167                 f->modtime = file_modtime(subfname);
7168         } else {
7169                 time_t t = file_modtime(subfname);
7170                 if (t)
7171                         f->modtime = t;
7172         }
7173         return;
7174 }
7175
7176 /**
7177  * Free the file lists
7178  */
7179 static void free_file_list(void)
7180 {
7181         struct file_lists *f;
7182         struct file_lists *next;
7183
7184         f = file_lists;
7185         while( f ) {
7186                 next = f->next;
7187                 SAFE_FREE( f->name );
7188                 SAFE_FREE( f->subfname );
7189                 SAFE_FREE( f );
7190                 f = next;
7191         }
7192         file_lists = NULL;
7193 }
7194
7195
7196 /**
7197  * Utility function for outsiders to check if we're running on registry.
7198  */
7199 bool lp_config_backend_is_registry(void)
7200 {
7201         return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
7202 }
7203
7204 /**
7205  * Utility function to check if the config backend is FILE.
7206  */
7207 bool lp_config_backend_is_file(void)
7208 {
7209         return (lp_config_backend() == CONFIG_BACKEND_FILE);
7210 }
7211
7212 /*******************************************************************
7213  Check if a config file has changed date.
7214 ********************************************************************/
7215
7216 bool lp_file_list_changed(void)
7217 {
7218         struct file_lists *f = file_lists;
7219
7220         DEBUG(6, ("lp_file_list_changed()\n"));
7221
7222         while (f) {
7223                 time_t mod_time;
7224
7225                 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
7226                         struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7227
7228                         if (conf_ctx == NULL) {
7229                                 return false;
7230                         }
7231                         if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
7232                                             NULL))
7233                         {
7234                                 DEBUGADD(6, ("registry config changed\n"));
7235                                 return true;
7236                         }
7237                 } else {
7238                         char *n2 = NULL;
7239                         n2 = talloc_sub_basic(talloc_tos(),
7240                                               get_current_username(),
7241                                               current_user_info.domain,
7242                                               f->name);
7243                         if (!n2) {
7244                                 return false;
7245                         }
7246                         DEBUGADD(6, ("file %s -> %s  last mod_time: %s\n",
7247                                      f->name, n2, ctime(&f->modtime)));
7248
7249                         mod_time = file_modtime(n2);
7250
7251                         if (mod_time &&
7252                             ((f->modtime != mod_time) ||
7253                              (f->subfname == NULL) ||
7254                              (strcmp(n2, f->subfname) != 0)))
7255                         {
7256                                 DEBUGADD(6,
7257                                          ("file %s modified: %s\n", n2,
7258                                           ctime(&mod_time)));
7259                                 f->modtime = mod_time;
7260                                 SAFE_FREE(f->subfname);
7261                                 f->subfname = SMB_STRDUP(n2);
7262                                 TALLOC_FREE(n2);
7263                                 return true;
7264                         }
7265                         TALLOC_FREE(n2);
7266                 }
7267                 f = f->next;
7268         }
7269         return (False);
7270 }
7271
7272
7273 /***************************************************************************
7274  Run standard_sub_basic on netbios name... needed because global_myname
7275  is not accessed through any lp_ macro.
7276  Note: We must *NOT* use string_set() here as ptr points to global_myname.
7277 ***************************************************************************/
7278
7279 static bool handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
7280 {
7281         bool ret;
7282         char *netbios_name = talloc_sub_basic(
7283                 talloc_tos(), get_current_username(), current_user_info.domain,
7284                 pszParmValue);
7285
7286         ret = set_global_myname(netbios_name);
7287         TALLOC_FREE(netbios_name);
7288         string_set(&Globals.szNetbiosName,global_myname());
7289
7290         DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
7291                global_myname()));
7292
7293         return ret;
7294 }
7295
7296 static bool handle_charset(int snum, const char *pszParmValue, char **ptr)
7297 {
7298         if (strcmp(*ptr, pszParmValue) != 0) {
7299                 string_set(ptr, pszParmValue);
7300                 init_iconv();
7301         }
7302         return True;
7303 }
7304
7305
7306
7307 static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
7308 {
7309         bool ret;
7310
7311         ret = set_global_myworkgroup(pszParmValue);
7312         string_set(&Globals.szWorkgroup,lp_workgroup());
7313
7314         return ret;
7315 }
7316
7317 static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
7318 {
7319         bool ret;
7320
7321         ret = set_global_scope(pszParmValue);
7322         string_set(&Globals.szNetbiosScope,global_scope());
7323
7324         return ret;
7325 }
7326
7327 static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
7328 {
7329         TALLOC_FREE(Globals.szNetbiosAliases);
7330         Globals.szNetbiosAliases = str_list_make_v3(talloc_autofree_context(), pszParmValue, NULL);
7331         return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
7332 }
7333
7334 /***************************************************************************
7335  Handle the include operation.
7336 ***************************************************************************/
7337 static bool bAllowIncludeRegistry = true;
7338
7339 static bool handle_include(int snum, const char *pszParmValue, char **ptr)
7340 {
7341         char *fname;
7342
7343         if (include_depth >= MAX_INCLUDE_DEPTH) {
7344                 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
7345                           include_depth));
7346                 return false;
7347         }
7348
7349         if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
7350                 if (!bAllowIncludeRegistry) {
7351                         return true;
7352                 }
7353                 if (bInGlobalSection) {
7354                         bool ret;
7355                         include_depth++;
7356                         ret = process_registry_globals();
7357                         include_depth--;
7358                         return ret;
7359                 } else {
7360                         DEBUG(1, ("\"include = registry\" only effective "
7361                                   "in %s section\n", GLOBAL_NAME));
7362                         return false;
7363                 }
7364         }
7365
7366         fname = talloc_sub_basic(talloc_tos(), get_current_username(),
7367                                  current_user_info.domain,
7368                                  pszParmValue);
7369
7370         add_to_file_list(pszParmValue, fname);
7371
7372         string_set(ptr, fname);
7373
7374         if (file_exist(fname)) {
7375                 bool ret;
7376                 include_depth++;
7377                 ret = pm_process(fname, do_section, do_parameter, NULL);
7378                 include_depth--;
7379                 TALLOC_FREE(fname);
7380                 return ret;
7381         }
7382
7383         DEBUG(2, ("Can't find include file %s\n", fname));
7384         TALLOC_FREE(fname);
7385         return true;
7386 }
7387
7388 /***************************************************************************
7389  Handle the interpretation of the copy parameter.
7390 ***************************************************************************/
7391
7392 static bool handle_copy(int snum, const char *pszParmValue, char **ptr)
7393 {
7394         bool bRetval;
7395         int iTemp;
7396         struct service serviceTemp;
7397
7398         string_set(ptr, pszParmValue);
7399
7400         init_service(&serviceTemp);
7401
7402         bRetval = False;
7403
7404         DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7405
7406         if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7407                 if (iTemp == iServiceIndex) {
7408                         DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7409                 } else {
7410                         copy_service(ServicePtrs[iServiceIndex],
7411                                      &serviceTemp,
7412                                      ServicePtrs[iServiceIndex]->copymap);
7413                         bRetval = True;
7414                 }
7415         } else {
7416                 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7417                 bRetval = False;
7418         }
7419
7420         free_service(&serviceTemp);
7421         return (bRetval);
7422 }
7423
7424 static bool handle_ldap_debug_level(int snum, const char *pszParmValue, char **ptr)
7425 {
7426         Globals.ldap_debug_level = lp_int(pszParmValue);
7427         init_ldap_debugging();
7428         return true;
7429 }
7430
7431 /***************************************************************************
7432  Handle idmap/non unix account uid and gid allocation parameters.  The format of these
7433  parameters is:
7434
7435  [global]
7436
7437         idmap uid = 1000-1999
7438         idmap gid = 700-899
7439
7440  We only do simple parsing checks here.  The strings are parsed into useful
7441  structures in the idmap daemon code.
7442
7443 ***************************************************************************/
7444
7445 /* Some lp_ routines to return idmap [ug]id information */
7446
7447 static uid_t idmap_uid_low, idmap_uid_high;
7448 static gid_t idmap_gid_low, idmap_gid_high;
7449
7450 bool lp_idmap_uid(uid_t *low, uid_t *high)
7451 {
7452         if (idmap_uid_low == 0 || idmap_uid_high == 0)
7453                 return False;
7454
7455         if (low)
7456                 *low = idmap_uid_low;
7457
7458         if (high)
7459                 *high = idmap_uid_high;
7460
7461         return True;
7462 }
7463
7464 bool lp_idmap_gid(gid_t *low, gid_t *high)
7465 {
7466         if (idmap_gid_low == 0 || idmap_gid_high == 0)
7467                 return False;
7468
7469         if (low)
7470                 *low = idmap_gid_low;
7471
7472         if (high)
7473                 *high = idmap_gid_high;
7474
7475         return True;
7476 }
7477
7478 /* Do some simple checks on "idmap [ug]id" parameter values */
7479
7480 static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
7481 {
7482         uint32 low, high;
7483
7484         if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7485                 return False;
7486
7487         /* Parse OK */
7488
7489         string_set(ptr, pszParmValue);
7490
7491         idmap_uid_low = low;
7492         idmap_uid_high = high;
7493
7494         return True;
7495 }
7496
7497 static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
7498 {
7499         uint32 low, high;
7500
7501         if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7502                 return False;
7503
7504         /* Parse OK */
7505
7506         string_set(ptr, pszParmValue);
7507
7508         idmap_gid_low = low;
7509         idmap_gid_high = high;
7510
7511         return True;
7512 }
7513
7514 /***************************************************************************
7515  Handle the DEBUG level list.
7516 ***************************************************************************/
7517
7518 static bool handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
7519 {
7520         string_set(ptr, pszParmValueIn);
7521         return debug_parse_levels(pszParmValueIn);
7522 }
7523
7524 /***************************************************************************
7525  Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7526 ***************************************************************************/
7527
7528 static const char *append_ldap_suffix( const char *str )
7529 {
7530         const char *suffix_string;
7531
7532
7533         suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7534                                         Globals.szLdapSuffix );
7535         if ( !suffix_string ) {
7536                 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7537                 return "";
7538         }
7539
7540         return suffix_string;
7541 }
7542
7543 const char *lp_ldap_machine_suffix(void)
7544 {
7545         if (Globals.szLdapMachineSuffix[0])
7546                 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7547
7548         return lp_string(Globals.szLdapSuffix);
7549 }
7550
7551 const char *lp_ldap_user_suffix(void)
7552 {
7553         if (Globals.szLdapUserSuffix[0])
7554                 return append_ldap_suffix(Globals.szLdapUserSuffix);
7555
7556         return lp_string(Globals.szLdapSuffix);
7557 }
7558
7559 const char *lp_ldap_group_suffix(void)
7560 {
7561         if (Globals.szLdapGroupSuffix[0])
7562                 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7563
7564         return lp_string(Globals.szLdapSuffix);
7565 }
7566
7567 const char *lp_ldap_idmap_suffix(void)
7568 {
7569         if (Globals.szLdapIdmapSuffix[0])
7570                 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7571
7572         return lp_string(Globals.szLdapSuffix);
7573 }
7574
7575 /****************************************************************************
7576  set the value for a P_ENUM
7577  ***************************************************************************/
7578
7579 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7580                               int *ptr )
7581 {
7582         int i;
7583
7584         for (i = 0; parm->enum_list[i].name; i++) {
7585                 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7586                         *ptr = parm->enum_list[i].value;
7587                         return;
7588                 }
7589         }
7590         DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7591                   pszParmValue, parm->label));
7592 }
7593
7594 /***************************************************************************
7595 ***************************************************************************/
7596
7597 static bool handle_printing(int snum, const char *pszParmValue, char **ptr)
7598 {
7599         static int parm_num = -1;
7600         struct service *s;
7601
7602         if ( parm_num == -1 )
7603                 parm_num = map_parameter( "printing" );
7604
7605         lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7606
7607         if ( snum < 0 )
7608                 s = &sDefault;
7609         else
7610                 s = ServicePtrs[snum];
7611
7612         init_printer_values( s );
7613
7614         return True;
7615 }
7616
7617
7618 /***************************************************************************
7619  Initialise a copymap.
7620 ***************************************************************************/
7621
7622 static void init_copymap(struct service *pservice)
7623 {
7624         int i;
7625
7626         TALLOC_FREE(pservice->copymap);
7627
7628         pservice->copymap = bitmap_talloc(talloc_autofree_context(),
7629                                           NUMPARAMETERS);
7630         if (!pservice->copymap)
7631                 DEBUG(0,
7632                       ("Couldn't allocate copymap!! (size %d)\n",
7633                        (int)NUMPARAMETERS));
7634         else
7635                 for (i = 0; i < NUMPARAMETERS; i++)
7636                         bitmap_set(pservice->copymap, i);
7637 }
7638
7639 /***************************************************************************
7640  Return the local pointer to a parameter given a service struct and the
7641  pointer into the default structure.
7642 ***************************************************************************/
7643
7644 static void *lp_local_ptr(struct service *service, void *ptr)
7645 {
7646         return (void *)(((char *)service) + PTR_DIFF(ptr, &sDefault));
7647 }
7648
7649 /***************************************************************************
7650  Return the local pointer to a parameter given the service number and the 
7651  pointer into the default structure.
7652 ***************************************************************************/
7653
7654 void *lp_local_ptr_by_snum(int snum, void *ptr)
7655 {
7656         return lp_local_ptr(ServicePtrs[snum], ptr);
7657 }
7658
7659 /***************************************************************************
7660  Process a parameter for a particular service number. If snum < 0
7661  then assume we are in the globals.
7662 ***************************************************************************/
7663
7664 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7665 {
7666         int parmnum, i;
7667         void *parm_ptr = NULL;  /* where we are going to store the result */
7668         void *def_ptr = NULL;
7669         struct param_opt_struct **opt_list;
7670
7671         parmnum = map_parameter(pszParmName);
7672
7673         if (parmnum < 0) {
7674                 if (strchr(pszParmName, ':') == NULL) {
7675                         DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7676                                   pszParmName));
7677                         return (True);
7678                 }
7679
7680                 /*
7681                  * We've got a parametric option
7682                  */
7683
7684                 opt_list = (snum < 0)
7685                         ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7686                 set_param_opt(opt_list, pszParmName, pszParmValue);
7687
7688                 return (True);
7689         }
7690
7691         if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7692                 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7693                           pszParmName));
7694         }
7695
7696         def_ptr = parm_table[parmnum].ptr;
7697
7698         /* we might point at a service, the default service or a global */
7699         if (snum < 0) {
7700                 parm_ptr = def_ptr;
7701         } else {
7702                 if (parm_table[parmnum].p_class == P_GLOBAL) {
7703                         DEBUG(0,
7704                               ("Global parameter %s found in service section!\n",
7705                                pszParmName));
7706                         return (True);
7707                 }
7708                 parm_ptr = lp_local_ptr_by_snum(snum, def_ptr);
7709         }
7710
7711         if (snum >= 0) {
7712                 if (!ServicePtrs[snum]->copymap)
7713                         init_copymap(ServicePtrs[snum]);
7714
7715                 /* this handles the aliases - set the copymap for other entries with
7716                    the same data pointer */
7717                 for (i = 0; parm_table[i].label; i++)
7718                         if (parm_table[i].ptr == parm_table[parmnum].ptr)
7719                                 bitmap_clear(ServicePtrs[snum]->copymap, i);
7720         }
7721
7722         /* if it is a special case then go ahead */
7723         if (parm_table[parmnum].special) {
7724                 return parm_table[parmnum].special(snum, pszParmValue,
7725                                                    (char **)parm_ptr);
7726         }
7727
7728         /* now switch on the type of variable it is */
7729         switch (parm_table[parmnum].type)
7730         {
7731                 case P_BOOL:
7732                         *(bool *)parm_ptr = lp_bool(pszParmValue);
7733                         break;
7734
7735                 case P_BOOLREV:
7736                         *(bool *)parm_ptr = !lp_bool(pszParmValue);
7737                         break;
7738
7739                 case P_INTEGER:
7740                         *(int *)parm_ptr = lp_int(pszParmValue);
7741                         break;
7742
7743                 case P_CHAR:
7744                         *(char *)parm_ptr = *pszParmValue;
7745                         break;
7746
7747                 case P_OCTAL:
7748                         i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7749                         if ( i != 1 ) {
7750                             DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7751                         }
7752                         break;
7753
7754                 case P_LIST:
7755                         TALLOC_FREE(*((char ***)parm_ptr));
7756                         *(char ***)parm_ptr = str_list_make_v3(
7757                                 talloc_autofree_context(), pszParmValue, NULL);
7758                         break;
7759
7760                 case P_STRING:
7761                         string_set((char **)parm_ptr, pszParmValue);
7762                         break;
7763
7764                 case P_USTRING:
7765                         string_set((char **)parm_ptr, pszParmValue);
7766                         strupper_m(*(char **)parm_ptr);
7767                         break;
7768
7769                 case P_ENUM:
7770                         lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7771                         break;
7772                 case P_SEP:
7773                         break;
7774         }
7775
7776         return (True);
7777 }
7778
7779 /***************************************************************************
7780  Process a parameter.
7781 ***************************************************************************/
7782
7783 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7784                          void *userdata)
7785 {
7786         if (!bInGlobalSection && bGlobalOnly)
7787                 return (True);
7788
7789         DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7790
7791         return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7792                                 pszParmName, pszParmValue));
7793 }
7794
7795 /***************************************************************************
7796  Print a parameter of the specified type.
7797 ***************************************************************************/
7798
7799 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7800 {
7801         int i;
7802         switch (p->type)
7803         {
7804                 case P_ENUM:
7805                         for (i = 0; p->enum_list[i].name; i++) {
7806                                 if (*(int *)ptr == p->enum_list[i].value) {
7807                                         fprintf(f, "%s",
7808                                                 p->enum_list[i].name);
7809                                         break;
7810                                 }
7811                         }
7812                         break;
7813
7814                 case P_BOOL:
7815                         fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7816                         break;
7817
7818                 case P_BOOLREV:
7819                         fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7820                         break;
7821
7822                 case P_INTEGER:
7823                         fprintf(f, "%d", *(int *)ptr);
7824                         break;
7825
7826                 case P_CHAR:
7827                         fprintf(f, "%c", *(char *)ptr);
7828                         break;
7829
7830                 case P_OCTAL: {
7831                         char *o = octal_string(*(int *)ptr);
7832                         fprintf(f, "%s", o);
7833                         TALLOC_FREE(o);
7834                         break;
7835                 }
7836
7837                 case P_LIST:
7838                         if ((char ***)ptr && *(char ***)ptr) {
7839                                 char **list = *(char ***)ptr;
7840                                 for (; *list; list++) {
7841                                         /* surround strings with whitespace in double quotes */
7842                                         if ( strchr_m( *list, ' ' ) )
7843                                                 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
7844                                         else
7845                                                 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
7846                                 }
7847                         }
7848                         break;
7849
7850                 case P_STRING:
7851                 case P_USTRING:
7852                         if (*(char **)ptr) {
7853                                 fprintf(f, "%s", *(char **)ptr);
7854                         }
7855                         break;
7856                 case P_SEP:
7857                         break;
7858         }
7859 }
7860
7861 /***************************************************************************
7862  Check if two parameters are equal.
7863 ***************************************************************************/
7864
7865 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7866 {
7867         switch (type) {
7868                 case P_BOOL:
7869                 case P_BOOLREV:
7870                         return (*((bool *)ptr1) == *((bool *)ptr2));
7871
7872                 case P_INTEGER:
7873                 case P_ENUM:
7874                 case P_OCTAL:
7875                         return (*((int *)ptr1) == *((int *)ptr2));
7876
7877                 case P_CHAR:
7878                         return (*((char *)ptr1) == *((char *)ptr2));
7879
7880                 case P_LIST:
7881                         return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7882
7883                 case P_STRING:
7884                 case P_USTRING:
7885                 {
7886                         char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7887                         if (p1 && !*p1)
7888                                 p1 = NULL;
7889                         if (p2 && !*p2)
7890                                 p2 = NULL;
7891                         return (p1 == p2 || strequal(p1, p2));
7892                 }
7893                 case P_SEP:
7894                         break;
7895         }
7896         return (False);
7897 }
7898
7899 /***************************************************************************
7900  Initialize any local varients in the sDefault table.
7901 ***************************************************************************/
7902
7903 void init_locals(void)
7904 {
7905         /* None as yet. */
7906 }
7907
7908 /***************************************************************************
7909  Process a new section (service). At this stage all sections are services.
7910  Later we'll have special sections that permit server parameters to be set.
7911  Returns True on success, False on failure. 
7912 ***************************************************************************/
7913
7914 static bool do_section(const char *pszSectionName, void *userdata)
7915 {
7916         bool bRetval;
7917         bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7918                          (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7919         bRetval = False;
7920
7921         /* if we were in a global section then do the local inits */
7922         if (bInGlobalSection && !isglobal)
7923                 init_locals();
7924
7925         /* if we've just struck a global section, note the fact. */
7926         bInGlobalSection = isglobal;
7927
7928         /* check for multiple global sections */
7929         if (bInGlobalSection) {
7930                 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7931                 return (True);
7932         }
7933
7934         if (!bInGlobalSection && bGlobalOnly)
7935                 return (True);
7936
7937         /* if we have a current service, tidy it up before moving on */
7938         bRetval = True;
7939
7940         if (iServiceIndex >= 0)
7941                 bRetval = service_ok(iServiceIndex);
7942
7943         /* if all is still well, move to the next record in the services array */
7944         if (bRetval) {
7945                 /* We put this here to avoid an odd message order if messages are */
7946                 /* issued by the post-processing of a previous section. */
7947                 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7948
7949                 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
7950                     < 0) {
7951                         DEBUG(0, ("Failed to add a new service\n"));
7952                         return (False);
7953                 }
7954         }
7955
7956         return (bRetval);
7957 }
7958
7959
7960 /***************************************************************************
7961  Determine if a partcular base parameter is currentl set to the default value.
7962 ***************************************************************************/
7963
7964 static bool is_default(int i)
7965 {
7966         if (!defaults_saved)
7967                 return False;
7968         switch (parm_table[i].type) {
7969                 case P_LIST:
7970                         return str_list_equal((const char **)parm_table[i].def.lvalue, 
7971                                                 *(const char ***)parm_table[i].ptr);
7972                 case P_STRING:
7973                 case P_USTRING:
7974                         return strequal(parm_table[i].def.svalue,
7975                                         *(char **)parm_table[i].ptr);
7976                 case P_BOOL:
7977                 case P_BOOLREV:
7978                         return parm_table[i].def.bvalue ==
7979                                 *(bool *)parm_table[i].ptr;
7980                 case P_CHAR:
7981                         return parm_table[i].def.cvalue ==
7982                                 *(char *)parm_table[i].ptr;
7983                 case P_INTEGER:
7984                 case P_OCTAL:
7985                 case P_ENUM:
7986                         return parm_table[i].def.ivalue ==
7987                                 *(int *)parm_table[i].ptr;
7988                 case P_SEP:
7989                         break;
7990         }
7991         return False;
7992 }
7993
7994 /***************************************************************************
7995 Display the contents of the global structure.
7996 ***************************************************************************/
7997
7998 static void dump_globals(FILE *f)
7999 {
8000         int i;
8001         struct param_opt_struct *data;
8002
8003         fprintf(f, "[global]\n");
8004
8005         for (i = 0; parm_table[i].label; i++)
8006                 if (parm_table[i].p_class == P_GLOBAL &&
8007                     !(parm_table[i].flags & FLAG_META) &&
8008                     parm_table[i].ptr &&
8009                     (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
8010                         if (defaults_saved && is_default(i))
8011                                 continue;
8012                         fprintf(f, "\t%s = ", parm_table[i].label);
8013                         print_parameter(&parm_table[i], parm_table[i].ptr, f);
8014                         fprintf(f, "\n");
8015         }
8016         if (Globals.param_opt != NULL) {
8017                 data = Globals.param_opt;
8018                 while(data) {
8019                         fprintf(f, "\t%s = %s\n", data->key, data->value);
8020                         data = data->next;
8021                 }
8022         }
8023
8024 }
8025
8026 /***************************************************************************
8027  Return True if a local parameter is currently set to the global default.
8028 ***************************************************************************/
8029
8030 bool lp_is_default(int snum, struct parm_struct *parm)
8031 {
8032         int pdiff = PTR_DIFF(parm->ptr, &sDefault);
8033
8034         return equal_parameter(parm->type,
8035                                ((char *)ServicePtrs[snum]) + pdiff,
8036                                ((char *)&sDefault) + pdiff);
8037 }
8038
8039 /***************************************************************************
8040  Display the contents of a single services record.
8041 ***************************************************************************/
8042
8043 static void dump_a_service(struct service *pService, FILE * f)
8044 {
8045         int i;
8046         struct param_opt_struct *data;
8047
8048         if (pService != &sDefault)
8049                 fprintf(f, "[%s]\n", pService->szService);
8050
8051         for (i = 0; parm_table[i].label; i++) {
8052
8053                 if (parm_table[i].p_class == P_LOCAL &&
8054                     !(parm_table[i].flags & FLAG_META) &&
8055                     parm_table[i].ptr &&
8056                     (*parm_table[i].label != '-') &&
8057                     (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) 
8058                 {
8059                         int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
8060
8061                         if (pService == &sDefault) {
8062                                 if (defaults_saved && is_default(i))
8063                                         continue;
8064                         } else {
8065                                 if (equal_parameter(parm_table[i].type,
8066                                                     ((char *)pService) +
8067                                                     pdiff,
8068                                                     ((char *)&sDefault) +
8069                                                     pdiff))
8070                                         continue;
8071                         }
8072
8073                         fprintf(f, "\t%s = ", parm_table[i].label);
8074                         print_parameter(&parm_table[i],
8075                                         ((char *)pService) + pdiff, f);
8076                         fprintf(f, "\n");
8077                 }
8078         }
8079
8080                 if (pService->param_opt != NULL) {
8081                         data = pService->param_opt;
8082                         while(data) {
8083                                 fprintf(f, "\t%s = %s\n", data->key, data->value);
8084                                 data = data->next;
8085                         }
8086                 }
8087 }
8088
8089 /***************************************************************************
8090  Display the contents of a parameter of a single services record.
8091 ***************************************************************************/
8092
8093 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
8094 {
8095         int i;
8096         bool result = False;
8097         parm_class p_class;
8098         unsigned flag = 0;
8099         fstring local_parm_name;
8100         char *parm_opt;
8101         const char *parm_opt_value;
8102
8103         /* check for parametrical option */
8104         fstrcpy( local_parm_name, parm_name);
8105         parm_opt = strchr( local_parm_name, ':');
8106
8107         if (parm_opt) {
8108                 *parm_opt = '\0';
8109                 parm_opt++;
8110                 if (strlen(parm_opt)) {
8111                         parm_opt_value = lp_parm_const_string( snum,
8112                                 local_parm_name, parm_opt, NULL);
8113                         if (parm_opt_value) {
8114                                 printf( "%s\n", parm_opt_value);
8115                                 result = True;
8116                         }
8117                 }
8118                 return result;
8119         }
8120
8121         /* check for a key and print the value */
8122         if (isGlobal) {
8123                 p_class = P_GLOBAL;
8124                 flag = FLAG_GLOBAL;
8125         } else
8126                 p_class = P_LOCAL;
8127
8128         for (i = 0; parm_table[i].label; i++) {
8129                 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
8130                     !(parm_table[i].flags & FLAG_META) &&
8131                     (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
8132                     parm_table[i].ptr &&
8133                     (*parm_table[i].label != '-') &&
8134                     (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) 
8135                 {
8136                         void *ptr;
8137
8138                         if (isGlobal) {
8139                                 ptr = parm_table[i].ptr;
8140                         } else {
8141                                 struct service *pService = ServicePtrs[snum];
8142                                 ptr = ((char *)pService) +
8143                                         PTR_DIFF(parm_table[i].ptr, &sDefault);
8144                         }
8145
8146                         print_parameter(&parm_table[i],
8147                                         ptr, f);
8148                         fprintf(f, "\n");
8149                         result = True;
8150                         break;
8151                 }
8152         }
8153
8154         return result;
8155 }
8156
8157 /***************************************************************************
8158  Return info about the requested parameter (given as a string).
8159  Return NULL when the string is not a valid parameter name.
8160 ***************************************************************************/
8161
8162 struct parm_struct *lp_get_parameter(const char *param_name)
8163 {
8164         int num = map_parameter(param_name);
8165
8166         if (num < 0) {
8167                 return NULL;
8168         }
8169
8170         return &parm_table[num];
8171 }
8172
8173 /***************************************************************************
8174  Return info about the next parameter in a service.
8175  snum==GLOBAL_SECTION_SNUM gives the globals.
8176  Return NULL when out of parameters.
8177 ***************************************************************************/
8178
8179 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
8180 {
8181         if (snum < 0) {
8182                 /* do the globals */
8183                 for (; parm_table[*i].label; (*i)++) {
8184                         if (parm_table[*i].p_class == P_SEPARATOR)
8185                                 return &parm_table[(*i)++];
8186
8187                         if (!parm_table[*i].ptr
8188                             || (*parm_table[*i].label == '-'))
8189                                 continue;
8190
8191                         if ((*i) > 0
8192                             && (parm_table[*i].ptr ==
8193                                 parm_table[(*i) - 1].ptr))
8194                                 continue;
8195
8196                         if (is_default(*i) && !allparameters)
8197                                 continue;
8198
8199                         return &parm_table[(*i)++];
8200                 }
8201         } else {
8202                 struct service *pService = ServicePtrs[snum];
8203
8204                 for (; parm_table[*i].label; (*i)++) {
8205                         if (parm_table[*i].p_class == P_SEPARATOR)
8206                                 return &parm_table[(*i)++];
8207
8208                         if (parm_table[*i].p_class == P_LOCAL &&
8209                             parm_table[*i].ptr &&
8210                             (*parm_table[*i].label != '-') &&
8211                             ((*i) == 0 ||
8212                              (parm_table[*i].ptr !=
8213                               parm_table[(*i) - 1].ptr)))
8214                         {
8215                                 int pdiff =
8216                                         PTR_DIFF(parm_table[*i].ptr,
8217                                                  &sDefault);
8218
8219                                 if (allparameters ||
8220                                     !equal_parameter(parm_table[*i].type,
8221                                                      ((char *)pService) +
8222                                                      pdiff,
8223                                                      ((char *)&sDefault) +
8224                                                      pdiff))
8225                                 {
8226                                         return &parm_table[(*i)++];
8227                                 }
8228                         }
8229                 }
8230         }
8231
8232         return NULL;
8233 }
8234
8235
8236 #if 0
8237 /***************************************************************************
8238  Display the contents of a single copy structure.
8239 ***************************************************************************/
8240 static void dump_copy_map(bool *pcopymap)
8241 {
8242         int i;
8243         if (!pcopymap)
8244                 return;
8245
8246         printf("\n\tNon-Copied parameters:\n");
8247
8248         for (i = 0; parm_table[i].label; i++)
8249                 if (parm_table[i].p_class == P_LOCAL &&
8250                     parm_table[i].ptr && !pcopymap[i] &&
8251                     (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8252                 {
8253                         printf("\t\t%s\n", parm_table[i].label);
8254                 }
8255 }
8256 #endif
8257
8258 /***************************************************************************
8259  Return TRUE if the passed service number is within range.
8260 ***************************************************************************/
8261
8262 bool lp_snum_ok(int iService)
8263 {
8264         return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8265 }
8266
8267 /***************************************************************************
8268  Auto-load some home services.
8269 ***************************************************************************/
8270
8271 static void lp_add_auto_services(char *str)
8272 {
8273         char *s;
8274         char *p;
8275         int homes;
8276         char *saveptr;
8277
8278         if (!str)
8279                 return;
8280
8281         s = SMB_STRDUP(str);
8282         if (!s)
8283                 return;
8284
8285         homes = lp_servicenumber(HOMES_NAME);
8286
8287         for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8288              p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8289                 char *home;
8290
8291                 if (lp_servicenumber(p) >= 0)
8292                         continue;
8293
8294                 home = get_user_home_dir(talloc_tos(), p);
8295
8296                 if (home && home[0] && homes >= 0)
8297                         lp_add_home(p, homes, p, home);
8298
8299                 TALLOC_FREE(home);
8300         }
8301         SAFE_FREE(s);
8302 }
8303
8304 /***************************************************************************
8305  Auto-load one printer.
8306 ***************************************************************************/
8307
8308 void lp_add_one_printer(const char *name, const char *comment, void *pdata)
8309 {
8310         int printers = lp_servicenumber(PRINTERS_NAME);
8311         int i;
8312
8313         if (lp_servicenumber(name) < 0) {
8314                 lp_add_printer(name, printers);
8315                 if ((i = lp_servicenumber(name)) >= 0) {
8316                         string_set(&ServicePtrs[i]->comment, comment);
8317                         ServicePtrs[i]->autoloaded = True;
8318                 }
8319         }
8320 }
8321
8322 /***************************************************************************
8323  Have we loaded a services file yet?
8324 ***************************************************************************/
8325
8326 bool lp_loaded(void)
8327 {
8328         return (bLoaded);
8329 }
8330
8331 /***************************************************************************
8332  Unload unused services.
8333 ***************************************************************************/
8334
8335 void lp_killunused(bool (*snumused) (int))
8336 {
8337         int i;
8338         for (i = 0; i < iNumServices; i++) {
8339                 if (!VALID(i))
8340                         continue;
8341
8342                 /* don't kill autoloaded or usershare services */
8343                 if ( ServicePtrs[i]->autoloaded ||
8344                                 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8345                         continue;
8346                 }
8347
8348                 if (!snumused || !snumused(i)) {
8349                         free_service_byindex(i);
8350                 }
8351         }
8352 }
8353
8354 /**
8355  * Kill all except autoloaded and usershare services - convenience wrapper
8356  */
8357 void lp_kill_all_services(void)
8358 {
8359         lp_killunused(NULL);
8360 }
8361
8362 /***************************************************************************
8363  Unload a service.
8364 ***************************************************************************/
8365
8366 void lp_killservice(int iServiceIn)
8367 {
8368         if (VALID(iServiceIn)) {
8369                 free_service_byindex(iServiceIn);
8370         }
8371 }
8372
8373 /***************************************************************************
8374  Save the curent values of all global and sDefault parameters into the 
8375  defaults union. This allows swat and testparm to show only the
8376  changed (ie. non-default) parameters.
8377 ***************************************************************************/
8378
8379 static void lp_save_defaults(void)
8380 {
8381         int i;
8382         for (i = 0; parm_table[i].label; i++) {
8383                 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
8384                         continue;
8385                 switch (parm_table[i].type) {
8386                         case P_LIST:
8387                                 parm_table[i].def.lvalue = str_list_copy(
8388                                         NULL, *(const char ***)parm_table[i].ptr);
8389                                 break;
8390                         case P_STRING:
8391                         case P_USTRING:
8392                                 if (parm_table[i].ptr) {
8393                                         parm_table[i].def.svalue = SMB_STRDUP(*(char **)parm_table[i].ptr);
8394                                 } else {
8395                                         parm_table[i].def.svalue = NULL;
8396                                 }
8397                                 break;
8398                         case P_BOOL:
8399                         case P_BOOLREV:
8400                                 parm_table[i].def.bvalue =
8401                                         *(bool *)parm_table[i].ptr;
8402                                 break;
8403                         case P_CHAR:
8404                                 parm_table[i].def.cvalue =
8405                                         *(char *)parm_table[i].ptr;
8406                                 break;
8407                         case P_INTEGER:
8408                         case P_OCTAL:
8409                         case P_ENUM:
8410                                 parm_table[i].def.ivalue =
8411                                         *(int *)parm_table[i].ptr;
8412                                 break;
8413                         case P_SEP:
8414                                 break;
8415                 }
8416         }
8417         defaults_saved = True;
8418 }
8419
8420 /***********************************************************
8421  If we should send plaintext/LANMAN passwords in the clinet
8422 ************************************************************/
8423
8424 static void set_allowed_client_auth(void)
8425 {
8426         if (Globals.bClientNTLMv2Auth) {
8427                 Globals.bClientLanManAuth = False;
8428         }
8429         if (!Globals.bClientLanManAuth) {
8430                 Globals.bClientPlaintextAuth = False;
8431         }
8432 }
8433
8434 /***************************************************************************
8435  JRA.
8436  The following code allows smbd to read a user defined share file.
8437  Yes, this is my intent. Yes, I'm comfortable with that...
8438
8439  THE FOLLOWING IS SECURITY CRITICAL CODE.
8440
8441  It washes your clothes, it cleans your house, it guards you while you sleep...
8442  Do not f%^k with it....
8443 ***************************************************************************/
8444
8445 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8446
8447 /***************************************************************************
8448  Check allowed stat state of a usershare file.
8449  Ensure we print out who is dicking with us so the admin can
8450  get their sorry ass fired.
8451 ***************************************************************************/
8452
8453 static bool check_usershare_stat(const char *fname,
8454                                  const SMB_STRUCT_STAT *psbuf)
8455 {
8456         if (!S_ISREG(psbuf->st_ex_mode)) {
8457                 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8458                         "not a regular file\n",
8459                         fname, (unsigned int)psbuf->st_ex_uid ));
8460                 return False;
8461         }
8462
8463         /* Ensure this doesn't have the other write bit set. */
8464         if (psbuf->st_ex_mode & S_IWOTH) {
8465                 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8466                         "public write. Refusing to allow as a usershare file.\n",
8467                         fname, (unsigned int)psbuf->st_ex_uid ));
8468                 return False;
8469         }
8470
8471         /* Should be 10k or less. */
8472         if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8473                 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8474                         "too large (%u) to be a user share file.\n",
8475                         fname, (unsigned int)psbuf->st_ex_uid,
8476                         (unsigned int)psbuf->st_ex_size ));
8477                 return False;
8478         }
8479
8480         return True;
8481 }
8482
8483 /***************************************************************************
8484  Parse the contents of a usershare file.
8485 ***************************************************************************/
8486
8487 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8488                         SMB_STRUCT_STAT *psbuf,
8489                         const char *servicename,
8490                         int snum,
8491                         char **lines,
8492                         int numlines,
8493                         char **pp_sharepath,
8494                         char **pp_comment,
8495                         char **pp_cp_servicename,
8496                         struct security_descriptor **ppsd,
8497                         bool *pallow_guest)
8498 {
8499         const char **prefixallowlist = lp_usershare_prefix_allow_list();
8500         const char **prefixdenylist = lp_usershare_prefix_deny_list();
8501         int us_vers;
8502         SMB_STRUCT_DIR *dp;
8503         SMB_STRUCT_STAT sbuf;
8504         char *sharepath = NULL;
8505         char *comment = NULL;
8506
8507         *pp_sharepath = NULL;
8508         *pp_comment = NULL;
8509
8510         *pallow_guest = False;
8511
8512         if (numlines < 4) {
8513                 return USERSHARE_MALFORMED_FILE;
8514         }
8515
8516         if (strcmp(lines[0], "#VERSION 1") == 0) {
8517                 us_vers = 1;
8518         } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8519                 us_vers = 2;
8520                 if (numlines < 5) {
8521                         return USERSHARE_MALFORMED_FILE;
8522                 }
8523         } else {
8524                 return USERSHARE_BAD_VERSION;
8525         }
8526
8527         if (strncmp(lines[1], "path=", 5) != 0) {
8528                 return USERSHARE_MALFORMED_PATH;
8529         }
8530
8531         sharepath = talloc_strdup(ctx, &lines[1][5]);
8532         if (!sharepath) {
8533                 return USERSHARE_POSIX_ERR;
8534         }
8535         trim_string(sharepath, " ", " ");
8536
8537         if (strncmp(lines[2], "comment=", 8) != 0) {
8538                 return USERSHARE_MALFORMED_COMMENT_DEF;
8539         }
8540
8541         comment = talloc_strdup(ctx, &lines[2][8]);
8542         if (!comment) {
8543                 return USERSHARE_POSIX_ERR;
8544         }
8545         trim_string(comment, " ", " ");
8546         trim_char(comment, '"', '"');
8547
8548         if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8549                 return USERSHARE_MALFORMED_ACL_DEF;
8550         }
8551
8552         if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8553                 return USERSHARE_ACL_ERR;
8554         }
8555
8556         if (us_vers == 2) {
8557                 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8558                         return USERSHARE_MALFORMED_ACL_DEF;
8559                 }
8560                 if (lines[4][9] == 'y') {
8561                         *pallow_guest = True;
8562                 }
8563
8564                 /* Backwards compatible extension to file version #2. */
8565                 if (numlines > 5) {
8566                         if (strncmp(lines[5], "sharename=", 10) != 0) {
8567                                 return USERSHARE_MALFORMED_SHARENAME_DEF;
8568                         }
8569                         if (!strequal(&lines[5][10], servicename)) {
8570                                 return USERSHARE_BAD_SHARENAME;
8571                         }
8572                         *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
8573                         if (!*pp_cp_servicename) {
8574                                 return USERSHARE_POSIX_ERR;
8575                         }
8576                 }
8577         }
8578
8579         if (*pp_cp_servicename == NULL) {
8580                 *pp_cp_servicename = talloc_strdup(ctx, servicename);
8581                 if (!*pp_cp_servicename) {
8582                         return USERSHARE_POSIX_ERR;
8583                 }
8584         }
8585
8586         if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8587                 /* Path didn't change, no checks needed. */
8588                 *pp_sharepath = sharepath;
8589                 *pp_comment = comment;
8590                 return USERSHARE_OK;
8591         }
8592
8593         /* The path *must* be absolute. */
8594         if (sharepath[0] != '/') {
8595                 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8596                         servicename, sharepath));
8597                 return USERSHARE_PATH_NOT_ABSOLUTE;
8598         }
8599
8600         /* If there is a usershare prefix deny list ensure one of these paths
8601            doesn't match the start of the user given path. */
8602         if (prefixdenylist) {
8603                 int i;
8604                 for ( i=0; prefixdenylist[i]; i++ ) {
8605                         DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8606                                 servicename, i, prefixdenylist[i], sharepath ));
8607                         if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8608                                 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8609                                         "usershare prefix deny list entries.\n",
8610                                         servicename, sharepath));
8611                                 return USERSHARE_PATH_IS_DENIED;
8612                         }
8613                 }
8614         }
8615
8616         /* If there is a usershare prefix allow list ensure one of these paths
8617            does match the start of the user given path. */
8618
8619         if (prefixallowlist) {
8620                 int i;
8621                 for ( i=0; prefixallowlist[i]; i++ ) {
8622                         DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8623                                 servicename, i, prefixallowlist[i], sharepath ));
8624                         if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8625                                 break;
8626                         }
8627                 }
8628                 if (prefixallowlist[i] == NULL) {
8629                         DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8630                                 "usershare prefix allow list entries.\n",
8631                                 servicename, sharepath));
8632                         return USERSHARE_PATH_NOT_ALLOWED;
8633                 }
8634         }
8635
8636         /* Ensure this is pointing to a directory. */
8637         dp = sys_opendir(sharepath);
8638
8639         if (!dp) {
8640                 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8641                         servicename, sharepath));
8642                 return USERSHARE_PATH_NOT_DIRECTORY;
8643         }
8644
8645         /* Ensure the owner of the usershare file has permission to share
8646            this directory. */
8647
8648         if (sys_stat(sharepath, &sbuf, false) == -1) {
8649                 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8650                         servicename, sharepath, strerror(errno) ));
8651                 sys_closedir(dp);
8652                 return USERSHARE_POSIX_ERR;
8653         }
8654
8655         sys_closedir(dp);
8656
8657         if (!S_ISDIR(sbuf.st_ex_mode)) {
8658                 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8659                         servicename, sharepath ));
8660                 return USERSHARE_PATH_NOT_DIRECTORY;
8661         }
8662
8663         /* Check if sharing is restricted to owner-only. */
8664         /* psbuf is the stat of the usershare definition file,
8665            sbuf is the stat of the target directory to be shared. */
8666
8667         if (lp_usershare_owner_only()) {
8668                 /* root can share anything. */
8669                 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8670                         return USERSHARE_PATH_NOT_ALLOWED;
8671                 }
8672         }
8673
8674         *pp_sharepath = sharepath;
8675         *pp_comment = comment;
8676         return USERSHARE_OK;
8677 }
8678
8679 /***************************************************************************
8680  Deal with a usershare file.
8681  Returns:
8682         >= 0 - snum
8683         -1 - Bad name, invalid contents.
8684            - service name already existed and not a usershare, problem
8685             with permissions to share directory etc.
8686 ***************************************************************************/
8687
8688 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8689 {
8690         SMB_STRUCT_STAT sbuf;
8691         SMB_STRUCT_STAT lsbuf;
8692         char *fname = NULL;
8693         char *sharepath = NULL;
8694         char *comment = NULL;
8695         char *cp_service_name = NULL;
8696         char **lines = NULL;
8697         int numlines = 0;
8698         int fd = -1;
8699         int iService = -1;
8700         TALLOC_CTX *ctx = talloc_stackframe();
8701         struct security_descriptor *psd = NULL;
8702         bool guest_ok = False;
8703         char *canon_name = NULL;
8704         bool added_service = false;
8705         int ret = -1;
8706
8707         /* Ensure share name doesn't contain invalid characters. */
8708         if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8709                 DEBUG(0,("process_usershare_file: share name %s contains "
8710                         "invalid characters (any of %s)\n",
8711                         file_name, INVALID_SHARENAME_CHARS ));
8712                 goto out;
8713         }
8714
8715         canon_name = canonicalize_servicename(ctx, file_name);
8716         if (!canon_name) {
8717                 goto out;
8718         }
8719
8720         fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
8721         if (!fname) {
8722                 goto out;
8723         }
8724
8725         /* Minimize the race condition by doing an lstat before we
8726            open and fstat. Ensure this isn't a symlink link. */
8727
8728         if (sys_lstat(fname, &lsbuf, false) != 0) {
8729                 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8730                         fname, strerror(errno) ));
8731                 goto out;
8732         }
8733
8734         /* This must be a regular file, not a symlink, directory or
8735            other strange filetype. */
8736         if (!check_usershare_stat(fname, &lsbuf)) {
8737                 goto out;
8738         }
8739
8740         {
8741                 TDB_DATA data = dbwrap_fetch_bystring(
8742                         ServiceHash, canon_name, canon_name);
8743
8744                 iService = -1;
8745
8746                 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
8747                         iService = *(int *)data.dptr;
8748                 }
8749         }
8750
8751         if (iService != -1 &&
8752             timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8753                              &lsbuf.st_ex_mtime) == 0) {
8754                 /* Nothing changed - Mark valid and return. */
8755                 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8756                         canon_name ));
8757                 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8758                 ret = iService;
8759                 goto out;
8760         }
8761
8762         /* Try and open the file read only - no symlinks allowed. */
8763 #ifdef O_NOFOLLOW
8764         fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8765 #else
8766         fd = sys_open(fname, O_RDONLY, 0);
8767 #endif
8768
8769         if (fd == -1) {
8770                 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8771                         fname, strerror(errno) ));
8772                 goto out;
8773         }
8774
8775         /* Now fstat to be *SURE* it's a regular file. */
8776         if (sys_fstat(fd, &sbuf, false) != 0) {
8777                 close(fd);
8778                 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8779                         fname, strerror(errno) ));
8780                 goto out;
8781         }
8782
8783         /* Is it the same dev/inode as was lstated ? */
8784         if (lsbuf.st_ex_dev != sbuf.st_ex_dev || lsbuf.st_ex_ino != sbuf.st_ex_ino) {
8785                 close(fd);
8786                 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8787                         "Symlink spoofing going on ?\n", fname ));
8788                 goto out;
8789         }
8790
8791         /* This must be a regular file, not a symlink, directory or
8792            other strange filetype. */
8793         if (!check_usershare_stat(fname, &sbuf)) {
8794                 goto out;
8795         }
8796
8797         lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8798
8799         close(fd);
8800         if (lines == NULL) {
8801                 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8802                         fname, (unsigned int)sbuf.st_ex_uid ));
8803                 goto out;
8804         }
8805
8806         if (parse_usershare_file(ctx, &sbuf, file_name,
8807                         iService, lines, numlines, &sharepath,
8808                         &comment, &cp_service_name,
8809                         &psd, &guest_ok) != USERSHARE_OK) {
8810                 goto out;
8811         }
8812
8813         /* Everything ok - add the service possibly using a template. */
8814         if (iService < 0) {
8815                 const struct service *sp = &sDefault;
8816                 if (snum_template != -1) {
8817                         sp = ServicePtrs[snum_template];
8818                 }
8819
8820                 if ((iService = add_a_service(sp, cp_service_name)) < 0) {
8821                         DEBUG(0, ("process_usershare_file: Failed to add "
8822                                 "new service %s\n", cp_service_name));
8823                         goto out;
8824                 }
8825
8826                 added_service = true;
8827
8828                 /* Read only is controlled by usershare ACL below. */
8829                 ServicePtrs[iService]->bRead_only = False;
8830         }
8831
8832         /* Write the ACL of the new/modified share. */
8833         if (!set_share_security(canon_name, psd)) {
8834                  DEBUG(0, ("process_usershare_file: Failed to set share "
8835                         "security for user share %s\n",
8836                         canon_name ));
8837                 goto out;
8838         }
8839
8840         /* If from a template it may be marked invalid. */
8841         ServicePtrs[iService]->valid = True;
8842
8843         /* Set the service as a valid usershare. */
8844         ServicePtrs[iService]->usershare = USERSHARE_VALID;
8845
8846         /* Set guest access. */
8847         if (lp_usershare_allow_guests()) {
8848                 ServicePtrs[iService]->bGuest_ok = guest_ok;
8849         }
8850
8851         /* And note when it was loaded. */
8852         ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8853         string_set(&ServicePtrs[iService]->szPath, sharepath);
8854         string_set(&ServicePtrs[iService]->comment, comment);
8855
8856         ret = iService;
8857
8858   out:
8859
8860         if (ret == -1 && iService != -1 && added_service) {
8861                 lp_remove_service(iService);
8862         }
8863
8864         TALLOC_FREE(lines);
8865         TALLOC_FREE(ctx);
8866         return ret;
8867 }
8868
8869 /***************************************************************************
8870  Checks if a usershare entry has been modified since last load.
8871 ***************************************************************************/
8872
8873 static bool usershare_exists(int iService, struct timespec *last_mod)
8874 {
8875         SMB_STRUCT_STAT lsbuf;
8876         const char *usersharepath = Globals.szUsersharePath;
8877         char *fname;
8878
8879         if (asprintf(&fname, "%s/%s",
8880                                 usersharepath,
8881                                 ServicePtrs[iService]->szService) < 0) {
8882                 return false;
8883         }
8884
8885         if (sys_lstat(fname, &lsbuf, false) != 0) {
8886                 SAFE_FREE(fname);
8887                 return false;
8888         }
8889
8890         if (!S_ISREG(lsbuf.st_ex_mode)) {
8891                 SAFE_FREE(fname);
8892                 return false;
8893         }
8894
8895         SAFE_FREE(fname);
8896         *last_mod = lsbuf.st_ex_mtime;
8897         return true;
8898 }
8899
8900 /***************************************************************************
8901  Load a usershare service by name. Returns a valid servicenumber or -1.
8902 ***************************************************************************/
8903
8904 int load_usershare_service(const char *servicename)
8905 {
8906         SMB_STRUCT_STAT sbuf;
8907         const char *usersharepath = Globals.szUsersharePath;
8908         int max_user_shares = Globals.iUsershareMaxShares;
8909         int snum_template = -1;
8910
8911         if (*usersharepath == 0 ||  max_user_shares == 0) {
8912                 return -1;
8913         }
8914
8915         if (sys_stat(usersharepath, &sbuf, false) != 0) {
8916                 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8917                         usersharepath, strerror(errno) ));
8918                 return -1;
8919         }
8920
8921         if (!S_ISDIR(sbuf.st_ex_mode)) {
8922                 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8923                         usersharepath ));
8924                 return -1;
8925         }
8926
8927         /*
8928          * This directory must be owned by root, and have the 't' bit set.
8929          * It also must not be writable by "other".
8930          */
8931
8932 #ifdef S_ISVTX
8933         if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8934 #else
8935         if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8936 #endif
8937                 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8938                         "or does not have the sticky bit 't' set or is writable by anyone.\n",
8939                         usersharepath ));
8940                 return -1;
8941         }
8942
8943         /* Ensure the template share exists if it's set. */
8944         if (Globals.szUsershareTemplateShare[0]) {
8945                 /* We can't use lp_servicenumber here as we are recommending that
8946                    template shares have -valid=False set. */
8947                 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8948                         if (ServicePtrs[snum_template]->szService &&
8949                                         strequal(ServicePtrs[snum_template]->szService,
8950                                                 Globals.szUsershareTemplateShare)) {
8951                                 break;
8952                         }
8953                 }
8954
8955                 if (snum_template == -1) {
8956                         DEBUG(0,("load_usershare_service: usershare template share %s "
8957                                 "does not exist.\n",
8958                                 Globals.szUsershareTemplateShare ));
8959                         return -1;
8960                 }
8961         }
8962
8963         return process_usershare_file(usersharepath, servicename, snum_template);
8964 }
8965
8966 /***************************************************************************
8967  Load all user defined shares from the user share directory.
8968  We only do this if we're enumerating the share list.
8969  This is the function that can delete usershares that have
8970  been removed.
8971 ***************************************************************************/
8972
8973 int load_usershare_shares(void)
8974 {
8975         SMB_STRUCT_DIR *dp;
8976         SMB_STRUCT_STAT sbuf;
8977         SMB_STRUCT_DIRENT *de;
8978         int num_usershares = 0;
8979         int max_user_shares = Globals.iUsershareMaxShares;
8980         unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8981         unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8982         unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8983         int iService;
8984         int snum_template = -1;
8985         const char *usersharepath = Globals.szUsersharePath;
8986         int ret = lp_numservices();
8987
8988         if (max_user_shares == 0 || *usersharepath == '\0') {
8989                 return lp_numservices();
8990         }
8991
8992         if (sys_stat(usersharepath, &sbuf, false) != 0) {
8993                 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8994                         usersharepath, strerror(errno) ));
8995                 return ret;
8996         }
8997
8998         /*
8999          * This directory must be owned by root, and have the 't' bit set.
9000          * It also must not be writable by "other".
9001          */
9002
9003 #ifdef S_ISVTX
9004         if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
9005 #else
9006         if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
9007 #endif
9008                 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
9009                         "or does not have the sticky bit 't' set or is writable by anyone.\n",
9010                         usersharepath ));
9011                 return ret;
9012         }
9013
9014         /* Ensure the template share exists if it's set. */
9015         if (Globals.szUsershareTemplateShare[0]) {
9016                 /* We can't use lp_servicenumber here as we are recommending that
9017                    template shares have -valid=False set. */
9018                 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
9019                         if (ServicePtrs[snum_template]->szService &&
9020                                         strequal(ServicePtrs[snum_template]->szService,
9021                                                 Globals.szUsershareTemplateShare)) {
9022                                 break;
9023                         }
9024                 }
9025
9026                 if (snum_template == -1) {
9027                         DEBUG(0,("load_usershare_shares: usershare template share %s "
9028                                 "does not exist.\n",
9029                                 Globals.szUsershareTemplateShare ));
9030                         return ret;
9031                 }
9032         }
9033
9034         /* Mark all existing usershares as pending delete. */
9035         for (iService = iNumServices - 1; iService >= 0; iService--) {
9036                 if (VALID(iService) && ServicePtrs[iService]->usershare) {
9037                         ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
9038                 }
9039         }
9040
9041         dp = sys_opendir(usersharepath);
9042         if (!dp) {
9043                 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
9044                         usersharepath, strerror(errno) ));
9045                 return ret;
9046         }
9047
9048         for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
9049                         (de = sys_readdir(dp));
9050                         num_dir_entries++ ) {
9051                 int r;
9052                 const char *n = de->d_name;
9053
9054                 /* Ignore . and .. */
9055                 if (*n == '.') {
9056                         if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
9057                                 continue;
9058                         }
9059                 }
9060
9061                 if (n[0] == ':') {
9062                         /* Temporary file used when creating a share. */
9063                         num_tmp_dir_entries++;
9064                 }
9065
9066                 /* Allow 20% tmp entries. */
9067                 if (num_tmp_dir_entries > allowed_tmp_entries) {
9068                         DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
9069                                 "in directory %s\n",
9070                                 num_tmp_dir_entries, usersharepath));
9071                         break;
9072                 }
9073
9074                 r = process_usershare_file(usersharepath, n, snum_template);
9075                 if (r == 0) {
9076                         /* Update the services count. */
9077                         num_usershares++;
9078                         if (num_usershares >= max_user_shares) {
9079                                 DEBUG(0,("load_usershare_shares: max user shares reached "
9080                                         "on file %s in directory %s\n",
9081                                         n, usersharepath ));
9082                                 break;
9083                         }
9084                 } else if (r == -1) {
9085                         num_bad_dir_entries++;
9086                 }
9087
9088                 /* Allow 20% bad entries. */
9089                 if (num_bad_dir_entries > allowed_bad_entries) {
9090                         DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
9091                                 "in directory %s\n",
9092                                 num_bad_dir_entries, usersharepath));
9093                         break;
9094                 }
9095
9096                 /* Allow 20% bad entries. */
9097                 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
9098                         DEBUG(0,("load_usershare_shares: too many total entries (%u) "
9099                         "in directory %s\n",
9100                         num_dir_entries, usersharepath));
9101                         break;
9102                 }
9103         }
9104
9105         sys_closedir(dp);
9106
9107         /* Sweep through and delete any non-refreshed usershares that are
9108            not currently in use. */
9109         for (iService = iNumServices - 1; iService >= 0; iService--) {
9110                 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
9111                         if (conn_snum_used(iService)) {
9112                                 continue;
9113                         }
9114                         /* Remove from the share ACL db. */
9115                         DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
9116                                 lp_servicename(iService) ));
9117                         delete_share_security(lp_servicename(iService));
9118                         free_service_byindex(iService);
9119                 }
9120         }
9121
9122         return lp_numservices();
9123 }
9124
9125 /********************************************************
9126  Destroy global resources allocated in this file
9127 ********************************************************/
9128
9129 void gfree_loadparm(void)
9130 {
9131         int i;
9132
9133         free_file_list();
9134
9135         /* Free resources allocated to services */
9136
9137         for ( i = 0; i < iNumServices; i++ ) {
9138                 if ( VALID(i) ) {
9139                         free_service_byindex(i);
9140                 }
9141         }
9142
9143         SAFE_FREE( ServicePtrs );
9144         iNumServices = 0;
9145
9146         /* Now release all resources allocated to global
9147            parameters and the default service */
9148
9149         free_global_parameters();
9150 }
9151
9152
9153 /***************************************************************************
9154  Allow client apps to specify that they are a client
9155 ***************************************************************************/
9156 void lp_set_in_client(bool b)
9157 {
9158     in_client = b;
9159 }
9160
9161
9162 /***************************************************************************
9163  Determine if we're running in a client app
9164 ***************************************************************************/
9165 bool lp_is_in_client(void)
9166 {
9167     return in_client;
9168 }
9169
9170 /***************************************************************************
9171  Load the services array from the services file. Return True on success, 
9172  False on failure.
9173 ***************************************************************************/
9174
9175 bool lp_load_ex(const char *pszFname,
9176                 bool global_only,
9177                 bool save_defaults,
9178                 bool add_ipc,
9179                 bool initialize_globals,
9180                 bool allow_include_registry,
9181                 bool allow_registry_shares)
9182 {
9183         char *n2 = NULL;
9184         bool bRetval;
9185
9186         bRetval = False;
9187
9188         DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
9189
9190         bInGlobalSection = True;
9191         bGlobalOnly = global_only;
9192         bAllowIncludeRegistry = allow_include_registry;
9193
9194         init_globals(! initialize_globals);
9195         debug_init();
9196
9197         free_file_list();
9198
9199         if (save_defaults) {
9200                 init_locals();
9201                 lp_save_defaults();
9202         }
9203
9204         free_param_opts(&Globals.param_opt);
9205
9206         /* We get sections first, so have to start 'behind' to make up */
9207         iServiceIndex = -1;
9208
9209         if (lp_config_backend_is_file()) {
9210                 n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
9211                                         current_user_info.domain,
9212                                         pszFname);
9213                 if (!n2) {
9214                         smb_panic("lp_load_ex: out of memory");
9215                 }
9216
9217                 add_to_file_list(pszFname, n2);
9218
9219                 bRetval = pm_process(n2, do_section, do_parameter, NULL);
9220                 TALLOC_FREE(n2);
9221
9222                 /* finish up the last section */
9223                 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
9224                 if (bRetval) {
9225                         if (iServiceIndex >= 0) {
9226                                 bRetval = service_ok(iServiceIndex);
9227                         }
9228                 }
9229
9230                 if (lp_config_backend_is_registry()) {
9231                         /* config backend changed to registry in config file */
9232                         /*
9233                          * We need to use this extra global variable here to
9234                          * survive restart: init_globals uses this as a default
9235                          * for ConfigBackend. Otherwise, init_globals would
9236                          *  send us into an endless loop here.
9237                          */
9238                         config_backend = CONFIG_BACKEND_REGISTRY;
9239                         /* start over */
9240                         DEBUG(1, ("lp_load_ex: changing to config backend "
9241                                   "registry\n"));
9242                         init_globals(false);
9243                         lp_kill_all_services();
9244                         return lp_load_ex(pszFname, global_only, save_defaults,
9245                                           add_ipc, initialize_globals,
9246                                           allow_include_registry,
9247                                           allow_registry_shares);
9248                 }
9249         } else if (lp_config_backend_is_registry()) {
9250                 bRetval = process_registry_globals();
9251         } else {
9252                 DEBUG(0, ("Illegal config  backend given: %d\n",
9253                           lp_config_backend()));
9254                 bRetval = false;
9255         }
9256
9257         if (bRetval && lp_registry_shares() && allow_registry_shares) {
9258                 bRetval = process_registry_shares();
9259         }
9260
9261         lp_add_auto_services(lp_auto_services());
9262
9263         if (add_ipc) {
9264                 /* When 'restrict anonymous = 2' guest connections to ipc$
9265                    are denied */
9266                 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9267                 if ( lp_enable_asu_support() ) {
9268                         lp_add_ipc("ADMIN$", false);
9269                 }
9270         }
9271
9272         set_server_role();
9273         set_default_server_announce_type();
9274         set_allowed_client_auth();
9275
9276         bLoaded = True;
9277
9278         /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9279         /* if bWINSsupport is true and we are in the client            */
9280         if (lp_is_in_client() && Globals.bWINSsupport) {
9281                 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9282         }
9283
9284         init_iconv();
9285
9286         bAllowIncludeRegistry = true;
9287
9288         return (bRetval);
9289 }
9290
9291 bool lp_load(const char *pszFname,
9292              bool global_only,
9293              bool save_defaults,
9294              bool add_ipc,
9295              bool initialize_globals)
9296 {
9297         return lp_load_ex(pszFname,
9298                           global_only,
9299                           save_defaults,
9300                           add_ipc,
9301                           initialize_globals,
9302                           true, false);
9303 }
9304
9305 bool lp_load_initial_only(const char *pszFname)
9306 {
9307         return lp_load_ex(pszFname,
9308                           true,
9309                           false,
9310                           false,
9311                           true,
9312                           false,
9313                           false);
9314 }
9315
9316 bool lp_load_with_registry_shares(const char *pszFname,
9317                                   bool global_only,
9318                                   bool save_defaults,
9319                                   bool add_ipc,
9320                                   bool initialize_globals)
9321 {
9322         return lp_load_ex(pszFname,
9323                           global_only,
9324                           save_defaults,
9325                           add_ipc,
9326                           initialize_globals,
9327                           true,
9328                           true);
9329 }
9330
9331 /***************************************************************************
9332  Return the max number of services.
9333 ***************************************************************************/
9334
9335 int lp_numservices(void)
9336 {
9337         return (iNumServices);
9338 }
9339
9340 /***************************************************************************
9341 Display the contents of the services array in human-readable form.
9342 ***************************************************************************/
9343
9344 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9345 {
9346         int iService;
9347
9348         if (show_defaults)
9349                 defaults_saved = False;
9350
9351         dump_globals(f);
9352
9353         dump_a_service(&sDefault, f);
9354
9355         for (iService = 0; iService < maxtoprint; iService++) {
9356                 fprintf(f,"\n");
9357                 lp_dump_one(f, show_defaults, iService);
9358         }
9359 }
9360
9361 /***************************************************************************
9362 Display the contents of one service in human-readable form.
9363 ***************************************************************************/
9364
9365 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9366 {
9367         if (VALID(snum)) {
9368                 if (ServicePtrs[snum]->szService[0] == '\0')
9369                         return;
9370                 dump_a_service(ServicePtrs[snum], f);
9371         }
9372 }
9373
9374 /***************************************************************************
9375 Return the number of the service with the given name, or -1 if it doesn't
9376 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9377 getservicebyname()! This works ONLY if all services have been loaded, and
9378 does not copy the found service.
9379 ***************************************************************************/
9380
9381 int lp_servicenumber(const char *pszServiceName)
9382 {
9383         int iService;
9384         fstring serviceName;
9385
9386         if (!pszServiceName) {
9387                 return GLOBAL_SECTION_SNUM;
9388         }
9389
9390         for (iService = iNumServices - 1; iService >= 0; iService--) {
9391                 if (VALID(iService) && ServicePtrs[iService]->szService) {
9392                         /*
9393                          * The substitution here is used to support %U is
9394                          * service names
9395                          */
9396                         fstrcpy(serviceName, ServicePtrs[iService]->szService);
9397                         standard_sub_basic(get_current_username(),
9398                                            current_user_info.domain,
9399                                            serviceName,sizeof(serviceName));
9400                         if (strequal(serviceName, pszServiceName)) {
9401                                 break;
9402                         }
9403                 }
9404         }
9405
9406         if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9407                 struct timespec last_mod;
9408
9409                 if (!usershare_exists(iService, &last_mod)) {
9410                         /* Remove the share security tdb entry for it. */
9411                         delete_share_security(lp_servicename(iService));
9412                         /* Remove it from the array. */
9413                         free_service_byindex(iService);
9414                         /* Doesn't exist anymore. */
9415                         return GLOBAL_SECTION_SNUM;
9416                 }
9417
9418                 /* Has it been modified ? If so delete and reload. */
9419                 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9420                                      &last_mod) < 0) {
9421                         /* Remove it from the array. */
9422                         free_service_byindex(iService);
9423                         /* and now reload it. */
9424                         iService = load_usershare_service(pszServiceName);
9425                 }
9426         }
9427
9428         if (iService < 0) {
9429                 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9430                 return GLOBAL_SECTION_SNUM;
9431         }
9432
9433         return (iService);
9434 }
9435
9436 bool share_defined(const char *service_name)
9437 {
9438         return (lp_servicenumber(service_name) != -1);
9439 }
9440
9441 struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
9442                                       const char *sharename)
9443 {
9444         struct share_params *result;
9445         char *sname;
9446         int snum;
9447
9448         if (!(sname = SMB_STRDUP(sharename))) {
9449                 return NULL;
9450         }
9451
9452         snum = find_service(sname);
9453         SAFE_FREE(sname);
9454
9455         if (snum < 0) {
9456                 return NULL;
9457         }
9458
9459         if (!(result = TALLOC_P(mem_ctx, struct share_params))) {
9460                 DEBUG(0, ("talloc failed\n"));
9461                 return NULL;
9462         }
9463
9464         result->service = snum;
9465         return result;
9466 }
9467
9468 struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx)
9469 {
9470         struct share_iterator *result;
9471
9472         if (!(result = TALLOC_P(mem_ctx, struct share_iterator))) {
9473                 DEBUG(0, ("talloc failed\n"));
9474                 return NULL;
9475         }
9476
9477         result->next_id = 0;
9478         return result;
9479 }
9480
9481 struct share_params *next_share(struct share_iterator *list)
9482 {
9483         struct share_params *result;
9484
9485         while (!lp_snum_ok(list->next_id) &&
9486                (list->next_id < lp_numservices())) {
9487                 list->next_id += 1;
9488         }
9489
9490         if (list->next_id >= lp_numservices()) {
9491                 return NULL;
9492         }
9493
9494         if (!(result = TALLOC_P(list, struct share_params))) {
9495                 DEBUG(0, ("talloc failed\n"));
9496                 return NULL;
9497         }
9498
9499         result->service = list->next_id;
9500         list->next_id += 1;
9501         return result;
9502 }
9503
9504 struct share_params *next_printer(struct share_iterator *list)
9505 {
9506         struct share_params *result;
9507
9508         while ((result = next_share(list)) != NULL) {
9509                 if (lp_print_ok(result->service)) {
9510                         break;
9511                 }
9512         }
9513         return result;
9514 }
9515
9516 /*
9517  * This is a hack for a transition period until we transformed all code from
9518  * service numbers to struct share_params.
9519  */
9520
9521 struct share_params *snum2params_static(int snum)
9522 {
9523         static struct share_params result;
9524         result.service = snum;
9525         return &result;
9526 }
9527
9528 /*******************************************************************
9529  A useful volume label function. 
9530 ********************************************************************/
9531
9532 const char *volume_label(int snum)
9533 {
9534         char *ret;
9535         const char *label = lp_volume(snum);
9536         if (!*label) {
9537                 label = lp_servicename(snum);
9538         }
9539
9540         /* This returns a 33 byte guarenteed null terminated string. */
9541         ret = talloc_strndup(talloc_tos(), label, 32);
9542         if (!ret) {
9543                 return "";
9544         }               
9545         return ret;
9546 }
9547
9548 /*******************************************************************
9549  Set the server type we will announce as via nmbd.
9550 ********************************************************************/
9551
9552 static void set_default_server_announce_type(void)
9553 {
9554         default_server_announce = 0;
9555         default_server_announce |= SV_TYPE_WORKSTATION;
9556         default_server_announce |= SV_TYPE_SERVER;
9557         default_server_announce |= SV_TYPE_SERVER_UNIX;
9558
9559         /* note that the flag should be set only if we have a 
9560            printer service but nmbd doesn't actually load the 
9561            services so we can't tell   --jerry */
9562
9563         default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9564
9565         switch (lp_announce_as()) {
9566                 case ANNOUNCE_AS_NT_SERVER:
9567                         default_server_announce |= SV_TYPE_SERVER_NT;
9568                         /* fall through... */
9569                 case ANNOUNCE_AS_NT_WORKSTATION:
9570                         default_server_announce |= SV_TYPE_NT;
9571                         break;
9572                 case ANNOUNCE_AS_WIN95:
9573                         default_server_announce |= SV_TYPE_WIN95_PLUS;
9574                         break;
9575                 case ANNOUNCE_AS_WFW:
9576                         default_server_announce |= SV_TYPE_WFW;
9577                         break;
9578                 default:
9579                         break;
9580         }
9581
9582         switch (lp_server_role()) {
9583                 case ROLE_DOMAIN_MEMBER:
9584                         default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9585                         break;
9586                 case ROLE_DOMAIN_PDC:
9587                         default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9588                         break;
9589                 case ROLE_DOMAIN_BDC:
9590                         default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9591                         break;
9592                 case ROLE_STANDALONE:
9593                 default:
9594                         break;
9595         }
9596         if (lp_time_server())
9597                 default_server_announce |= SV_TYPE_TIME_SOURCE;
9598
9599         if (lp_host_msdfs())
9600                 default_server_announce |= SV_TYPE_DFS_SERVER;
9601 }
9602
9603 /***********************************************************
9604  If we are PDC then prefer us as DMB
9605 ************************************************************/
9606
9607 bool lp_domain_master(void)
9608 {
9609         if (Globals.iDomainMaster == Auto)
9610                 return (lp_server_role() == ROLE_DOMAIN_PDC);
9611
9612         return (bool)Globals.iDomainMaster;
9613 }
9614
9615 /***********************************************************
9616  If we are PDC then prefer us as DMB
9617 ************************************************************/
9618
9619 bool lp_domain_master_true_or_auto(void)
9620 {
9621         if (Globals.iDomainMaster) /* auto or yes */
9622                 return true;
9623
9624         return false;
9625 }
9626
9627 /***********************************************************
9628  If we are DMB then prefer us as LMB
9629 ************************************************************/
9630
9631 bool lp_preferred_master(void)
9632 {
9633         if (Globals.iPreferredMaster == Auto)
9634                 return (lp_local_master() && lp_domain_master());
9635
9636         return (bool)Globals.iPreferredMaster;
9637 }
9638
9639 /*******************************************************************
9640  Remove a service.
9641 ********************************************************************/
9642
9643 void lp_remove_service(int snum)
9644 {
9645         ServicePtrs[snum]->valid = False;
9646         invalid_services[num_invalid_services++] = snum;
9647 }
9648
9649 /*******************************************************************
9650  Copy a service.
9651 ********************************************************************/
9652
9653 void lp_copy_service(int snum, const char *new_name)
9654 {
9655         do_section(new_name, NULL);
9656         if (snum >= 0) {
9657                 snum = lp_servicenumber(new_name);
9658                 if (snum >= 0)
9659                         lp_do_parameter(snum, "copy", lp_servicename(snum));
9660         }
9661 }
9662
9663
9664 /*******************************************************************
9665  Get the default server type we will announce as via nmbd.
9666 ********************************************************************/
9667
9668 int lp_default_server_announce(void)
9669 {
9670         return default_server_announce;
9671 }
9672
9673 /*******************************************************************
9674  Split the announce version into major and minor numbers.
9675 ********************************************************************/
9676
9677 int lp_major_announce_version(void)
9678 {
9679         static bool got_major = False;
9680         static int major_version = DEFAULT_MAJOR_VERSION;
9681         char *vers;
9682         char *p;
9683
9684         if (got_major)
9685                 return major_version;
9686
9687         got_major = True;
9688         if ((vers = lp_announce_version()) == NULL)
9689                 return major_version;
9690
9691         if ((p = strchr_m(vers, '.')) == 0)
9692                 return major_version;
9693
9694         *p = '\0';
9695         major_version = atoi(vers);
9696         return major_version;
9697 }
9698
9699 int lp_minor_announce_version(void)
9700 {
9701         static bool got_minor = False;
9702         static int minor_version = DEFAULT_MINOR_VERSION;
9703         char *vers;
9704         char *p;
9705
9706         if (got_minor)
9707                 return minor_version;
9708
9709         got_minor = True;
9710         if ((vers = lp_announce_version()) == NULL)
9711                 return minor_version;
9712
9713         if ((p = strchr_m(vers, '.')) == 0)
9714                 return minor_version;
9715
9716         p++;
9717         minor_version = atoi(p);
9718         return minor_version;
9719 }
9720
9721 /***********************************************************
9722  Set the global name resolution order (used in smbclient).
9723 ************************************************************/
9724
9725 void lp_set_name_resolve_order(const char *new_order)
9726 {
9727         string_set(&Globals.szNameResolveOrder, new_order);
9728 }
9729
9730 const char *lp_printername(int snum)
9731 {
9732         const char *ret = _lp_printername(snum);
9733         if (ret == NULL || (ret != NULL && *ret == '\0'))
9734                 ret = lp_const_servicename(snum);
9735
9736         return ret;
9737 }
9738
9739
9740 /***********************************************************
9741  Allow daemons such as winbindd to fix their logfile name.
9742 ************************************************************/
9743
9744 void lp_set_logfile(const char *name)
9745 {
9746         string_set(&Globals.szLogFile, name);
9747         debug_set_logfile(name);
9748 }
9749
9750 /*******************************************************************
9751  Return the max print jobs per queue.
9752 ********************************************************************/
9753
9754 int lp_maxprintjobs(int snum)
9755 {
9756         int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9757         if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9758                 maxjobs = PRINT_MAX_JOBID - 1;
9759
9760         return maxjobs;
9761 }
9762
9763 const char *lp_printcapname(void)
9764 {
9765         if ((Globals.szPrintcapname != NULL) &&
9766             (Globals.szPrintcapname[0] != '\0'))
9767                 return Globals.szPrintcapname;
9768
9769         if (sDefault.iPrinting == PRINT_CUPS) {
9770 #ifdef HAVE_CUPS
9771                 return "cups";
9772 #else
9773                 return "lpstat";
9774 #endif
9775         }
9776
9777         if (sDefault.iPrinting == PRINT_BSD)
9778                 return "/etc/printcap";
9779
9780         return PRINTCAP_NAME;
9781 }
9782
9783 static uint32 spoolss_state;
9784
9785 bool lp_disable_spoolss( void )
9786 {
9787         if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9788                 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9789
9790         return spoolss_state == SVCCTL_STOPPED ? True : False;
9791 }
9792
9793 void lp_set_spoolss_state( uint32 state )
9794 {
9795         SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9796
9797         spoolss_state = state;
9798 }
9799
9800 uint32 lp_get_spoolss_state( void )
9801 {
9802         return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9803 }
9804
9805 /*******************************************************************
9806  Ensure we don't use sendfile if server smb signing is active.
9807 ********************************************************************/
9808
9809 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9810 {
9811         bool sign_active = false;
9812
9813         /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9814         if (get_Protocol() < PROTOCOL_NT1) {
9815                 return false;
9816         }
9817         if (signing_state) {
9818                 sign_active = smb_signing_is_active(signing_state);
9819         }
9820         return (_lp_use_sendfile(snum) &&
9821                         (get_remote_arch() != RA_WIN95) &&
9822                         !sign_active);
9823 }
9824
9825 /*******************************************************************
9826  Turn off sendfile if we find the underlying OS doesn't support it.
9827 ********************************************************************/
9828
9829 void set_use_sendfile(int snum, bool val)
9830 {
9831         if (LP_SNUM_OK(snum))
9832                 ServicePtrs[snum]->bUseSendfile = val;
9833         else
9834                 sDefault.bUseSendfile = val;
9835 }
9836
9837 /*******************************************************************
9838  Turn off storing DOS attributes if this share doesn't support it.
9839 ********************************************************************/
9840
9841 void set_store_dos_attributes(int snum, bool val)
9842 {
9843         if (!LP_SNUM_OK(snum))
9844                 return;
9845         ServicePtrs[(snum)]->bStoreDosAttributes = val;
9846 }
9847
9848 void lp_set_mangling_method(const char *new_method)
9849 {
9850         string_set(&Globals.szManglingMethod, new_method);
9851 }
9852
9853 /*******************************************************************
9854  Global state for POSIX pathname processing.
9855 ********************************************************************/
9856
9857 static bool posix_pathnames;
9858
9859 bool lp_posix_pathnames(void)
9860 {
9861         return posix_pathnames;
9862 }
9863
9864 /*******************************************************************
9865  Change everything needed to ensure POSIX pathname processing (currently
9866  not much).
9867 ********************************************************************/
9868
9869 void lp_set_posix_pathnames(void)
9870 {
9871         posix_pathnames = True;
9872 }
9873
9874 /*******************************************************************
9875  Global state for POSIX lock processing - CIFS unix extensions.
9876 ********************************************************************/
9877
9878 bool posix_default_lock_was_set;
9879 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9880
9881 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9882 {
9883         if (posix_default_lock_was_set) {
9884                 return posix_cifsx_locktype;
9885         } else {
9886                 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9887         }
9888 }
9889
9890 /*******************************************************************
9891 ********************************************************************/
9892
9893 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9894 {
9895         posix_default_lock_was_set = True;
9896         posix_cifsx_locktype = val;
9897 }
9898
9899 int lp_min_receive_file_size(void)
9900 {
9901         if (Globals.iminreceivefile < 0) {
9902                 return 0;
9903         }
9904         return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9905 }
9906
9907 /*******************************************************************
9908  If socket address is an empty character string, it is necessary to 
9909  define it as "0.0.0.0". 
9910 ********************************************************************/
9911
9912 const char *lp_socket_address(void)
9913 {
9914         char *sock_addr = Globals.szSocketAddress;
9915
9916         if (sock_addr[0] == '\0'){
9917                 string_set(&Globals.szSocketAddress, "0.0.0.0");
9918         }
9919         return  Globals.szSocketAddress;
9920 }
9921
9922 void lp_set_passdb_backend(const char *backend)
9923 {
9924         string_set(&Globals.szPassdbBackend, backend);
9925 }
9926
9927 /*******************************************************************
9928  Safe wide links checks.
9929  This helper function always verify the validity of wide links,
9930  even after a configuration file reload.
9931 ********************************************************************/
9932
9933 static bool lp_widelinks_internal(int snum)
9934 {
9935         return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9936                         sDefault.bWidelinks);
9937 }
9938
9939 void widelinks_warning(int snum)
9940 {
9941         if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9942                 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9943                         "These parameters are incompatible. "
9944                         "Wide links will be disabled for this share.\n",
9945                         lp_servicename(snum) ));
9946         }
9947 }
9948
9949 bool lp_widelinks(int snum)
9950 {
9951         /* wide links is always incompatible with unix extensions */
9952         if (lp_unix_extensions()) {
9953                 return false;
9954         }
9955
9956         return lp_widelinks_internal(snum);
9957 }
9958
9959 bool lp_writeraw(void)
9960 {
9961         if (lp_async_smb_echo_handler()) {
9962                 return false;
9963         }
9964         return _lp_writeraw();
9965 }
9966
9967 bool lp_readraw(void)
9968 {
9969         if (lp_async_smb_echo_handler()) {
9970                 return false;
9971         }
9972         return _lp_readraw();
9973 }