Make --with-ldapsam 'go away'. This is now a standard, stable, feature
[kai/samba.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    
11    This program is free software; you can redistribute it and/or modify
12    it under the terms of the GNU General Public License as published by
13    the Free Software Foundation; either version 2 of the License, or
14    (at your option) any later version.
15    
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19    GNU General Public License for more details.
20    
21    You should have received a copy of the GNU General Public License
22    along with this program; if not, write to the Free Software
23    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26 /*
27  *  Load parameters.
28  *
29  *  This module provides suitable callback functions for the params
30  *  module. It builds the internal table of service details which is
31  *  then used by the rest of the server.
32  *
33  * To add a parameter:
34  *
35  * 1) add it to the global or service structure definition
36  * 2) add it to the parm_table
37  * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
38  * 4) If it's a global then initialise it in init_globals. If a local
39  *    (ie. service) parameter then initialise it in the sDefault structure
40  *  
41  *
42  * Notes:
43  *   The configuration file is processed sequentially for speed. It is NOT
44  *   accessed randomly as happens in 'real' Windows. For this reason, there
45  *   is a fair bit of sequence-dependent code here - ie., code which assumes
46  *   that certain things happen before others. In particular, the code which
47  *   happens at the boundary between sections is delicately poised, so be
48  *   careful!
49  *
50  */
51
52 #include "includes.h"
53
54 BOOL in_client = False;         /* Not in the client by default */
55 BOOL bLoaded = False;
56
57 extern userdom_struct current_user_info;
58 extern int DEBUGLEVEL_CLASS[DBGC_LAST];
59 extern pstring user_socket_options;
60 extern pstring global_myname;
61 pstring global_scope = "";
62
63 #ifndef GLOBAL_NAME
64 #define GLOBAL_NAME "global"
65 #endif
66
67 #ifndef PRINTERS_NAME
68 #define PRINTERS_NAME "printers"
69 #endif
70
71 #ifndef HOMES_NAME
72 #define HOMES_NAME "homes"
73 #endif
74
75 /* some helpful bits */
76 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && ServicePtrs[(i)]->valid)
77 #define VALID(i) ServicePtrs[i]->valid
78
79 int keepalive = DEFAULT_KEEPALIVE;
80 BOOL use_getwd_cache = True;
81
82 extern int extra_time_offset;
83
84 static BOOL defaults_saved = False;
85
86 /* 
87  * This structure describes global (ie., server-wide) parameters.
88  */
89 typedef struct
90 {
91         char *dos_charset;
92         char *unix_charset;
93         char *display_charset;
94         char *szPrintcapname;
95         char *szEnumPortsCommand;
96         char *szAddPrinterCommand;
97         char *szDeletePrinterCommand;
98         char *szOs2DriverMap;
99         char *szLockDir;
100         char *szPidDir;
101         char *szRootdir;
102         char *szDefaultService;
103         char *szDfree;
104         char *szMsgCommand;
105         char *szHostsEquiv;
106         char *szServerString;
107         char *szAutoServices;
108         char *szPasswdProgram;
109         char *szPasswdChat;
110         char *szLogFile;
111         char *szConfigFile;
112         char *szSMBPasswdFile;
113         char *szPrivateDir;
114         char *szPassdbBackend;
115         char *szPasswordServer;
116         char *szSocketOptions;
117         char *szWorkGroup;
118         char *szRealm;
119         char *szADSserver;
120         char *szUsernameMap;
121         char *szLogonScript;
122         char *szLogonPath;
123         char *szLogonDrive;
124         char *szLogonHome;
125         char *szWINSserver;
126         char **szInterfaces;
127         char *szRemoteAnnounce;
128         char *szRemoteBrowseSync;
129         char *szSocketAddress;
130         char *szNISHomeMapName;
131         char *szAnnounceVersion;        /* This is initialised in init_globals */
132         char **szNetbiosAliases;
133         char *szDomainOtherSIDs;
134         char *szNameResolveOrder;
135         char *szPanicAction;
136         char *szAddUserScript;
137         char *szDelUserScript;
138         char *szAddGroupScript;
139         char *szDelGroupScript;
140         char *szAddUserToGroupScript;
141         char *szDelUserToGroupScript;
142         char *szAddMachineScript;
143         char *szShutdownScript;
144         char *szAbortShutdownScript;
145         char *szWINSHook;
146         char *szWINSPartners;
147 #ifdef WITH_UTMP
148         char *szUtmpDir;
149         char *szWtmpDir;
150         BOOL bUtmp;
151 #endif
152         char *szSourceEnv;
153         char *szWinbindUID;
154         char *szWinbindGID;
155         char *szNonUnixAccountRange;
156         BOOL bAlgorithmicRidBase;
157         char *szTemplateHomedir;
158         char *szTemplateShell;
159         char *szWinbindSeparator;
160         BOOL bWinbindEnumUsers;
161         BOOL bWinbindEnumGroups;
162         BOOL bWinbindUseDefaultDomain;
163         char *szAddShareCommand;
164         char *szChangeShareCommand;
165         char *szDeleteShareCommand;
166         char *szGuestaccount;
167         char *szManglingMethod;
168         int max_log_size;
169         int mangled_stack;
170         int max_xmit;
171         int max_mux;
172         int max_open_files;
173         int max_packet;
174         int pwordlevel;
175         int unamelevel;
176         int deadtime;
177         int maxprotocol;
178         int minprotocol;
179         int security;
180         char **AuthMethods;
181         BOOL paranoid_server_security;
182         int maxdisksize;
183         int lpqcachetime;
184         int iMaxSmbdProcesses;
185         BOOL bDisableSpoolss;
186         int iTotalPrintJobs;
187         int syslog;
188         int os_level;
189         int enhanced_browsing;
190         int max_ttl;
191         int max_wins_ttl;
192         int min_wins_ttl;
193         int ReadSize;
194         int lm_announce;
195         int lm_interval;
196         int announce_as;        /* This is initialised in init_globals */
197         int machine_password_timeout;
198         int change_notify_timeout;
199         int stat_cache_size;
200         int map_to_guest;
201         int min_passwd_length;
202         int oplock_break_wait_time;
203         int winbind_cache_time;
204         int iLockSpinCount;
205         int iLockSpinTime;
206         char *szLdapMachineSuffix;
207         char *szLdapUserSuffix;
208         int ldap_port;
209         int ldap_ssl;
210         char *szLdapSuffix;
211         char *szLdapFilter;
212         char *szLdapAdminDn;
213         BOOL bMsAddPrinterWizard;
214         BOOL bDNSproxy;
215         BOOL bWINSsupport;
216         BOOL bWINSproxy;
217         BOOL bLocalMaster;
218         BOOL bPreferredMaster;
219         BOOL bDomainMaster;
220         BOOL bDomainLogons;
221         BOOL bEncryptPasswords;
222         BOOL bUpdateEncrypt;
223         BOOL bStripDot;
224         BOOL bNullPasswords;
225         BOOL bObeyPamRestrictions;
226         BOOL bLoadPrinters;
227         BOOL bLargeReadwrite;
228         BOOL bReadRaw;
229         BOOL bWriteRaw;
230         BOOL bReadPrediction;
231         BOOL bReadbmpx;
232         BOOL bSyslogOnly;
233         BOOL bAdminLog;
234         BOOL bBrowseList;
235         BOOL bNISHomeMap;
236         BOOL bTimeServer;
237         BOOL bBindInterfacesOnly;
238         BOOL bPamPasswordChange;
239         BOOL bUnixPasswdSync;
240         BOOL bPasswdChatDebug;
241         BOOL bTimestampLogs;
242         BOOL bNTSmbSupport;
243         BOOL bNTPipeSupport;
244         BOOL bNTStatusSupport;
245         BOOL bStatCache;
246         BOOL bKernelOplocks;
247         BOOL bAllowTrustedDomains;
248         BOOL bRestrictAnonymous;
249         BOOL bLanmanAuth;
250         BOOL bNTLMAuth;
251         BOOL bDebugHiresTimestamp;
252         BOOL bDebugPid;
253         BOOL bDebugUid;
254         BOOL bHostMSDfs;
255         BOOL bHideLocalUsers;
256         BOOL bUnicode;
257         BOOL bUseMmap;
258         BOOL bHostnameLookups;
259         BOOL bUseSpnego;
260 }
261 global;
262
263 static global Globals;
264
265
266
267 /* 
268  * This structure describes a single service. 
269  */
270 typedef struct
271 {
272         BOOL valid;
273         BOOL autoloaded;
274         char *szService;
275         char *szPath;
276         char *szUsername;
277         char **szInvalidUsers;
278         char **szValidUsers;
279         char **szAdminUsers;
280         char *szCopy;
281         char *szInclude;
282         char *szPreExec;
283         char *szPostExec;
284         char *szRootPreExec;
285         char *szRootPostExec;
286         char *szPrintcommand;
287         char *szLpqcommand;
288         char *szLprmcommand;
289         char *szLppausecommand;
290         char *szLpresumecommand;
291         char *szQueuepausecommand;
292         char *szQueueresumecommand;
293         char *szPrintername;
294         char *szPrinterDriver;
295         char *szPrinterDriverLocation;
296         char *szDriverFile;
297         char *szDontdescend;
298         char **szHostsallow;
299         char **szHostsdeny;
300         char *szMagicScript;
301         char *szMagicOutput;
302         char *szMangledMap;
303         char *szVetoFiles;
304         char *szHideFiles;
305         char *szVetoOplockFiles;
306         char *comment;
307         char *force_user;
308         char *force_group;
309         char **readlist;
310         char **writelist;
311         char **printer_admin;
312         char *volume;
313         char *fstype;
314         char *szVfsObjectFile;
315         char *szVfsOptions;
316         int iMinPrintSpace;
317         int iMaxPrintJobs;
318         int iWriteCacheSize;
319         int iCreate_mask;
320         int iCreate_force_mode;
321         int iSecurity_mask;
322         int iSecurity_force_mode;
323         int iDir_mask;
324         int iDir_force_mode;
325         int iDir_Security_mask;
326         int iDir_Security_force_mode;
327         int iMaxConnections;
328         int iDefaultCase;
329         int iPrinting;
330         int iOplockContentionLimit;
331         int iCSCPolicy;
332         BOOL bAlternatePerm;
333         BOOL bPreexecClose;
334         BOOL bRootpreexecClose;
335         BOOL bCaseSensitive;
336         BOOL bCasePreserve;
337         BOOL bShortCasePreserve;
338         BOOL bCaseMangle;
339         BOOL bHideDotFiles;
340         BOOL bHideUnReadable;
341         BOOL bBrowseable;
342         BOOL bAvailable;
343         BOOL bRead_only;
344         BOOL bNo_set_dir;
345         BOOL bGuest_only;
346         BOOL bGuest_ok;
347         BOOL bPrint_ok;
348         BOOL bPostscript;
349         BOOL bMap_system;
350         BOOL bMap_hidden;
351         BOOL bMap_archive;
352         BOOL bLocking;
353         BOOL bStrictLocking;
354         BOOL bPosixLocking;
355         BOOL bShareModes;
356         BOOL bOpLocks;
357         BOOL bLevel2OpLocks;
358         BOOL bOnlyUser;
359         BOOL bMangledNames;
360         BOOL bWidelinks;
361         BOOL bSymlinks;
362         BOOL bSyncAlways;
363         BOOL bStrictAllocate;
364         BOOL bStrictSync;
365         char magic_char;
366         BOOL *copymap;
367         BOOL bDeleteReadonly;
368         BOOL bFakeOplocks;
369         BOOL bDeleteVetoFiles;
370         BOOL bDosFilemode;
371         BOOL bDosFiletimes;
372         BOOL bDosFiletimeResolution;
373         BOOL bFakeDirCreateTimes;
374         BOOL bBlockingLocks;
375         BOOL bInheritPerms;
376         BOOL bInheritACLS;
377         BOOL bMSDfsRoot;
378         BOOL bUseClientDriver;
379         BOOL bDefaultDevmode;
380         BOOL bNTAclSupport;
381
382         char dummy[3];          /* for alignment */
383 }
384 service;
385
386
387 /* This is a default service used to prime a services structure */
388 static service sDefault = {
389         True,                   /* valid */
390         False,                  /* not autoloaded */
391         NULL,                   /* szService */
392         NULL,                   /* szPath */
393         NULL,                   /* szUsername */
394         NULL,                   /* szInvalidUsers */
395         NULL,                   /* szValidUsers */
396         NULL,                   /* szAdminUsers */
397         NULL,                   /* szCopy */
398         NULL,                   /* szInclude */
399         NULL,                   /* szPreExec */
400         NULL,                   /* szPostExec */
401         NULL,                   /* szRootPreExec */
402         NULL,                   /* szRootPostExec */
403         NULL,                   /* szPrintcommand */
404         NULL,                   /* szLpqcommand */
405         NULL,                   /* szLprmcommand */
406         NULL,                   /* szLppausecommand */
407         NULL,                   /* szLpresumecommand */
408         NULL,                   /* szQueuepausecommand */
409         NULL,                   /* szQueueresumecommand */
410         NULL,                   /* szPrintername */
411         NULL,                   /* szPrinterDriver - this is set in init_globals() */
412         NULL,                   /* szPrinterDriverLocation */
413         NULL,                   /* szDriverFile */
414         NULL,                   /* szDontdescend */
415         NULL,                   /* szHostsallow */
416         NULL,                   /* szHostsdeny */
417         NULL,                   /* szMagicScript */
418         NULL,                   /* szMagicOutput */
419         NULL,                   /* szMangledMap */
420         NULL,                   /* szVetoFiles */
421         NULL,                   /* szHideFiles */
422         NULL,                   /* szVetoOplockFiles */
423         NULL,                   /* comment */
424         NULL,                   /* force user */
425         NULL,                   /* force group */
426         NULL,                   /* readlist */
427         NULL,                   /* writelist */
428         NULL,                   /* printer admin */
429         NULL,                   /* volume */
430         NULL,                   /* fstype */
431         NULL,                   /* vfs object */
432         NULL,                   /* vfs options */
433         0,                      /* iMinPrintSpace */
434         1000,                   /* iMaxPrintJobs */
435         0,                      /* iWriteCacheSize */
436         0744,                   /* iCreate_mask */
437         0000,                   /* iCreate_force_mode */
438         0777,                   /* iSecurity_mask */
439         0,                      /* iSecurity_force_mode */
440         0755,                   /* iDir_mask */
441         0000,                   /* iDir_force_mode */
442         0777,                   /* iDir_Security_mask */
443         0,                      /* iDir_Security_force_mode */
444         0,                      /* iMaxConnections */
445         CASE_LOWER,             /* iDefaultCase */
446         DEFAULT_PRINTING,       /* iPrinting */
447         2,                      /* iOplockContentionLimit */
448         0,                      /* iCSCPolicy */
449         False,                  /* bAlternatePerm */
450         False,                  /* bPreexecClose */
451         False,                  /* bRootpreexecClose */
452         False,                  /* case sensitive */
453         True,                   /* case preserve */
454         True,                   /* short case preserve */
455         False,                  /* case mangle */
456         True,                   /* bHideDotFiles */
457         False,                  /* bHideUnReadable */
458         True,                   /* bBrowseable */
459         True,                   /* bAvailable */
460         True,                   /* bRead_only */
461         True,                   /* bNo_set_dir */
462         False,                  /* bGuest_only */
463         False,                  /* bGuest_ok */
464         False,                  /* bPrint_ok */
465         False,                  /* bPostscript */
466         False,                  /* bMap_system */
467         False,                  /* bMap_hidden */
468         True,                   /* bMap_archive */
469         True,                   /* bLocking */
470         True,                   /* bStrictLocking */
471         True,                   /* bPosixLocking */
472         True,                   /* bShareModes */
473         True,                   /* bOpLocks */
474         True,                   /* bLevel2OpLocks */
475         False,                  /* bOnlyUser */
476         True,                   /* bMangledNames */
477         True,                   /* bWidelinks */
478         True,                   /* bSymlinks */
479         False,                  /* bSyncAlways */
480         False,                  /* bStrictAllocate */
481         False,                  /* bStrictSync */
482         '~',                    /* magic char */
483         NULL,                   /* copymap */
484         False,                  /* bDeleteReadonly */
485         False,                  /* bFakeOplocks */
486         False,                  /* bDeleteVetoFiles */
487         False,                  /* bDosFilemode */
488         False,                  /* bDosFiletimes */
489         False,                  /* bDosFiletimeResolution */
490         False,                  /* bFakeDirCreateTimes */
491         True,                   /* bBlockingLocks */
492         False,                  /* bInheritPerms */
493         False,                  /* bInheritACLS */
494         False,                  /* bMSDfsRoot */
495         False,                  /* bUseClientDriver */
496         False,                  /* bDefaultDevmode */
497         True,                   /* bNTAclSupport */
498
499         ""                      /* dummy */
500 };
501
502 /* local variables */
503 static service **ServicePtrs = NULL;
504 static int iNumServices = 0;
505 static int iServiceIndex = 0;
506 static BOOL bInGlobalSection = True;
507 static BOOL bGlobalOnly = False;
508 static int server_role;
509 static int default_server_announce;
510
511 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
512
513 /* prototypes for the special type handlers */
514 static BOOL handle_include(char *pszParmValue, char **ptr);
515 static BOOL handle_copy(char *pszParmValue, char **ptr);
516 static BOOL handle_vfs_object(char *pszParmValue, char **ptr);
517 static BOOL handle_source_env(char *pszParmValue, char **ptr);
518 static BOOL handle_netbios_name(char *pszParmValue, char **ptr);
519 static BOOL handle_winbind_uid(char *pszParmValue, char **ptr);
520 static BOOL handle_winbind_gid(char *pszParmValue, char **ptr);
521 static BOOL handle_non_unix_account_range(char *pszParmValue, char **ptr);
522 static BOOL handle_wins_server_list(char *pszParmValue, char **ptr);
523 static BOOL handle_debug_list( char *pszParmValue, char **ptr );
524
525 static BOOL handle_ldap_machine_suffix ( char *pszParmValue, char **ptr );
526 static BOOL handle_ldap_user_suffix ( char *pszParmValue, char **ptr );
527 static BOOL handle_ldap_suffix ( char *pszParmValue, char **ptr );
528
529 static void set_server_role(void);
530 static void set_default_server_announce_type(void);
531
532 static struct enum_list enum_protocol[] = {
533         {PROTOCOL_NT1, "NT1"},
534         {PROTOCOL_LANMAN2, "LANMAN2"},
535         {PROTOCOL_LANMAN1, "LANMAN1"},
536         {PROTOCOL_CORE, "CORE"},
537         {PROTOCOL_COREPLUS, "COREPLUS"},
538         {PROTOCOL_COREPLUS, "CORE+"},
539         {-1, NULL}
540 };
541
542 static struct enum_list enum_security[] = {
543         {SEC_SHARE, "SHARE"},
544         {SEC_USER, "USER"},
545         {SEC_SERVER, "SERVER"},
546         {SEC_DOMAIN, "DOMAIN"},
547         {SEC_ADS, "ADS"},
548         {-1, NULL}
549 };
550
551 static struct enum_list enum_printing[] = {
552         {PRINT_SYSV, "sysv"},
553         {PRINT_AIX, "aix"},
554         {PRINT_HPUX, "hpux"},
555         {PRINT_BSD, "bsd"},
556         {PRINT_QNX, "qnx"},
557         {PRINT_PLP, "plp"},
558         {PRINT_LPRNG, "lprng"},
559         {PRINT_SOFTQ, "softq"},
560         {PRINT_CUPS, "cups"},
561         {PRINT_LPRNT, "nt"},
562         {PRINT_LPROS2, "os2"},
563 #ifdef DEVELOPER
564         {PRINT_TEST, "test"},
565         {PRINT_VLP, "vlp"},
566 #endif /* DEVELOPER */
567         {-1, NULL}
568 };
569
570 static struct enum_list enum_ldap_ssl[] = {
571         {LDAP_SSL_ON, "Yes"},
572         {LDAP_SSL_ON, "yes"},
573         {LDAP_SSL_ON, "on"},
574         {LDAP_SSL_ON, "On"},
575         {LDAP_SSL_OFF, "no"},
576         {LDAP_SSL_OFF, "No"},
577         {LDAP_SSL_OFF, "off"},
578         {LDAP_SSL_OFF, "Off"},
579         {LDAP_SSL_START_TLS, "start tls"},
580         {LDAP_SSL_START_TLS, "start_tls"},
581         {-1, NULL}
582 };
583
584 /* Types of machine we can announce as. */
585 #define ANNOUNCE_AS_NT_SERVER 1
586 #define ANNOUNCE_AS_WIN95 2
587 #define ANNOUNCE_AS_WFW 3
588 #define ANNOUNCE_AS_NT_WORKSTATION 4
589
590 static struct enum_list enum_announce_as[] = {
591         {ANNOUNCE_AS_NT_SERVER, "NT"},
592         {ANNOUNCE_AS_NT_SERVER, "NT Server"},
593         {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
594         {ANNOUNCE_AS_WIN95, "win95"},
595         {ANNOUNCE_AS_WFW, "WfW"},
596         {-1, NULL}
597 };
598
599 static struct enum_list enum_case[] = {
600         {CASE_LOWER, "lower"},
601         {CASE_UPPER, "upper"},
602         {-1, NULL}
603 };
604
605 static struct enum_list enum_bool_auto[] = {
606         {False, "False"},
607         {False, "No"},
608         {False, "0"},
609         {True, "True"},
610         {True, "Yes"},
611         {True, "1"},
612         {Auto, "Auto"},
613         {-1, NULL}
614 };
615
616 /* Client-side offline caching policy types */
617 #define CSC_POLICY_MANUAL 0
618 #define CSC_POLICY_DOCUMENTS 1
619 #define CSC_POLICY_PROGRAMS 2
620 #define CSC_POLICY_DISABLE 3
621
622 static struct enum_list enum_csc_policy[] = {
623         {CSC_POLICY_MANUAL, "manual"},
624         {CSC_POLICY_DOCUMENTS, "documents"},
625         {CSC_POLICY_PROGRAMS, "programs"},
626         {CSC_POLICY_DISABLE, "disable"}
627 };
628
629 /* 
630    Do you want session setups at user level security with a invalid
631    password to be rejected or allowed in as guest? WinNT rejects them
632    but it can be a pain as it means "net view" needs to use a password
633
634    You have 3 choices in the setting of map_to_guest:
635
636    "Never" means session setups with an invalid password
637    are rejected. This is the default.
638
639    "Bad User" means session setups with an invalid password
640    are rejected, unless the username does not exist, in which case it
641    is treated as a guest login
642
643    "Bad Password" means session setups with an invalid password
644    are treated as a guest login
645
646    Note that map_to_guest only has an effect in user or server
647    level security.
648 */
649
650 static struct enum_list enum_map_to_guest[] = {
651         {NEVER_MAP_TO_GUEST, "Never"},
652         {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
653         {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
654         {-1, NULL}
655 };
656
657 /* note that we do not initialise the defaults union - it is not allowed in ANSI C */
658 static struct parm_struct parm_table[] = {
659         {"Base Options", P_SEP, P_SEPARATOR},
660
661         {"dos charset", P_STRING, P_GLOBAL, &Globals.dos_charset, NULL, NULL, 0},
662         {"unix charset", P_STRING, P_GLOBAL, &Globals.unix_charset, NULL, NULL, 0},
663         {"display charset", P_STRING, P_GLOBAL, &Globals.display_charset, NULL, NULL, 0},
664         {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, NULL, FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
665         {"path", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
666         {"directory", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, 0},
667         {"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkGroup, NULL, NULL, FLAG_BASIC},
668         {"realm", P_USTRING, P_GLOBAL, &Globals.szRealm, NULL, NULL, FLAG_BASIC},
669         {"ADS server", P_STRING, P_GLOBAL, &Globals.szADSserver, NULL, NULL, FLAG_BASIC},
670         {"netbios name", P_UGSTRING, P_GLOBAL, global_myname, handle_netbios_name, NULL, FLAG_BASIC},
671         {"netbios aliases", P_LIST, P_GLOBAL, &Globals.szNetbiosAliases, NULL, NULL, 0},
672         {"netbios scope", P_UGSTRING, P_GLOBAL, global_scope, NULL, NULL, 0},
673         {"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL, NULL, FLAG_BASIC },
674         {"interfaces", P_LIST, P_GLOBAL, &Globals.szInterfaces, NULL, NULL, FLAG_BASIC},
675         {"bind interfaces only", P_BOOL, P_GLOBAL, &Globals.bBindInterfacesOnly, NULL, NULL, 0},
676
677         {"Security Options", P_SEP, P_SEPARATOR},
678         
679         {"security", P_ENUM, P_GLOBAL, &Globals.security, NULL, enum_security, FLAG_BASIC},
680         {"auth methods", P_LIST, P_GLOBAL, &Globals.AuthMethods, NULL, NULL, FLAG_BASIC},
681         {"encrypt passwords", P_BOOL, P_GLOBAL, &Globals.bEncryptPasswords, NULL, NULL, FLAG_BASIC},
682         {"update encrypted", P_BOOL, P_GLOBAL, &Globals.bUpdateEncrypt, NULL, NULL, FLAG_BASIC},
683         {"allow trusted domains", P_BOOL, P_GLOBAL, &Globals.bAllowTrustedDomains, NULL, NULL, 0},
684         {"alternate permissions", P_BOOL, P_LOCAL, &sDefault.bAlternatePerm, NULL, NULL, FLAG_GLOBAL | FLAG_DEPRECATED},
685         {"hosts equiv", P_STRING, P_GLOBAL, &Globals.szHostsEquiv, NULL, NULL, 0},
686         {"min passwd length", P_INTEGER, P_GLOBAL, &Globals.min_passwd_length, NULL, NULL, 0},
687         {"min password length", P_INTEGER, P_GLOBAL, &Globals.min_passwd_length, NULL, NULL, 0},
688         {"map to guest", P_ENUM, P_GLOBAL, &Globals.map_to_guest, NULL, enum_map_to_guest, 0},
689         {"null passwords", P_BOOL, P_GLOBAL, &Globals.bNullPasswords, NULL, NULL, 0},
690         {"obey pam restrictions", P_BOOL, P_GLOBAL, &Globals.bObeyPamRestrictions, NULL, NULL, 0},
691         {"password server", P_STRING, P_GLOBAL, &Globals.szPasswordServer, NULL, NULL, 0},
692         {"smb passwd file", P_STRING, P_GLOBAL, &Globals.szSMBPasswdFile, NULL, NULL, 0},
693         {"private dir", P_STRING, P_GLOBAL, &Globals.szPrivateDir, NULL, NULL, 0},
694         {"passdb backend", P_STRING, P_GLOBAL, &Globals.szPassdbBackend, NULL, NULL, 0},
695         {"non unix account range", P_STRING, P_GLOBAL, &Globals.szNonUnixAccountRange, handle_non_unix_account_range, NULL, 0},
696         {"algorithmic rid base", P_INTEGER, P_GLOBAL, &Globals.bAlgorithmicRidBase, NULL, NULL, 0},
697         {"root directory", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, 0},
698         {"root dir", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, 0},
699         {"root", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, 0},
700         {"guest account", P_STRING, P_GLOBAL, &Globals.szGuestaccount, NULL, NULL, FLAG_BASIC},
701         
702         {"pam password change", P_BOOL, P_GLOBAL, &Globals.bPamPasswordChange, NULL, NULL, 0},
703         {"passwd program", P_STRING, P_GLOBAL, &Globals.szPasswdProgram, NULL, NULL, 0},
704         {"passwd chat", P_STRING, P_GLOBAL, &Globals.szPasswdChat, NULL, NULL, 0},
705         {"passwd chat debug", P_BOOL, P_GLOBAL, &Globals.bPasswdChatDebug, NULL, NULL, 0},
706         {"username map", P_STRING, P_GLOBAL, &Globals.szUsernameMap, NULL, NULL, 0},
707         {"password level", P_INTEGER, P_GLOBAL, &Globals.pwordlevel, NULL, NULL, 0},
708         {"username level", P_INTEGER, P_GLOBAL, &Globals.unamelevel, NULL, NULL, 0},
709         {"unix password sync", P_BOOL, P_GLOBAL, &Globals.bUnixPasswdSync, NULL, NULL, 0},
710         {"restrict anonymous", P_BOOL, P_GLOBAL, &Globals.bRestrictAnonymous, NULL, NULL, 0},
711         {"lanman auth", P_BOOL, P_GLOBAL, &Globals.bLanmanAuth, NULL, NULL, 0},
712         {"ntlm auth", P_BOOL, P_GLOBAL, &Globals.bNTLMAuth, NULL, NULL, 0},
713         
714         {"username", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
715         {"user", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, 0},
716         {"users", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, 0},
717         
718         {"invalid users", P_LIST, P_LOCAL, &sDefault.szInvalidUsers, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
719         {"valid users", P_LIST, P_LOCAL, &sDefault.szValidUsers, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
720         {"admin users", P_LIST, P_LOCAL, &sDefault.szAdminUsers, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
721         {"read list", P_LIST, P_LOCAL, &sDefault.readlist, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
722         {"write list", P_LIST, P_LOCAL, &sDefault.writelist, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
723         {"printer admin", P_LIST, P_LOCAL, &sDefault.printer_admin, NULL, NULL, FLAG_GLOBAL | FLAG_PRINT},
724         {"force user", P_STRING, P_LOCAL, &sDefault.force_user, NULL, NULL, FLAG_SHARE},
725         {"force group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL, FLAG_SHARE},
726         {"group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL, 0},
727         
728         {"read only", P_BOOL, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_BASIC | FLAG_SHARE},
729         {"write ok", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, 0},
730         {"writeable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, 0},
731         {"writable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, 0},
732         
733         {"create mask", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
734         {"create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_GLOBAL},
735         {"force create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_force_mode, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
736         {"security mask", P_OCTAL, P_LOCAL, &sDefault.iSecurity_mask, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
737         {"force security mode", P_OCTAL, P_LOCAL, &sDefault.iSecurity_force_mode, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
738         {"directory mask", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
739         {"directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_GLOBAL},
740         {"force directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_force_mode, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
741         {"directory security mask", P_OCTAL, P_LOCAL, &sDefault.iDir_Security_mask, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
742         {"force directory security mode", P_OCTAL, P_LOCAL, &sDefault.iDir_Security_force_mode, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
743         {"inherit permissions", P_BOOL, P_LOCAL, &sDefault.bInheritPerms, NULL, NULL, FLAG_SHARE},
744         {"inherit acls", P_BOOL, P_LOCAL, &sDefault.bInheritACLS, NULL, NULL, FLAG_SHARE},
745         {"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, FLAG_SHARE},
746         {"only guest", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, 0},
747
748         {"guest ok", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
749         {"public", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, 0},
750         
751         {"only user", P_BOOL, P_LOCAL, &sDefault.bOnlyUser, NULL, NULL, FLAG_SHARE},
752         {"hosts allow", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
753         {"allow hosts", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, 0},
754         {"hosts deny", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
755         {"deny hosts", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, 0},
756
757         {"Logging Options", P_SEP, P_SEPARATOR},
758
759         {"admin log", P_BOOL, P_GLOBAL, &Globals.bAdminLog, NULL, NULL, 0},
760         {"log level", P_INTEGER, P_GLOBAL, &DEBUGLEVEL_CLASS[DBGC_ALL], handle_debug_list, NULL, 0},
761         {"debuglevel", P_INTEGER, P_GLOBAL, &DEBUGLEVEL_CLASS[DBGC_ALL], handle_debug_list, NULL, 0},
762         {"syslog", P_INTEGER, P_GLOBAL, &Globals.syslog, NULL, NULL, 0},
763         {"syslog only", P_BOOL, P_GLOBAL, &Globals.bSyslogOnly, NULL, NULL, 0},
764         {"log file", P_STRING, P_GLOBAL, &Globals.szLogFile, NULL, NULL, 0},
765         
766         {"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL, NULL, 0},
767         {"timestamp logs", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, 0},
768         {"debug timestamp", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, 0},
769         {"debug hires timestamp", P_BOOL, P_GLOBAL, &Globals.bDebugHiresTimestamp, NULL, NULL, 0},
770         {"debug pid", P_BOOL, P_GLOBAL, &Globals.bDebugPid, NULL, NULL, 0},
771         {"debug uid", P_BOOL, P_GLOBAL, &Globals.bDebugUid, NULL, NULL, 0},
772         
773         {"Protocol Options", P_SEP, P_SEPARATOR},
774         
775         {"protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, 0},
776         {"large readwrite", P_BOOL, P_GLOBAL, &Globals.bLargeReadwrite, NULL, NULL, 0},
777         {"max protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, 0},
778         {"min protocol", P_ENUM, P_GLOBAL, &Globals.minprotocol, NULL, enum_protocol, 0},
779         {"unicode", P_BOOL, P_GLOBAL, &Globals.bUnicode, NULL, NULL, 0},
780         {"read bmpx", P_BOOL, P_GLOBAL, &Globals.bReadbmpx, NULL, NULL, 0},
781         {"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL, 0},
782         {"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL, 0},
783         
784         {"nt pipe support", P_BOOL, P_GLOBAL, &Globals.bNTPipeSupport, NULL, NULL, 0},
785         {"nt acl support", P_BOOL,  P_LOCAL, &sDefault.bNTAclSupport, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE },
786         {"nt status support", P_BOOL, P_GLOBAL, &Globals.bNTStatusSupport, NULL, NULL, 0},
787         {"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL, NULL, 0},
788         {"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as, 0},
789         {"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL, 0},
790         {"max xmit", P_INTEGER, P_GLOBAL, &Globals.max_xmit, NULL, NULL, 0},
791         
792         {"name resolve order", P_STRING, P_GLOBAL, &Globals.szNameResolveOrder, NULL, NULL, 0},
793         {"max packet", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL, NULL, 0},
794         {"packet size", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL, NULL, 0},
795         {"max ttl", P_INTEGER, P_GLOBAL, &Globals.max_ttl, NULL, NULL, 0}, 
796         {"max wins ttl", P_INTEGER, P_GLOBAL, &Globals.max_wins_ttl, NULL, NULL, 0},
797         {"min wins ttl", P_INTEGER, P_GLOBAL, &Globals.min_wins_ttl, NULL, NULL, 0},
798         {"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL, NULL, 0},
799         {"use spnego", P_BOOL, P_GLOBAL, &Globals.bUseSpnego, NULL, NULL, 0},
800
801         {"Tuning Options", P_SEP, P_SEPARATOR},
802         
803         {"change notify timeout", P_INTEGER, P_GLOBAL, &Globals.change_notify_timeout, NULL, NULL, 0},
804         {"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL, NULL, 0},
805         {"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL, NULL, 0},
806         {"keepalive", P_INTEGER, P_GLOBAL, &keepalive, NULL, NULL, 0},
807         
808         {"lpq cache time", P_INTEGER, P_GLOBAL, &Globals.lpqcachetime, NULL, NULL, 0},
809         {"max smbd processes", P_INTEGER, P_GLOBAL, &Globals.iMaxSmbdProcesses, NULL, NULL, 0},
810         {"max connections", P_INTEGER, P_LOCAL, &sDefault.iMaxConnections, NULL, NULL, FLAG_SHARE},
811         {"paranoid server security", P_BOOL, P_GLOBAL, &Globals.paranoid_server_security, NULL, NULL, 0},
812         {"max disk size", P_INTEGER, P_GLOBAL, &Globals.maxdisksize, NULL, NULL, 0},
813         {"max open files", P_INTEGER, P_GLOBAL, &Globals.max_open_files, NULL, NULL, 0},
814         {"min print space", P_INTEGER, P_LOCAL, &sDefault.iMinPrintSpace, NULL, NULL, FLAG_PRINT},
815         {"read size", P_INTEGER, P_GLOBAL, &Globals.ReadSize, NULL, NULL, 0},
816         
817         {"socket options", P_GSTRING, P_GLOBAL, user_socket_options, NULL, NULL, 0},
818         {"stat cache size", P_INTEGER, P_GLOBAL, &Globals.stat_cache_size, NULL, NULL, 0},
819         {"strict allocate", P_BOOL, P_LOCAL, &sDefault.bStrictAllocate, NULL, NULL, FLAG_SHARE},
820         {"strict sync", P_BOOL, P_LOCAL, &sDefault.bStrictSync, NULL, NULL, FLAG_SHARE},
821         {"sync always", P_BOOL, P_LOCAL, &sDefault.bSyncAlways, NULL, NULL, FLAG_SHARE},
822         {"use mmap", P_BOOL, P_GLOBAL, &Globals.bUseMmap, NULL, NULL, 0},
823         {"hostname lookups", P_BOOL, P_GLOBAL, &Globals.bHostnameLookups, NULL, NULL, 0},
824         {"write cache size", P_INTEGER, P_LOCAL, &sDefault.iWriteCacheSize, NULL, NULL, FLAG_SHARE},
825
826         {"Printing Options", P_SEP, P_SEPARATOR},
827         
828         {"total print jobs", P_INTEGER, P_GLOBAL, &Globals.iTotalPrintJobs, NULL, NULL, FLAG_PRINT},
829         {"max print jobs", P_INTEGER, P_LOCAL, &sDefault.iMaxPrintJobs, NULL, NULL, FLAG_PRINT},
830         {"load printers", P_BOOL, P_GLOBAL, &Globals.bLoadPrinters, NULL, NULL, FLAG_PRINT},
831         {"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, FLAG_PRINT},
832         {"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, 0},
833         {"printable", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, FLAG_PRINT},
834         {"print ok", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, 0},
835         {"postscript", P_BOOL, P_LOCAL, &sDefault.bPostscript, NULL, NULL, FLAG_PRINT | FLAG_DEPRECATED},
836         {"printing", P_ENUM, P_LOCAL, &sDefault.iPrinting, NULL, enum_printing, FLAG_PRINT | FLAG_GLOBAL},
837         {"print command", P_STRING, P_LOCAL, &sDefault.szPrintcommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
838         {"disable spoolss", P_BOOL, P_GLOBAL, &Globals.bDisableSpoolss, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
839         {"lpq command", P_STRING, P_LOCAL, &sDefault.szLpqcommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
840         {"lprm command", P_STRING, P_LOCAL, &sDefault.szLprmcommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
841         {"lppause command", P_STRING, P_LOCAL, &sDefault.szLppausecommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
842         {"lpresume command", P_STRING, P_LOCAL, &sDefault.szLpresumecommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
843         {"queuepause command", P_STRING, P_LOCAL, &sDefault.szQueuepausecommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
844         {"queueresume command", P_STRING, P_LOCAL, &sDefault.szQueueresumecommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
845
846         {"enumports command", P_STRING, P_GLOBAL, &Globals.szEnumPortsCommand, NULL, NULL, 0},
847         {"addprinter command", P_STRING, P_GLOBAL, &Globals.szAddPrinterCommand, NULL, NULL, 0},
848         {"deleteprinter command", P_STRING, P_GLOBAL, &Globals.szDeletePrinterCommand, NULL, NULL, 0},
849         {"show add printer wizard", P_BOOL, P_GLOBAL, &Globals.bMsAddPrinterWizard, NULL, NULL, 0},
850         {"os2 driver map", P_STRING, P_GLOBAL, &Globals.szOs2DriverMap, NULL, NULL, 0},
851         
852         {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_PRINT},
853         {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, 0},
854         {"use client driver", P_BOOL, P_LOCAL, &sDefault.bUseClientDriver, NULL, NULL, FLAG_PRINT},
855         {"default devmode", P_BOOL, P_LOCAL, &sDefault.bDefaultDevmode, NULL, NULL, FLAG_PRINT},
856         {"printer driver", P_STRING, P_LOCAL, &sDefault.szPrinterDriver, NULL, NULL, FLAG_PRINT | FLAG_DEPRECATED},
857         {"printer driver file", P_STRING, P_LOCAL, &sDefault.szDriverFile, NULL, NULL, FLAG_PRINT | FLAG_DEPRECATED},
858         {"printer driver location", P_STRING, P_LOCAL, &sDefault.szPrinterDriverLocation, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL | FLAG_DEPRECATED},
859
860         {"Filename Handling", P_SEP, P_SEPARATOR},
861         {"strip dot", P_BOOL, P_GLOBAL, &Globals.bStripDot, NULL, NULL, 0},
862         {"mangling method", P_STRING, P_GLOBAL, &Globals.szManglingMethod, NULL, NULL, 0},
863         
864         {"mangled stack", P_INTEGER, P_GLOBAL, &Globals.mangled_stack, NULL, NULL, 0},
865         {"default case", P_ENUM, P_LOCAL, &sDefault.iDefaultCase, NULL, enum_case, FLAG_SHARE},
866         {"case sensitive", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
867         {"casesignames", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL, NULL, 0},
868         {"preserve case", P_BOOL, P_LOCAL, &sDefault.bCasePreserve, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
869         {"short preserve case", P_BOOL, P_LOCAL, &sDefault.bShortCasePreserve, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
870         {"mangle case", P_BOOL, P_LOCAL, &sDefault.bCaseMangle, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
871         {"mangling char", P_CHAR, P_LOCAL, &sDefault.magic_char, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
872         {"hide dot files", P_BOOL, P_LOCAL, &sDefault.bHideDotFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
873         {"hide unreadable", P_BOOL, P_LOCAL, &sDefault.bHideUnReadable, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
874         {"delete veto files", P_BOOL, P_LOCAL, &sDefault.bDeleteVetoFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
875         {"veto files", P_STRING, P_LOCAL, &sDefault.szVetoFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL },
876         {"hide files", P_STRING, P_LOCAL, &sDefault.szHideFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL },
877         {"veto oplock files", P_STRING, P_LOCAL, &sDefault.szVetoOplockFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL },
878         {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
879         {"map hidden", P_BOOL, P_LOCAL, &sDefault.bMap_hidden, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
880         {"map archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
881         {"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
882         {"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
883         {"stat cache", P_BOOL, P_GLOBAL, &Globals.bStatCache, NULL, NULL, 0},
884
885         {"Domain Options", P_SEP, P_SEPARATOR},
886         
887         {"machine password timeout", P_INTEGER, P_GLOBAL, &Globals.machine_password_timeout, NULL, NULL, 0},
888
889         {"Logon Options", P_SEP, P_SEPARATOR},
890
891         {"add user script", P_STRING, P_GLOBAL, &Globals.szAddUserScript, NULL, NULL, 0},
892         {"delete user script", P_STRING, P_GLOBAL, &Globals.szDelUserScript, NULL, NULL, 0},
893         {"add group script", P_STRING, P_GLOBAL, &Globals.szAddGroupScript, NULL, NULL, 0},
894         {"delete group script", P_STRING, P_GLOBAL, &Globals.szDelGroupScript, NULL, NULL, 0},
895         {"add user to group script", P_STRING, P_GLOBAL, &Globals.szAddUserToGroupScript, NULL, NULL, 0},
896         {"delete user from group script", P_STRING, P_GLOBAL, &Globals.szDelUserToGroupScript, NULL, NULL, 0},
897         {"add machine script", P_STRING, P_GLOBAL, &Globals.szAddMachineScript, NULL, NULL, 0},
898         {"shutdown script", P_STRING, P_GLOBAL, &Globals.szShutdownScript, NULL, NULL, 0},
899         {"abort shutdown script", P_STRING, P_GLOBAL, &Globals.szAbortShutdownScript, NULL, NULL, 0},
900
901         {"logon script", P_STRING, P_GLOBAL, &Globals.szLogonScript, NULL, NULL, 0},
902         {"logon path", P_STRING, P_GLOBAL, &Globals.szLogonPath, NULL, NULL, 0},
903         {"logon drive", P_STRING, P_GLOBAL, &Globals.szLogonDrive, NULL, NULL, 0},
904         {"logon home", P_STRING, P_GLOBAL, &Globals.szLogonHome, NULL, NULL, 0},
905         {"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL, NULL, 0},
906
907         {"Browse Options", P_SEP, P_SEPARATOR},
908         
909         {"os level", P_INTEGER, P_GLOBAL, &Globals.os_level, NULL, NULL, FLAG_BASIC},
910         {"lm announce", P_ENUM, P_GLOBAL, &Globals.lm_announce, NULL, enum_bool_auto, 0},
911         {"lm interval", P_INTEGER, P_GLOBAL, &Globals.lm_interval, NULL, NULL, 0},
912         {"preferred master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_BASIC},
913         {"prefered master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_HIDE},
914         {"local master", P_BOOL, P_GLOBAL, &Globals.bLocalMaster, NULL, NULL, FLAG_BASIC},
915         {"domain master", P_ENUM, P_GLOBAL, &Globals.bDomainMaster, NULL, enum_bool_auto, FLAG_BASIC},
916         {"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL, NULL, 0},
917         {"browseable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
918         {"browsable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, 0},
919         {"enhanced browsing", P_BOOL, P_GLOBAL, &Globals.enhanced_browsing, NULL, NULL},
920
921         {"WINS Options", P_SEP, P_SEPARATOR},
922         {"dns proxy", P_BOOL, P_GLOBAL, &Globals.bDNSproxy, NULL, NULL, 0},
923         {"wins proxy", P_BOOL, P_GLOBAL, &Globals.bWINSproxy, NULL, NULL, 0},
924         
925         {"wins server", P_STRING, P_GLOBAL, &Globals.szWINSserver, handle_wins_server_list, NULL, FLAG_BASIC},
926         {"wins support", P_BOOL, P_GLOBAL, &Globals.bWINSsupport, NULL, NULL, FLAG_BASIC},
927         {"wins hook", P_STRING, P_GLOBAL, &Globals.szWINSHook, NULL, NULL, 0},
928         {"wins partners", P_STRING, P_GLOBAL, &Globals.szWINSPartners, NULL, NULL, 0},
929
930         {"Locking Options", P_SEP, P_SEPARATOR},
931         
932         {"blocking locks", P_BOOL, P_LOCAL, &sDefault.bBlockingLocks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
933         {"csc policy", P_ENUM, P_LOCAL, &sDefault.iCSCPolicy, NULL, enum_csc_policy, FLAG_SHARE | FLAG_GLOBAL},
934         {"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL, NULL, FLAG_SHARE},
935         {"kernel oplocks", P_BOOL, P_GLOBAL, &Globals.bKernelOplocks, NULL, NULL, FLAG_GLOBAL},
936         {"locking", P_BOOL, P_LOCAL, &sDefault.bLocking, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
937         {"lock spin count", P_INTEGER, P_GLOBAL, &Globals.iLockSpinCount, NULL, NULL, FLAG_GLOBAL},
938         {"lock spin time", P_INTEGER, P_GLOBAL, &Globals.iLockSpinTime, NULL, NULL, FLAG_GLOBAL},
939         
940         {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
941         {"level2 oplocks", P_BOOL, P_LOCAL, &sDefault.bLevel2OpLocks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
942         {"oplock break wait time", P_INTEGER, P_GLOBAL, &Globals.oplock_break_wait_time, NULL, NULL, FLAG_GLOBAL},
943         {"oplock contention limit", P_INTEGER, P_LOCAL, &sDefault.iOplockContentionLimit, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
944         {"posix locking", P_BOOL, P_LOCAL, &sDefault.bPosixLocking, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
945         {"strict locking", P_BOOL, P_LOCAL, &sDefault.bStrictLocking, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
946         {"share modes", P_BOOL, P_LOCAL,  &sDefault.bShareModes, NULL, NULL, FLAG_SHARE|FLAG_GLOBAL},
947
948         {"Ldap Options", P_SEP, P_SEPARATOR},
949         
950         {"ldap suffix", P_STRING, P_GLOBAL, &Globals.szLdapSuffix, handle_ldap_suffix, NULL, 0},
951         {"ldap machine suffix", P_STRING, P_GLOBAL, &Globals.szLdapMachineSuffix, handle_ldap_machine_suffix, NULL, 0},
952         {"ldap user suffix", P_STRING, P_GLOBAL, &Globals.szLdapUserSuffix, handle_ldap_user_suffix, NULL, 0},
953         {"ldap filter", P_STRING, P_GLOBAL, &Globals.szLdapFilter, NULL, NULL, 0},
954         {"ldap admin dn", P_STRING, P_GLOBAL, &Globals.szLdapAdminDn, NULL, NULL, 0},
955         {"ldap ssl", P_ENUM, P_GLOBAL, &Globals.ldap_ssl, NULL, enum_ldap_ssl, 0},
956
957         {"Miscellaneous Options", P_SEP, P_SEPARATOR},
958         {"add share command", P_STRING, P_GLOBAL, &Globals.szAddShareCommand, NULL, NULL, 0},
959         {"change share command", P_STRING, P_GLOBAL, &Globals.szChangeShareCommand, NULL, NULL, 0},
960         {"delete share command", P_STRING, P_GLOBAL, &Globals.szDeleteShareCommand, NULL, NULL, 0},
961         
962         {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL, FLAG_HIDE},
963         {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, 0},
964         {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, 0},
965         {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, 0}, 
966         {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, 0},
967         {"pid directory", P_STRING, P_GLOBAL, &Globals.szPidDir, NULL, NULL, 0}, 
968 #ifdef WITH_UTMP
969         {"utmp directory", P_STRING, P_GLOBAL, &Globals.szUtmpDir, NULL, NULL, 0},
970         {"wtmp directory", P_STRING, P_GLOBAL, &Globals.szWtmpDir, NULL, NULL, 0},
971         {"utmp",          P_BOOL, P_GLOBAL, &Globals.bUtmp, NULL, NULL, 0},
972 #endif
973         
974         {"default service", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL, 0},
975         {"default", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL, 0},
976         {"message command", P_STRING, P_GLOBAL, &Globals.szMsgCommand, NULL, NULL, 0},
977         {"dfree command", P_STRING, P_GLOBAL, &Globals.szDfree, NULL, NULL, 0},
978         {"remote announce", P_STRING, P_GLOBAL, &Globals.szRemoteAnnounce, NULL, NULL, 0},
979         {"remote browse sync", P_STRING, P_GLOBAL, &Globals.szRemoteBrowseSync, NULL, NULL, 0},
980         {"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL, NULL, 0},
981         {"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL, NULL, 0},
982         {"time offset", P_INTEGER, P_GLOBAL, &extra_time_offset, NULL, NULL, 0},
983         {"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL, NULL, 0},
984         {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL, NULL, FLAG_HIDE},
985         
986         {"copy", P_STRING, P_LOCAL, &sDefault.szCopy, handle_copy, NULL, FLAG_HIDE},
987         {"include", P_STRING, P_LOCAL, &sDefault.szInclude, handle_include, NULL, FLAG_HIDE},
988         {"exec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL, FLAG_SHARE | FLAG_PRINT},
989         {"preexec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL, 0},
990         
991         {"preexec close", P_BOOL, P_LOCAL, &sDefault.bPreexecClose, NULL, NULL, FLAG_SHARE},
992         {"postexec", P_STRING, P_LOCAL, &sDefault.szPostExec, NULL, NULL, FLAG_SHARE | FLAG_PRINT},
993         {"root preexec", P_STRING, P_LOCAL, &sDefault.szRootPreExec, NULL, NULL, FLAG_SHARE | FLAG_PRINT},
994         {"root preexec close", P_BOOL, P_LOCAL, &sDefault.bRootpreexecClose, NULL, NULL, FLAG_SHARE},
995         {"root postexec", P_STRING, P_LOCAL, &sDefault.szRootPostExec, NULL, NULL, FLAG_SHARE | FLAG_PRINT},
996         {"available", P_BOOL, P_LOCAL, &sDefault.bAvailable, NULL, NULL, FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
997         {"volume", P_STRING, P_LOCAL, &sDefault.volume, NULL, NULL, FLAG_SHARE },
998         {"fstype", P_STRING, P_LOCAL, &sDefault.fstype, NULL, NULL, FLAG_SHARE},
999         {"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL, NULL, FLAG_SHARE},
1000         {"source environment", P_STRING, P_GLOBAL, &Globals.szSourceEnv, handle_source_env, NULL, 0},
1001         {"wide links", P_BOOL, P_LOCAL, &sDefault.bWidelinks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1002         {"follow symlinks", P_BOOL, P_LOCAL, &sDefault.bSymlinks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1003         {"dont descend", P_STRING, P_LOCAL, &sDefault.szDontdescend, NULL, NULL, FLAG_SHARE},
1004         {"magic script", P_STRING, P_LOCAL, &sDefault.szMagicScript, NULL, NULL, FLAG_SHARE},
1005         {"magic output", P_STRING, P_LOCAL, &sDefault.szMagicOutput, NULL, NULL, FLAG_SHARE},
1006         {"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1007         {"dos filemode", P_BOOL, P_LOCAL, &sDefault.bDosFilemode, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1008         {"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1009         {"dos filetime resolution", P_BOOL, P_LOCAL, &sDefault.bDosFiletimeResolution, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1010
1011         {"fake directory create times", P_BOOL, P_LOCAL, &sDefault.bFakeDirCreateTimes, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1012         {"panic action", P_STRING, P_GLOBAL, &Globals.szPanicAction, NULL, NULL, 0},
1013         {"hide local users", P_BOOL, P_GLOBAL, &Globals.bHideLocalUsers, NULL,
1014          NULL, 0},
1015
1016         {"VFS module options", P_SEP, P_SEPARATOR},
1017         
1018         {"vfs object", P_STRING, P_LOCAL, &sDefault.szVfsObjectFile, handle_vfs_object, NULL, FLAG_SHARE},
1019         {"vfs options", P_STRING, P_LOCAL, &sDefault.szVfsOptions, NULL, NULL, FLAG_SHARE},
1020
1021         
1022         {"msdfs root", P_BOOL, P_LOCAL, &sDefault.bMSDfsRoot, NULL, NULL, FLAG_SHARE},
1023         {"host msdfs", P_BOOL, P_GLOBAL, &Globals.bHostMSDfs, NULL, NULL, 0},
1024
1025         {"Winbind options", P_SEP, P_SEPARATOR},
1026
1027         {"winbind uid", P_STRING, P_GLOBAL, &Globals.szWinbindUID, handle_winbind_uid, NULL, 0},
1028         {"winbind gid", P_STRING, P_GLOBAL, &Globals.szWinbindGID, handle_winbind_gid, NULL, 0},
1029         {"template homedir", P_STRING, P_GLOBAL, &Globals.szTemplateHomedir, NULL, NULL, 0},
1030         {"template shell", P_STRING, P_GLOBAL, &Globals.szTemplateShell, NULL, NULL, 0},
1031         {"winbind separator", P_STRING, P_GLOBAL, &Globals.szWinbindSeparator, NULL, NULL, 0},
1032         {"winbind cache time", P_INTEGER, P_GLOBAL, &Globals.winbind_cache_time, NULL, NULL, 0},
1033         {"winbind enum users", P_BOOL, P_GLOBAL, &Globals.bWinbindEnumUsers, NULL, NULL, 0},
1034         {"winbind enum groups", P_BOOL, P_GLOBAL, &Globals.bWinbindEnumGroups, NULL, NULL, 0},
1035         {"winbind use default domain", P_BOOL, P_GLOBAL, &Globals.bWinbindUseDefaultDomain, NULL, NULL, 0},
1036
1037         {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
1038 };
1039
1040
1041 /***************************************************************************
1042 Initialise the sDefault parameter structure for the printer values.
1043 ***************************************************************************/
1044 static void init_printer_values(void)
1045 {
1046         string_set(&sDefault.szPrinterDriver, "");
1047         string_set(&sDefault.szDriverFile, dyn_DRIVERFILE);
1048
1049         /* choose defaults depending on the type of printing */
1050         switch (sDefault.iPrinting)
1051         {
1052                 case PRINT_BSD:
1053                 case PRINT_AIX:
1054                 case PRINT_LPRNT:
1055                 case PRINT_LPROS2:
1056                         string_set(&sDefault.szLpqcommand, "lpq -P%p");
1057                         string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
1058                         string_set(&sDefault.szPrintcommand,
1059                                    "lpr -r -P%p %s");
1060                         break;
1061
1062                 case PRINT_LPRNG:
1063                 case PRINT_PLP:
1064                         string_set(&sDefault.szLpqcommand, "lpq -P%p");
1065                         string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
1066                         string_set(&sDefault.szPrintcommand,
1067                                    "lpr -r -P%p %s");
1068                         string_set(&sDefault.szQueuepausecommand,
1069                                    "lpc stop %p");
1070                         string_set(&sDefault.szQueueresumecommand,
1071                                    "lpc start %p");
1072                         string_set(&sDefault.szLppausecommand,
1073                                    "lpc hold %p %j");
1074                         string_set(&sDefault.szLpresumecommand,
1075                                    "lpc release %p %j");
1076                         break;
1077
1078                 case PRINT_CUPS:
1079 #ifdef HAVE_CUPS
1080                         string_set(&sDefault.szLpqcommand, "");
1081                         string_set(&sDefault.szLprmcommand, "");
1082                         string_set(&sDefault.szPrintcommand, "");
1083                         string_set(&sDefault.szLppausecommand, "");
1084                         string_set(&sDefault.szLpresumecommand, "");
1085                         string_set(&sDefault.szQueuepausecommand, "");
1086                         string_set(&sDefault.szQueueresumecommand, "");
1087
1088                         string_set(&Globals.szPrintcapname, "cups");
1089 #else
1090                         string_set(&sDefault.szLpqcommand,
1091                                    "/usr/bin/lpstat -o %p");
1092                         string_set(&sDefault.szLprmcommand,
1093                                    "/usr/bin/cancel %p-%j");
1094                         string_set(&sDefault.szPrintcommand,
1095                                    "/usr/bin/lp -d %p %s; rm %s");
1096                         string_set(&sDefault.szLppausecommand,
1097                                    "lp -i %p-%j -H hold");
1098                         string_set(&sDefault.szLpresumecommand,
1099                                    "lp -i %p-%j -H resume");
1100                         string_set(&sDefault.szQueuepausecommand,
1101                                    "/usr/bin/disable %p");
1102                         string_set(&sDefault.szQueueresumecommand,
1103                                    "/usr/bin/enable %p");
1104                         string_set(&Globals.szPrintcapname, "lpstat");
1105 #endif /* HAVE_CUPS */
1106                         break;
1107
1108                 case PRINT_SYSV:
1109                 case PRINT_HPUX:
1110                         string_set(&sDefault.szLpqcommand, "lpstat -o%p");
1111                         string_set(&sDefault.szLprmcommand, "cancel %p-%j");
1112                         string_set(&sDefault.szPrintcommand,
1113                                    "lp -c -d%p %s; rm %s");
1114                         string_set(&sDefault.szQueuepausecommand,
1115                                    "disable %p");
1116                         string_set(&sDefault.szQueueresumecommand,
1117                                    "enable %p");
1118 #ifndef HPUX
1119                         string_set(&sDefault.szLppausecommand,
1120                                    "lp -i %p-%j -H hold");
1121                         string_set(&sDefault.szLpresumecommand,
1122                                    "lp -i %p-%j -H resume");
1123 #endif /* SYSV */
1124                         break;
1125
1126                 case PRINT_QNX:
1127                         string_set(&sDefault.szLpqcommand, "lpq -P%p");
1128                         string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
1129                         string_set(&sDefault.szPrintcommand, "lp -r -P%p %s");
1130                         break;
1131
1132                 case PRINT_SOFTQ:
1133                         string_set(&sDefault.szLpqcommand, "qstat -l -d%p");
1134                         string_set(&sDefault.szLprmcommand,
1135                                    "qstat -s -j%j -c");
1136                         string_set(&sDefault.szPrintcommand,
1137                                    "lp -d%p -s %s; rm %s");
1138                         string_set(&sDefault.szLppausecommand,
1139                                    "qstat -s -j%j -h");
1140                         string_set(&sDefault.szLpresumecommand,
1141                                    "qstat -s -j%j -r");
1142                         break;
1143 #ifdef DEVELOPER
1144         case PRINT_TEST:
1145         case PRINT_VLP:
1146                 string_set(&sDefault.szPrintcommand, "vlp print %p %s");
1147                 string_set(&sDefault.szLpqcommand, "vlp lpq %p");
1148                 string_set(&sDefault.szLprmcommand, "vlp lprm %p %j");
1149                 string_set(&sDefault.szLppausecommand, "vlp lppause %p %j");
1150                 string_set(&sDefault.szLpresumecommand, "vlp lpresum %p %j");
1151                 string_set(&sDefault.szQueuepausecommand, "vlp queuepause %p");
1152                 string_set(&sDefault.szQueueresumecommand, "vlp queueresume %p");
1153                 break;
1154 #endif /* DEVELOPER */
1155
1156         }
1157 }
1158
1159 /***************************************************************************
1160 Initialise the global parameter structure.
1161 ***************************************************************************/
1162 static void init_globals(void)
1163 {
1164         static BOOL done_init = False;
1165         pstring s;
1166
1167         if (!done_init)
1168         {
1169                 int i;
1170                 memset((void *)&Globals, '\0', sizeof(Globals));
1171
1172                 for (i = 0; parm_table[i].label; i++)
1173                         if ((parm_table[i].type == P_STRING ||
1174                              parm_table[i].type == P_USTRING) &&
1175                             parm_table[i].ptr)
1176                                 string_set(parm_table[i].ptr, "");
1177
1178                 string_set(&sDefault.fstype, FSTYPE_STRING);
1179
1180                 init_printer_values();
1181
1182                 done_init = True;
1183         }
1184
1185
1186         DEBUG(3, ("Initialising global parameters\n"));
1187
1188         string_set(&Globals.szSMBPasswdFile, dyn_SMB_PASSWD_FILE);
1189         string_set(&Globals.szPrivateDir, dyn_PRIVATE_DIR);
1190         string_set(&Globals.szPassdbBackend, "smbpasswd");
1191
1192         /* use the new 'hash2' method by default */
1193         string_set(&Globals.szManglingMethod, "hash2");
1194
1195         string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
1196
1197         /* using UTF8 by default allows us to support all chars */
1198         string_set(&Globals.unix_charset, "UTF8");
1199
1200         /*
1201          * Allow the default PASSWD_CHAT to be overridden in local.h.
1202          */
1203         string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
1204         string_set(&Globals.szWorkGroup, WORKGROUP);
1205         string_set(&Globals.szPasswdProgram, "");
1206         string_set(&Globals.szPrintcapname, PRINTCAP_NAME);
1207         string_set(&Globals.szPidDir, dyn_PIDDIR);
1208         string_set(&Globals.szLockDir, dyn_LOCKDIR);
1209         string_set(&Globals.szSocketAddress, "0.0.0.0");
1210         pstrcpy(s, "Samba ");
1211         pstrcat(s, VERSION);
1212         string_set(&Globals.szServerString, s);
1213         slprintf(s, sizeof(s) - 1, "%d.%d", DEFAULT_MAJOR_VERSION,
1214                  DEFAULT_MINOR_VERSION);
1215         string_set(&Globals.szAnnounceVersion, s);
1216
1217         pstrcpy(user_socket_options, DEFAULT_SOCKET_OPTIONS);
1218
1219         string_set(&Globals.szLogonDrive, "");
1220         /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
1221         string_set(&Globals.szLogonHome, "\\\\%N\\%U");
1222         string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
1223
1224         string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
1225         string_set(&Globals.szPasswordServer, "*");
1226
1227         Globals.bAlgorithmicRidBase = BASE_RID;
1228
1229         Globals.bLoadPrinters = True;
1230         Globals.max_packet = 65535;
1231         Globals.mangled_stack = 50;
1232         Globals.max_xmit = 65535;
1233         Globals.max_mux = 50;   /* This is *needed* for profile support. */
1234         Globals.lpqcachetime = 10;
1235         Globals.bDisableSpoolss = False;
1236         Globals.iMaxSmbdProcesses = 0;/* no limit specified */
1237         Globals.iTotalPrintJobs = 0;  /* no limit specified */
1238         Globals.pwordlevel = 0;
1239         Globals.unamelevel = 0;
1240         Globals.deadtime = 0;
1241         Globals.bLargeReadwrite = True;
1242         Globals.max_log_size = 5000;
1243         Globals.max_open_files = MAX_OPEN_FILES;
1244         Globals.maxprotocol = PROTOCOL_NT1;
1245         Globals.minprotocol = PROTOCOL_CORE;
1246         Globals.security = SEC_USER;
1247         Globals.paranoid_server_security = True;
1248         Globals.bEncryptPasswords = True;
1249         Globals.bUpdateEncrypt = False;
1250         Globals.bReadRaw = True;
1251         Globals.bWriteRaw = True;
1252         Globals.bReadPrediction = False;
1253         Globals.bReadbmpx = False;
1254         Globals.bNullPasswords = False;
1255         Globals.bObeyPamRestrictions = False;
1256         Globals.bStripDot = False;
1257         Globals.syslog = 1;
1258         Globals.bSyslogOnly = False;
1259         Globals.bAdminLog = False;
1260         Globals.bTimestampLogs = True;
1261         Globals.bDebugHiresTimestamp = False;
1262         Globals.bDebugPid = False;
1263         Globals.bDebugUid = False;
1264         Globals.max_ttl = 60 * 60 * 24 * 3;     /* 3 days default. */
1265         Globals.max_wins_ttl = 60 * 60 * 24 * 6;        /* 6 days default. */
1266         Globals.min_wins_ttl = 60 * 60 * 6;     /* 6 hours default. */
1267         Globals.machine_password_timeout = 60 * 60 * 24 * 7;    /* 7 days default. */
1268         Globals.change_notify_timeout = 60;     /* 1 minute default. */
1269         Globals.ReadSize = 16 * 1024;
1270         Globals.lm_announce = 2;        /* = Auto: send only if LM clients found */
1271         Globals.lm_interval = 60;
1272         Globals.stat_cache_size = 50;   /* Number of stat translations we'll keep */
1273         Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
1274 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
1275         Globals.bNISHomeMap = False;
1276 #ifdef WITH_NISPLUS_HOME
1277         string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
1278 #else
1279         string_set(&Globals.szNISHomeMapName, "auto.home");
1280 #endif
1281 #endif
1282         Globals.bTimeServer = False;
1283         Globals.bBindInterfacesOnly = False;
1284         Globals.bUnixPasswdSync = False;
1285         Globals.bPamPasswordChange = False;
1286         Globals.bPasswdChatDebug = False;
1287         Globals.bUnicode = True;        /* Do unicode on the wire by default */
1288         Globals.bNTPipeSupport = True;  /* Do NT pipes by default. */
1289         Globals.bNTStatusSupport = True; /* Use NT status by default. */
1290         Globals.bStatCache = True;      /* use stat cache by default */
1291         Globals.bRestrictAnonymous = False;
1292         Globals.bLanmanAuth = True;     /* Do use the LanMan hash if it is available */
1293         Globals.bNTLMAuth = True;       /* Do use NTLMv1 if it is available (otherwise NTLMv2) */
1294         Globals.map_to_guest = 0;       /* By Default, "Never" */
1295         Globals.min_passwd_length = MINPASSWDLENGTH;    /* By Default, 5. */
1296         Globals.oplock_break_wait_time = 0;     /* By Default, 0 msecs. */
1297         Globals.enhanced_browsing = True; 
1298         Globals.iLockSpinCount = 3; /* Try 2 times. */
1299         Globals.iLockSpinTime = 10; /* usec. */
1300 #ifdef MMAP_BLACKLIST
1301         Globals.bUseMmap = False;
1302 #else
1303         Globals.bUseMmap = True;
1304 #endif
1305
1306         /* hostname lookups can be very expensive and are broken on
1307            a large number of sites (tridge) */
1308         Globals.bHostnameLookups = False;
1309
1310         string_set(&Globals.szLdapSuffix, "");
1311         string_set(&Globals.szLdapMachineSuffix, "");
1312         string_set(&Globals.szLdapUserSuffix, "");
1313
1314         string_set(&Globals.szLdapFilter, "(&(uid=%u)(objectclass=sambaAccount))");
1315         string_set(&Globals.szLdapAdminDn, "");
1316         Globals.ldap_ssl = LDAP_SSL_ON;
1317
1318 /* these parameters are set to defaults that are more appropriate
1319    for the increasing samba install base:
1320
1321    as a member of the workgroup, that will possibly become a
1322    _local_ master browser (lm = True).  this is opposed to a forced
1323    local master browser startup (pm = True).
1324
1325    doesn't provide WINS server service by default (wsupp = False),
1326    and doesn't provide domain master browser services by default, either.
1327
1328 */
1329
1330         Globals.bMsAddPrinterWizard = True;
1331         Globals.bPreferredMaster = Auto;        /* depending on bDomainMaster */
1332         Globals.os_level = 20;
1333         Globals.bLocalMaster = True;
1334         Globals.bDomainMaster = Auto;   /* depending on bDomainLogons */
1335         Globals.bDomainLogons = False;
1336         Globals.bBrowseList = True;
1337         Globals.bWINSsupport = False;
1338         Globals.bWINSproxy = False;
1339
1340         Globals.bDNSproxy = True;
1341
1342         /* this just means to use them if they exist */
1343         Globals.bKernelOplocks = True;
1344
1345         Globals.bAllowTrustedDomains = True;
1346
1347         string_set(&Globals.szTemplateShell, "/bin/false");
1348         string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
1349         string_set(&Globals.szWinbindSeparator, "\\");
1350
1351         Globals.winbind_cache_time = 15;
1352         Globals.bWinbindEnumUsers = True;
1353         Globals.bWinbindEnumGroups = True;
1354         Globals.bWinbindUseDefaultDomain = False;
1355
1356         Globals.bUseSpnego = True;
1357
1358 }
1359
1360 static TALLOC_CTX *lp_talloc;
1361
1362 /******************************************************************* a
1363 free up temporary memory - called from the main loop
1364 ********************************************************************/
1365 void lp_talloc_free(void)
1366 {
1367         if (!lp_talloc)
1368                 return;
1369         talloc_destroy(lp_talloc);
1370         lp_talloc = NULL;
1371 }
1372
1373 /*******************************************************************
1374 convenience routine to grab string parameters into temporary memory
1375 and run standard_sub_basic on them. The buffers can be written to by
1376 callers without affecting the source string.
1377 ********************************************************************/
1378 static char *lp_string(const char *s)
1379 {
1380         size_t len = s ? strlen(s) : 0;
1381         char *ret;
1382
1383         /* The follow debug is useful for tracking down memory problems
1384            especially if you have an inner loop that is calling a lp_*()
1385            function that returns a string.  Perhaps this debug should be
1386            present all the time? */
1387
1388 #if 0
1389         DEBUG(10, ("lp_string(%s)\n", s));
1390 #endif
1391
1392         if (!lp_talloc)
1393                 lp_talloc = talloc_init_named("lp_talloc");
1394
1395         ret = (char *)talloc(lp_talloc, len + 100);     /* leave room for substitution */
1396
1397         if (!ret)
1398                 return NULL;
1399
1400         if (!s)
1401                 *ret = 0;
1402         else
1403                 StrnCpy(ret, s, len);
1404
1405         trim_string(ret, "\"", "\"");
1406
1407         standard_sub_basic(current_user_info.smb_name,ret);
1408         return (ret);
1409 }
1410
1411
1412 /*
1413    In this section all the functions that are used to access the 
1414    parameters from the rest of the program are defined 
1415 */
1416
1417 #define FN_GLOBAL_STRING(fn_name,ptr) \
1418  char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
1419 #define FN_GLOBAL_LIST(fn_name,ptr) \
1420  char **fn_name(void) {return(*(char ***)(ptr));}
1421 #define FN_GLOBAL_BOOL(fn_name,ptr) \
1422  BOOL fn_name(void) {return(*(BOOL *)(ptr));}
1423 #define FN_GLOBAL_CHAR(fn_name,ptr) \
1424  char fn_name(void) {return(*(char *)(ptr));}
1425 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
1426  int fn_name(void) {return(*(int *)(ptr));}
1427
1428 #define FN_LOCAL_STRING(fn_name,val) \
1429  char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
1430 #define FN_LOCAL_CONST_STRING(fn_name,val) \
1431  const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
1432 #define FN_LOCAL_LIST(fn_name,val) \
1433  char **fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1434 #define FN_LOCAL_BOOL(fn_name,val) \
1435  BOOL fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1436 #define FN_LOCAL_CHAR(fn_name,val) \
1437  char fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1438 #define FN_LOCAL_INTEGER(fn_name,val) \
1439  int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1440
1441 FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
1442 FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
1443 FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
1444 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
1445 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
1446 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
1447 FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
1448 FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
1449 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
1450 FN_GLOBAL_STRING(lp_printcapname, &Globals.szPrintcapname)
1451 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
1452 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
1453 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
1454 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
1455 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
1456 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
1457 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
1458 #ifdef WITH_UTMP
1459 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
1460 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
1461 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
1462 #endif
1463 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
1464 FN_GLOBAL_STRING(lp_source_environment, &Globals.szSourceEnv)
1465 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
1466 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
1467 FN_GLOBAL_STRING(lp_dfree_command, &Globals.szDfree)
1468 FN_GLOBAL_STRING(lp_hosts_equiv, &Globals.szHostsEquiv)
1469 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
1470 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
1471 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
1472 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
1473 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
1474 FN_GLOBAL_STRING(lp_workgroup, &Globals.szWorkGroup)
1475 FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
1476 FN_GLOBAL_STRING(lp_ads_server, &Globals.szADSserver)
1477 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
1478 FN_GLOBAL_STRING(lp_logon_script, &Globals.szLogonScript)
1479 FN_GLOBAL_STRING(lp_logon_path, &Globals.szLogonPath)
1480 FN_GLOBAL_STRING(lp_logon_drive, &Globals.szLogonDrive)
1481 FN_GLOBAL_STRING(lp_logon_home, &Globals.szLogonHome)
1482 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
1483 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
1484 FN_GLOBAL_STRING(lp_wins_server_list, &Globals.szWINSserver)
1485 FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
1486 FN_GLOBAL_STRING(lp_socket_address, &Globals.szSocketAddress)
1487 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
1488 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
1489 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
1490 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
1491 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
1492 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
1493
1494 FN_GLOBAL_STRING(lp_guestaccount, &Globals.szGuestaccount)
1495 FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
1496 FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
1497 FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
1498 FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserToGroupScript)
1499
1500 FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
1501
1502 FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
1503 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
1504
1505 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
1506 FN_GLOBAL_STRING(lp_wins_partners, &Globals.szWINSPartners)
1507 FN_GLOBAL_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
1508 FN_GLOBAL_STRING(lp_template_shell, &Globals.szTemplateShell)
1509 FN_GLOBAL_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
1510 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
1511 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
1512 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
1513 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
1514 FN_GLOBAL_STRING(lp_ldap_machine_suffix, &Globals.szLdapMachineSuffix)
1515 FN_GLOBAL_STRING(lp_ldap_user_suffix, &Globals.szLdapUserSuffix)
1516 FN_GLOBAL_STRING(lp_ldap_filter, &Globals.szLdapFilter)
1517 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
1518 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
1519 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
1520 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
1521 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
1522
1523 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
1524 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
1525 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
1526 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
1527 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
1528 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
1529 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
1530 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
1531 FN_GLOBAL_BOOL(lp_readprediction, &Globals.bReadPrediction)
1532 FN_GLOBAL_BOOL(lp_readbmpx, &Globals.bReadbmpx)
1533 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
1534 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
1535 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
1536 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
1537 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
1538 FN_GLOBAL_BOOL(lp_strip_dot, &Globals.bStripDot)
1539 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
1540 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
1541 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
1542 FN_GLOBAL_BOOL(lp_admin_log, &Globals.bAdminLog)
1543 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
1544 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
1545 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
1546 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
1547 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
1548 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
1549 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
1550 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
1551 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
1552 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
1553 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
1554 FN_GLOBAL_BOOL(lp_unicode, &Globals.bUnicode)
1555 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
1556 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
1557 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
1558 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
1559 FN_GLOBAL_BOOL(lp_restrict_anonymous, &Globals.bRestrictAnonymous)
1560 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
1561 FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
1562 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
1563 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
1564 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
1565 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
1566 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
1567 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
1568 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
1569 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
1570 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
1571 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
1572 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
1573 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
1574 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
1575 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
1576 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
1577 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
1578 FN_GLOBAL_INTEGER(lp_readsize, &Globals.ReadSize)
1579 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
1580 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
1581 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
1582 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
1583 FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
1584 FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
1585 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
1586 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
1587 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
1588 FN_GLOBAL_INTEGER(lp_disable_spoolss, &Globals.bDisableSpoolss)
1589 FN_GLOBAL_INTEGER(lp_totalprintjobs, &Globals.iTotalPrintJobs)
1590 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
1591 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
1592 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
1593 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
1594 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
1595 FN_GLOBAL_INTEGER(lp_change_notify_timeout, &Globals.change_notify_timeout)
1596 FN_GLOBAL_INTEGER(lp_stat_cache_size, &Globals.stat_cache_size)
1597 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
1598 FN_GLOBAL_INTEGER(lp_min_passwd_length, &Globals.min_passwd_length)
1599 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
1600 FN_GLOBAL_INTEGER(lp_lock_spin_count, &Globals.iLockSpinCount)
1601 FN_GLOBAL_INTEGER(lp_lock_sleep_time, &Globals.iLockSpinTime)
1602 FN_LOCAL_STRING(lp_preexec, szPreExec)
1603 FN_LOCAL_STRING(lp_postexec, szPostExec)
1604 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
1605 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
1606 FN_LOCAL_STRING(lp_servicename, szService)
1607 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
1608 FN_LOCAL_STRING(lp_pathname, szPath)
1609 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
1610 FN_LOCAL_STRING(lp_username, szUsername)
1611 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
1612 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
1613 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
1614 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
1615 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
1616 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
1617 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
1618 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
1619 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
1620 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
1621 static FN_LOCAL_STRING(_lp_printername, szPrintername)
1622 FN_LOCAL_STRING(lp_driverfile, szDriverFile)
1623 FN_LOCAL_STRING(lp_printerdriver, szPrinterDriver)
1624 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
1625 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
1626 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
1627 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
1628 FN_LOCAL_STRING(lp_comment, comment)
1629 FN_LOCAL_STRING(lp_force_user, force_user)
1630 FN_LOCAL_STRING(lp_force_group, force_group)
1631 FN_LOCAL_LIST(lp_readlist, readlist)
1632 FN_LOCAL_LIST(lp_writelist, writelist)
1633 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
1634 FN_LOCAL_STRING(lp_fstype, fstype)
1635 FN_LOCAL_STRING(lp_vfsobj, szVfsObjectFile)
1636 FN_LOCAL_STRING(lp_vfs_options, szVfsOptions)
1637 static FN_LOCAL_STRING(lp_volume, volume)
1638 FN_LOCAL_STRING(lp_mangled_map, szMangledMap)
1639 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
1640 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
1641 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
1642 FN_LOCAL_STRING(lp_driverlocation, szPrinterDriverLocation)
1643 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
1644 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
1645 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
1646 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
1647 FN_LOCAL_BOOL(lp_casesensitive, bCaseSensitive)
1648 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
1649 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
1650 FN_LOCAL_BOOL(lp_casemangle, bCaseMangle)
1651 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
1652 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
1653 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
1654 FN_LOCAL_BOOL(lp_readonly, bRead_only)
1655 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
1656 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
1657 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
1658 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
1659 FN_LOCAL_BOOL(lp_postscript, bPostscript)
1660 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
1661 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
1662 FN_LOCAL_BOOL(lp_locking, bLocking)
1663 FN_LOCAL_BOOL(lp_strict_locking, bStrictLocking)
1664 FN_LOCAL_BOOL(lp_posix_locking, bPosixLocking)
1665 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
1666 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
1667 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
1668 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
1669 FN_LOCAL_BOOL(lp_manglednames, bMangledNames)
1670 FN_LOCAL_BOOL(lp_widelinks, bWidelinks)
1671 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
1672 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
1673 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
1674 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
1675 FN_LOCAL_BOOL(lp_map_system, bMap_system)
1676 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
1677 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
1678 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
1679 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
1680 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
1681 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
1682 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
1683 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
1684 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
1685 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
1686 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
1687 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
1688 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
1689 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
1690 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
1691 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
1692 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
1693 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
1694 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
1695 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
1696 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
1697 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
1698 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
1699 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
1700 FN_LOCAL_INTEGER(lp_maxprintjobs, iMaxPrintJobs)
1701 FN_LOCAL_INTEGER(lp_printing, iPrinting)
1702 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
1703 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
1704 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
1705 FN_LOCAL_CHAR(lp_magicchar, magic_char)
1706 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
1707 FN_GLOBAL_BOOL(lp_hide_local_users, &Globals.bHideLocalUsers)
1708 FN_GLOBAL_BOOL(lp_algorithmic_rid_base, &Globals.bAlgorithmicRidBase)
1709
1710 typedef struct _param_opt_struct param_opt_struct;
1711 struct _param_opt_struct {
1712         char *key;
1713         char *value;
1714         param_opt_struct *prev, *next;
1715 };
1716
1717 static param_opt_struct *param_opt = NULL;
1718
1719 /* Return parametric option from given service. Type is a part of option before ':' */
1720 /* Parametric option has following syntax: 'Type: option = value' */
1721 /* Returned value is allocated in 'lp_talloc' context */
1722 char *lp_parm_string(const char *servicename, const char *type, const char *option)
1723 {
1724     param_opt_struct *data;
1725     pstring vfskey;
1726     
1727     if (param_opt != NULL) {
1728             ZERO_STRUCT(vfskey);
1729             pstr_sprintf(vfskey, "%s:%s:%s", (servicename==NULL) ? "global" : servicename,
1730                     type, option);
1731             data = param_opt;
1732             while (data) {
1733                     if (strcmp(data->key, vfskey) == 0) {
1734                             return lp_string(data->value);
1735                     }
1736                     data = data->next;
1737             }
1738             /* Try to fetch the same option but from globals */
1739             pstr_sprintf(vfskey, "global:%s:%s", type, option);
1740             data = param_opt;
1741             while (data) {
1742                     if (strcmp(data->key, vfskey) == 0) {
1743                             return lp_string(data->value);
1744                     }
1745                     data = data->next;
1746             }
1747         
1748     }
1749     return NULL;
1750 }
1751
1752 /* local prototypes */
1753
1754 static int map_parameter(char *pszParmName);
1755 static BOOL set_boolean(BOOL *pb, char *pszParmValue);
1756 static int getservicebyname(const char *pszServiceName,
1757                             service * pserviceDest);
1758 static void copy_service(service * pserviceDest,
1759                          service * pserviceSource, BOOL *pcopymapDest);
1760 static BOOL service_ok(int iService);
1761 static BOOL do_parameter(char *pszParmName, char *pszParmValue);
1762 static BOOL do_section(char *pszSectionName);
1763 static void init_copymap(service * pservice);
1764
1765
1766 /***************************************************************************
1767 initialise a service to the defaults
1768 ***************************************************************************/
1769 static void init_service(service * pservice)
1770 {
1771         memset((char *)pservice, '\0', sizeof(service));
1772         copy_service(pservice, &sDefault, NULL);
1773 }
1774
1775
1776 /***************************************************************************
1777 free the dynamically allocated parts of a service struct
1778 ***************************************************************************/
1779 static void free_service(service * pservice)
1780 {
1781         int i;
1782         if (!pservice)
1783                 return;
1784
1785         if (pservice->szService)
1786                 DEBUG(5,
1787                       ("free_service: Freeing service %s\n",
1788                        pservice->szService));
1789
1790         string_free(&pservice->szService);
1791         SAFE_FREE(pservice->copymap);
1792
1793         for (i = 0; parm_table[i].label; i++)
1794         {
1795                 if ((parm_table[i].type == P_STRING ||
1796                      parm_table[i].type == P_USTRING) &&
1797                     parm_table[i].class == P_LOCAL)
1798                         string_free((char **)
1799                                     (((char *)pservice) +
1800                                      PTR_DIFF(parm_table[i].ptr, &sDefault)));
1801                 else if (parm_table[i].type == P_LIST &&
1802                          parm_table[i].class == P_LOCAL)
1803                              lp_list_free((char ***)
1804                                             (((char *)pservice) +
1805                                              PTR_DIFF(parm_table[i].ptr, &sDefault)));
1806         }
1807                                 
1808
1809         ZERO_STRUCTP(pservice);
1810 }
1811
1812 /***************************************************************************
1813 add a new service to the services array initialising it with the given 
1814 service. 
1815 ***************************************************************************/
1816 static int add_a_service(const service * pservice, const char *name)
1817 {
1818         int i;
1819         service tservice;
1820         int num_to_alloc = iNumServices + 1;
1821
1822         tservice = *pservice;
1823
1824         /* it might already exist */
1825         if (name)
1826         {
1827                 i = getservicebyname(name, NULL);
1828                 if (i >= 0)
1829                         return (i);
1830         }
1831
1832         /* find an invalid one */
1833         for (i = 0; i < iNumServices; i++)
1834                 if (!ServicePtrs[i]->valid)
1835                         break;
1836
1837         /* if not, then create one */
1838         if (i == iNumServices)
1839         {
1840                 service **tsp;
1841                 
1842                 tsp = (service **) Realloc(ServicePtrs,
1843                                            sizeof(service *) *
1844                                            num_to_alloc);
1845                                            
1846                 if (!tsp) {
1847                         DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
1848                         return (-1);
1849                 }
1850                 else {
1851                         ServicePtrs = tsp;
1852                         ServicePtrs[iNumServices] =
1853                                 (service *) malloc(sizeof(service));
1854                 }
1855                 if (!ServicePtrs[iNumServices]) {
1856                         DEBUG(0,("add_a_service: out of memory!\n"));
1857                         return (-1);
1858                 }
1859
1860                 iNumServices++;
1861         }
1862         else
1863                 free_service(ServicePtrs[i]);
1864
1865         ServicePtrs[i]->valid = True;
1866
1867         init_service(ServicePtrs[i]);
1868         copy_service(ServicePtrs[i], &tservice, NULL);
1869         if (name)
1870         {
1871                 string_set(&ServicePtrs[i]->szService, name);
1872         }
1873         return (i);
1874 }
1875
1876 /***************************************************************************
1877 add a new home service, with the specified home directory, defaults coming 
1878 from service ifrom.
1879 ***************************************************************************/
1880 BOOL lp_add_home(const char *pszHomename, int iDefaultService, const char *pszHomedir)
1881 {
1882         int i;
1883         SMB_STRUCT_STAT buf;
1884
1885         /* if the user's home directory doesn't exist, then don't
1886            add it to the list of available shares */
1887         if (sys_stat(pszHomedir, &buf))
1888                 return False;
1889
1890         i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
1891
1892         if (i < 0)
1893                 return (False);
1894
1895         if (!(*(ServicePtrs[i]->szPath))
1896             || strequal(ServicePtrs[i]->szPath, lp_pathname(-1)))
1897                 string_set(&ServicePtrs[i]->szPath, pszHomedir);
1898         if (!(*(ServicePtrs[i]->comment)))
1899         {
1900                 pstring comment;
1901                 slprintf(comment, sizeof(comment) - 1,
1902                          "Home directory of %s", pszHomename);
1903                 string_set(&ServicePtrs[i]->comment, comment);
1904         }
1905         ServicePtrs[i]->bAvailable = sDefault.bAvailable;
1906         ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
1907
1908         DEBUG(3,
1909               ("adding home directory %s at %s\n", pszHomename, pszHomedir));
1910
1911         return (True);
1912 }
1913
1914 /***************************************************************************
1915 add a new service, based on an old one.
1916 ***************************************************************************/
1917 int lp_add_service(const char *pszService, int iDefaultService)
1918 {
1919         return (add_a_service(ServicePtrs[iDefaultService], pszService));
1920 }
1921
1922
1923 /***************************************************************************
1924 add the IPC service
1925 ***************************************************************************/
1926 static BOOL lp_add_ipc(char *ipc_name, BOOL guest_ok)
1927 {
1928         pstring comment;
1929         int i = add_a_service(&sDefault, ipc_name);
1930
1931         if (i < 0)
1932                 return (False);
1933
1934         slprintf(comment, sizeof(comment) - 1,
1935                  "IPC Service (%s)", Globals.szServerString);
1936
1937         string_set(&ServicePtrs[i]->szPath, tmpdir());
1938         string_set(&ServicePtrs[i]->szUsername, "");
1939         string_set(&ServicePtrs[i]->comment, comment);
1940         string_set(&ServicePtrs[i]->fstype, "IPC");
1941         ServicePtrs[i]->iMaxConnections = 0;
1942         ServicePtrs[i]->bAvailable = True;
1943         ServicePtrs[i]->bRead_only = True;
1944         ServicePtrs[i]->bGuest_only = False;
1945         ServicePtrs[i]->bGuest_ok = guest_ok;
1946         ServicePtrs[i]->bPrint_ok = False;
1947         ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
1948
1949         DEBUG(3, ("adding IPC service\n"));
1950
1951         return (True);
1952 }
1953
1954
1955 /***************************************************************************
1956 add a new printer service, with defaults coming from service iFrom.
1957 ***************************************************************************/
1958 BOOL lp_add_printer(char *pszPrintername, int iDefaultService)
1959 {
1960         char *comment = "From Printcap";
1961         int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
1962
1963         if (i < 0)
1964                 return (False);
1965
1966         /* note that we do NOT default the availability flag to True - */
1967         /* we take it from the default service passed. This allows all */
1968         /* dynamic printers to be disabled by disabling the [printers] */
1969         /* entry (if/when the 'available' keyword is implemented!).    */
1970
1971         /* the printer name is set to the service name. */
1972         string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
1973         string_set(&ServicePtrs[i]->comment, comment);
1974         ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
1975         /* Printers cannot be read_only. */
1976         ServicePtrs[i]->bRead_only = False;
1977         /* No share modes on printer services. */
1978         ServicePtrs[i]->bShareModes = False;
1979         /* No oplocks on printer services. */
1980         ServicePtrs[i]->bOpLocks = False;
1981         /* Printer services must be printable. */
1982         ServicePtrs[i]->bPrint_ok = True;
1983
1984         DEBUG(3, ("adding printer service %s\n", pszPrintername));
1985
1986         return (True);
1987 }
1988
1989 /***************************************************************************
1990 Map a parameter's string representation to something we can use. 
1991 Returns False if the parameter string is not recognised, else TRUE.
1992 ***************************************************************************/
1993 static int map_parameter(char *pszParmName)
1994 {
1995         int iIndex;
1996
1997         if (*pszParmName == '-')
1998                 return (-1);
1999
2000         for (iIndex = 0; parm_table[iIndex].label; iIndex++)
2001                 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
2002                         return (iIndex);
2003
2004         /* Warn only if it isn't parametric option */
2005         if (strchr(pszParmName, ':') == NULL)
2006                 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
2007         /* We do return 'fail' for parametric options as well because they are
2008            stored in different storage
2009          */
2010         return (-1);
2011 }
2012
2013
2014 /***************************************************************************
2015 Set a boolean variable from the text value stored in the passed string.
2016 Returns True in success, False if the passed string does not correctly 
2017 represent a boolean.
2018 ***************************************************************************/
2019 static BOOL set_boolean(BOOL *pb, char *pszParmValue)
2020 {
2021         BOOL bRetval;
2022
2023         bRetval = True;
2024         if (strwicmp(pszParmValue, "yes") == 0 ||
2025             strwicmp(pszParmValue, "true") == 0 ||
2026             strwicmp(pszParmValue, "1") == 0)
2027                 *pb = True;
2028         else
2029                 if (strwicmp(pszParmValue, "no") == 0 ||
2030                     strwicmp(pszParmValue, "False") == 0 ||
2031                     strwicmp(pszParmValue, "0") == 0)
2032                 *pb = False;
2033         else
2034         {
2035                 DEBUG(0,
2036                       ("ERROR: Badly formed boolean in configuration file: \"%s\".\n",
2037                        pszParmValue));
2038                 bRetval = False;
2039         }
2040         return (bRetval);
2041 }
2042
2043 /***************************************************************************
2044 Find a service by name. Otherwise works like get_service.
2045 ***************************************************************************/
2046 static int getservicebyname(const char *pszServiceName, service * pserviceDest)
2047 {
2048         int iService;
2049
2050         for (iService = iNumServices - 1; iService >= 0; iService--)
2051                 if (VALID(iService) &&
2052                     strwicmp(ServicePtrs[iService]->szService, pszServiceName) == 0)
2053                 {
2054                         if (pserviceDest != NULL)
2055                                 copy_service(pserviceDest, ServicePtrs[iService], NULL);
2056                         break;
2057                 }
2058
2059         return (iService);
2060 }
2061
2062
2063
2064 /***************************************************************************
2065 Copy a service structure to another
2066
2067 If pcopymapDest is NULL then copy all fields
2068 ***************************************************************************/
2069 static void copy_service(service * pserviceDest,
2070                          service * pserviceSource, BOOL *pcopymapDest)
2071 {
2072         int i;
2073         BOOL bcopyall = (pcopymapDest == NULL);
2074
2075         for (i = 0; parm_table[i].label; i++)
2076                 if (parm_table[i].ptr && parm_table[i].class == P_LOCAL &&
2077                     (bcopyall || pcopymapDest[i]))
2078                 {
2079                         void *def_ptr = parm_table[i].ptr;
2080                         void *src_ptr =
2081                                 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
2082                                                                     &sDefault);
2083                         void *dest_ptr =
2084                                 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
2085                                                                   &sDefault);
2086
2087                         switch (parm_table[i].type)
2088                         {
2089                                 case P_BOOL:
2090                                 case P_BOOLREV:
2091                                         *(BOOL *)dest_ptr = *(BOOL *)src_ptr;
2092                                         break;
2093
2094                                 case P_INTEGER:
2095                                 case P_ENUM:
2096                                 case P_OCTAL:
2097                                         *(int *)dest_ptr = *(int *)src_ptr;
2098                                         break;
2099
2100                                 case P_CHAR:
2101                                         *(char *)dest_ptr = *(char *)src_ptr;
2102                                         break;
2103
2104                                 case P_STRING:
2105                                         string_set(dest_ptr,
2106                                                    *(char **)src_ptr);
2107                                         break;
2108
2109                                 case P_USTRING:
2110                                         string_set(dest_ptr,
2111                                                    *(char **)src_ptr);
2112                                         strupper(*(char **)dest_ptr);
2113                                         break;
2114                                 case P_LIST:
2115                                         lp_list_copy((char ***)dest_ptr, *(char ***)src_ptr);
2116                                         break;
2117                                 default:
2118                                         break;
2119                         }
2120                 }
2121
2122         if (bcopyall)
2123         {
2124                 init_copymap(pserviceDest);
2125                 if (pserviceSource->copymap)
2126                         memcpy((void *)pserviceDest->copymap,
2127                                (void *)pserviceSource->copymap,
2128                                sizeof(BOOL) * NUMPARAMETERS);
2129         }
2130 }
2131
2132 /***************************************************************************
2133 Check a service for consistency. Return False if the service is in any way
2134 incomplete or faulty, else True.
2135 ***************************************************************************/
2136 static BOOL service_ok(int iService)
2137 {
2138         BOOL bRetval;
2139
2140         bRetval = True;
2141         if (ServicePtrs[iService]->szService[0] == '\0')
2142         {
2143                 DEBUG(0,
2144                       ("The following message indicates an internal error:\n"));
2145                 DEBUG(0, ("No service name in service entry.\n"));
2146                 bRetval = False;
2147         }
2148
2149         /* The [printers] entry MUST be printable. I'm all for flexibility, but */
2150         /* I can't see why you'd want a non-printable printer service...        */
2151         if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
2152                 if (!ServicePtrs[iService]->bPrint_ok) {
2153                         DEBUG(0,
2154                               ("WARNING: [%s] service MUST be printable!\n",
2155                                ServicePtrs[iService]->szService));
2156                         ServicePtrs[iService]->bPrint_ok = True;
2157                 }
2158                 /* [printers] service must also be non-browsable. */
2159                 if (ServicePtrs[iService]->bBrowseable)
2160                         ServicePtrs[iService]->bBrowseable = False;
2161         }
2162
2163         if (ServicePtrs[iService]->szPath[0] == '\0' &&
2164             strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0)
2165         {
2166                 DEBUG(0,
2167                       ("No path in service %s - using %s\n",
2168                        ServicePtrs[iService]->szService, tmpdir()));
2169                 string_set(&ServicePtrs[iService]->szPath, tmpdir());
2170         }
2171
2172         /* If a service is flagged unavailable, log the fact at level 0. */
2173         if (!ServicePtrs[iService]->bAvailable)
2174                 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
2175                           ServicePtrs[iService]->szService));
2176
2177         return (bRetval);
2178 }
2179
2180 static struct file_lists
2181 {
2182         struct file_lists *next;
2183         char *name;
2184         char *subfname;
2185         time_t modtime;
2186 }
2187  *file_lists = NULL;
2188
2189 /*******************************************************************
2190 keep a linked list of all config files so we know when one has changed 
2191 it's date and needs to be reloaded
2192 ********************************************************************/
2193 static void add_to_file_list(const char *fname, const char *subfname)
2194 {
2195         struct file_lists *f = file_lists;
2196
2197         while (f)
2198         {
2199                 if (f->name && !strcmp(f->name, fname))
2200                         break;
2201                 f = f->next;
2202         }
2203
2204         if (!f)
2205         {
2206                 f = (struct file_lists *)malloc(sizeof(file_lists[0]));
2207                 if (!f)
2208                         return;
2209                 f->next = file_lists;
2210                 f->name = strdup(fname);
2211                 if (!f->name)
2212                 {
2213                         SAFE_FREE(f);
2214                         return;
2215                 }
2216                 f->subfname = strdup(subfname);
2217                 if (!f->subfname)
2218                 {
2219                         SAFE_FREE(f);
2220                         return;
2221                 }
2222                 file_lists = f;
2223                 f->modtime = file_modtime(subfname);
2224         } else {
2225                 time_t t = file_modtime(subfname);
2226                 if (t)
2227                         f->modtime = t;
2228         }
2229 }
2230
2231 /*******************************************************************
2232 check if a config file has changed date
2233 ********************************************************************/
2234 BOOL lp_file_list_changed(void)
2235 {
2236         struct file_lists *f = file_lists;
2237         DEBUG(6, ("lp_file_list_changed()\n"));
2238
2239         while (f) {
2240                 pstring n2;
2241                 time_t mod_time;
2242
2243                 pstrcpy(n2, f->name);
2244                 standard_sub_basic(current_user_info.smb_name, n2);
2245
2246                 DEBUGADD(6, ("file %s -> %s  last mod_time: %s\n",
2247                              f->name, n2, ctime(&f->modtime)));
2248
2249                 mod_time = file_modtime(n2);
2250
2251                 if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
2252                         DEBUGADD(6,
2253                                  ("file %s modified: %s\n", n2,
2254                                   ctime(&mod_time)));
2255                         f->modtime = mod_time;
2256                         SAFE_FREE(f->subfname);
2257                         f->subfname = strdup(n2);
2258                         return (True);
2259                 }
2260                 f = f->next;
2261         }
2262         return (False);
2263 }
2264
2265 /***************************************************************************
2266  Run standard_sub_basic on netbios name... needed because global_myname
2267  is not accessed through any lp_ macro.
2268  Note: We must *NOT* use string_set() here as ptr points to global_myname.
2269 ***************************************************************************/
2270
2271 static BOOL handle_netbios_name(char *pszParmValue, char **ptr)
2272 {
2273         pstring netbios_name;
2274
2275         pstrcpy(netbios_name, pszParmValue);
2276
2277         standard_sub_basic(current_user_info.smb_name, netbios_name);
2278         strupper(netbios_name);
2279
2280         pstrcpy(global_myname, netbios_name);
2281
2282         DEBUG(4,
2283               ("handle_netbios_name: set global_myname to: %s\n",
2284                global_myname));
2285
2286         return (True);
2287 }
2288
2289 /***************************************************************************
2290  Do the work of sourcing in environment variable/value pairs.
2291 ***************************************************************************/
2292
2293 static BOOL source_env(char **lines)
2294 {
2295         char *varval;
2296         size_t len;
2297         int i;
2298         char *p;
2299
2300         for (i = 0; lines[i]; i++)
2301         {
2302                 char *line = lines[i];
2303
2304                 if ((len = strlen(line)) == 0)
2305                         continue;
2306
2307                 if (line[len - 1] == '\n')
2308                         line[--len] = '\0';
2309
2310                 if ((varval = malloc(len + 1)) == NULL)
2311                 {
2312                         DEBUG(0, ("source_env: Not enough memory!\n"));
2313                         return (False);
2314                 }
2315
2316                 DEBUG(4, ("source_env: Adding to environment: %s\n", line));
2317                 strncpy(varval, line, len);
2318                 varval[len] = '\0';
2319
2320                 p = strchr_m(line, (int)'=');
2321                 if (p == NULL)
2322                 {
2323                         DEBUG(4, ("source_env: missing '=': %s\n", line));
2324                         continue;
2325                 }
2326
2327                 if (putenv(varval))
2328                 {
2329                         DEBUG(0,
2330                               ("source_env: Failed to put environment variable %s\n",
2331                                varval));
2332                         continue;
2333                 }
2334
2335                 *p = '\0';
2336                 p++;
2337                 DEBUG(4,
2338                       ("source_env: getting var %s = %s\n", line,
2339                        getenv(line)));
2340         }
2341
2342         DEBUG(4, ("source_env: returning successfully\n"));
2343         return (True);
2344 }
2345
2346 /***************************************************************************
2347  Handle the source environment operation
2348 ***************************************************************************/
2349
2350 static BOOL handle_source_env(char *pszParmValue, char **ptr)
2351 {
2352         pstring fname;
2353         char *p = fname;
2354         BOOL result;
2355         char **lines;
2356
2357         pstrcpy(fname, pszParmValue);
2358
2359         standard_sub_basic(current_user_info.smb_name, fname);
2360
2361         string_set(ptr, pszParmValue);
2362
2363         DEBUG(4, ("handle_source_env: checking env type\n"));
2364
2365         /*
2366          * Filename starting with '|' means popen and read from stdin.
2367          */
2368
2369         if (*p == '|')
2370         {
2371                 lines = file_lines_pload(p + 1, NULL);
2372         }
2373         else
2374         {
2375                 lines = file_lines_load(fname, NULL);
2376         }
2377
2378         if (!lines)
2379         {
2380                 DEBUG(0,
2381                       ("handle_source_env: Failed to open file %s, Error was %s\n",
2382                        fname, strerror(errno)));
2383                 return (False);
2384         }
2385
2386         result = source_env(lines);
2387         file_lines_free(lines);
2388
2389         return (result);
2390 }
2391
2392 /***************************************************************************
2393   handle the interpretation of the vfs object parameter
2394   *************************************************************************/
2395 static BOOL handle_vfs_object(char *pszParmValue, char **ptr)
2396 {
2397         /* Set string value */
2398
2399         string_set(ptr, pszParmValue);
2400
2401         /* Do any other initialisation required for vfs.  Note that
2402            anything done here may have linking repercussions in nmbd. */
2403
2404         return True;
2405 }
2406
2407
2408 /***************************************************************************
2409 handle the include operation
2410 ***************************************************************************/
2411
2412 static BOOL handle_include(char *pszParmValue, char **ptr)
2413 {
2414         pstring fname;
2415         pstrcpy(fname, pszParmValue);
2416
2417         standard_sub_basic(current_user_info.smb_name, fname);
2418
2419         add_to_file_list(pszParmValue, fname);
2420
2421         string_set(ptr, fname);
2422
2423         if (file_exist(fname, NULL))
2424                 return (pm_process(fname, do_section, do_parameter));
2425
2426         DEBUG(2, ("Can't find include file %s\n", fname));
2427
2428         return (False);
2429 }
2430
2431
2432 /***************************************************************************
2433 handle the interpretation of the copy parameter
2434 ***************************************************************************/
2435 static BOOL handle_copy(char *pszParmValue, char **ptr)
2436 {
2437         BOOL bRetval;
2438         int iTemp;
2439         service serviceTemp;
2440
2441         string_set(ptr, pszParmValue);
2442
2443         init_service(&serviceTemp);
2444
2445         bRetval = False;
2446
2447         DEBUG(3, ("Copying service from service %s\n", pszParmValue));
2448
2449         if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0)
2450         {
2451                 if (iTemp == iServiceIndex)
2452                 {
2453                         DEBUG(0,
2454                               ("Can't copy service %s - unable to copy self!\n",
2455                                pszParmValue));
2456                 }
2457                 else
2458                 {
2459                         copy_service(ServicePtrs[iServiceIndex],
2460                                      &serviceTemp,
2461                                      ServicePtrs[iServiceIndex]->copymap);
2462                         bRetval = True;
2463                 }
2464         }
2465         else
2466         {
2467                 DEBUG(0, ("Unable to copy service - source not found: %s\n",
2468                           pszParmValue));
2469                 bRetval = False;
2470         }
2471
2472         free_service(&serviceTemp);
2473         return (bRetval);
2474 }
2475
2476 /***************************************************************************
2477  Handle winbind/non unix account uid and gid allocation parameters.  The format of these
2478  parameters is:
2479
2480  [global]
2481
2482         winbind uid = 1000-1999
2483         winbind gid = 700-899
2484
2485  We only do simple parsing checks here.  The strings are parsed into useful
2486  structures in the winbind daemon code.
2487
2488 ***************************************************************************/
2489
2490 /* Some lp_ routines to return winbind [ug]id information */
2491
2492 static uid_t winbind_uid_low, winbind_uid_high;
2493 static gid_t winbind_gid_low, winbind_gid_high;
2494 static uint32 non_unix_account_low, non_unix_account_high;
2495
2496 BOOL lp_winbind_uid(uid_t *low, uid_t *high)
2497 {
2498         if (winbind_uid_low == 0 || winbind_uid_high == 0)
2499                 return False;
2500
2501         if (low)
2502                 *low = winbind_uid_low;
2503
2504         if (high)
2505                 *high = winbind_uid_high;
2506
2507         return True;
2508 }
2509
2510 BOOL lp_winbind_gid(gid_t *low, gid_t *high)
2511 {
2512         if (winbind_gid_low == 0 || winbind_gid_high == 0)
2513                 return False;
2514
2515         if (low)
2516                 *low = winbind_gid_low;
2517
2518         if (high)
2519                 *high = winbind_gid_high;
2520
2521         return True;
2522 }
2523
2524 BOOL lp_non_unix_account_range(uint32 *low, uint32 *high)
2525 {
2526         if (non_unix_account_low == 0 || non_unix_account_high == 0)
2527                 return False;
2528
2529         if (low)
2530                 *low = non_unix_account_low;
2531
2532         if (high)
2533                 *high = non_unix_account_high;
2534
2535         return True;
2536 }
2537
2538 /* Do some simple checks on "winbind [ug]id" parameter values */
2539
2540 static BOOL handle_winbind_uid(char *pszParmValue, char **ptr)
2541 {
2542         uint32 low, high;
2543
2544         if (sscanf(pszParmValue, "%u-%u", &low, &high) != 2 || high < low)
2545                 return False;
2546
2547         /* Parse OK */
2548
2549         string_set(ptr, pszParmValue);
2550
2551         winbind_uid_low = low;
2552         winbind_uid_high = high;
2553
2554         return True;
2555 }
2556
2557 static BOOL handle_winbind_gid(char *pszParmValue, char **ptr)
2558 {
2559         uint32 low, high;
2560
2561         if (sscanf(pszParmValue, "%u-%u", &low, &high) != 2 || high < low)
2562                 return False;
2563
2564         /* Parse OK */
2565
2566         string_set(ptr, pszParmValue);
2567
2568         winbind_gid_low = low;
2569         winbind_gid_high = high;
2570
2571         return True;
2572 }
2573
2574 /* Do some simple checks on "non unix account range" parameter values */
2575
2576 static BOOL handle_non_unix_account_range(char *pszParmValue, char **ptr)
2577 {
2578         uint32 low, high;
2579
2580         if (sscanf(pszParmValue, "%u-%u", &low, &high) != 2 || high < low)
2581                 return False;
2582
2583         /* Parse OK */
2584
2585         string_set(ptr, pszParmValue);
2586
2587         non_unix_account_low = low;
2588         non_unix_account_high = high;
2589
2590         return True;
2591 }
2592
2593 /***************************************************************************
2594  Handle the WINS SERVER list
2595 ***************************************************************************/
2596 static BOOL handle_wins_server_list( char *pszParmValue, char **ptr )
2597   {
2598   if( !wins_srv_load_list( pszParmValue ) )
2599     return( False );  /* Parse failed. */
2600
2601   string_set( ptr, pszParmValue );
2602   return( True );
2603   }
2604
2605
2606 /***************************************************************************
2607  Handle the DEBUG level list
2608 ***************************************************************************/
2609 static BOOL handle_debug_list( char *pszParmValueIn, char **ptr )
2610 {
2611         pstring pszParmValue;
2612
2613         pstrcpy(pszParmValue, pszParmValueIn);
2614         return debug_parse_levels( pszParmValue );
2615 }
2616
2617 /***************************************************************************
2618  Handle the ldap machine suffix option
2619 ***************************************************************************/
2620 static BOOL handle_ldap_machine_suffix( char *pszParmValue, char **ptr)
2621 {
2622        pstring suffix;
2623        
2624        pstrcpy(suffix, pszParmValue);
2625
2626        if (! *Globals.szLdapSuffix ) {
2627                string_set( ptr, suffix );
2628                return True;
2629        }
2630
2631        if (! strstr(suffix, Globals.szLdapSuffix) ) {
2632                if ( *pszParmValue )
2633                        pstrcat(suffix, ",");
2634                pstrcat(suffix, Globals.szLdapSuffix);
2635        }
2636        string_set( ptr, suffix );
2637        return True;
2638 }
2639
2640 /***************************************************************************
2641  Handle the ldap user suffix option
2642 ***************************************************************************/
2643 static BOOL handle_ldap_user_suffix( char *pszParmValue, char **ptr)
2644 {
2645        pstring suffix;
2646        
2647        pstrcpy(suffix, pszParmValue);
2648
2649        if (! *Globals.szLdapSuffix ) {
2650                string_set( ptr, suffix );
2651                return True;
2652        }
2653        
2654        if (! strstr(suffix, Globals.szLdapSuffix) ) {
2655                if ( *pszParmValue )
2656                        pstrcat(suffix, ",");
2657                pstrcat(suffix, Globals.szLdapSuffix);
2658        }
2659        string_set( ptr, suffix );
2660        return True;
2661 }
2662
2663 /***************************************************************************
2664  Handle setting ldap suffix and determines whether ldap machine suffix needs
2665  to be set as well
2666 ***************************************************************************/
2667 static BOOL handle_ldap_suffix( char *pszParmValue, char **ptr)
2668 {
2669        pstring suffix;
2670        pstring user_suffix;
2671        pstring machine_suffix;
2672                
2673        pstrcpy(suffix, pszParmValue);
2674
2675        if (! *Globals.szLdapMachineSuffix )
2676                string_set(&Globals.szLdapMachineSuffix, suffix);
2677        if (! *Globals.szLdapUserSuffix ) 
2678                string_set(&Globals.szLdapUserSuffix, suffix);
2679        
2680        if (! strstr(Globals.szLdapMachineSuffix, suffix)) {
2681                pstrcpy(machine_suffix, Globals.szLdapMachineSuffix);
2682                if ( *Globals.szLdapMachineSuffix )
2683                        pstrcat(machine_suffix, ",");
2684                pstrcat(machine_suffix, suffix);
2685                string_set(&Globals.szLdapMachineSuffix, machine_suffix);       
2686        }
2687
2688        if (! strstr(Globals.szLdapUserSuffix, suffix)) {
2689                pstrcpy(user_suffix, Globals.szLdapUserSuffix);
2690                if ( *Globals.szLdapUserSuffix )
2691                        pstrcat(user_suffix, ",");
2692                pstrcat(user_suffix, suffix);   
2693                string_set(&Globals.szLdapUserSuffix, user_suffix);
2694        } 
2695
2696        string_set(ptr, suffix); 
2697        return True;
2698 }
2699
2700 /***************************************************************************
2701 initialise a copymap
2702 ***************************************************************************/
2703 static void init_copymap(service * pservice)
2704 {
2705         int i;
2706         SAFE_FREE(pservice->copymap);
2707         pservice->copymap = (BOOL *)malloc(sizeof(BOOL) * NUMPARAMETERS);
2708         if (!pservice->copymap)
2709                 DEBUG(0,
2710                       ("Couldn't allocate copymap!! (size %d)\n",
2711                        (int)NUMPARAMETERS));
2712         else
2713                 for (i = 0; i < NUMPARAMETERS; i++)
2714                         pservice->copymap[i] = True;
2715 }
2716
2717
2718 /***************************************************************************
2719  return the local pointer to a parameter given the service number and the 
2720  pointer into the default structure
2721 ***************************************************************************/
2722 void *lp_local_ptr(int snum, void *ptr)
2723 {
2724         return (void *)(((char *)ServicePtrs[snum]) + PTR_DIFF(ptr, &sDefault));
2725 }
2726
2727 /***************************************************************************
2728 Process a parameter for a particular service number. If snum < 0
2729 then assume we are in the globals
2730 ***************************************************************************/
2731 BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
2732 {
2733         int parmnum, i, slen;
2734         void *parm_ptr = NULL;  /* where we are going to store the result */
2735         void *def_ptr = NULL;
2736         pstring vfskey;
2737         char *sep;
2738         param_opt_struct *paramo;
2739
2740         parmnum = map_parameter(pszParmName);
2741
2742         if (parmnum < 0)
2743         {
2744                 if ((sep=strchr(pszParmName, ':')) != NULL) {
2745                         *sep = 0;
2746                         ZERO_STRUCT(vfskey);
2747                         pstr_sprintf(vfskey, "%s:%s:", 
2748                                 (snum >= 0) ? lp_servicename(snum) : "global", pszParmName);
2749                         slen = strlen(vfskey);
2750                         safe_strcat(vfskey, sep+1, sizeof(pstring));
2751                         trim_string(vfskey+slen, " ", " ");
2752                         paramo = smb_xmalloc(sizeof(param_opt_struct));
2753                         paramo->key = strdup(vfskey);
2754                         paramo->value = strdup(pszParmValue);
2755                         DLIST_ADD(param_opt, paramo);
2756                         *sep = ':';
2757                         return (True);
2758                 }
2759                 DEBUG(0,
2760                       ("Ignoring unknown parameter \"%s\"\n", pszParmName));
2761                 return (True);
2762         }
2763
2764         if (parm_table[parmnum].flags & FLAG_DEPRECATED)
2765         {
2766                 DEBUG(1, ("WARNING: The \"%s\"option is deprecated\n",
2767                           pszParmName));
2768         }
2769
2770         def_ptr = parm_table[parmnum].ptr;
2771
2772         /* we might point at a service, the default service or a global */
2773         if (snum < 0)
2774         {
2775                 parm_ptr = def_ptr;
2776         }
2777         else
2778         {
2779                 if (parm_table[parmnum].class == P_GLOBAL)
2780                 {
2781                         DEBUG(0,
2782                               ("Global parameter %s found in service section!\n",
2783                                pszParmName));
2784                         return (True);
2785                 }
2786                 parm_ptr =
2787                         ((char *)ServicePtrs[snum]) + PTR_DIFF(def_ptr,
2788                                                             &sDefault);
2789         }
2790
2791         if (snum >= 0)
2792         {
2793                 if (!ServicePtrs[snum]->copymap)
2794                         init_copymap(ServicePtrs[snum]);
2795
2796                 /* this handles the aliases - set the copymap for other entries with
2797                    the same data pointer */
2798                 for (i = 0; parm_table[i].label; i++)
2799                         if (parm_table[i].ptr == parm_table[parmnum].ptr)
2800                                 ServicePtrs[snum]->copymap[i] = False;
2801         }
2802
2803         /* if it is a special case then go ahead */
2804         if (parm_table[parmnum].special)
2805         {
2806                 parm_table[parmnum].special(pszParmValue, (char **)parm_ptr);
2807                 return (True);
2808         }
2809
2810         /* now switch on the type of variable it is */
2811         switch (parm_table[parmnum].type)
2812         {
2813                 case P_BOOL:
2814                         set_boolean(parm_ptr, pszParmValue);
2815                         break;
2816
2817                 case P_BOOLREV:
2818                         set_boolean(parm_ptr, pszParmValue);
2819                         *(BOOL *)parm_ptr = !*(BOOL *)parm_ptr;
2820                         break;
2821
2822                 case P_INTEGER:
2823                         *(int *)parm_ptr = atoi(pszParmValue);
2824                         break;
2825
2826                 case P_CHAR:
2827                         *(char *)parm_ptr = *pszParmValue;
2828                         break;
2829
2830                 case P_OCTAL:
2831                         sscanf(pszParmValue, "%o", (int *)parm_ptr);
2832                         break;
2833
2834                 case P_LIST:
2835                         *(char ***)parm_ptr = lp_list_make(pszParmValue);
2836                         break;
2837
2838                 case P_STRING:
2839                         string_set(parm_ptr, pszParmValue);
2840                         break;
2841
2842                 case P_USTRING:
2843                         string_set(parm_ptr, pszParmValue);
2844                         strupper(*(char **)parm_ptr);
2845                         break;
2846
2847                 case P_GSTRING:
2848                         pstrcpy((char *)parm_ptr, pszParmValue);
2849                         break;
2850
2851                 case P_UGSTRING:
2852                         pstrcpy((char *)parm_ptr, pszParmValue);
2853                         strupper((char *)parm_ptr);
2854                         break;
2855
2856                 case P_ENUM:
2857                         for (i = 0; parm_table[parmnum].enum_list[i].name;
2858                              i++)
2859                         {
2860                                 if (strequal
2861                                     (pszParmValue,
2862                                      parm_table[parmnum].enum_list[i].name))
2863                                 {
2864                                         *(int *)parm_ptr =
2865                                                 parm_table[parmnum].
2866                                                 enum_list[i].value;
2867                                         break;
2868                                 }
2869                         }
2870                         break;
2871                 case P_SEP:
2872                         break;
2873         }
2874
2875         return (True);
2876 }
2877
2878 /***************************************************************************
2879 Process a parameter.
2880 ***************************************************************************/
2881 static BOOL do_parameter(char *pszParmName, char *pszParmValue)
2882 {
2883         if (!bInGlobalSection && bGlobalOnly)
2884                 return (True);
2885
2886         DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
2887
2888         return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
2889                                 pszParmName, pszParmValue));
2890 }
2891
2892
2893 /***************************************************************************
2894 print a parameter of the specified type
2895 ***************************************************************************/
2896 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
2897 {
2898         int i;
2899         switch (p->type)
2900         {
2901                 case P_ENUM:
2902                         for (i = 0; p->enum_list[i].name; i++)
2903                         {
2904                                 if (*(int *)ptr == p->enum_list[i].value)
2905                                 {
2906                                         fprintf(f, "%s",
2907                                                 p->enum_list[i].name);
2908                                         break;
2909                                 }
2910                         }
2911                         break;
2912
2913                 case P_BOOL:
2914                         fprintf(f, "%s", BOOLSTR(*(BOOL *)ptr));
2915                         break;
2916
2917                 case P_BOOLREV:
2918                         fprintf(f, "%s", BOOLSTR(!*(BOOL *)ptr));
2919                         break;
2920
2921                 case P_INTEGER:
2922                         fprintf(f, "%d", *(int *)ptr);
2923                         break;
2924
2925                 case P_CHAR:
2926                         fprintf(f, "%c", *(char *)ptr);
2927                         break;
2928
2929                 case P_OCTAL:
2930                         fprintf(f, "%s", octal_string(*(int *)ptr));
2931                         break;
2932
2933                 case P_LIST:
2934                         if ((char ***)ptr && *(char ***)ptr) {
2935                                 char **list = *(char ***)ptr;
2936                                 
2937                                 for (; *list; list++)
2938                                         fprintf(f, "%s%s", *list,
2939                                                 ((*(list+1))?", ":""));
2940                         }
2941                         break;
2942
2943                 case P_GSTRING:
2944                 case P_UGSTRING:
2945                         if ((char *)ptr) {
2946                                 fprintf(f, "%s", (char *)ptr);
2947                         }
2948                         break;
2949
2950                 case P_STRING:
2951                 case P_USTRING:
2952                         if (*(char **)ptr) {
2953                                 fprintf(f, "%s", *(char **)ptr);
2954                         }
2955                         break;
2956                 case P_SEP:
2957                         break;
2958         }
2959 }
2960
2961
2962 /***************************************************************************
2963 check if two parameters are equal
2964 ***************************************************************************/
2965 static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
2966 {
2967         switch (type)
2968         {
2969                 case P_BOOL:
2970                 case P_BOOLREV:
2971                         return (*((BOOL *)ptr1) == *((BOOL *)ptr2));
2972
2973                 case P_INTEGER:
2974                 case P_ENUM:
2975                 case P_OCTAL:
2976                         return (*((int *)ptr1) == *((int *)ptr2));
2977
2978                 case P_CHAR:
2979                         return (*((char *)ptr1) == *((char *)ptr2));
2980                 
2981                 case P_LIST:
2982                         return lp_list_compare(*(char ***)ptr1, *(char ***)ptr2);
2983
2984                 case P_GSTRING:
2985                 case P_UGSTRING:
2986                 {
2987                         char *p1 = (char *)ptr1, *p2 = (char *)ptr2;
2988                         if (p1 && !*p1)
2989                                 p1 = NULL;
2990                         if (p2 && !*p2)
2991                                 p2 = NULL;
2992                         return (p1 == p2 || strequal(p1, p2));
2993                 }
2994                 case P_STRING:
2995                 case P_USTRING:
2996                 {
2997                         char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
2998                         if (p1 && !*p1)
2999                                 p1 = NULL;
3000                         if (p2 && !*p2)
3001                                 p2 = NULL;
3002                         return (p1 == p2 || strequal(p1, p2));
3003                 }
3004                 case P_SEP:
3005                         break;
3006         }
3007         return (False);
3008 }
3009
3010 /***************************************************************************
3011  Initialize any local varients in the sDefault table.
3012 ***************************************************************************/
3013
3014 void init_locals(void)
3015 {
3016         /* None as yet. */
3017 }
3018
3019 /***************************************************************************
3020 Process a new section (service). At this stage all sections are services.
3021 Later we'll have special sections that permit server parameters to be set.
3022 Returns True on success, False on failure. 
3023 ***************************************************************************/
3024 static BOOL do_section(char *pszSectionName)
3025 {
3026         BOOL bRetval;
3027         BOOL isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
3028                          (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
3029         bRetval = False;
3030
3031         /* if we were in a global section then do the local inits */
3032         if (bInGlobalSection && !isglobal)
3033                 init_locals();
3034
3035         /* if we've just struck a global section, note the fact. */
3036         bInGlobalSection = isglobal;
3037
3038         /* check for multiple global sections */
3039         if (bInGlobalSection)
3040         {
3041                 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
3042                 return (True);
3043         }
3044
3045         if (!bInGlobalSection && bGlobalOnly)
3046                 return (True);
3047
3048         /* if we have a current service, tidy it up before moving on */
3049         bRetval = True;
3050
3051         if (iServiceIndex >= 0)
3052                 bRetval = service_ok(iServiceIndex);
3053
3054         /* if all is still well, move to the next record in the services array */
3055         if (bRetval)
3056         {
3057                 /* We put this here to avoid an odd message order if messages are */
3058                 /* issued by the post-processing of a previous section. */
3059                 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
3060
3061                 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
3062                     < 0)
3063                 {
3064                         DEBUG(0, ("Failed to add a new service\n"));
3065                         return (False);
3066                 }
3067         }
3068
3069         return (bRetval);
3070 }
3071
3072
3073 /***************************************************************************
3074 determine if a partcular base parameter is currentl set to the default value.
3075 ***************************************************************************/
3076 static BOOL is_default(int i)
3077 {
3078         if (!defaults_saved)
3079                 return False;
3080         switch (parm_table[i].type)
3081         {
3082                 case P_LIST:
3083                         return lp_list_compare (parm_table[i].def.lvalue, 
3084                                                 *(char ***)parm_table[i].ptr);
3085                 case P_STRING:
3086                 case P_USTRING:
3087                         return strequal(parm_table[i].def.svalue,
3088                                         *(char **)parm_table[i].ptr);
3089                 case P_GSTRING:
3090                 case P_UGSTRING:
3091                         return strequal(parm_table[i].def.svalue,
3092                                         (char *)parm_table[i].ptr);
3093                 case P_BOOL:
3094                 case P_BOOLREV:
3095                         return parm_table[i].def.bvalue ==
3096                                 *(BOOL *)parm_table[i].ptr;
3097                 case P_CHAR:
3098                         return parm_table[i].def.cvalue ==
3099                                 *(char *)parm_table[i].ptr;
3100                 case P_INTEGER:
3101                 case P_OCTAL:
3102                 case P_ENUM:
3103                         return parm_table[i].def.ivalue ==
3104                                 *(int *)parm_table[i].ptr;
3105                 case P_SEP:
3106                         break;
3107         }
3108         return False;
3109 }
3110
3111
3112 /***************************************************************************
3113 Display the contents of the global structure.
3114 ***************************************************************************/
3115 static void dump_globals(FILE *f)
3116 {
3117         int i;
3118         param_opt_struct *data;
3119         char *s;
3120         
3121         fprintf(f, "# Global parameters\n[global]\n");
3122
3123         for (i = 0; parm_table[i].label; i++)
3124                 if (parm_table[i].class == P_GLOBAL &&
3125                     parm_table[i].ptr &&
3126                     (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
3127                 {
3128                         if (defaults_saved && is_default(i))
3129                                 continue;
3130                         fprintf(f, "\t%s = ", parm_table[i].label);
3131                         print_parameter(&parm_table[i], parm_table[i].ptr, f);
3132                         fprintf(f, "\n");
3133                 }
3134         if (param_opt != NULL) {
3135                 data = param_opt;
3136                 while(data) {
3137                     if (((s=strstr(data->key, "global")) == data->key) &&
3138                         (*(s+strlen("global")) == ':')) {
3139                             fprintf(f, "\t%s = %s\n", s+strlen("global")+1, data->value);
3140                     }
3141                     data = data->next;
3142                 }
3143         }
3144
3145 }
3146
3147 /***************************************************************************
3148 return True if a local parameter is currently set to the global default
3149 ***************************************************************************/
3150 BOOL lp_is_default(int snum, struct parm_struct *parm)
3151 {
3152         int pdiff = PTR_DIFF(parm->ptr, &sDefault);
3153
3154         return equal_parameter(parm->type,
3155                                ((char *)ServicePtrs[snum]) + pdiff,
3156                                ((char *)&sDefault) + pdiff);
3157 }
3158
3159 /***************************************************************************
3160 Display the contents of a single services record.
3161 ***************************************************************************/
3162 static void dump_a_service(service * pService, FILE * f)
3163 {
3164         int i;
3165         param_opt_struct *data;
3166         char *s, *sn;
3167         
3168         if (pService != &sDefault)
3169                 fprintf(f, "\n[%s]\n", pService->szService);
3170
3171         for (i = 0; parm_table[i].label; i++)
3172                 if (parm_table[i].class == P_LOCAL &&
3173                     parm_table[i].ptr &&
3174                     (*parm_table[i].label != '-') &&
3175                     (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
3176                 {
3177                         int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
3178
3179                         if (pService == &sDefault)
3180                         {
3181                                 if (defaults_saved && is_default(i))
3182                                         continue;
3183                         }
3184                         else
3185                         {
3186                                 if (equal_parameter(parm_table[i].type,
3187                                                     ((char *)pService) +
3188                                                     pdiff,
3189                                                     ((char *)&sDefault) +
3190                                                     pdiff))
3191                                         continue;
3192                         }
3193
3194                         fprintf(f, "\t%s = ", parm_table[i].label);
3195                         print_parameter(&parm_table[i],
3196                                         ((char *)pService) + pdiff, f);
3197                         fprintf(f, "\n");
3198                 }
3199         if (param_opt != NULL) {
3200                 data = param_opt;
3201                 sn = (pService == &sDefault) ? "global" : pService->szService;
3202                 while(data) {
3203                     if (((s=strstr(data->key, sn)) == data->key) &&
3204                         (*(s+strlen(sn)) == ':')) {
3205                             fprintf(f, "\t%s = %s\n", s+strlen(sn)+1, data->value);
3206                     }
3207                     data = data->next;
3208                 }
3209         }
3210 }
3211
3212
3213 /***************************************************************************
3214 return info about the next service  in a service. snum==-1 gives the globals
3215
3216 return NULL when out of parameters
3217 ***************************************************************************/
3218 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
3219 {
3220         if (snum == -1)
3221         {
3222                 /* do the globals */
3223                 for (; parm_table[*i].label; (*i)++)
3224                 {
3225                         if (parm_table[*i].class == P_SEPARATOR)
3226                                 return &parm_table[(*i)++];
3227
3228                         if (!parm_table[*i].ptr