r6895: Add "acl check permissions" to turn on/off the new behaviour of
[Samba.git] / source3 / param / loadparm.c
blob0ddd6bb0c71ad715d08c554341633d18723cddd7
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 int restrict_anonymous;
308 int name_cache_timeout;
309 int client_signing;
310 int server_signing;
311 param_opt_struct *param_opt;
313 global;
315 static global Globals;
318 * This structure describes a single service.
320 typedef struct
322 BOOL valid;
323 BOOL autoloaded;
324 char *szService;
325 char *szPath;
326 char *szUsername;
327 char **szInvalidUsers;
328 char **szValidUsers;
329 char **szAdminUsers;
330 char *szCopy;
331 char *szInclude;
332 char *szPreExec;
333 char *szPostExec;
334 char *szRootPreExec;
335 char *szRootPostExec;
336 char *szCupsOptions;
337 char *szPrintcommand;
338 char *szLpqcommand;
339 char *szLprmcommand;
340 char *szLppausecommand;
341 char *szLpresumecommand;
342 char *szQueuepausecommand;
343 char *szQueueresumecommand;
344 char *szPrintername;
345 char *szDontdescend;
346 char **szHostsallow;
347 char **szHostsdeny;
348 char *szMagicScript;
349 char *szMagicOutput;
350 char *szMangledMap;
351 char *szVetoFiles;
352 char *szHideFiles;
353 char *szVetoOplockFiles;
354 char *comment;
355 char *force_user;
356 char *force_group;
357 char **readlist;
358 char **writelist;
359 char **printer_admin;
360 char *volume;
361 char *fstype;
362 char **szVfsObjects;
363 char *szMSDfsProxy;
364 int iMinPrintSpace;
365 int iMaxPrintJobs;
366 int iMaxReportedPrintJobs;
367 int iWriteCacheSize;
368 int iCreate_mask;
369 int iCreate_force_mode;
370 int iSecurity_mask;
371 int iSecurity_force_mode;
372 int iDir_mask;
373 int iDir_force_mode;
374 int iDir_Security_mask;
375 int iDir_Security_force_mode;
376 int iMaxConnections;
377 int iDefaultCase;
378 int iPrinting;
379 int iOplockContentionLimit;
380 int iCSCPolicy;
381 int iBlock_size;
382 BOOL bPreexecClose;
383 BOOL bRootpreexecClose;
384 int iCaseSensitive;
385 BOOL bCasePreserve;
386 BOOL bShortCasePreserve;
387 BOOL bHideDotFiles;
388 BOOL bHideSpecialFiles;
389 BOOL bHideUnReadable;
390 BOOL bHideUnWriteableFiles;
391 BOOL bBrowseable;
392 BOOL bAvailable;
393 BOOL bRead_only;
394 BOOL bNo_set_dir;
395 BOOL bGuest_only;
396 BOOL bGuest_ok;
397 BOOL bPrint_ok;
398 BOOL bMap_system;
399 BOOL bMap_hidden;
400 BOOL bMap_archive;
401 BOOL bStoreDosAttributes;
402 BOOL bLocking;
403 int iStrictLocking;
404 BOOL bPosixLocking;
405 BOOL bShareModes;
406 BOOL bOpLocks;
407 BOOL bLevel2OpLocks;
408 BOOL bOnlyUser;
409 BOOL bMangledNames;
410 BOOL bWidelinks;
411 BOOL bSymlinks;
412 BOOL bSyncAlways;
413 BOOL bStrictAllocate;
414 BOOL bStrictSync;
415 char magic_char;
416 BOOL *copymap;
417 BOOL bDeleteReadonly;
418 BOOL bFakeOplocks;
419 BOOL bDeleteVetoFiles;
420 BOOL bDosFilemode;
421 BOOL bDosFiletimes;
422 BOOL bDosFiletimeResolution;
423 BOOL bFakeDirCreateTimes;
424 BOOL bBlockingLocks;
425 BOOL bInheritPerms;
426 BOOL bInheritACLS;
427 BOOL bInheritOwner;
428 BOOL bMSDfsRoot;
429 BOOL bUseClientDriver;
430 BOOL bDefaultDevmode;
431 BOOL bForcePrintername;
432 BOOL bNTAclSupport;
433 BOOL bForceUnknownAclUser;
434 BOOL bUseSendfile;
435 BOOL bProfileAcls;
436 BOOL bMap_acl_inherit;
437 BOOL bAfs_Share;
438 BOOL bEASupport;
439 BOOL bAclCheckPermissions;
440 int iallocation_roundup_size;
441 param_opt_struct *param_opt;
443 char dummy[3]; /* for alignment */
445 service;
448 /* This is a default service used to prime a services structure */
449 static service sDefault = {
450 True, /* valid */
451 False, /* not autoloaded */
452 NULL, /* szService */
453 NULL, /* szPath */
454 NULL, /* szUsername */
455 NULL, /* szInvalidUsers */
456 NULL, /* szValidUsers */
457 NULL, /* szAdminUsers */
458 NULL, /* szCopy */
459 NULL, /* szInclude */
460 NULL, /* szPreExec */
461 NULL, /* szPostExec */
462 NULL, /* szRootPreExec */
463 NULL, /* szRootPostExec */
464 NULL, /* szCupsOptions */
465 NULL, /* szPrintcommand */
466 NULL, /* szLpqcommand */
467 NULL, /* szLprmcommand */
468 NULL, /* szLppausecommand */
469 NULL, /* szLpresumecommand */
470 NULL, /* szQueuepausecommand */
471 NULL, /* szQueueresumecommand */
472 NULL, /* szPrintername */
473 NULL, /* szDontdescend */
474 NULL, /* szHostsallow */
475 NULL, /* szHostsdeny */
476 NULL, /* szMagicScript */
477 NULL, /* szMagicOutput */
478 NULL, /* szMangledMap */
479 NULL, /* szVetoFiles */
480 NULL, /* szHideFiles */
481 NULL, /* szVetoOplockFiles */
482 NULL, /* comment */
483 NULL, /* force user */
484 NULL, /* force group */
485 NULL, /* readlist */
486 NULL, /* writelist */
487 NULL, /* printer admin */
488 NULL, /* volume */
489 NULL, /* fstype */
490 NULL, /* vfs objects */
491 NULL, /* szMSDfsProxy */
492 0, /* iMinPrintSpace */
493 1000, /* iMaxPrintJobs */
494 0, /* iMaxReportedPrintJobs */
495 0, /* iWriteCacheSize */
496 0744, /* iCreate_mask */
497 0000, /* iCreate_force_mode */
498 0777, /* iSecurity_mask */
499 0, /* iSecurity_force_mode */
500 0755, /* iDir_mask */
501 0000, /* iDir_force_mode */
502 0777, /* iDir_Security_mask */
503 0, /* iDir_Security_force_mode */
504 0, /* iMaxConnections */
505 CASE_LOWER, /* iDefaultCase */
506 DEFAULT_PRINTING, /* iPrinting */
507 2, /* iOplockContentionLimit */
508 0, /* iCSCPolicy */
509 1024, /* iBlock_size */
510 False, /* bPreexecClose */
511 False, /* bRootpreexecClose */
512 Auto, /* case sensitive */
513 True, /* case preserve */
514 True, /* short case preserve */
515 True, /* bHideDotFiles */
516 False, /* bHideSpecialFiles */
517 False, /* bHideUnReadable */
518 False, /* bHideUnWriteableFiles */
519 True, /* bBrowseable */
520 True, /* bAvailable */
521 True, /* bRead_only */
522 True, /* bNo_set_dir */
523 False, /* bGuest_only */
524 False, /* bGuest_ok */
525 False, /* bPrint_ok */
526 False, /* bMap_system */
527 False, /* bMap_hidden */
528 True, /* bMap_archive */
529 False, /* bStoreDosAttributes */
530 True, /* bLocking */
531 True, /* iStrictLocking */
532 True, /* bPosixLocking */
533 True, /* bShareModes */
534 True, /* bOpLocks */
535 True, /* bLevel2OpLocks */
536 False, /* bOnlyUser */
537 True, /* bMangledNames */
538 True, /* bWidelinks */
539 True, /* bSymlinks */
540 False, /* bSyncAlways */
541 False, /* bStrictAllocate */
542 False, /* bStrictSync */
543 '~', /* magic char */
544 NULL, /* copymap */
545 False, /* bDeleteReadonly */
546 False, /* bFakeOplocks */
547 False, /* bDeleteVetoFiles */
548 False, /* bDosFilemode */
549 True, /* bDosFiletimes */
550 False, /* bDosFiletimeResolution */
551 False, /* bFakeDirCreateTimes */
552 True, /* bBlockingLocks */
553 False, /* bInheritPerms */
554 False, /* bInheritACLS */
555 False, /* bInheritOwner */
556 False, /* bMSDfsRoot */
557 False, /* bUseClientDriver */
558 False, /* bDefaultDevmode */
559 False, /* bForcePrintername */
560 True, /* bNTAclSupport */
561 False, /* bForceUnknownAclUser */
562 False, /* bUseSendfile */
563 False, /* bProfileAcls */
564 False, /* bMap_acl_inherit */
565 False, /* bAfs_Share */
566 False, /* bEASupport */
567 True, /* bAclCheckPermissions */
568 SMB_ROUNDUP_ALLOCATION_SIZE, /* iallocation_roundup_size */
570 NULL, /* Parametric options */
572 "" /* dummy */
575 /* local variables */
576 static service **ServicePtrs = NULL;
577 static int iNumServices = 0;
578 static int iServiceIndex = 0;
579 static BOOL bInGlobalSection = True;
580 static BOOL bGlobalOnly = False;
581 static int server_role;
582 static int default_server_announce;
584 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
586 /* prototypes for the special type handlers */
587 static BOOL handle_include( int snum, const char *pszParmValue, char **ptr);
588 static BOOL handle_copy( int snum, const char *pszParmValue, char **ptr);
589 static BOOL handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
590 static BOOL handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
591 static BOOL handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
592 static BOOL handle_debug_list( int snum, const char *pszParmValue, char **ptr );
593 static BOOL handle_workgroup( int snum, const char *pszParmValue, char **ptr );
594 static BOOL handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
595 static BOOL handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
596 static BOOL handle_charset( int snum, const char *pszParmValue, char **ptr );
597 static BOOL handle_acl_compatibility( int snum, const char *pszParmValue, char **ptr);
598 static BOOL handle_printing( int snum, const char *pszParmValue, char **ptr);
599 static BOOL handle_eventlog( int snum, const char *pszParmValue, char **ptr);
601 static void set_server_role(void);
602 static void set_default_server_announce_type(void);
603 static void set_allowed_client_auth(void);
605 static const struct enum_list enum_protocol[] = {
606 {PROTOCOL_NT1, "NT1"},
607 {PROTOCOL_LANMAN2, "LANMAN2"},
608 {PROTOCOL_LANMAN1, "LANMAN1"},
609 {PROTOCOL_CORE, "CORE"},
610 {PROTOCOL_COREPLUS, "COREPLUS"},
611 {PROTOCOL_COREPLUS, "CORE+"},
612 {-1, NULL}
615 static const struct enum_list enum_security[] = {
616 {SEC_SHARE, "SHARE"},
617 {SEC_USER, "USER"},
618 {SEC_SERVER, "SERVER"},
619 {SEC_DOMAIN, "DOMAIN"},
620 #ifdef HAVE_ADS
621 {SEC_ADS, "ADS"},
622 #endif
623 {-1, NULL}
626 static const struct enum_list enum_printing[] = {
627 {PRINT_SYSV, "sysv"},
628 {PRINT_AIX, "aix"},
629 {PRINT_HPUX, "hpux"},
630 {PRINT_BSD, "bsd"},
631 {PRINT_QNX, "qnx"},
632 {PRINT_PLP, "plp"},
633 {PRINT_LPRNG, "lprng"},
634 {PRINT_CUPS, "cups"},
635 {PRINT_LPRNT, "nt"},
636 {PRINT_LPROS2, "os2"},
637 #ifdef DEVELOPER
638 {PRINT_TEST, "test"},
639 {PRINT_VLP, "vlp"},
640 #endif /* DEVELOPER */
641 {-1, NULL}
644 static const struct enum_list enum_ldap_ssl[] = {
645 #ifdef WITH_LDAP_SAMCONFIG
646 {LDAP_SSL_ON, "Yes"},
647 {LDAP_SSL_ON, "yes"},
648 {LDAP_SSL_ON, "on"},
649 {LDAP_SSL_ON, "On"},
650 #endif
651 {LDAP_SSL_OFF, "no"},
652 {LDAP_SSL_OFF, "No"},
653 {LDAP_SSL_OFF, "off"},
654 {LDAP_SSL_OFF, "Off"},
655 {LDAP_SSL_START_TLS, "start tls"},
656 {LDAP_SSL_START_TLS, "Start_tls"},
657 {-1, NULL}
660 static const struct enum_list enum_ldap_passwd_sync[] = {
661 {LDAP_PASSWD_SYNC_OFF, "no"},
662 {LDAP_PASSWD_SYNC_OFF, "No"},
663 {LDAP_PASSWD_SYNC_OFF, "off"},
664 {LDAP_PASSWD_SYNC_OFF, "Off"},
665 {LDAP_PASSWD_SYNC_ON, "Yes"},
666 {LDAP_PASSWD_SYNC_ON, "yes"},
667 {LDAP_PASSWD_SYNC_ON, "on"},
668 {LDAP_PASSWD_SYNC_ON, "On"},
669 {LDAP_PASSWD_SYNC_ONLY, "Only"},
670 {LDAP_PASSWD_SYNC_ONLY, "only"},
671 {-1, NULL}
674 /* Types of machine we can announce as. */
675 #define ANNOUNCE_AS_NT_SERVER 1
676 #define ANNOUNCE_AS_WIN95 2
677 #define ANNOUNCE_AS_WFW 3
678 #define ANNOUNCE_AS_NT_WORKSTATION 4
680 static const struct enum_list enum_announce_as[] = {
681 {ANNOUNCE_AS_NT_SERVER, "NT"},
682 {ANNOUNCE_AS_NT_SERVER, "NT Server"},
683 {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
684 {ANNOUNCE_AS_WIN95, "win95"},
685 {ANNOUNCE_AS_WFW, "WfW"},
686 {-1, NULL}
689 static const struct enum_list enum_case[] = {
690 {CASE_LOWER, "lower"},
691 {CASE_UPPER, "upper"},
692 {-1, NULL}
695 static const struct enum_list enum_bool_auto[] = {
696 {False, "No"},
697 {False, "False"},
698 {False, "0"},
699 {True, "Yes"},
700 {True, "True"},
701 {True, "1"},
702 {Auto, "Auto"},
703 {-1, NULL}
706 /* Client-side offline caching policy types */
707 #define CSC_POLICY_MANUAL 0
708 #define CSC_POLICY_DOCUMENTS 1
709 #define CSC_POLICY_PROGRAMS 2
710 #define CSC_POLICY_DISABLE 3
712 static const struct enum_list enum_csc_policy[] = {
713 {CSC_POLICY_MANUAL, "manual"},
714 {CSC_POLICY_DOCUMENTS, "documents"},
715 {CSC_POLICY_PROGRAMS, "programs"},
716 {CSC_POLICY_DISABLE, "disable"},
717 {-1, NULL}
720 /* SMB signing types. */
721 static const struct enum_list enum_smb_signing_vals[] = {
722 {False, "No"},
723 {False, "False"},
724 {False, "0"},
725 {False, "Off"},
726 {False, "disabled"},
727 {True, "Yes"},
728 {True, "True"},
729 {True, "1"},
730 {True, "On"},
731 {True, "enabled"},
732 {Auto, "auto"},
733 {Required, "required"},
734 {Required, "mandatory"},
735 {Required, "force"},
736 {Required, "forced"},
737 {Required, "enforced"},
738 {-1, NULL}
743 Do you want session setups at user level security with a invalid
744 password to be rejected or allowed in as guest? WinNT rejects them
745 but it can be a pain as it means "net view" needs to use a password
747 You have 3 choices in the setting of map_to_guest:
749 "Never" means session setups with an invalid password
750 are rejected. This is the default.
752 "Bad User" means session setups with an invalid password
753 are rejected, unless the username does not exist, in which case it
754 is treated as a guest login
756 "Bad Password" means session setups with an invalid password
757 are treated as a guest login
759 Note that map_to_guest only has an effect in user or server
760 level security.
763 static const struct enum_list enum_map_to_guest[] = {
764 {NEVER_MAP_TO_GUEST, "Never"},
765 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
766 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
767 {-1, NULL}
770 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
772 * The FLAG_HIDE is explicit. Paramters set this way do NOT appear in any edit
773 * screen in SWAT. This is used to exclude parameters as well as to squash all
774 * parameters that have been duplicated by pseudonyms.
776 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
777 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
778 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
779 * respective views.
781 * NOTE2: Handling of duplicated (synonym) paramters:
782 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
783 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
784 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
785 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
788 static struct parm_struct parm_table[] = {
789 {N_("Base Options"), P_SEP, P_SEPARATOR},
791 {"dos charset", P_STRING, P_GLOBAL, &Globals.dos_charset, handle_charset, NULL, FLAG_ADVANCED},
792 {"unix charset", P_STRING, P_GLOBAL, &Globals.unix_charset, handle_charset, NULL, FLAG_ADVANCED},
793 {"display charset", P_STRING, P_GLOBAL, &Globals.display_charset, handle_charset, NULL, FLAG_ADVANCED},
794 {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
795 {"path", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
796 {"directory", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_HIDE},
797 {"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkgroup, handle_workgroup, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
798 #ifdef WITH_ADS
799 {"realm", P_USTRING, P_GLOBAL, &Globals.szRealm, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
800 #endif
801 {"netbios name", P_USTRING, P_GLOBAL, &Globals.szNetbiosName, handle_netbios_name, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
802 {"netbios aliases", P_LIST, P_GLOBAL, &Globals.szNetbiosAliases, handle_netbios_aliases, NULL, FLAG_ADVANCED},
803 {"netbios scope", P_USTRING, P_GLOBAL, &Globals.szNetbiosScope, handle_netbios_scope, NULL, FLAG_ADVANCED},
804 {"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED },
805 {"interfaces", P_LIST, P_GLOBAL, &Globals.szInterfaces, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
806 {"bind interfaces only", P_BOOL, P_GLOBAL, &Globals.bBindInterfacesOnly, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD},
808 {N_("Security Options"), P_SEP, P_SEPARATOR},
810 {"security", P_ENUM, P_GLOBAL, &Globals.security, NULL, enum_security, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
811 {"auth methods", P_LIST, P_GLOBAL, &Globals.AuthMethods, NULL, NULL, FLAG_ADVANCED},
812 {"encrypt passwords", P_BOOL, P_GLOBAL, &Globals.bEncryptPasswords, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
813 {"update encrypted", P_BOOL, P_GLOBAL, &Globals.bUpdateEncrypt, NULL, NULL, FLAG_ADVANCED},
814 {"client schannel", P_ENUM, P_GLOBAL, &Globals.clientSchannel, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED},
815 {"server schannel", P_ENUM, P_GLOBAL, &Globals.serverSchannel, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED},
816 {"allow trusted domains", P_BOOL, P_GLOBAL, &Globals.bAllowTrustedDomains, NULL, NULL, FLAG_ADVANCED},
817 {"hosts equiv", P_STRING, P_GLOBAL, &Globals.szHostsEquiv, NULL, NULL, FLAG_ADVANCED},
818 {"min password length", P_INTEGER, P_GLOBAL, &Globals.min_passwd_length, NULL, NULL, FLAG_DEPRECATED},
819 {"min passwd length", P_INTEGER, P_GLOBAL, &Globals.min_passwd_length, NULL, NULL, FLAG_DEPRECATED},
820 {"map to guest", P_ENUM, P_GLOBAL, &Globals.map_to_guest, NULL, enum_map_to_guest, FLAG_ADVANCED},
821 {"null passwords", P_BOOL, P_GLOBAL, &Globals.bNullPasswords, NULL, NULL, FLAG_ADVANCED},
822 {"obey pam restrictions", P_BOOL, P_GLOBAL, &Globals.bObeyPamRestrictions, NULL, NULL, FLAG_ADVANCED},
823 {"password server", P_STRING, P_GLOBAL, &Globals.szPasswordServer, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD},
824 {"smb passwd file", P_STRING, P_GLOBAL, &Globals.szSMBPasswdFile, NULL, NULL, FLAG_ADVANCED},
825 {"private dir", P_STRING, P_GLOBAL, &Globals.szPrivateDir, NULL, NULL, FLAG_ADVANCED},
826 {"passdb backend", P_LIST, P_GLOBAL, &Globals.szPassdbBackend, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD},
827 {"algorithmic rid base", P_INTEGER, P_GLOBAL, &Globals.AlgorithmicRidBase, NULL, NULL, FLAG_ADVANCED},
828 {"root directory", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, FLAG_ADVANCED},
829 {"root dir", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, FLAG_HIDE},
830 {"root", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, FLAG_HIDE},
831 {"guest account", P_STRING, P_GLOBAL, &Globals.szGuestaccount, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED},
832 {"enable privileges", P_BOOL, P_GLOBAL, &Globals.bEnablePrivileges, NULL, NULL, FLAG_ADVANCED},
834 {"pam password change", P_BOOL, P_GLOBAL, &Globals.bPamPasswordChange, NULL, NULL, FLAG_ADVANCED},
835 {"passwd program", P_STRING, P_GLOBAL, &Globals.szPasswdProgram, NULL, NULL, FLAG_ADVANCED},
836 {"passwd chat", P_STRING, P_GLOBAL, &Globals.szPasswdChat, NULL, NULL, FLAG_ADVANCED},
837 {"passwd chat debug", P_BOOL, P_GLOBAL, &Globals.bPasswdChatDebug, NULL, NULL, FLAG_ADVANCED},
838 {"passwd chat timeout", P_INTEGER, P_GLOBAL, &Globals.iPasswdChatTimeout, NULL, NULL, FLAG_ADVANCED},
839 {"check password script", P_STRING, P_GLOBAL, &Globals.szCheckPasswordScript, NULL, NULL, FLAG_ADVANCED},
840 {"username map", P_STRING, P_GLOBAL, &Globals.szUsernameMap, NULL, NULL, FLAG_ADVANCED},
841 {"password level", P_INTEGER, P_GLOBAL, &Globals.pwordlevel, NULL, NULL, FLAG_ADVANCED},
842 {"username level", P_INTEGER, P_GLOBAL, &Globals.unamelevel, NULL, NULL, FLAG_ADVANCED},
843 {"unix password sync", P_BOOL, P_GLOBAL, &Globals.bUnixPasswdSync, NULL, NULL, FLAG_ADVANCED},
844 {"restrict anonymous", P_INTEGER, P_GLOBAL, &Globals.restrict_anonymous, NULL, NULL, FLAG_ADVANCED},
845 {"lanman auth", P_BOOL, P_GLOBAL, &Globals.bLanmanAuth, NULL, NULL, FLAG_ADVANCED},
846 {"ntlm auth", P_BOOL, P_GLOBAL, &Globals.bNTLMAuth, NULL, NULL, FLAG_ADVANCED},
847 {"client NTLMv2 auth", P_BOOL, P_GLOBAL, &Globals.bClientNTLMv2Auth, NULL, NULL, FLAG_ADVANCED},
848 {"client lanman auth", P_BOOL, P_GLOBAL, &Globals.bClientLanManAuth, NULL, NULL, FLAG_ADVANCED},
849 {"client plaintext auth", P_BOOL, P_GLOBAL, &Globals.bClientPlaintextAuth, NULL, NULL, FLAG_ADVANCED},
851 {"username", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
852 {"user", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, FLAG_HIDE},
853 {"users", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, FLAG_HIDE},
855 {"invalid users", P_LIST, P_LOCAL, &sDefault.szInvalidUsers, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
856 {"valid users", P_LIST, P_LOCAL, &sDefault.szValidUsers, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
857 {"admin users", P_LIST, P_LOCAL, &sDefault.szAdminUsers, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
858 {"read list", P_LIST, P_LOCAL, &sDefault.readlist, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
859 {"write list", P_LIST, P_LOCAL, &sDefault.writelist, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
860 {"printer admin", P_LIST, P_LOCAL, &sDefault.printer_admin, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED },
861 {"force user", P_STRING, P_LOCAL, &sDefault.force_user, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
862 {"force group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
863 {"group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL, FLAG_ADVANCED},
865 {"read only", P_BOOL, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE},
866 {"write ok", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_HIDE},
867 {"writeable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_HIDE},
868 {"writable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_HIDE},
870 {"acl check permissions", P_BOOL, P_LOCAL, &sDefault.bAclCheckPermissions, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
871 {"create mask", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
872 {"create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_HIDE},
873 {"force create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_force_mode, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
874 {"security mask", P_OCTAL, P_LOCAL, &sDefault.iSecurity_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
875 {"force security mode", P_OCTAL, P_LOCAL, &sDefault.iSecurity_force_mode, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
876 {"directory mask", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
877 {"directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
878 {"force directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_force_mode, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
879 {"directory security mask", P_OCTAL, P_LOCAL, &sDefault.iDir_Security_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
880 {"force directory security mode", P_OCTAL, P_LOCAL, &sDefault.iDir_Security_force_mode, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
881 {"force unknown acl user", P_BOOL, P_LOCAL, &sDefault.bForceUnknownAclUser, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
882 {"inherit permissions", P_BOOL, P_LOCAL, &sDefault.bInheritPerms, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
883 {"inherit acls", P_BOOL, P_LOCAL, &sDefault.bInheritACLS, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
884 {"inherit owner", P_BOOL, P_LOCAL, &sDefault.bInheritOwner, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
885 {"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
886 {"only guest", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, FLAG_HIDE},
888 {"guest ok", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
889 {"public", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_HIDE},
891 {"only user", P_BOOL, P_LOCAL, &sDefault.bOnlyUser, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED},
892 {"hosts allow", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
893 {"allow hosts", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_HIDE},
894 {"hosts deny", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
895 {"deny hosts", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_HIDE},
896 {"preload modules", P_LIST, P_GLOBAL, &Globals.szPreloadModules, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
897 {"use kerberos keytab", P_BOOL, P_GLOBAL, &Globals.bUseKerberosKeytab, NULL, NULL, FLAG_ADVANCED},
899 {N_("Logging Options"), P_SEP, P_SEPARATOR},
901 {"log level", P_STRING, P_GLOBAL, &Globals.szLogLevel, handle_debug_list, NULL, FLAG_ADVANCED},
902 {"debuglevel", P_STRING, P_GLOBAL, &Globals.szLogLevel, handle_debug_list, NULL, FLAG_HIDE},
903 {"syslog", P_INTEGER, P_GLOBAL, &Globals.syslog, NULL, NULL, FLAG_ADVANCED},
904 {"syslog only", P_BOOL, P_GLOBAL, &Globals.bSyslogOnly, NULL, NULL, FLAG_ADVANCED},
905 {"log file", P_STRING, P_GLOBAL, &Globals.szLogFile, NULL, NULL, FLAG_ADVANCED},
907 {"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL, NULL, FLAG_ADVANCED},
908 {"debug timestamp", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, FLAG_ADVANCED},
909 {"timestamp logs", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, FLAG_ADVANCED},
910 {"debug hires timestamp", P_BOOL, P_GLOBAL, &Globals.bDebugHiresTimestamp, NULL, NULL, FLAG_ADVANCED},
911 {"debug pid", P_BOOL, P_GLOBAL, &Globals.bDebugPid, NULL, NULL, FLAG_ADVANCED},
912 {"debug uid", P_BOOL, P_GLOBAL, &Globals.bDebugUid, NULL, NULL, FLAG_ADVANCED},
914 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
916 {"allocation roundup size", P_INTEGER, P_LOCAL, &sDefault.iallocation_roundup_size, NULL, NULL, FLAG_ADVANCED},
917 {"smb ports", P_STRING, P_GLOBAL, &Globals.smb_ports, NULL, NULL, FLAG_ADVANCED},
918 {"large readwrite", P_BOOL, P_GLOBAL, &Globals.bLargeReadwrite, NULL, NULL, FLAG_ADVANCED},
919 {"max protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, FLAG_ADVANCED},
920 {"protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, FLAG_ADVANCED},
921 {"min protocol", P_ENUM, P_GLOBAL, &Globals.minprotocol, NULL, enum_protocol, FLAG_ADVANCED},
922 {"read bmpx", P_BOOL, P_GLOBAL, &Globals.bReadbmpx, NULL, NULL, FLAG_ADVANCED},
923 {"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL, FLAG_ADVANCED},
924 {"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL, FLAG_ADVANCED},
925 {"disable netbios", P_BOOL, P_GLOBAL, &Globals.bDisableNetbios, NULL, NULL, FLAG_ADVANCED},
927 {"acl compatibility", P_STRING, P_GLOBAL, &Globals.szAclCompat, handle_acl_compatibility, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
928 {"defer sharing violations", P_BOOL, P_GLOBAL, &Globals.bDeferSharingViolations, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
929 {"ea support", P_BOOL, P_LOCAL, &sDefault.bEASupport, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
930 {"nt acl support", P_BOOL, P_LOCAL, &sDefault.bNTAclSupport, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
931 {"nt pipe support", P_BOOL, P_GLOBAL, &Globals.bNTPipeSupport, NULL, NULL, FLAG_ADVANCED},
932 {"nt status support", P_BOOL, P_GLOBAL, &Globals.bNTStatusSupport, NULL, NULL, FLAG_ADVANCED},
933 {"profile acls", P_BOOL, P_LOCAL, &sDefault.bProfileAcls, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
935 {"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL, NULL, FLAG_ADVANCED},
936 {"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as, FLAG_ADVANCED},
937 {"map acl inherit", P_BOOL, P_LOCAL, &sDefault.bMap_acl_inherit, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
938 {"afs share", P_BOOL, P_LOCAL, &sDefault.bAfs_Share, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
939 {"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL, FLAG_ADVANCED},
940 {"max xmit", P_INTEGER, P_GLOBAL, &Globals.max_xmit, NULL, NULL, FLAG_ADVANCED},
942 {"name resolve order", P_STRING, P_GLOBAL, &Globals.szNameResolveOrder, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD},
943 {"max ttl", P_INTEGER, P_GLOBAL, &Globals.max_ttl, NULL, NULL, FLAG_ADVANCED},
944 {"max wins ttl", P_INTEGER, P_GLOBAL, &Globals.max_wins_ttl, NULL, NULL, FLAG_ADVANCED},
945 {"min wins ttl", P_INTEGER, P_GLOBAL, &Globals.min_wins_ttl, NULL, NULL, FLAG_ADVANCED},
946 {"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL, NULL, FLAG_ADVANCED},
947 {"unix extensions", P_BOOL, P_GLOBAL, &Globals.bUnixExtensions, NULL, NULL, FLAG_ADVANCED},
948 {"use spnego", P_BOOL, P_GLOBAL, &Globals.bUseSpnego, NULL, NULL, FLAG_ADVANCED},
949 {"client signing", P_ENUM, P_GLOBAL, &Globals.client_signing, NULL, enum_smb_signing_vals, FLAG_ADVANCED},
950 {"server signing", P_ENUM, P_GLOBAL, &Globals.server_signing, NULL, enum_smb_signing_vals, FLAG_ADVANCED},
951 {"client use spnego", P_BOOL, P_GLOBAL, &Globals.bClientUseSpnego, NULL, NULL, FLAG_ADVANCED},
953 {"enable svcctl", P_LIST, P_GLOBAL, &Globals.szServicesList, NULL, NULL, FLAG_ADVANCED},
955 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
957 {"block size", P_INTEGER, P_LOCAL, &sDefault.iBlock_size, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
958 {"change notify timeout", P_INTEGER, P_GLOBAL, &Globals.change_notify_timeout, NULL, NULL, FLAG_ADVANCED},
959 {"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL, NULL, FLAG_ADVANCED},
960 {"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL, NULL, FLAG_ADVANCED},
961 {"keepalive", P_INTEGER, P_GLOBAL, &keepalive, NULL, NULL, FLAG_ADVANCED},
962 {"kernel change notify", P_BOOL, P_GLOBAL, &Globals.bKernelChangeNotify, NULL, NULL, FLAG_ADVANCED},
964 {"lpq cache time", P_INTEGER, P_GLOBAL, &Globals.lpqcachetime, NULL, NULL, FLAG_ADVANCED},
965 {"max smbd processes", P_INTEGER, P_GLOBAL, &Globals.iMaxSmbdProcesses, NULL, NULL, FLAG_ADVANCED},
966 {"max connections", P_INTEGER, P_LOCAL, &sDefault.iMaxConnections, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
967 {"paranoid server security", P_BOOL, P_GLOBAL, &Globals.paranoid_server_security, NULL, NULL, FLAG_ADVANCED},
968 {"max disk size", P_INTEGER, P_GLOBAL, &Globals.maxdisksize, NULL, NULL, FLAG_ADVANCED},
969 {"max open files", P_INTEGER, P_GLOBAL, &Globals.max_open_files, NULL, NULL, FLAG_ADVANCED},
970 {"min print space", P_INTEGER, P_LOCAL, &sDefault.iMinPrintSpace, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
972 {"socket options", P_GSTRING, P_GLOBAL, user_socket_options, NULL, NULL, FLAG_ADVANCED},
973 {"strict allocate", P_BOOL, P_LOCAL, &sDefault.bStrictAllocate, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
974 {"strict sync", P_BOOL, P_LOCAL, &sDefault.bStrictSync, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
975 {"sync always", P_BOOL, P_LOCAL, &sDefault.bSyncAlways, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
976 {"use mmap", P_BOOL, P_GLOBAL, &Globals.bUseMmap, NULL, NULL, FLAG_ADVANCED},
977 {"use sendfile", P_BOOL, P_LOCAL, &sDefault.bUseSendfile, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
978 {"hostname lookups", P_BOOL, P_GLOBAL, &Globals.bHostnameLookups, NULL, NULL, FLAG_ADVANCED},
979 {"write cache size", P_INTEGER, P_LOCAL, &sDefault.iWriteCacheSize, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED},
981 {"name cache timeout", P_INTEGER, P_GLOBAL, &Globals.name_cache_timeout, NULL, NULL, FLAG_ADVANCED},
983 {N_("Printing Options"), P_SEP, P_SEPARATOR},
985 {"max reported print jobs", P_INTEGER, P_LOCAL, &sDefault.iMaxReportedPrintJobs, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
986 {"max print jobs", P_INTEGER, P_LOCAL, &sDefault.iMaxPrintJobs, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
987 {"load printers", P_BOOL, P_GLOBAL, &Globals.bLoadPrinters, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
988 {"printcap cache time", P_INTEGER, P_GLOBAL, &Globals.PrintcapCacheTime, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
989 {"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
990 {"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, FLAG_HIDE},
991 {"printable", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
992 {"print ok", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, FLAG_HIDE},
993 {"printing", P_ENUM, P_LOCAL, &sDefault.iPrinting, handle_printing, enum_printing, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
994 {"cups options", P_STRING, P_LOCAL, &sDefault.szCupsOptions, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
995 {"cups server", P_STRING, P_GLOBAL, &Globals.szCupsServer, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
996 {"print command", P_STRING, P_LOCAL, &sDefault.szPrintcommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
997 {"disable spoolss", P_BOOL, P_GLOBAL, &Globals.bDisableSpoolss, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
998 {"enable spoolss", P_BOOLREV, P_GLOBAL, &Globals.bDisableSpoolss, NULL, NULL, FLAG_HIDE},
999 {"lpq command", P_STRING, P_LOCAL, &sDefault.szLpqcommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1000 {"lprm command", P_STRING, P_LOCAL, &sDefault.szLprmcommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1001 {"lppause command", P_STRING, P_LOCAL, &sDefault.szLppausecommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1002 {"lpresume command", P_STRING, P_LOCAL, &sDefault.szLpresumecommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1003 {"queuepause command", P_STRING, P_LOCAL, &sDefault.szQueuepausecommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1004 {"queueresume command", P_STRING, P_LOCAL, &sDefault.szQueueresumecommand, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL},
1006 {"enumports command", P_STRING, P_GLOBAL, &Globals.szEnumPortsCommand, NULL, NULL, FLAG_ADVANCED},
1007 {"addprinter command", P_STRING, P_GLOBAL, &Globals.szAddPrinterCommand, NULL, NULL, FLAG_ADVANCED},
1008 {"deleteprinter command", P_STRING, P_GLOBAL, &Globals.szDeletePrinterCommand, NULL, NULL, FLAG_ADVANCED},
1009 {"show add printer wizard", P_BOOL, P_GLOBAL, &Globals.bMsAddPrinterWizard, NULL, NULL, FLAG_ADVANCED},
1010 {"os2 driver map", P_STRING, P_GLOBAL, &Globals.szOs2DriverMap, NULL, NULL, FLAG_ADVANCED},
1012 {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
1013 {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_HIDE},
1014 {"use client driver", P_BOOL, P_LOCAL, &sDefault.bUseClientDriver, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
1015 {"default devmode", P_BOOL, P_LOCAL, &sDefault.bDefaultDevmode, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
1016 {"force printername", P_BOOL, P_LOCAL, &sDefault.bForcePrintername, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
1018 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
1019 {"mangling method", P_STRING, P_GLOBAL, &Globals.szManglingMethod, NULL, NULL, FLAG_ADVANCED},
1020 {"mangle prefix", P_INTEGER, P_GLOBAL, &Globals.mangle_prefix, NULL, NULL, FLAG_ADVANCED},
1022 {"default case", P_ENUM, P_LOCAL, &sDefault.iDefaultCase, NULL, enum_case, FLAG_ADVANCED | FLAG_SHARE},
1023 {"case sensitive", P_ENUM, P_LOCAL, &sDefault.iCaseSensitive, NULL, enum_bool_auto, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1024 {"casesignames", P_ENUM, P_LOCAL, &sDefault.iCaseSensitive, NULL, enum_bool_auto, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE},
1025 {"preserve case", P_BOOL, P_LOCAL, &sDefault.bCasePreserve, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1026 {"short preserve case", P_BOOL, P_LOCAL, &sDefault.bShortCasePreserve, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1027 {"mangling char", P_CHAR, P_LOCAL, &sDefault.magic_char, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1028 {"hide dot files", P_BOOL, P_LOCAL, &sDefault.bHideDotFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1029 {"hide special files", P_BOOL, P_LOCAL, &sDefault.bHideSpecialFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1030 {"hide unreadable", P_BOOL, P_LOCAL, &sDefault.bHideUnReadable, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1031 {"hide unwriteable files", P_BOOL, P_LOCAL, &sDefault.bHideUnWriteableFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1032 {"delete veto files", P_BOOL, P_LOCAL, &sDefault.bDeleteVetoFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1033 {"veto files", P_STRING, P_LOCAL, &sDefault.szVetoFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL },
1034 {"hide files", P_STRING, P_LOCAL, &sDefault.szHideFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL },
1035 {"veto oplock files", P_STRING, P_LOCAL, &sDefault.szVetoOplockFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL },
1036 {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1037 {"map hidden", P_BOOL, P_LOCAL, &sDefault.bMap_hidden, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1038 {"map archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1039 {"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1040 {"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED },
1041 {"max stat cache size", P_INTEGER, P_GLOBAL, &Globals.iMaxStatCacheSize, NULL, NULL, FLAG_ADVANCED},
1042 {"stat cache", P_BOOL, P_GLOBAL, &Globals.bStatCache, NULL, NULL, FLAG_ADVANCED},
1043 {"store dos attributes", P_BOOL, P_LOCAL, &sDefault.bStoreDosAttributes, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1045 {N_("Domain Options"), P_SEP, P_SEPARATOR},
1047 {"machine password timeout", P_INTEGER, P_GLOBAL, &Globals.machine_password_timeout, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD},
1049 {N_("Logon Options"), P_SEP, P_SEPARATOR},
1051 {"add user script", P_STRING, P_GLOBAL, &Globals.szAddUserScript, NULL, NULL, FLAG_ADVANCED},
1052 {"delete user script", P_STRING, P_GLOBAL, &Globals.szDelUserScript, NULL, NULL, FLAG_ADVANCED},
1053 {"add group script", P_STRING, P_GLOBAL, &Globals.szAddGroupScript, NULL, NULL, FLAG_ADVANCED},
1054 {"delete group script", P_STRING, P_GLOBAL, &Globals.szDelGroupScript, NULL, NULL, FLAG_ADVANCED},
1055 {"add user to group script", P_STRING, P_GLOBAL, &Globals.szAddUserToGroupScript, NULL, NULL, FLAG_ADVANCED},
1056 {"delete user from group script", P_STRING, P_GLOBAL, &Globals.szDelUserFromGroupScript, NULL, NULL, FLAG_ADVANCED},
1057 {"set primary group script", P_STRING, P_GLOBAL, &Globals.szSetPrimaryGroupScript, NULL, NULL, FLAG_ADVANCED},
1058 {"add machine script", P_STRING, P_GLOBAL, &Globals.szAddMachineScript, NULL, NULL, FLAG_ADVANCED},
1059 {"shutdown script", P_STRING, P_GLOBAL, &Globals.szShutdownScript, NULL, NULL, FLAG_ADVANCED},
1060 {"abort shutdown script", P_STRING, P_GLOBAL, &Globals.szAbortShutdownScript, NULL, NULL, FLAG_ADVANCED},
1062 {"logon script", P_STRING, P_GLOBAL, &Globals.szLogonScript, NULL, NULL, FLAG_ADVANCED},
1063 {"logon path", P_STRING, P_GLOBAL, &Globals.szLogonPath, NULL, NULL, FLAG_ADVANCED},
1064 {"logon drive", P_STRING, P_GLOBAL, &Globals.szLogonDrive, NULL, NULL, FLAG_ADVANCED},
1065 {"logon home", P_STRING, P_GLOBAL, &Globals.szLogonHome, NULL, NULL, FLAG_ADVANCED},
1066 {"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL, NULL, FLAG_ADVANCED},
1068 {N_("Browse Options"), P_SEP, P_SEPARATOR},
1070 {"os level", P_INTEGER, P_GLOBAL, &Globals.os_level, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED},
1071 {"lm announce", P_ENUM, P_GLOBAL, &Globals.lm_announce, NULL, enum_bool_auto, FLAG_ADVANCED},
1072 {"lm interval", P_INTEGER, P_GLOBAL, &Globals.lm_interval, NULL, NULL, FLAG_ADVANCED},
1073 {"preferred master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED},
1074 {"prefered master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_HIDE},
1075 {"local master", P_BOOL, P_GLOBAL, &Globals.bLocalMaster, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED},
1076 {"domain master", P_ENUM, P_GLOBAL, &Globals.bDomainMaster, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED},
1077 {"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL, NULL, FLAG_ADVANCED},
1078 {"browseable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1079 {"browsable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_HIDE},
1080 {"enhanced browsing", P_BOOL, P_GLOBAL, &Globals.enhanced_browsing, NULL, NULL, FLAG_ADVANCED},
1082 {N_("WINS Options"), P_SEP, P_SEPARATOR},
1084 {"dns proxy", P_BOOL, P_GLOBAL, &Globals.bDNSproxy, NULL, NULL, FLAG_ADVANCED},
1085 {"wins proxy", P_BOOL, P_GLOBAL, &Globals.bWINSproxy, NULL, NULL, FLAG_ADVANCED},
1087 {"wins server", P_LIST, P_GLOBAL, &Globals.szWINSservers, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
1088 {"wins support", P_BOOL, P_GLOBAL, &Globals.bWINSsupport, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD},
1089 {"wins hook", P_STRING, P_GLOBAL, &Globals.szWINSHook, NULL, NULL, FLAG_ADVANCED},
1090 {"wins partners", P_STRING, P_GLOBAL, &Globals.szWINSPartners, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD},
1092 {N_("Locking Options"), P_SEP, P_SEPARATOR},
1094 {"blocking locks", P_BOOL, P_LOCAL, &sDefault.bBlockingLocks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1095 {"csc policy", P_ENUM, P_LOCAL, &sDefault.iCSCPolicy, NULL, enum_csc_policy, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1096 {"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1097 {"kernel oplocks", P_BOOL, P_GLOBAL, &Globals.bKernelOplocks, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
1098 {"locking", P_BOOL, P_LOCAL, &sDefault.bLocking, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1099 {"lock spin count", P_INTEGER, P_GLOBAL, &Globals.iLockSpinCount, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
1100 {"lock spin time", P_INTEGER, P_GLOBAL, &Globals.iLockSpinTime, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
1102 {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1103 {"level2 oplocks", P_BOOL, P_LOCAL, &sDefault.bLevel2OpLocks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1104 {"oplock break wait time", P_INTEGER, P_GLOBAL, &Globals.oplock_break_wait_time, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
1105 {"oplock contention limit", P_INTEGER, P_LOCAL, &sDefault.iOplockContentionLimit, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1106 {"posix locking", P_BOOL, P_LOCAL, &sDefault.bPosixLocking, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1107 {"strict locking", P_ENUM, P_LOCAL, &sDefault.iStrictLocking, NULL, enum_bool_auto, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1108 {"share modes", P_BOOL, P_LOCAL, &sDefault.bShareModes, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1110 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
1112 #ifdef WITH_LDAP_SAMCONFIG
1113 {"ldap server", P_STRING, P_GLOBAL, &Globals.szLdapServer, NULL, NULL, FLAG_ADVANCED},
1114 {"ldap port", P_INTEGER, P_GLOBAL, &Globals.ldap_port, NULL, NULL, FLAG_ADVANCED},
1115 #endif
1116 {"ldap admin dn", P_STRING, P_GLOBAL, &Globals.szLdapAdminDn, NULL, NULL, FLAG_ADVANCED},
1117 {"ldap delete dn", P_BOOL, P_GLOBAL, &Globals.ldap_delete_dn, NULL, NULL, FLAG_ADVANCED},
1118 {"ldap filter", P_STRING, P_GLOBAL, &Globals.szLdapFilter, NULL, NULL, FLAG_ADVANCED},
1119 {"ldap group suffix", P_STRING, P_GLOBAL, &Globals.szLdapGroupSuffix, NULL, NULL, FLAG_ADVANCED},
1120 {"ldap idmap suffix", P_STRING, P_GLOBAL, &Globals.szLdapIdmapSuffix, NULL, NULL, FLAG_ADVANCED},
1121 {"ldap machine suffix", P_STRING, P_GLOBAL, &Globals.szLdapMachineSuffix, NULL, NULL, FLAG_ADVANCED},
1122 {"ldap passwd sync", P_ENUM, P_GLOBAL, &Globals.ldap_passwd_sync, NULL, enum_ldap_passwd_sync, FLAG_ADVANCED},
1123 {"ldap password sync", P_ENUM, P_GLOBAL, &Globals.ldap_passwd_sync, NULL, enum_ldap_passwd_sync, FLAG_HIDE},
1124 {"ldap replication sleep", P_INTEGER, P_GLOBAL, &Globals.ldap_replication_sleep, NULL, NULL, FLAG_ADVANCED},
1125 {"ldap suffix", P_STRING, P_GLOBAL, &Globals.szLdapSuffix, NULL, NULL, FLAG_ADVANCED},
1126 {"ldap ssl", P_ENUM, P_GLOBAL, &Globals.ldap_ssl, NULL, enum_ldap_ssl, FLAG_ADVANCED},
1127 {"ldap timeout", P_INTEGER, P_GLOBAL, &Globals.ldap_timeout, NULL, NULL, FLAG_ADVANCED},
1128 {"ldap page size", P_INTEGER, P_GLOBAL, &Globals.ldap_page_size, NULL, NULL, FLAG_ADVANCED},
1129 {"ldap user suffix", P_STRING, P_GLOBAL, &Globals.szLdapUserSuffix, NULL, NULL, FLAG_ADVANCED},
1131 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
1132 {"add share command", P_STRING, P_GLOBAL, &Globals.szAddShareCommand, NULL, NULL, FLAG_ADVANCED},
1133 {"change share command", P_STRING, P_GLOBAL, &Globals.szChangeShareCommand, NULL, NULL, FLAG_ADVANCED},
1134 {"delete share command", P_STRING, P_GLOBAL, &Globals.szDeleteShareCommand, NULL, NULL, FLAG_ADVANCED},
1136 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
1137 {"eventlog open command", P_STRING, P_GLOBAL, &Globals.szEventLogOpenCommand, handle_eventlog, NULL, FLAG_ADVANCED},
1138 {"eventlog read command", P_STRING, P_GLOBAL, &Globals.szEventLogReadCommand, handle_eventlog, NULL, FLAG_ADVANCED},
1139 {"eventlog clear command", P_STRING, P_GLOBAL, &Globals.szEventLogClearCommand, handle_eventlog, NULL, FLAG_ADVANCED},
1140 {"eventlog num records command", P_STRING, P_GLOBAL, &Globals.szEventLogNumRecordsCommand, handle_eventlog, NULL, FLAG_ADVANCED},
1141 {"eventlog oldest record command", P_STRING, P_GLOBAL, &Globals.szEventLogOldestRecordCommand, handle_eventlog, NULL, FLAG_ADVANCED},
1142 {"eventlog list", P_LIST, P_GLOBAL, &Globals.szEventLogs, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
1144 {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL, FLAG_HIDE},
1145 {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED},
1146 {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED},
1147 {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_ADVANCED},
1148 {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_HIDE},
1149 {"pid directory", P_STRING, P_GLOBAL, &Globals.szPidDir, NULL, NULL, FLAG_ADVANCED},
1150 #ifdef WITH_UTMP
1151 {"utmp directory", P_STRING, P_GLOBAL, &Globals.szUtmpDir, NULL, NULL, FLAG_ADVANCED},
1152 {"wtmp directory", P_STRING, P_GLOBAL, &Globals.szWtmpDir, NULL, NULL, FLAG_ADVANCED},
1153 {"utmp", P_BOOL, P_GLOBAL, &Globals.bUtmp, NULL, NULL, FLAG_ADVANCED},
1154 #endif
1156 {"default service", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL, FLAG_ADVANCED},
1157 {"default", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL, FLAG_ADVANCED},
1158 {"message command", P_STRING, P_GLOBAL, &Globals.szMsgCommand, NULL, NULL, FLAG_ADVANCED},
1159 {"dfree command", P_STRING, P_GLOBAL, &Globals.szDfree, NULL, NULL, FLAG_ADVANCED},
1160 {"get quota command", P_STRING, P_GLOBAL, &Globals.szGetQuota, NULL, NULL, FLAG_ADVANCED},
1161 {"set quota command", P_STRING, P_GLOBAL, &Globals.szSetQuota, NULL, NULL, FLAG_ADVANCED},
1162 {"remote announce", P_STRING, P_GLOBAL, &Globals.szRemoteAnnounce, NULL, NULL, FLAG_ADVANCED},
1163 {"remote browse sync", P_STRING, P_GLOBAL, &Globals.szRemoteBrowseSync, NULL, NULL, FLAG_ADVANCED},
1164 {"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL, NULL, FLAG_ADVANCED},
1165 {"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL, NULL, FLAG_ADVANCED},
1166 {"afs username map", P_STRING, P_GLOBAL, &Globals.szAfsUsernameMap, NULL, NULL, FLAG_ADVANCED},
1167 {"afs token lifetime", P_INTEGER, P_GLOBAL, &Globals.iAfsTokenLifetime, NULL, NULL, FLAG_ADVANCED},
1168 {"log nt token command", P_STRING, P_GLOBAL, &Globals.szLogNtTokenCommand, NULL, NULL, FLAG_ADVANCED},
1169 {"time offset", P_INTEGER, P_GLOBAL, &extra_time_offset, NULL, NULL, FLAG_ADVANCED},
1170 {"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL, NULL, FLAG_ADVANCED},
1171 {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL, NULL, FLAG_HIDE},
1173 {"copy", P_STRING, P_LOCAL, &sDefault.szCopy, handle_copy, NULL, FLAG_HIDE},
1174 {"include", P_STRING, P_LOCAL, &sDefault.szInclude, handle_include, NULL, FLAG_HIDE},
1175 {"preexec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1176 {"exec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL, FLAG_ADVANCED},
1178 {"preexec close", P_BOOL, P_LOCAL, &sDefault.bPreexecClose, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1179 {"postexec", P_STRING, P_LOCAL, &sDefault.szPostExec, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1180 {"root preexec", P_STRING, P_LOCAL, &sDefault.szRootPreExec, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1181 {"root preexec close", P_BOOL, P_LOCAL, &sDefault.bRootpreexecClose, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1182 {"root postexec", P_STRING, P_LOCAL, &sDefault.szRootPostExec, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1183 {"available", P_BOOL, P_LOCAL, &sDefault.bAvailable, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
1184 {"volume", P_STRING, P_LOCAL, &sDefault.volume, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE },
1185 {"fstype", P_STRING, P_LOCAL, &sDefault.fstype, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1186 {"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1187 {"wide links", P_BOOL, P_LOCAL, &sDefault.bWidelinks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1188 {"follow symlinks", P_BOOL, P_LOCAL, &sDefault.bSymlinks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1189 {"dont descend", P_STRING, P_LOCAL, &sDefault.szDontdescend, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1190 {"magic script", P_STRING, P_LOCAL, &sDefault.szMagicScript, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1191 {"magic output", P_STRING, P_LOCAL, &sDefault.szMagicOutput, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1192 {"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1193 {"dos filemode", P_BOOL, P_LOCAL, &sDefault.bDosFilemode, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1194 {"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1195 {"dos filetime resolution", P_BOOL, P_LOCAL, &sDefault.bDosFiletimeResolution, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1197 {"fake directory create times", P_BOOL, P_LOCAL, &sDefault.bFakeDirCreateTimes, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
1198 {"panic action", P_STRING, P_GLOBAL, &Globals.szPanicAction, NULL, NULL, FLAG_ADVANCED},
1200 {N_("VFS module options"), P_SEP, P_SEPARATOR},
1202 {"vfs objects", P_LIST, P_LOCAL, &sDefault.szVfsObjects, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1203 {"vfs object", P_LIST, P_LOCAL, &sDefault.szVfsObjects, NULL, NULL, FLAG_HIDE},
1206 {"msdfs root", P_BOOL, P_LOCAL, &sDefault.bMSDfsRoot, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1207 {"msdfs proxy", P_STRING, P_LOCAL, &sDefault.szMSDfsProxy, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
1208 {"host msdfs", P_BOOL, P_GLOBAL, &Globals.bHostMSDfs, NULL, NULL, FLAG_ADVANCED},
1210 {N_("Winbind options"), P_SEP, P_SEPARATOR},
1212 {"enable rid algorithm", P_BOOL, P_GLOBAL, &Globals.bEnableRidAlgorithm, NULL, NULL, FLAG_DEPRECATED},
1213 {"idmap backend", P_LIST, P_GLOBAL, &Globals.szIdmapBackend, NULL, NULL, FLAG_ADVANCED},
1214 {"idmap uid", P_STRING, P_GLOBAL, &Globals.szIdmapUID, handle_idmap_uid, NULL, FLAG_ADVANCED},
1215 {"winbind uid", P_STRING, P_GLOBAL, &Globals.szIdmapUID, handle_idmap_uid, NULL, FLAG_HIDE},
1216 {"idmap gid", P_STRING, P_GLOBAL, &Globals.szIdmapGID, handle_idmap_gid, NULL, FLAG_ADVANCED},
1217 {"winbind gid", P_STRING, P_GLOBAL, &Globals.szIdmapGID, handle_idmap_gid, NULL, FLAG_HIDE},
1218 {"template primary group", P_STRING, P_GLOBAL, &Globals.szTemplatePrimaryGroup, NULL, NULL, FLAG_ADVANCED},
1219 {"template homedir", P_STRING, P_GLOBAL, &Globals.szTemplateHomedir, NULL, NULL, FLAG_ADVANCED},
1220 {"template shell", P_STRING, P_GLOBAL, &Globals.szTemplateShell, NULL, NULL, FLAG_ADVANCED},
1221 {"winbind separator", P_STRING, P_GLOBAL, &Globals.szWinbindSeparator, NULL, NULL, FLAG_ADVANCED},
1222 {"winbind cache time", P_INTEGER, P_GLOBAL, &Globals.winbind_cache_time, NULL, NULL, FLAG_ADVANCED},
1223 {"winbind enable local accounts", P_BOOL, P_GLOBAL, &Globals.bWinbindEnableLocalAccounts, NULL, NULL, FLAG_ADVANCED|FLAG_DEPRECATED},
1224 {"winbind enum users", P_BOOL, P_GLOBAL, &Globals.bWinbindEnumUsers, NULL, NULL, FLAG_ADVANCED},
1225 {"winbind enum groups", P_BOOL, P_GLOBAL, &Globals.bWinbindEnumGroups, NULL, NULL, FLAG_ADVANCED},
1226 {"winbind use default domain", P_BOOL, P_GLOBAL, &Globals.bWinbindUseDefaultDomain, NULL, NULL, FLAG_ADVANCED},
1227 {"winbind trusted domains only", P_BOOL, P_GLOBAL, &Globals.bWinbindTrustedDomainsOnly, NULL, NULL, FLAG_ADVANCED},
1228 {"winbind nested groups", P_BOOL, P_GLOBAL, &Globals.bWinbindNestedGroups, NULL, NULL, FLAG_ADVANCED},
1230 {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
1233 /***************************************************************************
1234 Initialise the sDefault parameter structure for the printer values.
1235 ***************************************************************************/
1237 static void init_printer_values(service *pService)
1239 /* choose defaults depending on the type of printing */
1240 switch (pService->iPrinting) {
1241 case PRINT_BSD:
1242 case PRINT_AIX:
1243 case PRINT_LPRNT:
1244 case PRINT_LPROS2:
1245 string_set(&pService->szLpqcommand, "lpq -P'%p'");
1246 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
1247 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
1248 break;
1250 case PRINT_LPRNG:
1251 case PRINT_PLP:
1252 string_set(&pService->szLpqcommand, "lpq -P'%p'");
1253 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
1254 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
1255 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
1256 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
1257 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
1258 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
1259 break;
1261 case PRINT_CUPS:
1262 #ifdef HAVE_CUPS
1263 /* set the lpq command to contain the destination printer
1264 name only. This is used by cups_queue_get() */
1265 string_set(&pService->szLpqcommand, "%p");
1266 string_set(&pService->szLprmcommand, "");
1267 string_set(&pService->szPrintcommand, "");
1268 string_set(&pService->szLppausecommand, "");
1269 string_set(&pService->szLpresumecommand, "");
1270 string_set(&pService->szQueuepausecommand, "");
1271 string_set(&pService->szQueueresumecommand, "");
1272 #else
1273 string_set(&pService->szLpqcommand, "lpq -P'%p'");
1274 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
1275 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
1276 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
1277 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
1278 string_set(&pService->szQueuepausecommand, "disable '%p'");
1279 string_set(&pService->szQueueresumecommand, "enable '%p'");
1280 #endif /* HAVE_CUPS */
1281 break;
1283 case PRINT_SYSV:
1284 case PRINT_HPUX:
1285 string_set(&pService->szLpqcommand, "lpstat -o%p");
1286 string_set(&pService->szLprmcommand, "cancel %p-%j");
1287 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
1288 string_set(&pService->szQueuepausecommand, "disable %p");
1289 string_set(&pService->szQueueresumecommand, "enable %p");
1290 #ifndef HPUX
1291 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
1292 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
1293 #endif /* HPUX */
1294 break;
1296 case PRINT_QNX:
1297 string_set(&pService->szLpqcommand, "lpq -P%p");
1298 string_set(&pService->szLprmcommand, "lprm -P%p %j");
1299 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
1300 break;
1302 #ifdef DEVELOPER
1303 case PRINT_TEST:
1304 case PRINT_VLP:
1305 string_set(&pService->szPrintcommand, "vlp print %p %s");
1306 string_set(&pService->szLpqcommand, "vlp lpq %p");
1307 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
1308 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
1309 string_set(&pService->szLpresumecommand, "vlp lpresum %p %j");
1310 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
1311 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
1312 break;
1313 #endif /* DEVELOPER */
1318 /***************************************************************************
1319 Initialise the global parameter structure.
1320 ***************************************************************************/
1322 static void init_globals(void)
1324 static BOOL done_init = False;
1325 pstring s;
1327 if (!done_init) {
1328 int i;
1330 /* The logfile can be set before this is invoked. Free it if so. */
1331 if (Globals.szLogFile != NULL) {
1332 string_free(&Globals.szLogFile);
1333 Globals.szLogFile = NULL;
1336 memset((void *)&Globals, '\0', sizeof(Globals));
1338 for (i = 0; parm_table[i].label; i++)
1339 if ((parm_table[i].type == P_STRING ||
1340 parm_table[i].type == P_USTRING) &&
1341 parm_table[i].ptr)
1342 string_set(parm_table[i].ptr, "");
1344 string_set(&sDefault.fstype, FSTYPE_STRING);
1346 init_printer_values(&sDefault);
1348 done_init = True;
1352 DEBUG(3, ("Initialising global parameters\n"));
1354 string_set(&Globals.szSMBPasswdFile, dyn_SMB_PASSWD_FILE);
1355 string_set(&Globals.szPrivateDir, dyn_PRIVATE_DIR);
1357 /* use the new 'hash2' method by default, with a prefix of 1 */
1358 string_set(&Globals.szManglingMethod, "hash2");
1359 Globals.mangle_prefix = 1;
1361 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
1363 /* using UTF8 by default allows us to support all chars */
1364 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
1366 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
1367 /* If the system supports nl_langinfo(), try to grab the value
1368 from the user's locale */
1369 string_set(&Globals.display_charset, "LOCALE");
1370 #else
1371 string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
1372 #endif
1374 /* Use codepage 850 as a default for the dos character set */
1375 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
1378 * Allow the default PASSWD_CHAT to be overridden in local.h.
1380 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
1382 set_global_myname(myhostname());
1383 string_set(&Globals.szNetbiosName,global_myname());
1385 set_global_myworkgroup(WORKGROUP);
1386 string_set(&Globals.szWorkgroup, lp_workgroup());
1388 string_set(&Globals.szPasswdProgram, "");
1389 string_set(&Globals.szPidDir, dyn_PIDDIR);
1390 string_set(&Globals.szLockDir, dyn_LOCKDIR);
1391 string_set(&Globals.szSocketAddress, "0.0.0.0");
1392 pstrcpy(s, "Samba ");
1393 pstrcat(s, SAMBA_VERSION_STRING);
1394 string_set(&Globals.szServerString, s);
1395 slprintf(s, sizeof(s) - 1, "%d.%d", DEFAULT_MAJOR_VERSION,
1396 DEFAULT_MINOR_VERSION);
1397 string_set(&Globals.szAnnounceVersion, s);
1399 pstrcpy(user_socket_options, DEFAULT_SOCKET_OPTIONS);
1401 string_set(&Globals.szLogonDrive, "");
1402 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
1403 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
1404 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
1406 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
1407 string_set(&Globals.szPasswordServer, "*");
1409 Globals.AlgorithmicRidBase = BASE_RID;
1411 Globals.bLoadPrinters = True;
1412 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
1413 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
1414 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
1415 Globals.max_xmit = 0x4104;
1416 Globals.max_mux = 50; /* This is *needed* for profile support. */
1417 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
1418 Globals.bDisableSpoolss = False;
1419 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
1420 Globals.pwordlevel = 0;
1421 Globals.unamelevel = 0;
1422 Globals.deadtime = 0;
1423 Globals.bLargeReadwrite = True;
1424 Globals.max_log_size = 5000;
1425 Globals.max_open_files = MAX_OPEN_FILES;
1426 Globals.maxprotocol = PROTOCOL_NT1;
1427 Globals.minprotocol = PROTOCOL_CORE;
1428 Globals.security = SEC_USER;
1429 Globals.paranoid_server_security = True;
1430 Globals.bEncryptPasswords = True;
1431 Globals.bUpdateEncrypt = False;
1432 Globals.clientSchannel = Auto;
1433 Globals.serverSchannel = Auto;
1434 Globals.bReadRaw = True;
1435 Globals.bWriteRaw = True;
1436 Globals.bReadbmpx = False;
1437 Globals.bNullPasswords = False;
1438 Globals.bObeyPamRestrictions = False;
1439 Globals.syslog = 1;
1440 Globals.bSyslogOnly = False;
1441 Globals.bTimestampLogs = True;
1442 string_set(&Globals.szLogLevel, "0");
1443 Globals.bDebugHiresTimestamp = False;
1444 Globals.bDebugPid = False;
1445 Globals.bDebugUid = False;
1446 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
1447 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
1448 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
1449 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
1450 Globals.change_notify_timeout = 60; /* 1 minute default. */
1451 Globals.bKernelChangeNotify = True; /* On if we have it. */
1452 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
1453 Globals.lm_interval = 60;
1454 Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
1455 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
1456 Globals.bNISHomeMap = False;
1457 #ifdef WITH_NISPLUS_HOME
1458 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
1459 #else
1460 string_set(&Globals.szNISHomeMapName, "auto.home");
1461 #endif
1462 #endif
1463 Globals.bTimeServer = False;
1464 Globals.bBindInterfacesOnly = False;
1465 Globals.bUnixPasswdSync = False;
1466 Globals.bPamPasswordChange = False;
1467 Globals.bPasswdChatDebug = False;
1468 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
1469 Globals.bNTPipeSupport = True; /* Do NT pipes by default. */
1470 Globals.bNTStatusSupport = True; /* Use NT status by default. */
1471 Globals.bStatCache = True; /* use stat cache by default */
1472 Globals.iMaxStatCacheSize = 0; /* unlimited size in kb by default. */
1473 Globals.restrict_anonymous = 0;
1474 Globals.bClientLanManAuth = True; /* Do use the LanMan hash if it is available */
1475 Globals.bClientPlaintextAuth = True; /* Do use a plaintext password if is requested by the server */
1476 Globals.bLanmanAuth = True; /* Do use the LanMan hash if it is available */
1477 Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is available (otherwise NTLMv2) */
1478 Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
1479 /* Note, that we will use NTLM2 session security (which is different), if it is available */
1481 Globals.map_to_guest = 0; /* By Default, "Never" */
1482 Globals.min_passwd_length = MINPASSWDLENGTH; /* By Default, 5. */
1483 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
1484 Globals.enhanced_browsing = True;
1485 Globals.iLockSpinCount = 3; /* Try 3 times. */
1486 Globals.iLockSpinTime = 10; /* usec. */
1487 #ifdef MMAP_BLACKLIST
1488 Globals.bUseMmap = False;
1489 #else
1490 Globals.bUseMmap = True;
1491 #endif
1492 Globals.bUnixExtensions = True;
1494 /* hostname lookups can be very expensive and are broken on
1495 a large number of sites (tridge) */
1496 Globals.bHostnameLookups = False;
1498 str_list_free(&Globals.szPassdbBackend);
1499 #ifdef WITH_LDAP_SAMCONFIG
1500 string_set(&Globals.szLdapServer, "localhost");
1501 Globals.ldap_port = 636;
1502 Globals.szPassdbBackend = str_list_make("ldapsam_compat", NULL);
1503 #else
1504 Globals.szPassdbBackend = str_list_make("smbpasswd", NULL);
1505 #endif /* WITH_LDAP_SAMCONFIG */
1507 string_set(&Globals.szLdapSuffix, "");
1508 string_set(&Globals.szLdapFilter, "(uid=%u)");
1509 string_set(&Globals.szLdapMachineSuffix, "");
1510 string_set(&Globals.szLdapUserSuffix, "");
1511 string_set(&Globals.szLdapGroupSuffix, "");
1512 string_set(&Globals.szLdapIdmapSuffix, "");
1514 string_set(&Globals.szLdapAdminDn, "");
1515 Globals.ldap_ssl = LDAP_SSL_ON;
1516 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
1517 Globals.ldap_delete_dn = False;
1518 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
1519 Globals.ldap_timeout = LDAP_CONNECT_DEFAULT_TIMEOUT;
1520 Globals.ldap_page_size = LDAP_PAGE_SIZE;
1522 /* This is what we tell the afs client. in reality we set the token
1523 * to never expire, though, when this runs out the afs client will
1524 * forget the token. Set to 0 to get NEVERDATE.*/
1525 Globals.iAfsTokenLifetime = 604800;
1527 /* these parameters are set to defaults that are more appropriate
1528 for the increasing samba install base:
1530 as a member of the workgroup, that will possibly become a
1531 _local_ master browser (lm = True). this is opposed to a forced
1532 local master browser startup (pm = True).
1534 doesn't provide WINS server service by default (wsupp = False),
1535 and doesn't provide domain master browser services by default, either.
1539 Globals.bMsAddPrinterWizard = True;
1540 Globals.bPreferredMaster = Auto; /* depending on bDomainMaster */
1541 Globals.os_level = 20;
1542 Globals.bLocalMaster = True;
1543 Globals.bDomainMaster = Auto; /* depending on bDomainLogons */
1544 Globals.bDomainLogons = False;
1545 Globals.bBrowseList = True;
1546 Globals.bWINSsupport = False;
1547 Globals.bWINSproxy = False;
1549 Globals.bDNSproxy = True;
1551 /* this just means to use them if they exist */
1552 Globals.bKernelOplocks = True;
1554 Globals.bAllowTrustedDomains = True;
1556 string_set(&Globals.szTemplateShell, "/bin/false");
1557 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
1558 string_set(&Globals.szTemplatePrimaryGroup, "nobody");
1559 string_set(&Globals.szWinbindSeparator, "\\");
1560 string_set(&Globals.szAclCompat, "");
1561 string_set(&Globals.szCupsServer, "");
1563 string_set(&Globals.szEventLogOpenCommand, "");
1564 string_set(&Globals.szEventLogReadCommand, "");
1565 string_set(&Globals.szEventLogClearCommand, "");
1566 string_set(&Globals.szEventLogNumRecordsCommand, "");
1567 string_set(&Globals.szEventLogOldestRecordCommand, "");
1569 Globals.winbind_cache_time = 300; /* 5 minutes */
1570 Globals.bWinbindEnableLocalAccounts = False;
1571 Globals.bWinbindEnumUsers = True;
1572 Globals.bWinbindEnumGroups = True;
1573 Globals.bWinbindUseDefaultDomain = False;
1574 Globals.bWinbindTrustedDomainsOnly = False;
1575 Globals.bWinbindNestedGroups = False;
1577 Globals.bEnableRidAlgorithm = True;
1579 Globals.name_cache_timeout = 660; /* In seconds */
1581 Globals.bUseSpnego = True;
1582 Globals.bClientUseSpnego = True;
1584 Globals.client_signing = Auto;
1585 Globals.server_signing = False;
1587 Globals.bDeferSharingViolations = True;
1588 string_set(&Globals.smb_ports, SMB_PORTS);
1590 /* don't enable privileges by default since Domain
1591 Admins can then assign thr rights to perform certain
1592 operations as root */
1594 Globals.bEnablePrivileges = False;
1596 Globals.szServicesList = str_list_make( "Spooler NETLOGON", NULL );
1599 static TALLOC_CTX *lp_talloc;
1601 /******************************************************************* a
1602 Free up temporary memory - called from the main loop.
1603 ********************************************************************/
1605 void lp_talloc_free(void)
1607 if (!lp_talloc)
1608 return;
1609 talloc_free(lp_talloc);
1610 lp_talloc = NULL;
1613 /*******************************************************************
1614 Convenience routine to grab string parameters into temporary memory
1615 and run standard_sub_basic on them. The buffers can be written to by
1616 callers without affecting the source string.
1617 ********************************************************************/
1619 static char *lp_string(const char *s)
1621 char *ret, *tmpstr;
1623 /* The follow debug is useful for tracking down memory problems
1624 especially if you have an inner loop that is calling a lp_*()
1625 function that returns a string. Perhaps this debug should be
1626 present all the time? */
1628 #if 0
1629 DEBUG(10, ("lp_string(%s)\n", s));
1630 #endif
1632 if (!lp_talloc)
1633 lp_talloc = talloc_init("lp_talloc");
1635 tmpstr = alloc_sub_basic(get_current_username(), s);
1636 if (trim_char(tmpstr, '\"', '\"')) {
1637 if (strchr(tmpstr,'\"') != NULL) {
1638 SAFE_FREE(tmpstr);
1639 tmpstr = alloc_sub_basic(get_current_username(),s);
1642 ret = talloc_strdup(lp_talloc, tmpstr);
1643 SAFE_FREE(tmpstr);
1645 return (ret);
1649 In this section all the functions that are used to access the
1650 parameters from the rest of the program are defined
1653 #define FN_GLOBAL_STRING(fn_name,ptr) \
1654 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
1655 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
1656 const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
1657 #define FN_GLOBAL_LIST(fn_name,ptr) \
1658 const char **fn_name(void) {return(*(const char ***)(ptr));}
1659 #define FN_GLOBAL_BOOL(fn_name,ptr) \
1660 BOOL fn_name(void) {return(*(BOOL *)(ptr));}
1661 #define FN_GLOBAL_CHAR(fn_name,ptr) \
1662 char fn_name(void) {return(*(char *)(ptr));}
1663 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
1664 int fn_name(void) {return(*(int *)(ptr));}
1666 #define FN_LOCAL_STRING(fn_name,val) \
1667 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
1668 #define FN_LOCAL_CONST_STRING(fn_name,val) \
1669 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
1670 #define FN_LOCAL_LIST(fn_name,val) \
1671 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1672 #define FN_LOCAL_BOOL(fn_name,val) \
1673 BOOL fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1674 #define FN_LOCAL_CHAR(fn_name,val) \
1675 char fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1676 #define FN_LOCAL_INTEGER(fn_name,val) \
1677 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1679 FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
1680 FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
1681 FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
1682 FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
1683 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
1684 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
1685 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
1686 FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
1687 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
1688 FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
1689 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
1690 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
1691 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
1692 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
1693 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
1694 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
1695 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
1696 FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
1697 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
1698 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
1699 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
1700 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
1701 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
1702 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
1703 FN_GLOBAL_STRING(lp_dfree_command, &Globals.szDfree)
1704 FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
1705 FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
1706 FN_GLOBAL_STRING(lp_hosts_equiv, &Globals.szHostsEquiv)
1707 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
1708 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
1709 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
1710 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
1711 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
1712 FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
1713 FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
1714 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
1715 FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
1716 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
1717 FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
1718 FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
1719 FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
1720 FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
1721 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
1722 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
1723 FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
1724 FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
1725 FN_GLOBAL_STRING(lp_socket_address, &Globals.szSocketAddress)
1726 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
1727 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
1728 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
1729 FN_GLOBAL_LIST(lp_passdb_backend, &Globals.szPassdbBackend)
1730 FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
1731 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
1732 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
1733 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
1735 FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
1736 FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
1737 FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
1738 FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
1739 FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
1740 FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
1742 FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
1744 FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
1745 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
1747 FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
1749 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
1750 FN_GLOBAL_STRING(lp_wins_partners, &Globals.szWINSPartners)
1751 FN_GLOBAL_STRING(lp_template_primary_group, &Globals.szTemplatePrimaryGroup)
1752 FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
1753 FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
1754 FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
1755 FN_GLOBAL_STRING(lp_acl_compatibility, &Globals.szAclCompat)
1756 FN_GLOBAL_BOOL(lp_winbind_enable_local_accounts, &Globals.bWinbindEnableLocalAccounts)
1757 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
1758 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
1759 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
1760 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
1761 FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
1764 FN_GLOBAL_LIST(lp_idmap_backend, &Globals.szIdmapBackend)
1765 FN_GLOBAL_BOOL(lp_enable_rid_algorithm, &Globals.bEnableRidAlgorithm)
1767 #ifdef WITH_LDAP_SAMCONFIG
1768 FN_GLOBAL_STRING(lp_ldap_server, &Globals.szLdapServer)
1769 FN_GLOBAL_INTEGER(lp_ldap_port, &Globals.ldap_port)
1770 #endif
1771 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
1772 FN_GLOBAL_STRING(lp_ldap_filter, &Globals.szLdapFilter)
1773 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
1774 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
1775 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
1776 FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
1777 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
1778 FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
1779 FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
1780 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
1781 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
1782 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
1784 FN_GLOBAL_STRING(lp_eventlog_open_cmd, &Globals.szEventLogOpenCommand)
1785 FN_GLOBAL_STRING(lp_eventlog_read_cmd, &Globals.szEventLogReadCommand)
1786 FN_GLOBAL_STRING(lp_eventlog_clear_cmd, &Globals.szEventLogClearCommand)
1787 FN_GLOBAL_STRING(lp_eventlog_num_records_cmd, &Globals.szEventLogNumRecordsCommand)
1788 FN_GLOBAL_STRING(lp_eventlog_oldest_record_cmd, &Globals.szEventLogOldestRecordCommand)
1789 FN_GLOBAL_STRING(lp_eventlog_close_cmd, &Globals.szEventLogCloseCommand)
1790 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
1792 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
1793 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
1794 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
1795 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
1796 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
1797 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
1798 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
1799 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
1800 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
1801 FN_GLOBAL_BOOL(lp_readbmpx, &Globals.bReadbmpx)
1802 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
1803 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
1804 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
1805 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
1806 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
1807 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
1808 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
1809 FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
1810 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
1811 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
1812 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
1813 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
1814 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
1815 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
1816 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
1817 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
1818 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
1819 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
1820 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
1821 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
1822 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
1823 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
1824 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
1825 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
1826 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
1827 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
1828 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
1829 FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
1830 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
1831 FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
1832 FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
1833 FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
1834 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
1835 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
1836 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
1837 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
1838 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
1839 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
1840 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
1841 FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
1842 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
1843 FN_GLOBAL_BOOL(lp_kernel_change_notify, &Globals.bKernelChangeNotify)
1844 FN_GLOBAL_BOOL(lp_use_kerberos_keytab, &Globals.bUseKerberosKeytab)
1845 FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
1846 FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
1847 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
1848 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
1849 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
1850 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
1851 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
1852 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
1853 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
1854 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
1855 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
1856 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
1857 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
1858 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
1859 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
1860 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
1861 FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
1862 FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
1863 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
1864 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
1865 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
1866 FN_GLOBAL_INTEGER(lp_disable_spoolss, &Globals.bDisableSpoolss)
1867 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
1868 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
1869 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
1870 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
1871 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
1872 FN_GLOBAL_INTEGER(lp_change_notify_timeout, &Globals.change_notify_timeout)
1873 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
1874 FN_GLOBAL_INTEGER(lp_min_passwd_length, &Globals.min_passwd_length)
1875 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
1876 FN_GLOBAL_INTEGER(lp_lock_spin_count, &Globals.iLockSpinCount)
1877 FN_GLOBAL_INTEGER(lp_lock_sleep_time, &Globals.iLockSpinTime)
1878 FN_LOCAL_STRING(lp_preexec, szPreExec)
1879 FN_LOCAL_STRING(lp_postexec, szPostExec)
1880 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
1881 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
1882 FN_LOCAL_STRING(lp_servicename, szService)
1883 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
1884 FN_LOCAL_STRING(lp_pathname, szPath)
1885 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
1886 FN_LOCAL_STRING(lp_username, szUsername)
1887 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
1888 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
1889 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
1890 FN_GLOBAL_LIST(lp_enable_svcctl, &Globals.szServicesList)
1891 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
1892 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
1893 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
1894 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
1895 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
1896 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
1897 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
1898 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
1899 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
1900 static FN_LOCAL_STRING(_lp_printername, szPrintername)
1901 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
1902 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
1903 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
1904 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
1905 FN_LOCAL_STRING(lp_comment, comment)
1906 FN_LOCAL_STRING(lp_force_user, force_user)
1907 FN_LOCAL_STRING(lp_force_group, force_group)
1908 FN_LOCAL_LIST(lp_readlist, readlist)
1909 FN_LOCAL_LIST(lp_writelist, writelist)
1910 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
1911 FN_LOCAL_STRING(lp_fstype, fstype)
1912 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
1913 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
1914 static FN_LOCAL_STRING(lp_volume, volume)
1915 FN_LOCAL_STRING(lp_mangled_map, szMangledMap)
1916 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
1917 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
1918 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
1919 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
1920 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
1921 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
1922 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
1923 FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
1924 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
1925 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
1926 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
1927 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
1928 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
1929 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
1930 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
1931 FN_LOCAL_BOOL(lp_readonly, bRead_only)
1932 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
1933 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
1934 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
1935 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
1936 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
1937 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
1938 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
1939 FN_LOCAL_BOOL(lp_locking, bLocking)
1940 FN_LOCAL_INTEGER(lp_strict_locking, iStrictLocking)
1941 FN_LOCAL_BOOL(lp_posix_locking, bPosixLocking)
1942 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
1943 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
1944 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
1945 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
1946 FN_LOCAL_BOOL(lp_manglednames, bMangledNames)
1947 FN_LOCAL_BOOL(lp_widelinks, bWidelinks)
1948 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
1949 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
1950 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
1951 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
1952 FN_LOCAL_BOOL(lp_map_system, bMap_system)
1953 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
1954 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
1955 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
1956 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
1957 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
1958 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
1959 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
1960 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
1961 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
1962 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
1963 FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
1964 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
1965 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
1966 FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
1967 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
1968 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
1969 FN_LOCAL_BOOL(lp_ea_support, bEASupport)
1970 FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
1971 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
1972 FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
1973 FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
1974 FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
1975 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
1976 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
1977 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
1978 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
1979 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
1980 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
1981 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
1982 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
1983 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
1984 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
1985 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
1986 FN_LOCAL_INTEGER(lp_printing, iPrinting)
1987 FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
1988 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
1989 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
1990 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
1991 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
1992 FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size);
1993 FN_LOCAL_CHAR(lp_magicchar, magic_char)
1994 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
1995 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
1996 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
1997 FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
1998 FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
2000 /* local prototypes */
2002 static int map_parameter(const char *pszParmName);
2003 static BOOL set_boolean(BOOL *pb, const char *pszParmValue);
2004 static int getservicebyname(const char *pszServiceName,
2005 service * pserviceDest);
2006 static void copy_service(service * pserviceDest,
2007 service * pserviceSource, BOOL *pcopymapDest);
2008 static BOOL service_ok(int iService);
2009 static BOOL do_parameter(const char *pszParmName, const char *pszParmValue);
2010 static BOOL do_section(const char *pszSectionName);
2011 static void init_copymap(service * pservice);
2013 /* This is a helper function for parametrical options support. */
2014 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
2015 /* Actual parametrical functions are quite simple */
2016 static param_opt_struct *get_parametrics(int snum, const char *type, const char *option)
2018 BOOL global_section = False;
2019 char* param_key;
2020 param_opt_struct *data;
2022 if (snum >= iNumServices) return NULL;
2024 if (snum < 0) {
2025 data = Globals.param_opt;
2026 global_section = True;
2027 } else {
2028 data = ServicePtrs[snum]->param_opt;
2031 asprintf(&param_key, "%s:%s", type, option);
2032 if (!param_key) {
2033 DEBUG(0,("asprintf failed!\n"));
2034 return NULL;
2037 while (data) {
2038 if (strcmp(data->key, param_key) == 0) {
2039 string_free(&param_key);
2040 return data;
2042 data = data->next;
2045 if (!global_section) {
2046 /* Try to fetch the same option but from globals */
2047 /* but only if we are not already working with Globals */
2048 data = Globals.param_opt;
2049 while (data) {
2050 if (strcmp(data->key, param_key) == 0) {
2051 string_free(&param_key);
2052 return data;
2054 data = data->next;
2058 string_free(&param_key);
2060 return NULL;
2064 /*******************************************************************
2065 convenience routine to return int parameters.
2066 ********************************************************************/
2067 static int lp_int(const char *s)
2070 if (!s) {
2071 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
2072 return (-1);
2075 return atoi(s);
2078 /*******************************************************************
2079 convenience routine to return unsigned long parameters.
2080 ********************************************************************/
2081 static int lp_ulong(const char *s)
2084 if (!s) {
2085 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
2086 return (-1);
2089 return strtoul(s, NULL, 10);
2092 /*******************************************************************
2093 convenience routine to return boolean parameters.
2094 ********************************************************************/
2095 static BOOL lp_bool(const char *s)
2097 BOOL ret = False;
2099 if (!s) {
2100 DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
2101 return False;
2104 if (!set_boolean(&ret,s)) {
2105 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
2106 return False;
2109 return ret;
2112 /*******************************************************************
2113 convenience routine to return enum parameters.
2114 ********************************************************************/
2115 static int lp_enum(const char *s,const struct enum_list *_enum)
2117 int i;
2119 if (!s || !_enum) {
2120 DEBUG(0,("lp_enum(%s,enum): is called with NULL!\n",s));
2121 return (-1);
2124 for (i=0; _enum[i].name; i++) {
2125 if (strequal(_enum[i].name,s))
2126 return _enum[i].value;
2129 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
2130 return (-1);
2134 /* DO NOT USE lp_parm_string ANYMORE!!!!
2135 * use lp_parm_const_string or lp_parm_talloc_string
2137 * lp_parm_string is only used to let old modules find this symbol
2139 #undef lp_parm_string
2140 char *lp_parm_string(const char *servicename, const char *type, const char *option)
2142 return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
2145 /* Return parametric option from a given service. Type is a part of option before ':' */
2146 /* Parametric option has following syntax: 'Type: option = value' */
2147 /* the returned value is talloced in lp_talloc */
2148 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
2150 param_opt_struct *data = get_parametrics(snum, type, option);
2152 if (data == NULL||data->value==NULL) {
2153 if (def) {
2154 return lp_string(def);
2155 } else {
2156 return NULL;
2160 return lp_string(data->value);
2163 /* Return parametric option from a given service. Type is a part of option before ':' */
2164 /* Parametric option has following syntax: 'Type: option = value' */
2165 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
2167 param_opt_struct *data = get_parametrics(snum, type, option);
2169 if (data == NULL||data->value==NULL)
2170 return def;
2172 return data->value;
2175 /* Return parametric option from a given service. Type is a part of option before ':' */
2176 /* Parametric option has following syntax: 'Type: option = value' */
2178 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
2180 param_opt_struct *data = get_parametrics(snum, type, option);
2182 if (data == NULL||data->value==NULL)
2183 return (const char **)def;
2185 if (data->list==NULL) {
2186 data->list = str_list_make(data->value, NULL);
2189 return (const char **)data->list;
2192 /* Return parametric option from a given service. Type is a part of option before ':' */
2193 /* Parametric option has following syntax: 'Type: option = value' */
2195 int lp_parm_int(int snum, const char *type, const char *option, int def)
2197 param_opt_struct *data = get_parametrics(snum, type, option);
2199 if (data && data->value && *data->value)
2200 return lp_int(data->value);
2202 return def;
2205 /* Return parametric option from a given service. Type is a part of option before ':' */
2206 /* Parametric option has following syntax: 'Type: option = value' */
2208 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
2210 param_opt_struct *data = get_parametrics(snum, type, option);
2212 if (data && data->value && *data->value)
2213 return lp_ulong(data->value);
2215 return def;
2218 /* Return parametric option from a given service. Type is a part of option before ':' */
2219 /* Parametric option has following syntax: 'Type: option = value' */
2221 BOOL lp_parm_bool(int snum, const char *type, const char *option, BOOL def)
2223 param_opt_struct *data = get_parametrics(snum, type, option);
2225 if (data && data->value && *data->value)
2226 return lp_bool(data->value);
2228 return def;
2231 /* Return parametric option from a given service. Type is a part of option before ':' */
2232 /* Parametric option has following syntax: 'Type: option = value' */
2234 int lp_parm_enum(int snum, const char *type, const char *option,
2235 const struct enum_list *_enum, int def)
2237 param_opt_struct *data = get_parametrics(snum, type, option);
2239 if (data && data->value && *data->value && _enum)
2240 return lp_enum(data->value, _enum);
2242 return def;
2246 /***************************************************************************
2247 Initialise a service to the defaults.
2248 ***************************************************************************/
2250 static void init_service(service * pservice)
2252 memset((char *)pservice, '\0', sizeof(service));
2253 copy_service(pservice, &sDefault, NULL);
2256 /***************************************************************************
2257 Free the dynamically allocated parts of a service struct.
2258 ***************************************************************************/
2260 static void free_service(service *pservice)
2262 int i;
2263 param_opt_struct *data, *pdata;
2264 if (!pservice)
2265 return;
2267 if (pservice->szService)
2268 DEBUG(5, ("free_service: Freeing service %s\n",
2269 pservice->szService));
2271 string_free(&pservice->szService);
2272 SAFE_FREE(pservice->copymap);
2274 for (i = 0; parm_table[i].label; i++) {
2275 if ((parm_table[i].type == P_STRING ||
2276 parm_table[i].type == P_USTRING) &&
2277 parm_table[i].class == P_LOCAL)
2278 string_free((char **)
2279 (((char *)pservice) +
2280 PTR_DIFF(parm_table[i].ptr, &sDefault)));
2281 else if (parm_table[i].type == P_LIST &&
2282 parm_table[i].class == P_LOCAL)
2283 str_list_free((char ***)
2284 (((char *)pservice) +
2285 PTR_DIFF(parm_table[i].ptr, &sDefault)));
2288 data = pservice->param_opt;
2289 if (data)
2290 DEBUG(5,("Freeing parametrics:\n"));
2291 while (data) {
2292 DEBUG(5,("[%s = %s]\n", data->key, data->value));
2293 string_free(&data->key);
2294 string_free(&data->value);
2295 str_list_free(&data->list);
2296 pdata = data->next;
2297 SAFE_FREE(data);
2298 data = pdata;
2301 ZERO_STRUCTP(pservice);
2304 /***************************************************************************
2305 Add a new service to the services array initialising it with the given
2306 service.
2307 ***************************************************************************/
2309 static int add_a_service(const service *pservice, const char *name)
2311 int i;
2312 service tservice;
2313 int num_to_alloc = iNumServices + 1;
2314 param_opt_struct *data, *pdata;
2316 tservice = *pservice;
2318 /* it might already exist */
2319 if (name) {
2320 i = getservicebyname(name, NULL);
2321 if (i >= 0) {
2322 /* Clean all parametric options for service */
2323 /* They will be added during parsing again */
2324 data = ServicePtrs[i]->param_opt;
2325 while (data) {
2326 string_free(&data->key);
2327 string_free(&data->value);
2328 str_list_free(&data->list);
2329 pdata = data->next;
2330 SAFE_FREE(data);
2331 data = pdata;
2333 ServicePtrs[i]->param_opt = NULL;
2334 return (i);
2338 /* find an invalid one */
2339 for (i = 0; i < iNumServices; i++)
2340 if (!ServicePtrs[i]->valid)
2341 break;
2343 /* if not, then create one */
2344 if (i == iNumServices) {
2345 service **tsp;
2347 tsp = SMB_REALLOC_ARRAY(ServicePtrs, service *, num_to_alloc);
2349 if (!tsp) {
2350 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
2351 return (-1);
2353 else {
2354 ServicePtrs = tsp;
2355 ServicePtrs[iNumServices] = SMB_MALLOC_P(service);
2357 if (!ServicePtrs[iNumServices]) {
2358 DEBUG(0,("add_a_service: out of memory!\n"));
2359 return (-1);
2362 iNumServices++;
2363 } else
2364 free_service(ServicePtrs[i]);
2366 ServicePtrs[i]->valid = True;
2368 init_service(ServicePtrs[i]);
2369 copy_service(ServicePtrs[i], &tservice, NULL);
2370 if (name)
2371 string_set(&ServicePtrs[i]->szService, name);
2373 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
2374 i, ServicePtrs[i]->szService));
2376 return (i);
2379 /***************************************************************************
2380 Add a new home service, with the specified home directory, defaults coming
2381 from service ifrom.
2382 ***************************************************************************/
2384 BOOL lp_add_home(const char *pszHomename, int iDefaultService,
2385 const char *user, const char *pszHomedir)
2387 int i;
2388 pstring newHomedir;
2390 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
2392 if (i < 0)
2393 return (False);
2395 if (!(*(ServicePtrs[iDefaultService]->szPath))
2396 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
2397 pstrcpy(newHomedir, pszHomedir);
2398 string_set(&ServicePtrs[i]->szPath, newHomedir);
2401 if (!(*(ServicePtrs[i]->comment))) {
2402 pstring comment;
2403 slprintf(comment, sizeof(comment) - 1,
2404 "Home directory of %s", user);
2405 string_set(&ServicePtrs[i]->comment, comment);
2408 /* set the browseable flag from the gloabl default */
2410 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
2412 ServicePtrs[i]->autoloaded = True;
2414 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
2415 user, ServicePtrs[i]->szPath ));
2417 return (True);
2420 /***************************************************************************
2421 Add a new service, based on an old one.
2422 ***************************************************************************/
2424 int lp_add_service(const char *pszService, int iDefaultService)
2426 return (add_a_service(ServicePtrs[iDefaultService], pszService));
2429 /***************************************************************************
2430 Add the IPC service.
2431 ***************************************************************************/
2433 static BOOL lp_add_ipc(const char *ipc_name, BOOL guest_ok)
2435 pstring comment;
2436 int i = add_a_service(&sDefault, ipc_name);
2438 if (i < 0)
2439 return (False);
2441 slprintf(comment, sizeof(comment) - 1,
2442 "IPC Service (%s)", Globals.szServerString);
2444 string_set(&ServicePtrs[i]->szPath, tmpdir());
2445 string_set(&ServicePtrs[i]->szUsername, "");
2446 string_set(&ServicePtrs[i]->comment, comment);
2447 string_set(&ServicePtrs[i]->fstype, "IPC");
2448 ServicePtrs[i]->iMaxConnections = 0;
2449 ServicePtrs[i]->bAvailable = True;
2450 ServicePtrs[i]->bRead_only = True;
2451 ServicePtrs[i]->bGuest_only = False;
2452 ServicePtrs[i]->bGuest_ok = guest_ok;
2453 ServicePtrs[i]->bPrint_ok = False;
2454 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
2456 DEBUG(3, ("adding IPC service\n"));
2458 return (True);
2461 /***************************************************************************
2462 Add a new printer service, with defaults coming from service iFrom.
2463 ***************************************************************************/
2465 BOOL lp_add_printer(const char *pszPrintername, int iDefaultService)
2467 const char *comment = "From Printcap";
2468 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
2470 if (i < 0)
2471 return (False);
2473 /* note that we do NOT default the availability flag to True - */
2474 /* we take it from the default service passed. This allows all */
2475 /* dynamic printers to be disabled by disabling the [printers] */
2476 /* entry (if/when the 'available' keyword is implemented!). */
2478 /* the printer name is set to the service name. */
2479 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
2480 string_set(&ServicePtrs[i]->comment, comment);
2482 /* set the browseable flag from the gloabl default */
2483 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
2485 /* Printers cannot be read_only. */
2486 ServicePtrs[i]->bRead_only = False;
2487 /* No share modes on printer services. */
2488 ServicePtrs[i]->bShareModes = False;
2489 /* No oplocks on printer services. */
2490 ServicePtrs[i]->bOpLocks = False;
2491 /* Printer services must be printable. */
2492 ServicePtrs[i]->bPrint_ok = True;
2494 DEBUG(3, ("adding printer service %s\n", pszPrintername));
2496 return (True);
2499 /***************************************************************************
2500 Map a parameter's string representation to something we can use.
2501 Returns False if the parameter string is not recognised, else TRUE.
2502 ***************************************************************************/
2504 static int map_parameter(const char *pszParmName)
2506 int iIndex;
2508 if (*pszParmName == '-')
2509 return (-1);
2511 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
2512 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
2513 return (iIndex);
2515 /* Warn only if it isn't parametric option */
2516 if (strchr(pszParmName, ':') == NULL)
2517 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
2518 /* We do return 'fail' for parametric options as well because they are
2519 stored in different storage
2521 return (-1);
2524 /***************************************************************************
2525 Set a boolean variable from the text value stored in the passed string.
2526 Returns True in success, False if the passed string does not correctly
2527 represent a boolean.
2528 ***************************************************************************/
2530 static BOOL set_boolean(BOOL *pb, const char *pszParmValue)
2532 BOOL bRetval;
2534 bRetval = True;
2535 if (strwicmp(pszParmValue, "yes") == 0 ||
2536 strwicmp(pszParmValue, "true") == 0 ||
2537 strwicmp(pszParmValue, "1") == 0)
2538 *pb = True;
2539 else if (strwicmp(pszParmValue, "no") == 0 ||
2540 strwicmp(pszParmValue, "False") == 0 ||
2541 strwicmp(pszParmValue, "0") == 0)
2542 *pb = False;
2543 else {
2544 DEBUG(0,
2545 ("ERROR: Badly formed boolean in configuration file: \"%s\".\n",
2546 pszParmValue));
2547 bRetval = False;
2549 return (bRetval);
2552 /***************************************************************************
2553 Find a service by name. Otherwise works like get_service.
2554 ***************************************************************************/
2556 static int getservicebyname(const char *pszServiceName, service * pserviceDest)
2558 int iService;
2560 for (iService = iNumServices - 1; iService >= 0; iService--)
2561 if (VALID(iService) &&
2562 strwicmp(ServicePtrs[iService]->szService, pszServiceName) == 0) {
2563 if (pserviceDest != NULL)
2564 copy_service(pserviceDest, ServicePtrs[iService], NULL);
2565 break;
2568 return (iService);
2571 /***************************************************************************
2572 Copy a service structure to another.
2573 If pcopymapDest is NULL then copy all fields
2574 ***************************************************************************/
2576 static void copy_service(service * pserviceDest, service * pserviceSource, BOOL *pcopymapDest)
2578 int i;
2579 BOOL bcopyall = (pcopymapDest == NULL);
2580 param_opt_struct *data, *pdata, *paramo;
2581 BOOL not_added;
2583 for (i = 0; parm_table[i].label; i++)
2584 if (parm_table[i].ptr && parm_table[i].class == P_LOCAL &&
2585 (bcopyall || pcopymapDest[i])) {
2586 void *def_ptr = parm_table[i].ptr;
2587 void *src_ptr =
2588 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
2589 &sDefault);
2590 void *dest_ptr =
2591 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
2592 &sDefault);
2594 switch (parm_table[i].type) {
2595 case P_BOOL:
2596 case P_BOOLREV:
2597 *(BOOL *)dest_ptr = *(BOOL *)src_ptr;
2598 break;
2600 case P_INTEGER:
2601 case P_ENUM:
2602 case P_OCTAL:
2603 *(int *)dest_ptr = *(int *)src_ptr;
2604 break;
2606 case P_CHAR:
2607 *(char *)dest_ptr = *(char *)src_ptr;
2608 break;
2610 case P_STRING:
2611 string_set(dest_ptr,
2612 *(char **)src_ptr);
2613 break;
2615 case P_USTRING:
2616 string_set(dest_ptr,
2617 *(char **)src_ptr);
2618 strupper_m(*(char **)dest_ptr);
2619 break;
2620 case P_LIST:
2621 str_list_free((char ***)dest_ptr);
2622 str_list_copy((char ***)dest_ptr, *(const char ***)src_ptr);
2623 break;
2624 default:
2625 break;
2629 if (bcopyall) {
2630 init_copymap(pserviceDest);
2631 if (pserviceSource->copymap)
2632 memcpy((void *)pserviceDest->copymap,
2633 (void *)pserviceSource->copymap,
2634 sizeof(BOOL) * NUMPARAMETERS);
2637 data = pserviceSource->param_opt;
2638 while (data) {
2639 not_added = True;
2640 pdata = pserviceDest->param_opt;
2641 /* Traverse destination */
2642 while (pdata) {
2643 /* If we already have same option, override it */
2644 if (strcmp(pdata->key, data->key) == 0) {
2645 string_free(&pdata->value);
2646 str_list_free(&data->list);
2647 pdata->value = SMB_STRDUP(data->value);
2648 not_added = False;
2649 break;
2651 pdata = pdata->next;
2653 if (not_added) {
2654 paramo = SMB_XMALLOC_P(param_opt_struct);
2655 paramo->key = SMB_STRDUP(data->key);
2656 paramo->value = SMB_STRDUP(data->value);
2657 paramo->list = NULL;
2658 DLIST_ADD(pserviceDest->param_opt, paramo);
2660 data = data->next;
2664 /***************************************************************************
2665 Check a service for consistency. Return False if the service is in any way
2666 incomplete or faulty, else True.
2667 ***************************************************************************/
2669 static BOOL service_ok(int iService)
2671 BOOL bRetval;
2673 bRetval = True;
2674 if (ServicePtrs[iService]->szService[0] == '\0') {
2675 DEBUG(0, ("The following message indicates an internal error:\n"));
2676 DEBUG(0, ("No service name in service entry.\n"));
2677 bRetval = False;
2680 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
2681 /* I can't see why you'd want a non-printable printer service... */
2682 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
2683 if (!ServicePtrs[iService]->bPrint_ok) {
2684 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
2685 ServicePtrs[iService]->szService));
2686 ServicePtrs[iService]->bPrint_ok = True;
2688 /* [printers] service must also be non-browsable. */
2689 if (ServicePtrs[iService]->bBrowseable)
2690 ServicePtrs[iService]->bBrowseable = False;
2693 if (ServicePtrs[iService]->szPath[0] == '\0' &&
2694 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0) {
2695 DEBUG(0, ("No path in service %s - using %s\n",
2696 ServicePtrs[iService]->szService, tmpdir()));
2697 string_set(&ServicePtrs[iService]->szPath, tmpdir());
2700 /* If a service is flagged unavailable, log the fact at level 0. */
2701 if (!ServicePtrs[iService]->bAvailable)
2702 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
2703 ServicePtrs[iService]->szService));
2705 return (bRetval);
2708 static struct file_lists {
2709 struct file_lists *next;
2710 char *name;
2711 char *subfname;
2712 time_t modtime;
2713 } *file_lists = NULL;
2715 /*******************************************************************
2716 Keep a linked list of all config files so we know when one has changed
2717 it's date and needs to be reloaded.
2718 ********************************************************************/
2720 static void add_to_file_list(const char *fname, const char *subfname)
2722 struct file_lists *f = file_lists;
2724 while (f) {
2725 if (f->name && !strcmp(f->name, fname))
2726 break;
2727 f = f->next;
2730 if (!f) {
2731 f = SMB_MALLOC_P(struct file_lists);
2732 if (!f)
2733 return;
2734 f->next = file_lists;
2735 f->name = SMB_STRDUP(fname);
2736 if (!f->name) {
2737 SAFE_FREE(f);
2738 return;
2740 f->subfname = SMB_STRDUP(subfname);
2741 if (!f->subfname) {
2742 SAFE_FREE(f);
2743 return;
2745 file_lists = f;
2746 f->modtime = file_modtime(subfname);
2747 } else {
2748 time_t t = file_modtime(subfname);
2749 if (t)
2750 f->modtime = t;
2754 /*******************************************************************
2755 Check if a config file has changed date.
2756 ********************************************************************/
2758 BOOL lp_file_list_changed(void)
2760 struct file_lists *f = file_lists;
2762 DEBUG(6, ("lp_file_list_changed()\n"));
2764 while (f) {
2765 pstring n2;
2766 time_t mod_time;
2768 pstrcpy(n2, f->name);
2769 standard_sub_basic( get_current_username(), n2, sizeof(n2) );
2771 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
2772 f->name, n2, ctime(&f->modtime)));
2774 mod_time = file_modtime(n2);
2776 if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
2777 DEBUGADD(6,
2778 ("file %s modified: %s\n", n2,
2779 ctime(&mod_time)));
2780 f->modtime = mod_time;
2781 SAFE_FREE(f->subfname);
2782 f->subfname = SMB_STRDUP(n2);
2783 return (True);
2785 f = f->next;
2787 return (False);
2790 /***************************************************************************
2791 Run standard_sub_basic on netbios name... needed because global_myname
2792 is not accessed through any lp_ macro.
2793 Note: We must *NOT* use string_set() here as ptr points to global_myname.
2794 ***************************************************************************/
2796 static BOOL handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
2798 BOOL ret;
2799 pstring netbios_name;
2801 pstrcpy(netbios_name, pszParmValue);
2803 standard_sub_basic(get_current_username(), netbios_name,sizeof(netbios_name));
2805 ret = set_global_myname(netbios_name);
2806 string_set(&Globals.szNetbiosName,global_myname());
2808 DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
2809 global_myname()));
2811 return ret;
2814 static BOOL handle_charset(int snum, const char *pszParmValue, char **ptr)
2816 if (strcmp(*ptr, pszParmValue) != 0) {
2817 string_set(ptr, pszParmValue);
2818 init_iconv();
2820 return True;
2823 static BOOL handle_eventlog(int snum, const char *pszParmValue, char **ptr)
2825 string_set(ptr, pszParmValue);
2826 return True;
2829 static BOOL handle_workgroup(int snum, const char *pszParmValue, char **ptr)
2831 BOOL ret;
2833 ret = set_global_myworkgroup(pszParmValue);
2834 string_set(&Globals.szWorkgroup,lp_workgroup());
2836 return ret;
2839 static BOOL handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
2841 BOOL ret;
2843 ret = set_global_scope(pszParmValue);
2844 string_set(&Globals.szNetbiosScope,global_scope());
2846 return ret;
2849 static BOOL handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
2851 str_list_free(&Globals.szNetbiosAliases);
2852 Globals.szNetbiosAliases = str_list_make(pszParmValue, NULL);
2853 return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
2856 /***************************************************************************
2857 Handle the include operation.
2858 ***************************************************************************/
2860 static BOOL handle_include(int snum, const char *pszParmValue, char **ptr)
2862 pstring fname;
2863 pstrcpy(fname, pszParmValue);
2865 standard_sub_basic(get_current_username(), fname,sizeof(fname));
2867 add_to_file_list(pszParmValue, fname);
2869 string_set(ptr, fname);
2871 if (file_exist(fname, NULL))
2872 return (pm_process(fname, do_section, do_parameter));
2874 DEBUG(2, ("Can't find include file %s\n", fname));
2876 return (False);
2879 /***************************************************************************
2880 Handle the interpretation of the copy parameter.
2881 ***************************************************************************/
2883 static BOOL handle_copy(int snum, const char *pszParmValue, char **ptr)
2885 BOOL bRetval;
2886 int iTemp;
2887 service serviceTemp;
2889 string_set(ptr, pszParmValue);
2891 init_service(&serviceTemp);
2893 bRetval = False;
2895 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
2897 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
2898 if (iTemp == iServiceIndex) {
2899 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
2900 } else {
2901 copy_service(ServicePtrs[iServiceIndex],
2902 &serviceTemp,
2903 ServicePtrs[iServiceIndex]->copymap);
2904 bRetval = True;
2906 } else {
2907 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
2908 bRetval = False;
2911 free_service(&serviceTemp);
2912 return (bRetval);
2915 /***************************************************************************
2916 Handle idmap/non unix account uid and gid allocation parameters. The format of these
2917 parameters is:
2919 [global]
2921 idmap uid = 1000-1999
2922 idmap gid = 700-899
2924 We only do simple parsing checks here. The strings are parsed into useful
2925 structures in the idmap daemon code.
2927 ***************************************************************************/
2929 /* Some lp_ routines to return idmap [ug]id information */
2931 static uid_t idmap_uid_low, idmap_uid_high;
2932 static gid_t idmap_gid_low, idmap_gid_high;
2934 BOOL lp_idmap_uid(uid_t *low, uid_t *high)
2936 if (idmap_uid_low == 0 || idmap_uid_high == 0)
2937 return False;
2939 if (low)
2940 *low = idmap_uid_low;
2942 if (high)
2943 *high = idmap_uid_high;
2945 return True;
2948 BOOL lp_idmap_gid(gid_t *low, gid_t *high)
2950 if (idmap_gid_low == 0 || idmap_gid_high == 0)
2951 return False;
2953 if (low)
2954 *low = idmap_gid_low;
2956 if (high)
2957 *high = idmap_gid_high;
2959 return True;
2962 /* Do some simple checks on "idmap [ug]id" parameter values */
2964 static BOOL handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
2966 uint32 low, high;
2968 if (sscanf(pszParmValue, "%u-%u", &low, &high) != 2 || high < low)
2969 return False;
2971 /* Parse OK */
2973 string_set(ptr, pszParmValue);
2975 idmap_uid_low = low;
2976 idmap_uid_high = high;
2978 return True;
2981 static BOOL handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
2983 uint32 low, high;
2985 if (sscanf(pszParmValue, "%u-%u", &low, &high) != 2 || high < low)
2986 return False;
2988 /* Parse OK */
2990 string_set(ptr, pszParmValue);
2992 idmap_gid_low = low;
2993 idmap_gid_high = high;
2995 return True;
2998 /***************************************************************************
2999 Handle the DEBUG level list.
3000 ***************************************************************************/
3002 static BOOL handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
3004 pstring pszParmValue;
3006 pstrcpy(pszParmValue, pszParmValueIn);
3007 string_set(ptr, pszParmValueIn);
3008 return debug_parse_levels( pszParmValue );
3011 /***************************************************************************
3012 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
3013 ***************************************************************************/
3015 static char* append_ldap_suffix( const char *str )
3017 char *suffix_string;
3020 if (!lp_talloc)
3021 lp_talloc = talloc_init("lp_talloc");
3023 suffix_string = talloc_asprintf( lp_talloc, "%s,%s", str, Globals.szLdapSuffix );
3024 if ( !suffix_string ) {
3025 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
3026 return NULL;
3029 return suffix_string;
3032 char *lp_ldap_machine_suffix(void)
3034 if (Globals.szLdapMachineSuffix[0])
3035 return append_ldap_suffix(Globals.szLdapMachineSuffix);
3037 return lp_string(Globals.szLdapSuffix);
3040 char *lp_ldap_user_suffix(void)
3042 if (Globals.szLdapUserSuffix[0])
3043 return append_ldap_suffix(Globals.szLdapUserSuffix);
3045 return lp_string(Globals.szLdapSuffix);
3048 char *lp_ldap_group_suffix(void)
3050 if (Globals.szLdapGroupSuffix[0])
3051 return append_ldap_suffix(Globals.szLdapGroupSuffix);
3053 return lp_string(Globals.szLdapSuffix);
3056 char *lp_ldap_idmap_suffix(void)
3058 if (Globals.szLdapIdmapSuffix[0])
3059 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
3061 return lp_string(Globals.szLdapSuffix);
3064 /***************************************************************************
3065 ***************************************************************************/
3067 static BOOL handle_acl_compatibility(int snum, const char *pszParmValue, char **ptr)
3069 if (strequal(pszParmValue, "auto"))
3070 string_set(ptr, "");
3071 else if (strequal(pszParmValue, "winnt"))
3072 string_set(ptr, "winnt");
3073 else if (strequal(pszParmValue, "win2k"))
3074 string_set(ptr, "win2k");
3075 else
3076 return False;
3078 return True;
3081 /****************************************************************************
3082 set the value for a P_ENUM
3083 ***************************************************************************/
3085 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
3086 int *ptr )
3088 int i;
3090 for (i = 0; parm->enum_list[i].name; i++) {
3091 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
3092 *ptr = parm->enum_list[i].value;
3093 break;
3098 /***************************************************************************
3099 ***************************************************************************/
3101 static BOOL handle_printing(int snum, const char *pszParmValue, char **ptr)
3103 static int parm_num = -1;
3104 service *s;
3106 if ( parm_num == -1 )
3107 parm_num = map_parameter( "printing" );
3109 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
3111 if ( snum < 0 )
3112 s = &sDefault;
3113 else
3114 s = ServicePtrs[snum];
3116 init_printer_values( s );
3118 return True;
3122 /***************************************************************************
3123 Initialise a copymap.
3124 ***************************************************************************/
3126 static void init_copymap(service * pservice)
3128 int i;
3129 SAFE_FREE(pservice->copymap);
3130 pservice->copymap = SMB_MALLOC_ARRAY(BOOL,NUMPARAMETERS);
3131 if (!pservice->copymap)
3132 DEBUG(0,
3133 ("Couldn't allocate copymap!! (size %d)\n",
3134 (int)NUMPARAMETERS));
3135 else
3136 for (i = 0; i < NUMPARAMETERS; i++)
3137 pservice->copymap[i] = True;
3140 /***************************************************************************
3141 Return the local pointer to a parameter given the service number and the
3142 pointer into the default structure.
3143 ***************************************************************************/
3145 void *lp_local_ptr(int snum, void *ptr)
3147 return (void *)(((char *)ServicePtrs[snum]) + PTR_DIFF(ptr, &sDefault));
3150 /***************************************************************************
3151 Process a parameter for a particular service number. If snum < 0
3152 then assume we are in the globals.
3153 ***************************************************************************/
3155 BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
3157 int parmnum, i, slen;
3158 void *parm_ptr = NULL; /* where we are going to store the result */
3159 void *def_ptr = NULL;
3160 pstring param_key;
3161 char *sep;
3162 param_opt_struct *paramo, *data;
3163 BOOL not_added;
3165 parmnum = map_parameter(pszParmName);
3167 if (parmnum < 0) {
3168 if ((sep=strchr(pszParmName, ':')) != NULL) {
3169 *sep = '\0';
3170 ZERO_STRUCT(param_key);
3171 pstr_sprintf(param_key, "%s:", pszParmName);
3172 slen = strlen(param_key);
3173 pstrcat(param_key, sep+1);
3174 trim_char(param_key+slen, ' ', ' ');
3175 not_added = True;
3176 data = (snum < 0) ? Globals.param_opt :
3177 ServicePtrs[snum]->param_opt;
3178 /* Traverse destination */
3179 while (data) {
3180 /* If we already have same option, override it */
3181 if (strcmp(data->key, param_key) == 0) {
3182 string_free(&data->value);
3183 str_list_free(&data->list);
3184 data->value = SMB_STRDUP(pszParmValue);
3185 not_added = False;
3186 break;
3188 data = data->next;
3190 if (not_added) {
3191 paramo = SMB_XMALLOC_P(param_opt_struct);
3192 paramo->key = SMB_STRDUP(param_key);
3193 paramo->value = SMB_STRDUP(pszParmValue);
3194 paramo->list = NULL;
3195 if (snum < 0) {
3196 DLIST_ADD(Globals.param_opt, paramo);
3197 } else {
3198 DLIST_ADD(ServicePtrs[snum]->param_opt, paramo);
3202 *sep = ':';
3203 return (True);
3205 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
3206 return (True);
3209 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
3210 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
3211 pszParmName));
3214 def_ptr = parm_table[parmnum].ptr;
3216 /* we might point at a service, the default service or a global */
3217 if (snum < 0) {
3218 parm_ptr = def_ptr;
3219 } else {
3220 if (parm_table[parmnum].class == P_GLOBAL) {
3221 DEBUG(0,
3222 ("Global parameter %s found in service section!\n",
3223 pszParmName));
3224 return (True);
3226 parm_ptr =
3227 ((char *)ServicePtrs[snum]) + PTR_DIFF(def_ptr,
3228 &sDefault);
3231 if (snum >= 0) {
3232 if (!ServicePtrs[snum]->copymap)
3233 init_copymap(ServicePtrs[snum]);
3235 /* this handles the aliases - set the copymap for other entries with
3236 the same data pointer */
3237 for (i = 0; parm_table[i].label; i++)
3238 if (parm_table[i].ptr == parm_table[parmnum].ptr)
3239 ServicePtrs[snum]->copymap[i] = False;
3242 /* if it is a special case then go ahead */
3243 if (parm_table[parmnum].special) {
3244 parm_table[parmnum].special(snum, pszParmValue, (char **)parm_ptr);
3245 return (True);
3248 /* now switch on the type of variable it is */
3249 switch (parm_table[parmnum].type)
3251 case P_BOOL:
3252 set_boolean(parm_ptr, pszParmValue);
3253 break;
3255 case P_BOOLREV:
3256 set_boolean(parm_ptr, pszParmValue);
3257 *(BOOL *)parm_ptr = !*(BOOL *)parm_ptr;
3258 break;
3260 case P_INTEGER:
3261 *(int *)parm_ptr = atoi(pszParmValue);
3262 break;
3264 case P_CHAR:
3265 *(char *)parm_ptr = *pszParmValue;
3266 break;
3268 case P_OCTAL:
3269 sscanf(pszParmValue, "%o", (int *)parm_ptr);
3270 break;
3272 case P_LIST:
3273 str_list_free(parm_ptr);
3274 *(char ***)parm_ptr = str_list_make(pszParmValue, NULL);
3275 break;
3277 case P_STRING:
3278 string_set(parm_ptr, pszParmValue);
3279 break;
3281 case P_USTRING:
3282 string_set(parm_ptr, pszParmValue);
3283 strupper_m(*(char **)parm_ptr);
3284 break;
3286 case P_GSTRING:
3287 pstrcpy((char *)parm_ptr, pszParmValue);
3288 break;
3290 case P_UGSTRING:
3291 pstrcpy((char *)parm_ptr, pszParmValue);
3292 strupper_m((char *)parm_ptr);
3293 break;
3295 case P_ENUM:
3296 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
3297 break;
3298 case P_SEP:
3299 break;
3302 return (True);
3305 /***************************************************************************
3306 Process a parameter.
3307 ***************************************************************************/
3309 static BOOL do_parameter(const char *pszParmName, const char *pszParmValue)
3311 if (!bInGlobalSection && bGlobalOnly)
3312 return (True);
3314 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
3316 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
3317 pszParmName, pszParmValue));
3320 /***************************************************************************
3321 Print a parameter of the specified type.
3322 ***************************************************************************/
3324 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
3326 int i;
3327 switch (p->type)
3329 case P_ENUM:
3330 for (i = 0; p->enum_list[i].name; i++) {
3331 if (*(int *)ptr == p->enum_list[i].value) {
3332 fprintf(f, "%s",
3333 p->enum_list[i].name);
3334 break;
3337 break;
3339 case P_BOOL:
3340 fprintf(f, "%s", BOOLSTR(*(BOOL *)ptr));
3341 break;
3343 case P_BOOLREV:
3344 fprintf(f, "%s", BOOLSTR(!*(BOOL *)ptr));
3345 break;
3347 case P_INTEGER:
3348 fprintf(f, "%d", *(int *)ptr);
3349 break;
3351 case P_CHAR:
3352 fprintf(f, "%c", *(char *)ptr);
3353 break;
3355 case P_OCTAL:
3356 fprintf(f, "%s", octal_string(*(int *)ptr));
3357 break;
3359 case P_LIST:
3360 if ((char ***)ptr && *(char ***)ptr) {
3361 char **list = *(char ***)ptr;
3363 for (; *list; list++) {
3364 /* surround strings with whitespace in double quotes */
3365 if ( strchr_m( *list, ' ' ) )
3366 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
3367 else
3368 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
3371 break;
3373 case P_GSTRING:
3374 case P_UGSTRING:
3375 if ((char *)ptr) {
3376 fprintf(f, "%s", (char *)ptr);
3378 break;
3380 case P_STRING:
3381 case P_USTRING:
3382 if (*(char **)ptr) {
3383 fprintf(f, "%s", *(char **)ptr);
3385 break;
3386 case P_SEP:
3387 break;
3391 /***************************************************************************
3392 Check if two parameters are equal.
3393 ***************************************************************************/
3395 static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
3397 switch (type) {
3398 case P_BOOL:
3399 case P_BOOLREV:
3400 return (*((BOOL *)ptr1) == *((BOOL *)ptr2));
3402 case P_INTEGER:
3403 case P_ENUM:
3404 case P_OCTAL:
3405 return (*((int *)ptr1) == *((int *)ptr2));
3407 case P_CHAR:
3408 return (*((char *)ptr1) == *((char *)ptr2));
3410 case P_LIST:
3411 return str_list_compare(*(char ***)ptr1, *(char ***)ptr2);
3413 case P_GSTRING:
3414 case P_UGSTRING:
3416 char *p1 = (char *)ptr1, *p2 = (char *)ptr2;
3417 if (p1 && !*p1)
3418 p1 = NULL;
3419 if (p2 && !*p2)
3420 p2 = NULL;
3421 return (p1 == p2 || strequal(p1, p2));
3423 case P_STRING:
3424 case P_USTRING:
3426 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
3427 if (p1 && !*p1)
3428 p1 = NULL;
3429 if (p2 && !*p2)
3430 p2 = NULL;
3431 return (p1 == p2 || strequal(p1, p2));
3433 case P_SEP:
3434 break;
3436 return (False);
3439 /***************************************************************************
3440 Initialize any local varients in the sDefault table.
3441 ***************************************************************************/
3443 void init_locals(void)
3445 /* None as yet. */
3448 /***************************************************************************
3449 Process a new section (service). At this stage all sections are services.
3450 Later we'll have special sections that permit server parameters to be set.
3451 Returns True on success, False on failure.
3452 ***************************************************************************/
3454 static BOOL do_section(const char *pszSectionName)
3456 BOOL bRetval;
3457 BOOL isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
3458 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
3459 bRetval = False;
3461 /* if we were in a global section then do the local inits */
3462 if (bInGlobalSection && !isglobal)
3463 init_locals();
3465 /* if we've just struck a global section, note the fact. */
3466 bInGlobalSection = isglobal;
3468 /* check for multiple global sections */
3469 if (bInGlobalSection) {
3470 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
3471 return (True);
3474 if (!bInGlobalSection && bGlobalOnly)
3475 return (True);
3477 /* if we have a current service, tidy it up before moving on */
3478 bRetval = True;
3480 if (iServiceIndex >= 0)
3481 bRetval = service_ok(iServiceIndex);
3483 /* if all is still well, move to the next record in the services array */
3484 if (bRetval) {
3485 /* We put this here to avoid an odd message order if messages are */
3486 /* issued by the post-processing of a previous section. */
3487 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
3489 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
3490 < 0) {
3491 DEBUG(0, ("Failed to add a new service\n"));
3492 return (False);
3496 return (bRetval);
3500 /***************************************************************************
3501 Determine if a partcular base parameter is currentl set to the default value.
3502 ***************************************************************************/
3504 static BOOL is_default(int i)
3506 if (!defaults_saved)
3507 return False;
3508 switch (parm_table[i].type) {
3509 case P_LIST:
3510 return str_list_compare (parm_table[i].def.lvalue,
3511 *(char ***)parm_table[i].ptr);
3512 case P_STRING:
3513 case P_USTRING:
3514 return strequal(parm_table[i].def.svalue,
3515 *(char **)parm_table[i].ptr);
3516 case P_GSTRING:
3517 case P_UGSTRING:
3518 return strequal(parm_table[i].def.svalue,
3519 (char *)parm_table[i].ptr);
3520 case P_BOOL:
3521 case P_BOOLREV:
3522 return parm_table[i].def.bvalue ==
3523 *(BOOL *)parm_table[i].ptr;
3524 case P_CHAR:
3525 return parm_table[i].def.cvalue ==
3526 *(char *)parm_table[i].ptr;
3527 case P_INTEGER:
3528 case P_OCTAL:
3529 case P_ENUM:
3530 return parm_table[i].def.ivalue ==
3531 *(int *)parm_table[i].ptr;
3532 case P_SEP:
3533 break;
3535 return False;
3538 /***************************************************************************
3539 Display the contents of the global structure.
3540 ***************************************************************************/
3542 static void dump_globals(FILE *f)
3544 int i;
3545 param_opt_struct *data;
3547 fprintf(f, "# Global parameters\n[global]\n");
3549 for (i = 0; parm_table[i].label; i++)
3550 if (parm_table[i].class == P_GLOBAL &&
3551 parm_table[i].ptr &&
3552 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
3553 if (defaults_saved && is_default(i))
3554 continue;
3555 fprintf(f, "\t%s = ", parm_table[i].label);
3556 print_parameter(&parm_table[i], parm_table[i].ptr, f);
3557 fprintf(f, "\n");
3559 if (Globals.param_opt != NULL) {
3560 data = Globals.param_opt;
3561 while(data) {
3562 fprintf(f, "\t%s = %s\n", data->key, data->value);
3563 data = data->next;
3569 /***************************************************************************
3570 Return True if a local parameter is currently set to the global default.
3571 ***************************************************************************/
3573 BOOL lp_is_default(int snum, struct parm_struct *parm)
3575 int pdiff = PTR_DIFF(parm->ptr, &sDefault);
3577 return equal_parameter(parm->type,
3578 ((char *)ServicePtrs[snum]) + pdiff,
3579 ((char *)&sDefault) + pdiff);
3582 /***************************************************************************
3583 Display the contents of a single services record.
3584 ***************************************************************************/
3586 static void dump_a_service(service * pService, FILE * f)
3588 int i;
3589 param_opt_struct *data;
3591 if (pService != &sDefault)
3592 fprintf(f, "\n[%s]\n", pService->szService);
3594 for (i = 0; parm_table[i].label; i++) {
3596 if (parm_table[i].class == P_LOCAL &&
3597 parm_table[i].ptr &&
3598 (*parm_table[i].label != '-') &&
3599 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
3602 int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
3604 if (pService == &sDefault) {
3605 if (defaults_saved && is_default(i))
3606 continue;
3607 } else {
3608 if (equal_parameter(parm_table[i].type,
3609 ((char *)pService) +
3610 pdiff,
3611 ((char *)&sDefault) +
3612 pdiff))
3613 continue;
3616 fprintf(f, "\t%s = ", parm_table[i].label);
3617 print_parameter(&parm_table[i],
3618 ((char *)pService) + pdiff, f);
3619 fprintf(f, "\n");
3623 if (pService->param_opt != NULL) {
3624 data = pService->param_opt;
3625 while(data) {
3626 fprintf(f, "\t%s = %s\n", data->key, data->value);
3627 data = data->next;
3633 /***************************************************************************
3634 Return info about the next service in a service. snum==GLOBAL_SECTION_SNUM gives the globals.
3635 Return NULL when out of parameters.
3636 ***************************************************************************/
3638 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
3640 if (snum < 0) {
3641 /* do the globals */
3642 for (; parm_table[*i].label; (*i)++) {
3643 if (parm_table[*i].class == P_SEPARATOR)
3644 return &parm_table[(*i)++];
3646 if (!parm_table[*i].ptr
3647 || (*parm_table[*i].label == '-'))
3648 continue;
3650 if ((*i) > 0
3651 && (parm_table[*i].ptr ==
3652 parm_table[(*i) - 1].ptr))
3653 continue;
3655 return &parm_table[(*i)++];
3657 } else {
3658 service *pService = ServicePtrs[snum];
3660 for (; parm_table[*i].label; (*i)++) {
3661 if (parm_table[*i].class == P_SEPARATOR)
3662 return &parm_table[(*i)++];
3664 if (parm_table[*i].class == P_LOCAL &&
3665 parm_table[*i].ptr &&
3666 (*parm_table[*i].label != '-') &&
3667 ((*i) == 0 ||
3668 (parm_table[*i].ptr !=
3669 parm_table[(*i) - 1].ptr)))
3671 int pdiff =
3672 PTR_DIFF(parm_table[*i].ptr,
3673 &sDefault);
3675 if (allparameters ||
3676 !equal_parameter(parm_table[*i].type,
3677 ((char *)pService) +
3678 pdiff,
3679 ((char *)&sDefault) +
3680 pdiff))
3682 return &parm_table[(*i)++];
3688 return NULL;
3692 #if 0
3693 /***************************************************************************
3694 Display the contents of a single copy structure.
3695 ***************************************************************************/
3696 static void dump_copy_map(BOOL *pcopymap)
3698 int i;
3699 if (!pcopymap)
3700 return;
3702 printf("\n\tNon-Copied parameters:\n");
3704 for (i = 0; parm_table[i].label; i++)
3705 if (parm_table[i].class == P_LOCAL &&
3706 parm_table[i].ptr && !pcopymap[i] &&
3707 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
3709 printf("\t\t%s\n", parm_table[i].label);
3712 #endif
3714 /***************************************************************************
3715 Return TRUE if the passed service number is within range.
3716 ***************************************************************************/
3718 BOOL lp_snum_ok(int iService)
3720 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
3723 /***************************************************************************
3724 Auto-load some home services.
3725 ***************************************************************************/
3727 static void lp_add_auto_services(char *str)
3729 char *s;
3730 char *p;
3731 int homes;
3733 if (!str)
3734 return;
3736 s = SMB_STRDUP(str);
3737 if (!s)
3738 return;
3740 homes = lp_servicenumber(HOMES_NAME);
3742 for (p = strtok(s, LIST_SEP); p; p = strtok(NULL, LIST_SEP)) {
3743 char *home = get_user_home_dir(p);
3745 if (lp_servicenumber(p) >= 0)
3746 continue;
3748 if (home && homes >= 0)
3749 lp_add_home(p, homes, p, home);
3751 SAFE_FREE(s);
3754 /***************************************************************************
3755 Auto-load one printer.
3756 ***************************************************************************/
3758 void lp_add_one_printer(char *name, char *comment)
3760 int printers = lp_servicenumber(PRINTERS_NAME);
3761 int i;
3763 if (lp_servicenumber(name) < 0) {
3764 lp_add_printer(name, printers);
3765 if ((i = lp_servicenumber(name)) >= 0) {
3766 string_set(&ServicePtrs[i]->comment, comment);
3767 ServicePtrs[i]->autoloaded = True;
3772 /***************************************************************************
3773 Have we loaded a services file yet?
3774 ***************************************************************************/
3776 BOOL lp_loaded(void)
3778 return (bLoaded);
3781 /***************************************************************************
3782 Unload unused services.
3783 ***************************************************************************/
3785 void lp_killunused(BOOL (*snumused) (int))
3787 int i;
3788 for (i = 0; i < iNumServices; i++) {
3789 if (!VALID(i))
3790 continue;
3792 /* don't kill autoloaded services */
3793 if ( ServicePtrs[i]->autoloaded )
3794 continue;
3796 if (!snumused || !snumused(i)) {
3797 ServicePtrs[i]->valid = False;
3798 free_service(ServicePtrs[i]);
3803 /***************************************************************************
3804 Unload a service.
3805 ***************************************************************************/
3807 void lp_killservice(int iServiceIn)
3809 if (VALID(iServiceIn)) {
3810 ServicePtrs[iServiceIn]->valid = False;
3811 free_service(ServicePtrs[iServiceIn]);
3815 /***************************************************************************
3816 Save the curent values of all global and sDefault parameters into the
3817 defaults union. This allows swat and testparm to show only the
3818 changed (ie. non-default) parameters.
3819 ***************************************************************************/
3821 static void lp_save_defaults(void)
3823 int i;
3824 for (i = 0; parm_table[i].label; i++) {
3825 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
3826 continue;
3827 switch (parm_table[i].type) {
3828 case P_LIST:
3829 str_list_copy(&(parm_table[i].def.lvalue),
3830 *(const char ***)parm_table[i].ptr);
3831 break;
3832 case P_STRING:
3833 case P_USTRING:
3834 if (parm_table[i].ptr) {
3835 parm_table[i].def.svalue = SMB_STRDUP(*(char **)parm_table[i].ptr);
3836 } else {
3837 parm_table[i].def.svalue = NULL;
3839 break;
3840 case P_GSTRING:
3841 case P_UGSTRING:
3842 if (parm_table[i].ptr) {
3843 parm_table[i].def.svalue = SMB_STRDUP((char *)parm_table[i].ptr);
3844 } else {
3845 parm_table[i].def.svalue = NULL;
3847 break;
3848 case P_BOOL:
3849 case P_BOOLREV:
3850 parm_table[i].def.bvalue =
3851 *(BOOL *)parm_table[i].ptr;
3852 break;
3853 case P_CHAR:
3854 parm_table[i].def.cvalue =
3855 *(char *)parm_table[i].ptr;
3856 break;
3857 case P_INTEGER:
3858 case P_OCTAL:
3859 case P_ENUM:
3860 parm_table[i].def.ivalue =
3861 *(int *)parm_table[i].ptr;
3862 break;
3863 case P_SEP:
3864 break;
3867 defaults_saved = True;
3870 /*******************************************************************
3871 Set the server type we will announce as via nmbd.
3872 ********************************************************************/
3874 static void set_server_role(void)
3876 server_role = ROLE_STANDALONE;
3878 switch (lp_security()) {
3879 case SEC_SHARE:
3880 if (lp_domain_logons())
3881 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
3882 break;
3883 case SEC_SERVER:
3884 if (lp_domain_logons())
3885 DEBUG(0, ("Server's Role (logon server) conflicts with server-level security\n"));
3886 server_role = ROLE_DOMAIN_MEMBER;
3887 break;
3888 case SEC_DOMAIN:
3889 if (lp_domain_logons()) {
3890 DEBUG(1, ("Server's Role (logon server) NOT ADVISED with domain-level security\n"));
3891 server_role = ROLE_DOMAIN_BDC;
3892 break;
3894 server_role = ROLE_DOMAIN_MEMBER;
3895 break;
3896 case SEC_ADS:
3897 if (lp_domain_logons()) {
3898 server_role = ROLE_DOMAIN_PDC;
3899 break;
3901 server_role = ROLE_DOMAIN_MEMBER;
3902 break;
3903 case SEC_USER:
3904 if (lp_domain_logons()) {
3906 if (Globals.bDomainMaster) /* auto or yes */
3907 server_role = ROLE_DOMAIN_PDC;
3908 else
3909 server_role = ROLE_DOMAIN_BDC;
3911 break;
3912 default:
3913 DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
3914 break;
3917 DEBUG(10, ("set_server_role: role = "));
3919 switch(server_role) {
3920 case ROLE_STANDALONE:
3921 DEBUGADD(10, ("ROLE_STANDALONE\n"));
3922 break;
3923 case ROLE_DOMAIN_MEMBER:
3924 DEBUGADD(10, ("ROLE_DOMAIN_MEMBER\n"));
3925 break;
3926 case ROLE_DOMAIN_BDC:
3927 DEBUGADD(10, ("ROLE_DOMAIN_BDC\n"));
3928 break;
3929 case ROLE_DOMAIN_PDC:
3930 DEBUGADD(10, ("ROLE_DOMAIN_PDC\n"));
3931 break;
3935 /***********************************************************
3936 If we should send plaintext/LANMAN passwords in the clinet
3937 ************************************************************/
3938 static void set_allowed_client_auth(void)
3940 if (Globals.bClientNTLMv2Auth) {
3941 Globals.bClientLanManAuth = False;
3943 if (!Globals.bClientLanManAuth) {
3944 Globals.bClientPlaintextAuth = False;
3948 /***************************************************************************
3949 Load the services array from the services file. Return True on success,
3950 False on failure.
3951 ***************************************************************************/
3953 BOOL lp_load(const char *pszFname, BOOL global_only, BOOL save_defaults,
3954 BOOL add_ipc)
3956 pstring n2;
3957 BOOL bRetval;
3958 param_opt_struct *data, *pdata;
3960 pstrcpy(n2, pszFname);
3962 standard_sub_basic( get_current_username(), n2,sizeof(n2) );
3964 add_to_file_list(pszFname, n2);
3966 bRetval = False;
3968 DEBUG(3, ("lp_load: refreshing parameters\n"));
3970 bInGlobalSection = True;
3971 bGlobalOnly = global_only;
3973 init_globals();
3974 debug_init();
3976 if (save_defaults) {
3977 init_locals();
3978 lp_save_defaults();
3981 if (Globals.param_opt != NULL) {
3982 data = Globals.param_opt;
3983 while (data) {
3984 string_free(&data->key);
3985 string_free(&data->value);
3986 str_list_free(&data->list);
3987 pdata = data->next;
3988 SAFE_FREE(data);
3989 data = pdata;
3991 Globals.param_opt = NULL;
3994 /* We get sections first, so have to start 'behind' to make up */
3995 iServiceIndex = -1;
3996 bRetval = pm_process(n2, do_section, do_parameter);
3998 /* finish up the last section */
3999 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
4000 if (bRetval)
4001 if (iServiceIndex >= 0)
4002 bRetval = service_ok(iServiceIndex);
4004 lp_add_auto_services(lp_auto_services());
4006 if (add_ipc) {
4007 /* When 'restrict anonymous = 2' guest connections to ipc$
4008 are denied */
4009 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
4010 lp_add_ipc("ADMIN$", False);
4013 set_server_role();
4014 set_default_server_announce_type();
4015 set_allowed_client_auth();
4017 bLoaded = True;
4019 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
4020 /* if bWINSsupport is true and we are in the client */
4021 if (in_client && Globals.bWINSsupport) {
4022 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
4025 init_iconv();
4027 return (bRetval);
4030 /***************************************************************************
4031 Reset the max number of services.
4032 ***************************************************************************/
4034 void lp_resetnumservices(void)
4036 iNumServices = 0;
4039 /***************************************************************************
4040 Return the max number of services.
4041 ***************************************************************************/
4043 int lp_numservices(void)
4045 return (iNumServices);
4048 /***************************************************************************
4049 Display the contents of the services array in human-readable form.
4050 ***************************************************************************/
4052 void lp_dump(FILE *f, BOOL show_defaults, int maxtoprint)
4054 int iService;
4056 if (show_defaults)
4057 defaults_saved = False;
4059 dump_globals(f);
4061 dump_a_service(&sDefault, f);
4063 for (iService = 0; iService < maxtoprint; iService++)
4064 lp_dump_one(f, show_defaults, iService);
4067 /***************************************************************************
4068 Display the contents of one service in human-readable form.
4069 ***************************************************************************/
4071 void lp_dump_one(FILE * f, BOOL show_defaults, int snum)
4073 if (VALID(snum)) {
4074 if (ServicePtrs[snum]->szService[0] == '\0')
4075 return;
4076 dump_a_service(ServicePtrs[snum], f);
4080 /***************************************************************************
4081 Return the number of the service with the given name, or -1 if it doesn't
4082 exist. Note that this is a DIFFERENT ANIMAL from the internal function
4083 getservicebyname()! This works ONLY if all services have been loaded, and
4084 does not copy the found service.
4085 ***************************************************************************/
4087 int lp_servicenumber(const char *pszServiceName)
4089 int iService;
4090 fstring serviceName;
4092 if (!pszServiceName)
4093 return GLOBAL_SECTION_SNUM;
4095 for (iService = iNumServices - 1; iService >= 0; iService--) {
4096 if (VALID(iService) && ServicePtrs[iService]->szService) {
4098 * The substitution here is used to support %U is
4099 * service names
4101 fstrcpy(serviceName, ServicePtrs[iService]->szService);
4102 standard_sub_basic(get_current_username(), serviceName,sizeof(serviceName));
4103 if (strequal(serviceName, pszServiceName))
4104 break;
4108 if (iService < 0) {
4109 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
4110 return GLOBAL_SECTION_SNUM;
4113 return (iService);
4116 /*******************************************************************
4117 A useful volume label function.
4118 ********************************************************************/
4120 char *volume_label(int snum)
4122 char *ret = lp_volume(snum);
4123 if (!*ret)
4124 return lp_servicename(snum);
4125 return (ret);
4129 /*******************************************************************
4130 Set the server type we will announce as via nmbd.
4131 ********************************************************************/
4133 static void set_default_server_announce_type(void)
4135 default_server_announce = 0;
4136 default_server_announce |= SV_TYPE_WORKSTATION;
4137 default_server_announce |= SV_TYPE_SERVER;
4138 default_server_announce |= SV_TYPE_SERVER_UNIX;
4140 /* note that the flag should be set only if we have a
4141 printer service but nmbd doesn't actually load the
4142 services so we can't tell --jerry */
4144 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
4146 switch (lp_announce_as()) {
4147 case ANNOUNCE_AS_NT_SERVER:
4148 default_server_announce |= SV_TYPE_SERVER_NT;
4149 /* fall through... */
4150 case ANNOUNCE_AS_NT_WORKSTATION:
4151 default_server_announce |= SV_TYPE_NT;
4152 break;
4153 case ANNOUNCE_AS_WIN95:
4154 default_server_announce |= SV_TYPE_WIN95_PLUS;
4155 break;
4156 case ANNOUNCE_AS_WFW:
4157 default_server_announce |= SV_TYPE_WFW;
4158 break;
4159 default:
4160 break;
4163 switch (lp_server_role()) {
4164 case ROLE_DOMAIN_MEMBER:
4165 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
4166 break;
4167 case ROLE_DOMAIN_PDC:
4168 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
4169 break;
4170 case ROLE_DOMAIN_BDC:
4171 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
4172 break;
4173 case ROLE_STANDALONE:
4174 default:
4175 break;
4177 if (lp_time_server())
4178 default_server_announce |= SV_TYPE_TIME_SOURCE;
4180 if (lp_host_msdfs())
4181 default_server_announce |= SV_TYPE_DFS_SERVER;
4184 /***********************************************************
4185 returns role of Samba server
4186 ************************************************************/
4188 int lp_server_role(void)
4190 return server_role;
4193 /***********************************************************
4194 If we are PDC then prefer us as DMB
4195 ************************************************************/
4197 BOOL lp_domain_master(void)
4199 if (Globals.bDomainMaster == Auto)
4200 return (lp_server_role() == ROLE_DOMAIN_PDC);
4202 return Globals.bDomainMaster;
4205 /***********************************************************
4206 If we are DMB then prefer us as LMB
4207 ************************************************************/
4209 BOOL lp_preferred_master(void)
4211 if (Globals.bPreferredMaster == Auto)
4212 return (lp_local_master() && lp_domain_master());
4214 return Globals.bPreferredMaster;
4217 /*******************************************************************
4218 Remove a service.
4219 ********************************************************************/
4221 void lp_remove_service(int snum)
4223 ServicePtrs[snum]->valid = False;
4226 /*******************************************************************
4227 Copy a service.
4228 ********************************************************************/
4230 void lp_copy_service(int snum, const char *new_name)
4232 do_section(new_name);
4233 if (snum >= 0) {
4234 snum = lp_servicenumber(new_name);
4235 if (snum >= 0)
4236 lp_do_parameter(snum, "copy", lp_servicename(snum));
4241 /*******************************************************************
4242 Get the default server type we will announce as via nmbd.
4243 ********************************************************************/
4245 int lp_default_server_announce(void)
4247 return default_server_announce;
4250 /*******************************************************************
4251 Split the announce version into major and minor numbers.
4252 ********************************************************************/
4254 int lp_major_announce_version(void)
4256 static BOOL got_major = False;
4257 static int major_version = DEFAULT_MAJOR_VERSION;
4258 char *vers;
4259 char *p;
4261 if (got_major)
4262 return major_version;
4264 got_major = True;
4265 if ((vers = lp_announce_version()) == NULL)
4266 return major_version;
4268 if ((p = strchr_m(vers, '.')) == 0)
4269 return major_version;
4271 *p = '\0';
4272 major_version = atoi(vers);
4273 return major_version;
4276 int lp_minor_announce_version(void)
4278 static BOOL got_minor = False;
4279 static int minor_version = DEFAULT_MINOR_VERSION;
4280 char *vers;
4281 char *p;
4283 if (got_minor)
4284 return minor_version;
4286 got_minor = True;
4287 if ((vers = lp_announce_version()) == NULL)
4288 return minor_version;
4290 if ((p = strchr_m(vers, '.')) == 0)
4291 return minor_version;
4293 p++;
4294 minor_version = atoi(p);
4295 return minor_version;
4298 /***********************************************************
4299 Set the global name resolution order (used in smbclient).
4300 ************************************************************/
4302 void lp_set_name_resolve_order(const char *new_order)
4304 string_set(&Globals.szNameResolveOrder, new_order);
4307 const char *lp_printername(int snum)
4309 const char *ret = _lp_printername(snum);
4310 if (ret == NULL || (ret != NULL && *ret == '\0'))
4311 ret = lp_const_servicename(snum);
4313 return ret;
4317 /****************************************************************
4318 Compatibility fn. for 2.2.2 code.....
4319 *****************************************************************/
4321 void get_private_directory(pstring privdir)
4323 pstrcpy (privdir, lp_private_dir());
4326 /***********************************************************
4327 Allow daemons such as winbindd to fix their logfile name.
4328 ************************************************************/
4330 void lp_set_logfile(const char *name)
4332 string_set(&Globals.szLogFile, name);
4333 pstrcpy(debugf, name);
4336 /*******************************************************************
4337 Return the max print jobs per queue.
4338 ********************************************************************/
4340 int lp_maxprintjobs(int snum)
4342 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
4343 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
4344 maxjobs = PRINT_MAX_JOBID - 1;
4346 return maxjobs;
4349 const char *lp_printcapname(void)
4351 if ((Globals.szPrintcapname != NULL) &&
4352 (Globals.szPrintcapname[0] != '\0'))
4353 return Globals.szPrintcapname;
4355 if (sDefault.iPrinting == PRINT_CUPS) {
4356 #ifdef HAVE_CUPS
4357 return "cups";
4358 #else
4359 return "lpstat";
4360 #endif
4363 if (sDefault.iPrinting == PRINT_BSD)
4364 return "/etc/printcap";
4366 return PRINTCAP_NAME;
4369 /*******************************************************************
4370 Ensure we don't use sendfile if server smb signing is active.
4371 ********************************************************************/
4373 BOOL lp_use_sendfile(int snum)
4375 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
4376 if (Protocol < PROTOCOL_NT1) {
4377 return False;
4379 return (_lp_use_sendfile(snum) && (get_remote_arch() != RA_WIN95) && !srv_is_signing_active());
4382 /*******************************************************************
4383 Turn off sendfile if we find the underlying OS doesn't support it.
4384 ********************************************************************/
4386 void set_use_sendfile(int snum, BOOL val)
4388 if (LP_SNUM_OK(snum))
4389 ServicePtrs[snum]->bUseSendfile = val;
4390 else
4391 sDefault.bUseSendfile = val;
4394 /*******************************************************************
4395 Turn off storing DOS attributes if this share doesn't support it.
4396 ********************************************************************/
4398 void set_store_dos_attributes(int snum, BOOL val)
4400 if (!LP_SNUM_OK(snum))
4401 return;
4402 ServicePtrs[(snum)]->bStoreDosAttributes = val;