Change default of max_xmit to match W2K. Ensure NT negprot uses it.
[vlendec/samba-autobuild/.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 pstring user_socket_options;
59 extern pstring global_myname;
60 pstring global_scope = "";
61
62 #ifndef GLOBAL_NAME
63 #define GLOBAL_NAME "global"
64 #endif
65
66 #ifndef PRINTERS_NAME
67 #define PRINTERS_NAME "printers"
68 #endif
69
70 #ifndef HOMES_NAME
71 #define HOMES_NAME "homes"
72 #endif
73
74 /* some helpful bits */
75 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && ServicePtrs[(i)]->valid)
76 #define VALID(i) ServicePtrs[i]->valid
77
78 int keepalive = DEFAULT_KEEPALIVE;
79 BOOL use_getwd_cache = True;
80
81 extern int extra_time_offset;
82
83 static BOOL defaults_saved = False;
84
85 /* 
86  * This structure describes global (ie., server-wide) parameters.
87  */
88 typedef struct
89 {
90         char *smb_ports;
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 **szSamBackend;
116         char *szPasswordServer;
117         char *szSocketOptions;
118         char *szWorkGroup;
119         char *szRealm;
120         char *szADSserver;
121         char *szUsernameMap;
122         char *szLogonScript;
123         char *szLogonPath;
124         char *szLogonDrive;
125         char *szLogonHome;
126         char **szWINSservers;
127         char **szInterfaces;
128         char *szRemoteAnnounce;
129         char *szRemoteBrowseSync;
130         char *szSocketAddress;
131         char *szNISHomeMapName;
132         char *szAnnounceVersion;        /* This is initialised in init_globals */
133         char **szNetbiosAliases;
134         char *szDomainOtherSIDs;
135         char *szNameResolveOrder;
136         char *szPanicAction;
137         char *szAddUserScript;
138         char *szDelUserScript;
139         char *szAddGroupScript;
140         char *szDelGroupScript;
141         char *szAddUserToGroupScript;
142         char *szDelUserFromGroupScript;
143         char *szSetPrimaryGroupScript;
144         char *szAddMachineScript;
145         char *szShutdownScript;
146         char *szAbortShutdownScript;
147         char *szWINSHook;
148         char *szWINSPartners;
149 #ifdef WITH_UTMP
150         char *szUtmpDir;
151         char *szWtmpDir;
152         BOOL bUtmp;
153 #endif
154         char *szSourceEnv;
155         char *szWinbindUID;
156         char *szWinbindGID;
157         char *szNonUnixAccountRange;
158         BOOL bAlgorithmicRidBase;
159         char *szTemplateHomedir;
160         char *szTemplateShell;
161         char *szWinbindSeparator;
162         BOOL bWinbindEnumUsers;
163         BOOL bWinbindEnumGroups;
164         BOOL bWinbindUseDefaultDomain;
165         char *szAddShareCommand;
166         char *szChangeShareCommand;
167         char *szDeleteShareCommand;
168         char *szGuestaccount;
169         char *szManglingMethod;
170         int max_log_size;
171         char *szLogLevel;
172         int mangled_stack;
173         int max_xmit;
174         int max_mux;
175         int max_open_files;
176         int pwordlevel;
177         int unamelevel;
178         int deadtime;
179         int maxprotocol;
180         int minprotocol;
181         int security;
182         char **AuthMethods;
183         BOOL paranoid_server_security;
184         int maxdisksize;
185         int lpqcachetime;
186         int iMaxSmbdProcesses;
187         BOOL bDisableSpoolss;
188         int iTotalPrintJobs;
189         int syslog;
190         int os_level;
191         int enhanced_browsing;
192         int max_ttl;
193         int max_wins_ttl;
194         int min_wins_ttl;
195         int ReadSize;
196         int lm_announce;
197         int lm_interval;
198         int announce_as;        /* This is initialised in init_globals */
199         int machine_password_timeout;
200         int change_notify_timeout;
201         int stat_cache_size;
202         int map_to_guest;
203         int min_passwd_length;
204         int oplock_break_wait_time;
205         int winbind_cache_time;
206         int iLockSpinCount;
207         int iLockSpinTime;
208         char *szLdapMachineSuffix;
209         char *szLdapUserSuffix;
210 #ifdef WITH_LDAP_SAMCONFIG
211         int ldap_port;
212         char *szLdapServer;
213 #endif
214         int ldap_ssl;
215         char *szLdapSuffix;
216         char *szLdapFilter;
217         char *szLdapAdminDn;
218         int ldap_passwd_sync; 
219         BOOL bMsAddPrinterWizard;
220         BOOL bDNSproxy;
221         BOOL bWINSsupport;
222         BOOL bWINSproxy;
223         BOOL bLocalMaster;
224         BOOL bPreferredMaster;
225         BOOL bDomainMaster;
226         BOOL bDomainLogons;
227         BOOL bEncryptPasswords;
228         BOOL bUpdateEncrypt;
229         BOOL bStripDot;
230         BOOL bNullPasswords;
231         BOOL bObeyPamRestrictions;
232         BOOL bLoadPrinters;
233         BOOL bLargeReadwrite;
234         BOOL bReadRaw;
235         BOOL bWriteRaw;
236         BOOL bReadPrediction;
237         BOOL bReadbmpx;
238         BOOL bSyslogOnly;
239         BOOL bBrowseList;
240         BOOL bNISHomeMap;
241         BOOL bTimeServer;
242         BOOL bBindInterfacesOnly;
243         BOOL bPamPasswordChange;
244         BOOL bUnixPasswdSync;
245         BOOL bPasswdChatDebug;
246         BOOL bTimestampLogs;
247         BOOL bNTSmbSupport;
248         BOOL bNTPipeSupport;
249         BOOL bNTStatusSupport;
250         BOOL bStatCache;
251         BOOL bKernelOplocks;
252         BOOL bAllowTrustedDomains;
253         BOOL bLanmanAuth;
254         BOOL bNTLMAuth;
255         BOOL bDebugHiresTimestamp;
256         BOOL bDebugPid;
257         BOOL bDebugUid;
258         BOOL bHostMSDfs;
259         BOOL bHideLocalUsers;
260         BOOL bUnicode;
261         BOOL bUseMmap;
262         BOOL bHostnameLookups;
263         BOOL bUseSpnego;
264         BOOL bUnixExtensions;
265         BOOL bDisableNetbios;
266         int restrict_anonymous;
267         int name_cache_timeout;
268 }
269 global;
270
271 static global Globals;
272
273
274
275 /* 
276  * This structure describes a single service. 
277  */
278 typedef struct
279 {
280         BOOL valid;
281         BOOL autoloaded;
282         char *szService;
283         char *szPath;
284         char *szUsername;
285         char **szInvalidUsers;
286         char **szValidUsers;
287         char **szAdminUsers;
288         char *szCopy;
289         char *szInclude;
290         char *szPreExec;
291         char *szPostExec;
292         char *szRootPreExec;
293         char *szRootPostExec;
294         char *szPrintcommand;
295         char *szLpqcommand;
296         char *szLprmcommand;
297         char *szLppausecommand;
298         char *szLpresumecommand;
299         char *szQueuepausecommand;
300         char *szQueueresumecommand;
301         char *szPrintername;
302         char *szPrinterDriver;
303         char *szPrinterDriverLocation;
304         char *szDriverFile;
305         char *szDontdescend;
306         char **szHostsallow;
307         char **szHostsdeny;
308         char *szMagicScript;
309         char *szMagicOutput;
310         char *szMangledMap;
311         char *szVetoFiles;
312         char *szHideFiles;
313         char *szVetoOplockFiles;
314         char *comment;
315         char *force_user;
316         char *force_group;
317         char **readlist;
318         char **writelist;
319         char **printer_admin;
320         char *volume;
321         char *fstype;
322         char *szVfsObjectFile;
323         char *szVfsOptions;
324         char *szVfsPath;
325         int iMinPrintSpace;
326         int iMaxPrintJobs;
327         int iWriteCacheSize;
328         int iCreate_mask;
329         int iCreate_force_mode;
330         int iSecurity_mask;
331         int iSecurity_force_mode;
332         int iDir_mask;
333         int iDir_force_mode;
334         int iDir_Security_mask;
335         int iDir_Security_force_mode;
336         int iMaxConnections;
337         int iDefaultCase;
338         int iPrinting;
339         int iOplockContentionLimit;
340         int iCSCPolicy;
341         int iBlock_size;
342         BOOL bPreexecClose;
343         BOOL bRootpreexecClose;
344         BOOL bCaseSensitive;
345         BOOL bCasePreserve;
346         BOOL bShortCasePreserve;
347         BOOL bCaseMangle;
348         BOOL bHideDotFiles;
349         BOOL bHideSpecialFiles;
350         BOOL bHideUnReadable;
351         BOOL bHideUnWriteableFiles;
352         BOOL bBrowseable;
353         BOOL bAvailable;
354         BOOL bRead_only;
355         BOOL bNo_set_dir;
356         BOOL bGuest_only;
357         BOOL bGuest_ok;
358         BOOL bPrint_ok;
359         BOOL bPostscript;
360         BOOL bMap_system;
361         BOOL bMap_hidden;
362         BOOL bMap_archive;
363         BOOL bLocking;
364         BOOL bStrictLocking;
365         BOOL bPosixLocking;
366         BOOL bShareModes;
367         BOOL bOpLocks;
368         BOOL bLevel2OpLocks;
369         BOOL bOnlyUser;
370         BOOL bMangledNames;
371         BOOL bWidelinks;
372         BOOL bSymlinks;
373         BOOL bSyncAlways;
374         BOOL bStrictAllocate;
375         BOOL bStrictSync;
376         char magic_char;
377         BOOL *copymap;
378         BOOL bDeleteReadonly;
379         BOOL bFakeOplocks;
380         BOOL bDeleteVetoFiles;
381         BOOL bDosFilemode;
382         BOOL bDosFiletimes;
383         BOOL bDosFiletimeResolution;
384         BOOL bFakeDirCreateTimes;
385         BOOL bBlockingLocks;
386         BOOL bInheritPerms;
387         BOOL bInheritACLS;
388         BOOL bMSDfsRoot;
389         BOOL bUseClientDriver;
390         BOOL bDefaultDevmode;
391         BOOL bNTAclSupport;
392         BOOL bUseSendfile;
393         BOOL bProfileAcls;
394
395         char dummy[3];          /* for alignment */
396 }
397 service;
398
399
400 /* This is a default service used to prime a services structure */
401 static service sDefault = {
402         True,                   /* valid */
403         False,                  /* not autoloaded */
404         NULL,                   /* szService */
405         NULL,                   /* szPath */
406         NULL,                   /* szUsername */
407         NULL,                   /* szInvalidUsers */
408         NULL,                   /* szValidUsers */
409         NULL,                   /* szAdminUsers */
410         NULL,                   /* szCopy */
411         NULL,                   /* szInclude */
412         NULL,                   /* szPreExec */
413         NULL,                   /* szPostExec */
414         NULL,                   /* szRootPreExec */
415         NULL,                   /* szRootPostExec */
416         NULL,                   /* szPrintcommand */
417         NULL,                   /* szLpqcommand */
418         NULL,                   /* szLprmcommand */
419         NULL,                   /* szLppausecommand */
420         NULL,                   /* szLpresumecommand */
421         NULL,                   /* szQueuepausecommand */
422         NULL,                   /* szQueueresumecommand */
423         NULL,                   /* szPrintername */
424         NULL,                   /* szPrinterDriver - this is set in init_globals() */
425         NULL,                   /* szPrinterDriverLocation */
426         NULL,                   /* szDriverFile */
427         NULL,                   /* szDontdescend */
428         NULL,                   /* szHostsallow */
429         NULL,                   /* szHostsdeny */
430         NULL,                   /* szMagicScript */
431         NULL,                   /* szMagicOutput */
432         NULL,                   /* szMangledMap */
433         NULL,                   /* szVetoFiles */
434         NULL,                   /* szHideFiles */
435         NULL,                   /* szVetoOplockFiles */
436         NULL,                   /* comment */
437         NULL,                   /* force user */
438         NULL,                   /* force group */
439         NULL,                   /* readlist */
440         NULL,                   /* writelist */
441         NULL,                   /* printer admin */
442         NULL,                   /* volume */
443         NULL,                   /* fstype */
444         NULL,                   /* vfs object */
445         NULL,                   /* vfs options */
446         NULL,                   /* vfs path */
447         0,                      /* iMinPrintSpace */
448         1000,                   /* iMaxPrintJobs */
449         0,                      /* iWriteCacheSize */
450         0744,                   /* iCreate_mask */
451         0000,                   /* iCreate_force_mode */
452         0777,                   /* iSecurity_mask */
453         0,                      /* iSecurity_force_mode */
454         0755,                   /* iDir_mask */
455         0000,                   /* iDir_force_mode */
456         0777,                   /* iDir_Security_mask */
457         0,                      /* iDir_Security_force_mode */
458         0,                      /* iMaxConnections */
459         CASE_LOWER,             /* iDefaultCase */
460         DEFAULT_PRINTING,       /* iPrinting */
461         2,                      /* iOplockContentionLimit */
462         0,                      /* iCSCPolicy */
463         1024,           /* iBlock_size */
464         False,                  /* bPreexecClose */
465         False,                  /* bRootpreexecClose */
466         False,                  /* case sensitive */
467         True,                   /* case preserve */
468         True,                   /* short case preserve */
469         False,                  /* case mangle */
470         True,                   /* bHideDotFiles */
471         False,                  /* bHideSpecialFiles */
472         False,                  /* bHideUnReadable */
473         False,                  /* bHideUnWriteableFiles */
474         True,                   /* bBrowseable */
475         True,                   /* bAvailable */
476         True,                   /* bRead_only */
477         True,                   /* bNo_set_dir */
478         False,                  /* bGuest_only */
479         False,                  /* bGuest_ok */
480         False,                  /* bPrint_ok */
481         False,                  /* bPostscript */
482         False,                  /* bMap_system */
483         False,                  /* bMap_hidden */
484         True,                   /* bMap_archive */
485         True,                   /* bLocking */
486         True,                   /* bStrictLocking */
487         True,                   /* bPosixLocking */
488         True,                   /* bShareModes */
489         True,                   /* bOpLocks */
490         True,                   /* bLevel2OpLocks */
491         False,                  /* bOnlyUser */
492         True,                   /* bMangledNames */
493         True,                   /* bWidelinks */
494         True,                   /* bSymlinks */
495         False,                  /* bSyncAlways */
496         False,                  /* bStrictAllocate */
497         False,                  /* bStrictSync */
498         '~',                    /* magic char */
499         NULL,                   /* copymap */
500         False,                  /* bDeleteReadonly */
501         False,                  /* bFakeOplocks */
502         False,                  /* bDeleteVetoFiles */
503         False,                  /* bDosFilemode */
504         False,                  /* bDosFiletimes */
505         False,                  /* bDosFiletimeResolution */
506         False,                  /* bFakeDirCreateTimes */
507         True,                   /* bBlockingLocks */
508         False,                  /* bInheritPerms */
509         False,                  /* bInheritACLS */
510         False,                  /* bMSDfsRoot */
511         False,                  /* bUseClientDriver */
512         False,                  /* bDefaultDevmode */
513         True,                   /* bNTAclSupport */
514         False,                  /* bUseSendfile */
515         False,                  /* bProfileAcls */
516
517         ""                      /* dummy */
518 };
519
520 /* local variables */
521 static service **ServicePtrs = NULL;
522 static int iNumServices = 0;
523 static int iServiceIndex = 0;
524 static BOOL bInGlobalSection = True;
525 static BOOL bGlobalOnly = False;
526 static int server_role;
527 static int default_server_announce;
528
529 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
530
531 /* prototypes for the special type handlers */
532 static BOOL handle_include(char *pszParmValue, char **ptr);
533 static BOOL handle_copy(char *pszParmValue, char **ptr);
534 static BOOL handle_vfs_object(char *pszParmValue, char **ptr);
535 static BOOL handle_source_env(char *pszParmValue, char **ptr);
536 static BOOL handle_netbios_name(char *pszParmValue, char **ptr);
537 static BOOL handle_winbind_uid(char *pszParmValue, char **ptr);
538 static BOOL handle_winbind_gid(char *pszParmValue, char **ptr);
539 static BOOL handle_non_unix_account_range(char *pszParmValue, char **ptr);
540 static BOOL handle_debug_list( char *pszParmValue, char **ptr );
541
542 static BOOL handle_ldap_machine_suffix ( char *pszParmValue, char **ptr );
543 static BOOL handle_ldap_user_suffix ( char *pszParmValue, char **ptr );
544 static BOOL handle_ldap_suffix ( char *pszParmValue, char **ptr );
545
546 static void set_server_role(void);
547 static void set_default_server_announce_type(void);
548
549 static struct enum_list enum_protocol[] = {
550         {PROTOCOL_NT1, "NT1"},
551         {PROTOCOL_LANMAN2, "LANMAN2"},
552         {PROTOCOL_LANMAN1, "LANMAN1"},
553         {PROTOCOL_CORE, "CORE"},
554         {PROTOCOL_COREPLUS, "COREPLUS"},
555         {PROTOCOL_COREPLUS, "CORE+"},
556         {-1, NULL}
557 };
558
559 static struct enum_list enum_security[] = {
560         {SEC_SHARE, "SHARE"},
561         {SEC_USER, "USER"},
562         {SEC_SERVER, "SERVER"},
563         {SEC_DOMAIN, "DOMAIN"},
564 #ifdef HAVE_ADS
565         {SEC_ADS, "ADS"},
566 #endif
567         {-1, NULL}
568 };
569
570 static struct enum_list enum_printing[] = {
571         {PRINT_SYSV, "sysv"},
572         {PRINT_AIX, "aix"},
573         {PRINT_HPUX, "hpux"},
574         {PRINT_BSD, "bsd"},
575         {PRINT_QNX, "qnx"},
576         {PRINT_PLP, "plp"},
577         {PRINT_LPRNG, "lprng"},
578         {PRINT_SOFTQ, "softq"},
579         {PRINT_CUPS, "cups"},
580         {PRINT_LPRNT, "nt"},
581         {PRINT_LPROS2, "os2"},
582 #ifdef DEVELOPER
583         {PRINT_TEST, "test"},
584         {PRINT_VLP, "vlp"},
585 #endif /* DEVELOPER */
586         {-1, NULL}
587 };
588
589 static struct enum_list enum_ldap_ssl[] = {
590         {LDAP_SSL_ON, "Yes"},
591         {LDAP_SSL_ON, "yes"},
592         {LDAP_SSL_ON, "on"},
593         {LDAP_SSL_ON, "On"},
594         {LDAP_SSL_OFF, "no"},
595         {LDAP_SSL_OFF, "No"},
596         {LDAP_SSL_OFF, "off"},
597         {LDAP_SSL_OFF, "Off"},
598         {LDAP_SSL_START_TLS, "start tls"},
599         {LDAP_SSL_START_TLS, "Start_tls"},
600         {-1, NULL}
601 };
602
603 static struct enum_list enum_ldap_passwd_sync[] = {
604         {LDAP_PASSWD_SYNC_ON, "Yes"},
605         {LDAP_PASSWD_SYNC_ON, "yes"},
606         {LDAP_PASSWD_SYNC_ON, "on"},
607         {LDAP_PASSWD_SYNC_ON, "On"},
608         {LDAP_PASSWD_SYNC_OFF, "no"},
609         {LDAP_PASSWD_SYNC_OFF, "No"},
610         {LDAP_PASSWD_SYNC_OFF, "off"},
611         {LDAP_PASSWD_SYNC_OFF, "Off"},
612 #ifdef LDAP_EXOP_X_MODIFY_PASSWD        
613         {LDAP_PASSWD_SYNC_ONLY, "Only"},
614         {LDAP_PASSWD_SYNC_ONLY, "only"},
615 #endif /* LDAP_EXOP_X_MODIFY_PASSWD */  
616         {-1, NULL}
617 };
618
619 /* Types of machine we can announce as. */
620 #define ANNOUNCE_AS_NT_SERVER 1
621 #define ANNOUNCE_AS_WIN95 2
622 #define ANNOUNCE_AS_WFW 3
623 #define ANNOUNCE_AS_NT_WORKSTATION 4
624
625 static struct enum_list enum_announce_as[] = {
626         {ANNOUNCE_AS_NT_SERVER, "NT"},
627         {ANNOUNCE_AS_NT_SERVER, "NT Server"},
628         {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
629         {ANNOUNCE_AS_WIN95, "win95"},
630         {ANNOUNCE_AS_WFW, "WfW"},
631         {-1, NULL}
632 };
633
634 static struct enum_list enum_case[] = {
635         {CASE_LOWER, "lower"},
636         {CASE_UPPER, "upper"},
637         {-1, NULL}
638 };
639
640 static struct enum_list enum_bool_auto[] = {
641         {False, "No"},
642         {False, "False"},
643         {False, "0"},
644         {True, "Yes"},
645         {True, "True"},
646         {True, "1"},
647         {Auto, "Auto"},
648         {-1, NULL}
649 };
650
651 /* Client-side offline caching policy types */
652 #define CSC_POLICY_MANUAL 0
653 #define CSC_POLICY_DOCUMENTS 1
654 #define CSC_POLICY_PROGRAMS 2
655 #define CSC_POLICY_DISABLE 3
656
657 static struct enum_list enum_csc_policy[] = {
658         {CSC_POLICY_MANUAL, "manual"},
659         {CSC_POLICY_DOCUMENTS, "documents"},
660         {CSC_POLICY_PROGRAMS, "programs"},
661         {CSC_POLICY_DISABLE, "disable"},
662         {-1, NULL}
663 };
664
665 /* 
666    Do you want session setups at user level security with a invalid
667    password to be rejected or allowed in as guest? WinNT rejects them
668    but it can be a pain as it means "net view" needs to use a password
669
670    You have 3 choices in the setting of map_to_guest:
671
672    "Never" means session setups with an invalid password
673    are rejected. This is the default.
674
675    "Bad User" means session setups with an invalid password
676    are rejected, unless the username does not exist, in which case it
677    is treated as a guest login
678
679    "Bad Password" means session setups with an invalid password
680    are treated as a guest login
681
682    Note that map_to_guest only has an effect in user or server
683    level security.
684 */
685
686 static struct enum_list enum_map_to_guest[] = {
687         {NEVER_MAP_TO_GUEST, "Never"},
688         {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
689         {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
690         {-1, NULL}
691 };
692
693 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
694  *
695  * Note: We have a flag called FLAG_DEVELOPER but is not used at this time, it
696  * is implied in current control logic. This may change at some later time. A
697  * flag value of 0 means - show as development option only.
698  *
699  * The FLAG_HIDE is explicit. Paramters set this way do NOT appear in any edit
700  * screen in SWAT. This is used to exclude parameters as well as to squash all
701  * parameters that have been duplicated by pseudonyms.
702  */
703 static struct parm_struct parm_table[] = {
704         {"Base Options", P_SEP, P_SEPARATOR},
705
706         {"dos charset", P_STRING, P_GLOBAL, &Globals.dos_charset, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
707         {"unix charset", P_STRING, P_GLOBAL, &Globals.unix_charset, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
708         {"display charset", P_STRING, P_GLOBAL, &Globals.display_charset, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
709         {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
710         {"path", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
711         {"directory", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_HIDE},
712         {"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkGroup, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
713         {"realm", P_USTRING, P_GLOBAL, &Globals.szRealm, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
714         {"ADS server", P_STRING, P_GLOBAL, &Globals.szADSserver, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
715         {"netbios name", P_UGSTRING, P_GLOBAL, global_myname, handle_netbios_name, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
716         {"netbios aliases", P_LIST, P_GLOBAL, &Globals.szNetbiosAliases, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
717         {"netbios scope", P_UGSTRING, P_GLOBAL, global_scope, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
718         {"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED  | FLAG_DEVELOPER},
719         {"interfaces", P_LIST, P_GLOBAL, &Globals.szInterfaces, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
720         {"bind interfaces only", P_BOOL, P_GLOBAL, &Globals.bBindInterfacesOnly, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
721
722         {"Security Options", P_SEP, P_SEPARATOR},
723         
724         {"security", P_ENUM, P_GLOBAL, &Globals.security, NULL, enum_security, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
725         {"auth methods", P_LIST, P_GLOBAL, &Globals.AuthMethods, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
726         {"encrypt passwords", P_BOOL, P_GLOBAL, &Globals.bEncryptPasswords, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
727         {"update encrypted", P_BOOL, P_GLOBAL, &Globals.bUpdateEncrypt, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
728         {"allow trusted domains", P_BOOL, P_GLOBAL, &Globals.bAllowTrustedDomains, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
729         {"hosts equiv", P_STRING, P_GLOBAL, &Globals.szHostsEquiv, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
730         {"min passwd length", P_INTEGER, P_GLOBAL, &Globals.min_passwd_length, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
731         {"min password length", P_INTEGER, P_GLOBAL, &Globals.min_passwd_length, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
732         {"map to guest", P_ENUM, P_GLOBAL, &Globals.map_to_guest, NULL, enum_map_to_guest, FLAG_ADVANCED | FLAG_DEVELOPER},
733         {"null passwords", P_BOOL, P_GLOBAL, &Globals.bNullPasswords, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
734         {"obey pam restrictions", P_BOOL, P_GLOBAL, &Globals.bObeyPamRestrictions, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
735         {"password server", P_STRING, P_GLOBAL, &Globals.szPasswordServer, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
736         {"smb passwd file", P_STRING, P_GLOBAL, &Globals.szSMBPasswdFile, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
737         {"private dir", P_STRING, P_GLOBAL, &Globals.szPrivateDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
738         {"passdb backend", P_LIST, P_GLOBAL, &Globals.szPassdbBackend, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
739         {"sam backend", P_LIST, P_GLOBAL, &Globals.szSamBackend, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
740         {"non unix account range", P_STRING, P_GLOBAL, &Globals.szNonUnixAccountRange, handle_non_unix_account_range, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
741         {"algorithmic rid base", P_INTEGER, P_GLOBAL, &Globals.bAlgorithmicRidBase, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
742         {"root directory", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
743         {"root dir", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
744         {"root", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, FLAG_HIDE | FLAG_DEVELOPER},
745         {"guest account", P_STRING, P_GLOBAL, &Globals.szGuestaccount, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
746         
747         {"pam password change", P_BOOL, P_GLOBAL, &Globals.bPamPasswordChange, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
748         {"passwd program", P_STRING, P_GLOBAL, &Globals.szPasswdProgram, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
749         {"passwd chat", P_STRING, P_GLOBAL, &Globals.szPasswdChat, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
750         {"passwd chat debug", P_BOOL, P_GLOBAL, &Globals.bPasswdChatDebug, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
751         {"username map", P_STRING, P_GLOBAL, &Globals.szUsernameMap, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER | FLAG_DEVELOPER},
752         {"password level", P_INTEGER, P_GLOBAL, &Globals.pwordlevel, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
753         {"username level", P_INTEGER, P_GLOBAL, &Globals.unamelevel, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
754         {"unix password sync", P_BOOL, P_GLOBAL, &Globals.bUnixPasswdSync, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
755         {"restrict anonymous", P_INTEGER, P_GLOBAL, &Globals.restrict_anonymous, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
756         {"lanman auth", P_BOOL, P_GLOBAL, &Globals.bLanmanAuth, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
757         {"ntlm auth", P_BOOL, P_GLOBAL, &Globals.bNTLMAuth, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
758         
759         {"username", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
760         {"user", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, FLAG_HIDE},
761         {"users", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, FLAG_HIDE},
762         
763         {"invalid users", P_LIST, P_LOCAL, &sDefault.szInvalidUsers, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
764         {"valid users", P_LIST, P_LOCAL, &sDefault.szValidUsers, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
765         {"admin users", P_LIST, P_LOCAL, &sDefault.szAdminUsers, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
766         {"read list", P_LIST, P_LOCAL, &sDefault.readlist, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
767         {"write list", P_LIST, P_LOCAL, &sDefault.writelist, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
768         {"printer admin", P_LIST, P_LOCAL, &sDefault.printer_admin, NULL, NULL, FLAG_GLOBAL | FLAG_PRINT},
769         {"force user", P_STRING, P_LOCAL, &sDefault.force_user, NULL, NULL, FLAG_SHARE},
770         {"force group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL, FLAG_SHARE},
771         {"group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
772         
773         {"read only", P_BOOL, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE},
774         {"write ok", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_HIDE},
775         {"writeable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_HIDE},
776         {"writable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_HIDE},
777         
778         {"create mask", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
779         {"create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_GLOBAL},
780         {"force create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_force_mode, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
781         {"security mask", P_OCTAL, P_LOCAL, &sDefault.iSecurity_mask, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
782         {"force security mode", P_OCTAL, P_LOCAL, &sDefault.iSecurity_force_mode, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
783         {"directory mask", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
784         {"directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_GLOBAL},
785         {"force directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_force_mode, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
786         {"directory security mask", P_OCTAL, P_LOCAL, &sDefault.iDir_Security_mask, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
787         {"force directory security mode", P_OCTAL, P_LOCAL, &sDefault.iDir_Security_force_mode, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
788         {"inherit permissions", P_BOOL, P_LOCAL, &sDefault.bInheritPerms, NULL, NULL, FLAG_SHARE},
789         {"inherit acls", P_BOOL, P_LOCAL, &sDefault.bInheritACLS, NULL, NULL, FLAG_SHARE},
790         {"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, FLAG_SHARE},
791         {"only guest", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, FLAG_HIDE},
792
793         {"guest ok", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
794         {"public", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_HIDE},
795         
796         {"only user", P_BOOL, P_LOCAL, &sDefault.bOnlyUser, NULL, NULL, FLAG_SHARE},
797         {"hosts allow", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
798         {"allow hosts", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_HIDE},
799         {"hosts deny", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
800         {"deny hosts", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_HIDE},
801
802         {"Logging Options", P_SEP, P_SEPARATOR},
803
804         {"log level", P_STRING, P_GLOBAL, &Globals.szLogLevel, handle_debug_list, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
805         {"debuglevel", P_STRING, P_GLOBAL, &Globals.szLogLevel, handle_debug_list, NULL, FLAG_HIDE},
806         {"syslog", P_INTEGER, P_GLOBAL, &Globals.syslog, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
807         {"syslog only", P_BOOL, P_GLOBAL, &Globals.bSyslogOnly, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
808         {"log file", P_STRING, P_GLOBAL, &Globals.szLogFile, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
809         
810         {"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
811         {"timestamp logs", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
812         {"debug timestamp", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, FLAG_DEVELOPER},
813         {"debug hires timestamp", P_BOOL, P_GLOBAL, &Globals.bDebugHiresTimestamp, NULL, NULL, FLAG_DEVELOPER},
814         {"debug pid", P_BOOL, P_GLOBAL, &Globals.bDebugPid, NULL, NULL, FLAG_DEVELOPER},
815         {"debug uid", P_BOOL, P_GLOBAL, &Globals.bDebugUid, NULL, NULL, FLAG_DEVELOPER},
816         
817         {"Protocol Options", P_SEP, P_SEPARATOR},
818         
819         {"smb ports", P_STRING, P_GLOBAL, &Globals.smb_ports, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
820         {"protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, FLAG_ADVANCED | FLAG_DEVELOPER},
821         {"large readwrite", P_BOOL, P_GLOBAL, &Globals.bLargeReadwrite, NULL, NULL, FLAG_DEVELOPER},
822         {"max protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, FLAG_DEVELOPER},
823         {"min protocol", P_ENUM, P_GLOBAL, &Globals.minprotocol, NULL, enum_protocol, FLAG_DEVELOPER},
824         {"unicode", P_BOOL, P_GLOBAL, &Globals.bUnicode, NULL, NULL, FLAG_DEVELOPER},
825         {"read bmpx", P_BOOL, P_GLOBAL, &Globals.bReadbmpx, NULL, NULL, FLAG_DEVELOPER},
826         {"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL, FLAG_DEVELOPER},
827         {"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL, FLAG_DEVELOPER},
828         {"disable netbios", P_BOOL, P_GLOBAL, &Globals.bDisableNetbios, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
829         
830         {"nt pipe support", P_BOOL, P_GLOBAL, &Globals.bNTPipeSupport, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
831         {"nt acl support", P_BOOL,  P_LOCAL, &sDefault.bNTAclSupport, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE  | FLAG_ADVANCED | FLAG_WIZARD},
832         {"nt status support", P_BOOL, P_GLOBAL, &Globals.bNTStatusSupport, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
833         {"profile acls", P_BOOL,  P_LOCAL, &sDefault.bProfileAcls, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE  | FLAG_ADVANCED | FLAG_WIZARD},
834         
835         {"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL, NULL, FLAG_DEVELOPER},
836         {"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as, FLAG_DEVELOPER},
837         {"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
838         {"max xmit", P_INTEGER, P_GLOBAL, &Globals.max_xmit, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
839         
840         {"name resolve order", P_STRING, P_GLOBAL, &Globals.szNameResolveOrder, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
841         {"max ttl", P_INTEGER, P_GLOBAL, &Globals.max_ttl, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER}, 
842         {"max wins ttl", P_INTEGER, P_GLOBAL, &Globals.max_wins_ttl, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
843         {"min wins ttl", P_INTEGER, P_GLOBAL, &Globals.min_wins_ttl, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
844         {"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
845         {"unix extensions", P_BOOL, P_GLOBAL, &Globals.bUnixExtensions, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
846         {"use spnego", P_BOOL, P_GLOBAL, &Globals.bUseSpnego, NULL, NULL, FLAG_DEVELOPER},
847
848         {"Tuning Options", P_SEP, P_SEPARATOR},
849         
850         {"block size", P_INTEGER, P_LOCAL, &sDefault.iBlock_size, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
851         {"change notify timeout", P_INTEGER, P_GLOBAL, &Globals.change_notify_timeout, NULL, NULL, FLAG_DEVELOPER},
852         {"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL, NULL, FLAG_DEVELOPER},
853         {"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL, NULL, FLAG_DEVELOPER},
854         {"keepalive", P_INTEGER, P_GLOBAL, &keepalive, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
855         
856         {"lpq cache time", P_INTEGER, P_GLOBAL, &Globals.lpqcachetime, NULL, NULL, FLAG_DEVELOPER},
857         {"max smbd processes", P_INTEGER, P_GLOBAL, &Globals.iMaxSmbdProcesses, NULL, NULL, FLAG_DEVELOPER},
858         {"max connections", P_INTEGER, P_LOCAL, &sDefault.iMaxConnections, NULL, NULL, FLAG_SHARE},
859         {"paranoid server security", P_BOOL, P_GLOBAL, &Globals.paranoid_server_security, NULL, NULL, FLAG_DEVELOPER},
860         {"max disk size", P_INTEGER, P_GLOBAL, &Globals.maxdisksize, NULL, NULL, FLAG_DEVELOPER},
861         {"max open files", P_INTEGER, P_GLOBAL, &Globals.max_open_files, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
862         {"min print space", P_INTEGER, P_LOCAL, &sDefault.iMinPrintSpace, NULL, NULL, FLAG_PRINT},
863         {"read size", P_INTEGER, P_GLOBAL, &Globals.ReadSize, NULL, NULL, FLAG_DEVELOPER},
864         
865         {"socket options", P_GSTRING, P_GLOBAL, user_socket_options, NULL, NULL, FLAG_DEVELOPER},
866         {"stat cache size", P_INTEGER, P_GLOBAL, &Globals.stat_cache_size, NULL, NULL, FLAG_DEVELOPER},
867         {"strict allocate", P_BOOL, P_LOCAL, &sDefault.bStrictAllocate, NULL, NULL, FLAG_SHARE},
868         {"strict sync", P_BOOL, P_LOCAL, &sDefault.bStrictSync, NULL, NULL, FLAG_SHARE},
869         {"sync always", P_BOOL, P_LOCAL, &sDefault.bSyncAlways, NULL, NULL, FLAG_SHARE},
870         {"use mmap", P_BOOL, P_GLOBAL, &Globals.bUseMmap, NULL, NULL, FLAG_DEVELOPER},
871         {"use sendfile", P_BOOL, P_LOCAL, &sDefault.bUseSendfile, NULL, NULL, FLAG_SHARE},
872         {"hostname lookups", P_BOOL, P_GLOBAL, &Globals.bHostnameLookups, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
873         {"write cache size", P_INTEGER, P_LOCAL, &sDefault.iWriteCacheSize, NULL, NULL, FLAG_SHARE},
874
875         {"name cache timeout", P_INTEGER, P_GLOBAL, &Globals.name_cache_timeout, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
876
877         {"Printing Options", P_SEP, P_SEPARATOR},
878         
879         {"total print jobs", P_INTEGER, P_GLOBAL, &Globals.iTotalPrintJobs, NULL, NULL, FLAG_PRINT},
880         {"max print jobs", P_INTEGER, P_LOCAL, &sDefault.iMaxPrintJobs, NULL, NULL, FLAG_PRINT},
881         {"load printers", P_BOOL, P_GLOBAL, &Globals.bLoadPrinters, NULL, NULL, FLAG_PRINT},
882         {"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, FLAG_PRINT | FLAG_DEVELOPER},
883         {"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, FLAG_HIDE},
884         {"printable", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, FLAG_PRINT},
885         {"print ok", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, FLAG_HIDE},
886         {"postscript", P_BOOL, P_LOCAL, &sDefault.bPostscript, NULL, NULL, FLAG_PRINT | FLAG_DEPRECATED},
887         {"printing", P_ENUM, P_LOCAL, &sDefault.iPrinting, NULL, enum_printing, FLAG_PRINT | FLAG_GLOBAL},
888         {"print command", P_STRING, P_LOCAL, &sDefault.szPrintcommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
889         {"disable spoolss", P_BOOL, P_GLOBAL, &Globals.bDisableSpoolss, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
890         {"lpq command", P_STRING, P_LOCAL, &sDefault.szLpqcommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
891         {"lprm command", P_STRING, P_LOCAL, &sDefault.szLprmcommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
892         {"lppause command", P_STRING, P_LOCAL, &sDefault.szLppausecommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
893         {"lpresume command", P_STRING, P_LOCAL, &sDefault.szLpresumecommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
894         {"queuepause command", P_STRING, P_LOCAL, &sDefault.szQueuepausecommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
895         {"queueresume command", P_STRING, P_LOCAL, &sDefault.szQueueresumecommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
896
897         {"enumports command", P_STRING, P_GLOBAL, &Globals.szEnumPortsCommand, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
898         {"addprinter command", P_STRING, P_GLOBAL, &Globals.szAddPrinterCommand, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
899         {"deleteprinter command", P_STRING, P_GLOBAL, &Globals.szDeletePrinterCommand, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
900         {"show add printer wizard", P_BOOL, P_GLOBAL, &Globals.bMsAddPrinterWizard, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
901         {"os2 driver map", P_STRING, P_GLOBAL, &Globals.szOs2DriverMap, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
902         
903         {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_PRINT},
904         {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_HIDE},
905         {"use client driver", P_BOOL, P_LOCAL, &sDefault.bUseClientDriver, NULL, NULL, FLAG_PRINT},
906         {"default devmode", P_BOOL, P_LOCAL, &sDefault.bDefaultDevmode, NULL, NULL, FLAG_PRINT},
907         {"printer driver", P_STRING, P_LOCAL, &sDefault.szPrinterDriver, NULL, NULL, FLAG_PRINT | FLAG_DEPRECATED},
908         {"printer driver file", P_STRING, P_LOCAL, &sDefault.szDriverFile, NULL, NULL, FLAG_PRINT | FLAG_DEPRECATED},
909         {"printer driver location", P_STRING, P_LOCAL, &sDefault.szPrinterDriverLocation, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL | FLAG_DEPRECATED},
910
911         {"Filename Handling", P_SEP, P_SEPARATOR},
912         {"strip dot", P_BOOL, P_GLOBAL, &Globals.bStripDot, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
913         {"mangling method", P_STRING, P_GLOBAL, &Globals.szManglingMethod, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
914         
915         {"mangled stack", P_INTEGER, P_GLOBAL, &Globals.mangled_stack, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
916         {"default case", P_ENUM, P_LOCAL, &sDefault.iDefaultCase, NULL, enum_case, FLAG_SHARE},
917         {"case sensitive", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
918         {"casesignames", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL, NULL, FLAG_HIDE},
919         {"preserve case", P_BOOL, P_LOCAL, &sDefault.bCasePreserve, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
920         {"short preserve case", P_BOOL, P_LOCAL, &sDefault.bShortCasePreserve, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
921         {"mangle case", P_BOOL, P_LOCAL, &sDefault.bCaseMangle, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
922         {"mangling char", P_CHAR, P_LOCAL, &sDefault.magic_char, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
923         {"hide dot files", P_BOOL, P_LOCAL, &sDefault.bHideDotFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
924         {"hide special files", P_BOOL, P_LOCAL, &sDefault.bHideSpecialFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
925         {"hide unreadable", P_BOOL, P_LOCAL, &sDefault.bHideUnReadable, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
926         {"hide unwriteable files", P_BOOL, P_LOCAL, &sDefault.bHideUnWriteableFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
927         {"delete veto files", P_BOOL, P_LOCAL, &sDefault.bDeleteVetoFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
928         {"veto files", P_STRING, P_LOCAL, &sDefault.szVetoFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL },
929         {"hide files", P_STRING, P_LOCAL, &sDefault.szHideFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL },
930         {"veto oplock files", P_STRING, P_LOCAL, &sDefault.szVetoOplockFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL },
931         {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
932         {"map hidden", P_BOOL, P_LOCAL, &sDefault.bMap_hidden, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
933         {"map archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
934         {"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
935         {"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
936         {"stat cache", P_BOOL, P_GLOBAL, &Globals.bStatCache, NULL, NULL, FLAG_DEVELOPER},
937
938         {"Domain Options", P_SEP, P_SEPARATOR},
939         
940         {"machine password timeout", P_INTEGER, P_GLOBAL, &Globals.machine_password_timeout, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
941
942         {"Logon Options", P_SEP, P_SEPARATOR},
943
944         {"add user script", P_STRING, P_GLOBAL, &Globals.szAddUserScript, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
945         {"delete user script", P_STRING, P_GLOBAL, &Globals.szDelUserScript, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
946         {"add group script", P_STRING, P_GLOBAL, &Globals.szAddGroupScript, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
947         {"delete group script", P_STRING, P_GLOBAL, &Globals.szDelGroupScript, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
948         {"add user to group script", P_STRING, P_GLOBAL, &Globals.szAddUserToGroupScript, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
949         {"delete user from group script", P_STRING, P_GLOBAL, &Globals.szDelUserFromGroupScript, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
950         {"set primary group script", P_STRING, P_GLOBAL, &Globals.szSetPrimaryGroupScript, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
951         {"add machine script", P_STRING, P_GLOBAL, &Globals.szAddMachineScript, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
952         {"shutdown script", P_STRING, P_GLOBAL, &Globals.szShutdownScript, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
953         {"abort shutdown script", P_STRING, P_GLOBAL, &Globals.szAbortShutdownScript, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
954
955         {"logon script", P_STRING, P_GLOBAL, &Globals.szLogonScript, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
956         {"logon path", P_STRING, P_GLOBAL, &Globals.szLogonPath, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
957         {"logon drive", P_STRING, P_GLOBAL, &Globals.szLogonDrive, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
958         {"logon home", P_STRING, P_GLOBAL, &Globals.szLogonHome, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
959         {"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
960
961         {"Browse Options", P_SEP, P_SEPARATOR},
962         
963         {"os level", P_INTEGER, P_GLOBAL, &Globals.os_level, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
964         {"lm announce", P_ENUM, P_GLOBAL, &Globals.lm_announce, NULL, enum_bool_auto, FLAG_ADVANCED | FLAG_DEVELOPER},
965         {"lm interval", P_INTEGER, P_GLOBAL, &Globals.lm_interval, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
966         {"preferred master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
967         {"prefered master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_HIDE},
968         {"local master", P_BOOL, P_GLOBAL, &Globals.bLocalMaster, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
969         {"domain master", P_ENUM, P_GLOBAL, &Globals.bDomainMaster, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
970         {"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
971         {"browseable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
972         {"browsable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_HIDE},
973         {"enhanced browsing", P_BOOL, P_GLOBAL, &Globals.enhanced_browsing, NULL, NULL, FLAG_DEVELOPER | FLAG_ADVANCED},
974
975         {"WINS Options", P_SEP, P_SEPARATOR},
976         {"dns proxy", P_BOOL, P_GLOBAL, &Globals.bDNSproxy, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
977         {"wins proxy", P_BOOL, P_GLOBAL, &Globals.bWINSproxy, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
978         
979         {"wins server", P_LIST, P_GLOBAL, &Globals.szWINSservers, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
980         {"wins support", P_BOOL, P_GLOBAL, &Globals.bWINSsupport, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
981         {"wins hook", P_STRING, P_GLOBAL, &Globals.szWINSHook, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
982         {"wins partners", P_STRING, P_GLOBAL, &Globals.szWINSPartners, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
983
984         {"Locking Options", P_SEP, P_SEPARATOR},
985         
986         {"blocking locks", P_BOOL, P_LOCAL, &sDefault.bBlockingLocks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
987         {"csc policy", P_ENUM, P_LOCAL, &sDefault.iCSCPolicy, NULL, enum_csc_policy, FLAG_SHARE | FLAG_GLOBAL},
988         {"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL, NULL, FLAG_SHARE},
989         {"kernel oplocks", P_BOOL, P_GLOBAL, &Globals.bKernelOplocks, NULL, NULL, FLAG_GLOBAL},
990         {"locking", P_BOOL, P_LOCAL, &sDefault.bLocking, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
991         {"lock spin count", P_INTEGER, P_GLOBAL, &Globals.iLockSpinCount, NULL, NULL, FLAG_GLOBAL},
992         {"lock spin time", P_INTEGER, P_GLOBAL, &Globals.iLockSpinTime, NULL, NULL, FLAG_GLOBAL},
993         
994         {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
995         {"level2 oplocks", P_BOOL, P_LOCAL, &sDefault.bLevel2OpLocks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
996         {"oplock break wait time", P_INTEGER, P_GLOBAL, &Globals.oplock_break_wait_time, NULL, NULL, FLAG_GLOBAL},
997         {"oplock contention limit", P_INTEGER, P_LOCAL, &sDefault.iOplockContentionLimit, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
998         {"posix locking", P_BOOL, P_LOCAL, &sDefault.bPosixLocking, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
999         {"strict locking", P_BOOL, P_LOCAL, &sDefault.bStrictLocking, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1000         {"share modes", P_BOOL, P_LOCAL,  &sDefault.bShareModes, NULL, NULL, FLAG_SHARE|FLAG_GLOBAL},
1001
1002         {"Ldap Options", P_SEP, P_SEPARATOR},
1003         
1004 #ifdef WITH_LDAP_SAMCONFIG
1005         {"ldap server", P_STRING, P_GLOBAL, &Globals.szLdapServer, NULL, NULL, 0},
1006         {"ldap port", P_INTEGER, P_GLOBAL, &Globals.ldap_port, NULL, NULL, 0}, 
1007 #endif
1008         {"ldap suffix", P_STRING, P_GLOBAL, &Globals.szLdapSuffix, handle_ldap_suffix, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1009         {"ldap machine suffix", P_STRING, P_GLOBAL, &Globals.szLdapMachineSuffix, handle_ldap_machine_suffix, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1010         {"ldap user suffix", P_STRING, P_GLOBAL, &Globals.szLdapUserSuffix, handle_ldap_user_suffix, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1011         {"ldap filter", P_STRING, P_GLOBAL, &Globals.szLdapFilter, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1012         {"ldap admin dn", P_STRING, P_GLOBAL, &Globals.szLdapAdminDn, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1013         {"ldap ssl", P_ENUM, P_GLOBAL, &Globals.ldap_ssl, NULL, enum_ldap_ssl, FLAG_ADVANCED | FLAG_DEVELOPER},
1014         {"ldap passwd sync", P_ENUM, P_GLOBAL, &Globals.ldap_passwd_sync, NULL, enum_ldap_passwd_sync, FLAG_ADVANCED | FLAG_DEVELOPER},
1015
1016         {"Miscellaneous Options", P_SEP, P_SEPARATOR},
1017         {"add share command", P_STRING, P_GLOBAL, &Globals.szAddShareCommand, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1018         {"change share command", P_STRING, P_GLOBAL, &Globals.szChangeShareCommand, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1019         {"delete share command", P_STRING, P_GLOBAL, &Globals.szDeleteShareCommand, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1020         
1021         {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL, FLAG_HIDE},
1022         {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1023         {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1024         {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_HIDE}, 
1025         {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1026         {"pid directory", P_STRING, P_GLOBAL, &Globals.szPidDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER}, 
1027 #ifdef WITH_UTMP
1028         {"utmp directory", P_STRING, P_GLOBAL, &Globals.szUtmpDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1029         {"wtmp directory", P_STRING, P_GLOBAL, &Globals.szWtmpDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1030         {"utmp",          P_BOOL, P_GLOBAL, &Globals.bUtmp, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1031 #endif
1032         
1033         {"default service", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1034         {"default", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL,  FLAG_DEVELOPER},
1035         {"message command", P_STRING, P_GLOBAL, &Globals.szMsgCommand, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1036         {"dfree command", P_STRING, P_GLOBAL, &Globals.szDfree, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1037         {"remote announce", P_STRING, P_GLOBAL, &Globals.szRemoteAnnounce, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1038         {"remote browse sync", P_STRING, P_GLOBAL, &Globals.szRemoteBrowseSync, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1039         {"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL, NULL, FLAG_DEVELOPER},
1040         {"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1041         {"time offset", P_INTEGER, P_GLOBAL, &extra_time_offset, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1042         {"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1043         {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL, NULL, FLAG_HIDE},
1044         
1045         {"copy", P_STRING, P_LOCAL, &sDefault.szCopy, handle_copy, NULL, FLAG_HIDE},
1046         {"include", P_STRING, P_LOCAL, &sDefault.szInclude, handle_include, NULL, FLAG_HIDE},
1047         {"exec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL, FLAG_SHARE | FLAG_PRINT},
1048         {"preexec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1049         
1050         {"preexec close", P_BOOL, P_LOCAL, &sDefault.bPreexecClose, NULL, NULL, FLAG_SHARE},
1051         {"postexec", P_STRING, P_LOCAL, &sDefault.szPostExec, NULL, NULL, FLAG_SHARE | FLAG_PRINT},
1052         {"root preexec", P_STRING, P_LOCAL, &sDefault.szRootPreExec, NULL, NULL, FLAG_SHARE | FLAG_PRINT},
1053         {"root preexec close", P_BOOL, P_LOCAL, &sDefault.bRootpreexecClose, NULL, NULL, FLAG_SHARE},
1054         {"root postexec", P_STRING, P_LOCAL, &sDefault.szRootPostExec, NULL, NULL, FLAG_SHARE | FLAG_PRINT},
1055         {"available", P_BOOL, P_LOCAL, &sDefault.bAvailable, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1056         {"volume", P_STRING, P_LOCAL, &sDefault.volume, NULL, NULL, FLAG_SHARE },
1057         {"fstype", P_STRING, P_LOCAL, &sDefault.fstype, NULL, NULL, FLAG_SHARE},
1058         {"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL, NULL, FLAG_SHARE},
1059         {"source environment", P_STRING, P_GLOBAL, &Globals.szSourceEnv, handle_source_env, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1060         {"wide links", P_BOOL, P_LOCAL, &sDefault.bWidelinks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1061         {"follow symlinks", P_BOOL, P_LOCAL, &sDefault.bSymlinks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1062         {"dont descend", P_STRING, P_LOCAL, &sDefault.szDontdescend, NULL, NULL, FLAG_SHARE},
1063         {"magic script", P_STRING, P_LOCAL, &sDefault.szMagicScript, NULL, NULL, FLAG_SHARE},
1064         {"magic output", P_STRING, P_LOCAL, &sDefault.szMagicOutput, NULL, NULL, FLAG_SHARE},
1065         {"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1066         {"dos filemode", P_BOOL, P_LOCAL, &sDefault.bDosFilemode, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1067         {"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1068         {"dos filetime resolution", P_BOOL, P_LOCAL, &sDefault.bDosFiletimeResolution, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1069
1070         {"fake directory create times", P_BOOL, P_LOCAL, &sDefault.bFakeDirCreateTimes, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1071         {"panic action", P_STRING, P_GLOBAL, &Globals.szPanicAction, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1072         {"hide local users", P_BOOL, P_GLOBAL, &Globals.bHideLocalUsers, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1073
1074         {"VFS module options", P_SEP, P_SEPARATOR},
1075         
1076         {"vfs object", P_STRING, P_LOCAL, &sDefault.szVfsObjectFile, handle_vfs_object, NULL, FLAG_SHARE},
1077         {"vfs options", P_STRING, P_LOCAL, &sDefault.szVfsOptions, NULL, NULL, FLAG_SHARE},
1078         {"vfs path", P_STRING, P_LOCAL, &sDefault.szVfsPath, NULL, NULL, FLAG_SHARE},
1079
1080         
1081         {"msdfs root", P_BOOL, P_LOCAL, &sDefault.bMSDfsRoot, NULL, NULL, FLAG_SHARE},
1082         {"host msdfs", P_BOOL, P_GLOBAL, &Globals.bHostMSDfs, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1083
1084         {"Winbind options", P_SEP, P_SEPARATOR},
1085
1086         {"winbind uid", P_STRING, P_GLOBAL, &Globals.szWinbindUID, handle_winbind_uid, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1087         {"winbind gid", P_STRING, P_GLOBAL, &Globals.szWinbindGID, handle_winbind_gid, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1088         {"template homedir", P_STRING, P_GLOBAL, &Globals.szTemplateHomedir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1089         {"template shell", P_STRING, P_GLOBAL, &Globals.szTemplateShell, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1090         {"winbind separator", P_STRING, P_GLOBAL, &Globals.szWinbindSeparator, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1091         {"winbind cache time", P_INTEGER, P_GLOBAL, &Globals.winbind_cache_time, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1092         {"winbind enum users", P_BOOL, P_GLOBAL, &Globals.bWinbindEnumUsers, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1093         {"winbind enum groups", P_BOOL, P_GLOBAL, &Globals.bWinbindEnumGroups, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1094         {"winbind use default domain", P_BOOL, P_GLOBAL, &Globals.bWinbindUseDefaultDomain, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
1095
1096         {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
1097 };
1098
1099
1100 /***************************************************************************
1101 Initialise the sDefault parameter structure for the printer values.
1102 ***************************************************************************/
1103 static void init_printer_values(void)
1104 {
1105         string_set(&sDefault.szPrinterDriver, "");
1106         string_set(&sDefault.szDriverFile, dyn_DRIVERFILE);
1107
1108         /* choose defaults depending on the type of printing */
1109         switch (sDefault.iPrinting)
1110         {
1111                 case PRINT_BSD:
1112                 case PRINT_AIX:
1113                 case PRINT_LPRNT:
1114                 case PRINT_LPROS2:
1115                         string_set(&sDefault.szLpqcommand, "lpq -P'%p'");
1116                         string_set(&sDefault.szLprmcommand, "lprm -P'%p' %j");
1117                         string_set(&sDefault.szPrintcommand,
1118                                    "lpr -r -P'%p' %s");
1119                         break;
1120
1121                 case PRINT_LPRNG:
1122                 case PRINT_PLP:
1123                         string_set(&sDefault.szLpqcommand, "lpq -P'%p'");
1124                         string_set(&sDefault.szLprmcommand, "lprm -P'%p' %j");
1125                         string_set(&sDefault.szPrintcommand,
1126                                    "lpr -r -P'%p' %s");
1127                         string_set(&sDefault.szQueuepausecommand,
1128                                    "lpc stop '%p'");
1129                         string_set(&sDefault.szQueueresumecommand,
1130                                    "lpc start '%p'");
1131                         string_set(&sDefault.szLppausecommand,
1132                                    "lpc hold '%p' %j");
1133                         string_set(&sDefault.szLpresumecommand,
1134                                    "lpc release '%p' %j");
1135                         break;
1136
1137                 case PRINT_CUPS:
1138 #ifdef HAVE_CUPS
1139                         string_set(&sDefault.szLpqcommand, "");
1140                         string_set(&sDefault.szLprmcommand, "");
1141                         string_set(&sDefault.szPrintcommand, "");
1142                         string_set(&sDefault.szLppausecommand, "");
1143                         string_set(&sDefault.szLpresumecommand, "");
1144                         string_set(&sDefault.szQueuepausecommand, "");
1145                         string_set(&sDefault.szQueueresumecommand, "");
1146
1147                         string_set(&Globals.szPrintcapname, "cups");
1148 #else
1149                         string_set(&sDefault.szLpqcommand,
1150                                    "/usr/bin/lpstat -o '%p'");
1151                         string_set(&sDefault.szLprmcommand,
1152                                    "/usr/bin/cancel '%p-%j'");
1153                         string_set(&sDefault.szPrintcommand,
1154                                    "/usr/bin/lp -d '%p' %s; rm %s");
1155                         string_set(&sDefault.szLppausecommand,
1156                                    "lp -i '%p-%j' -H hold");
1157                         string_set(&sDefault.szLpresumecommand,
1158                                    "lp -i '%p-%j' -H resume");
1159                         string_set(&sDefault.szQueuepausecommand,
1160                                    "/usr/bin/disable '%p'");
1161                         string_set(&sDefault.szQueueresumecommand,
1162                                    "/usr/bin/enable '%p'");
1163                         string_set(&Globals.szPrintcapname, "lpstat");
1164 #endif /* HAVE_CUPS */
1165                         break;
1166
1167                 case PRINT_SYSV:
1168                 case PRINT_HPUX:
1169                         string_set(&sDefault.szLpqcommand, "lpstat -o%p");
1170                         string_set(&sDefault.szLprmcommand, "cancel %p-%j");
1171                         string_set(&sDefault.szPrintcommand,
1172                                    "lp -c -d%p %s; rm %s");
1173                         string_set(&sDefault.szQueuepausecommand,
1174                                    "disable %p");
1175                         string_set(&sDefault.szQueueresumecommand,
1176                                    "enable %p");
1177 #ifndef HPUX
1178                         string_set(&sDefault.szLppausecommand,
1179                                    "lp -i %p-%j -H hold");
1180                         string_set(&sDefault.szLpresumecommand,
1181                                    "lp -i %p-%j -H resume");
1182 #endif /* HPUX */
1183                         break;
1184
1185                 case PRINT_QNX:
1186                         string_set(&sDefault.szLpqcommand, "lpq -P%p");
1187                         string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
1188                         string_set(&sDefault.szPrintcommand, "lp -r -P%p %s");
1189                         break;
1190
1191                 case PRINT_SOFTQ:
1192                         string_set(&sDefault.szLpqcommand, "qstat -l -d%p");
1193                         string_set(&sDefault.szLprmcommand,
1194                                    "qstat -s -j%j -c");
1195                         string_set(&sDefault.szPrintcommand,
1196                                    "lp -d%p -s %s; rm %s");
1197                         string_set(&sDefault.szLppausecommand,
1198                                    "qstat -s -j%j -h");
1199                         string_set(&sDefault.szLpresumecommand,
1200                                    "qstat -s -j%j -r");
1201                         break;
1202 #ifdef DEVELOPER
1203         case PRINT_TEST:
1204         case PRINT_VLP:
1205                 string_set(&sDefault.szPrintcommand, "vlp print %p %s");
1206                 string_set(&sDefault.szLpqcommand, "vlp lpq %p");
1207                 string_set(&sDefault.szLprmcommand, "vlp lprm %p %j");
1208                 string_set(&sDefault.szLppausecommand, "vlp lppause %p %j");
1209                 string_set(&sDefault.szLpresumecommand, "vlp lpresum %p %j");
1210                 string_set(&sDefault.szQueuepausecommand, "vlp queuepause %p");
1211                 string_set(&sDefault.szQueueresumecommand, "vlp queueresume %p");
1212                 break;
1213 #endif /* DEVELOPER */
1214
1215         }
1216 }
1217
1218 /***************************************************************************
1219 Initialise the global parameter structure.
1220 ***************************************************************************/
1221 static void init_globals(void)
1222 {
1223         static BOOL done_init = False;
1224         pstring s;
1225
1226         if (!done_init)
1227         {
1228                 int i;
1229                 memset((void *)&Globals, '\0', sizeof(Globals));
1230
1231                 for (i = 0; parm_table[i].label; i++)
1232                         if ((parm_table[i].type == P_STRING ||
1233                              parm_table[i].type == P_USTRING) &&
1234                             parm_table[i].ptr)
1235                                 string_set(parm_table[i].ptr, "");
1236
1237                 string_set(&sDefault.fstype, FSTYPE_STRING);
1238
1239                 init_printer_values();
1240
1241                 done_init = True;
1242         }
1243
1244
1245         DEBUG(3, ("Initialising global parameters\n"));
1246
1247         string_set(&Globals.szSMBPasswdFile, dyn_SMB_PASSWD_FILE);
1248         string_set(&Globals.szPrivateDir, dyn_PRIVATE_DIR);
1249
1250         /* use the new 'hash2' method by default */
1251         string_set(&Globals.szManglingMethod, "hash2");
1252
1253         string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
1254
1255         /* using UTF8 by default allows us to support all chars */
1256         string_set(&Globals.unix_charset, "UTF8");
1257
1258         /* Use codepage 850 as a default for the dos character set */
1259         string_set(&Globals.dos_charset, "CP850");
1260
1261         /*
1262          * Allow the default PASSWD_CHAT to be overridden in local.h.
1263          */
1264         string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
1265         string_set(&Globals.szWorkGroup, WORKGROUP);
1266         string_set(&Globals.szPasswdProgram, "");
1267         string_set(&Globals.szPrintcapname, PRINTCAP_NAME);
1268         string_set(&Globals.szPidDir, dyn_PIDDIR);
1269         string_set(&Globals.szLockDir, dyn_LOCKDIR);
1270         string_set(&Globals.szSocketAddress, "0.0.0.0");
1271         pstrcpy(s, "Samba ");
1272         pstrcat(s, VERSION);
1273         string_set(&Globals.szServerString, s);
1274         slprintf(s, sizeof(s) - 1, "%d.%d", DEFAULT_MAJOR_VERSION,
1275                  DEFAULT_MINOR_VERSION);
1276         string_set(&Globals.szAnnounceVersion, s);
1277
1278         pstrcpy(user_socket_options, DEFAULT_SOCKET_OPTIONS);
1279
1280         string_set(&Globals.szLogonDrive, "");
1281         /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
1282         string_set(&Globals.szLogonHome, "\\\\%N\\%U");
1283         string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
1284
1285         string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
1286         string_set(&Globals.szPasswordServer, "*");
1287
1288         Globals.bAlgorithmicRidBase = BASE_RID;
1289
1290         Globals.bLoadPrinters = True;
1291         Globals.mangled_stack = 50;
1292         /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
1293         /* Discovered by 2 days of pain by Don McCall @ HP :-). */
1294         Globals.max_xmit = 0x4104;
1295         Globals.max_mux = 50;   /* This is *needed* for profile support. */
1296         Globals.lpqcachetime = 10;
1297         Globals.bDisableSpoolss = False;
1298         Globals.iMaxSmbdProcesses = 0;/* no limit specified */
1299         Globals.iTotalPrintJobs = 0;  /* no limit specified */
1300         Globals.pwordlevel = 0;
1301         Globals.unamelevel = 0;
1302         Globals.deadtime = 0;
1303         Globals.bLargeReadwrite = True;
1304         Globals.max_log_size = 5000;
1305         Globals.max_open_files = MAX_OPEN_FILES;
1306         Globals.maxprotocol = PROTOCOL_NT1;
1307         Globals.minprotocol = PROTOCOL_CORE;
1308         Globals.security = SEC_USER;
1309         Globals.paranoid_server_security = True;
1310         Globals.bEncryptPasswords = True;
1311         Globals.bUpdateEncrypt = False;
1312         Globals.bReadRaw = True;
1313         Globals.bWriteRaw = True;
1314         Globals.bReadPrediction = False;
1315         Globals.bReadbmpx = False;
1316         Globals.bNullPasswords = False;
1317         Globals.bObeyPamRestrictions = False;
1318         Globals.bStripDot = False;
1319         Globals.syslog = 1;
1320         Globals.bSyslogOnly = False;
1321         Globals.bTimestampLogs = True;
1322         string_set(&Globals.szLogLevel, "0");
1323         Globals.bDebugHiresTimestamp = False;
1324         Globals.bDebugPid = False;
1325         Globals.bDebugUid = False;
1326         Globals.max_ttl = 60 * 60 * 24 * 3;     /* 3 days default. */
1327         Globals.max_wins_ttl = 60 * 60 * 24 * 6;        /* 6 days default. */
1328         Globals.min_wins_ttl = 60 * 60 * 6;     /* 6 hours default. */
1329         Globals.machine_password_timeout = 60 * 60 * 24 * 7;    /* 7 days default. */
1330         Globals.change_notify_timeout = 60;     /* 1 minute default. */
1331         Globals.ReadSize = 16 * 1024;
1332         Globals.lm_announce = 2;        /* = Auto: send only if LM clients found */
1333         Globals.lm_interval = 60;
1334         Globals.stat_cache_size = 50;   /* Number of stat translations we'll keep */
1335         Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
1336 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
1337         Globals.bNISHomeMap = False;
1338 #ifdef WITH_NISPLUS_HOME
1339         string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
1340 #else
1341         string_set(&Globals.szNISHomeMapName, "auto.home");
1342 #endif
1343 #endif
1344         Globals.bTimeServer = False;
1345         Globals.bBindInterfacesOnly = False;
1346         Globals.bUnixPasswdSync = False;
1347         Globals.bPamPasswordChange = False;
1348         Globals.bPasswdChatDebug = False;
1349         Globals.bUnicode = True;        /* Do unicode on the wire by default */
1350         Globals.bNTPipeSupport = True;  /* Do NT pipes by default. */
1351         Globals.bNTStatusSupport = True; /* Use NT status by default. */
1352         Globals.bStatCache = True;      /* use stat cache by default */
1353         Globals.restrict_anonymous = 0;
1354         Globals.bLanmanAuth = True;     /* Do use the LanMan hash if it is available */
1355         Globals.bNTLMAuth = True;       /* Do use NTLMv1 if it is available (otherwise NTLMv2) */
1356         Globals.map_to_guest = 0;       /* By Default, "Never" */
1357         Globals.min_passwd_length = MINPASSWDLENGTH;    /* By Default, 5. */
1358         Globals.oplock_break_wait_time = 0;     /* By Default, 0 msecs. */
1359         Globals.enhanced_browsing = True; 
1360         Globals.iLockSpinCount = 3; /* Try 2 times. */
1361         Globals.iLockSpinTime = 10; /* usec. */
1362 #ifdef MMAP_BLACKLIST
1363         Globals.bUseMmap = False;
1364 #else
1365         Globals.bUseMmap = True;
1366 #endif
1367         Globals.bUnixExtensions = False;
1368
1369         /* hostname lookups can be very expensive and are broken on
1370            a large number of sites (tridge) */
1371         Globals.bHostnameLookups = False;
1372
1373 #ifdef WITH_LDAP_SAMCONFIG
1374         string_set(&Globals.szLdapServer, "localhost");
1375         Globals.ldap_port = 636;
1376         Globals.szPassdbBackend = str_list_make("ldapsam unixsam", NULL);
1377 #else
1378         Globals.szPassdbBackend = str_list_make("smbpasswd unixsam", NULL);
1379 #endif /* WITH_LDAP_SAMCONFIG */
1380
1381         string_set(&Globals.szLdapSuffix, "");
1382         string_set(&Globals.szLdapMachineSuffix, "");
1383         string_set(&Globals.szLdapUserSuffix, "");
1384
1385         string_set(&Globals.szLdapFilter, "(&(uid=%u)(objectclass=sambaAccount))");
1386         string_set(&Globals.szLdapAdminDn, "");
1387         Globals.ldap_ssl = LDAP_SSL_ON;
1388         Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
1389
1390 /* these parameters are set to defaults that are more appropriate
1391    for the increasing samba install base:
1392
1393    as a member of the workgroup, that will possibly become a
1394    _local_ master browser (lm = True).  this is opposed to a forced
1395    local master browser startup (pm = True).
1396
1397    doesn't provide WINS server service by default (wsupp = False),
1398    and doesn't provide domain master browser services by default, either.
1399
1400 */
1401
1402         Globals.bMsAddPrinterWizard = True;
1403         Globals.bPreferredMaster = Auto;        /* depending on bDomainMaster */
1404         Globals.os_level = 20;
1405         Globals.bLocalMaster = True;
1406         Globals.bDomainMaster = Auto;   /* depending on bDomainLogons */
1407         Globals.bDomainLogons = False;
1408         Globals.bBrowseList = True;
1409         Globals.bWINSsupport = False;
1410         Globals.bWINSproxy = False;
1411
1412         Globals.bDNSproxy = True;
1413
1414         /* this just means to use them if they exist */
1415         Globals.bKernelOplocks = True;
1416
1417         Globals.bAllowTrustedDomains = True;
1418
1419         string_set(&Globals.szTemplateShell, "/bin/false");
1420         string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
1421         string_set(&Globals.szWinbindSeparator, "\\");
1422
1423         Globals.winbind_cache_time = 15;
1424         Globals.bWinbindEnumUsers = True;
1425         Globals.bWinbindEnumGroups = True;
1426         Globals.bWinbindUseDefaultDomain = False;
1427
1428         Globals.name_cache_timeout = 660; /* In seconds */
1429
1430         Globals.bUseSpnego = True;
1431
1432         string_set(&Globals.smb_ports, SMB_PORTS);
1433 }
1434
1435 static TALLOC_CTX *lp_talloc;
1436
1437 /******************************************************************* a
1438 free up temporary memory - called from the main loop
1439 ********************************************************************/
1440 void lp_talloc_free(void)
1441 {
1442         if (!lp_talloc)
1443                 return;
1444         talloc_destroy(lp_talloc);
1445         lp_talloc = NULL;
1446 }
1447
1448 /*******************************************************************
1449 convenience routine to grab string parameters into temporary memory
1450 and run standard_sub_basic on them. The buffers can be written to by
1451 callers without affecting the source string.
1452 ********************************************************************/
1453 static char *lp_string(const char *s)
1454 {
1455         size_t len = s ? strlen(s) : 0;
1456         char *ret;
1457
1458         /* The follow debug is useful for tracking down memory problems
1459            especially if you have an inner loop that is calling a lp_*()
1460            function that returns a string.  Perhaps this debug should be
1461            present all the time? */
1462
1463 #if 0
1464         DEBUG(10, ("lp_string(%s)\n", s));
1465 #endif
1466
1467         if (!lp_talloc)
1468                 lp_talloc = talloc_init_named("lp_talloc");
1469
1470         ret = (char *)talloc(lp_talloc, len + 100);     /* leave room for substitution */
1471
1472         if (!ret)
1473                 return NULL;
1474
1475         if (!s)
1476                 *ret = 0;
1477         else
1478                 StrnCpy(ret, s, len);
1479
1480         if (trim_string(ret, "\"", "\"")) {
1481                 if (strchr(ret,'"') != NULL)
1482                         StrnCpy(ret, s, len);
1483         }
1484
1485         standard_sub_basic(current_user_info.smb_name,ret,len+100);
1486         return (ret);
1487 }
1488
1489
1490 /*
1491    In this section all the functions that are used to access the 
1492    parameters from the rest of the program are defined 
1493 */
1494
1495 #define FN_GLOBAL_STRING(fn_name,ptr) \
1496  char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
1497 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
1498  const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
1499 #define FN_GLOBAL_LIST(fn_name,ptr) \
1500  char **fn_name(void) {return(*(char ***)(ptr));}
1501 #define FN_GLOBAL_BOOL(fn_name,ptr) \
1502  BOOL fn_name(void) {return(*(BOOL *)(ptr));}
1503 #define FN_GLOBAL_CHAR(fn_name,ptr) \
1504  char fn_name(void) {return(*(char *)(ptr));}
1505 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
1506  int fn_name(void) {return(*(int *)(ptr));}
1507
1508 #define FN_LOCAL_STRING(fn_name,val) \
1509  char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
1510 #define FN_LOCAL_CONST_STRING(fn_name,val) \
1511  const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
1512 #define FN_LOCAL_LIST(fn_name,val) \
1513  char **fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1514 #define FN_LOCAL_BOOL(fn_name,val) \
1515  BOOL fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1516 #define FN_LOCAL_CHAR(fn_name,val) \
1517  char fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1518 #define FN_LOCAL_INTEGER(fn_name,val) \
1519  int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1520
1521 FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
1522 FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
1523 FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
1524 FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
1525 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
1526 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
1527 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
1528 FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
1529 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
1530 FN_GLOBAL_STRING(lp_printcapname, &Globals.szPrintcapname)
1531 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
1532 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
1533 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
1534 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
1535 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
1536 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
1537 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
1538 #ifdef WITH_UTMP
1539 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
1540 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
1541 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
1542 #endif
1543 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
1544 FN_GLOBAL_STRING(lp_source_environment, &Globals.szSourceEnv)
1545 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
1546 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
1547 FN_GLOBAL_STRING(lp_dfree_command, &Globals.szDfree)
1548 FN_GLOBAL_STRING(lp_hosts_equiv, &Globals.szHostsEquiv)
1549 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
1550 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
1551 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
1552 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
1553 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
1554 FN_GLOBAL_STRING(lp_workgroup, &Globals.szWorkGroup)
1555 FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
1556 FN_GLOBAL_STRING(lp_ads_server, &Globals.szADSserver)
1557 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
1558 FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
1559 FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
1560 FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
1561 FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
1562 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
1563 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
1564 FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
1565 FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
1566 FN_GLOBAL_STRING(lp_socket_address, &Globals.szSocketAddress)
1567 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
1568 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
1569 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
1570 FN_GLOBAL_LIST(lp_passdb_backend, &Globals.szPassdbBackend)
1571 FN_GLOBAL_LIST(lp_sam_backend, &Globals.szSamBackend)
1572 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
1573 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
1574 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
1575
1576 FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
1577 FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
1578 FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
1579 FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
1580 FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
1581 FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
1582
1583 FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
1584
1585 FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
1586 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
1587
1588 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
1589 FN_GLOBAL_STRING(lp_wins_partners, &Globals.szWINSPartners)
1590 FN_GLOBAL_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
1591 FN_GLOBAL_STRING(lp_template_shell, &Globals.szTemplateShell)
1592 FN_GLOBAL_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
1593 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
1594 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
1595 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
1596
1597 #ifdef WITH_LDAP_SAMCONFIG
1598 FN_GLOBAL_STRING(lp_ldap_server, &Globals.szLdapServer)
1599 FN_GLOBAL_INTEGER(lp_ldap_port, &Globals.ldap_port)
1600 #endif
1601 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
1602 FN_GLOBAL_STRING(lp_ldap_machine_suffix, &Globals.szLdapMachineSuffix)
1603 FN_GLOBAL_STRING(lp_ldap_user_suffix, &Globals.szLdapUserSuffix)
1604 FN_GLOBAL_STRING(lp_ldap_filter, &Globals.szLdapFilter)
1605 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
1606 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
1607 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
1608 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
1609 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
1610 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
1611
1612 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
1613 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
1614 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
1615 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
1616 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
1617 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
1618 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
1619 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
1620 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
1621 FN_GLOBAL_BOOL(lp_readprediction, &Globals.bReadPrediction)
1622 FN_GLOBAL_BOOL(lp_readbmpx, &Globals.bReadbmpx)
1623 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
1624 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
1625 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
1626 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
1627 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
1628 FN_GLOBAL_BOOL(lp_strip_dot, &Globals.bStripDot)
1629 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
1630 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
1631 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
1632 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
1633 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
1634 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
1635 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
1636 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
1637 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
1638 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
1639 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
1640 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
1641 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
1642 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
1643 FN_GLOBAL_BOOL(lp_unicode, &Globals.bUnicode)
1644 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
1645 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
1646 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
1647 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
1648 FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
1649 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
1650 FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
1651 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
1652 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
1653 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
1654 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
1655 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
1656 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
1657 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
1658 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
1659 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
1660 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
1661 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
1662 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
1663 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
1664 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
1665 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
1666 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
1667 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
1668 FN_GLOBAL_INTEGER(lp_readsize, &Globals.ReadSize)
1669 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
1670 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
1671 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
1672 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
1673 FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
1674 FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
1675 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
1676 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
1677 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
1678 FN_GLOBAL_INTEGER(lp_disable_spoolss, &Globals.bDisableSpoolss)
1679 FN_GLOBAL_INTEGER(lp_totalprintjobs, &Globals.iTotalPrintJobs)
1680 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
1681 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
1682 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
1683 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
1684 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
1685 FN_GLOBAL_INTEGER(lp_change_notify_timeout, &Globals.change_notify_timeout)
1686 FN_GLOBAL_INTEGER(lp_stat_cache_size, &Globals.stat_cache_size)
1687 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
1688 FN_GLOBAL_INTEGER(lp_min_passwd_length, &Globals.min_passwd_length)
1689 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
1690 FN_GLOBAL_INTEGER(lp_lock_spin_count, &Globals.iLockSpinCount)
1691 FN_GLOBAL_INTEGER(lp_lock_sleep_time, &Globals.iLockSpinTime)
1692 FN_LOCAL_STRING(lp_preexec, szPreExec)
1693 FN_LOCAL_STRING(lp_postexec, szPostExec)
1694 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
1695 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
1696 FN_LOCAL_STRING(lp_servicename, szService)
1697 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
1698 FN_LOCAL_STRING(lp_pathname, szPath)
1699 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
1700 FN_LOCAL_STRING(lp_username, szUsername)
1701 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
1702 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
1703 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
1704 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
1705 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
1706 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
1707 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
1708 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
1709 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
1710 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
1711 static FN_LOCAL_STRING(_lp_printername, szPrintername)
1712 FN_LOCAL_STRING(lp_driverfile, szDriverFile)
1713 FN_LOCAL_STRING(lp_printerdriver, szPrinterDriver)
1714 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
1715 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
1716 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
1717 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
1718 FN_LOCAL_STRING(lp_comment, comment)
1719 FN_LOCAL_STRING(lp_force_user, force_user)
1720 FN_LOCAL_STRING(lp_force_group, force_group)
1721 FN_LOCAL_LIST(lp_readlist, readlist)
1722 FN_LOCAL_LIST(lp_writelist, writelist)
1723 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
1724 FN_LOCAL_STRING(lp_fstype, fstype)
1725 FN_LOCAL_STRING(lp_vfsobj, szVfsObjectFile)
1726 FN_LOCAL_STRING(lp_vfs_options, szVfsOptions)
1727 FN_LOCAL_STRING(lp_vfs_path, szVfsPath)
1728 static FN_LOCAL_STRING(lp_volume, volume)
1729 FN_LOCAL_STRING(lp_mangled_map, szMangledMap)
1730 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
1731 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
1732 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
1733 FN_LOCAL_STRING(lp_driverlocation, szPrinterDriverLocation)
1734 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
1735 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
1736 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
1737 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
1738 FN_LOCAL_BOOL(lp_casesensitive, bCaseSensitive)
1739 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
1740 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
1741 FN_LOCAL_BOOL(lp_casemangle, bCaseMangle)
1742 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
1743 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
1744 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
1745 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
1746 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
1747 FN_LOCAL_BOOL(lp_readonly, bRead_only)
1748 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
1749 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
1750 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
1751 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
1752 FN_LOCAL_BOOL(lp_postscript, bPostscript)
1753 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
1754 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
1755 FN_LOCAL_BOOL(lp_locking, bLocking)
1756 FN_LOCAL_BOOL(lp_strict_locking, bStrictLocking)
1757 FN_LOCAL_BOOL(lp_posix_locking, bPosixLocking)
1758 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
1759 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
1760 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
1761 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
1762 FN_LOCAL_BOOL(lp_manglednames, bMangledNames)
1763 FN_LOCAL_BOOL(lp_widelinks, bWidelinks)
1764 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
1765 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
1766 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
1767 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
1768 FN_LOCAL_BOOL(lp_map_system, bMap_system)
1769 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
1770 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
1771 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
1772 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
1773 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
1774 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
1775 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
1776 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
1777 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
1778 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
1779 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
1780 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
1781 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
1782 FN_LOCAL_BOOL(lp_use_sendfile, bUseSendfile)
1783 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
1784 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
1785 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
1786 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
1787 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
1788 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
1789 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
1790 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
1791 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
1792 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
1793 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
1794 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
1795 FN_LOCAL_INTEGER(lp_printing, iPrinting)
1796 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
1797 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
1798 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
1799 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
1800 FN_LOCAL_CHAR(lp_magicchar, magic_char)
1801 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
1802 FN_GLOBAL_BOOL(lp_hide_local_users, &Globals.bHideLocalUsers)
1803 FN_GLOBAL_BOOL(lp_algorithmic_rid_base, &Globals.bAlgorithmicRidBase)
1804 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
1805
1806 typedef struct _param_opt_struct param_opt_struct;
1807 struct _param_opt_struct {
1808         char *key;
1809         char *value;
1810         param_opt_struct *prev, *next;
1811 };
1812
1813 static param_opt_struct *param_opt = NULL;
1814
1815 /* Return parametric option from given service. Type is a part of option before ':' */
1816 /* Parametric option has following syntax: 'Type: option = value' */
1817 /* Returned value is allocated in 'lp_talloc' context */
1818 char *lp_parm_string(const char *servicename, const char *type, const char *option)
1819 {
1820     param_opt_struct *data;
1821     pstring vfskey;
1822     
1823     if (param_opt != NULL) {
1824             ZERO_STRUCT(vfskey);
1825             pstr_sprintf(vfskey, "%s:%s:%s", (servicename==NULL) ? "global" : servicename,
1826                     type, option);
1827             data = param_opt;
1828             while (data) {
1829                     if (strcmp(data->key, vfskey) == 0) {
1830                             return lp_string(data->value);
1831                     }
1832                     data = data->next;
1833             }
1834             /* Try to fetch the same option but from globals */
1835             pstr_sprintf(vfskey, "global:%s:%s", type, option);
1836             data = param_opt;
1837             while (data) {
1838                     if (strcmp(data->key, vfskey) == 0) {
1839                             return lp_string(data->value);
1840                     }
1841                     data = data->next;
1842             }
1843         
1844     }
1845     return NULL;
1846 }
1847
1848 /* local prototypes */
1849
1850 static int map_parameter(char *pszParmName);
1851 static BOOL set_boolean(BOOL *pb, char *pszParmValue);
1852 static int getservicebyname(const char *pszServiceName,
1853                             service * pserviceDest);
1854 static void copy_service(service * pserviceDest,
1855                          service * pserviceSource, BOOL *pcopymapDest);
1856 static BOOL service_ok(int iService);
1857 static BOOL do_parameter(char *pszParmName, char *pszParmValue);
1858 static BOOL do_section(char *pszSectionName);
1859 static void init_copymap(service * pservice);
1860
1861
1862 /***************************************************************************
1863 initialise a service to the defaults
1864 ***************************************************************************/
1865 static void init_service(service * pservice)
1866 {
1867         memset((char *)pservice, '\0', sizeof(service));
1868         copy_service(pservice, &sDefault, NULL);
1869 }
1870
1871
1872 /***************************************************************************
1873 free the dynamically allocated parts of a service struct
1874 ***************************************************************************/
1875 static void free_service(service * pservice)
1876 {
1877         int i;
1878         if (!pservice)
1879                 return;
1880
1881         if (pservice->szService)
1882                 DEBUG(5,
1883                       ("free_service: Freeing service %s\n",
1884                        pservice->szService));
1885
1886         string_free(&pservice->szService);
1887         SAFE_FREE(pservice->copymap);
1888
1889         for (i = 0; parm_table[i].label; i++)
1890         {
1891                 if ((parm_table[i].type == P_STRING ||
1892                      parm_table[i].type == P_USTRING) &&
1893                     parm_table[i].class == P_LOCAL)
1894                         string_free((char **)
1895                                     (((char *)pservice) +
1896                                      PTR_DIFF(parm_table[i].ptr, &sDefault)));
1897                 else if (parm_table[i].type == P_LIST &&
1898                          parm_table[i].class == P_LOCAL)
1899                              str_list_free((char ***)
1900                                             (((char *)pservice) +
1901                                              PTR_DIFF(parm_table[i].ptr, &sDefault)));
1902         }
1903                                 
1904
1905         ZERO_STRUCTP(pservice);
1906 }
1907
1908 /***************************************************************************
1909 add a new service to the services array initialising it with the given 
1910 service. 
1911 ***************************************************************************/
1912 static int add_a_service(const service * pservice, const char *name)
1913 {
1914         int i;
1915         service tservice;
1916         int num_to_alloc = iNumServices + 1;
1917
1918         tservice = *pservice;
1919
1920         /* it might already exist */
1921         if (name)
1922         {
1923                 i = getservicebyname(name, NULL);
1924                 if (i >= 0)
1925                         return (i);
1926         }
1927
1928         /* find an invalid one */
1929         for (i = 0; i < iNumServices; i++)
1930                 if (!ServicePtrs[i]->valid)
1931                         break;
1932
1933         /* if not, then create one */
1934         if (i == iNumServices)
1935         {
1936                 service **tsp;
1937                 
1938                 tsp = (service **) Realloc(ServicePtrs,
1939                                            sizeof(service *) *
1940                                            num_to_alloc);
1941                                            
1942                 if (!tsp) {
1943                         DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
1944                         return (-1);
1945                 }
1946                 else {
1947                         ServicePtrs = tsp;
1948                         ServicePtrs[iNumServices] =
1949                                 (service *) malloc(sizeof(service));
1950                 }
1951                 if (!ServicePtrs[iNumServices]) {
1952                         DEBUG(0,("add_a_service: out of memory!\n"));
1953                         return (-1);
1954                 }
1955
1956                 iNumServices++;
1957         }
1958         else
1959                 free_service(ServicePtrs[i]);
1960
1961         ServicePtrs[i]->valid = True;
1962
1963         init_service(ServicePtrs[i]);
1964         copy_service(ServicePtrs[i], &tservice, NULL);
1965         if (name)
1966         {
1967                 string_set(&ServicePtrs[i]->szService, name);
1968         }
1969         return (i);
1970 }
1971
1972 /***************************************************************************
1973 add a new home service, with the specified home directory, defaults coming 
1974 from service ifrom.
1975 ***************************************************************************/
1976 BOOL lp_add_home(const char *pszHomename, int iDefaultService, 
1977                  const char *user, const char *pszHomedir)
1978 {
1979         int i;
1980         pstring newHomedir;
1981
1982         i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
1983
1984         if (i < 0)
1985                 return (False);
1986
1987         if (!(*(ServicePtrs[iDefaultService]->szPath))
1988             || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(-1))) {
1989                 pstrcpy(newHomedir, pszHomedir);
1990         } else {
1991                 pstrcpy(newHomedir, lp_pathname(iDefaultService));
1992                 string_sub(newHomedir,"%H", pszHomedir, sizeof(newHomedir)); 
1993         }
1994
1995         string_set(&ServicePtrs[i]->szPath, newHomedir);
1996
1997         if (!(*(ServicePtrs[i]->comment)))
1998         {
1999                 pstring comment;
2000                 slprintf(comment, sizeof(comment) - 1,
2001                          "Home directory of %s", user);
2002                 string_set(&ServicePtrs[i]->comment, comment);
2003         }
2004         ServicePtrs[i]->bAvailable = sDefault.bAvailable;
2005         ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
2006
2007         DEBUG(3,
2008               ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename, 
2009                user, newHomedir));
2010         
2011         return (True);
2012 }
2013
2014 /***************************************************************************
2015 add a new service, based on an old one.
2016 ***************************************************************************/
2017 int lp_add_service(const char *pszService, int iDefaultService)
2018 {
2019         return (add_a_service(ServicePtrs[iDefaultService], pszService));
2020 }
2021
2022
2023 /***************************************************************************
2024 add the IPC service
2025 ***************************************************************************/
2026 static BOOL lp_add_ipc(char *ipc_name, BOOL guest_ok)
2027 {
2028         pstring comment;
2029         int i = add_a_service(&sDefault, ipc_name);
2030
2031         if (i < 0)
2032                 return (False);
2033
2034         slprintf(comment, sizeof(comment) - 1,
2035                  "IPC Service (%s)", Globals.szServerString);
2036
2037         string_set(&ServicePtrs[i]->szPath, tmpdir());
2038         string_set(&ServicePtrs[i]->szUsername, "");
2039         string_set(&ServicePtrs[i]->comment, comment);
2040         string_set(&ServicePtrs[i]->fstype, "IPC");
2041         ServicePtrs[i]->iMaxConnections = 0;
2042         ServicePtrs[i]->bAvailable = True;
2043         ServicePtrs[i]->bRead_only = True;
2044         ServicePtrs[i]->bGuest_only = False;
2045         ServicePtrs[i]->bGuest_ok = guest_ok;
2046         ServicePtrs[i]->bPrint_ok = False;
2047         ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
2048
2049         DEBUG(3, ("adding IPC service\n"));
2050
2051         return (True);
2052 }
2053
2054 /***************************************************************************
2055 add a new printer service, with defaults coming from service iFrom.
2056 ***************************************************************************/
2057 BOOL lp_add_printer(const char *pszPrintername, int iDefaultService)
2058 {
2059         const char *comment = "From Printcap";
2060         int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
2061
2062         if (i < 0)
2063                 return (False);
2064
2065         /* note that we do NOT default the availability flag to True - */
2066         /* we take it from the default service passed. This allows all */
2067         /* dynamic printers to be disabled by disabling the [printers] */
2068         /* entry (if/when the 'available' keyword is implemented!).    */
2069
2070         /* the printer name is set to the service name. */
2071         string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
2072         string_set(&ServicePtrs[i]->comment, comment);
2073         ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
2074         /* Printers cannot be read_only. */
2075         ServicePtrs[i]->bRead_only = False;
2076         /* No share modes on printer services. */
2077         ServicePtrs[i]->bShareModes = False;
2078         /* No oplocks on printer services. */
2079         ServicePtrs[i]->bOpLocks = False;
2080         /* Printer services must be printable. */
2081         ServicePtrs[i]->bPrint_ok = True;
2082
2083         DEBUG(3, ("adding printer service %s\n", pszPrintername));
2084
2085         update_server_announce_as_printserver();
2086
2087         return (True);
2088 }
2089
2090 /***************************************************************************
2091 Map a parameter's string representation to something we can use. 
2092 Returns False if the parameter string is not recognised, else TRUE.
2093 ***************************************************************************/
2094 static int map_parameter(char *pszParmName)
2095 {
2096         int iIndex;
2097
2098         if (*pszParmName == '-')
2099                 return (-1);
2100
2101         for (iIndex = 0; parm_table[iIndex].label; iIndex++)
2102                 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
2103                         return (iIndex);
2104
2105         /* Warn only if it isn't parametric option */
2106         if (strchr(pszParmName, ':') == NULL)
2107                 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
2108         /* We do return 'fail' for parametric options as well because they are
2109            stored in different storage
2110          */
2111         return (-1);
2112 }
2113
2114
2115 /***************************************************************************
2116 Set a boolean variable from the text value stored in the passed string.
2117 Returns True in success, False if the passed string does not correctly 
2118 represent a boolean.
2119 ***************************************************************************/
2120 static BOOL set_boolean(BOOL *pb, char *pszParmValue)
2121 {
2122         BOOL bRetval;
2123
2124         bRetval = True;
2125         if (strwicmp(pszParmValue, "yes") == 0 ||
2126             strwicmp(pszParmValue, "true") == 0 ||
2127             strwicmp(pszParmValue, "1") == 0)
2128                 *pb = True;
2129         else
2130                 if (strwicmp(pszParmValue, "no") == 0 ||
2131                     strwicmp(pszParmValue, "False") == 0 ||
2132                     strwicmp(pszParmValue, "0") == 0)
2133                 *pb = False;
2134         else
2135         {
2136                 DEBUG(0,
2137                       ("ERROR: Badly formed boolean in configuration file: \"%s\".\n",
2138                        pszParmValue));
2139                 bRetval = False;
2140         }
2141         return (bRetval);
2142 }
2143
2144 /***************************************************************************
2145 Find a service by name. Otherwise works like get_service.
2146 ***************************************************************************/
2147 static int getservicebyname(const char *pszServiceName, service * pserviceDest)
2148 {
2149         int iService;
2150
2151         for (iService = iNumServices - 1; iService >= 0; iService--)
2152                 if (VALID(iService) &&
2153                     strwicmp(ServicePtrs[iService]->szService, pszServiceName) == 0)
2154                 {
2155                         if (pserviceDest != NULL)
2156                                 copy_service(pserviceDest, ServicePtrs[iService], NULL);
2157                         break;
2158                 }
2159
2160         return (iService);
2161 }
2162
2163
2164
2165 /***************************************************************************
2166 Copy a service structure to another
2167
2168 If pcopymapDest is NULL then copy all fields
2169 ***************************************************************************/
2170 static void copy_service(service * pserviceDest,
2171                          service * pserviceSource, BOOL *pcopymapDest)
2172 {
2173         int i;
2174         BOOL bcopyall = (pcopymapDest == NULL);
2175
2176         for (i = 0; parm_table[i].label; i++)
2177                 if (parm_table[i].ptr && parm_table[i].class == P_LOCAL &&
2178                     (bcopyall || pcopymapDest[i]))
2179                 {
2180                         void *def_ptr = parm_table[i].ptr;
2181                         void *src_ptr =
2182                                 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
2183                                                                     &sDefault);
2184                         void *dest_ptr =
2185                                 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
2186                                                                   &sDefault);
2187
2188                         switch (parm_table[i].type)
2189                         {
2190                                 case P_BOOL:
2191                                 case P_BOOLREV:
2192                                         *(BOOL *)dest_ptr = *(BOOL *)src_ptr;
2193                                         break;
2194
2195                                 case P_INTEGER:
2196                                 case P_ENUM:
2197                                 case P_OCTAL:
2198                                         *(int *)dest_ptr = *(int *)src_ptr;
2199                                         break;
2200
2201                                 case P_CHAR:
2202                                         *(char *)dest_ptr = *(char *)src_ptr;
2203                                         break;
2204
2205                                 case P_STRING:
2206                                         string_set(dest_ptr,
2207                                                    *(char **)src_ptr);
2208                                         break;
2209
2210                                 case P_USTRING:
2211                                         string_set(dest_ptr,
2212                                                    *(char **)src_ptr);
2213                                         strupper(*(char **)dest_ptr);
2214                                         break;
2215                                 case P_LIST:
2216                                         str_list_copy((char ***)dest_ptr, *(char ***)src_ptr);
2217                                         break;
2218                                 default:
2219                                         break;
2220                         }
2221                 }
2222
2223         if (bcopyall)
2224         {
2225                 init_copymap(pserviceDest);
2226                 if (pserviceSource->copymap)
2227                         memcpy((void *)pserviceDest->copymap,
2228                                (void *)pserviceSource->copymap,
2229                                sizeof(BOOL) * NUMPARAMETERS);
2230         }
2231 }
2232
2233 /***************************************************************************
2234 Check a service for consistency. Return False if the service is in any way
2235 incomplete or faulty, else True.
2236 ***************************************************************************/
2237 static BOOL service_ok(int iService)
2238 {
2239         BOOL bRetval;
2240
2241         bRetval = True;
2242         if (ServicePtrs[iService]->szService[0] == '\0')
2243         {
2244                 DEBUG(0,
2245                       ("The following message indicates an internal error:\n"));
2246                 DEBUG(0, ("No service name in service entry.\n"));
2247                 bRetval = False;
2248         }
2249
2250         /* The [printers] entry MUST be printable. I'm all for flexibility, but */
2251         /* I can't see why you'd want a non-printable printer service...        */
2252         if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
2253                 if (!ServicePtrs[iService]->bPrint_ok) {
2254                         DEBUG(0,
2255                               ("WARNING: [%s] service MUST be printable!\n",
2256                                ServicePtrs[iService]->szService));
2257                         ServicePtrs[iService]->bPrint_ok = True;
2258                 }
2259                 /* [printers] service must also be non-browsable. */
2260                 if (ServicePtrs[iService]->bBrowseable)
2261                         ServicePtrs[iService]->bBrowseable = False;
2262         }
2263
2264         if (ServicePtrs[iService]->szPath[0] == '\0' &&
2265             strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0)
2266         {
2267                 DEBUG(0,
2268                       ("No path in service %s - using %s\n",
2269                        ServicePtrs[iService]->szService, tmpdir()));
2270                 string_set(&ServicePtrs[iService]->szPath, tmpdir());
2271         }
2272
2273         /* If a service is flagged unavailable, log the fact at level 0. */
2274         if (!ServicePtrs[iService]->bAvailable)
2275                 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
2276                           ServicePtrs[iService]->szService));
2277
2278         return (bRetval);
2279 }
2280
2281 static struct file_lists
2282 {
2283         struct file_lists *next;
2284         char *name;
2285         char *subfname;
2286         time_t modtime;
2287 }
2288  *file_lists = NULL;
2289
2290 /*******************************************************************
2291 keep a linked list of all config files so we know when one has changed 
2292 it's date and needs to be reloaded
2293 ********************************************************************/
2294 static void add_to_file_list(const char *fname, const char *subfname)
2295 {
2296         struct file_lists *f = file_lists;
2297
2298         while (f)
2299         {
2300                 if (f->name && !strcmp(f->name, fname))
2301                         break;
2302                 f = f->next;
2303         }
2304
2305         if (!f)
2306         {
2307                 f = (struct file_lists *)malloc(sizeof(file_lists[0]));
2308                 if (!f)
2309                         return;
2310                 f->next = file_lists;
2311                 f->name = strdup(fname);
2312                 if (!f->name)
2313                 {
2314                         SAFE_FREE(f);
2315                         return;
2316                 }
2317                 f->subfname = strdup(subfname);
2318                 if (!f->subfname)
2319                 {
2320                         SAFE_FREE(f);
2321                         return;
2322                 }
2323                 file_lists = f;
2324                 f->modtime = file_modtime(subfname);
2325         } else {
2326                 time_t t = file_modtime(subfname);
2327                 if (t)
2328                         f->modtime = t;
2329         }
2330 }
2331
2332 /*******************************************************************
2333 check if a config file has changed date
2334 ********************************************************************/
2335 BOOL lp_file_list_changed(void)
2336 {
2337         struct file_lists *f = file_lists;
2338         DEBUG(6, ("lp_file_list_changed()\n"));
2339
2340         while (f) {
2341                 pstring n2;
2342                 time_t mod_time;
2343
2344                 pstrcpy(n2, f->name);
2345                 standard_sub_basic(current_user_info.smb_name, n2,sizeof(n2));
2346
2347                 DEBUGADD(6, ("file %s -> %s  last mod_time: %s\n",
2348                              f->name, n2, ctime(&f->modtime)));
2349
2350                 mod_time = file_modtime(n2);
2351
2352                 if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
2353                         DEBUGADD(6,
2354                                  ("file %s modified: %s\n", n2,
2355                                   ctime(&mod_time)));
2356                         f->modtime = mod_time;
2357                         SAFE_FREE(f->subfname);
2358                         f->subfname = strdup(n2);
2359                         return (True);
2360                 }
2361                 f = f->next;
2362         }
2363         return (False);
2364 }
2365
2366 /***************************************************************************
2367  Run standard_sub_basic on netbios name... needed because global_myname
2368  is not accessed through any lp_ macro.
2369  Note: We must *NOT* use string_set() here as ptr points to global_myname.
2370 ***************************************************************************/
2371
2372 static BOOL handle_netbios_name(char *pszParmValue, char **ptr)
2373 {
2374         pstring netbios_name;
2375
2376         pstrcpy(netbios_name, pszParmValue);
2377
2378         standard_sub_basic(current_user_info.smb_name, netbios_name,sizeof(netbios_name));
2379         strupper(netbios_name);
2380
2381         pstrcpy(global_myname, netbios_name);
2382
2383         DEBUG(4,
2384               ("handle_netbios_name: set global_myname to: %s\n",
2385                global_myname));
2386
2387         return (True);
2388 }
2389
2390 /***************************************************************************
2391  Do the work of sourcing in environment variable/value pairs.
2392 ***************************************************************************/
2393
2394 static BOOL source_env(char **lines)
2395 {
2396         char *varval;
2397         size_t len;
2398         int i;
2399         char *p;
2400
2401         for (i = 0; lines[i]; i++)
2402         {
2403                 char *line = lines[i];
2404
2405                 if ((len = strlen(line)) == 0)
2406                         continue;
2407
2408                 if (line[len - 1] == '\n')
2409                         line[--len] = '\0';
2410
2411                 if ((varval = malloc(len + 1)) == NULL)
2412                 {
2413                         DEBUG(0, ("source_env: Not enough memory!\n"));
2414                         return (False);
2415                 }
2416
2417                 DEBUG(4, ("source_env: Adding to environment: %s\n", line));
2418                 strncpy(varval, line, len);
2419                 varval[len] = '\0';
2420
2421                 p = strchr_m(line, (int)'=');
2422                 if (p == NULL)
2423                 {
2424                         DEBUG(4, ("source_env: missing '=': %s\n", line));
2425                         continue;
2426                 }
2427
2428                 if (putenv(varval))
2429                 {
2430                         DEBUG(0,
2431                               ("source_env: Failed to put environment variable %s\n",
2432                                varval));
2433                         continue;
2434                 }
2435
2436                 *p = '\0';
2437                 p++;
2438                 DEBUG(4,
2439                       ("source_env: getting var %s = %s\n", line,
2440                        getenv(line)));
2441         }
2442
2443         DEBUG(4, ("source_env: returning successfully\n"));
2444         return (True);
2445 }
2446
2447 /***************************************************************************
2448  Handle the source environment operation
2449 ***************************************************************************/
2450
2451 static BOOL handle_source_env(char *pszParmValue, char **ptr)
2452 {
2453         pstring fname;
2454         char *p = fname;
2455         BOOL result;
2456         char **lines;
2457
2458         pstrcpy(fname, pszParmValue);
2459
2460         standard_sub_basic(current_user_info.smb_name, fname,sizeof(fname));
2461
2462         string_set(ptr, pszParmValue);
2463
2464         DEBUG(4, ("handle_source_env: checking env type\n"));
2465
2466         /*
2467          * Filename starting with '|' means popen and read from stdin.
2468          */
2469
2470         if (*p == '|')
2471         {
2472                 lines = file_lines_pload(p + 1, NULL);
2473         }
2474         else
2475         {
2476                 lines = file_lines_load(fname, NULL);
2477         }
2478
2479         if (!lines)
2480         {
2481                 DEBUG(0,
2482                       ("handle_source_env: Failed to open file %s, Error was %s\n",
2483                        fname, strerror(errno)));
2484                 return (False);
2485         }
2486
2487         result = source_env(lines);
2488         file_lines_free(lines);
2489
2490         return (result);
2491 }
2492
2493 /***************************************************************************
2494   handle the interpretation of the vfs object parameter
2495   *************************************************************************/
2496 static BOOL handle_vfs_object(char *pszParmValue, char **ptr)
2497 {
2498         /* Set string value */
2499
2500         string_set(ptr, pszParmValue);
2501
2502         /* Do any other initialisation required for vfs.  Note that
2503            anything done here may have linking repercussions in nmbd. */
2504
2505         return True;
2506 }
2507
2508
2509 /***************************************************************************
2510 handle the include operation
2511 ***************************************************************************/
2512
2513 static BOOL handle_include(char *pszParmValue, char **ptr)
2514 {
2515         pstring fname;
2516         pstrcpy(fname, pszParmValue);
2517
2518         standard_sub_basic(current_user_info.smb_name, fname,sizeof(fname));
2519
2520         add_to_file_list(pszParmValue, fname);
2521
2522         string_set(ptr, fname);
2523
2524         if (file_exist(fname, NULL))
2525                 return (pm_process(fname, do_section, do_parameter));
2526
2527         DEBUG(2, ("Can't find include file %s\n", fname));
2528
2529         return (False);
2530 }
2531
2532
2533 /***************************************************************************
2534 handle the interpretation of the copy parameter
2535 ***************************************************************************/
2536 static BOOL handle_copy(char *pszParmValue, char **ptr)
2537 {
2538         BOOL bRetval;
2539         int iTemp;
2540         service serviceTemp;
2541
2542         string_set(ptr, pszParmValue);
2543
2544         init_service(&serviceTemp);
2545
2546         bRetval = False;
2547
2548         DEBUG(3, ("Copying service from service %s\n", pszParmValue));
2549
2550         if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0)
2551         {
2552                 if (iTemp == iServiceIndex)
2553                 {
2554                         DEBUG(0,
2555                               ("Can't copy service %s - unable to copy self!\n",
2556                                pszParmValue));
2557                 }
2558                 else
2559                 {
2560                         copy_service(ServicePtrs[iServiceIndex],
2561                                      &serviceTemp,
2562                                      ServicePtrs[iServiceIndex]->copymap);
2563                         bRetval = True;
2564                 }
2565         }
2566         else
2567         {
2568                 DEBUG(0, ("Unable to copy service - source not found: %s\n",
2569                           pszParmValue));
2570                 bRetval = False;
2571         }
2572
2573         free_service(&serviceTemp);
2574         return (bRetval);
2575 }
2576
2577 /***************************************************************************
2578  Handle winbind/non unix account uid and gid allocation parameters.  The format of these
2579  parameters is:
2580
2581  [global]
2582
2583         winbind uid = 1000-1999
2584         winbind gid = 700-899
2585
2586  We only do simple parsing checks here.  The strings are parsed into useful
2587  structures in the winbind daemon code.
2588
2589 ***************************************************************************/
2590
2591 /* Some lp_ routines to return winbind [ug]id information */
2592
2593 static uid_t winbind_uid_low, winbind_uid_high;
2594 static gid_t winbind_gid_low, winbind_gid_high;
2595 static uint32 non_unix_account_low, non_unix_account_high;
2596
2597 BOOL lp_winbind_uid(uid_t *low, uid_t *high)
2598 {
2599         if (winbind_uid_low == 0 || winbind_uid_high == 0)
2600                 return False;
2601
2602         if (low)
2603                 *low = winbind_uid_low;
2604
2605         if (high)
2606                 *high = winbind_uid_high;
2607
2608         return True;
2609 }
2610
2611 BOOL lp_winbind_gid(gid_t *low, gid_t *high)
2612 {
2613         if (winbind_gid_low == 0 || winbind_gid_high == 0)
2614                 return False;
2615
2616         if (low)
2617                 *low = winbind_gid_low;
2618
2619         if (high)
2620                 *high = winbind_gid_high;
2621
2622         return True;
2623 }
2624
2625 BOOL lp_non_unix_account_range(uint32 *low, uint32 *high)
2626 {
2627         if (non_unix_account_low == 0 || non_unix_account_high == 0)
2628                 return False;
2629
2630         if (low)
2631                 *low = non_unix_account_low;
2632
2633         if (high)
2634                 *high = non_unix_account_high;
2635
2636         return True;
2637 }
2638
2639 /* Do some simple checks on "winbind [ug]id" parameter values */
2640
2641 static BOOL handle_winbind_uid(char *pszParmValue, char **ptr)
2642 {
2643         uint32 low, high;
2644
2645         if (sscanf(pszParmValue, "%u-%u", &low, &high) != 2 || high < low)
2646                 return False;
2647
2648         /* Parse OK */
2649
2650         string_set(ptr, pszParmValue);
2651
2652         winbind_uid_low = low;
2653         winbind_uid_high = high;
2654
2655         return True;
2656 }
2657
2658 static BOOL handle_winbind_gid(char *pszParmValue, char **ptr)
2659 {
2660         uint32 low, high;
2661
2662         if (sscanf(pszParmValue, "%u-%u", &low, &high) != 2 || high < low)
2663                 return False;
2664
2665         /* Parse OK */
2666
2667         string_set(ptr, pszParmValue);
2668
2669         winbind_gid_low = low;
2670         winbind_gid_high = high;
2671
2672         return True;
2673 }
2674
2675 /* Do some simple checks on "non unix account range" parameter values */
2676
2677 static BOOL handle_non_unix_account_range(char *pszParmValue, char **ptr)
2678 {
2679         uint32 low, high;
2680
2681         if (sscanf(pszParmValue, "%u-%u", &low, &high) != 2 || high < low)
2682                 return False;
2683
2684         /* Parse OK */
2685
2686         string_set(ptr, pszParmValue);
2687
2688         non_unix_account_low = low;
2689         non_unix_account_high = high;
2690
2691         return True;
2692 }
2693
2694 /***************************************************************************
2695  Handle the DEBUG level list
2696 ***************************************************************************/
2697 static BOOL handle_debug_list( char *pszParmValueIn, char **ptr )
2698 {
2699         pstring pszParmValue;
2700
2701         pstrcpy(pszParmValue, pszParmValueIn);
2702         string_set(ptr, pszParmValueIn);
2703         return debug_parse_levels( pszParmValue );
2704 }
2705
2706 /***************************************************************************
2707  Handle the ldap machine suffix option
2708 ***************************************************************************/
2709 static BOOL handle_ldap_machine_suffix( char *pszParmValue, char **ptr)
2710 {
2711        pstring suffix;
2712        
2713        pstrcpy(suffix, pszParmValue);
2714
2715        if (! *Globals.szLdapSuffix ) {
2716                string_set( ptr, suffix );
2717                return True;
2718        }
2719
2720        if (! strstr(suffix, Globals.szLdapSuffix) ) {
2721                if ( *pszParmValue )
2722                        pstrcat(suffix, ",");
2723                pstrcat(suffix, Globals.szLdapSuffix);
2724        }
2725        string_set( ptr, suffix );
2726        return True;
2727 }
2728
2729 /***************************************************************************
2730  Handle the ldap user suffix option
2731 ***************************************************************************/
2732 static BOOL handle_ldap_user_suffix( char *pszParmValue, char **ptr)
2733 {
2734        pstring suffix;
2735        
2736        pstrcpy(suffix, pszParmValue);
2737
2738        if (! *Globals.szLdapSuffix ) {
2739                string_set( ptr, suffix );
2740                return True;
2741        }
2742        
2743        if (! strstr(suffix, Globals.szLdapSuffix) ) {
2744                if ( *pszParmValue )
2745                        pstrcat(suffix, ",");
2746                pstrcat(suffix, Globals.szLdapSuffix);
2747        }
2748        string_set( ptr, suffix );
2749        return True;
2750 }
2751
2752 /***************************************************************************
2753  Handle setting ldap suffix and determines whether ldap machine suffix needs
2754  to be set as well
2755 ***************************************************************************/
2756 static BOOL handle_ldap_suffix( char *pszParmValue, char **ptr)
2757 {
2758        pstring suffix;
2759        pstring user_suffix;
2760        pstring machine_suffix;
2761                
2762        pstrcpy(suffix, pszParmValue);
2763
2764        if (! *Globals.szLdapMachineSuffix )
2765                string_set(&Globals.szLdapMachineSuffix, suffix);
2766        if (! *Globals.szLdapUserSuffix ) 
2767                string_set(&Globals.szLdapUserSuffix, suffix);
2768        
2769        if (! strstr(Globals.szLdapMachineSuffix, suffix)) {
2770                pstrcpy(machine_suffix, Globals.szLdapMachineSuffix);
2771                if ( *Globals.szLdapMachineSuffix )
2772                        pstrcat(machine_suffix, ",");
2773                pstrcat(machine_suffix, suffix);
2774                string_set(&Globals.szLdapMachineSuffix, machine_suffix);       
2775        }
2776
2777        if (! strstr(Globals.szLdapUserSuffix, suffix)) {
2778                pstrcpy(user_suffix, Globals.szLdapUserSuffix);
2779                if ( *Globals.szLdapUserSuffix )
2780                        pstrcat(user_suffix, ",");
2781                pstrcat(user_suffix, suffix);   
2782                string_set(&Globals.szLdapUserSuffix, user_suffix);
2783        } 
2784
2785        string_set(ptr, suffix); 
2786        return True;
2787 }
2788
2789 /***************************************************************************
2790 initialise a copymap
2791 ***************************************************************************/
2792 static void init_copymap(service * pservice)
2793 {
2794         int i;
2795         SAFE_FREE(pservice->copymap);
2796         pservice->copymap = (BOOL *)malloc(sizeof(BOOL) * NUMPARAMETERS);
2797         if (!pservice->copymap)
2798                 DEBUG(0,
2799                       ("Couldn't allocate copymap!! (size %d)\n",
2800                        (int)NUMPARAMETERS));
2801         else
2802                 for (i = 0; i < NUMPARAMETERS; i++)
2803                         pservice->copymap[i] = True;
2804 }
2805
2806
2807 /***************************************************************************
2808  return the local pointer to a parameter given the service number and the 
2809  pointer into the default structure
2810 ***************************************************************************/
2811 void *lp_local_ptr(int snum, void *ptr)
2812 {
2813         return (void *)(((char *)ServicePtrs[snum]) + PTR_DIFF(ptr, &sDefault));
2814 }
2815
2816 /***************************************************************************
2817 Process a parameter for a particular service number. If snum < 0
2818 then assume we are in the globals
2819 ***************************************************************************/
2820 BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
2821 {
2822         int parmnum, i, slen;
2823         void *parm_ptr = NULL;  /* where we are going to store the result */
2824         void *def_ptr = NULL;
2825         pstring vfskey;
2826         char *sep;
2827         param_opt_struct *paramo;
2828
2829         parmnum = map_parameter(pszParmName);
2830
2831         if (parmnum < 0)
2832         {
2833                 if ((sep=strchr(pszParmName, ':')) != NULL) {
2834                         *sep = 0;
2835                         ZERO_STRUCT(vfskey);
2836                         pstr_sprintf(vfskey, "%s:%s:", 
2837                                 (snum >= 0) ? lp_servicename(snum) : "global", pszParmName);
2838                         slen = strlen(vfskey);
2839                         safe_strcat(vfskey, sep+1, sizeof(pstring));
2840                         trim_string(vfskey+slen, " ", " ");
2841                         paramo = smb_xmalloc(sizeof(param_opt_struct));
2842                         paramo->key = strdup(vfskey);
2843                         paramo->value = strdup(pszParmValue);
2844                         DLIST_ADD(param_opt, paramo);
2845                         *sep = ':';
2846                         return (True);
2847                 }
2848                 DEBUG(0,
2849                       ("Ignoring unknown parameter \"%s\"\n", pszParmName));
2850                 return (True);
2851         }
2852
2853         if (parm_table[parmnum].flags & FLAG_DEPRECATED)
2854         {
2855                 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
2856                           pszParmName));
2857         }
2858
2859         def_ptr = parm_table[parmnum].ptr;
2860
2861         /* we might point at a service, the default service or a global */
2862         if (snum < 0)
2863         {
2864                 parm_ptr = def_ptr;
2865         }
2866         else
2867         {
2868                 if (parm_table[parmnum].class == P_GLOBAL)
2869                 {
2870                         DEBUG(0,
2871                               ("Global parameter %s found in service section!\n",
2872                                pszParmName));
2873                         return (True);
2874                 }
2875                 parm_ptr =
2876                         ((char *)ServicePtrs[snum]) + PTR_DIFF(def_ptr,
2877                                                             &sDefault);
2878         }
2879
2880         if (snum >= 0)
2881         {
2882                 if (!ServicePtrs[snum]->copymap)
2883                         init_copymap(ServicePtrs[snum]);
2884
2885                 /* this handles the aliases - set the copymap for other entries with
2886                    the same data pointer */
2887                 for (i = 0; parm_table[i].label; i++)
2888                         if (parm_table[i].ptr == parm_table[parmnum].ptr)
2889                                 ServicePtrs[snum]->copymap[i] = False;
2890         }
2891
2892         /* if it is a special case then go ahead */
2893         if (parm_table[parmnum].special)
2894         {
2895                 parm_table[parmnum].special(pszParmValue, (char **)parm_ptr);
2896                 return (True);
2897         }
2898
2899         /* now switch on the type of variable it is */
2900         switch (parm_table[parmnum].type)
2901         {
2902                 case P_BOOL:
2903                         set_boolean(parm_ptr, pszParmValue);
2904                         break;
2905
2906                 case P_BOOLREV:
2907                         set_boolean(parm_ptr, pszParmValue);
2908                         *(BOOL *)parm_ptr = !*(BOOL *)parm_ptr;
2909                         break;
2910
2911                 case P_INTEGER:
2912                         *(int *)parm_ptr = atoi(pszParmValue);
2913                         break;
2914
2915                 case P_CHAR:
2916                         *(char *)parm_ptr = *pszParmValue;
2917                         break;
2918
2919                 case P_OCTAL:
2920                         sscanf(pszParmValue, "%o", (int *)parm_ptr);
2921                         break;
2922
2923                 case P_LIST:
2924                         *(char ***)parm_ptr = str_list_make(pszParmValue, NULL);
2925                         break;
2926
2927                 case P_STRING:
2928                         string_set(parm_ptr, pszParmValue);
2929                         break;
2930
2931                 case P_USTRING:
2932                         string_set(parm_ptr, pszParmValue);
2933                         strupper(*(char **)parm_ptr);
2934                         break;
2935
2936                 case P_GSTRING:
2937                         pstrcpy((char *)parm_ptr, pszParmValue);
2938                         break;
2939
2940                 case P_UGSTRING:
2941                         pstrcpy((char *)parm_ptr, pszParmValue);
2942                         strupper((char *)parm_ptr);
2943                         break;
2944
2945                 case P_ENUM:
2946                         for (i = 0; parm_table[parmnum].enum_list[i].name;
2947                              i++)
2948                         {
2949                                 if (strequal
2950                                     (pszParmValue,
2951                                      parm_table[parmnum].enum_list[i].name))
2952                                 {
2953                                         *(int *)parm_ptr =
2954                                                 parm_table[parmnum].
2955                                                 enum_list[i].value;
2956                                         break;
2957                                 }
2958                         }
2959                         break;
2960                 case P_SEP:
2961                         break;
2962         }
2963
2964         return (True);
2965 }
2966
2967 /***************************************************************************
2968 Process a parameter.
2969 ***************************************************************************/
2970 static BOOL do_parameter(char *pszParmName, char *pszParmValue)
2971 {
2972         if (!bInGlobalSection && bGlobalOnly)
2973                 return (True);
2974
2975         DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
2976
2977         return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
2978                                 pszParmName, pszParmValue));
2979 }
2980
2981
2982 /***************************************************************************
2983 print a parameter of the specified type
2984 ***************************************************************************/
2985 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
2986 {
2987         int i;
2988         switch (p->type)
2989         {
2990                 case P_ENUM:
2991                         for (i = 0; p->enum_list[i].name; i++)
2992                         {
2993                                 if (*(int *)ptr == p->enum_list[i].value)
2994                                 {
2995                                         fprintf(f, "%s",
2996                                                 p->enum_list[i].name);
2997                                         break;
2998                                 }
2999                         }
3000                         break;
3001
3002                 case P_BOOL:
3003                         fprintf(f, "%s", BOOLSTR(*(BOOL *)ptr));
3004                         break;
3005
3006                 case P_BOOLREV:
3007                         fprintf(f, "%s", BOOLSTR(!*(BOOL *)ptr));
3008                         break;
3009
3010                 case P_INTEGER:
3011                         fprintf(f, "%d", *(int *)ptr);
3012                         break;
3013
3014                 case P_CHAR:
3015                         fprintf(f, "%c", *(char *)ptr);
3016                         break;
3017
3018                 case P_OCTAL:
3019                         fprintf(f, "%s", octal_string(*(int *)ptr));
3020                         break;
3021
3022                 case P_LIST:
3023                         if ((char ***)ptr && *(char ***)ptr) {
3024                                 char **list = *(char ***)ptr;
3025                                 
3026                                 for (; *list; list++)
3027                                         fprintf(f, "%s%s", *list,
3028                                                 ((*(list+1))?", ":""));
3029                         }
3030                         break;
3031
3032                 case P_GSTRING:
3033                 case P_UGSTRING:
3034                         if ((char *)ptr) {
3035                                 fprintf(f, "%s", (char *)ptr);
3036                         }
3037                         break;
3038
3039                 case P_STRING:
3040                 case P_USTRING:
3041                         if (*(char **)ptr) {
3042                                 fprintf(f, "%s", *(char **)ptr);
3043                         }
3044                         break;
3045                 case P_SEP:
3046                         break;
3047         }
3048 }
3049
3050
3051 /***************************************************************************
3052 check if two parameters are equal
3053 ***************************************************************************/
3054 static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
3055 {
3056         switch (type)
3057         {
3058                 case P_BOOL:
3059                 case P_BOOLREV:
3060                         return (*((BOOL *)ptr1) == *((BOOL *)ptr2));
3061
3062                 case P_INTEGER:
3063                 case P_ENUM:
3064                 case P_OCTAL:
3065                         return (*((int *)ptr1) == *((int *)ptr2));
3066
3067                 case P_CHAR:
3068                         return (*((char *)ptr1) == *((char *)ptr2));
3069                 
3070                 case P_LIST:
3071                         return str_list_compare(*(char ***)ptr1, *(char ***)ptr2);
3072
3073                 case P_GSTRING:
3074                 case P_UGSTRING:
3075                 {
3076                         char *p1 = (char *)ptr1, *p2 = (char *)ptr2;
3077                         if (p1 && !*p1)
3078                                 p1 = NULL;
3079                         if (p2 && !*p2)
3080                                 p2 = NULL;
3081                         return (p1 == p2 || strequal(p1, p2));
3082                 }
3083                 case P_STRING:
3084                 case P_USTRING:
3085                 {
3086                         char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
3087                         if (p1 && !*p1)
3088                                 p1 = NULL;
3089                         if (p2 && !*p2)
3090                                 p2 = NULL;
3091                         return (p1 == p2 || strequal(p1, p2));
3092                 }
3093                 case P_SEP:
3094                         break;
3095         }
3096         return (False);
3097 }
3098
3099 /***************************************************************************
3100  Initialize any local varients in the sDefault table.
3101 ***************************************************************************/
3102
3103 void init_locals(void)
3104 {
3105         /* None as yet. */
3106 }
3107
3108 /***************************************************************************
3109 Process a new section (service). At this stage all sections are services.
3110 Later we'll have special sections that permit server parameters to be set.
3111 Returns True on success, False on failure. 
3112 ***************************************************************************/
3113 static BOOL do_section(char *pszSectionName)
3114 {
3115         BOOL bRetval;
3116         BOOL isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
3117                          (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
3118         bRetval = False;
3119
3120         /* if we were in a global section then do the local inits */
3121         if (bInGlobalSection && !isglobal)
3122                 init_locals();
3123
3124         /* if we've just struck a global section, note the fact. */
3125         bInGlobalSection = isglobal;
3126
3127         /* check for multiple global sections */
3128         if (bInGlobalSection)
3129         {
3130                 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
3131                 return (True);
3132         }
3133
3134         if (!bInGlobalSection && bGlobalOnly)
3135                 return (True);
3136
3137         /* if we have a current service, tidy it up before moving on */
3138         bRetval = True;
3139
3140         if (iServiceIndex >= 0)
3141                 bRetval = service_ok(iServiceIndex);
3142
3143         /* if all is still well, move to the next record in the services array */
3144         if (bRetval)
3145         {
3146                 /* We put this here to avoid an odd message order if messages are */
3147                 /* issued by the post-processing of a previous section. */
3148                 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
3149
3150                 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
3151                     < 0)
3152                 {
3153                         DEBUG(0, ("Failed to add a new service\n"));
3154                         return (False);
3155                 }
3156         }
3157
3158         return (bRetval);
3159 }
3160
3161
3162 /***************************************************************************
3163 determine if a partcular base parameter is currentl set to the default value.
3164 ***************************************************************************/
3165 static BOOL is_default(int i)
3166 {
3167         if (!defaults_saved)
3168                 return False;
3169         switch (parm_table[i].type)
3170         {
3171                 case P_LIST:
3172                         return str_list_compare (parm_table[i].def.lvalue, 
3173                                                 *(char ***)parm_table[i].ptr);
3174                 case P_STRING:
3175                 case P_USTRING:
3176                         return strequal(parm_table[i].def.svalue,
3177                                         *(char **)parm_table[i].ptr);
3178                 case P_GSTRING:
3179                 case P_UGSTRING:
3180                         return strequal(parm_table[i].def.svalue,
3181                                         (char *)parm_table[i].ptr);
3182                 case P_BOOL:
3183                 case P_BOOLREV:
3184                         return parm_table[i].def.bvalue ==
3185                                 *(BOOL *)parm_table[i].ptr;
3186                 case P_CHAR:
3187                         return parm_table[i].def.cvalue ==
3188                                 *(char *)parm_table[i].ptr;
3189                 case P_INTEGER:
3190                 case P_OCTAL:
3191                 case P_ENUM:
3192                         return parm_table[i].def.ivalue ==
3193                                 *(int *)parm_table[i].ptr;
3194                 case P_SEP:
3195                         break;
3196         }
3197         return False;
3198 }
3199
3200
3201 /***************************************************************************
3202 Display the contents of the global structure.
3203 ***************************************************************************/
3204 static void dump_globals(FILE *f)
3205 {
3206         int i;
3207         param_opt_struct *data;
3208         char *s;
3209         
3210         fprintf(f, "# Global parameters\n[global]\n");
3211
3212         for (i = 0; parm_table[i].label; i++)
3213                 if (parm_table[i].class == P_GLOBAL &&
3214                     parm_table[i].ptr &&
3215                     (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
3216                 {
3217                         if (defaults_saved && is_default(i))
3218                                 continue;
3219                         fprintf(f, "\t%s = ", parm_table[i].label);
3220                         print_parameter(&parm_table[i], parm_table[i].ptr, f);
3221                         fprintf(f, "\n");
3222                 }
3223         if (param_opt != NULL) {
3224                 data = param_opt;
3225                 while(data) {
3226                     if (((s=strstr(data->key, "global")) == data->key) &&
3227                         (*(s+strlen("global")) == ':')) {
3228                             fprintf(f, "\t%s = %s\n", s+strlen("global")+1, data->value);
3229                     }
3230                     data = data->next;
3231                 }
3232         }
3233
3234 }
3235
3236 /***************************************************************************
3237 return True if a local parameter is currently set to the global default
3238 ***************************************************************************/
3239 BOOL lp_is_default(int snum, struct parm_struct *parm)
3240 {
3241         int pdiff = PTR_DIFF(parm->ptr, &sDefault);
3242
3243         return equal_parameter(parm->type,
3244                                ((char *)ServicePtrs[snum]) + pdiff,
3245                                ((char *)&sDefault) + pdiff);
3246 }
3247
3248 /***************************************************************************
3249 Display the contents of a single services record.
3250 ***************************************************************************/
3251 static void dump_a_service(service * pService, FILE * f)
3252 {
3253         int i;
3254         param_opt_struct *data;
3255         char *s, *sn;
3256         
3257         if (pService != &sDefault)
3258                 fprintf(f, "\n[%s]\n", pService->szService);
3259
3260         for (i = 0; parm_table[i].label; i++)
3261                 if (parm_table[i].class == P_LOCAL &&
3262                     parm_table[i].ptr &&
3263                     (*parm_table[i].label != '-') &&
3264                     (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
3265                 {
3266                         int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
3267
3268                         if (pService == &sDefault)
3269                         {
3270                                 if (defaults_saved && is_default(i))
3271                                         continue;
3272                         }
3273                         else
3274                         {
3275                                 if (equal_parameter(parm_table[i].type,
3276                                                     ((char *)pService) +
3277                                                     pdiff,
3278                                                     ((char *)&sDefault) +
3279                                                     pdiff))
3280                                         continue;
3281                         }
3282
3283                         fprintf(f, "\t%s = ", parm_table[i].label);
3284                         print_parameter(&parm_table[i],
3285                                         ((char *)pService) + pdiff, f);
3286                         fprintf(f, "\n");
3287                 }
3288         if (param_opt != NULL) {
3289                 data = param_opt;
3290                 sn = (pService == &sDefault) ? "global" : pService->szService;
3291                 while(data) {
3292                     if (((s=strstr(data->key, sn)) == data->key) &&
3293                         (*(s+strlen(sn)) == ':')) {
3294                             fprintf(f, "\t%s = %s\n", s+strlen(sn)+1, data->value);
3295                     }
3296                     data = data->next;
3297                 }
3298         }
3299 }
3300
3301
3302 /***************************************************************************
3303 return info about the next service  in a service. snum==-1 gives the globals
3304
3305 return NULL when out of parameters
3306 ***************************************************************************/
3307 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
3308 {
3309         if (snum == -1)
3310         {
3311                 /* do the globals */
3312                 for (; parm_table[*i].label; (*i)++)
3313                 {
3314                         if (parm_table[*i].class == P_SEPARATOR)
3315                                 return &parm_table[(*i)++];
3316
3317                         if (!parm_table[*i].ptr
3318                             || (*parm_table[*i].label == '-'))
3319                                 continue;
3320
3321                         if ((*i) > 0
3322                             && (parm_table[*i].ptr ==
3323                                 parm_table[(*i) - 1].ptr))
3324                                 continue;
3325
3326                         return &parm_table[(*i)++];
3327                 }
3328         }
3329         else
3330         {
3331                 service *pService = ServicePtrs[snum];
3332
3333                 for (; parm_table[*i].label; (*i)++)
3334                 {
3335                         if (parm_table[*i].class == P_SEPARATOR)
3336                                 return &parm_table[(*i)++];
3337
3338                         if (parm_table[*i].class == P_LOCAL &&
3339                             parm_table[*i].ptr &&
3340                             (*parm_table[*i].label != '-') &&
3341                             ((*i) == 0 ||
3342                              (parm_table[*i].ptr !=
3343                               parm_table[(*i) - 1].ptr)))
3344                         {
3345                                 int pdiff =
3346                                         PTR_DIFF(parm_table[*i].ptr,
3347                                                  &sDefault);
3348
3349                                 if (allparameters ||
3350                                     !equal_parameter(parm_table[*i].type,
3351                                                      ((char *)pService) +
3352                                                      pdiff,
3353                                                      ((char *)&sDefault) +
3354                                                      pdiff))
3355                                 {
3356                                         return &parm_table[(*i)++];
3357                                 }
3358                         }
3359                 }
3360         }
3361
3362         return NULL;
3363 }
3364
3365
3366 #if 0
3367 /***************************************************************************
3368 Display the contents of a single copy structure.
3369 ***************************************************************************/
3370 static void dump_copy_map(BOOL *pcopymap)
3371 {
3372         int i;
3373         if (!pcopymap)
3374                 return;
3375
3376         printf("\n\tNon-Copied parameters:\n");
3377
3378         for (i = 0; parm_table[i].label; i++)
3379                 if (parm_table[i].class == P_LOCAL &&
3380                     parm_table[i].ptr && !pcopymap[i] &&
3381                     (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
3382                 {
3383                         printf("\t\t%s\n", parm_table[i].label);
3384                 }
3385 }
3386 #endif
3387
3388 /***************************************************************************
3389 Return TRUE if the passed service number is within range.
3390 ***************************************************************************/
3391
3392 BOOL lp_snum_ok(int iService)
3393 {
3394         return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
3395 }
3396
3397 /***************************************************************************
3398  Auto-load some home services.
3399 ***************************************************************************/
3400
3401 static void lp_add_auto_services(char *str)
3402 {
3403         char *s;
3404         char *p;
3405         int homes;
3406
3407         if (!str)
3408                 return;
3409
3410         s = strdup(str);
3411         if (!s)
3412                 return;
3413
3414         homes = lp_servicenumber(HOMES_NAME);
3415
3416         for (p = strtok(s, LIST_SEP); p; p = strtok(NULL, LIST_SEP)) {
3417                 char *home = get_user_home_dir(p);
3418
3419                 if (lp_servicenumber(p) >= 0)
3420                         continue;
3421
3422                 if (home && homes >= 0)
3423                         lp_add_home(p, homes, p, home);
3424         }
3425         SAFE_FREE(s);
3426 }
3427
3428 /***************************************************************************
3429  Auto-load one printer.
3430 ***************************************************************************/
3431
3432 void lp_add_one_printer(char *name, char *comment)
3433 {
3434         int printers = lp_servicenumber(PRINTERS_NAME);
3435         int i;
3436
3437         if (lp_servicenumber(name) < 0) {
3438                 lp_add_printer(name, printers);
3439                 if ((i = lp_servicenumber(name)) >= 0) {
3440                         string_set(&ServicePtrs[i]->comment, comment);
3441                         ServicePtrs[i]->autoloaded = True;
3442                 }
3443         }
3444 }
3445
3446 /* Announce ourselves as a print server */
3447
3448 void update_server_announce_as_printserver(void)
3449 {
3450         default_server_announce |= SV_TYPE_PRINTQ_SERVER;       
3451 }
3452
3453 /***************************************************************************
3454  Have we loaded a services file yet?
3455 ***************************************************************************/
3456
3457 BOOL lp_loaded(void)
3458 {
3459         return (bLoaded);
3460 }
3461
3462 /***************************************************************************
3463  Unload unused services.
3464 ***************************************************************************/
3465
3466 void lp_killunused(BOOL (*snumused) (int))
3467 {
3468         int i;
3469         for (i = 0; i < iNumServices; i++) {
3470                 if (!VALID(i))
3471                         continue;
3472
3473                 if (!snumused || !snumused(i)) {
3474                         ServicePtrs[i]->valid = False;
3475                         free_service(ServicePtrs[i]);
3476                 }
3477         }
3478 }
3479
3480 /***************************************************************************
3481  Unload a service.
3482 ***************************************************************************/
3483
3484 void lp_killservice(int iServiceIn)
3485 {
3486         if (VALID(iServiceIn)) {
3487                 ServicePtrs[iServiceIn]->valid = False;
3488                 free_service(ServicePtrs[iServiceIn]);
3489         }
3490 }
3491
3492 /***************************************************************************
3493  Save the curent values of all global and sDefault parameters into the 
3494  defaults union. This allows swat and testparm to show only the
3495  changed (ie. non-default) parameters.
3496 ***************************************************************************/
3497
3498 static void lp_save_defaults(void)
3499 {
3500         int i;
3501         for (i = 0; parm_table[i].label; i++) {
3502                 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
3503                         continue;
3504                 switch (parm_table[i].type) {
3505                         case P_LIST:
3506                                 str_list_copy(&(parm_table[i].def.lvalue),
3507                                             *(char ***)parm_table[i].ptr);
3508                                 break;
3509                         case P_STRING:
3510                         case P_USTRING:
3511                                 if (parm_table[i].ptr) {
3512                                         parm_table[i].def.svalue = strdup(*(char **)parm_table[i].ptr);
3513                                 } else {
3514                                         parm_table[i].def.svalue = NULL;
3515                                 }
3516                                 break;
3517                         case P_GSTRING:
3518                         case P_UGSTRING:
3519                                 if (parm_table[i].ptr) {
3520                                         parm_table[i].def.svalue = strdup((char *)parm_table[i].ptr);
3521                                 } else {
3522                                         parm_table[i].def.svalue = NULL;
3523                                 }
3524                                 break;
3525                         case P_BOOL:
3526                         case P_BOOLREV:
3527                                 parm_table[i].def.bvalue =
3528                                         *(BOOL *)parm_table[i].ptr;
3529                                 break;
3530                         case P_CHAR:
3531                                 parm_table[i].def.cvalue =
3532                                         *(char *)parm_table[i].ptr;
3533                                 break;
3534                         case P_INTEGER:
3535                         case P_OCTAL:
3536                         case P_ENUM:
3537                                 parm_table[i].def.ivalue =
3538                                         *(int *)parm_table[i].ptr;
3539                                 break;
3540                         case P_SEP:
3541                                 break;
3542                 }
3543         }
3544         defaults_saved = True;
3545 }
3546
3547 /*******************************************************************
3548  Set the server type we will announce as via nmbd.
3549 ********************************************************************/
3550
3551 static void set_server_role(void)
3552 {
3553         server_role = ROLE_STANDALONE;
3554
3555         switch (lp_security()) {
3556                 case SEC_SHARE:
3557                         if (lp_domain_logons())
3558                                 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
3559                         break;
3560                 case SEC_SERVER:
3561                 case SEC_DOMAIN:
3562                 case SEC_ADS:
3563                         if (lp_domain_logons()) {
3564                                 server_role = ROLE_DOMAIN_PDC;
3565                                 break;
3566                         }
3567                         server_role = ROLE_DOMAIN_MEMBER;
3568                         break;
3569                 case SEC_USER:
3570                         if (lp_domain_logons()) {
3571
3572                                 if (Globals.bDomainMaster) /* auto or yes */ 
3573                                         server_role = ROLE_DOMAIN_PDC;
3574                                 else
3575                                         server_role = ROLE_DOMAIN_BDC;
3576                         }
3577                         break;
3578                 default:
3579                         DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
3580                         break;
3581         }
3582
3583         DEBUG(10, ("set_server_role: role = "));
3584
3585         switch(server_role) {
3586         case ROLE_STANDALONE:
3587                 DEBUGADD(10, ("ROLE_STANDALONE\n"));
3588                 break;
3589         case ROLE_DOMAIN_MEMBER:
3590                 DEBUGADD(10, ("ROLE_DOMAIN_MEMBER\n"));
3591                 break;
3592         case ROLE_DOMAIN_BDC:
3593                 DEBUGADD(10, ("ROLE_DOMAIN_BDC\n"));
3594                 break;
3595         case ROLE_DOMAIN_PDC:
3596                 DEBUGADD(10, ("ROLE_DOMAIN_PDC\n"));
3597                 break;
3598         }
3599 }
3600
3601
3602
3603 /***************************************************************************
3604 Load the services array from the services file. Return True on success, 
3605 False on failure.
3606 ***************************************************************************/
3607 BOOL lp_load(const char *pszFname, BOOL global_only, BOOL save_defaults,
3608              BOOL add_ipc)
3609 {
3610         pstring n2;
3611         BOOL bRetval;
3612         param_opt_struct *data, *pdata;
3613
3614         pstrcpy(n2, pszFname);
3615         standard_sub_basic(current_user_info.smb_name, n2,sizeof(n2));
3616
3617         add_to_file_list(pszFname, n2);
3618
3619         bRetval = False;
3620
3621         DEBUG(3, ("lp_load: refreshing parameters\n"));
3622         
3623         bInGlobalSection = True;
3624         bGlobalOnly = global_only;
3625
3626         init_globals();
3627         debug_init();
3628
3629         if (save_defaults)
3630         {
3631                 init_locals();
3632                 lp_save_defaults();
3633         }
3634
3635         if (param_opt != NULL) {
3636                 data = param_opt;
3637                 while (data) {
3638                         SAFE_FREE(data->key);
3639                         SAFE_FREE(data->value);
3640                         pdata = data->next;
3641                         SAFE_FREE(data);
3642                         data = pdata;
3643                 }
3644                 param_opt = NULL;
3645         }
3646         
3647         /* We get sections first, so have to start 'behind' to make up */
3648         iServiceIndex = -1;
3649         bRetval = pm_process(n2, do_section, do_parameter);
3650
3651         /* finish up the last section */
3652         DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
3653         if (bRetval)
3654                 if (iServiceIndex >= 0)
3655                         bRetval = service_ok(iServiceIndex);
3656
3657         lp_add_auto_services(lp_auto_services());
3658
3659         if (add_ipc) {
3660                 lp_add_ipc("IPC$", True);
3661                 lp_add_ipc("ADMIN$", False);
3662         }
3663
3664         set_server_role();
3665         set_default_server_announce_type();
3666
3667         bLoaded = True;
3668
3669         /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
3670         /* if bWINSsupport is true and we are in the client            */
3671         if (in_client && Globals.bWINSsupport) {
3672                 lp_do_parameter(-1, "wins server", "127.0.0.1");
3673         }
3674
3675         init_iconv();
3676
3677         return (bRetval);
3678 }
3679
3680 /***************************************************************************
3681 reset the max number of services
3682 ***************************************************************************/
3683 void lp_resetnumservices(void)
3684 {
3685         iNumServices = 0;
3686 }
3687
3688 /***************************************************************************
3689 return the max number of services
3690 ***************************************************************************/
3691 int lp_numservices(void)
3692 {
3693         return (iNumServices);
3694 }
3695
3696 /***************************************************************************
3697 Display the contents of the services array in human-readable form.
3698 ***************************************************************************/
3699 void lp_dump(FILE *f, BOOL show_defaults, int maxtoprint)
3700 {
3701         int iService;
3702
3703         if (show_defaults)
3704         {
3705                 defaults_saved = False;
3706         }
3707
3708         dump_globals(f);
3709
3710         dump_a_service(&sDefault, f);
3711
3712         for (iService = 0; iService < maxtoprint; iService++)
3713                 lp_dump_one(f, show_defaults, iService);
3714 }
3715
3716 /***************************************************************************
3717 Display the contents of one service in human-readable form.
3718 ***************************************************************************/
3719 void lp_dump_one(FILE * f, BOOL show_defaults, int snum)
3720 {
3721         if (VALID(snum))
3722         {
3723                 if (ServicePtrs[snum]->szService[0] == '\0')
3724                         return;
3725                 dump_a_service(ServicePtrs[snum], f);
3726         }
3727 }
3728
3729
3730 /***************************************************************************
3731 Return the number of the service with the given name, or -1 if it doesn't
3732 exist. Note that this is a DIFFERENT ANIMAL from the internal function
3733 getservicebyname()! This works ONLY if all services have been loaded, and
3734 does not copy the found service.
3735 ***************************************************************************/
3736 int lp_servicenumber(const char *pszServiceName)
3737 {
3738         int iService;
3739         fstring serviceName;
3740  
3741  
3742         for (iService = iNumServices - 1; iService >= 0; iService--)
3743         {
3744                 if (VALID(iService) && ServicePtrs[iService]->szService)
3745                 {
3746                         /*
3747                          * The substitution here is used to support %U is
3748                          * service names
3749                          */
3750                         fstrcpy(serviceName, ServicePtrs[iService]->szService);
3751                         standard_sub_basic(current_user_info.smb_name, serviceName,sizeof(serviceName));
3752                         if (strequal(serviceName, pszServiceName))
3753                                 break;
3754                 }
3755         }
3756
3757         if (iService < 0)
3758                 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
3759
3760         return (iService);
3761 }
3762
3763 /*******************************************************************
3764  A useful volume label function. 
3765 ********************************************************************/
3766
3767 char *volume_label(int snum)
3768 {
3769         char *ret = lp_volume(snum);
3770         if (!*ret)
3771                 return lp_servicename(snum);
3772         return (ret);
3773 }
3774
3775
3776 /*******************************************************************
3777  Set the server type we will announce as via nmbd.
3778 ********************************************************************/
3779 static void set_default_server_announce_type(void)
3780 {
3781         default_server_announce = 0;
3782         default_server_announce |= SV_TYPE_WORKSTATION;
3783         default_server_announce |= SV_TYPE_SERVER;
3784         default_server_announce |= SV_TYPE_SERVER_UNIX;
3785
3786         switch (lp_announce_as())
3787         {
3788                 case ANNOUNCE_AS_NT_SERVER:
3789                 {
3790                         default_server_announce |= SV_TYPE_SERVER_NT;
3791                         /* fall through... */
3792                 }
3793                 case ANNOUNCE_AS_NT_WORKSTATION:
3794                 {
3795                         default_server_announce |= SV_TYPE_NT;
3796                         break;
3797                 }
3798                 case ANNOUNCE_AS_WIN95:
3799                 {
3800                         default_server_announce |= SV_TYPE_WIN95_PLUS;
3801                         break;
3802                 }
3803                 case ANNOUNCE_AS_WFW:
3804                 {
3805                         default_server_announce |= SV_TYPE_WFW;
3806                         break;
3807                 }
3808                 default:
3809                 {
3810                         break;
3811                 }
3812         }
3813
3814         switch (lp_server_role())
3815         {
3816                 case ROLE_DOMAIN_MEMBER:
3817                 {
3818                         default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
3819                         break;
3820                 }
3821                 case ROLE_DOMAIN_PDC:
3822                 {
3823                         default_server_announce |= SV_TYPE_DOMAIN_CTRL;
3824                         break;
3825                 }
3826                 case ROLE_DOMAIN_BDC:
3827                 {
3828                         default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
3829                         break;
3830                 }
3831                 case ROLE_STANDALONE:
3832                 default:
3833                 {
3834                         break;
3835                 }
3836         }
3837
3838         if (lp_time_server())
3839         {
3840                 default_server_announce |= SV_TYPE_TIME_SOURCE;
3841         }
3842
3843         if (lp_host_msdfs())
3844         {
3845                 default_server_announce |= SV_TYPE_DFS_SERVER;
3846         }
3847 }
3848
3849 /***********************************************************
3850  returns role of Samba server
3851 ************************************************************/
3852
3853 int lp_server_role(void)
3854 {
3855         return server_role;
3856 }
3857
3858 /***********************************************************
3859  If we are PDC then prefer us as DMB
3860 ************************************************************/
3861
3862 BOOL lp_domain_master(void)
3863 {
3864         if (Globals.bDomainMaster == Auto)
3865         {
3866                 return (lp_server_role() == ROLE_DOMAIN_PDC);
3867         }
3868
3869         return Globals.bDomainMaster;
3870 }
3871
3872 /***********************************************************
3873  If we are DMB then prefer us as LMB
3874 ************************************************************/
3875
3876 BOOL lp_preferred_master(void)
3877 {
3878         if (Globals.bPreferredMaster == Auto)
3879         {
3880                 return (lp_local_master() && lp_domain_master());
3881         }
3882
3883         return Globals.bPreferredMaster;
3884 }
3885
3886
3887
3888 /*******************************************************************
3889 remove a service
3890 ********************************************************************/
3891 void lp_remove_service(int snum)
3892 {
3893         ServicePtrs[snum]->valid = False;
3894 }
3895
3896 /*******************************************************************
3897 copy a service. 
3898 ********************************************************************/
3899 void lp_copy_service(int snum, char *new_name)
3900 {
3901         char *oldname = lp_servicename(snum);
3902         do_section(new_name);
3903         if (snum >= 0)
3904         {
3905                 snum = lp_servicenumber(new_name);
3906                 if (snum >= 0)
3907                         lp_do_parameter(snum, "copy", oldname);
3908         }
3909 }
3910
3911
3912 /*******************************************************************
3913  Get the default server type we will announce as via nmbd.
3914 ********************************************************************/
3915 int lp_default_server_announce(void)
3916 {
3917         return default_server_announce;
3918 }
3919
3920 /*******************************************************************
3921  Split the announce version into major and minor numbers.
3922 ********************************************************************/
3923 int lp_major_announce_version(void)
3924 {
3925         static BOOL got_major = False;
3926         static int major_version = DEFAULT_MAJOR_VERSION;
3927         char *vers;
3928         char *p;
3929
3930         if (got_major)
3931                 return major_version;
3932
3933         got_major = True;
3934         if ((vers = lp_announce_version()) == NULL)
3935                 return major_version;
3936
3937         if ((p = strchr_m(vers, '.')) == 0)
3938                 return major_version;
3939
3940         *p = '\0';
3941         major_version = atoi(vers);
3942         return major_version;
3943 }
3944
3945 int lp_minor_announce_version(void)
3946 {
3947         static BOOL got_minor = False;
3948         static int minor_version = DEFAULT_MINOR_VERSION;
3949         char *vers;
3950         char *p;
3951
3952         if (got_minor)
3953                 return minor_version;
3954
3955         got_minor = True;
3956         if ((vers = lp_announce_version()) == NULL)
3957                 return minor_version;
3958
3959         if ((p = strchr_m(vers, '.')) == 0)
3960                 return minor_version;
3961
3962         p++;
3963         minor_version = atoi(p);
3964         return minor_version;
3965 }
3966
3967 /***********************************************************
3968  Set the global name resolution order (used in smbclient).
3969 ************************************************************/
3970
3971 void lp_set_name_resolve_order(char *new_order)
3972 {
3973         Globals.szNameResolveOrder = new_order;
3974 }
3975
3976 const char *lp_printername(int snum)
3977 {
3978         const char *ret = _lp_printername(snum);
3979         if (ret == NULL || (ret != NULL && *ret == '\0'))
3980                 ret = lp_const_servicename(snum);
3981
3982         return ret;
3983 }
3984
3985
3986 /****************************************************************
3987  Compatibility fn. for 2.2.2 code.....
3988 *****************************************************************/
3989
3990 void get_private_directory(pstring privdir)
3991 {
3992         pstrcpy (privdir, lp_private_dir());
3993 }
3994
3995
3996 /****************************************************************
3997  Is netbios alias or name
3998 *****************************************************************/
3999
4000 BOOL is_netbios_alias_or_name(const char *name)
4001 {
4002         char **netbios_aliases = lp_netbios_aliases();
4003         
4004         if (StrCaseCmp(name, global_myname) == 0) {
4005                 return True;
4006         }
4007
4008         for (netbios_aliases = lp_netbios_aliases();
4009              netbios_aliases && *netbios_aliases;
4010              netbios_aliases++) {
4011                 if (StrCaseCmp(name, *netbios_aliases) == 0) {
4012                         return True;
4013                 }
4014         }
4015         
4016         return False;
4017 }
4018
4019 /***********************************************************
4020  Allow daemons such as winbindd to fix their logfile name.
4021 ************************************************************/
4022
4023 void lp_set_logfile(const char *name)
4024 {
4025         extern pstring debugf;
4026         string_set(&Globals.szLogFile, name);
4027         pstrcpy(debugf, name);
4028 }
4029
4030 /*******************************************************************
4031  Return the NetBIOS called name.
4032 ********************************************************************/
4033
4034 const char *get_called_name(void)
4035 {
4036         extern fstring local_machine;
4037         static fstring called_name;
4038
4039         if (! *local_machine)
4040                 return global_myname;
4041
4042         /*
4043          * Windows NT/2k uses "*SMBSERVER" and XP uses "*SMBSERV"
4044          * arrggg!!! but we've already rewritten the client's
4045          * netbios name at this point...
4046          */
4047
4048         if (*local_machine) {
4049                 if (!StrCaseCmp(local_machine, "_SMBSERVER") || !StrCaseCmp(local_machine, "_SMBSERV")) {
4050                         fstrcpy(called_name, get_my_primary_ip());
4051                         DEBUG(8,("get_called_name: assuming that client used IP address [%s] as called name.\n",
4052                                 called_name));
4053                         return called_name;
4054                 }
4055         }
4056
4057         return local_machine;
4058 }
4059
4060 /*******************************************************************
4061  Return the max print jobs per queue.
4062 ********************************************************************/
4063
4064 int lp_maxprintjobs(int snum)
4065 {
4066         int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
4067         if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
4068                 maxjobs = PRINT_MAX_JOBID - 1;
4069
4070         return maxjobs;
4071 }