r7024: reverting mistaken commit
[Samba/gbeck.git] / source / param / loadparm.c
blobac6dbb4d4a0d57b0b47f5fd57da91a03b5606149
1 /*
2 Unix SMB/CIFS implementation.
3 Parameter loading functions
4 Copyright (C) Karl Auer 1993-1998
6 Largely re-written by Andrew Tridgell, September 1994
8 Copyright (C) Simo Sorce 2001
9 Copyright (C) Alexander Bokovoy 2002
10 Copyright (C) Stefan (metze) Metzmacher 2002
11 Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 * Load parameters.
31 * This module provides suitable callback functions for the params
32 * module. It builds the internal table of service details which is
33 * then used by the rest of the server.
35 * To add a parameter:
37 * 1) add it to the global or service structure definition
38 * 2) add it to the parm_table
39 * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
40 * 4) If it's a global then initialise it in init_globals. If a local
41 * (ie. service) parameter then initialise it in the sDefault structure
44 * Notes:
45 * The configuration file is processed sequentially for speed. It is NOT
46 * accessed randomly as happens in 'real' Windows. For this reason, there
47 * is a fair bit of sequence-dependent code here - ie., code which assumes
48 * that certain things happen before others. In particular, the code which
49 * happens at the boundary between sections is delicately poised, so be
50 * careful!
54 #include "includes.h"
56 BOOL in_client = False; /* Not in the client by default */
57 BOOL bLoaded = False;
59 extern userdom_struct current_user_info;
60 extern pstring user_socket_options;
61 extern enum protocol_types Protocol;
63 #ifndef GLOBAL_NAME
64 #define GLOBAL_NAME "global"
65 #endif
67 #ifndef PRINTERS_NAME
68 #define PRINTERS_NAME "printers"
69 #endif
71 #ifndef HOMES_NAME
72 #define HOMES_NAME "homes"
73 #endif
75 /* some helpful bits */
76 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && ServicePtrs[(i)]->valid)
77 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
79 int keepalive = DEFAULT_KEEPALIVE;
80 BOOL use_getwd_cache = True;
82 extern int extra_time_offset;
84 static BOOL defaults_saved = False;
86 typedef struct _param_opt_struct param_opt_struct;
87 struct _param_opt_struct {
88 param_opt_struct *prev, *next;
89 char *key;
90 char *value;
91 char **list;
94 /*
95 * This structure describes global (ie., server-wide) parameters.
97 typedef struct
99 char *smb_ports;
100 char *dos_charset;
101 char *unix_charset;
102 char *display_charset;
103 char *szPrintcapname;
104 char *szEnumPortsCommand;
105 char *szAddPrinterCommand;
106 char *szDeletePrinterCommand;
107 char *szOs2DriverMap;
108 char *szLockDir;
109 char *szPidDir;
110 char *szRootdir;
111 char *szDefaultService;
112 char *szDfree;
113 char *szGetQuota;
114 char *szSetQuota;
115 char *szMsgCommand;
116 char *szHostsEquiv;
117 char *szServerString;
118 char *szAutoServices;
119 char *szPasswdProgram;
120 char *szPasswdChat;
121 char *szLogFile;
122 char *szConfigFile;
123 char *szSMBPasswdFile;
124 char *szPrivateDir;
125 char **szPassdbBackend;
126 char **szPreloadModules;
127 char *szPasswordServer;
128 char *szSocketOptions;
129 char *szRealm;
130 char *szAfsUsernameMap;
131 int iAfsTokenLifetime;
132 char *szLogNtTokenCommand;
133 char *szUsernameMap;
134 char *szLogonScript;
135 char *szLogonPath;
136 char *szLogonDrive;
137 char *szLogonHome;
138 char **szWINSservers;
139 char **szInterfaces;
140 char *szRemoteAnnounce;
141 char *szRemoteBrowseSync;
142 char *szSocketAddress;
143 char *szNISHomeMapName;
144 char *szAnnounceVersion; /* This is initialised in init_globals */
145 char *szWorkgroup;
146 char *szNetbiosName;
147 char **szNetbiosAliases;
148 char *szNetbiosScope;
149 char *szDomainOtherSIDs;
150 char *szNameResolveOrder;
151 char *szPanicAction;
152 char *szAddUserScript;
153 char *szDelUserScript;
154 char *szAddGroupScript;
155 char *szDelGroupScript;
156 char *szAddUserToGroupScript;
157 char *szDelUserFromGroupScript;
158 char *szSetPrimaryGroupScript;
159 char *szAddMachineScript;
160 char *szShutdownScript;
161 char *szAbortShutdownScript;
162 char *szCheckPasswordScript;
163 char *szWINSHook;
164 char *szWINSPartners;
165 char *szUtmpDir;
166 char *szWtmpDir;
167 BOOL bUtmp;
168 char *szIdmapUID;
169 char *szIdmapGID;
170 BOOL bEnableRidAlgorithm;
171 int AlgorithmicRidBase;
172 char *szTemplatePrimaryGroup;
173 char *szTemplateHomedir;
174 char *szTemplateShell;
175 char *szWinbindSeparator;
176 BOOL bWinbindEnableLocalAccounts;
177 BOOL bWinbindEnumUsers;
178 BOOL bWinbindEnumGroups;
179 BOOL bWinbindUseDefaultDomain;
180 BOOL bWinbindTrustedDomainsOnly;
181 BOOL bWinbindNestedGroups;
182 char *szWinbindBackend;
183 char **szIdmapBackend;
184 char *szAddShareCommand;
185 char *szChangeShareCommand;
186 char *szDeleteShareCommand;
187 char *szEventLogOpenCommand;
188 char *szEventLogReadCommand;
189 char *szEventLogClearCommand;
190 char *szEventLogNumRecordsCommand;
191 char *szEventLogOldestRecordCommand;
192 char *szEventLogCloseCommand;
193 char **szEventLogs;
194 char *szGuestaccount;
195 char *szManglingMethod;
196 char **szServicesList;
197 int mangle_prefix;
198 int max_log_size;
199 char *szLogLevel;
200 int max_xmit;
201 int max_mux;
202 int max_open_files;
203 int pwordlevel;
204 int unamelevel;
205 int deadtime;
206 int maxprotocol;
207 int minprotocol;
208 int security;
209 char **AuthMethods;
210 BOOL paranoid_server_security;
211 int maxdisksize;
212 int lpqcachetime;
213 int iMaxSmbdProcesses;
214 BOOL bDisableSpoolss;
215 int syslog;
216 int os_level;
217 int enhanced_browsing;
218 int max_ttl;
219 int max_wins_ttl;
220 int min_wins_ttl;
221 int lm_announce;
222 int lm_interval;
223 int announce_as; /* This is initialised in init_globals */
224 int machine_password_timeout;
225 int change_notify_timeout;
226 int map_to_guest;
227 int min_passwd_length;
228 int oplock_break_wait_time;
229 int winbind_cache_time;
230 int iLockSpinCount;
231 int iLockSpinTime;
232 char *szLdapMachineSuffix;
233 char *szLdapUserSuffix;
234 char *szLdapIdmapSuffix;
235 char *szLdapGroupSuffix;
236 #ifdef WITH_LDAP_SAMCONFIG
237 int ldap_port;
238 char *szLdapServer;
239 #endif
240 int ldap_ssl;
241 char *szLdapSuffix;
242 char *szLdapFilter;
243 char *szLdapAdminDn;
244 char *szAclCompat;
245 char *szCupsServer;
246 int ldap_passwd_sync;
247 int ldap_replication_sleep;
248 int ldap_timeout; /* This is initialised in init_globals */
249 int ldap_page_size;
250 BOOL ldap_delete_dn;
251 BOOL bMsAddPrinterWizard;
252 BOOL bDNSproxy;
253 BOOL bWINSsupport;
254 BOOL bWINSproxy;
255 BOOL bLocalMaster;
256 BOOL bPreferredMaster;
257 BOOL bDomainMaster;
258 BOOL bDomainLogons;
259 BOOL bEncryptPasswords;
260 BOOL bUpdateEncrypt;
261 int clientSchannel;
262 int serverSchannel;
263 BOOL bNullPasswords;
264 BOOL bObeyPamRestrictions;
265 BOOL bLoadPrinters;
266 int PrintcapCacheTime;
267 BOOL bLargeReadwrite;
268 BOOL bReadRaw;
269 BOOL bWriteRaw;
270 BOOL bReadbmpx;
271 BOOL bSyslogOnly;
272 BOOL bBrowseList;
273 BOOL bNISHomeMap;
274 BOOL bTimeServer;
275 BOOL bBindInterfacesOnly;
276 BOOL bPamPasswordChange;
277 BOOL bUnixPasswdSync;
278 BOOL bPasswdChatDebug;
279 int iPasswdChatTimeout;
280 BOOL bTimestampLogs;
281 BOOL bNTSmbSupport;
282 BOOL bNTPipeSupport;
283 BOOL bNTStatusSupport;
284 BOOL bStatCache;
285 int iMaxStatCacheSize;
286 BOOL bKernelOplocks;
287 BOOL bAllowTrustedDomains;
288 BOOL bLanmanAuth;
289 BOOL bNTLMAuth;
290 BOOL bUseSpnego;
291 BOOL bClientLanManAuth;
292 BOOL bClientNTLMv2Auth;
293 BOOL bClientPlaintextAuth;
294 BOOL bClientUseSpnego;
295 BOOL bDebugHiresTimestamp;
296 BOOL bDebugPid;
297 BOOL bDebugUid;
298 BOOL bHostMSDfs;
299 BOOL bUseMmap;
300 BOOL bHostnameLookups;
301 BOOL bUnixExtensions;
302 BOOL bDisableNetbios;
303 BOOL bKernelChangeNotify;
304 BOOL bUseKerberosKeytab;
305 BOOL bDeferSharingViolations;
306 BOOL bEnablePrivileges;
307 BOOL bASUSupport;
308 int restrict_anonymous;
309 int name_cache_timeout;
310 int client_signing;
311 int server_signing;
312 param_opt_struct *param_opt;
314 global;
316 static global Globals;
319 * This structure describes a single service.
321 typedef struct
323 BOOL valid;
324 BOOL autoloaded;
325 char *szService;
326 char *szPath;
327 char *szUsername;
328 char **szInvalidUsers;
329 char **szValidUsers;
330 char **szAdminUsers;
331 char *szCopy;
332 char *szInclude;
333 char *szPreExec;
334 char *szPostExec;
335 char *szRootPreExec;
336 char *szRootPostExec;
337 char *szCupsOptions;
338 char *szPrintcommand;
339 char *szLpqcommand;
340 char *szLprmcommand;
341 char *szLppausecommand;
342 char *szLpresumecommand;
343 char *szQueuepausecommand;
344 char *szQueueresumecommand;
345 char *szPrintername;
346 char *szDontdescend;
347 char **szHostsallow;
348 char **szHostsdeny;
349 char *szMagicScript;
350 char *szMagicOutput;
351 char *szMangledMap;
352 char *szVetoFiles;
353 char *szHideFiles;
354 char *szVetoOplockFiles;
355 char *comment;
356 char *force_user;
357 char *force_group;
358 char **readlist;
359 char **writelist;
360 char **printer_admin;
361 char *volume;
362 char *fstype;
363 char **szVfsObjects;
364 char *szMSDfsProxy;
365 int iMinPrintSpace;
366 int iMaxPrintJobs;
367 int iMaxReportedPrintJobs;
368 int iWriteCacheSize;
369 int iCreate_mask;
370 int iCreate_force_mode;
371 int iSecurity_mask;
372 int iSecurity_force_mode;
373 int iDir_mask;
374 int iDir_force_mode;
375 int iDir_Security_mask;
376 int iDir_Security_force_mode;
377 int iMaxConnections;
378 int iDefaultCase;
379 int iPrinting;
380 int iOplockContentionLimit;
381 int iCSCPolicy;
382 int iBlock_size;
383 BOOL bPreexecClose;
384 BOOL bRootpreexecClose;
385 int iCaseSensitive;
386 BOOL bCasePreserve;
387 BOOL bShortCasePreserve;
388 BOOL bHideDotFiles;
389 BOOL bHideSpecialFiles;
390 BOOL bHideUnReadable;
391 BOOL bHideUnWriteableFiles;
392 BOOL bBrowseable;
393 BOOL bAvailable;
394 BOOL bRead_only;
395 BOOL bNo_set_dir;
396 BOOL bGuest_only;
397 BOOL bGuest_ok;
398 BOOL bPrint_ok;
399 BOOL bMap_system;
400 BOOL bMap_hidden;
401 BOOL bMap_archive;
402 BOOL bStoreDosAttributes;
403 BOOL bLocking;
404 int iStrictLocking;
405 BOOL bPosixLocking;
406 BOOL bShareModes;
407 BOOL bOpLocks;
408 BOOL bLevel2OpLocks;
409 BOOL bOnlyUser;
410 BOOL bMangledNames;
411 BOOL bWidelinks;
412 BOOL bSymlinks;
413 BOOL bSyncAlways;
414 BOOL bStrictAllocate;
415 BOOL bStrictSync;
416 char magic_char;
417 BOOL *copymap;
418 BOOL bDeleteReadonly;
419 BOOL bFakeOplocks;
420 BOOL bDeleteVetoFiles;
421 BOOL bDosFilemode;
422 BOOL bDosFiletimes;
423 BOOL bDosFiletimeResolution;
424 BOOL bFakeDirCreateTimes;
425 BOOL bBlockingLocks;
426 BOOL bInheritPerms;
427 BOOL bInheritACLS;
428 BOOL bInheritOwner;
429 BOOL bMSDfsRoot;
430 BOOL bUseClientDriver;
431 BOOL bDefaultDevmode;
432 BOOL bForcePrintername;
433 BOOL bNTAclSupport;
434 BOOL bForceUnknownAclUser;
435 BOOL bUseSendfile;
436 BOOL bProfileAcls;
437 BOOL bMap_acl_inherit;
438 BOOL bAfs_Share;
439 BOOL bEASupport;
440 BOOL bAclCheckPermissions;
441 int iallocation_roundup_size;
442 param_opt_struct *param_opt;
444 char dummy[3]; /* for alignment */
446 service;
449 /* This is a default service used to prime a services structure */
450 static service sDefault = {
451 True, /* valid */
452 False, /* not autoloaded */
453 NULL, /* szService */
454 NULL, /* szPath */
455 NULL, /* szUsername */
456 NULL, /* szInvalidUsers */
457 NULL, /* szValidUsers */
458 NULL, /* szAdminUsers */
459 NULL, /* szCopy */
460 NULL, /* szInclude */
461 NULL, /* szPreExec */
462 NULL, /* szPostExec */
463 NULL, /* szRootPreExec */
464 NULL, /* szRootPostExec */
465 NULL, /* szCupsOptions */
466 NULL, /* szPrintcommand */
467 NULL, /* szLpqcommand */
468 NULL, /* szLprmcommand */
469 NULL, /* szLppausecommand */
470 NULL, /* szLpresumecommand */
471 NULL, /* szQueuepausecommand */
472 NULL, /* szQueueresumecommand */
473 NULL, /* szPrintername */
474 NULL, /* szDontdescend */
475 NULL, /* szHostsallow */
476 NULL, /* szHostsdeny */
477 NULL, /* szMagicScript */
478 NULL, /* szMagicOutput */
479 NULL, /* szMangledMap */
480 NULL, /* szVetoFiles */
481 NULL, /* szHideFiles */
482 NULL, /* szVetoOplockFiles */
483 NULL, /* comment */
484 NULL, /* force user */
485 NULL, /* force group */
486 NULL, /* readlist */
487 NULL, /* writelist */
488 NULL, /* printer admin */
489 NULL, /* volume */
490 NULL, /* fstype */
491 NULL, /* vfs objects */
492 NULL, /* szMSDfsProxy */
493 0, /* iMinPrintSpace */
494 1000, /* iMaxPrintJobs */
495 0, /* iMaxReportedPrintJobs */
496 0, /* iWriteCacheSize */
497 0744, /* iCreate_mask */
498 0000, /* iCreate_force_mode */
499 0777, /* iSecurity_mask */
500 0, /* iSecurity_force_mode */
501 0755, /* iDir_mask */
502 0000, /* iDir_force_mode */
503 0777, /* iDir_Security_mask */
504 0, /* iDir_Security_force_mode */
505 0, /* iMaxConnections */
506 CASE_LOWER, /* iDefaultCase */
507 DEFAULT_PRINTING, /* iPrinting */
508 2, /* iOplockContentionLimit */
509 0, /* iCSCPolicy */
510 1024, /* iBlock_size */
511 False, /* bPreexecClose */
512 False, /* bRootpreexecClose */
513 Auto, /* case sensitive */
514 True, /* case preserve */
515 True, /* short case preserve */
516 True, /* bHideDotFiles */
517 False, /* bHideSpecialFiles */
518 False, /* bHideUnReadable */
519 False, /* bHideUnWriteableFiles */
520 True, /* bBrowseable */
521 True, /* bAvailable */
522 True, /* bRead_only */
523 True, /* bNo_set_dir */
524 False, /* bGuest_only */
525 False, /* bGuest_ok */
526 False, /* bPrint_ok */
527 False, /* bMap_system */
528 False, /* bMap_hidden */
529 True, /* bMap_archive */
530 False, /* bStoreDosAttributes */
531 True, /* bLocking */
532 True, /* iStrictLocking */
533 True, /* bPosixLocking */
534 True, /* bShareModes */
535 True, /* bOpLocks */
536 True, /* bLevel2OpLocks */
537 False, /* bOnlyUser */
538 True, /* bMangledNames */
539 True, /* bWidelinks */
540 True, /* bSymlinks */
541 False, /* bSyncAlways */
542 False, /* bStrictAllocate */
543 False, /* bStrictSync */
544 '~', /* magic char */
545 NULL, /* copymap */
546 False, /* bDeleteReadonly */
547 False, /* bFakeOplocks */
548 False, /* bDeleteVetoFiles */
549 False, /* bDosFilemode */
550 True, /* bDosFiletimes */
551 False, /* bDosFiletimeResolution */
552 False, /* bFakeDirCreateTimes */
553 True, /* bBlockingLocks */
554 False, /* bInheritPerms */
555 False, /* bInheritACLS */
556 False, /* bInheritOwner */
557 False, /* bMSDfsRoot */
558 False, /* bUseClientDriver */
559 False, /* bDefaultDevmode */
560 False, /* bForcePrintername */
561 True, /* bNTAclSupport */
562 False, /* bForceUnknownAclUser */
563 False, /* bUseSendfile */
564 False, /* bProfileAcls */
565 False, /* bMap_acl_inherit */
566 False, /* bAfs_Share */
567 False, /* bEASupport */
568 True, /* bAclCheckPermissions */
569 SMB_ROUNDUP_ALLOCATION_SIZE, /* iallocation_roundup_size */
571 NULL, /* Parametric options */
573 "" /* dummy */
576 /* local variables */
577 static service **ServicePtrs = NULL;
578 static int iNumServices = 0;
579 static int iServiceIndex = 0;
580 static BOOL bInGlobalSection = True;
581 static BOOL bGlobalOnly = False;
582 static int server_role;
583 static int default_server_announce;
585 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
587 /* prototypes for the special type handlers */
588 static BOOL handle_include( int snum, const char *pszParmValue, char **ptr);
589 static BOOL handle_copy( int snum, const char *pszParmValue, char **ptr);
590 static BOOL handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
591 static BOOL handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
592 static BOOL handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
593 static BOOL handle_debug_list( int snum, const char *pszParmValue, char **ptr );
594 static BOOL handle_workgroup( int snum, const char *pszParmValue, char **ptr );
595 static BOOL handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
596 static BOOL handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
597 static BOOL handle_charset( int snum, const char *pszParmValue, char **ptr );
598 static BOOL handle_acl_compatibility( int snum, const char *pszParmValue, char **ptr);
599 static BOOL handle_printing( int snum, const char *pszParmValue, char **ptr);
600 static BOOL handle_eventlog( int snum, const char *pszParmValue, char **ptr);
602 static void set_server_role(void);
603 static void set_default_server_announce_type(void);
604 static void set_allowed_client_auth(void);
606 static const struct enum_list enum_protocol[] = {
607 {PROTOCOL_NT1, "NT1"},
608 {PROTOCOL_LANMAN2, "LANMAN2"},
609 {PROTOCOL_LANMAN1, "LANMAN1"},
610 {PROTOCOL_CORE, "CORE"},
611 {PROTOCOL_COREPLUS, "COREPLUS"},
612 {PROTOCOL_COREPLUS, "CORE+"},
613 {-1, NULL}
616 static const struct enum_list enum_security[] = {
617 {SEC_SHARE, "SHARE"},
618 {SEC_USER, "USER"},
619 {SEC_SERVER, "SERVER"},
620 {SEC_DOMAIN, "DOMAIN"},
621 #ifdef HAVE_ADS
622 {SEC_ADS, "ADS"},
623 #endif
624 {-1, NULL}
627 static const struct enum_list enum_printing[] = {
628 {PRINT_SYSV, "sysv"},
629 {PRINT_AIX, "aix"},
630 {PRINT_HPUX, "hpux"},
631 {PRINT_BSD, "bsd"},
632 {PRINT_QNX, "qnx"},
633 {PRINT_PLP, "plp"},
634 {PRINT_LPRNG, "lprng"},
635 {PRINT_CUPS, "cups"},
636 {PRINT_LPRNT, "nt"},
637 {PRINT_LPROS2, "os2"},
638 #ifdef DEVELOPER
639 {PRINT_TEST, "test"},
640 {PRINT_VLP, "vlp"},
641 #endif /* DEVELOPER */
642 {-1, NULL}
645 static const struct enum_list enum_ldap_ssl[] = {
646 #ifdef WITH_LDAP_SAMCONFIG
647 {LDAP_SSL_ON, "Yes"},
648 {LDAP_SSL_ON, "yes"},
649 {LDAP_SSL_ON, "on"},
650 {LDAP_SSL_ON, "On"},
651 #endif
652 {LDAP_SSL_OFF, "no"},
653 {LDAP_SSL_OFF, "No"},
654 {LDAP_SSL_OFF, "off"},
655 {LDAP_SSL_OFF, "Off"},
656 {LDAP_SSL_START_TLS, "start tls"},
657 {LDAP_SSL_START_TLS, "Start_tls"},
658 {-1, NULL}
661 static const struct enum_list enum_ldap_passwd_sync[] = {
662 {LDAP_PASSWD_SYNC_OFF, "no"},
663 {LDAP_PASSWD_SYNC_OFF, "No"},
664 {LDAP_PASSWD_SYNC_OFF, "off"},
665 {LDAP_PASSWD_SYNC_OFF, "Off"},
666 {LDAP_PASSWD_SYNC_ON, "Yes"},
667 {LDAP_PASSWD_SYNC_ON, "yes"},
668 {LDAP_PASSWD_SYNC_ON, "on"},
669 {LDAP_PASSWD_SYNC_ON, "On"},
670 {LDAP_PASSWD_SYNC_ONLY, "Only"},
671 {LDAP_PASSWD_SYNC_ONLY, "only"},
672 {-1, NULL}
675 /* Types of machine we can announce as. */
676 #define ANNOUNCE_AS_NT_SERVER 1
677 #define ANNOUNCE_AS_WIN95 2
678 #define ANNOUNCE_AS_WFW 3
679 #define ANNOUNCE_AS_NT_WORKSTATION 4
681 static const struct enum_list enum_announce_as[] = {
682 {ANNOUNCE_AS_NT_SERVER, "NT"},
683 {ANNOUNCE_AS_NT_SERVER, "NT Server"},
684 {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
685 {ANNOUNCE_AS_WIN95, "win95"},
686 {ANNOUNCE_AS_WFW, "WfW"},
687 {-1, NULL}
690 static const struct enum_list enum_case[] = {
691 {CASE_LOWER, "lower"},
692 {CASE_UPPER, "upper"},
693 {-1, NULL}
696 static const struct enum_list enum_bool_auto[] = {
697 {False, "No"},
698 {False, "False"},
699 {False, "0"},
700 {True, "Yes"},
701 {True, "True"},
702 {True, "1"},
703 {Auto, "Auto"},
704 {-1, NULL}
707 /* Client-side offline caching policy types */
708 #define CSC_POLICY_MANUAL 0
709 #define CSC_POLICY_DOCUMENTS 1
710 #define CSC_POLICY_PROGRAMS 2
711 #define CSC_POLICY_DISABLE 3
713 static const struct enum_list enum_csc_policy[] = {
714 {CSC_POLICY_MANUAL, "manual"},
715 {CSC_POLICY_DOCUMENTS, "documents"},
716 {CSC_POLICY_PROGRAMS, "programs"},
717 {CSC_POLICY_DISABLE, "disable"},
718 {-1, NULL}
721 /* SMB signing types. */
722 static const struct enum_list enum_smb_signing_vals[] = {
723 {False, "No"},
724 {False, "False"},
725 {False, "0"},
726 {False, "Off"},
727 {False, "disabled"},
728 {True, "Yes"},
729 {True, "True"},
730 {True, "1"},
731 {True, "On"},
732 {True, "enabled"},
733 {Auto, "auto"},
734 {Required, "required"},
735 {Required, "mandatory"},
736 {Required, "force"},
737 {Required, "forced"},
738 {Required, "enforced"},
739 {-1, NULL}
744 Do you want session setups at user level security with a invalid
745 password to be rejected or allowed in as guest? WinNT rejects them
746 but it can be a pain as it means "net view" needs to use a password
748 You have 3 choices in the setting of map_to_guest:
750 "Never" means session setups with an invalid password
751 are rejected. This is the default.
753 "Bad User" means session setups with an invalid password
754 are rejected, unless the username does not exist, in which case it
755 is treated as a guest login
757 "Bad Password" means session setups with an invalid password
758 are treated as a guest login
760 Note that map_to_guest only has an effect in user or server
761 level security.
764 static const struct enum_list enum_map_to_guest[] = {
765 {NEVER_MAP_TO_GUEST, "Never"},
766 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
767 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
768 {-1, NULL}
771 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
773 * The FLAG_HIDE is explicit. Paramters set this way do NOT appear in any edit
774 * screen in SWAT. This is used to exclude parameters as well as to squash all
775 * parameters that have been duplicated by pseudonyms.
777 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
778 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
779 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
780 * respective views.
782 * NOTE2: Handling of duplicated (synonym) paramters:
783 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
784 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
785 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
786 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
789 static struct parm_struct parm_table[] = {
790 {N_("Base Options"), P_SEP, P_SEPARATOR},
792 {"dos charset", P_STRING, P_GLOBAL, &Globals.dos_charset, handle_charset, NULL, FLAG_ADVANCED},
793 {"unix charset", P_STRING, P_GLOBAL, &Globals.unix_charset, handle_charset, NULL, FLAG_ADVANCED},
794 {"display charset", P_STRING, P_GLOBAL, &Globals.display_charset, handle_charset, NULL, FLAG_ADVANCED},
795 {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
796 {"path", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
797 {"directory", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_HIDE},
798 {"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkgroup, handle_workgroup, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
799 #ifdef WITH_ADS
800 {"realm", P_USTRING, P_GLOBAL, &Globals.szRealm, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
801 #endif
802 {"netbios name", P_USTRING, P_GLOBAL, &Globals.szNetbiosName, handle_netbios_name, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
803 {"netbios aliases", P_LIST, P_GLOBAL, &Globals.szNetbiosAliases, handle_netbios_aliases, NULL, FLAG_ADVANCED},
804 {"netbios scope", P_USTRING, P_GLOBAL, &Globals.szNetbiosScope, handle_netbios_scope, NULL, FLAG_ADVANCED},
805 {"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED },
806 {"interfaces", P_LIST, P_GLOBAL, &Globals.szInterfaces, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
807 {"bind interfaces only", P_BOOL, P_GLOBAL, &Globals.bBindInterfacesOnly, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD},
809 {N_("Security Options"), P_SEP, P_SEPARATOR},
811 {"security", P_ENUM, P_GLOBAL, &Globals.security, NULL, enum_security, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
812 {"auth methods", P_LIST, P_GLOBAL, &Globals.AuthMethods, NULL, NULL, FLAG_ADVANCED},
813 {"encrypt passwords", P_BOOL, P_GLOBAL, &Globals.bEncryptPasswords, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
814 {"update encrypted", P_BOOL, P_GLOBAL, &Globals.bUpdateEncrypt, NULL, NULL, FLAG_ADVANCED},
815 {"client schannel", P_ENUM, P_GLOBAL, &Globals.clientSchannel, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED},
816 {"server schannel", P_ENUM, P_GLOBAL, &Globals.serverSchannel, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED},
817 {"allow trusted domains", P_BOOL, P_GLOBAL, &Globals.bAllowTrustedDomains, NULL, NULL, FLAG_ADVANCED},
818 {"hosts equiv", P_STRING, P_GLOBAL, &Globals.szHostsEquiv, NULL, NULL, FLAG_ADVANCED},
819 {"min password length", P_INTEGER, P_GLOBAL, &Globals.min_passwd_length, NULL, NULL, FLAG_DEPRECATED},
820 {"min passwd length", P_INTEGER, P_GLOBAL, &Globals.min_passwd_length, NULL, NULL, FLAG_DEPRECATED},
821 {"map to guest", P_ENUM, P_GLOBAL, &Globals.map_to_guest, NULL, enum_map_to_guest, FLAG_ADVANCED},
822 {"null passwords", P_BOOL, P_GLOBAL, &Globals.bNullPasswords, NULL, NULL, FLAG_ADVANCED},
823 {"obey pam restrictions", P_BOOL, P_GLOBAL, &Globals.bObeyPamRestrictions, NULL, NULL, FLAG_ADVANCED},
824 {"password server", P_STRING, P_GLOBAL, &Globals.szPasswordServer, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD},
825 {"smb passwd file", P_STRING, P_GLOBAL, &Globals.szSMBPasswdFile, NULL, NULL, FLAG_ADVANCED},
826 {"private dir", P_STRING, P_GLOBAL, &Globals.szPrivateDir, NULL, NULL, FLAG_ADVANCED},
827 {"passdb backend", P_LIST, P_GLOBAL, &Globals.szPassdbBackend, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD},
828 {"algorithmic rid base", P_INTEGER, P_GLOBAL, &Globals.AlgorithmicRidBase, NULL, NULL, FLAG_ADVANCED},
829 {"root directory", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, FLAG_ADVANCED},
830 {"root dir", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, FLAG_HIDE},
831 {"root", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, FLAG_HIDE},
832 {"guest account", P_STRING, P_GLOBAL, &Globals.szGuestaccount, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED},
833 {"enable privileges", P_BOOL, P_GLOBAL, &Globals.bEnablePrivileges, NULL, NULL, FLAG_ADVANCED},
835 {"pam password change", P_BOOL, P_GLOBAL, &Globals.bPamPasswordChange, NULL, NULL, FLAG_ADVANCED},
836 {"passwd program", P_STRING, P_GLOBAL, &Globals.szPasswdProgram, NULL, NULL, FLAG_ADVANCED},
837 {"passwd chat", P_STRING, P_GLOBAL, &Globals.szPasswdChat, NULL, NULL, FLAG_ADVANCED},
838 {"passwd chat debug", P_BOOL, P_GLOBAL, &Globals.bPasswdChatDebug, NULL, NULL, FLAG_ADVANCED},
839 {"passwd chat timeout", P_INTEGER, P_GLOBAL, &Globals.iPasswdChatTimeout, NULL, NULL, FLAG_ADVANCED},
840 {"check password script", P_STRING, P_GLOBAL, &Globals.szCheckPasswordScript, NULL, NULL, FLAG_ADVANCED},
841 {"username map", P_STRING, P_GLOBAL, &Globals.szUsernameMap, NULL, NULL, FLAG_ADVANCED},
842 {"password level", P_INTEGER, P_GLOBAL, &Globals.pwordlevel, NULL, NULL, FLAG_ADVANCED},
843 {"username level", P_INTEGER, P_GLOBAL, &Globals.unamelevel, NULL, NULL, FLAG_ADVANCED},
844 {"unix password sync", P_BOOL, P_GLOBAL, &Globals.bUnixPasswdSync, NULL, NULL, FLAG_ADVANCED},
845 {"restrict anonymous", P_INTEGER, P_GLOBAL, &Globals.restrict_anonymous, NULL, NULL, FLAG_ADVANCED},
846 {"lanman auth", P_BOOL, P_GLOBAL, &Globals.bLanmanAuth, NULL, NULL, FLAG_ADVANCED},
847 {"ntlm auth", P_BOOL, P_GLOBAL, &Globals.bNTLMAuth, NULL, NULL, FLAG_ADVANCED},
848 {"client NTLMv2 auth", P_BOOL, P_GLOBAL, &Globals.bClientNTLMv2Auth, NULL, NULL, FLAG_ADVANCED},
849 {"client lanman auth", P_BOOL, P_GLOBAL, &Globals.bClientLanManAuth, NULL, NULL, FLAG_ADVANCED},
850 {"client plaintext auth", P_BOOL, P_GLOBAL, &Globals.bClientPlaintextAuth, NULL, NULL, FLAG_ADVANCED},
852 {"username", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
853 {"user", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, FLAG_HIDE},
854 {"users", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, FLAG_HIDE},
856 {"invalid users", P_LIST, P_LOCAL, &sDefault.szInvalidUsers, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
857 {"valid users", P_LIST, P_LOCAL, &sDefault.szValidUsers, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
858 {"admin users", P_LIST, P_LOCAL, &sDefault.szAdminUsers, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
859 {"read list", P_LIST, P_LOCAL, &sDefault.readlist, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
860 {"write list", P_LIST, P_LOCAL, &sDefault.writelist, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
861 {"printer admin", P_LIST, P_LOCAL, &sDefault.printer_admin, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED },
862 {"force user", P_STRING, P_LOCAL, &sDefault.force_user, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
863 {"force group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
864 {"group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL, FLAG_ADVANCED},
866 {"read only", P_BOOL, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE},
867 {"write ok", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_HIDE},
868 {"writeable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_HIDE},
869 {"writable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_HIDE},
871 {"acl check permissions", P_BOOL, P_LOCAL, &sDefault.bAclCheckPermissions, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
872 {"create mask", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
873 {"create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_HIDE},
874 {"force create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_force_mode, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
875 {"security mask", P_OCTAL, P_LOCAL, &sDefault.iSecurity_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
876 {"force security mode", P_OCTAL, P_LOCAL, &sDefault.iSecurity_force_mode, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
877 {"directory mask", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
878 {"directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
879 {"force directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_force_mode, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
880 {"directory security mask", P_OCTAL, P_LOCAL, &sDefault.iDir_Security_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
881 {"force directory security mode", P_OCTAL, P_LOCAL, &sDefault.iDir_Security_force_mode, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
882 {"force unknown acl user", P_BOOL, P_LOCAL, &sDefault.bForceUnknownAclUser, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
883 {"inherit permissions", P_BOOL, P_LOCAL, &sDefault.bInheritPerms, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
884 {"inherit acls", P_BOOL, P_LOCAL, &sDefault.bInheritACLS, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
885 {"inherit owner", P_BOOL, P_LOCAL, &sDefault.bInheritOwner, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
886 {"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
887 {"only guest", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, FLAG_HIDE},
889 {"guest ok", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
890 {"public", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_HIDE},
892 {"only user", P_BOOL, P_LOCAL, &sDefault.bOnlyUser, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED},
893 {"hosts allow", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
894 {"allow hosts", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_HIDE},
895 {"hosts deny", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
896 {"deny hosts", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_HIDE},
897 {"preload modules", P_LIST, P_GLOBAL, &Globals.szPreloadModules, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
898 {"use kerberos keytab", P_BOOL, P_GLOBAL, &Globals.bUseKerberosKeytab, NULL, NULL, FLAG_ADVANCED},
900 {N_("Logging Options"), P_SEP, P_SEPARATOR},
902 {"log level", P_STRING, P_GLOBAL, &Globals.szLogLevel, handle_debug_list, NULL, FLAG_ADVANCED},
903 {"debuglevel", P_STRING, P_GLOBAL, &Globals.szLogLevel, handle_debug_list, NULL, FLAG_HIDE},
904 {"syslog", P_INTEGER, P_GLOBAL, &Globals.syslog, NULL, NULL, FLAG_ADVANCED},
905 {"syslog only", P_BOOL, P_GLOBAL, &Globals.bSyslogOnly, NULL, NULL, FLAG_ADVANCED},
906 {"log file", P_STRING, P_GLOBAL, &Globals.szLogFile, NULL, NULL, FLAG_ADVANCED},
908 {"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL, NULL, FLAG_ADVANCED},
909 {"debug timestamp", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, FLAG_ADVANCED},
910 {"timestamp logs", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, FLAG_ADVANCED},
911 {"debug hires timestamp", P_BOOL, P_GLOBAL, &Globals.bDebugHiresTimestamp, NULL, NULL, FLAG_ADVANCED},
912 {"debug pid", P_BOOL, P_GLOBAL, &Globals.bDebugPid, NULL, NULL, FLAG_ADVANCED},
913 {"debug uid", P_BOOL, P_GLOBAL, &Globals.bDebugUid, NULL, NULL, FLAG_ADVANCED},
915 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
917 {"allocation roundup size", P_INTEGER, P_LOCAL, &sDefault.iallocation_roundup_size, NULL, NULL, FLAG_ADVANCED},
918 {"smb ports", P_STRING, P_GLOBAL, &Globals.smb_ports, NULL, NULL, FLAG_ADVANCED},
919 {"large readwrite", P_BOOL, P_GLOBAL, &Globals.bLargeReadwrite, NULL, NULL, FLAG_ADVANCED},
920 {"max protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, FLAG_ADVANCED},
921 {"protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, FLAG_ADVANCED},
922 {"min protocol", P_ENUM, P_GLOBAL, &Globals.minprotocol, NULL, enum_protocol, FLAG_ADVANCED},
923 {"read bmpx", P_BOOL, P_GLOBAL, &Globals.bReadbmpx, NULL, NULL, FLAG_ADVANCED},
924 {"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL, FLAG_ADVANCED},
925 {"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL, FLAG_ADVANCED},
926 {"disable netbios", P_BOOL, P_GLOBAL, &Globals.bDisableNetbios, NULL, NULL, FLAG_ADVANCED},
928 {"acl compatibility", P_STRING, P_GLOBAL, &Globals.szAclCompat, handle_acl_compatibility, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
929 {"defer sharing violations", P_BOOL, P_GLOBAL, &Globals.bDeferSharingViolations, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
930 {"ea support", P_BOOL, P_LOCAL, &sDefault.bEASupport, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
931 {"nt acl support", P_BOOL, P_LOCAL, &sDefault.bNTAclSupport, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
932 {"nt pipe support", P_BOOL, P_GLOBAL, &Globals.bNTPipeSupport, NULL, NULL, FLAG_ADVANCED},
933 {"nt status support", P_BOOL, P_GLOBAL, &Globals.bNTStatusSupport, NULL, NULL, FLAG_ADVANCED},
934 {"profile acls", P_BOOL, P_LOCAL, &sDefault.bProfileAcls, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
936 {"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL, NULL, FLAG_ADVANCED},
937 {"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as, FLAG_ADVANCED},
938 {"map acl inherit", P_BOOL, P_LOCAL, &sDefault.bMap_acl_inherit, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
939 {"afs share", P_BOOL, P_LOCAL, &sDefault.bAfs_Share, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
940 {"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL, FLAG_ADVANCED},
941 {"max xmit", P_INTEGER, P_GLOBAL, &Globals.max_xmit, NULL, NULL, FLAG_ADVANCED},
943 {"name resolve order", P_STRING, P_GLOBAL, &Globals.szNameResolveOrder, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD},
944 {"max ttl", P_INTEGER, P_GLOBAL, &Globals.max_ttl, NULL, NULL, FLAG_ADVANCED},
945 {"max wins ttl", P_INTEGER, P_GLOBAL, &Globals.max_wins_ttl, NULL, NULL, FLAG_ADVANCED},
946 {"min wins ttl", P_INTEGER, P_GLOBAL, &Globals.min_wins_ttl, NULL, NULL, FLAG_ADVANCED},
947 {"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL, NULL, FLAG_ADVANCED},
948 {"unix extensions", P_BOOL, P_GLOBAL, &Globals.bUnixExtensions, NULL, NULL, FLAG_ADVANCED},
949 {"use spnego", P_BOOL, P_GLOBAL, &Globals.bUseSpnego, NULL, NULL, FLAG_ADVANCED},
950 {"client signing", P_ENUM, P_GLOBAL, &Globals.client_signing, NULL, enum_smb_signing_vals, FLAG_ADVANCED},
951 {"server signing", P_ENUM, P_GLOBAL, &Globals.server_signing, NULL, enum_smb_signing_vals, FLAG_ADVANCED},
952 {"client use spnego", P_BOOL, P_GLOBAL, &Globals.bClientUseSpnego, NULL, NULL, FLAG_ADVANCED},
954 {"enable asu support", P_BOOL, P_GLOBAL, &Globals.bASUSupport, NULL, NULL, FLAG_ADVANCED},
955 {"enable svcctl", P_LIST, P_GLOBAL, &Globals.szServicesList, NULL, NULL, FLAG_ADVANCED},
957 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
959 {"block size", P_INTEGER, P_LOCAL, &sDefault.iBlock_size, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
960 {"change notify timeout", P_INTEGER, P_GLOBAL, &Globals.change_notify_timeout, NULL, NULL, FLAG_ADVANCED},
961 {"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL, NULL, FLAG_ADVANCED},
962 {"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL, NULL, FLAG_ADVANCED},
963 {"keepalive", P_INTEGER, P_GLOBAL, &keepalive, NULL, NULL, FLAG_ADVANCED},
964 {"kernel change notify", P_BOOL, P_GLOBAL, &Globals.bKernelChangeNotify, NULL, NULL, FLAG_ADVANCED},
966 {"lpq cache time", P_INTEGER, P_GLOBAL, &Globals.lpqcachetime, NULL, NULL, FLAG_ADVANCED},
967 {"max smbd processes", P_INTEGER, P_GLOBAL, &Globals.iMaxSmbdProcesses, NULL, NULL, FLAG_ADVANCED},
968 {"max connections", P_INTEGER, P_LOCAL, &sDefault.iMaxConnections, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
969 {"paranoid server security", P_BOOL, P_GLOBAL, &Globals.paranoid_server_security, NULL, NULL, FLAG_ADVANCED},
970 {"max disk size", P_INTEGER, P_GLOBAL, &Globals.maxdisksize, NULL, NULL, FLAG_ADVANCED},
971 {"max open files", P_INTEGER, P_GLOBAL, &Globals.max_open_files, NULL, NULL, FLAG_ADVANCED},
972 {"min print space", P_INTEGER, P_LOCAL, &sDefault.iMinPrintSpace, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
974 {"socket options", P_GSTRING, P_GLOBAL, user_socket_options, NULL, NULL, FLAG_ADVANCED},
975 {"strict allocate", P_BOOL, P_LOCAL, &sDefault.bStrictAllocate, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
976 {"strict sync", P_BOOL, P_LOCAL, &sDefault.bStrictSync, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
977 {"sync always", P_BOOL, P_LOCAL, &sDefault.bSyncAlways, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
978 {"use mmap", P_BOOL, P_GLOBAL, &Globals.bUseMmap, NULL, NULL, FLAG_ADVANCED},
979 {"use sendfile", P_BOOL, P_LOCAL, &sDefault.bUseSendfile, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
980 {"hostname lookups", P_BOOL, P_GLOBAL, &Globals.bHostnameLookups, NULL, NULL, FLAG_ADVANCED},
981 {"write cache size", P_INTEGER, P_LOCAL, &sDefault.iWriteCacheSize, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED},
983 {"name cache timeout", P_INTEGER, P_GLOBAL, &Globals.name_cache_timeout, NULL, NULL, FLAG_ADVANCED},
985 {N_("Printing Options"), P_SEP, P_SEPARATOR},
987 {"max reported print jobs", P_INTEGER, P_LOCAL, &sDefault.iMaxReportedPrintJobs, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
988 {"max print jobs", P_INTEGER, P_LOCAL, &sDefault.iMaxPrintJobs, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
989 {"load printers", P_BOOL, P_GLOBAL, &Globals.bLoadPrinters, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
990 {"printcap cache time", P_INTEGER, P_GLOBAL, &Globals.PrintcapCacheTime, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
991 {"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
992 {"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, FLAG_HIDE},
993 {"printable", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
994 {"print ok", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, FLAG_HIDE},
995 {"printing", P_ENUM, P_LOCAL, &sDefault.iPrinting, handle_printing, enum_printing, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
996 {"cups options", P_STRING, P_LOCAL, &sDefault.szCupsOptions, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
997 {"cups server", P_STRING, P_GLOBAL, &Globals.szCupsServer, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
998 {"print command", P_STRING, P_LOCAL, &sDefault.szPrintcommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
999 {"disable spoolss", P_BOOL, P_GLOBAL, &Globals.bDisableSpoolss, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1000 {"enable spoolss", P_BOOLREV, P_GLOBAL, &Globals.bDisableSpoolss, NULL, NULL, FLAG_HIDE},
1001 {"lpq command", P_STRING, P_LOCAL, &sDefault.szLpqcommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1002 {"lprm command", P_STRING, P_LOCAL, &sDefault.szLprmcommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1003 {"lppause command", P_STRING, P_LOCAL, &sDefault.szLppausecommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1004 {"lpresume command", P_STRING, P_LOCAL, &sDefault.szLpresumecommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1005 {"queuepause command", P_STRING, P_LOCAL, &sDefault.szQueuepausecommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1006 {"queueresume command", P_STRING, P_LOCAL, &sDefault.szQueueresumecommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1008 {"enumports command", P_STRING, P_GLOBAL, &Globals.szEnumPortsCommand, NULL, NULL, FLAG_ADVANCED},
1009 {"addprinter command", P_STRING, P_GLOBAL, &Globals.szAddPrinterCommand, NULL, NULL, FLAG_ADVANCED},
1010 {"deleteprinter command", P_STRING, P_GLOBAL, &Globals.szDeletePrinterCommand, NULL, NULL, FLAG_ADVANCED},
1011 {"show add printer wizard", P_BOOL, P_GLOBAL, &Globals.bMsAddPrinterWizard, NULL, NULL, FLAG_ADVANCED},
1012 {"os2 driver map", P_STRING, P_GLOBAL, &Globals.szOs2DriverMap, NULL, NULL, FLAG_ADVANCED},
1014 {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
1015 {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_HIDE},
1016 {"use client driver", P_BOOL, P_LOCAL, &sDefault.bUseClientDriver, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
1017 {"default devmode", P_BOOL, P_LOCAL, &sDefault.bDefaultDevmode, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
1018 {"force printername", P_BOOL, P_LOCAL, &sDefault.bForcePrintername, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
1020 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
1021 {"mangling method", P_STRING, P_GLOBAL, &Globals.szManglingMethod, NULL, NULL, FLAG_ADVANCED},
1022 {"mangle prefix", P_INTEGER, P_GLOBAL, &Globals.mangle_prefix, NULL, NULL, FLAG_ADVANCED},
1024 {"default case", P_ENUM, P_LOCAL, &sDefault.iDefaultCase, NULL, enum_case, FLAG_ADVANCED | FLAG_SHARE},
1025 {"case sensitive", P_ENUM, P_LOCAL, &sDefault.iCaseSensitive, NULL, enum_bool_auto, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1026 {"casesignames", P_ENUM, P_LOCAL, &sDefault.iCaseSensitive, NULL, enum_bool_auto, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE},
1027 {"preserve case", P_BOOL, P_LOCAL, &sDefault.bCasePreserve, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1028 {"short preserve case", P_BOOL, P_LOCAL, &sDefault.bShortCasePreserve, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1029 {"mangling char", P_CHAR, P_LOCAL, &sDefault.magic_char, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1030 {"hide dot files", P_BOOL, P_LOCAL, &sDefault.bHideDotFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1031 {"hide special files", P_BOOL, P_LOCAL, &sDefault.bHideSpecialFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1032 {"hide unreadable", P_BOOL, P_LOCAL, &sDefault.bHideUnReadable, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1033 {"hide unwriteable files", P_BOOL, P_LOCAL, &sDefault.bHideUnWriteableFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1034 {"delete veto files", P_BOOL, P_LOCAL, &sDefault.bDeleteVetoFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1035 {"veto files", P_STRING, P_LOCAL, &sDefault.szVetoFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL },
1036 {"hide files", P_STRING, P_LOCAL, &sDefault.szHideFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL },
1037 {"veto oplock files", P_STRING, P_LOCAL, &sDefault.szVetoOplockFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL },
1038 {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1039 {"map hidden", P_BOOL, P_LOCAL, &sDefault.bMap_hidden, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1040 {"map archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1041 {"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1042 {"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED },
1043 {"max stat cache size", P_INTEGER, P_GLOBAL, &Globals.iMaxStatCacheSize, NULL, NULL, FLAG_ADVANCED},
1044 {"stat cache", P_BOOL, P_GLOBAL, &Globals.bStatCache, NULL, NULL, FLAG_ADVANCED},
1045 {"store dos attributes", P_BOOL, P_LOCAL, &sDefault.bStoreDosAttributes, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1047 {N_("Domain Options"), P_SEP, P_SEPARATOR},
1049 {"machine password timeout", P_INTEGER, P_GLOBAL, &Globals.machine_password_timeout, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD},
1051 {N_("Logon Options"), P_SEP, P_SEPARATOR},
1053 {"add user script", P_STRING, P_GLOBAL, &Globals.szAddUserScript, NULL, NULL, FLAG_ADVANCED},
1054 {"delete user script", P_STRING, P_GLOBAL, &Globals.szDelUserScript, NULL, NULL, FLAG_ADVANCED},
1055 {"add group script", P_STRING, P_GLOBAL, &Globals.szAddGroupScript, NULL, NULL, FLAG_ADVANCED},
1056 {"delete group script", P_STRING, P_GLOBAL, &Globals.szDelGroupScript, NULL, NULL, FLAG_ADVANCED},
1057 {"add user to group script", P_STRING, P_GLOBAL, &Globals.szAddUserToGroupScript, NULL, NULL, FLAG_ADVANCED},
1058 {"delete user from group script", P_STRING, P_GLOBAL, &Globals.szDelUserFromGroupScript, NULL, NULL, FLAG_ADVANCED},
1059 {"set primary group script", P_STRING, P_GLOBAL, &Globals.szSetPrimaryGroupScript, NULL, NULL, FLAG_ADVANCED},
1060 {"add machine script", P_STRING, P_GLOBAL, &Globals.szAddMachineScript, NULL, NULL, FLAG_ADVANCED},
1061 {"shutdown script", P_STRING, P_GLOBAL, &Globals.szShutdownScript, NULL, NULL, FLAG_ADVANCED},
1062 {"abort shutdown script", P_STRING, P_GLOBAL, &Globals.szAbortShutdownScript, NULL, NULL, FLAG_ADVANCED},
1064 {"logon script", P_STRING, P_GLOBAL, &Globals.szLogonScript, NULL, NULL, FLAG_ADVANCED},
1065 {"logon path", P_STRING, P_GLOBAL, &Globals.szLogonPath, NULL, NULL, FLAG_ADVANCED},
1066 {"logon drive", P_STRING, P_GLOBAL, &Globals.szLogonDrive, NULL, NULL, FLAG_ADVANCED},
1067 {"logon home", P_STRING, P_GLOBAL, &Globals.szLogonHome, NULL, NULL, FLAG_ADVANCED},
1068 {"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL, NULL, FLAG_ADVANCED},
1070 {N_("Browse Options"), P_SEP, P_SEPARATOR},
1072 {"os level", P_INTEGER, P_GLOBAL, &Globals.os_level, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED},
1073 {"lm announce", P_ENUM, P_GLOBAL, &Globals.lm_announce, NULL, enum_bool_auto, FLAG_ADVANCED},
1074 {"lm interval", P_INTEGER, P_GLOBAL, &Globals.lm_interval, NULL, NULL, FLAG_ADVANCED},
1075 {"preferred master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED},
1076 {"prefered master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_HIDE},
1077 {"local master", P_BOOL, P_GLOBAL, &Globals.bLocalMaster, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED},
1078 {"domain master", P_ENUM, P_GLOBAL, &Globals.bDomainMaster, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED},
1079 {"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL, NULL, FLAG_ADVANCED},
1080 {"browseable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1081 {"browsable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_HIDE},
1082 {"enhanced browsing", P_BOOL, P_GLOBAL, &Globals.enhanced_browsing, NULL, NULL, FLAG_ADVANCED},
1084 {N_("WINS Options"), P_SEP, P_SEPARATOR},
1086 {"dns proxy", P_BOOL, P_GLOBAL, &Globals.bDNSproxy, NULL, NULL, FLAG_ADVANCED},
1087 {"wins proxy", P_BOOL, P_GLOBAL, &Globals.bWINSproxy, NULL, NULL, FLAG_ADVANCED},
1089 {"wins server", P_LIST, P_GLOBAL, &Globals.szWINSservers, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
1090 {"wins support", P_BOOL, P_GLOBAL, &Globals.bWINSsupport, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
1091 {"wins hook", P_STRING, P_GLOBAL, &Globals.szWINSHook, NULL, NULL, FLAG_ADVANCED},
1092 {"wins partners", P_STRING, P_GLOBAL, &Globals.szWINSPartners, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD},
1094 {N_("Locking Options"), P_SEP, P_SEPARATOR},
1096 {"blocking locks", P_BOOL, P_LOCAL, &sDefault.bBlockingLocks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1097 {"csc policy", P_ENUM, P_LOCAL, &sDefault.iCSCPolicy, NULL, enum_csc_policy, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1098 {"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1099 {"kernel oplocks", P_BOOL, P_GLOBAL, &Globals.bKernelOplocks, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
1100 {"locking", P_BOOL, P_LOCAL, &sDefault.bLocking, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1101 {"lock spin count", P_INTEGER, P_GLOBAL, &Globals.iLockSpinCount, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
1102 {"lock spin time", P_INTEGER, P_GLOBAL, &Globals.iLockSpinTime, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
1104 {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1105 {"level2 oplocks", P_BOOL, P_LOCAL, &sDefault.bLevel2OpLocks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1106 {"oplock break wait time", P_INTEGER, P_GLOBAL, &Globals.oplock_break_wait_time, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
1107 {"oplock contention limit", P_INTEGER, P_LOCAL, &sDefault.iOplockContentionLimit, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1108 {"posix locking", P_BOOL, P_LOCAL, &sDefault.bPosixLocking, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1109 {"strict locking", P_ENUM, P_LOCAL, &sDefault.iStrictLocking, NULL, enum_bool_auto, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1110 {"share modes", P_BOOL, P_LOCAL, &sDefault.bShareModes, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1112 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
1114 #ifdef WITH_LDAP_SAMCONFIG
1115 {"ldap server", P_STRING, P_GLOBAL, &Globals.szLdapServer, NULL, NULL, FLAG_ADVANCED},
1116 {"ldap port", P_INTEGER, P_GLOBAL, &Globals.ldap_port, NULL, NULL, FLAG_ADVANCED},
1117 #endif
1118 {"ldap admin dn", P_STRING, P_GLOBAL, &Globals.szLdapAdminDn, NULL, NULL, FLAG_ADVANCED},
1119 {"ldap delete dn", P_BOOL, P_GLOBAL, &Globals.ldap_delete_dn, NULL, NULL, FLAG_ADVANCED},
1120 {"ldap filter", P_STRING, P_GLOBAL, &Globals.szLdapFilter, NULL, NULL, FLAG_ADVANCED},
1121 {"ldap group suffix", P_STRING, P_GLOBAL, &Globals.szLdapGroupSuffix, NULL, NULL, FLAG_ADVANCED},
1122 {"ldap idmap suffix", P_STRING, P_GLOBAL, &Globals.szLdapIdmapSuffix, NULL, NULL, FLAG_ADVANCED},
1123 {"ldap machine suffix", P_STRING, P_GLOBAL, &Globals.szLdapMachineSuffix, NULL, NULL, FLAG_ADVANCED},
1124 {"ldap passwd sync", P_ENUM, P_GLOBAL, &Globals.ldap_passwd_sync, NULL, enum_ldap_passwd_sync, FLAG_ADVANCED},
1125 {"ldap password sync", P_ENUM, P_GLOBAL, &Globals.ldap_passwd_sync, NULL, enum_ldap_passwd_sync, FLAG_HIDE},
1126 {"ldap replication sleep", P_INTEGER, P_GLOBAL, &Globals.ldap_replication_sleep, NULL, NULL, FLAG_ADVANCED},
1127 {"ldap suffix", P_STRING, P_GLOBAL, &Globals.szLdapSuffix, NULL, NULL, FLAG_ADVANCED},
1128 {"ldap ssl", P_ENUM, P_GLOBAL, &Globals.ldap_ssl, NULL, enum_ldap_ssl, FLAG_ADVANCED},
1129 {"ldap timeout", P_INTEGER, P_GLOBAL, &Globals.ldap_timeout, NULL, NULL, FLAG_ADVANCED},
1130 {"ldap page size", P_INTEGER, P_GLOBAL, &Globals.ldap_page_size, NULL, NULL, FLAG_ADVANCED},
1131 {"ldap user suffix", P_STRING, P_GLOBAL, &Globals.szLdapUserSuffix, NULL, NULL, FLAG_ADVANCED},
1133 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
1134 {"add share command", P_STRING, P_GLOBAL, &Globals.szAddShareCommand, NULL, NULL, FLAG_ADVANCED},
1135 {"change share command", P_STRING, P_GLOBAL, &Globals.szChangeShareCommand, NULL, NULL, FLAG_ADVANCED},
1136 {"delete share command", P_STRING, P_GLOBAL, &Globals.szDeleteShareCommand, NULL, NULL, FLAG_ADVANCED},
1138 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
1139 {"eventlog open command", P_STRING, P_GLOBAL, &Globals.szEventLogOpenCommand, handle_eventlog, NULL, FLAG_ADVANCED},
1140 {"eventlog read command", P_STRING, P_GLOBAL, &Globals.szEventLogReadCommand, handle_eventlog, NULL, FLAG_ADVANCED},
1141 {"eventlog clear command", P_STRING, P_GLOBAL, &Globals.szEventLogClearCommand, handle_eventlog, NULL, FLAG_ADVANCED},
1142 {"eventlog num records command", P_STRING, P_GLOBAL, &Globals.szEventLogNumRecordsCommand, handle_eventlog, NULL, FLAG_ADVANCED},
1143 {"eventlog oldest record command", P_STRING, P_GLOBAL, &Globals.szEventLogOldestRecordCommand, handle_eventlog, NULL, FLAG_ADVANCED},
1144 {"eventlog list", P_LIST, P_GLOBAL, &Globals.szEventLogs, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
1146 {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL, FLAG_HIDE},
1147 {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED},
1148 {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED},
1149 {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_ADVANCED},
1150 {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_HIDE},
1151 {"pid directory", P_STRING, P_GLOBAL, &Globals.szPidDir, NULL, NULL, FLAG_ADVANCED},
1152 #ifdef WITH_UTMP
1153 {"utmp directory", P_STRING, P_GLOBAL, &Globals.szUtmpDir, NULL, NULL, FLAG_ADVANCED},
1154 {"wtmp directory", P_STRING, P_GLOBAL, &Globals.szWtmpDir, NULL, NULL, FLAG_ADVANCED},
1155 {"utmp", P_BOOL, P_GLOBAL, &Globals.bUtmp, NULL, NULL, FLAG_ADVANCED},
1156 #endif
1158 {"default service", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL, FLAG_ADVANCED},
1159 {"default", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL, FLAG_ADVANCED},
1160 {"message command", P_STRING, P_GLOBAL, &Globals.szMsgCommand, NULL, NULL, FLAG_ADVANCED},
1161 {"dfree command", P_STRING, P_GLOBAL, &Globals.szDfree, NULL, NULL, FLAG_ADVANCED},
1162 {"get quota command", P_STRING, P_GLOBAL, &Globals.szGetQuota, NULL, NULL, FLAG_ADVANCED},
1163 {"set quota command", P_STRING, P_GLOBAL, &Globals.szSetQuota, NULL, NULL, FLAG_ADVANCED},
1164 {"remote announce", P_STRING, P_GLOBAL, &Globals.szRemoteAnnounce, NULL, NULL, FLAG_ADVANCED},
1165 {"remote browse sync", P_STRING, P_GLOBAL, &Globals.szRemoteBrowseSync, NULL, NULL, FLAG_ADVANCED},
1166 {"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL, NULL, FLAG_ADVANCED},
1167 {"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL, NULL, FLAG_ADVANCED},
1168 {"afs username map", P_STRING, P_GLOBAL, &Globals.szAfsUsernameMap, NULL, NULL, FLAG_ADVANCED},
1169 {"afs token lifetime", P_INTEGER, P_GLOBAL, &Globals.iAfsTokenLifetime, NULL, NULL, FLAG_ADVANCED},
1170 {"log nt token command", P_STRING, P_GLOBAL, &Globals.szLogNtTokenCommand, NULL, NULL, FLAG_ADVANCED},
1171 {"time offset", P_INTEGER, P_GLOBAL, &extra_time_offset, NULL, NULL, FLAG_ADVANCED},
1172 {"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL, NULL, FLAG_ADVANCED},
1173 {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL, NULL, FLAG_HIDE},
1175 {"copy", P_STRING, P_LOCAL, &sDefault.szCopy, handle_copy, NULL, FLAG_HIDE},
1176 {"include", P_STRING, P_LOCAL, &sDefault.szInclude, handle_include, NULL, FLAG_HIDE},
1177 {"preexec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1178 {"exec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL, FLAG_ADVANCED},
1180 {"preexec close", P_BOOL, P_LOCAL, &sDefault.bPreexecClose, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1181 {"postexec", P_STRING, P_LOCAL, &sDefault.szPostExec, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1182 {"root preexec", P_STRING, P_LOCAL, &sDefault.szRootPreExec, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1183 {"root preexec close", P_BOOL, P_LOCAL, &sDefault.bRootpreexecClose, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1184 {"root postexec", P_STRING, P_LOCAL, &sDefault.szRootPostExec, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1185 {"available", P_BOOL, P_LOCAL, &sDefault.bAvailable, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1186 {"volume", P_STRING, P_LOCAL, &sDefault.volume, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE },
1187 {"fstype", P_STRING, P_LOCAL, &sDefault.fstype, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1188 {"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1189 {"wide links", P_BOOL, P_LOCAL, &sDefault.bWidelinks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1190 {"follow symlinks", P_BOOL, P_LOCAL, &sDefault.bSymlinks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1191 {"dont descend", P_STRING, P_LOCAL, &sDefault.szDontdescend, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1192 {"magic script", P_STRING, P_LOCAL, &sDefault.szMagicScript, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1193 {"magic output", P_STRING, P_LOCAL, &sDefault.szMagicOutput, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1194 {"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1195 {"dos filemode", P_BOOL, P_LOCAL, &sDefault.bDosFilemode, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1196 {"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1197 {"dos filetime resolution", P_BOOL, P_LOCAL, &sDefault.bDosFiletimeResolution, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1199 {"fake directory create times", P_BOOL, P_LOCAL, &sDefault.bFakeDirCreateTimes, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1200 {"panic action", P_STRING, P_GLOBAL, &Globals.szPanicAction, NULL, NULL, FLAG_ADVANCED},
1202 {N_("VFS module options"), P_SEP, P_SEPARATOR},
1204 {"vfs objects", P_LIST, P_LOCAL, &sDefault.szVfsObjects, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1205 {"vfs object", P_LIST, P_LOCAL, &sDefault.szVfsObjects, NULL, NULL, FLAG_HIDE},
1208 {"msdfs root", P_BOOL, P_LOCAL, &sDefault.bMSDfsRoot, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1209 {"msdfs proxy", P_STRING, P_LOCAL, &sDefault.szMSDfsProxy, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1210 {"host msdfs", P_BOOL, P_GLOBAL, &Globals.bHostMSDfs, NULL, NULL, FLAG_ADVANCED},
1212 {N_("Winbind options"), P_SEP, P_SEPARATOR},
1214 {"enable rid algorithm", P_BOOL, P_GLOBAL, &Globals.bEnableRidAlgorithm, NULL, NULL, FLAG_DEPRECATED},
1215 {"idmap backend", P_LIST, P_GLOBAL, &Globals.szIdmapBackend, NULL, NULL, FLAG_ADVANCED},
1216 {"idmap uid", P_STRING, P_GLOBAL, &Globals.szIdmapUID, handle_idmap_uid, NULL, FLAG_ADVANCED},
1217 {"winbind uid", P_STRING, P_GLOBAL, &Globals.szIdmapUID, handle_idmap_uid, NULL, FLAG_HIDE},
1218 {"idmap gid", P_STRING, P_GLOBAL, &Globals.szIdmapGID, handle_idmap_gid, NULL, FLAG_ADVANCED},
1219 {"winbind gid", P_STRING, P_GLOBAL, &Globals.szIdmapGID, handle_idmap_gid, NULL, FLAG_HIDE},
1220 {"template primary group", P_STRING, P_GLOBAL, &Globals.szTemplatePrimaryGroup, NULL, NULL, FLAG_ADVANCED},
1221 {"template homedir", P_STRING, P_GLOBAL, &Globals.szTemplateHomedir, NULL, NULL, FLAG_ADVANCED},
1222 {"template shell", P_STRING, P_GLOBAL, &Globals.szTemplateShell, NULL, NULL, FLAG_ADVANCED},
1223 {"winbind separator", P_STRING, P_GLOBAL, &Globals.szWinbindSeparator, NULL, NULL, FLAG_ADVANCED},
1224 {"winbind cache time", P_INTEGER, P_GLOBAL, &Globals.winbind_cache_time, NULL, NULL, FLAG_ADVANCED},
1225 {"winbind enable local accounts", P_BOOL, P_GLOBAL, &Globals.bWinbindEnableLocalAccounts, NULL, NULL, FLAG_ADVANCED|FLAG_DEPRECATED},
1226 {"winbind enum users", P_BOOL, P_GLOBAL, &Globals.bWinbindEnumUsers, NULL, NULL, FLAG_ADVANCED},
1227 {"winbind enum groups", P_BOOL, P_GLOBAL, &Globals.bWinbindEnumGroups, NULL, NULL, FLAG_ADVANCED},
1228 {"winbind use default domain", P_BOOL, P_GLOBAL, &Globals.bWinbindUseDefaultDomain, NULL, NULL, FLAG_ADVANCED},
1229 {"winbind trusted domains only", P_BOOL, P_GLOBAL, &Globals.bWinbindTrustedDomainsOnly, NULL, NULL, FLAG_ADVANCED},
1230 {"winbind nested groups", P_BOOL, P_GLOBAL, &Globals.bWinbindNestedGroups, NULL, NULL, FLAG_ADVANCED},
1232 {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
1235 /***************************************************************************
1236 Initialise the sDefault parameter structure for the printer values.
1237 ***************************************************************************/
1239 static void init_printer_values(service *pService)
1241 /* choose defaults depending on the type of printing */
1242 switch (pService->iPrinting) {
1243 case PRINT_BSD:
1244 case PRINT_AIX:
1245 case PRINT_LPRNT:
1246 case PRINT_LPROS2:
1247 string_set(&pService->szLpqcommand, "lpq -P'%p'");
1248 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
1249 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
1250 break;
1252 case PRINT_LPRNG:
1253 case PRINT_PLP:
1254 string_set(&pService->szLpqcommand, "lpq -P'%p'");
1255 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
1256 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
1257 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
1258 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
1259 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
1260 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
1261 break;
1263 case PRINT_CUPS:
1264 #ifdef HAVE_CUPS
1265 /* set the lpq command to contain the destination printer
1266 name only. This is used by cups_queue_get() */
1267 string_set(&pService->szLpqcommand, "%p");
1268 string_set(&pService->szLprmcommand, "");
1269 string_set(&pService->szPrintcommand, "");
1270 string_set(&pService->szLppausecommand, "");
1271 string_set(&pService->szLpresumecommand, "");
1272 string_set(&pService->szQueuepausecommand, "");
1273 string_set(&pService->szQueueresumecommand, "");
1274 #else
1275 string_set(&pService->szLpqcommand, "lpq -P'%p'");
1276 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
1277 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
1278 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
1279 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
1280 string_set(&pService->szQueuepausecommand, "disable '%p'");
1281 string_set(&pService->szQueueresumecommand, "enable '%p'");
1282 #endif /* HAVE_CUPS */
1283 break;
1285 case PRINT_SYSV:
1286 case PRINT_HPUX:
1287 string_set(&pService->szLpqcommand, "lpstat -o%p");
1288 string_set(&pService->szLprmcommand, "cancel %p-%j");
1289 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
1290 string_set(&pService->szQueuepausecommand, "disable %p");
1291 string_set(&pService->szQueueresumecommand, "enable %p");
1292 #ifndef HPUX
1293 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
1294 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
1295 #endif /* HPUX */
1296 break;
1298 case PRINT_QNX:
1299 string_set(&pService->szLpqcommand, "lpq -P%p");
1300 string_set(&pService->szLprmcommand, "lprm -P%p %j");
1301 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
1302 break;
1304 #ifdef DEVELOPER
1305 case PRINT_TEST:
1306 case PRINT_VLP:
1307 string_set(&pService->szPrintcommand, "vlp print %p %s");
1308 string_set(&pService->szLpqcommand, "vlp lpq %p");
1309 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
1310 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
1311 string_set(&pService->szLpresumecommand, "vlp lpresum %p %j");
1312 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
1313 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
1314 break;
1315 #endif /* DEVELOPER */
1320 /***************************************************************************
1321 Initialise the global parameter structure.
1322 ***************************************************************************/
1324 static void init_globals(void)
1326 static BOOL done_init = False;
1327 pstring s;
1329 if (!done_init) {
1330 int i;
1332 /* The logfile can be set before this is invoked. Free it if so. */
1333 if (Globals.szLogFile != NULL) {
1334 string_free(&Globals.szLogFile);
1335 Globals.szLogFile = NULL;
1338 memset((void *)&Globals, '\0', sizeof(Globals));
1340 for (i = 0; parm_table[i].label; i++)
1341 if ((parm_table[i].type == P_STRING ||
1342 parm_table[i].type == P_USTRING) &&
1343 parm_table[i].ptr)
1344 string_set(parm_table[i].ptr, "");
1346 string_set(&sDefault.fstype, FSTYPE_STRING);
1348 init_printer_values(&sDefault);
1350 done_init = True;
1354 DEBUG(3, ("Initialising global parameters\n"));
1356 string_set(&Globals.szSMBPasswdFile, dyn_SMB_PASSWD_FILE);
1357 string_set(&Globals.szPrivateDir, dyn_PRIVATE_DIR);
1359 /* use the new 'hash2' method by default, with a prefix of 1 */
1360 string_set(&Globals.szManglingMethod, "hash2");
1361 Globals.mangle_prefix = 1;
1363 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
1365 /* using UTF8 by default allows us to support all chars */
1366 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
1368 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
1369 /* If the system supports nl_langinfo(), try to grab the value
1370 from the user's locale */
1371 string_set(&Globals.display_charset, "LOCALE");
1372 #else
1373 string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
1374 #endif
1376 /* Use codepage 850 as a default for the dos character set */
1377 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
1380 * Allow the default PASSWD_CHAT to be overridden in local.h.
1382 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
1384 set_global_myname(myhostname());
1385 string_set(&Globals.szNetbiosName,global_myname());
1387 set_global_myworkgroup(WORKGROUP);
1388 string_set(&Globals.szWorkgroup, lp_workgroup());
1390 string_set(&Globals.szPasswdProgram, "");
1391 string_set(&Globals.szPidDir, dyn_PIDDIR);
1392 string_set(&Globals.szLockDir, dyn_LOCKDIR);
1393 string_set(&Globals.szSocketAddress, "0.0.0.0");
1394 pstrcpy(s, "Samba ");
1395 pstrcat(s, SAMBA_VERSION_STRING);
1396 string_set(&Globals.szServerString, s);
1397 slprintf(s, sizeof(s) - 1, "%d.%d", DEFAULT_MAJOR_VERSION,
1398 DEFAULT_MINOR_VERSION);
1399 string_set(&Globals.szAnnounceVersion, s);
1401 pstrcpy(user_socket_options, DEFAULT_SOCKET_OPTIONS);
1403 string_set(&Globals.szLogonDrive, "");
1404 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
1405 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
1406 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
1408 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
1409 string_set(&Globals.szPasswordServer, "*");
1411 Globals.AlgorithmicRidBase = BASE_RID;
1413 Globals.bLoadPrinters = True;
1414 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
1415 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
1416 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
1417 Globals.max_xmit = 0x4104;
1418 Globals.max_mux = 50; /* This is *needed* for profile support. */
1419 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
1420 Globals.bDisableSpoolss = False;
1421 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
1422 Globals.pwordlevel = 0;
1423 Globals.unamelevel = 0;
1424 Globals.deadtime = 0;
1425 Globals.bLargeReadwrite = True;
1426 Globals.max_log_size = 5000;
1427 Globals.max_open_files = MAX_OPEN_FILES;
1428 Globals.maxprotocol = PROTOCOL_NT1;
1429 Globals.minprotocol = PROTOCOL_CORE;
1430 Globals.security = SEC_USER;
1431 Globals.paranoid_server_security = True;
1432 Globals.bEncryptPasswords = True;
1433 Globals.bUpdateEncrypt = False;
1434 Globals.clientSchannel = Auto;
1435 Globals.serverSchannel = Auto;
1436 Globals.bReadRaw = True;
1437 Globals.bWriteRaw = True;
1438 Globals.bReadbmpx = False;
1439 Globals.bNullPasswords = False;
1440 Globals.bObeyPamRestrictions = False;
1441 Globals.syslog = 1;
1442 Globals.bSyslogOnly = False;
1443 Globals.bTimestampLogs = True;
1444 string_set(&Globals.szLogLevel, "0");
1445 Globals.bDebugHiresTimestamp = False;
1446 Globals.bDebugPid = False;
1447 Globals.bDebugUid = False;
1448 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
1449 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
1450 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
1451 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
1452 Globals.change_notify_timeout = 60; /* 1 minute default. */
1453 Globals.bKernelChangeNotify = True; /* On if we have it. */
1454 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
1455 Globals.lm_interval = 60;
1456 Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
1457 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
1458 Globals.bNISHomeMap = False;
1459 #ifdef WITH_NISPLUS_HOME
1460 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
1461 #else
1462 string_set(&Globals.szNISHomeMapName, "auto.home");
1463 #endif
1464 #endif
1465 Globals.bTimeServer = False;
1466 Globals.bBindInterfacesOnly = False;
1467 Globals.bUnixPasswdSync = False;
1468 Globals.bPamPasswordChange = False;
1469 Globals.bPasswdChatDebug = False;
1470 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
1471 Globals.bNTPipeSupport = True; /* Do NT pipes by default. */
1472 Globals.bNTStatusSupport = True; /* Use NT status by default. */
1473 Globals.bStatCache = True; /* use stat cache by default */
1474 Globals.iMaxStatCacheSize = 0; /* unlimited size in kb by default. */
1475 Globals.restrict_anonymous = 0;
1476 Globals.bClientLanManAuth = True; /* Do use the LanMan hash if it is available */
1477 Globals.bClientPlaintextAuth = True; /* Do use a plaintext password if is requested by the server */
1478 Globals.bLanmanAuth = True; /* Do use the LanMan hash if it is available */
1479 Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is available (otherwise NTLMv2) */
1480 Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
1481 /* Note, that we will use NTLM2 session security (which is different), if it is available */
1483 Globals.map_to_guest = 0; /* By Default, "Never" */
1484 Globals.min_passwd_length = MINPASSWDLENGTH; /* By Default, 5. */
1485 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
1486 Globals.enhanced_browsing = True;
1487 Globals.iLockSpinCount = 3; /* Try 3 times. */
1488 Globals.iLockSpinTime = 10; /* usec. */
1489 #ifdef MMAP_BLACKLIST
1490 Globals.bUseMmap = False;
1491 #else
1492 Globals.bUseMmap = True;
1493 #endif
1494 Globals.bUnixExtensions = True;
1496 /* hostname lookups can be very expensive and are broken on
1497 a large number of sites (tridge) */
1498 Globals.bHostnameLookups = False;
1500 str_list_free(&Globals.szPassdbBackend);
1501 #ifdef WITH_LDAP_SAMCONFIG
1502 string_set(&Globals.szLdapServer, "localhost");
1503 Globals.ldap_port = 636;
1504 Globals.szPassdbBackend = str_list_make("ldapsam_compat", NULL);
1505 #else
1506 Globals.szPassdbBackend = str_list_make("smbpasswd", NULL);
1507 #endif /* WITH_LDAP_SAMCONFIG */
1509 string_set(&Globals.szLdapSuffix, "");
1510 string_set(&Globals.szLdapFilter, "(uid=%u)");
1511 string_set(&Globals.szLdapMachineSuffix, "");
1512 string_set(&Globals.szLdapUserSuffix, "");
1513 string_set(&Globals.szLdapGroupSuffix, "");
1514 string_set(&Globals.szLdapIdmapSuffix, "");
1516 string_set(&Globals.szLdapAdminDn, "");
1517 Globals.ldap_ssl = LDAP_SSL_ON;
1518 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
1519 Globals.ldap_delete_dn = False;
1520 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
1521 Globals.ldap_timeout = LDAP_CONNECT_DEFAULT_TIMEOUT;
1522 Globals.ldap_page_size = LDAP_PAGE_SIZE;
1524 /* This is what we tell the afs client. in reality we set the token
1525 * to never expire, though, when this runs out the afs client will
1526 * forget the token. Set to 0 to get NEVERDATE.*/
1527 Globals.iAfsTokenLifetime = 604800;
1529 /* these parameters are set to defaults that are more appropriate
1530 for the increasing samba install base:
1532 as a member of the workgroup, that will possibly become a
1533 _local_ master browser (lm = True). this is opposed to a forced
1534 local master browser startup (pm = True).
1536 doesn't provide WINS server service by default (wsupp = False),
1537 and doesn't provide domain master browser services by default, either.
1541 Globals.bMsAddPrinterWizard = True;
1542 Globals.bPreferredMaster = Auto; /* depending on bDomainMaster */
1543 Globals.os_level = 20;
1544 Globals.bLocalMaster = True;
1545 Globals.bDomainMaster = Auto; /* depending on bDomainLogons */
1546 Globals.bDomainLogons = False;
1547 Globals.bBrowseList = True;
1548 Globals.bWINSsupport = False;
1549 Globals.bWINSproxy = False;
1551 Globals.bDNSproxy = True;
1553 /* this just means to use them if they exist */
1554 Globals.bKernelOplocks = True;
1556 Globals.bAllowTrustedDomains = True;
1558 string_set(&Globals.szTemplateShell, "/bin/false");
1559 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
1560 string_set(&Globals.szTemplatePrimaryGroup, "nobody");
1561 string_set(&Globals.szWinbindSeparator, "\\");
1562 string_set(&Globals.szAclCompat, "");
1563 string_set(&Globals.szCupsServer, "");
1565 string_set(&Globals.szEventLogOpenCommand, "");
1566 string_set(&Globals.szEventLogReadCommand, "");
1567 string_set(&Globals.szEventLogClearCommand, "");
1568 string_set(&Globals.szEventLogNumRecordsCommand, "");
1569 string_set(&Globals.szEventLogOldestRecordCommand, "");
1571 Globals.winbind_cache_time = 300; /* 5 minutes */
1572 Globals.bWinbindEnableLocalAccounts = False;
1573 Globals.bWinbindEnumUsers = True;
1574 Globals.bWinbindEnumGroups = True;
1575 Globals.bWinbindUseDefaultDomain = False;
1576 Globals.bWinbindTrustedDomainsOnly = False;
1577 Globals.bWinbindNestedGroups = False;
1579 Globals.bEnableRidAlgorithm = True;
1581 Globals.name_cache_timeout = 660; /* In seconds */
1583 Globals.bUseSpnego = True;
1584 Globals.bClientUseSpnego = True;
1586 Globals.client_signing = Auto;
1587 Globals.server_signing = False;
1589 Globals.bDeferSharingViolations = True;
1590 string_set(&Globals.smb_ports, SMB_PORTS);
1592 /* don't enable privileges by default since Domain
1593 Admins can then assign thr rights to perform certain
1594 operations as root */
1596 Globals.bEnablePrivileges = False;
1598 Globals.bASUSupport = True;
1600 Globals.szServicesList = str_list_make( "Spooler NETLOGON", NULL );
1603 static TALLOC_CTX *lp_talloc;
1605 /******************************************************************* a
1606 Free up temporary memory - called from the main loop.
1607 ********************************************************************/
1609 void lp_talloc_free(void)
1611 if (!lp_talloc)
1612 return;
1613 talloc_free(lp_talloc);
1614 lp_talloc = NULL;
1617 /*******************************************************************
1618 Convenience routine to grab string parameters into temporary memory
1619 and run standard_sub_basic on them. The buffers can be written to by
1620 callers without affecting the source string.
1621 ********************************************************************/
1623 static char *lp_string(const char *s)
1625 char *ret, *tmpstr;
1627 /* The follow debug is useful for tracking down memory problems
1628 especially if you have an inner loop that is calling a lp_*()
1629 function that returns a string. Perhaps this debug should be
1630 present all the time? */
1632 #if 0
1633 DEBUG(10, ("lp_string(%s)\n", s));
1634 #endif
1636 if (!lp_talloc)
1637 lp_talloc = talloc_init("lp_talloc");
1639 tmpstr = alloc_sub_basic(get_current_username(), s);
1640 if (trim_char(tmpstr, '\"', '\"')) {
1641 if (strchr(tmpstr,'\"') != NULL) {
1642 SAFE_FREE(tmpstr);
1643 tmpstr = alloc_sub_basic(get_current_username(),s);
1646 ret = talloc_strdup(lp_talloc, tmpstr);
1647 SAFE_FREE(tmpstr);
1649 return (ret);
1653 In this section all the functions that are used to access the
1654 parameters from the rest of the program are defined
1657 #define FN_GLOBAL_STRING(fn_name,ptr) \
1658 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
1659 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
1660 const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
1661 #define FN_GLOBAL_LIST(fn_name,ptr) \
1662 const char **fn_name(void) {return(*(const char ***)(ptr));}
1663 #define FN_GLOBAL_BOOL(fn_name,ptr) \
1664 BOOL fn_name(void) {return(*(BOOL *)(ptr));}
1665 #define FN_GLOBAL_CHAR(fn_name,ptr) \
1666 char fn_name(void) {return(*(char *)(ptr));}
1667 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
1668 int fn_name(void) {return(*(int *)(ptr));}
1670 #define FN_LOCAL_STRING(fn_name,val) \
1671 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
1672 #define FN_LOCAL_CONST_STRING(fn_name,val) \
1673 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
1674 #define FN_LOCAL_LIST(fn_name,val) \
1675 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1676 #define FN_LOCAL_BOOL(fn_name,val) \
1677 BOOL fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1678 #define FN_LOCAL_CHAR(fn_name,val) \
1679 char fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1680 #define FN_LOCAL_INTEGER(fn_name,val) \
1681 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1683 FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
1684 FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
1685 FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
1686 FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
1687 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
1688 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
1689 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
1690 FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
1691 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
1692 FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
1693 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
1694 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
1695 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
1696 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
1697 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
1698 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
1699 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
1700 FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
1701 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
1702 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
1703 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
1704 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
1705 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
1706 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
1707 FN_GLOBAL_STRING(lp_dfree_command, &Globals.szDfree)
1708 FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
1709 FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
1710 FN_GLOBAL_STRING(lp_hosts_equiv, &Globals.szHostsEquiv)
1711 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
1712 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
1713 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
1714 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
1715 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
1716 FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
1717 FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
1718 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
1719 FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
1720 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
1721 FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
1722 FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
1723 FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
1724 FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
1725 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
1726 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
1727 FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
1728 FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
1729 FN_GLOBAL_STRING(lp_socket_address, &Globals.szSocketAddress)
1730 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
1731 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
1732 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
1733 FN_GLOBAL_LIST(lp_passdb_backend, &Globals.szPassdbBackend)
1734 FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
1735 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
1736 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
1737 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
1739 FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
1740 FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
1741 FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
1742 FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
1743 FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
1744 FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
1746 FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
1748 FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
1749 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
1751 FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
1753 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
1754 FN_GLOBAL_STRING(lp_wins_partners, &Globals.szWINSPartners)
1755 FN_GLOBAL_STRING(lp_template_primary_group, &Globals.szTemplatePrimaryGroup)
1756 FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
1757 FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
1758 FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
1759 FN_GLOBAL_STRING(lp_acl_compatibility, &Globals.szAclCompat)
1760 FN_GLOBAL_BOOL(lp_winbind_enable_local_accounts, &Globals.bWinbindEnableLocalAccounts)
1761 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
1762 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
1763 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
1764 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
1765 FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
1768 FN_GLOBAL_LIST(lp_idmap_backend, &Globals.szIdmapBackend)
1769 FN_GLOBAL_BOOL(lp_enable_rid_algorithm, &Globals.bEnableRidAlgorithm)
1771 #ifdef WITH_LDAP_SAMCONFIG
1772 FN_GLOBAL_STRING(lp_ldap_server, &Globals.szLdapServer)
1773 FN_GLOBAL_INTEGER(lp_ldap_port, &Globals.ldap_port)
1774 #endif
1775 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
1776 FN_GLOBAL_STRING(lp_ldap_filter, &Globals.szLdapFilter)
1777 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
1778 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
1779 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
1780 FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
1781 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
1782 FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
1783 FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
1784 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
1785 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
1786 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
1788 FN_GLOBAL_STRING(lp_eventlog_open_cmd, &Globals.szEventLogOpenCommand)
1789 FN_GLOBAL_STRING(lp_eventlog_read_cmd, &Globals.szEventLogReadCommand)
1790 FN_GLOBAL_STRING(lp_eventlog_clear_cmd, &Globals.szEventLogClearCommand)
1791 FN_GLOBAL_STRING(lp_eventlog_num_records_cmd, &Globals.szEventLogNumRecordsCommand)
1792 FN_GLOBAL_STRING(lp_eventlog_oldest_record_cmd, &Globals.szEventLogOldestRecordCommand)
1793 FN_GLOBAL_STRING(lp_eventlog_close_cmd, &Globals.szEventLogCloseCommand)
1794 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
1796 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
1797 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
1798 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
1799 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
1800 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
1801 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
1802 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
1803 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
1804 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
1805 FN_GLOBAL_BOOL(lp_readbmpx, &Globals.bReadbmpx)
1806 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
1807 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
1808 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
1809 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
1810 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
1811 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
1812 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
1813 FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
1814 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
1815 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
1816 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
1817 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
1818 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
1819 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
1820 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
1821 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
1822 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
1823 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
1824 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
1825 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
1826 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
1827 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
1828 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
1829 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
1830 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
1831 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
1832 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
1833 FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
1834 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
1835 FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
1836 FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
1837 FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
1838 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
1839 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
1840 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
1841 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
1842 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
1843 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
1844 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
1845 FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
1846 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
1847 FN_GLOBAL_BOOL(lp_kernel_change_notify, &Globals.bKernelChangeNotify)
1848 FN_GLOBAL_BOOL(lp_use_kerberos_keytab, &Globals.bUseKerberosKeytab)
1849 FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
1850 FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
1851 FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport)
1852 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
1853 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
1854 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
1855 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
1856 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
1857 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
1858 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
1859 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
1860 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
1861 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
1862 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
1863 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
1864 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
1865 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
1866 FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
1867 FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
1868 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
1869 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
1870 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
1871 FN_GLOBAL_INTEGER(lp_disable_spoolss, &Globals.bDisableSpoolss)
1872 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
1873 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
1874 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
1875 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
1876 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
1877 FN_GLOBAL_INTEGER(lp_change_notify_timeout, &Globals.change_notify_timeout)
1878 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
1879 FN_GLOBAL_INTEGER(lp_min_passwd_length, &Globals.min_passwd_length)
1880 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
1881 FN_GLOBAL_INTEGER(lp_lock_spin_count, &Globals.iLockSpinCount)
1882 FN_GLOBAL_INTEGER(lp_lock_sleep_time, &Globals.iLockSpinTime)
1883 FN_LOCAL_STRING(lp_preexec, szPreExec)
1884 FN_LOCAL_STRING(lp_postexec, szPostExec)
1885 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
1886 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
1887 FN_LOCAL_STRING(lp_servicename, szService)
1888 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
1889 FN_LOCAL_STRING(lp_pathname, szPath)
1890 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
1891 FN_LOCAL_STRING(lp_username, szUsername)
1892 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
1893 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
1894 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
1895 FN_GLOBAL_LIST(lp_enable_svcctl, &Globals.szServicesList)
1896 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
1897 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
1898 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
1899 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
1900 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
1901 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
1902 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
1903 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
1904 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
1905 static FN_LOCAL_STRING(_lp_printername, szPrintername)
1906 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
1907 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
1908 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
1909 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
1910 FN_LOCAL_STRING(lp_comment, comment)
1911 FN_LOCAL_STRING(lp_force_user, force_user)
1912 FN_LOCAL_STRING(lp_force_group, force_group)
1913 FN_LOCAL_LIST(lp_readlist, readlist)
1914 FN_LOCAL_LIST(lp_writelist, writelist)
1915 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
1916 FN_LOCAL_STRING(lp_fstype, fstype)
1917 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
1918 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
1919 static FN_LOCAL_STRING(lp_volume, volume)
1920 FN_LOCAL_STRING(lp_mangled_map, szMangledMap)
1921 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
1922 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
1923 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
1924 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
1925 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
1926 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
1927 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
1928 FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
1929 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
1930 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
1931 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
1932 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
1933 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
1934 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
1935 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
1936 FN_LOCAL_BOOL(lp_readonly, bRead_only)
1937 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
1938 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
1939 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
1940 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
1941 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
1942 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
1943 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
1944 FN_LOCAL_BOOL(lp_locking, bLocking)
1945 FN_LOCAL_INTEGER(lp_strict_locking, iStrictLocking)
1946 FN_LOCAL_BOOL(lp_posix_locking, bPosixLocking)
1947 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
1948 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
1949 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
1950 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
1951 FN_LOCAL_BOOL(lp_manglednames, bMangledNames)
1952 FN_LOCAL_BOOL(lp_widelinks, bWidelinks)
1953 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
1954 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
1955 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
1956 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
1957 FN_LOCAL_BOOL(lp_map_system, bMap_system)
1958 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
1959 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
1960 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
1961 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
1962 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
1963 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
1964 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
1965 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
1966 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
1967 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
1968 FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
1969 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
1970 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
1971 FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
1972 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
1973 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
1974 FN_LOCAL_BOOL(lp_ea_support, bEASupport)
1975 FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
1976 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
1977 FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
1978 FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
1979 FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
1980 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
1981 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
1982 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
1983 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
1984 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
1985 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
1986 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
1987 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
1988 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
1989 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
1990 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
1991 FN_LOCAL_INTEGER(lp_printing, iPrinting)
1992 FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
1993 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
1994 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
1995 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
1996 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
1997 FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size);
1998 FN_LOCAL_CHAR(lp_magicchar, magic_char)
1999 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
2000 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
2001 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
2002 FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
2003 FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
2005 /* local prototypes */
2007 static int map_parameter(const char *pszParmName);
2008 static BOOL set_boolean(BOOL *pb, const char *pszParmValue);
2009 static int getservicebyname(const char *pszServiceName,
2010 service * pserviceDest);
2011 static void copy_service(service * pserviceDest,
2012 service * pserviceSource, BOOL *pcopymapDest);
2013 static BOOL service_ok(int iService);
2014 static BOOL do_parameter(const char *pszParmName, const char *pszParmValue);
2015 static BOOL do_section(const char *pszSectionName);
2016 static void init_copymap(service * pservice);
2018 /* This is a helper function for parametrical options support. */
2019 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
2020 /* Actual parametrical functions are quite simple */
2021 static param_opt_struct *get_parametrics(int snum, const char *type, const char *option)
2023 BOOL global_section = False;
2024 char* param_key;
2025 param_opt_struct *data;
2027 if (snum >= iNumServices) return NULL;
2029 if (snum < 0) {
2030 data = Globals.param_opt;
2031 global_section = True;
2032 } else {
2033 data = ServicePtrs[snum]->param_opt;
2036 asprintf(&param_key, "%s:%s", type, option);
2037 if (!param_key) {
2038 DEBUG(0,("asprintf failed!\n"));
2039 return NULL;
2042 while (data) {
2043 if (strcmp(data->key, param_key) == 0) {
2044 string_free(&param_key);
2045 return data;
2047 data = data->next;
2050 if (!global_section) {
2051 /* Try to fetch the same option but from globals */
2052 /* but only if we are not already working with Globals */
2053 data = Globals.param_opt;
2054 while (data) {
2055 if (strcmp(data->key, param_key) == 0) {
2056 string_free(&param_key);
2057 return data;
2059 data = data->next;
2063 string_free(&param_key);
2065 return NULL;
2069 /*******************************************************************
2070 convenience routine to return int parameters.
2071 ********************************************************************/
2072 static int lp_int(const char *s)
2075 if (!s) {
2076 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
2077 return (-1);
2080 return atoi(s);
2083 /*******************************************************************
2084 convenience routine to return unsigned long parameters.
2085 ********************************************************************/
2086 static int lp_ulong(const char *s)
2089 if (!s) {
2090 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
2091 return (-1);
2094 return strtoul(s, NULL, 10);
2097 /*******************************************************************
2098 convenience routine to return boolean parameters.
2099 ********************************************************************/
2100 static BOOL lp_bool(const char *s)
2102 BOOL ret = False;
2104 if (!s) {
2105 DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
2106 return False;
2109 if (!set_boolean(&ret,s)) {
2110 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
2111 return False;
2114 return ret;
2117 /*******************************************************************
2118 convenience routine to return enum parameters.
2119 ********************************************************************/
2120 static int lp_enum(const char *s,const struct enum_list *_enum)
2122 int i;
2124 if (!s || !_enum) {
2125 DEBUG(0,("lp_enum(%s,enum): is called with NULL!\n",s));
2126 return (-1);
2129 for (i=0; _enum[i].name; i++) {
2130 if (strequal(_enum[i].name,s))
2131 return _enum[i].value;
2134 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
2135 return (-1);
2139 /* DO NOT USE lp_parm_string ANYMORE!!!!
2140 * use lp_parm_const_string or lp_parm_talloc_string
2142 * lp_parm_string is only used to let old modules find this symbol
2144 #undef lp_parm_string
2145 char *lp_parm_string(const char *servicename, const char *type, const char *option)
2147 return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
2150 /* Return parametric option from a given service. Type is a part of option before ':' */
2151 /* Parametric option has following syntax: 'Type: option = value' */
2152 /* the returned value is talloced in lp_talloc */
2153 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
2155 param_opt_struct *data = get_parametrics(snum, type, option);
2157 if (data == NULL||data->value==NULL) {
2158 if (def) {
2159 return lp_string(def);
2160 } else {
2161 return NULL;
2165 return lp_string(data->value);
2168 /* Return parametric option from a given service. Type is a part of option before ':' */
2169 /* Parametric option has following syntax: 'Type: option = value' */
2170 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
2172 param_opt_struct *data = get_parametrics(snum, type, option);
2174 if (data == NULL||data->value==NULL)
2175 return def;
2177 return data->value;
2180 /* Return parametric option from a given service. Type is a part of option before ':' */
2181 /* Parametric option has following syntax: 'Type: option = value' */
2183 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
2185 param_opt_struct *data = get_parametrics(snum, type, option);
2187 if (data == NULL||data->value==NULL)
2188 return (const char **)def;
2190 if (data->list==NULL) {
2191 data->list = str_list_make(data->value, NULL);
2194 return (const char **)data->list;
2197 /* Return parametric option from a given service. Type is a part of option before ':' */
2198 /* Parametric option has following syntax: 'Type: option = value' */
2200 int lp_parm_int(int snum, const char *type, const char *option, int def)
2202 param_opt_struct *data = get_parametrics(snum, type, option);
2204 if (data && data->value && *data->value)
2205 return lp_int(data->value);
2207 return def;
2210 /* Return parametric option from a given service. Type is a part of option before ':' */
2211 /* Parametric option has following syntax: 'Type: option = value' */
2213 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
2215 param_opt_struct *data = get_parametrics(snum, type, option);
2217 if (data && data->value && *data->value)
2218 return lp_ulong(data->value);
2220 return def;
2223 /* Return parametric option from a given service. Type is a part of option before ':' */
2224 /* Parametric option has following syntax: 'Type: option = value' */
2226 BOOL lp_parm_bool(int snum, const char *type, const char *option, BOOL def)
2228 param_opt_struct *data = get_parametrics(snum, type, option);
2230 if (data && data->value && *data->value)
2231 return lp_bool(data->value);
2233 return def;
2236 /* Return parametric option from a given service. Type is a part of option before ':' */
2237 /* Parametric option has following syntax: 'Type: option = value' */
2239 int lp_parm_enum(int snum, const char *type, const char *option,
2240 const struct enum_list *_enum, int def)
2242 param_opt_struct *data = get_parametrics(snum, type, option);
2244 if (data && data->value && *data->value && _enum)
2245 return lp_enum(data->value, _enum);
2247 return def;
2251 /***************************************************************************
2252 Initialise a service to the defaults.
2253 ***************************************************************************/
2255 static void init_service(service * pservice)
2257 memset((char *)pservice, '\0', sizeof(service));
2258 copy_service(pservice, &sDefault, NULL);
2261 /***************************************************************************
2262 Free the dynamically allocated parts of a service struct.
2263 ***************************************************************************/
2265 static void free_service(service *pservice)
2267 int i;
2268 param_opt_struct *data, *pdata;
2269 if (!pservice)
2270 return;
2272 if (pservice->szService)
2273 DEBUG(5, ("free_service: Freeing service %s\n",
2274 pservice->szService));
2276 string_free(&pservice->szService);
2277 SAFE_FREE(pservice->copymap);
2279 for (i = 0; parm_table[i].label; i++) {
2280 if ((parm_table[i].type == P_STRING ||
2281 parm_table[i].type == P_USTRING) &&
2282 parm_table[i].class == P_LOCAL)
2283 string_free((char **)
2284 (((char *)pservice) +
2285 PTR_DIFF(parm_table[i].ptr, &sDefault)));
2286 else if (parm_table[i].type == P_LIST &&
2287 parm_table[i].class == P_LOCAL)
2288 str_list_free((char ***)
2289 (((char *)pservice) +
2290 PTR_DIFF(parm_table[i].ptr, &sDefault)));
2293 data = pservice->param_opt;
2294 if (data)
2295 DEBUG(5,("Freeing parametrics:\n"));
2296 while (data) {
2297 DEBUG(5,("[%s = %s]\n", data->key, data->value));
2298 string_free(&data->key);
2299 string_free(&data->value);
2300 str_list_free(&data->list);
2301 pdata = data->next;
2302 SAFE_FREE(data);
2303 data = pdata;
2306 ZERO_STRUCTP(pservice);
2309 /***************************************************************************
2310 Add a new service to the services array initialising it with the given
2311 service.
2312 ***************************************************************************/
2314 static int add_a_service(const service *pservice, const char *name)
2316 int i;
2317 service tservice;
2318 int num_to_alloc = iNumServices + 1;
2319 param_opt_struct *data, *pdata;
2321 tservice = *pservice;
2323 /* it might already exist */
2324 if (name) {
2325 i = getservicebyname(name, NULL);
2326 if (i >= 0) {
2327 /* Clean all parametric options for service */
2328 /* They will be added during parsing again */
2329 data = ServicePtrs[i]->param_opt;
2330 while (data) {
2331 string_free(&data->key);
2332 string_free(&data->value);
2333 str_list_free(&data->list);
2334 pdata = data->next;
2335 SAFE_FREE(data);
2336 data = pdata;
2338 ServicePtrs[i]->param_opt = NULL;
2339 return (i);
2343 /* find an invalid one */
2344 for (i = 0; i < iNumServices; i++)
2345 if (!ServicePtrs[i]->valid)
2346 break;
2348 /* if not, then create one */
2349 if (i == iNumServices) {
2350 service **tsp;
2352 tsp = SMB_REALLOC_ARRAY(ServicePtrs, service *, num_to_alloc);
2354 if (!tsp) {
2355 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
2356 return (-1);
2358 else {
2359 ServicePtrs = tsp;
2360 ServicePtrs[iNumServices] = SMB_MALLOC_P(service);
2362 if (!ServicePtrs[iNumServices]) {
2363 DEBUG(0,("add_a_service: out of memory!\n"));
2364 return (-1);
2367 iNumServices++;
2368 } else
2369 free_service(ServicePtrs[i]);
2371 ServicePtrs[i]->valid = True;
2373 init_service(ServicePtrs[i]);
2374 copy_service(ServicePtrs[i], &tservice, NULL);
2375 if (name)
2376 string_set(&ServicePtrs[i]->szService, name);
2378 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
2379 i, ServicePtrs[i]->szService));
2381 return (i);
2384 /***************************************************************************
2385 Add a new home service, with the specified home directory, defaults coming
2386 from service ifrom.
2387 ***************************************************************************/
2389 BOOL lp_add_home(const char *pszHomename, int iDefaultService,
2390 const char *user, const char *pszHomedir)
2392 int i;
2393 pstring newHomedir;
2395 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
2397 if (i < 0)
2398 return (False);
2400 if (!(*(ServicePtrs[iDefaultService]->szPath))
2401 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
2402 pstrcpy(newHomedir, pszHomedir);
2403 string_set(&ServicePtrs[i]->szPath, newHomedir);
2406 if (!(*(ServicePtrs[i]->comment))) {
2407 pstring comment;
2408 slprintf(comment, sizeof(comment) - 1,
2409 "Home directory of %s", user);
2410 string_set(&ServicePtrs[i]->comment, comment);
2413 /* set the browseable flag from the gloabl default */
2415 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
2417 ServicePtrs[i]->autoloaded = True;
2419 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
2420 user, ServicePtrs[i]->szPath ));
2422 return (True);
2425 /***************************************************************************
2426 Add a new service, based on an old one.
2427 ***************************************************************************/
2429 int lp_add_service(const char *pszService, int iDefaultService)
2431 return (add_a_service(ServicePtrs[iDefaultService], pszService));
2434 /***************************************************************************
2435 Add the IPC service.
2436 ***************************************************************************/
2438 static BOOL lp_add_ipc(const char *ipc_name, BOOL guest_ok)
2440 pstring comment;
2441 int i = add_a_service(&sDefault, ipc_name);
2443 if (i < 0)
2444 return (False);
2446 slprintf(comment, sizeof(comment) - 1,
2447 "IPC Service (%s)", Globals.szServerString);
2449 string_set(&ServicePtrs[i]->szPath, tmpdir());
2450 string_set(&ServicePtrs[i]->szUsername, "");
2451 string_set(&ServicePtrs[i]->comment, comment);
2452 string_set(&ServicePtrs[i]->fstype, "IPC");
2453 ServicePtrs[i]->iMaxConnections = 0;
2454 ServicePtrs[i]->bAvailable = True;
2455 ServicePtrs[i]->bRead_only = True;
2456 ServicePtrs[i]->bGuest_only = False;
2457 ServicePtrs[i]->bGuest_ok = guest_ok;
2458 ServicePtrs[i]->bPrint_ok = False;
2459 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
2461 DEBUG(3, ("adding IPC service\n"));
2463 return (True);
2466 /***************************************************************************
2467 Add a new printer service, with defaults coming from service iFrom.
2468 ***************************************************************************/
2470 BOOL lp_add_printer(const char *pszPrintername, int iDefaultService)
2472 const char *comment = "From Printcap";
2473 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
2475 if (i < 0)
2476 return (False);
2478 /* note that we do NOT default the availability flag to True - */
2479 /* we take it from the default service passed. This allows all */
2480 /* dynamic printers to be disabled by disabling the [printers] */
2481 /* entry (if/when the 'available' keyword is implemented!). */
2483 /* the printer name is set to the service name. */
2484 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
2485 string_set(&ServicePtrs[i]->comment, comment);
2487 /* set the browseable flag from the gloabl default */
2488 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
2490 /* Printers cannot be read_only. */
2491 ServicePtrs[i]->bRead_only = False;
2492 /* No share modes on printer services. */
2493 ServicePtrs[i]->bShareModes = False;
2494 /* No oplocks on printer services. */
2495 ServicePtrs[i]->bOpLocks = False;
2496 /* Printer services must be printable. */
2497 ServicePtrs[i]->bPrint_ok = True;
2499 DEBUG(3, ("adding printer service %s\n", pszPrintername));
2501 return (True);
2504 /***************************************************************************
2505 Map a parameter's string representation to something we can use.
2506 Returns False if the parameter string is not recognised, else TRUE.
2507 ***************************************************************************/
2509 static int map_parameter(const char *pszParmName)
2511 int iIndex;
2513 if (*pszParmName == '-')
2514 return (-1);
2516 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
2517 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
2518 return (iIndex);
2520 /* Warn only if it isn't parametric option */
2521 if (strchr(pszParmName, ':') == NULL)
2522 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
2523 /* We do return 'fail' for parametric options as well because they are
2524 stored in different storage
2526 return (-1);
2529 /***************************************************************************
2530 Set a boolean variable from the text value stored in the passed string.
2531 Returns True in success, False if the passed string does not correctly
2532 represent a boolean.
2533 ***************************************************************************/
2535 static BOOL set_boolean(BOOL *pb, const char *pszParmValue)
2537 BOOL bRetval;
2539 bRetval = True;
2540 if (strwicmp(pszParmValue, "yes") == 0 ||
2541 strwicmp(pszParmValue, "true") == 0 ||
2542 strwicmp(pszParmValue, "1") == 0)
2543 *pb = True;
2544 else if (strwicmp(pszParmValue, "no") == 0 ||
2545 strwicmp(pszParmValue, "False") == 0 ||
2546 strwicmp(pszParmValue, "0") == 0)
2547 *pb = False;
2548 else {
2549 DEBUG(0,
2550 ("ERROR: Badly formed boolean in configuration file: \"%s\".\n",
2551 pszParmValue));
2552 bRetval = False;
2554 return (bRetval);
2557 /***************************************************************************
2558 Find a service by name. Otherwise works like get_service.
2559 ***************************************************************************/
2561 static int getservicebyname(const char *pszServiceName, service * pserviceDest)
2563 int iService;
2565 for (iService = iNumServices - 1; iService >= 0; iService--)
2566 if (VALID(iService) &&
2567 strwicmp(ServicePtrs[iService]->szService, pszServiceName) == 0) {
2568 if (pserviceDest != NULL)
2569 copy_service(pserviceDest, ServicePtrs[iService], NULL);
2570 break;
2573 return (iService);
2576 /***************************************************************************
2577 Copy a service structure to another.
2578 If pcopymapDest is NULL then copy all fields
2579 ***************************************************************************/
2581 static void copy_service(service * pserviceDest, service * pserviceSource, BOOL *pcopymapDest)
2583 int i;
2584 BOOL bcopyall = (pcopymapDest == NULL);
2585 param_opt_struct *data, *pdata, *paramo;
2586 BOOL not_added;
2588 for (i = 0; parm_table[i].label; i++)
2589 if (parm_table[i].ptr && parm_table[i].class == P_LOCAL &&
2590 (bcopyall || pcopymapDest[i])) {
2591 void *def_ptr = parm_table[i].ptr;
2592 void *src_ptr =
2593 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
2594 &sDefault);
2595 void *dest_ptr =
2596 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
2597 &sDefault);
2599 switch (parm_table[i].type) {
2600 case P_BOOL:
2601 case P_BOOLREV:
2602 *(BOOL *)dest_ptr = *(BOOL *)src_ptr;
2603 break;
2605 case P_INTEGER:
2606 case P_ENUM:
2607 case P_OCTAL:
2608 *(int *)dest_ptr = *(int *)src_ptr;
2609 break;
2611 case P_CHAR:
2612 *(char *)dest_ptr = *(char *)src_ptr;
2613 break;
2615 case P_STRING:
2616 string_set(dest_ptr,
2617 *(char **)src_ptr);
2618 break;
2620 case P_USTRING:
2621 string_set(dest_ptr,
2622 *(char **)src_ptr);
2623 strupper_m(*(char **)dest_ptr);
2624 break;
2625 case P_LIST:
2626 str_list_free((char ***)dest_ptr);
2627 str_list_copy((char ***)dest_ptr, *(const char ***)src_ptr);
2628 break;
2629 default:
2630 break;
2634 if (bcopyall) {
2635 init_copymap(pserviceDest);
2636 if (pserviceSource->copymap)
2637 memcpy((void *)pserviceDest->copymap,
2638 (void *)pserviceSource->copymap,
2639 sizeof(BOOL) * NUMPARAMETERS);
2642 data = pserviceSource->param_opt;
2643 while (data) {
2644 not_added = True;
2645 pdata = pserviceDest->param_opt;
2646 /* Traverse destination */
2647 while (pdata) {
2648 /* If we already have same option, override it */
2649 if (strcmp(pdata->key, data->key) == 0) {
2650 string_free(&pdata->value);
2651 str_list_free(&data->list);
2652 pdata->value = SMB_STRDUP(data->value);
2653 not_added = False;
2654 break;
2656 pdata = pdata->next;
2658 if (not_added) {
2659 paramo = SMB_XMALLOC_P(param_opt_struct);
2660 paramo->key = SMB_STRDUP(data->key);
2661 paramo->value = SMB_STRDUP(data->value);
2662 paramo->list = NULL;
2663 DLIST_ADD(pserviceDest->param_opt, paramo);
2665 data = data->next;
2669 /***************************************************************************
2670 Check a service for consistency. Return False if the service is in any way
2671 incomplete or faulty, else True.
2672 ***************************************************************************/
2674 static BOOL service_ok(int iService)
2676 BOOL bRetval;
2678 bRetval = True;
2679 if (ServicePtrs[iService]->szService[0] == '\0') {
2680 DEBUG(0, ("The following message indicates an internal error:\n"));
2681 DEBUG(0, ("No service name in service entry.\n"));
2682 bRetval = False;
2685 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
2686 /* I can't see why you'd want a non-printable printer service... */
2687 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
2688 if (!ServicePtrs[iService]->bPrint_ok) {
2689 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
2690 ServicePtrs[iService]->szService));
2691 ServicePtrs[iService]->bPrint_ok = True;
2693 /* [printers] service must also be non-browsable. */
2694 if (ServicePtrs[iService]->bBrowseable)
2695 ServicePtrs[iService]->bBrowseable = False;
2698 if (ServicePtrs[iService]->szPath[0] == '\0' &&
2699 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0) {
2700 DEBUG(0, ("No path in service %s - using %s\n",
2701 ServicePtrs[iService]->szService, tmpdir()));
2702 string_set(&ServicePtrs[iService]->szPath, tmpdir());
2705 /* If a service is flagged unavailable, log the fact at level 0. */
2706 if (!ServicePtrs[iService]->bAvailable)
2707 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
2708 ServicePtrs[iService]->szService));
2710 return (bRetval);
2713 static struct file_lists {
2714 struct file_lists *next;
2715 char *name;
2716 char *subfname;
2717 time_t modtime;
2718 } *file_lists = NULL;
2720 /*******************************************************************
2721 Keep a linked list of all config files so we know when one has changed
2722 it's date and needs to be reloaded.
2723 ********************************************************************/
2725 static void add_to_file_list(const char *fname, const char *subfname)
2727 struct file_lists *f = file_lists;
2729 while (f) {
2730 if (f->name && !strcmp(f->name, fname))
2731 break;
2732 f = f->next;
2735 if (!f) {
2736 f = SMB_MALLOC_P(struct file_lists);
2737 if (!f)
2738 return;
2739 f->next = file_lists;
2740 f->name = SMB_STRDUP(fname);
2741 if (!f->name) {
2742 SAFE_FREE(f);
2743 return;
2745 f->subfname = SMB_STRDUP(subfname);
2746 if (!f->subfname) {
2747 SAFE_FREE(f);
2748 return;
2750 file_lists = f;
2751 f->modtime = file_modtime(subfname);
2752 } else {
2753 time_t t = file_modtime(subfname);
2754 if (t)
2755 f->modtime = t;
2759 /*******************************************************************
2760 Check if a config file has changed date.
2761 ********************************************************************/
2763 BOOL lp_file_list_changed(void)
2765 struct file_lists *f = file_lists;
2767 DEBUG(6, ("lp_file_list_changed()\n"));
2769 while (f) {
2770 pstring n2;
2771 time_t mod_time;
2773 pstrcpy(n2, f->name);
2774 standard_sub_basic( get_current_username(), n2, sizeof(n2) );
2776 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
2777 f->name, n2, ctime(&f->modtime)));
2779 mod_time = file_modtime(n2);
2781 if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
2782 DEBUGADD(6,
2783 ("file %s modified: %s\n", n2,
2784 ctime(&mod_time)));
2785 f->modtime = mod_time;
2786 SAFE_FREE(f->subfname);
2787 f->subfname = SMB_STRDUP(n2);
2788 return (True);
2790 f = f->next;
2792 return (False);
2795 /***************************************************************************
2796 Run standard_sub_basic on netbios name... needed because global_myname
2797 is not accessed through any lp_ macro.
2798 Note: We must *NOT* use string_set() here as ptr points to global_myname.
2799 ***************************************************************************/
2801 static BOOL handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
2803 BOOL ret;
2804 pstring netbios_name;
2806 pstrcpy(netbios_name, pszParmValue);
2808 standard_sub_basic(get_current_username(), netbios_name,sizeof(netbios_name));
2810 ret = set_global_myname(netbios_name);
2811 string_set(&Globals.szNetbiosName,global_myname());
2813 DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
2814 global_myname()));
2816 return ret;
2819 static BOOL handle_charset(int snum, const char *pszParmValue, char **ptr)
2821 if (strcmp(*ptr, pszParmValue) != 0) {
2822 string_set(ptr, pszParmValue);
2823 init_iconv();
2825 return True;
2828 static BOOL handle_eventlog(int snum, const char *pszParmValue, char **ptr)
2830 string_set(ptr, pszParmValue);
2831 return True;
2834 static BOOL handle_workgroup(int snum, const char *pszParmValue, char **ptr)
2836 BOOL ret;
2838 ret = set_global_myworkgroup(pszParmValue);
2839 string_set(&Globals.szWorkgroup,lp_workgroup());
2841 return ret;
2844 static BOOL handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
2846 BOOL ret;
2848 ret = set_global_scope(pszParmValue);
2849 string_set(&Globals.szNetbiosScope,global_scope());
2851 return ret;
2854 static BOOL handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
2856 str_list_free(&Globals.szNetbiosAliases);
2857 Globals.szNetbiosAliases = str_list_make(pszParmValue, NULL);
2858 return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
2861 /***************************************************************************
2862 Handle the include operation.
2863 ***************************************************************************/
2865 static BOOL handle_include(int snum, const char *pszParmValue, char **ptr)
2867 pstring fname;
2868 pstrcpy(fname, pszParmValue);
2870 standard_sub_basic(get_current_username(), fname,sizeof(fname));
2872 add_to_file_list(pszParmValue, fname);
2874 string_set(ptr, fname);
2876 if (file_exist(fname, NULL))
2877 return (pm_process(fname, do_section, do_parameter));
2879 DEBUG(2, ("Can't find include file %s\n", fname));
2881 return (False);
2884 /***************************************************************************
2885 Handle the interpretation of the copy parameter.
2886 ***************************************************************************/
2888 static BOOL handle_copy(int snum, const char *pszParmValue, char **ptr)
2890 BOOL bRetval;
2891 int iTemp;
2892 service serviceTemp;
2894 string_set(ptr, pszParmValue);
2896 init_service(&serviceTemp);
2898 bRetval = False;
2900 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
2902 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
2903 if (iTemp == iServiceIndex) {
2904 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
2905 } else {
2906 copy_service(ServicePtrs[iServiceIndex],
2907 &serviceTemp,
2908 ServicePtrs[iServiceIndex]->copymap);
2909 bRetval = True;
2911 } else {
2912 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
2913 bRetval = False;
2916 free_service(&serviceTemp);
2917 return (bRetval);
2920 /***************************************************************************
2921 Handle idmap/non unix account uid and gid allocation parameters. The format of these
2922 parameters is:
2924 [global]
2926 idmap uid = 1000-1999
2927 idmap gid = 700-899
2929 We only do simple parsing checks here. The strings are parsed into useful
2930 structures in the idmap daemon code.
2932 ***************************************************************************/
2934 /* Some lp_ routines to return idmap [ug]id information */
2936 static uid_t idmap_uid_low, idmap_uid_high;
2937 static gid_t idmap_gid_low, idmap_gid_high;
2939 BOOL lp_idmap_uid(uid_t *low, uid_t *high)
2941 if (idmap_uid_low == 0 || idmap_uid_high == 0)
2942 return False;
2944 if (low)
2945 *low = idmap_uid_low;
2947 if (high)
2948 *high = idmap_uid_high;
2950 return True;
2953 BOOL lp_idmap_gid(gid_t *low, gid_t *high)
2955 if (idmap_gid_low == 0 || idmap_gid_high == 0)
2956 return False;
2958 if (low)
2959 *low = idmap_gid_low;
2961 if (high)
2962 *high = idmap_gid_high;
2964 return True;
2967 /* Do some simple checks on "idmap [ug]id" parameter values */
2969 static BOOL handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
2971 uint32 low, high;
2973 if (sscanf(pszParmValue, "%u-%u", &low, &high) != 2 || high < low)
2974 return False;
2976 /* Parse OK */
2978 string_set(ptr, pszParmValue);
2980 idmap_uid_low = low;
2981 idmap_uid_high = high;
2983 return True;
2986 static BOOL handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
2988 uint32 low, high;
2990 if (sscanf(pszParmValue, "%u-%u", &low, &high) != 2 || high < low)
2991 return False;
2993 /* Parse OK */
2995 string_set(ptr, pszParmValue);
2997 idmap_gid_low = low;
2998 idmap_gid_high = high;
3000 return True;
3003 /***************************************************************************
3004 Handle the DEBUG level list.
3005 ***************************************************************************/
3007 static BOOL handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
3009 pstring pszParmValue;
3011 pstrcpy(pszParmValue, pszParmValueIn);
3012 string_set(ptr, pszParmValueIn);
3013 return debug_parse_levels( pszParmValue );
3016 /***************************************************************************
3017 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
3018 ***************************************************************************/
3020 static char* append_ldap_suffix( const char *str )
3022 char *suffix_string;
3025 if (!lp_talloc)
3026 lp_talloc = talloc_init("lp_talloc");
3028 suffix_string = talloc_asprintf( lp_talloc, "%s,%s", str, Globals.szLdapSuffix );
3029 if ( !suffix_string ) {
3030 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
3031 return NULL;
3034 return suffix_string;
3037 char *lp_ldap_machine_suffix(void)
3039 if (Globals.szLdapMachineSuffix[0])
3040 return append_ldap_suffix(Globals.szLdapMachineSuffix);
3042 return lp_string(Globals.szLdapSuffix);
3045 char *lp_ldap_user_suffix(void)
3047 if (Globals.szLdapUserSuffix[0])
3048 return append_ldap_suffix(Globals.szLdapUserSuffix);
3050 return lp_string(Globals.szLdapSuffix);
3053 char *lp_ldap_group_suffix(void)
3055 if (Globals.szLdapGroupSuffix[0])
3056 return append_ldap_suffix(Globals.szLdapGroupSuffix);
3058 return lp_string(Globals.szLdapSuffix);
3061 char *lp_ldap_idmap_suffix(void)
3063 if (Globals.szLdapIdmapSuffix[0])
3064 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
3066 return lp_string(Globals.szLdapSuffix);
3069 /***************************************************************************
3070 ***************************************************************************/
3072 static BOOL handle_acl_compatibility(int snum, const char *pszParmValue, char **ptr)
3074 if (strequal(pszParmValue, "auto"))
3075 string_set(ptr, "");
3076 else if (strequal(pszParmValue, "winnt"))
3077 string_set(ptr, "winnt");
3078 else if (strequal(pszParmValue, "win2k"))
3079 string_set(ptr, "win2k");
3080 else
3081 return False;
3083 return True;
3086 /****************************************************************************
3087 set the value for a P_ENUM
3088 ***************************************************************************/
3090 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
3091 int *ptr )
3093 int i;
3095 for (i = 0; parm->enum_list[i].name; i++) {
3096 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
3097 *ptr = parm->enum_list[i].value;
3098 break;
3103 /***************************************************************************
3104 ***************************************************************************/
3106 static BOOL handle_printing(int snum, const char *pszParmValue, char **ptr)
3108 static int parm_num = -1;
3109 service *s;
3111 if ( parm_num == -1 )
3112 parm_num = map_parameter( "printing" );
3114 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
3116 if ( snum < 0 )
3117 s = &sDefault;
3118 else
3119 s = ServicePtrs[snum];
3121 init_printer_values( s );
3123 return True;
3127 /***************************************************************************
3128 Initialise a copymap.
3129 ***************************************************************************/
3131 static void init_copymap(service * pservice)
3133 int i;
3134 SAFE_FREE(pservice->copymap);
3135 pservice->copymap = SMB_MALLOC_ARRAY(BOOL,NUMPARAMETERS);
3136 if (!pservice->copymap)
3137 DEBUG(0,
3138 ("Couldn't allocate copymap!! (size %d)\n",
3139 (int)NUMPARAMETERS));
3140 else
3141 for (i = 0; i < NUMPARAMETERS; i++)
3142 pservice->copymap[i] = True;
3145 /***************************************************************************
3146 Return the local pointer to a parameter given the service number and the
3147 pointer into the default structure.
3148 ***************************************************************************/
3150 void *lp_local_ptr(int snum, void *ptr)
3152 return (void *)(((char *)ServicePtrs[snum]) + PTR_DIFF(ptr, &sDefault));
3155 /***************************************************************************
3156 Process a parameter for a particular service number. If snum < 0
3157 then assume we are in the globals.
3158 ***************************************************************************/
3160 BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
3162 int parmnum, i, slen;
3163 void *parm_ptr = NULL; /* where we are going to store the result */
3164 void *def_ptr = NULL;
3165 pstring param_key;
3166 char *sep;
3167 param_opt_struct *paramo, *data;
3168 BOOL not_added;
3170 parmnum = map_parameter(pszParmName);
3172 if (parmnum < 0) {
3173 if ((sep=strchr(pszParmName, ':')) != NULL) {
3174 *sep = '\0';
3175 ZERO_STRUCT(param_key);
3176 pstr_sprintf(param_key, "%s:", pszParmName);
3177 slen = strlen(param_key);
3178 pstrcat(param_key, sep+1);
3179 trim_char(param_key+slen, ' ', ' ');
3180 not_added = True;
3181 data = (snum < 0) ? Globals.param_opt :
3182 ServicePtrs[snum]->param_opt;
3183 /* Traverse destination */
3184 while (data) {
3185 /* If we already have same option, override it */
3186 if (strcmp(data->key, param_key) == 0) {
3187 string_free(&data->value);
3188 str_list_free(&data->list);
3189 data->value = SMB_STRDUP(pszParmValue);
3190 not_added = False;
3191 break;
3193 data = data->next;
3195 if (not_added) {
3196 paramo = SMB_XMALLOC_P(param_opt_struct);
3197 paramo->key = SMB_STRDUP(param_key);
3198 paramo->value = SMB_STRDUP(pszParmValue);
3199 paramo->list = NULL;
3200 if (snum < 0) {
3201 DLIST_ADD(Globals.param_opt, paramo);
3202 } else {
3203 DLIST_ADD(ServicePtrs[snum]->param_opt, paramo);
3207 *sep = ':';
3208 return (True);
3210 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
3211 return (True);
3214 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
3215 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
3216 pszParmName));
3219 def_ptr = parm_table[parmnum].ptr;
3221 /* we might point at a service, the default service or a global */
3222 if (snum < 0) {
3223 parm_ptr = def_ptr;
3224 } else {
3225 if (parm_table[parmnum].class == P_GLOBAL) {
3226 DEBUG(0,
3227 ("Global parameter %s found in service section!\n",
3228 pszParmName));
3229 return (True);
3231 parm_ptr =
3232 ((char *)ServicePtrs[snum]) + PTR_DIFF(def_ptr,
3233 &sDefault);
3236 if (snum >= 0) {
3237 if (!ServicePtrs[snum]->copymap)
3238 init_copymap(ServicePtrs[snum]);
3240 /* this handles the aliases - set the copymap for other entries with
3241 the same data pointer */
3242 for (i = 0; parm_table[i].label; i++)
3243 if (parm_table[i].ptr == parm_table[parmnum].ptr)
3244 ServicePtrs[snum]->copymap[i] = False;
3247 /* if it is a special case then go ahead */
3248 if (parm_table[parmnum].special) {
3249 parm_table[parmnum].special(snum, pszParmValue, (char **)parm_ptr);
3250 return (True);
3253 /* now switch on the type of variable it is */
3254 switch (parm_table[parmnum].type)
3256 case P_BOOL:
3257 set_boolean(parm_ptr, pszParmValue);
3258 break;
3260 case P_BOOLREV:
3261 set_boolean(parm_ptr, pszParmValue);
3262 *(BOOL *)parm_ptr = !*(BOOL *)parm_ptr;
3263 break;
3265 case P_INTEGER:
3266 *(int *)parm_ptr = atoi(pszParmValue);
3267 break;
3269 case P_CHAR:
3270 *(char *)parm_ptr = *pszParmValue;
3271 break;
3273 case P_OCTAL:
3274 sscanf(pszParmValue, "%o", (int *)parm_ptr);
3275 break;
3277 case P_LIST:
3278 str_list_free(parm_ptr);
3279 *(char ***)parm_ptr = str_list_make(pszParmValue, NULL);
3280 break;
3282 case P_STRING:
3283 string_set(parm_ptr, pszParmValue);
3284 break;
3286 case P_USTRING:
3287 string_set(parm_ptr, pszParmValue);
3288 strupper_m(*(char **)parm_ptr);
3289 break;
3291 case P_GSTRING:
3292 pstrcpy((char *)parm_ptr, pszParmValue);
3293 break;
3295 case P_UGSTRING:
3296 pstrcpy((char *)parm_ptr, pszParmValue);
3297 strupper_m((char *)parm_ptr);
3298 break;
3300 case P_ENUM:
3301 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
3302 break;
3303 case P_SEP:
3304 break;
3307 return (True);
3310 /***************************************************************************
3311 Process a parameter.
3312 ***************************************************************************/
3314 static BOOL do_parameter(const char *pszParmName, const char *pszParmValue)
3316 if (!bInGlobalSection && bGlobalOnly)
3317 return (True);
3319 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
3321 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
3322 pszParmName, pszParmValue));
3325 /***************************************************************************
3326 Print a parameter of the specified type.
3327 ***************************************************************************/
3329 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
3331 int i;
3332 switch (p->type)
3334 case P_ENUM:
3335 for (i = 0; p->enum_list[i].name; i++) {
3336 if (*(int *)ptr == p->enum_list[i].value) {
3337 fprintf(f, "%s",
3338 p->enum_list[i].name);
3339 break;
3342 break;
3344 case P_BOOL:
3345 fprintf(f, "%s", BOOLSTR(*(BOOL *)ptr));
3346 break;
3348 case P_BOOLREV:
3349 fprintf(f, "%s", BOOLSTR(!*(BOOL *)ptr));
3350 break;
3352 case P_INTEGER:
3353 fprintf(f, "%d", *(int *)ptr);
3354 break;
3356 case P_CHAR:
3357 fprintf(f, "%c", *(char *)ptr);
3358 break;
3360 case P_OCTAL:
3361 fprintf(f, "%s", octal_string(*(int *)ptr));
3362 break;
3364 case P_LIST:
3365 if ((char ***)ptr && *(char ***)ptr) {
3366 char **list = *(char ***)ptr;
3368 for (; *list; list++) {
3369 /* surround strings with whitespace in double quotes */
3370 if ( strchr_m( *list, ' ' ) )
3371 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
3372 else
3373 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
3376 break;
3378 case P_GSTRING:
3379 case P_UGSTRING:
3380 if ((char *)ptr) {
3381 fprintf(f, "%s", (char *)ptr);
3383 break;
3385 case P_STRING:
3386 case P_USTRING:
3387 if (*(char **)ptr) {
3388 fprintf(f, "%s", *(char **)ptr);
3390 break;
3391 case P_SEP:
3392 break;
3396 /***************************************************************************
3397 Check if two parameters are equal.
3398 ***************************************************************************/
3400 static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
3402 switch (type) {
3403 case P_BOOL:
3404 case P_BOOLREV:
3405 return (*((BOOL *)ptr1) == *((BOOL *)ptr2));
3407 case P_INTEGER:
3408 case P_ENUM:
3409 case P_OCTAL:
3410 return (*((int *)ptr1) == *((int *)ptr2));
3412 case P_CHAR:
3413 return (*((char *)ptr1) == *((char *)ptr2));
3415 case P_LIST:
3416 return str_list_compare(*(char ***)ptr1, *(char ***)ptr2);
3418 case P_GSTRING:
3419 case P_UGSTRING:
3421 char *p1 = (char *)ptr1, *p2 = (char *)ptr2;
3422 if (p1 && !*p1)
3423 p1 = NULL;
3424 if (p2 && !*p2)
3425 p2 = NULL;
3426 return (p1 == p2 || strequal(p1, p2));
3428 case P_STRING:
3429 case P_USTRING:
3431 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
3432 if (p1 && !*p1)
3433 p1 = NULL;
3434 if (p2 && !*p2)
3435 p2 = NULL;
3436 return (p1 == p2 || strequal(p1, p2));
3438 case P_SEP:
3439 break;
3441 return (False);
3444 /***************************************************************************
3445 Initialize any local varients in the sDefault table.
3446 ***************************************************************************/
3448 void init_locals(void)
3450 /* None as yet. */
3453 /***************************************************************************
3454 Process a new section (service). At this stage all sections are services.
3455 Later we'll have special sections that permit server parameters to be set.
3456 Returns True on success, False on failure.
3457 ***************************************************************************/
3459 static BOOL do_section(const char *pszSectionName)
3461 BOOL bRetval;
3462 BOOL isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
3463 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
3464 bRetval = False;
3466 /* if we were in a global section then do the local inits */
3467 if (bInGlobalSection && !isglobal)
3468 init_locals();
3470 /* if we've just struck a global section, note the fact. */
3471 bInGlobalSection = isglobal;
3473 /* check for multiple global sections */
3474 if (bInGlobalSection) {
3475 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
3476 return (True);
3479 if (!bInGlobalSection && bGlobalOnly)
3480 return (True);
3482 /* if we have a current service, tidy it up before moving on */
3483 bRetval = True;
3485 if (iServiceIndex >= 0)
3486 bRetval = service_ok(iServiceIndex);
3488 /* if all is still well, move to the next record in the services array */
3489 if (bRetval) {
3490 /* We put this here to avoid an odd message order if messages are */
3491 /* issued by the post-processing of a previous section. */
3492 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
3494 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
3495 < 0) {
3496 DEBUG(0, ("Failed to add a new service\n"));
3497 return (False);
3501 return (bRetval);
3505 /***************************************************************************
3506 Determine if a partcular base parameter is currentl set to the default value.
3507 ***************************************************************************/
3509 static BOOL is_default(int i)
3511 if (!defaults_saved)
3512 return False;
3513 switch (parm_table[i].type) {
3514 case P_LIST:
3515 return str_list_compare (parm_table[i].def.lvalue,
3516 *(char ***)parm_table[i].ptr);
3517 case P_STRING:
3518 case P_USTRING:
3519 return strequal(parm_table[i].def.svalue,
3520 *(char **)parm_table[i].ptr);
3521 case P_GSTRING:
3522 case P_UGSTRING:
3523 return strequal(parm_table[i].def.svalue,
3524 (char *)parm_table[i].ptr);
3525 case P_BOOL:
3526 case P_BOOLREV:
3527 return parm_table[i].def.bvalue ==
3528 *(BOOL *)parm_table[i].ptr;
3529 case P_CHAR:
3530 return parm_table[i].def.cvalue ==
3531 *(char *)parm_table[i].ptr;
3532 case P_INTEGER:
3533 case P_OCTAL:
3534 case P_ENUM:
3535 return parm_table[i].def.ivalue ==
3536 *(int *)parm_table[i].ptr;
3537 case P_SEP:
3538 break;
3540 return False;
3543 /***************************************************************************
3544 Display the contents of the global structure.
3545 ***************************************************************************/
3547 static void dump_globals(FILE *f)
3549 int i;
3550 param_opt_struct *data;
3552 fprintf(f, "# Global parameters\n[global]\n");
3554 for (i = 0; parm_table[i].label; i++)
3555 if (parm_table[i].class == P_GLOBAL &&
3556 parm_table[i].ptr &&
3557 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
3558 if (defaults_saved && is_default(i))
3559 continue;
3560 fprintf(f, "\t%s = ", parm_table[i].label);
3561 print_parameter(&parm_table[i], parm_table[i].ptr, f);
3562 fprintf(f, "\n");
3564 if (Globals.param_opt != NULL) {
3565 data = Globals.param_opt;
3566 while(data) {
3567 fprintf(f, "\t%s = %s\n", data->key, data->value);
3568 data = data->next;
3574 /***************************************************************************
3575 Return True if a local parameter is currently set to the global default.
3576 ***************************************************************************/
3578 BOOL lp_is_default(int snum, struct parm_struct *parm)
3580 int pdiff = PTR_DIFF(parm->ptr, &sDefault);
3582 return equal_parameter(parm->type,
3583 ((char *)ServicePtrs[snum]) + pdiff,
3584 ((char *)&sDefault) + pdiff);
3587 /***************************************************************************
3588 Display the contents of a single services record.
3589 ***************************************************************************/
3591 static void dump_a_service(service * pService, FILE * f)
3593 int i;
3594 param_opt_struct *data;
3596 if (pService != &sDefault)
3597 fprintf(f, "\n[%s]\n", pService->szService);
3599 for (i = 0; parm_table[i].label; i++) {
3601 if (parm_table[i].class == P_LOCAL &&
3602 parm_table[i].ptr &&
3603 (*parm_table[i].label != '-') &&
3604 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
3607 int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
3609 if (pService == &sDefault) {
3610 if (defaults_saved && is_default(i))
3611 continue;
3612 } else {
3613 if (equal_parameter(parm_table[i].type,
3614 ((char *)pService) +
3615 pdiff,
3616 ((char *)&sDefault) +
3617 pdiff))
3618 continue;
3621 fprintf(f, "\t%s = ", parm_table[i].label);
3622 print_parameter(&parm_table[i],
3623 ((char *)pService) + pdiff, f);
3624 fprintf(f, "\n");
3628 if (pService->param_opt != NULL) {
3629 data = pService->param_opt;
3630 while(data) {
3631 fprintf(f, "\t%s = %s\n", data->key, data->value);
3632 data = data->next;
3638 /***************************************************************************
3639 Return info about the next service in a service. snum==GLOBAL_SECTION_SNUM gives the globals.
3640 Return NULL when out of parameters.
3641 ***************************************************************************/
3643 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
3645 if (snum < 0) {
3646 /* do the globals */
3647 for (; parm_table[*i].label; (*i)++) {
3648 if (parm_table[*i].class == P_SEPARATOR)
3649 return &parm_table[(*i)++];
3651 if (!parm_table[*i].ptr
3652 || (*parm_table[*i].label == '-'))
3653 continue;
3655 if ((*i) > 0
3656 && (parm_table[*i].ptr ==
3657 parm_table[(*i) - 1].ptr))
3658 continue;
3660 return &parm_table[(*i)++];
3662 } else {
3663 service *pService = ServicePtrs[snum];
3665 for (; parm_table[*i].label; (*i)++) {
3666 if (parm_table[*i].class == P_SEPARATOR)
3667 return &parm_table[(*i)++];
3669 if (parm_table[*i].class == P_LOCAL &&
3670 parm_table[*i].ptr &&
3671 (*parm_table[*i].label != '-') &&
3672 ((*i) == 0 ||
3673 (parm_table[*i].ptr !=
3674 parm_table[(*i) - 1].ptr)))
3676 int pdiff =
3677 PTR_DIFF(parm_table[*i].ptr,
3678 &sDefault);
3680 if (allparameters ||
3681 !equal_parameter(parm_table[*i].type,
3682 ((char *)pService) +
3683 pdiff,
3684 ((char *)&sDefault) +
3685 pdiff))
3687 return &parm_table[(*i)++];
3693 return NULL;
3697 #if 0
3698 /***************************************************************************
3699 Display the contents of a single copy structure.
3700 ***************************************************************************/
3701 static void dump_copy_map(BOOL *pcopymap)
3703 int i;
3704 if (!pcopymap)
3705 return;
3707 printf("\n\tNon-Copied parameters:\n");
3709 for (i = 0; parm_table[i].label; i++)
3710 if (parm_table[i].class == P_LOCAL &&
3711 parm_table[i].ptr && !pcopymap[i] &&
3712 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
3714 printf("\t\t%s\n", parm_table[i].label);
3717 #endif
3719 /***************************************************************************
3720 Return TRUE if the passed service number is within range.
3721 ***************************************************************************/
3723 BOOL lp_snum_ok(int iService)
3725 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
3728 /***************************************************************************
3729 Auto-load some home services.
3730 ***************************************************************************/
3732 static void lp_add_auto_services(char *str)
3734 char *s;
3735 char *p;
3736 int homes;
3738 if (!str)
3739 return;
3741 s = SMB_STRDUP(str);
3742 if (!s)
3743 return;
3745 homes = lp_servicenumber(HOMES_NAME);
3747 for (p = strtok(s, LIST_SEP); p; p = strtok(NULL, LIST_SEP)) {
3748 char *home = get_user_home_dir(p);
3750 if (lp_servicenumber(p) >= 0)
3751 continue;
3753 if (home && homes >= 0)
3754 lp_add_home(p, homes, p, home);
3756 SAFE_FREE(s);
3759 /***************************************************************************
3760 Auto-load one printer.
3761 ***************************************************************************/
3763 void lp_add_one_printer(char *name, char *comment)
3765 int printers = lp_servicenumber(PRINTERS_NAME);
3766 int i;
3768 if (lp_servicenumber(name) < 0) {
3769 lp_add_printer(name, printers);
3770 if ((i = lp_servicenumber(name)) >= 0) {
3771 string_set(&ServicePtrs[i]->comment, comment);
3772 ServicePtrs[i]->autoloaded = True;
3777 /***************************************************************************
3778 Have we loaded a services file yet?
3779 ***************************************************************************/
3781 BOOL lp_loaded(void)
3783 return (bLoaded);
3786 /***************************************************************************
3787 Unload unused services.
3788 ***************************************************************************/
3790 void lp_killunused(BOOL (*snumused) (int))
3792 int i;
3793 for (i = 0; i < iNumServices; i++) {
3794 if (!VALID(i))
3795 continue;
3797 /* don't kill autoloaded services */
3798 if ( ServicePtrs[i]->autoloaded )
3799 continue;
3801 if (!snumused || !snumused(i)) {
3802 ServicePtrs[i]->valid = False;
3803 free_service(ServicePtrs[i]);
3808 /***************************************************************************
3809 Unload a service.
3810 ***************************************************************************/
3812 void lp_killservice(int iServiceIn)
3814 if (VALID(iServiceIn)) {
3815 ServicePtrs[iServiceIn]->valid = False;
3816 free_service(ServicePtrs[iServiceIn]);
3820 /***************************************************************************
3821 Save the curent values of all global and sDefault parameters into the
3822 defaults union. This allows swat and testparm to show only the
3823 changed (ie. non-default) parameters.
3824 ***************************************************************************/
3826 static void lp_save_defaults(void)
3828 int i;
3829 for (i = 0; parm_table[i].label; i++) {
3830 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
3831 continue;
3832 switch (parm_table[i].type) {
3833 case P_LIST:
3834 str_list_copy(&(parm_table[i].def.lvalue),
3835 *(const char ***)parm_table[i].ptr);
3836 break;
3837 case P_STRING:
3838 case P_USTRING:
3839 if (parm_table[i].ptr) {
3840 parm_table[i].def.svalue = SMB_STRDUP(*(char **)parm_table[i].ptr);
3841 } else {
3842 parm_table[i].def.svalue = NULL;
3844 break;
3845 case P_GSTRING:
3846 case P_UGSTRING:
3847 if (parm_table[i].ptr) {
3848 parm_table[i].def.svalue = SMB_STRDUP((char *)parm_table[i].ptr);
3849 } else {
3850 parm_table[i].def.svalue = NULL;
3852 break;
3853 case P_BOOL:
3854 case P_BOOLREV:
3855 parm_table[i].def.bvalue =
3856 *(BOOL *)parm_table[i].ptr;
3857 break;
3858 case P_CHAR:
3859 parm_table[i].def.cvalue =
3860 *(char *)parm_table[i].ptr;
3861 break;
3862 case P_INTEGER:
3863 case P_OCTAL:
3864 case P_ENUM:
3865 parm_table[i].def.ivalue =
3866 *(int *)parm_table[i].ptr;
3867 break;
3868 case P_SEP:
3869 break;
3872 defaults_saved = True;
3875 /*******************************************************************
3876 Set the server type we will announce as via nmbd.
3877 ********************************************************************/
3879 static void set_server_role(void)
3881 server_role = ROLE_STANDALONE;
3883 switch (lp_security()) {
3884 case SEC_SHARE:
3885 if (lp_domain_logons())
3886 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
3887 break;
3888 case SEC_SERVER:
3889 if (lp_domain_logons())
3890 DEBUG(0, ("Server's Role (logon server) conflicts with server-level security\n"));
3891 server_role = ROLE_DOMAIN_MEMBER;
3892 break;
3893 case SEC_DOMAIN:
3894 if (lp_domain_logons()) {
3895 DEBUG(1, ("Server's Role (logon server) NOT ADVISED with domain-level security\n"));
3896 server_role = ROLE_DOMAIN_BDC;
3897 break;
3899 server_role = ROLE_DOMAIN_MEMBER;
3900 break;
3901 case SEC_ADS:
3902 if (lp_domain_logons()) {
3903 server_role = ROLE_DOMAIN_PDC;
3904 break;
3906 server_role = ROLE_DOMAIN_MEMBER;
3907 break;
3908 case SEC_USER:
3909 if (lp_domain_logons()) {
3911 if (Globals.bDomainMaster) /* auto or yes */
3912 server_role = ROLE_DOMAIN_PDC;
3913 else
3914 server_role = ROLE_DOMAIN_BDC;
3916 break;
3917 default:
3918 DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
3919 break;
3922 DEBUG(10, ("set_server_role: role = "));
3924 switch(server_role) {
3925 case ROLE_STANDALONE:
3926 DEBUGADD(10, ("ROLE_STANDALONE\n"));
3927 break;
3928 case ROLE_DOMAIN_MEMBER:
3929 DEBUGADD(10, ("ROLE_DOMAIN_MEMBER\n"));
3930 break;
3931 case ROLE_DOMAIN_BDC:
3932 DEBUGADD(10, ("ROLE_DOMAIN_BDC\n"));
3933 break;
3934 case ROLE_DOMAIN_PDC:
3935 DEBUGADD(10, ("ROLE_DOMAIN_PDC\n"));
3936 break;
3940 /***********************************************************
3941 If we should send plaintext/LANMAN passwords in the clinet
3942 ************************************************************/
3943 static void set_allowed_client_auth(void)
3945 if (Globals.bClientNTLMv2Auth) {
3946 Globals.bClientLanManAuth = False;
3948 if (!Globals.bClientLanManAuth) {
3949 Globals.bClientPlaintextAuth = False;
3953 /***************************************************************************
3954 Load the services array from the services file. Return True on success,
3955 False on failure.
3956 ***************************************************************************/
3958 BOOL lp_load(const char *pszFname, BOOL global_only, BOOL save_defaults,
3959 BOOL add_ipc)
3961 pstring n2;
3962 BOOL bRetval;
3963 param_opt_struct *data, *pdata;
3965 pstrcpy(n2, pszFname);
3967 standard_sub_basic( get_current_username(), n2,sizeof(n2) );
3969 add_to_file_list(pszFname, n2);
3971 bRetval = False;
3973 DEBUG(3, ("lp_load: refreshing parameters\n"));
3975 bInGlobalSection = True;
3976 bGlobalOnly = global_only;
3978 init_globals();
3979 debug_init();
3981 if (save_defaults) {
3982 init_locals();
3983 lp_save_defaults();
3986 if (Globals.param_opt != NULL) {
3987 data = Globals.param_opt;
3988 while (data) {
3989 string_free(&data->key);
3990 string_free(&data->value);
3991 str_list_free(&data->list);
3992 pdata = data->next;
3993 SAFE_FREE(data);
3994 data = pdata;
3996 Globals.param_opt = NULL;
3999 /* We get sections first, so have to start 'behind' to make up */
4000 iServiceIndex = -1;
4001 bRetval = pm_process(n2, do_section, do_parameter);
4003 /* finish up the last section */
4004 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
4005 if (bRetval)
4006 if (iServiceIndex >= 0)
4007 bRetval = service_ok(iServiceIndex);
4009 lp_add_auto_services(lp_auto_services());
4011 if (add_ipc) {
4012 /* When 'restrict anonymous = 2' guest connections to ipc$
4013 are denied */
4014 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
4015 if ( lp_enable_asu_support() )
4016 lp_add_ipc("ADMIN$", False);
4019 set_server_role();
4020 set_default_server_announce_type();
4021 set_allowed_client_auth();
4023 bLoaded = True;
4025 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
4026 /* if bWINSsupport is true and we are in the client */
4027 if (in_client && Globals.bWINSsupport) {
4028 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
4031 init_iconv();
4033 return (bRetval);
4036 /***************************************************************************
4037 Reset the max number of services.
4038 ***************************************************************************/
4040 void lp_resetnumservices(void)
4042 iNumServices = 0;
4045 /***************************************************************************
4046 Return the max number of services.
4047 ***************************************************************************/
4049 int lp_numservices(void)
4051 return (iNumServices);
4054 /***************************************************************************
4055 Display the contents of the services array in human-readable form.
4056 ***************************************************************************/
4058 void lp_dump(FILE *f, BOOL show_defaults, int maxtoprint)
4060 int iService;
4062 if (show_defaults)
4063 defaults_saved = False;
4065 dump_globals(f);
4067 dump_a_service(&sDefault, f);
4069 for (iService = 0; iService < maxtoprint; iService++)
4070 lp_dump_one(f, show_defaults, iService);
4073 /***************************************************************************
4074 Display the contents of one service in human-readable form.
4075 ***************************************************************************/
4077 void lp_dump_one(FILE * f, BOOL show_defaults, int snum)
4079 if (VALID(snum)) {
4080 if (ServicePtrs[snum]->szService[0] == '\0')
4081 return;
4082 dump_a_service(ServicePtrs[snum], f);
4086 /***************************************************************************
4087 Return the number of the service with the given name, or -1 if it doesn't
4088 exist. Note that this is a DIFFERENT ANIMAL from the internal function
4089 getservicebyname()! This works ONLY if all services have been loaded, and
4090 does not copy the found service.
4091 ***************************************************************************/
4093 int lp_servicenumber(const char *pszServiceName)
4095 int iService;
4096 fstring serviceName;
4098 if (!pszServiceName)
4099 return GLOBAL_SECTION_SNUM;
4101 for (iService = iNumServices - 1; iService >= 0; iService--) {
4102 if (VALID(iService) && ServicePtrs[iService]->szService) {
4104 * The substitution here is used to support %U is
4105 * service names
4107 fstrcpy(serviceName, ServicePtrs[iService]->szService);
4108 standard_sub_basic(get_current_username(), serviceName,sizeof(serviceName));
4109 if (strequal(serviceName, pszServiceName))
4110 break;
4114 if (iService < 0) {
4115 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
4116 return GLOBAL_SECTION_SNUM;
4119 return (iService);
4122 /*******************************************************************
4123 A useful volume label function.
4124 ********************************************************************/
4126 char *volume_label(int snum)
4128 char *ret = lp_volume(snum);
4129 if (!*ret)
4130 return lp_servicename(snum);
4131 return (ret);
4135 /*******************************************************************
4136 Set the server type we will announce as via nmbd.
4137 ********************************************************************/
4139 static void set_default_server_announce_type(void)
4141 default_server_announce = 0;
4142 default_server_announce |= SV_TYPE_WORKSTATION;
4143 default_server_announce |= SV_TYPE_SERVER;
4144 default_server_announce |= SV_TYPE_SERVER_UNIX;
4146 /* note that the flag should be set only if we have a
4147 printer service but nmbd doesn't actually load the
4148 services so we can't tell --jerry */
4150 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
4152 switch (lp_announce_as()) {
4153 case ANNOUNCE_AS_NT_SERVER:
4154 default_server_announce |= SV_TYPE_SERVER_NT;
4155 /* fall through... */
4156 case ANNOUNCE_AS_NT_WORKSTATION:
4157 default_server_announce |= SV_TYPE_NT;
4158 break;
4159 case ANNOUNCE_AS_WIN95:
4160 default_server_announce |= SV_TYPE_WIN95_PLUS;
4161 break;
4162 case ANNOUNCE_AS_WFW:
4163 default_server_announce |= SV_TYPE_WFW;
4164 break;
4165 default:
4166 break;
4169 switch (lp_server_role()) {
4170 case ROLE_DOMAIN_MEMBER:
4171 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
4172 break;
4173 case ROLE_DOMAIN_PDC:
4174 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
4175 break;
4176 case ROLE_DOMAIN_BDC:
4177 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
4178 break;
4179 case ROLE_STANDALONE:
4180 default:
4181 break;
4183 if (lp_time_server())
4184 default_server_announce |= SV_TYPE_TIME_SOURCE;
4186 if (lp_host_msdfs())
4187 default_server_announce |= SV_TYPE_DFS_SERVER;
4190 /***********************************************************
4191 returns role of Samba server
4192 ************************************************************/
4194 int lp_server_role(void)
4196 return server_role;
4199 /***********************************************************
4200 If we are PDC then prefer us as DMB
4201 ************************************************************/
4203 BOOL lp_domain_master(void)
4205 if (Globals.bDomainMaster == Auto)
4206 return (lp_server_role() == ROLE_DOMAIN_PDC);
4208 return Globals.bDomainMaster;
4211 /***********************************************************
4212 If we are DMB then prefer us as LMB
4213 ************************************************************/
4215 BOOL lp_preferred_master(void)
4217 if (Globals.bPreferredMaster == Auto)
4218 return (lp_local_master() && lp_domain_master());
4220 return Globals.bPreferredMaster;
4223 /*******************************************************************
4224 Remove a service.
4225 ********************************************************************/
4227 void lp_remove_service(int snum)
4229 ServicePtrs[snum]->valid = False;
4232 /*******************************************************************
4233 Copy a service.
4234 ********************************************************************/
4236 void lp_copy_service(int snum, const char *new_name)
4238 do_section(new_name);
4239 if (snum >= 0) {
4240 snum = lp_servicenumber(new_name);
4241 if (snum >= 0)
4242 lp_do_parameter(snum, "copy", lp_servicename(snum));
4247 /*******************************************************************
4248 Get the default server type we will announce as via nmbd.
4249 ********************************************************************/
4251 int lp_default_server_announce(void)
4253 return default_server_announce;
4256 /*******************************************************************
4257 Split the announce version into major and minor numbers.
4258 ********************************************************************/
4260 int lp_major_announce_version(void)
4262 static BOOL got_major = False;
4263 static int major_version = DEFAULT_MAJOR_VERSION;
4264 char *vers;
4265 char *p;
4267 if (got_major)
4268 return major_version;
4270 got_major = True;
4271 if ((vers = lp_announce_version()) == NULL)
4272 return major_version;
4274 if ((p = strchr_m(vers, '.')) == 0)
4275 return major_version;
4277 *p = '\0';
4278 major_version = atoi(vers);
4279 return major_version;
4282 int lp_minor_announce_version(void)
4284 static BOOL got_minor = False;
4285 static int minor_version = DEFAULT_MINOR_VERSION;
4286 char *vers;
4287 char *p;
4289 if (got_minor)
4290 return minor_version;
4292 got_minor = True;
4293 if ((vers = lp_announce_version()) == NULL)
4294 return minor_version;
4296 if ((p = strchr_m(vers, '.')) == 0)
4297 return minor_version;
4299 p++;
4300 minor_version = atoi(p);
4301 return minor_version;
4304 /***********************************************************
4305 Set the global name resolution order (used in smbclient).
4306 ************************************************************/
4308 void lp_set_name_resolve_order(const char *new_order)
4310 string_set(&Globals.szNameResolveOrder, new_order);
4313 const char *lp_printername(int snum)
4315 const char *ret = _lp_printername(snum);
4316 if (ret == NULL || (ret != NULL && *ret == '\0'))
4317 ret = lp_const_servicename(snum);
4319 return ret;
4323 /****************************************************************
4324 Compatibility fn. for 2.2.2 code.....
4325 *****************************************************************/
4327 void get_private_directory(pstring privdir)
4329 pstrcpy (privdir, lp_private_dir());
4332 /***********************************************************
4333 Allow daemons such as winbindd to fix their logfile name.
4334 ************************************************************/
4336 void lp_set_logfile(const char *name)
4338 string_set(&Globals.szLogFile, name);
4339 pstrcpy(debugf, name);
4342 /*******************************************************************
4343 Return the max print jobs per queue.
4344 ********************************************************************/
4346 int lp_maxprintjobs(int snum)
4348 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
4349 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
4350 maxjobs = PRINT_MAX_JOBID - 1;
4352 return maxjobs;
4355 const char *lp_printcapname(void)
4357 if ((Globals.szPrintcapname != NULL) &&
4358 (Globals.szPrintcapname[0] != '\0'))
4359 return Globals.szPrintcapname;
4361 if (sDefault.iPrinting == PRINT_CUPS) {
4362 #ifdef HAVE_CUPS
4363 return "cups";
4364 #else
4365 return "lpstat";
4366 #endif
4369 if (sDefault.iPrinting == PRINT_BSD)
4370 return "/etc/printcap";
4372 return PRINTCAP_NAME;
4375 /*******************************************************************
4376 Ensure we don't use sendfile if server smb signing is active.
4377 ********************************************************************/
4379 BOOL lp_use_sendfile(int snum)
4381 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
4382 if (Protocol < PROTOCOL_NT1) {
4383 return False;
4385 return (_lp_use_sendfile(snum) && (get_remote_arch() != RA_WIN95) && !srv_is_signing_active());
4388 /*******************************************************************
4389 Turn off sendfile if we find the underlying OS doesn't support it.
4390 ********************************************************************/
4392 void set_use_sendfile(int snum, BOOL val)
4394 if (LP_SNUM_OK(snum))
4395 ServicePtrs[snum]->bUseSendfile = val;
4396 else
4397 sDefault.bUseSendfile = val;
4400 /*******************************************************************
4401 Turn off storing DOS attributes if this share doesn't support it.
4402 ********************************************************************/
4404 void set_store_dos_attributes(int snum, BOOL val)
4406 if (!LP_SNUM_OK(snum))
4407 return;
4408 ServicePtrs[(snum)]->bStoreDosAttributes = val;