libcli/auth: only expose creds to the caller on success
[Samba.git] / source3 / param / loadparm.c
blob08b6532b52d0f380956d8f8daa094a85ab19c639
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
12 Copyright (C) Michael Adam 2008
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 3 of the License, or
17 (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>.
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"
55 #include "printing.h"
57 #ifdef HAVE_SYS_SYSCTL_H
58 #include <sys/sysctl.h>
59 #endif
61 #ifdef HAVE_HTTPCONNECTENCRYPT
62 #include <cups/http.h>
63 #endif
65 bool bLoaded = False;
67 extern userdom_struct current_user_info;
69 #ifndef GLOBAL_NAME
70 #define GLOBAL_NAME "global"
71 #endif
73 #ifndef PRINTERS_NAME
74 #define PRINTERS_NAME "printers"
75 #endif
77 #ifndef HOMES_NAME
78 #define HOMES_NAME "homes"
79 #endif
81 /* the special value for the include parameter
82 * to be interpreted not as a file name but to
83 * trigger loading of the global smb.conf options
84 * from registry. */
85 #ifndef INCLUDE_REGISTRY_NAME
86 #define INCLUDE_REGISTRY_NAME "registry"
87 #endif
89 static bool in_client = False; /* Not in the client by default */
90 static struct smbconf_csn conf_last_csn;
92 #define CONFIG_BACKEND_FILE 0
93 #define CONFIG_BACKEND_REGISTRY 1
95 static int config_backend = CONFIG_BACKEND_FILE;
97 /* some helpful bits */
98 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
99 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
101 #define USERSHARE_VALID 1
102 #define USERSHARE_PENDING_DELETE 2
104 static bool defaults_saved = False;
106 struct param_opt_struct {
107 struct param_opt_struct *prev, *next;
108 char *key;
109 char *value;
110 char **list;
114 * This structure describes global (ie., server-wide) parameters.
116 struct global {
117 int ConfigBackend;
118 char *smb_ports;
119 char *dos_charset;
120 char *unix_charset;
121 char *display_charset;
122 char *szPrintcapname;
123 char *szAddPortCommand;
124 char *szEnumPortsCommand;
125 char *szAddPrinterCommand;
126 char *szDeletePrinterCommand;
127 char *szOs2DriverMap;
128 char *szLockDir;
129 char *szStateDir;
130 char *szCacheDir;
131 char *szPidDir;
132 char *szRootdir;
133 char *szDefaultService;
134 char *szGetQuota;
135 char *szSetQuota;
136 char *szMsgCommand;
137 char *szServerString;
138 char *szAutoServices;
139 char *szPasswdProgram;
140 char *szPasswdChat;
141 char *szLogFile;
142 char *szConfigFile;
143 char *szSMBPasswdFile;
144 char *szPrivateDir;
145 char *szPassdbBackend;
146 char **szPreloadModules;
147 char *szPasswordServer;
148 char *szSocketOptions;
149 char *szRealm;
150 char *szAfsUsernameMap;
151 int iAfsTokenLifetime;
152 char *szLogNtTokenCommand;
153 char *szUsernameMap;
154 char *szLogonScript;
155 char *szLogonPath;
156 char *szLogonDrive;
157 char *szLogonHome;
158 char **szWINSservers;
159 char **szInterfaces;
160 char *szRemoteAnnounce;
161 char *szRemoteBrowseSync;
162 char *szSocketAddress;
163 bool bNmbdBindExplicitBroadcast;
164 char *szNISHomeMapName;
165 char *szAnnounceVersion; /* This is initialised in init_globals */
166 char *szWorkgroup;
167 char *szNetbiosName;
168 char **szNetbiosAliases;
169 char *szNetbiosScope;
170 char *szNameResolveOrder;
171 char *szPanicAction;
172 char *szAddUserScript;
173 char *szRenameUserScript;
174 char *szDelUserScript;
175 char *szAddGroupScript;
176 char *szDelGroupScript;
177 char *szAddUserToGroupScript;
178 char *szDelUserFromGroupScript;
179 char *szSetPrimaryGroupScript;
180 char *szAddMachineScript;
181 char *szShutdownScript;
182 char *szAbortShutdownScript;
183 char *szUsernameMapScript;
184 char *szCheckPasswordScript;
185 char *szWINSHook;
186 char *szUtmpDir;
187 char *szWtmpDir;
188 bool bUtmp;
189 char *szIdmapUID;
190 char *szIdmapGID;
191 bool bPassdbExpandExplicit;
192 int AlgorithmicRidBase;
193 char *szTemplateHomedir;
194 char *szTemplateShell;
195 char *szWinbindSeparator;
196 bool bWinbindEnumUsers;
197 bool bWinbindEnumGroups;
198 bool bWinbindUseDefaultDomain;
199 bool bWinbindTrustedDomainsOnly;
200 bool bWinbindNestedGroups;
201 int winbind_expand_groups;
202 bool bWinbindRefreshTickets;
203 bool bWinbindOfflineLogon;
204 bool bWinbindNormalizeNames;
205 bool bWinbindRpcOnly;
206 bool bCreateKrb5Conf;
207 char *szIdmapBackend;
208 char *szIdmapAllocBackend;
209 char *szAddShareCommand;
210 char *szChangeShareCommand;
211 char *szDeleteShareCommand;
212 char **szEventLogs;
213 char *szGuestaccount;
214 char *szManglingMethod;
215 char **szServicesList;
216 char *szUsersharePath;
217 char *szUsershareTemplateShare;
218 char **szUsersharePrefixAllowList;
219 char **szUsersharePrefixDenyList;
220 int mangle_prefix;
221 int max_log_size;
222 char *szLogLevel;
223 int max_xmit;
224 int max_mux;
225 int max_open_files;
226 int open_files_db_hash_size;
227 int pwordlevel;
228 int unamelevel;
229 int deadtime;
230 bool getwd_cache;
231 int maxprotocol;
232 int minprotocol;
233 int security;
234 char **AuthMethods;
235 bool paranoid_server_security;
236 int maxdisksize;
237 int lpqcachetime;
238 int iMaxSmbdProcesses;
239 bool bDisableSpoolss;
240 int syslog;
241 int os_level;
242 bool enhanced_browsing;
243 int max_ttl;
244 int max_wins_ttl;
245 int min_wins_ttl;
246 int lm_announce;
247 int lm_interval;
248 int announce_as; /* This is initialised in init_globals */
249 int machine_password_timeout;
250 int map_to_guest;
251 int oplock_break_wait_time;
252 int winbind_cache_time;
253 int winbind_reconnect_delay;
254 int winbind_max_clients;
255 char **szWinbindNssInfo;
256 int iLockSpinTime;
257 char *szLdapMachineSuffix;
258 char *szLdapUserSuffix;
259 char *szLdapIdmapSuffix;
260 char *szLdapGroupSuffix;
261 int ldap_ssl;
262 bool ldap_ssl_ads;
263 int ldap_deref;
264 int ldap_follow_referral;
265 char *szLdapSuffix;
266 char *szLdapAdminDn;
267 int ldap_debug_level;
268 int ldap_debug_threshold;
269 int iAclCompat;
270 char *szCupsServer;
271 int CupsEncrypt;
272 char *szIPrintServer;
273 char *ctdbdSocket;
274 char **szClusterAddresses;
275 bool clustering;
276 int ctdb_timeout;
277 int ldap_passwd_sync;
278 int ldap_replication_sleep;
279 int ldap_timeout; /* This is initialised in init_globals */
280 int ldap_connection_timeout;
281 int ldap_page_size;
282 bool ldap_delete_dn;
283 bool bMsAddPrinterWizard;
284 bool bDNSproxy;
285 bool bWINSsupport;
286 bool bWINSproxy;
287 bool bLocalMaster;
288 int iPreferredMaster;
289 int iDomainMaster;
290 bool bDomainLogons;
291 char **szInitLogonDelayedHosts;
292 int InitLogonDelay;
293 bool bEncryptPasswords;
294 bool bUpdateEncrypt;
295 int clientSchannel;
296 int serverSchannel;
297 bool bNullPasswords;
298 bool bObeyPamRestrictions;
299 bool bLoadPrinters;
300 int PrintcapCacheTime;
301 bool bLargeReadwrite;
302 bool bReadRaw;
303 bool bWriteRaw;
304 bool bSyslogOnly;
305 bool bBrowseList;
306 bool bNISHomeMap;
307 bool bTimeServer;
308 bool bBindInterfacesOnly;
309 bool bPamPasswordChange;
310 bool bUnixPasswdSync;
311 bool bPasswdChatDebug;
312 int iPasswdChatTimeout;
313 bool bTimestampLogs;
314 bool bNTSmbSupport;
315 bool bNTPipeSupport;
316 bool bNTStatusSupport;
317 bool bStatCache;
318 int iMaxStatCacheSize;
319 bool bKernelOplocks;
320 bool bAllowTrustedDomains;
321 bool bLanmanAuth;
322 bool bNTLMAuth;
323 bool bUseSpnego;
324 bool bClientLanManAuth;
325 bool bClientNTLMv2Auth;
326 bool bClientPlaintextAuth;
327 bool bClientUseSpnego;
328 bool client_use_spnego_principal;
329 bool bDebugPrefixTimestamp;
330 bool bDebugHiresTimestamp;
331 bool bDebugPid;
332 bool bDebugUid;
333 bool bDebugClass;
334 bool bEnableCoreFiles;
335 bool bHostMSDfs;
336 bool bUseMmap;
337 bool bHostnameLookups;
338 bool bUnixExtensions;
339 bool bDisableNetbios;
340 char * szDedicatedKeytabFile;
341 int iKerberosMethod;
342 bool bDeferSharingViolations;
343 bool bEnablePrivileges;
344 bool bASUSupport;
345 bool bUsershareOwnerOnly;
346 bool bUsershareAllowGuests;
347 bool bRegistryShares;
348 int restrict_anonymous;
349 int name_cache_timeout;
350 int client_signing;
351 int server_signing;
352 int client_ldap_sasl_wrapping;
353 int iUsershareMaxShares;
354 int iIdmapCacheTime;
355 int iIdmapNegativeCacheTime;
356 bool bResetOnZeroVC;
357 int iKeepalive;
358 int iminreceivefile;
359 struct param_opt_struct *param_opt;
360 int cups_connection_timeout;
361 char *szSMBPerfcountModule;
362 bool bMapUntrustedToDomain;
365 static struct global Globals;
368 * This structure describes a single service.
370 struct service {
371 bool valid;
372 bool autoloaded;
373 int usershare;
374 struct timespec usershare_last_mod;
375 char *szService;
376 char *szPath;
377 char *szUsername;
378 char **szInvalidUsers;
379 char **szValidUsers;
380 char **szAdminUsers;
381 char *szCopy;
382 char *szInclude;
383 char *szPreExec;
384 char *szPostExec;
385 char *szRootPreExec;
386 char *szRootPostExec;
387 char *szCupsOptions;
388 char *szPrintcommand;
389 char *szLpqcommand;
390 char *szLprmcommand;
391 char *szLppausecommand;
392 char *szLpresumecommand;
393 char *szQueuepausecommand;
394 char *szQueueresumecommand;
395 char *szPrintername;
396 char *szPrintjobUsername;
397 char *szDontdescend;
398 char **szHostsallow;
399 char **szHostsdeny;
400 char *szMagicScript;
401 char *szMagicOutput;
402 char *szVetoFiles;
403 char *szHideFiles;
404 char *szVetoOplockFiles;
405 char *comment;
406 char *force_user;
407 char *force_group;
408 char **readlist;
409 char **writelist;
410 char **printer_admin;
411 char *volume;
412 char *fstype;
413 char **szVfsObjects;
414 char *szMSDfsProxy;
415 char *szAioWriteBehind;
416 char *szDfree;
417 int iMinPrintSpace;
418 int iMaxPrintJobs;
419 int iMaxReportedPrintJobs;
420 int iWriteCacheSize;
421 int iCreate_mask;
422 int iCreate_force_mode;
423 int iSecurity_mask;
424 int iSecurity_force_mode;
425 int iDir_mask;
426 int iDir_force_mode;
427 int iDir_Security_mask;
428 int iDir_Security_force_mode;
429 int iMaxConnections;
430 int iDefaultCase;
431 int iPrinting;
432 int iOplockContentionLimit;
433 int iCSCPolicy;
434 int iBlock_size;
435 int iDfreeCacheTime;
436 bool bPreexecClose;
437 bool bRootpreexecClose;
438 int iCaseSensitive;
439 bool bCasePreserve;
440 bool bShortCasePreserve;
441 bool bHideDotFiles;
442 bool bHideSpecialFiles;
443 bool bHideUnReadable;
444 bool bHideUnWriteableFiles;
445 bool bBrowseable;
446 bool bAccessBasedShareEnum;
447 bool bAvailable;
448 bool bRead_only;
449 bool bNo_set_dir;
450 bool bGuest_only;
451 bool bAdministrative_share;
452 bool bGuest_ok;
453 bool bPrint_ok;
454 bool bMap_system;
455 bool bMap_hidden;
456 bool bMap_archive;
457 bool bStoreDosAttributes;
458 bool bDmapiSupport;
459 bool bLocking;
460 int iStrictLocking;
461 bool bPosixLocking;
462 bool bShareModes;
463 bool bOpLocks;
464 bool bLevel2OpLocks;
465 bool bOnlyUser;
466 bool bMangledNames;
467 bool bWidelinks;
468 bool bSymlinks;
469 bool bSyncAlways;
470 bool bStrictAllocate;
471 bool bStrictSync;
472 char magic_char;
473 struct bitmap *copymap;
474 bool bDeleteReadonly;
475 bool bFakeOplocks;
476 bool bDeleteVetoFiles;
477 bool bDosFilemode;
478 bool bDosFiletimes;
479 bool bDosFiletimeResolution;
480 bool bFakeDirCreateTimes;
481 bool bBlockingLocks;
482 bool bInheritPerms;
483 bool bInheritACLS;
484 bool bInheritOwner;
485 bool bMSDfsRoot;
486 bool bUseClientDriver;
487 bool bDefaultDevmode;
488 bool bForcePrintername;
489 bool bNTAclSupport;
490 bool bForceUnknownAclUser;
491 bool bUseSendfile;
492 bool bProfileAcls;
493 bool bMap_acl_inherit;
494 bool bAfs_Share;
495 bool bEASupport;
496 bool bAclCheckPermissions;
497 bool bAclMapFullControl;
498 bool bAclGroupControl;
499 bool bChangeNotify;
500 bool bKernelChangeNotify;
501 int iallocation_roundup_size;
502 int iAioReadSize;
503 int iAioWriteSize;
504 int iMap_readonly;
505 int iDirectoryNameCacheSize;
506 int ismb_encrypt;
507 struct param_opt_struct *param_opt;
509 char dummy[3]; /* for alignment */
513 /* This is a default service used to prime a services structure */
514 static struct service sDefault = {
515 True, /* valid */
516 False, /* not autoloaded */
517 0, /* not a usershare */
518 {0, }, /* No last mod time */
519 NULL, /* szService */
520 NULL, /* szPath */
521 NULL, /* szUsername */
522 NULL, /* szInvalidUsers */
523 NULL, /* szValidUsers */
524 NULL, /* szAdminUsers */
525 NULL, /* szCopy */
526 NULL, /* szInclude */
527 NULL, /* szPreExec */
528 NULL, /* szPostExec */
529 NULL, /* szRootPreExec */
530 NULL, /* szRootPostExec */
531 NULL, /* szCupsOptions */
532 NULL, /* szPrintcommand */
533 NULL, /* szLpqcommand */
534 NULL, /* szLprmcommand */
535 NULL, /* szLppausecommand */
536 NULL, /* szLpresumecommand */
537 NULL, /* szQueuepausecommand */
538 NULL, /* szQueueresumecommand */
539 NULL, /* szPrintername */
540 NULL, /* szPrintjobUsername */
541 NULL, /* szDontdescend */
542 NULL, /* szHostsallow */
543 NULL, /* szHostsdeny */
544 NULL, /* szMagicScript */
545 NULL, /* szMagicOutput */
546 NULL, /* szVetoFiles */
547 NULL, /* szHideFiles */
548 NULL, /* szVetoOplockFiles */
549 NULL, /* comment */
550 NULL, /* force user */
551 NULL, /* force group */
552 NULL, /* readlist */
553 NULL, /* writelist */
554 NULL, /* printer admin */
555 NULL, /* volume */
556 NULL, /* fstype */
557 NULL, /* vfs objects */
558 NULL, /* szMSDfsProxy */
559 NULL, /* szAioWriteBehind */
560 NULL, /* szDfree */
561 0, /* iMinPrintSpace */
562 1000, /* iMaxPrintJobs */
563 0, /* iMaxReportedPrintJobs */
564 0, /* iWriteCacheSize */
565 0744, /* iCreate_mask */
566 0000, /* iCreate_force_mode */
567 0777, /* iSecurity_mask */
568 0, /* iSecurity_force_mode */
569 0755, /* iDir_mask */
570 0000, /* iDir_force_mode */
571 0777, /* iDir_Security_mask */
572 0, /* iDir_Security_force_mode */
573 0, /* iMaxConnections */
574 CASE_LOWER, /* iDefaultCase */
575 DEFAULT_PRINTING, /* iPrinting */
576 2, /* iOplockContentionLimit */
577 0, /* iCSCPolicy */
578 1024, /* iBlock_size */
579 0, /* iDfreeCacheTime */
580 False, /* bPreexecClose */
581 False, /* bRootpreexecClose */
582 Auto, /* case sensitive */
583 True, /* case preserve */
584 True, /* short case preserve */
585 True, /* bHideDotFiles */
586 False, /* bHideSpecialFiles */
587 False, /* bHideUnReadable */
588 False, /* bHideUnWriteableFiles */
589 True, /* bBrowseable */
590 False, /* bAccessBasedShareEnum */
591 True, /* bAvailable */
592 True, /* bRead_only */
593 True, /* bNo_set_dir */
594 False, /* bGuest_only */
595 False, /* bAdministrative_share */
596 False, /* bGuest_ok */
597 False, /* bPrint_ok */
598 False, /* bMap_system */
599 False, /* bMap_hidden */
600 True, /* bMap_archive */
601 False, /* bStoreDosAttributes */
602 False, /* bDmapiSupport */
603 True, /* bLocking */
604 Auto, /* iStrictLocking */
605 True, /* bPosixLocking */
606 True, /* bShareModes */
607 True, /* bOpLocks */
608 True, /* bLevel2OpLocks */
609 False, /* bOnlyUser */
610 True, /* bMangledNames */
611 false, /* bWidelinks */
612 True, /* bSymlinks */
613 False, /* bSyncAlways */
614 False, /* bStrictAllocate */
615 False, /* bStrictSync */
616 '~', /* magic char */
617 NULL, /* copymap */
618 False, /* bDeleteReadonly */
619 False, /* bFakeOplocks */
620 False, /* bDeleteVetoFiles */
621 False, /* bDosFilemode */
622 True, /* bDosFiletimes */
623 False, /* bDosFiletimeResolution */
624 False, /* bFakeDirCreateTimes */
625 True, /* bBlockingLocks */
626 False, /* bInheritPerms */
627 False, /* bInheritACLS */
628 False, /* bInheritOwner */
629 False, /* bMSDfsRoot */
630 False, /* bUseClientDriver */
631 True, /* bDefaultDevmode */
632 False, /* bForcePrintername */
633 True, /* bNTAclSupport */
634 False, /* bForceUnknownAclUser */
635 False, /* bUseSendfile */
636 False, /* bProfileAcls */
637 False, /* bMap_acl_inherit */
638 False, /* bAfs_Share */
639 False, /* bEASupport */
640 True, /* bAclCheckPermissions */
641 True, /* bAclMapFullControl */
642 False, /* bAclGroupControl */
643 True, /* bChangeNotify */
644 True, /* bKernelChangeNotify */
645 SMB_ROUNDUP_ALLOCATION_SIZE, /* iallocation_roundup_size */
646 0, /* iAioReadSize */
647 0, /* iAioWriteSize */
648 MAP_READONLY_YES, /* iMap_readonly */
649 #ifdef BROKEN_DIRECTORY_HANDLING
650 0, /* iDirectoryNameCacheSize */
651 #else
652 100, /* iDirectoryNameCacheSize */
653 #endif
654 Auto, /* ismb_encrypt */
655 NULL, /* Parametric options */
657 "" /* dummy */
660 /* local variables */
661 static struct service **ServicePtrs = NULL;
662 static int iNumServices = 0;
663 static int iServiceIndex = 0;
664 static struct db_context *ServiceHash;
665 static int *invalid_services = NULL;
666 static int num_invalid_services = 0;
667 static bool bInGlobalSection = True;
668 static bool bGlobalOnly = False;
669 static int server_role;
670 static int default_server_announce;
672 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
674 /* prototypes for the special type handlers */
675 static bool handle_include( int snum, const char *pszParmValue, char **ptr);
676 static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
677 static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
678 static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
679 static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
680 static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
681 static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
682 static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
683 static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
684 static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
685 static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
686 static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
688 static void set_server_role(void);
689 static void set_default_server_announce_type(void);
690 static void set_allowed_client_auth(void);
692 static void *lp_local_ptr(struct service *service, void *ptr);
694 static void add_to_file_list(const char *fname, const char *subfname);
696 static const struct enum_list enum_protocol[] = {
697 {PROTOCOL_SMB2, "SMB2"},
698 {PROTOCOL_NT1, "NT1"},
699 {PROTOCOL_LANMAN2, "LANMAN2"},
700 {PROTOCOL_LANMAN1, "LANMAN1"},
701 {PROTOCOL_CORE, "CORE"},
702 {PROTOCOL_COREPLUS, "COREPLUS"},
703 {PROTOCOL_COREPLUS, "CORE+"},
704 {-1, NULL}
707 static const struct enum_list enum_security[] = {
708 {SEC_SHARE, "SHARE"},
709 {SEC_USER, "USER"},
710 {SEC_SERVER, "SERVER"},
711 {SEC_DOMAIN, "DOMAIN"},
712 #ifdef HAVE_ADS
713 {SEC_ADS, "ADS"},
714 #endif
715 {-1, NULL}
718 static const struct enum_list enum_printing[] = {
719 {PRINT_SYSV, "sysv"},
720 {PRINT_AIX, "aix"},
721 {PRINT_HPUX, "hpux"},
722 {PRINT_BSD, "bsd"},
723 {PRINT_QNX, "qnx"},
724 {PRINT_PLP, "plp"},
725 {PRINT_LPRNG, "lprng"},
726 {PRINT_CUPS, "cups"},
727 {PRINT_IPRINT, "iprint"},
728 {PRINT_LPRNT, "nt"},
729 {PRINT_LPROS2, "os2"},
730 #ifdef DEVELOPER
731 {PRINT_TEST, "test"},
732 {PRINT_VLP, "vlp"},
733 #endif /* DEVELOPER */
734 {-1, NULL}
737 static const struct enum_list enum_ldap_sasl_wrapping[] = {
738 {0, "plain"},
739 {ADS_AUTH_SASL_SIGN, "sign"},
740 {ADS_AUTH_SASL_SEAL, "seal"},
741 {-1, NULL}
744 static const struct enum_list enum_ldap_ssl[] = {
745 {LDAP_SSL_OFF, "no"},
746 {LDAP_SSL_OFF, "off"},
747 {LDAP_SSL_START_TLS, "start tls"},
748 {LDAP_SSL_START_TLS, "start_tls"},
749 {-1, NULL}
752 /* LDAP Dereferencing Alias types */
753 #define SAMBA_LDAP_DEREF_NEVER 0
754 #define SAMBA_LDAP_DEREF_SEARCHING 1
755 #define SAMBA_LDAP_DEREF_FINDING 2
756 #define SAMBA_LDAP_DEREF_ALWAYS 3
758 static const struct enum_list enum_ldap_deref[] = {
759 {SAMBA_LDAP_DEREF_NEVER, "never"},
760 {SAMBA_LDAP_DEREF_SEARCHING, "searching"},
761 {SAMBA_LDAP_DEREF_FINDING, "finding"},
762 {SAMBA_LDAP_DEREF_ALWAYS, "always"},
763 {-1, "auto"}
766 static const struct enum_list enum_ldap_passwd_sync[] = {
767 {LDAP_PASSWD_SYNC_OFF, "no"},
768 {LDAP_PASSWD_SYNC_OFF, "off"},
769 {LDAP_PASSWD_SYNC_ON, "yes"},
770 {LDAP_PASSWD_SYNC_ON, "on"},
771 {LDAP_PASSWD_SYNC_ONLY, "only"},
772 {-1, NULL}
775 /* Types of machine we can announce as. */
776 #define ANNOUNCE_AS_NT_SERVER 1
777 #define ANNOUNCE_AS_WIN95 2
778 #define ANNOUNCE_AS_WFW 3
779 #define ANNOUNCE_AS_NT_WORKSTATION 4
781 static const struct enum_list enum_announce_as[] = {
782 {ANNOUNCE_AS_NT_SERVER, "NT"},
783 {ANNOUNCE_AS_NT_SERVER, "NT Server"},
784 {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
785 {ANNOUNCE_AS_WIN95, "win95"},
786 {ANNOUNCE_AS_WFW, "WfW"},
787 {-1, NULL}
790 static const struct enum_list enum_map_readonly[] = {
791 {MAP_READONLY_NO, "no"},
792 {MAP_READONLY_NO, "false"},
793 {MAP_READONLY_NO, "0"},
794 {MAP_READONLY_YES, "yes"},
795 {MAP_READONLY_YES, "true"},
796 {MAP_READONLY_YES, "1"},
797 {MAP_READONLY_PERMISSIONS, "permissions"},
798 {MAP_READONLY_PERMISSIONS, "perms"},
799 {-1, NULL}
802 static const struct enum_list enum_case[] = {
803 {CASE_LOWER, "lower"},
804 {CASE_UPPER, "upper"},
805 {-1, NULL}
810 static const struct enum_list enum_bool_auto[] = {
811 {False, "No"},
812 {False, "False"},
813 {False, "0"},
814 {True, "Yes"},
815 {True, "True"},
816 {True, "1"},
817 {Auto, "Auto"},
818 {-1, NULL}
821 /* Client-side offline caching policy types */
822 #define CSC_POLICY_MANUAL 0
823 #define CSC_POLICY_DOCUMENTS 1
824 #define CSC_POLICY_PROGRAMS 2
825 #define CSC_POLICY_DISABLE 3
827 static const struct enum_list enum_csc_policy[] = {
828 {CSC_POLICY_MANUAL, "manual"},
829 {CSC_POLICY_DOCUMENTS, "documents"},
830 {CSC_POLICY_PROGRAMS, "programs"},
831 {CSC_POLICY_DISABLE, "disable"},
832 {-1, NULL}
835 /* SMB signing types. */
836 static const struct enum_list enum_smb_signing_vals[] = {
837 {False, "No"},
838 {False, "False"},
839 {False, "0"},
840 {False, "Off"},
841 {False, "disabled"},
842 {True, "Yes"},
843 {True, "True"},
844 {True, "1"},
845 {True, "On"},
846 {True, "enabled"},
847 {Auto, "auto"},
848 {Required, "required"},
849 {Required, "mandatory"},
850 {Required, "force"},
851 {Required, "forced"},
852 {Required, "enforced"},
853 {-1, NULL}
856 /* ACL compatibility options. */
857 static const struct enum_list enum_acl_compat_vals[] = {
858 { ACL_COMPAT_AUTO, "auto" },
859 { ACL_COMPAT_WINNT, "winnt" },
860 { ACL_COMPAT_WIN2K, "win2k" },
861 { -1, NULL}
865 Do you want session setups at user level security with a invalid
866 password to be rejected or allowed in as guest? WinNT rejects them
867 but it can be a pain as it means "net view" needs to use a password
869 You have 3 choices in the setting of map_to_guest:
871 "Never" means session setups with an invalid password
872 are rejected. This is the default.
874 "Bad User" means session setups with an invalid password
875 are rejected, unless the username does not exist, in which case it
876 is treated as a guest login
878 "Bad Password" means session setups with an invalid password
879 are treated as a guest login
881 Note that map_to_guest only has an effect in user or server
882 level security.
885 static const struct enum_list enum_map_to_guest[] = {
886 {NEVER_MAP_TO_GUEST, "Never"},
887 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
888 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
889 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
890 {-1, NULL}
893 /* Config backend options */
895 static const struct enum_list enum_config_backend[] = {
896 {CONFIG_BACKEND_FILE, "file"},
897 {CONFIG_BACKEND_REGISTRY, "registry"},
898 {-1, NULL}
901 /* ADS kerberos ticket verification options */
903 static const struct enum_list enum_kerberos_method[] = {
904 {KERBEROS_VERIFY_SECRETS, "default"},
905 {KERBEROS_VERIFY_SECRETS, "secrets only"},
906 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
907 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
908 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
909 {-1, NULL}
912 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
914 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
915 * screen in SWAT. This is used to exclude parameters as well as to squash all
916 * parameters that have been duplicated by pseudonyms.
918 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
919 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
920 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
921 * respective views.
923 * NOTE2: Handling of duplicated (synonym) parameters:
924 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
925 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
926 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
927 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
930 static struct parm_struct parm_table[] = {
931 {N_("Base Options"), P_SEP, P_SEPARATOR},
934 .label = "dos charset",
935 .type = P_STRING,
936 .p_class = P_GLOBAL,
937 .ptr = &Globals.dos_charset,
938 .special = handle_charset,
939 .enum_list = NULL,
940 .flags = FLAG_ADVANCED
943 .label = "unix charset",
944 .type = P_STRING,
945 .p_class = P_GLOBAL,
946 .ptr = &Globals.unix_charset,
947 .special = handle_charset,
948 .enum_list = NULL,
949 .flags = FLAG_ADVANCED
952 .label = "display charset",
953 .type = P_STRING,
954 .p_class = P_GLOBAL,
955 .ptr = &Globals.display_charset,
956 .special = handle_charset,
957 .enum_list = NULL,
958 .flags = FLAG_ADVANCED
961 .label = "comment",
962 .type = P_STRING,
963 .p_class = P_LOCAL,
964 .ptr = &sDefault.comment,
965 .special = NULL,
966 .enum_list = NULL,
967 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
970 .label = "path",
971 .type = P_STRING,
972 .p_class = P_LOCAL,
973 .ptr = &sDefault.szPath,
974 .special = NULL,
975 .enum_list = NULL,
976 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
979 .label = "directory",
980 .type = P_STRING,
981 .p_class = P_LOCAL,
982 .ptr = &sDefault.szPath,
983 .special = NULL,
984 .enum_list = NULL,
985 .flags = FLAG_HIDE,
988 .label = "workgroup",
989 .type = P_USTRING,
990 .p_class = P_GLOBAL,
991 .ptr = &Globals.szWorkgroup,
992 .special = handle_workgroup,
993 .enum_list = NULL,
994 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
996 #ifdef WITH_ADS
998 .label = "realm",
999 .type = P_USTRING,
1000 .p_class = P_GLOBAL,
1001 .ptr = &Globals.szRealm,
1002 .special = NULL,
1003 .enum_list = NULL,
1004 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1006 #endif
1008 .label = "netbios name",
1009 .type = P_USTRING,
1010 .p_class = P_GLOBAL,
1011 .ptr = &Globals.szNetbiosName,
1012 .special = handle_netbios_name,
1013 .enum_list = NULL,
1014 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1017 .label = "netbios aliases",
1018 .type = P_LIST,
1019 .p_class = P_GLOBAL,
1020 .ptr = &Globals.szNetbiosAliases,
1021 .special = handle_netbios_aliases,
1022 .enum_list = NULL,
1023 .flags = FLAG_ADVANCED,
1026 .label = "netbios scope",
1027 .type = P_USTRING,
1028 .p_class = P_GLOBAL,
1029 .ptr = &Globals.szNetbiosScope,
1030 .special = handle_netbios_scope,
1031 .enum_list = NULL,
1032 .flags = FLAG_ADVANCED,
1035 .label = "server string",
1036 .type = P_STRING,
1037 .p_class = P_GLOBAL,
1038 .ptr = &Globals.szServerString,
1039 .special = NULL,
1040 .enum_list = NULL,
1041 .flags = FLAG_BASIC | FLAG_ADVANCED,
1044 .label = "interfaces",
1045 .type = P_LIST,
1046 .p_class = P_GLOBAL,
1047 .ptr = &Globals.szInterfaces,
1048 .special = NULL,
1049 .enum_list = NULL,
1050 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1053 .label = "bind interfaces only",
1054 .type = P_BOOL,
1055 .p_class = P_GLOBAL,
1056 .ptr = &Globals.bBindInterfacesOnly,
1057 .special = NULL,
1058 .enum_list = NULL,
1059 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1062 .label = "config backend",
1063 .type = P_ENUM,
1064 .p_class = P_GLOBAL,
1065 .ptr = &Globals.ConfigBackend,
1066 .special = NULL,
1067 .enum_list = enum_config_backend,
1068 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
1071 {N_("Security Options"), P_SEP, P_SEPARATOR},
1074 .label = "security",
1075 .type = P_ENUM,
1076 .p_class = P_GLOBAL,
1077 .ptr = &Globals.security,
1078 .special = NULL,
1079 .enum_list = enum_security,
1080 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1083 .label = "auth methods",
1084 .type = P_LIST,
1085 .p_class = P_GLOBAL,
1086 .ptr = &Globals.AuthMethods,
1087 .special = NULL,
1088 .enum_list = NULL,
1089 .flags = FLAG_ADVANCED,
1092 .label = "encrypt passwords",
1093 .type = P_BOOL,
1094 .p_class = P_GLOBAL,
1095 .ptr = &Globals.bEncryptPasswords,
1096 .special = NULL,
1097 .enum_list = NULL,
1098 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1101 .label = "update encrypted",
1102 .type = P_BOOL,
1103 .p_class = P_GLOBAL,
1104 .ptr = &Globals.bUpdateEncrypt,
1105 .special = NULL,
1106 .enum_list = NULL,
1107 .flags = FLAG_ADVANCED,
1110 .label = "client schannel",
1111 .type = P_ENUM,
1112 .p_class = P_GLOBAL,
1113 .ptr = &Globals.clientSchannel,
1114 .special = NULL,
1115 .enum_list = enum_bool_auto,
1116 .flags = FLAG_BASIC | FLAG_ADVANCED,
1119 .label = "server schannel",
1120 .type = P_ENUM,
1121 .p_class = P_GLOBAL,
1122 .ptr = &Globals.serverSchannel,
1123 .special = NULL,
1124 .enum_list = enum_bool_auto,
1125 .flags = FLAG_BASIC | FLAG_ADVANCED,
1128 .label = "allow trusted domains",
1129 .type = P_BOOL,
1130 .p_class = P_GLOBAL,
1131 .ptr = &Globals.bAllowTrustedDomains,
1132 .special = NULL,
1133 .enum_list = NULL,
1134 .flags = FLAG_ADVANCED,
1137 .label = "map to guest",
1138 .type = P_ENUM,
1139 .p_class = P_GLOBAL,
1140 .ptr = &Globals.map_to_guest,
1141 .special = NULL,
1142 .enum_list = enum_map_to_guest,
1143 .flags = FLAG_ADVANCED,
1146 .label = "null passwords",
1147 .type = P_BOOL,
1148 .p_class = P_GLOBAL,
1149 .ptr = &Globals.bNullPasswords,
1150 .special = NULL,
1151 .enum_list = NULL,
1152 .flags = FLAG_ADVANCED,
1155 .label = "obey pam restrictions",
1156 .type = P_BOOL,
1157 .p_class = P_GLOBAL,
1158 .ptr = &Globals.bObeyPamRestrictions,
1159 .special = NULL,
1160 .enum_list = NULL,
1161 .flags = FLAG_ADVANCED,
1164 .label = "password server",
1165 .type = P_STRING,
1166 .p_class = P_GLOBAL,
1167 .ptr = &Globals.szPasswordServer,
1168 .special = NULL,
1169 .enum_list = NULL,
1170 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1173 .label = "smb passwd file",
1174 .type = P_STRING,
1175 .p_class = P_GLOBAL,
1176 .ptr = &Globals.szSMBPasswdFile,
1177 .special = NULL,
1178 .enum_list = NULL,
1179 .flags = FLAG_ADVANCED,
1182 .label = "private dir",
1183 .type = P_STRING,
1184 .p_class = P_GLOBAL,
1185 .ptr = &Globals.szPrivateDir,
1186 .special = NULL,
1187 .enum_list = NULL,
1188 .flags = FLAG_ADVANCED,
1191 .label = "passdb backend",
1192 .type = P_STRING,
1193 .p_class = P_GLOBAL,
1194 .ptr = &Globals.szPassdbBackend,
1195 .special = NULL,
1196 .enum_list = NULL,
1197 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1200 .label = "algorithmic rid base",
1201 .type = P_INTEGER,
1202 .p_class = P_GLOBAL,
1203 .ptr = &Globals.AlgorithmicRidBase,
1204 .special = NULL,
1205 .enum_list = NULL,
1206 .flags = FLAG_ADVANCED,
1209 .label = "root directory",
1210 .type = P_STRING,
1211 .p_class = P_GLOBAL,
1212 .ptr = &Globals.szRootdir,
1213 .special = NULL,
1214 .enum_list = NULL,
1215 .flags = FLAG_ADVANCED,
1218 .label = "root dir",
1219 .type = P_STRING,
1220 .p_class = P_GLOBAL,
1221 .ptr = &Globals.szRootdir,
1222 .special = NULL,
1223 .enum_list = NULL,
1224 .flags = FLAG_HIDE,
1227 .label = "root",
1228 .type = P_STRING,
1229 .p_class = P_GLOBAL,
1230 .ptr = &Globals.szRootdir,
1231 .special = NULL,
1232 .enum_list = NULL,
1233 .flags = FLAG_HIDE,
1236 .label = "guest account",
1237 .type = P_STRING,
1238 .p_class = P_GLOBAL,
1239 .ptr = &Globals.szGuestaccount,
1240 .special = NULL,
1241 .enum_list = NULL,
1242 .flags = FLAG_BASIC | FLAG_ADVANCED,
1245 .label = "enable privileges",
1246 .type = P_BOOL,
1247 .p_class = P_GLOBAL,
1248 .ptr = &Globals.bEnablePrivileges,
1249 .special = NULL,
1250 .enum_list = NULL,
1251 .flags = FLAG_ADVANCED,
1255 .label = "pam password change",
1256 .type = P_BOOL,
1257 .p_class = P_GLOBAL,
1258 .ptr = &Globals.bPamPasswordChange,
1259 .special = NULL,
1260 .enum_list = NULL,
1261 .flags = FLAG_ADVANCED,
1264 .label = "passwd program",
1265 .type = P_STRING,
1266 .p_class = P_GLOBAL,
1267 .ptr = &Globals.szPasswdProgram,
1268 .special = NULL,
1269 .enum_list = NULL,
1270 .flags = FLAG_ADVANCED,
1273 .label = "passwd chat",
1274 .type = P_STRING,
1275 .p_class = P_GLOBAL,
1276 .ptr = &Globals.szPasswdChat,
1277 .special = NULL,
1278 .enum_list = NULL,
1279 .flags = FLAG_ADVANCED,
1282 .label = "passwd chat debug",
1283 .type = P_BOOL,
1284 .p_class = P_GLOBAL,
1285 .ptr = &Globals.bPasswdChatDebug,
1286 .special = NULL,
1287 .enum_list = NULL,
1288 .flags = FLAG_ADVANCED,
1291 .label = "passwd chat timeout",
1292 .type = P_INTEGER,
1293 .p_class = P_GLOBAL,
1294 .ptr = &Globals.iPasswdChatTimeout,
1295 .special = NULL,
1296 .enum_list = NULL,
1297 .flags = FLAG_ADVANCED,
1300 .label = "check password script",
1301 .type = P_STRING,
1302 .p_class = P_GLOBAL,
1303 .ptr = &Globals.szCheckPasswordScript,
1304 .special = NULL,
1305 .enum_list = NULL,
1306 .flags = FLAG_ADVANCED,
1309 .label = "username map",
1310 .type = P_STRING,
1311 .p_class = P_GLOBAL,
1312 .ptr = &Globals.szUsernameMap,
1313 .special = NULL,
1314 .enum_list = NULL,
1315 .flags = FLAG_ADVANCED,
1318 .label = "password level",
1319 .type = P_INTEGER,
1320 .p_class = P_GLOBAL,
1321 .ptr = &Globals.pwordlevel,
1322 .special = NULL,
1323 .enum_list = NULL,
1324 .flags = FLAG_ADVANCED,
1327 .label = "username level",
1328 .type = P_INTEGER,
1329 .p_class = P_GLOBAL,
1330 .ptr = &Globals.unamelevel,
1331 .special = NULL,
1332 .enum_list = NULL,
1333 .flags = FLAG_ADVANCED,
1336 .label = "unix password sync",
1337 .type = P_BOOL,
1338 .p_class = P_GLOBAL,
1339 .ptr = &Globals.bUnixPasswdSync,
1340 .special = NULL,
1341 .enum_list = NULL,
1342 .flags = FLAG_ADVANCED,
1345 .label = "restrict anonymous",
1346 .type = P_INTEGER,
1347 .p_class = P_GLOBAL,
1348 .ptr = &Globals.restrict_anonymous,
1349 .special = NULL,
1350 .enum_list = NULL,
1351 .flags = FLAG_ADVANCED,
1354 .label = "lanman auth",
1355 .type = P_BOOL,
1356 .p_class = P_GLOBAL,
1357 .ptr = &Globals.bLanmanAuth,
1358 .special = NULL,
1359 .enum_list = NULL,
1360 .flags = FLAG_ADVANCED,
1363 .label = "ntlm auth",
1364 .type = P_BOOL,
1365 .p_class = P_GLOBAL,
1366 .ptr = &Globals.bNTLMAuth,
1367 .special = NULL,
1368 .enum_list = NULL,
1369 .flags = FLAG_ADVANCED,
1372 .label = "client NTLMv2 auth",
1373 .type = P_BOOL,
1374 .p_class = P_GLOBAL,
1375 .ptr = &Globals.bClientNTLMv2Auth,
1376 .special = NULL,
1377 .enum_list = NULL,
1378 .flags = FLAG_ADVANCED,
1381 .label = "client lanman auth",
1382 .type = P_BOOL,
1383 .p_class = P_GLOBAL,
1384 .ptr = &Globals.bClientLanManAuth,
1385 .special = NULL,
1386 .enum_list = NULL,
1387 .flags = FLAG_ADVANCED,
1390 .label = "client plaintext auth",
1391 .type = P_BOOL,
1392 .p_class = P_GLOBAL,
1393 .ptr = &Globals.bClientPlaintextAuth,
1394 .special = NULL,
1395 .enum_list = NULL,
1396 .flags = FLAG_ADVANCED,
1399 .label = "client use spnego principal",
1400 .type = P_BOOL,
1401 .p_class = P_GLOBAL,
1402 .ptr = &Globals.client_use_spnego_principal,
1403 .special = NULL,
1404 .enum_list = NULL,
1405 .flags = FLAG_ADVANCED,
1408 .label = "username",
1409 .type = P_STRING,
1410 .p_class = P_LOCAL,
1411 .ptr = &sDefault.szUsername,
1412 .special = NULL,
1413 .enum_list = NULL,
1414 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1417 .label = "user",
1418 .type = P_STRING,
1419 .p_class = P_LOCAL,
1420 .ptr = &sDefault.szUsername,
1421 .special = NULL,
1422 .enum_list = NULL,
1423 .flags = FLAG_HIDE,
1426 .label = "users",
1427 .type = P_STRING,
1428 .p_class = P_LOCAL,
1429 .ptr = &sDefault.szUsername,
1430 .special = NULL,
1431 .enum_list = NULL,
1432 .flags = FLAG_HIDE,
1435 .label = "invalid users",
1436 .type = P_LIST,
1437 .p_class = P_LOCAL,
1438 .ptr = &sDefault.szInvalidUsers,
1439 .special = NULL,
1440 .enum_list = NULL,
1441 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1444 .label = "valid users",
1445 .type = P_LIST,
1446 .p_class = P_LOCAL,
1447 .ptr = &sDefault.szValidUsers,
1448 .special = NULL,
1449 .enum_list = NULL,
1450 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1453 .label = "admin users",
1454 .type = P_LIST,
1455 .p_class = P_LOCAL,
1456 .ptr = &sDefault.szAdminUsers,
1457 .special = NULL,
1458 .enum_list = NULL,
1459 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1462 .label = "read list",
1463 .type = P_LIST,
1464 .p_class = P_LOCAL,
1465 .ptr = &sDefault.readlist,
1466 .special = NULL,
1467 .enum_list = NULL,
1468 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1471 .label = "write list",
1472 .type = P_LIST,
1473 .p_class = P_LOCAL,
1474 .ptr = &sDefault.writelist,
1475 .special = NULL,
1476 .enum_list = NULL,
1477 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1480 .label = "printer admin",
1481 .type = P_LIST,
1482 .p_class = P_LOCAL,
1483 .ptr = &sDefault.printer_admin,
1484 .special = NULL,
1485 .enum_list = NULL,
1486 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1489 .label = "force user",
1490 .type = P_STRING,
1491 .p_class = P_LOCAL,
1492 .ptr = &sDefault.force_user,
1493 .special = NULL,
1494 .enum_list = NULL,
1495 .flags = FLAG_ADVANCED | FLAG_SHARE,
1498 .label = "force group",
1499 .type = P_STRING,
1500 .p_class = P_LOCAL,
1501 .ptr = &sDefault.force_group,
1502 .special = NULL,
1503 .enum_list = NULL,
1504 .flags = FLAG_ADVANCED | FLAG_SHARE,
1507 .label = "group",
1508 .type = P_STRING,
1509 .p_class = P_LOCAL,
1510 .ptr = &sDefault.force_group,
1511 .special = NULL,
1512 .enum_list = NULL,
1513 .flags = FLAG_ADVANCED,
1516 .label = "read only",
1517 .type = P_BOOL,
1518 .p_class = P_LOCAL,
1519 .ptr = &sDefault.bRead_only,
1520 .special = NULL,
1521 .enum_list = NULL,
1522 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1525 .label = "write ok",
1526 .type = P_BOOLREV,
1527 .p_class = P_LOCAL,
1528 .ptr = &sDefault.bRead_only,
1529 .special = NULL,
1530 .enum_list = NULL,
1531 .flags = FLAG_HIDE,
1534 .label = "writeable",
1535 .type = P_BOOLREV,
1536 .p_class = P_LOCAL,
1537 .ptr = &sDefault.bRead_only,
1538 .special = NULL,
1539 .enum_list = NULL,
1540 .flags = FLAG_HIDE,
1543 .label = "writable",
1544 .type = P_BOOLREV,
1545 .p_class = P_LOCAL,
1546 .ptr = &sDefault.bRead_only,
1547 .special = NULL,
1548 .enum_list = NULL,
1549 .flags = FLAG_HIDE,
1552 .label = "acl check permissions",
1553 .type = P_BOOL,
1554 .p_class = P_LOCAL,
1555 .ptr = &sDefault.bAclCheckPermissions,
1556 .special = NULL,
1557 .enum_list = NULL,
1558 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1561 .label = "acl group control",
1562 .type = P_BOOL,
1563 .p_class = P_LOCAL,
1564 .ptr = &sDefault.bAclGroupControl,
1565 .special = NULL,
1566 .enum_list = NULL,
1567 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1570 .label = "acl map full control",
1571 .type = P_BOOL,
1572 .p_class = P_LOCAL,
1573 .ptr = &sDefault.bAclMapFullControl,
1574 .special = NULL,
1575 .enum_list = NULL,
1576 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1579 .label = "create mask",
1580 .type = P_OCTAL,
1581 .p_class = P_LOCAL,
1582 .ptr = &sDefault.iCreate_mask,
1583 .special = NULL,
1584 .enum_list = NULL,
1585 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1588 .label = "create mode",
1589 .type = P_OCTAL,
1590 .p_class = P_LOCAL,
1591 .ptr = &sDefault.iCreate_mask,
1592 .special = NULL,
1593 .enum_list = NULL,
1594 .flags = FLAG_HIDE,
1597 .label = "force create mode",
1598 .type = P_OCTAL,
1599 .p_class = P_LOCAL,
1600 .ptr = &sDefault.iCreate_force_mode,
1601 .special = NULL,
1602 .enum_list = NULL,
1603 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1606 .label = "security mask",
1607 .type = P_OCTAL,
1608 .p_class = P_LOCAL,
1609 .ptr = &sDefault.iSecurity_mask,
1610 .special = NULL,
1611 .enum_list = NULL,
1612 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1615 .label = "force security mode",
1616 .type = P_OCTAL,
1617 .p_class = P_LOCAL,
1618 .ptr = &sDefault.iSecurity_force_mode,
1619 .special = NULL,
1620 .enum_list = NULL,
1621 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1624 .label = "directory mask",
1625 .type = P_OCTAL,
1626 .p_class = P_LOCAL,
1627 .ptr = &sDefault.iDir_mask,
1628 .special = NULL,
1629 .enum_list = NULL,
1630 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1633 .label = "directory mode",
1634 .type = P_OCTAL,
1635 .p_class = P_LOCAL,
1636 .ptr = &sDefault.iDir_mask,
1637 .special = NULL,
1638 .enum_list = NULL,
1639 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1642 .label = "force directory mode",
1643 .type = P_OCTAL,
1644 .p_class = P_LOCAL,
1645 .ptr = &sDefault.iDir_force_mode,
1646 .special = NULL,
1647 .enum_list = NULL,
1648 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1651 .label = "directory security mask",
1652 .type = P_OCTAL,
1653 .p_class = P_LOCAL,
1654 .ptr = &sDefault.iDir_Security_mask,
1655 .special = NULL,
1656 .enum_list = NULL,
1657 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1660 .label = "force directory security mode",
1661 .type = P_OCTAL,
1662 .p_class = P_LOCAL,
1663 .ptr = &sDefault.iDir_Security_force_mode,
1664 .special = NULL,
1665 .enum_list = NULL,
1666 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1669 .label = "force unknown acl user",
1670 .type = P_BOOL,
1671 .p_class = P_LOCAL,
1672 .ptr = &sDefault.bForceUnknownAclUser,
1673 .special = NULL,
1674 .enum_list = NULL,
1675 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1678 .label = "inherit permissions",
1679 .type = P_BOOL,
1680 .p_class = P_LOCAL,
1681 .ptr = &sDefault.bInheritPerms,
1682 .special = NULL,
1683 .enum_list = NULL,
1684 .flags = FLAG_ADVANCED | FLAG_SHARE,
1687 .label = "inherit acls",
1688 .type = P_BOOL,
1689 .p_class = P_LOCAL,
1690 .ptr = &sDefault.bInheritACLS,
1691 .special = NULL,
1692 .enum_list = NULL,
1693 .flags = FLAG_ADVANCED | FLAG_SHARE,
1696 .label = "inherit owner",
1697 .type = P_BOOL,
1698 .p_class = P_LOCAL,
1699 .ptr = &sDefault.bInheritOwner,
1700 .special = NULL,
1701 .enum_list = NULL,
1702 .flags = FLAG_ADVANCED | FLAG_SHARE,
1705 .label = "guest only",
1706 .type = P_BOOL,
1707 .p_class = P_LOCAL,
1708 .ptr = &sDefault.bGuest_only,
1709 .special = NULL,
1710 .enum_list = NULL,
1711 .flags = FLAG_ADVANCED | FLAG_SHARE,
1714 .label = "only guest",
1715 .type = P_BOOL,
1716 .p_class = P_LOCAL,
1717 .ptr = &sDefault.bGuest_only,
1718 .special = NULL,
1719 .enum_list = NULL,
1720 .flags = FLAG_HIDE,
1723 .label = "administrative share",
1724 .type = P_BOOL,
1725 .p_class = P_LOCAL,
1726 .ptr = &sDefault.bAdministrative_share,
1727 .special = NULL,
1728 .enum_list = NULL,
1729 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1733 .label = "guest ok",
1734 .type = P_BOOL,
1735 .p_class = P_LOCAL,
1736 .ptr = &sDefault.bGuest_ok,
1737 .special = NULL,
1738 .enum_list = NULL,
1739 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1742 .label = "public",
1743 .type = P_BOOL,
1744 .p_class = P_LOCAL,
1745 .ptr = &sDefault.bGuest_ok,
1746 .special = NULL,
1747 .enum_list = NULL,
1748 .flags = FLAG_HIDE,
1751 .label = "only user",
1752 .type = P_BOOL,
1753 .p_class = P_LOCAL,
1754 .ptr = &sDefault.bOnlyUser,
1755 .special = NULL,
1756 .enum_list = NULL,
1757 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1760 .label = "hosts allow",
1761 .type = P_LIST,
1762 .p_class = P_LOCAL,
1763 .ptr = &sDefault.szHostsallow,
1764 .special = NULL,
1765 .enum_list = NULL,
1766 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1769 .label = "allow hosts",
1770 .type = P_LIST,
1771 .p_class = P_LOCAL,
1772 .ptr = &sDefault.szHostsallow,
1773 .special = NULL,
1774 .enum_list = NULL,
1775 .flags = FLAG_HIDE,
1778 .label = "hosts deny",
1779 .type = P_LIST,
1780 .p_class = P_LOCAL,
1781 .ptr = &sDefault.szHostsdeny,
1782 .special = NULL,
1783 .enum_list = NULL,
1784 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1787 .label = "deny hosts",
1788 .type = P_LIST,
1789 .p_class = P_LOCAL,
1790 .ptr = &sDefault.szHostsdeny,
1791 .special = NULL,
1792 .enum_list = NULL,
1793 .flags = FLAG_HIDE,
1796 .label = "preload modules",
1797 .type = P_LIST,
1798 .p_class = P_GLOBAL,
1799 .ptr = &Globals.szPreloadModules,
1800 .special = NULL,
1801 .enum_list = NULL,
1802 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1805 .label = "dedicated keytab file",
1806 .type = P_STRING,
1807 .p_class = P_GLOBAL,
1808 .ptr = &Globals.szDedicatedKeytabFile,
1809 .special = NULL,
1810 .enum_list = NULL,
1811 .flags = FLAG_ADVANCED,
1814 .label = "kerberos method",
1815 .type = P_ENUM,
1816 .p_class = P_GLOBAL,
1817 .ptr = &Globals.iKerberosMethod,
1818 .special = NULL,
1819 .enum_list = enum_kerberos_method,
1820 .flags = FLAG_ADVANCED,
1823 .label = "map untrusted to domain",
1824 .type = P_BOOL,
1825 .p_class = P_GLOBAL,
1826 .ptr = &Globals.bMapUntrustedToDomain,
1827 .special = NULL,
1828 .enum_list = NULL,
1829 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1833 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1836 .label = "log level",
1837 .type = P_STRING,
1838 .p_class = P_GLOBAL,
1839 .ptr = &Globals.szLogLevel,
1840 .special = handle_debug_list,
1841 .enum_list = NULL,
1842 .flags = FLAG_ADVANCED,
1845 .label = "debuglevel",
1846 .type = P_STRING,
1847 .p_class = P_GLOBAL,
1848 .ptr = &Globals.szLogLevel,
1849 .special = handle_debug_list,
1850 .enum_list = NULL,
1851 .flags = FLAG_HIDE,
1854 .label = "syslog",
1855 .type = P_INTEGER,
1856 .p_class = P_GLOBAL,
1857 .ptr = &Globals.syslog,
1858 .special = NULL,
1859 .enum_list = NULL,
1860 .flags = FLAG_ADVANCED,
1863 .label = "syslog only",
1864 .type = P_BOOL,
1865 .p_class = P_GLOBAL,
1866 .ptr = &Globals.bSyslogOnly,
1867 .special = NULL,
1868 .enum_list = NULL,
1869 .flags = FLAG_ADVANCED,
1872 .label = "log file",
1873 .type = P_STRING,
1874 .p_class = P_GLOBAL,
1875 .ptr = &Globals.szLogFile,
1876 .special = NULL,
1877 .enum_list = NULL,
1878 .flags = FLAG_ADVANCED,
1881 .label = "max log size",
1882 .type = P_INTEGER,
1883 .p_class = P_GLOBAL,
1884 .ptr = &Globals.max_log_size,
1885 .special = NULL,
1886 .enum_list = NULL,
1887 .flags = FLAG_ADVANCED,
1890 .label = "debug timestamp",
1891 .type = P_BOOL,
1892 .p_class = P_GLOBAL,
1893 .ptr = &Globals.bTimestampLogs,
1894 .special = NULL,
1895 .enum_list = NULL,
1896 .flags = FLAG_ADVANCED,
1899 .label = "timestamp logs",
1900 .type = P_BOOL,
1901 .p_class = P_GLOBAL,
1902 .ptr = &Globals.bTimestampLogs,
1903 .special = NULL,
1904 .enum_list = NULL,
1905 .flags = FLAG_ADVANCED,
1908 .label = "debug prefix timestamp",
1909 .type = P_BOOL,
1910 .p_class = P_GLOBAL,
1911 .ptr = &Globals.bDebugPrefixTimestamp,
1912 .special = NULL,
1913 .enum_list = NULL,
1914 .flags = FLAG_ADVANCED,
1917 .label = "debug hires timestamp",
1918 .type = P_BOOL,
1919 .p_class = P_GLOBAL,
1920 .ptr = &Globals.bDebugHiresTimestamp,
1921 .special = NULL,
1922 .enum_list = NULL,
1923 .flags = FLAG_ADVANCED,
1926 .label = "debug pid",
1927 .type = P_BOOL,
1928 .p_class = P_GLOBAL,
1929 .ptr = &Globals.bDebugPid,
1930 .special = NULL,
1931 .enum_list = NULL,
1932 .flags = FLAG_ADVANCED,
1935 .label = "debug uid",
1936 .type = P_BOOL,
1937 .p_class = P_GLOBAL,
1938 .ptr = &Globals.bDebugUid,
1939 .special = NULL,
1940 .enum_list = NULL,
1941 .flags = FLAG_ADVANCED,
1944 .label = "debug class",
1945 .type = P_BOOL,
1946 .p_class = P_GLOBAL,
1947 .ptr = &Globals.bDebugClass,
1948 .special = NULL,
1949 .enum_list = NULL,
1950 .flags = FLAG_ADVANCED,
1953 .label = "enable core files",
1954 .type = P_BOOL,
1955 .p_class = P_GLOBAL,
1956 .ptr = &Globals.bEnableCoreFiles,
1957 .special = NULL,
1958 .enum_list = NULL,
1959 .flags = FLAG_ADVANCED,
1962 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1965 .label = "allocation roundup size",
1966 .type = P_INTEGER,
1967 .p_class = P_LOCAL,
1968 .ptr = &sDefault.iallocation_roundup_size,
1969 .special = NULL,
1970 .enum_list = NULL,
1971 .flags = FLAG_ADVANCED,
1974 .label = "aio read size",
1975 .type = P_INTEGER,
1976 .p_class = P_LOCAL,
1977 .ptr = &sDefault.iAioReadSize,
1978 .special = NULL,
1979 .enum_list = NULL,
1980 .flags = FLAG_ADVANCED,
1983 .label = "aio write size",
1984 .type = P_INTEGER,
1985 .p_class = P_LOCAL,
1986 .ptr = &sDefault.iAioWriteSize,
1987 .special = NULL,
1988 .enum_list = NULL,
1989 .flags = FLAG_ADVANCED,
1992 .label = "aio write behind",
1993 .type = P_STRING,
1994 .p_class = P_LOCAL,
1995 .ptr = &sDefault.szAioWriteBehind,
1996 .special = NULL,
1997 .enum_list = NULL,
1998 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2001 .label = "smb ports",
2002 .type = P_STRING,
2003 .p_class = P_GLOBAL,
2004 .ptr = &Globals.smb_ports,
2005 .special = NULL,
2006 .enum_list = NULL,
2007 .flags = FLAG_ADVANCED,
2010 .label = "large readwrite",
2011 .type = P_BOOL,
2012 .p_class = P_GLOBAL,
2013 .ptr = &Globals.bLargeReadwrite,
2014 .special = NULL,
2015 .enum_list = NULL,
2016 .flags = FLAG_ADVANCED,
2019 .label = "max protocol",
2020 .type = P_ENUM,
2021 .p_class = P_GLOBAL,
2022 .ptr = &Globals.maxprotocol,
2023 .special = NULL,
2024 .enum_list = enum_protocol,
2025 .flags = FLAG_ADVANCED,
2028 .label = "protocol",
2029 .type = P_ENUM,
2030 .p_class = P_GLOBAL,
2031 .ptr = &Globals.maxprotocol,
2032 .special = NULL,
2033 .enum_list = enum_protocol,
2034 .flags = FLAG_ADVANCED,
2037 .label = "min protocol",
2038 .type = P_ENUM,
2039 .p_class = P_GLOBAL,
2040 .ptr = &Globals.minprotocol,
2041 .special = NULL,
2042 .enum_list = enum_protocol,
2043 .flags = FLAG_ADVANCED,
2046 .label = "min receivefile size",
2047 .type = P_INTEGER,
2048 .p_class = P_GLOBAL,
2049 .ptr = &Globals.iminreceivefile,
2050 .special = NULL,
2051 .enum_list = NULL,
2052 .flags = FLAG_ADVANCED,
2055 .label = "read raw",
2056 .type = P_BOOL,
2057 .p_class = P_GLOBAL,
2058 .ptr = &Globals.bReadRaw,
2059 .special = NULL,
2060 .enum_list = NULL,
2061 .flags = FLAG_ADVANCED,
2064 .label = "write raw",
2065 .type = P_BOOL,
2066 .p_class = P_GLOBAL,
2067 .ptr = &Globals.bWriteRaw,
2068 .special = NULL,
2069 .enum_list = NULL,
2070 .flags = FLAG_ADVANCED,
2073 .label = "disable netbios",
2074 .type = P_BOOL,
2075 .p_class = P_GLOBAL,
2076 .ptr = &Globals.bDisableNetbios,
2077 .special = NULL,
2078 .enum_list = NULL,
2079 .flags = FLAG_ADVANCED,
2082 .label = "reset on zero vc",
2083 .type = P_BOOL,
2084 .p_class = P_GLOBAL,
2085 .ptr = &Globals.bResetOnZeroVC,
2086 .special = NULL,
2087 .enum_list = NULL,
2088 .flags = FLAG_ADVANCED,
2091 .label = "acl compatibility",
2092 .type = P_ENUM,
2093 .p_class = P_GLOBAL,
2094 .ptr = &Globals.iAclCompat,
2095 .special = NULL,
2096 .enum_list = enum_acl_compat_vals,
2097 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2100 .label = "defer sharing violations",
2101 .type = P_BOOL,
2102 .p_class = P_GLOBAL,
2103 .ptr = &Globals.bDeferSharingViolations,
2104 .special = NULL,
2105 .enum_list = NULL,
2106 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2109 .label = "ea support",
2110 .type = P_BOOL,
2111 .p_class = P_LOCAL,
2112 .ptr = &sDefault.bEASupport,
2113 .special = NULL,
2114 .enum_list = NULL,
2115 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2118 .label = "nt acl support",
2119 .type = P_BOOL,
2120 .p_class = P_LOCAL,
2121 .ptr = &sDefault.bNTAclSupport,
2122 .special = NULL,
2123 .enum_list = NULL,
2124 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2127 .label = "nt pipe support",
2128 .type = P_BOOL,
2129 .p_class = P_GLOBAL,
2130 .ptr = &Globals.bNTPipeSupport,
2131 .special = NULL,
2132 .enum_list = NULL,
2133 .flags = FLAG_ADVANCED,
2136 .label = "nt status support",
2137 .type = P_BOOL,
2138 .p_class = P_GLOBAL,
2139 .ptr = &Globals.bNTStatusSupport,
2140 .special = NULL,
2141 .enum_list = NULL,
2142 .flags = FLAG_ADVANCED,
2145 .label = "profile acls",
2146 .type = P_BOOL,
2147 .p_class = P_LOCAL,
2148 .ptr = &sDefault.bProfileAcls,
2149 .special = NULL,
2150 .enum_list = NULL,
2151 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
2154 .label = "announce version",
2155 .type = P_STRING,
2156 .p_class = P_GLOBAL,
2157 .ptr = &Globals.szAnnounceVersion,
2158 .special = NULL,
2159 .enum_list = NULL,
2160 .flags = FLAG_ADVANCED,
2163 .label = "announce as",
2164 .type = P_ENUM,
2165 .p_class = P_GLOBAL,
2166 .ptr = &Globals.announce_as,
2167 .special = NULL,
2168 .enum_list = enum_announce_as,
2169 .flags = FLAG_ADVANCED,
2172 .label = "map acl inherit",
2173 .type = P_BOOL,
2174 .p_class = P_LOCAL,
2175 .ptr = &sDefault.bMap_acl_inherit,
2176 .special = NULL,
2177 .enum_list = NULL,
2178 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2181 .label = "afs share",
2182 .type = P_BOOL,
2183 .p_class = P_LOCAL,
2184 .ptr = &sDefault.bAfs_Share,
2185 .special = NULL,
2186 .enum_list = NULL,
2187 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2190 .label = "max mux",
2191 .type = P_INTEGER,
2192 .p_class = P_GLOBAL,
2193 .ptr = &Globals.max_mux,
2194 .special = NULL,
2195 .enum_list = NULL,
2196 .flags = FLAG_ADVANCED,
2199 .label = "max xmit",
2200 .type = P_INTEGER,
2201 .p_class = P_GLOBAL,
2202 .ptr = &Globals.max_xmit,
2203 .special = NULL,
2204 .enum_list = NULL,
2205 .flags = FLAG_ADVANCED,
2208 .label = "name resolve order",
2209 .type = P_STRING,
2210 .p_class = P_GLOBAL,
2211 .ptr = &Globals.szNameResolveOrder,
2212 .special = NULL,
2213 .enum_list = NULL,
2214 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2217 .label = "max ttl",
2218 .type = P_INTEGER,
2219 .p_class = P_GLOBAL,
2220 .ptr = &Globals.max_ttl,
2221 .special = NULL,
2222 .enum_list = NULL,
2223 .flags = FLAG_ADVANCED,
2226 .label = "max wins ttl",
2227 .type = P_INTEGER,
2228 .p_class = P_GLOBAL,
2229 .ptr = &Globals.max_wins_ttl,
2230 .special = NULL,
2231 .enum_list = NULL,
2232 .flags = FLAG_ADVANCED,
2235 .label = "min wins ttl",
2236 .type = P_INTEGER,
2237 .p_class = P_GLOBAL,
2238 .ptr = &Globals.min_wins_ttl,
2239 .special = NULL,
2240 .enum_list = NULL,
2241 .flags = FLAG_ADVANCED,
2244 .label = "time server",
2245 .type = P_BOOL,
2246 .p_class = P_GLOBAL,
2247 .ptr = &Globals.bTimeServer,
2248 .special = NULL,
2249 .enum_list = NULL,
2250 .flags = FLAG_ADVANCED,
2253 .label = "unix extensions",
2254 .type = P_BOOL,
2255 .p_class = P_GLOBAL,
2256 .ptr = &Globals.bUnixExtensions,
2257 .special = NULL,
2258 .enum_list = NULL,
2259 .flags = FLAG_ADVANCED,
2262 .label = "use spnego",
2263 .type = P_BOOL,
2264 .p_class = P_GLOBAL,
2265 .ptr = &Globals.bUseSpnego,
2266 .special = NULL,
2267 .enum_list = NULL,
2268 .flags = FLAG_ADVANCED,
2271 .label = "client signing",
2272 .type = P_ENUM,
2273 .p_class = P_GLOBAL,
2274 .ptr = &Globals.client_signing,
2275 .special = NULL,
2276 .enum_list = enum_smb_signing_vals,
2277 .flags = FLAG_ADVANCED,
2280 .label = "server signing",
2281 .type = P_ENUM,
2282 .p_class = P_GLOBAL,
2283 .ptr = &Globals.server_signing,
2284 .special = NULL,
2285 .enum_list = enum_smb_signing_vals,
2286 .flags = FLAG_ADVANCED,
2289 .label = "smb encrypt",
2290 .type = P_ENUM,
2291 .p_class = P_LOCAL,
2292 .ptr = &sDefault.ismb_encrypt,
2293 .special = NULL,
2294 .enum_list = enum_smb_signing_vals,
2295 .flags = FLAG_ADVANCED,
2298 .label = "client use spnego",
2299 .type = P_BOOL,
2300 .p_class = P_GLOBAL,
2301 .ptr = &Globals.bClientUseSpnego,
2302 .special = NULL,
2303 .enum_list = NULL,
2304 .flags = FLAG_ADVANCED,
2307 .label = "client ldap sasl wrapping",
2308 .type = P_ENUM,
2309 .p_class = P_GLOBAL,
2310 .ptr = &Globals.client_ldap_sasl_wrapping,
2311 .special = NULL,
2312 .enum_list = enum_ldap_sasl_wrapping,
2313 .flags = FLAG_ADVANCED,
2316 .label = "enable asu support",
2317 .type = P_BOOL,
2318 .p_class = P_GLOBAL,
2319 .ptr = &Globals.bASUSupport,
2320 .special = NULL,
2321 .enum_list = NULL,
2322 .flags = FLAG_ADVANCED,
2325 .label = "svcctl list",
2326 .type = P_LIST,
2327 .p_class = P_GLOBAL,
2328 .ptr = &Globals.szServicesList,
2329 .special = NULL,
2330 .enum_list = NULL,
2331 .flags = FLAG_ADVANCED,
2334 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
2337 .label = "block size",
2338 .type = P_INTEGER,
2339 .p_class = P_LOCAL,
2340 .ptr = &sDefault.iBlock_size,
2341 .special = NULL,
2342 .enum_list = NULL,
2343 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2346 .label = "deadtime",
2347 .type = P_INTEGER,
2348 .p_class = P_GLOBAL,
2349 .ptr = &Globals.deadtime,
2350 .special = NULL,
2351 .enum_list = NULL,
2352 .flags = FLAG_ADVANCED,
2355 .label = "getwd cache",
2356 .type = P_BOOL,
2357 .p_class = P_GLOBAL,
2358 .ptr = &Globals.getwd_cache,
2359 .special = NULL,
2360 .enum_list = NULL,
2361 .flags = FLAG_ADVANCED,
2364 .label = "keepalive",
2365 .type = P_INTEGER,
2366 .p_class = P_GLOBAL,
2367 .ptr = &Globals.iKeepalive,
2368 .special = NULL,
2369 .enum_list = NULL,
2370 .flags = FLAG_ADVANCED,
2373 .label = "change notify",
2374 .type = P_BOOL,
2375 .p_class = P_LOCAL,
2376 .ptr = &sDefault.bChangeNotify,
2377 .special = NULL,
2378 .enum_list = NULL,
2379 .flags = FLAG_ADVANCED | FLAG_SHARE,
2382 .label = "directory name cache size",
2383 .type = P_INTEGER,
2384 .p_class = P_LOCAL,
2385 .ptr = &sDefault.iDirectoryNameCacheSize,
2386 .special = NULL,
2387 .enum_list = NULL,
2388 .flags = FLAG_ADVANCED | FLAG_SHARE,
2391 .label = "kernel change notify",
2392 .type = P_BOOL,
2393 .p_class = P_LOCAL,
2394 .ptr = &sDefault.bKernelChangeNotify,
2395 .special = NULL,
2396 .enum_list = NULL,
2397 .flags = FLAG_ADVANCED | FLAG_SHARE,
2400 .label = "lpq cache time",
2401 .type = P_INTEGER,
2402 .p_class = P_GLOBAL,
2403 .ptr = &Globals.lpqcachetime,
2404 .special = NULL,
2405 .enum_list = NULL,
2406 .flags = FLAG_ADVANCED,
2409 .label = "max smbd processes",
2410 .type = P_INTEGER,
2411 .p_class = P_GLOBAL,
2412 .ptr = &Globals.iMaxSmbdProcesses,
2413 .special = NULL,
2414 .enum_list = NULL,
2415 .flags = FLAG_ADVANCED,
2418 .label = "max connections",
2419 .type = P_INTEGER,
2420 .p_class = P_LOCAL,
2421 .ptr = &sDefault.iMaxConnections,
2422 .special = NULL,
2423 .enum_list = NULL,
2424 .flags = FLAG_ADVANCED | FLAG_SHARE,
2427 .label = "paranoid server security",
2428 .type = P_BOOL,
2429 .p_class = P_GLOBAL,
2430 .ptr = &Globals.paranoid_server_security,
2431 .special = NULL,
2432 .enum_list = NULL,
2433 .flags = FLAG_ADVANCED,
2436 .label = "max disk size",
2437 .type = P_INTEGER,
2438 .p_class = P_GLOBAL,
2439 .ptr = &Globals.maxdisksize,
2440 .special = NULL,
2441 .enum_list = NULL,
2442 .flags = FLAG_ADVANCED,
2445 .label = "max open files",
2446 .type = P_INTEGER,
2447 .p_class = P_GLOBAL,
2448 .ptr = &Globals.max_open_files,
2449 .special = NULL,
2450 .enum_list = NULL,
2451 .flags = FLAG_ADVANCED,
2454 .label = "min print space",
2455 .type = P_INTEGER,
2456 .p_class = P_LOCAL,
2457 .ptr = &sDefault.iMinPrintSpace,
2458 .special = NULL,
2459 .enum_list = NULL,
2460 .flags = FLAG_ADVANCED | FLAG_PRINT,
2463 .label = "socket options",
2464 .type = P_STRING,
2465 .p_class = P_GLOBAL,
2466 .ptr = &Globals.szSocketOptions,
2467 .special = NULL,
2468 .enum_list = NULL,
2469 .flags = FLAG_ADVANCED,
2472 .label = "strict allocate",
2473 .type = P_BOOL,
2474 .p_class = P_LOCAL,
2475 .ptr = &sDefault.bStrictAllocate,
2476 .special = NULL,
2477 .enum_list = NULL,
2478 .flags = FLAG_ADVANCED | FLAG_SHARE,
2481 .label = "strict sync",
2482 .type = P_BOOL,
2483 .p_class = P_LOCAL,
2484 .ptr = &sDefault.bStrictSync,
2485 .special = NULL,
2486 .enum_list = NULL,
2487 .flags = FLAG_ADVANCED | FLAG_SHARE,
2490 .label = "sync always",
2491 .type = P_BOOL,
2492 .p_class = P_LOCAL,
2493 .ptr = &sDefault.bSyncAlways,
2494 .special = NULL,
2495 .enum_list = NULL,
2496 .flags = FLAG_ADVANCED | FLAG_SHARE,
2499 .label = "use mmap",
2500 .type = P_BOOL,
2501 .p_class = P_GLOBAL,
2502 .ptr = &Globals.bUseMmap,
2503 .special = NULL,
2504 .enum_list = NULL,
2505 .flags = FLAG_ADVANCED,
2508 .label = "use sendfile",
2509 .type = P_BOOL,
2510 .p_class = P_LOCAL,
2511 .ptr = &sDefault.bUseSendfile,
2512 .special = NULL,
2513 .enum_list = NULL,
2514 .flags = FLAG_ADVANCED | FLAG_SHARE,
2517 .label = "hostname lookups",
2518 .type = P_BOOL,
2519 .p_class = P_GLOBAL,
2520 .ptr = &Globals.bHostnameLookups,
2521 .special = NULL,
2522 .enum_list = NULL,
2523 .flags = FLAG_ADVANCED,
2526 .label = "write cache size",
2527 .type = P_INTEGER,
2528 .p_class = P_LOCAL,
2529 .ptr = &sDefault.iWriteCacheSize,
2530 .special = NULL,
2531 .enum_list = NULL,
2532 .flags = FLAG_ADVANCED | FLAG_SHARE,
2535 .label = "name cache timeout",
2536 .type = P_INTEGER,
2537 .p_class = P_GLOBAL,
2538 .ptr = &Globals.name_cache_timeout,
2539 .special = NULL,
2540 .enum_list = NULL,
2541 .flags = FLAG_ADVANCED,
2544 .label = "ctdbd socket",
2545 .type = P_STRING,
2546 .p_class = P_GLOBAL,
2547 .ptr = &Globals.ctdbdSocket,
2548 .special = NULL,
2549 .enum_list = NULL,
2550 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2553 .label = "cluster addresses",
2554 .type = P_LIST,
2555 .p_class = P_GLOBAL,
2556 .ptr = &Globals.szClusterAddresses,
2557 .special = NULL,
2558 .enum_list = NULL,
2559 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2562 .label = "clustering",
2563 .type = P_BOOL,
2564 .p_class = P_GLOBAL,
2565 .ptr = &Globals.clustering,
2566 .special = NULL,
2567 .enum_list = NULL,
2568 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2571 .label = "ctdb timeout",
2572 .type = P_INTEGER,
2573 .p_class = P_GLOBAL,
2574 .ptr = &Globals.ctdb_timeout,
2575 .special = NULL,
2576 .enum_list = NULL,
2577 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2580 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2583 .label = "max reported print jobs",
2584 .type = P_INTEGER,
2585 .p_class = P_LOCAL,
2586 .ptr = &sDefault.iMaxReportedPrintJobs,
2587 .special = NULL,
2588 .enum_list = NULL,
2589 .flags = FLAG_ADVANCED | FLAG_PRINT,
2592 .label = "max print jobs",
2593 .type = P_INTEGER,
2594 .p_class = P_LOCAL,
2595 .ptr = &sDefault.iMaxPrintJobs,
2596 .special = NULL,
2597 .enum_list = NULL,
2598 .flags = FLAG_ADVANCED | FLAG_PRINT,
2601 .label = "load printers",
2602 .type = P_BOOL,
2603 .p_class = P_GLOBAL,
2604 .ptr = &Globals.bLoadPrinters,
2605 .special = NULL,
2606 .enum_list = NULL,
2607 .flags = FLAG_ADVANCED | FLAG_PRINT,
2610 .label = "printcap cache time",
2611 .type = P_INTEGER,
2612 .p_class = P_GLOBAL,
2613 .ptr = &Globals.PrintcapCacheTime,
2614 .special = NULL,
2615 .enum_list = NULL,
2616 .flags = FLAG_ADVANCED | FLAG_PRINT,
2619 .label = "printcap name",
2620 .type = P_STRING,
2621 .p_class = P_GLOBAL,
2622 .ptr = &Globals.szPrintcapname,
2623 .special = NULL,
2624 .enum_list = NULL,
2625 .flags = FLAG_ADVANCED | FLAG_PRINT,
2628 .label = "printcap",
2629 .type = P_STRING,
2630 .p_class = P_GLOBAL,
2631 .ptr = &Globals.szPrintcapname,
2632 .special = NULL,
2633 .enum_list = NULL,
2634 .flags = FLAG_HIDE,
2637 .label = "printable",
2638 .type = P_BOOL,
2639 .p_class = P_LOCAL,
2640 .ptr = &sDefault.bPrint_ok,
2641 .special = NULL,
2642 .enum_list = NULL,
2643 .flags = FLAG_ADVANCED | FLAG_PRINT,
2646 .label = "print ok",
2647 .type = P_BOOL,
2648 .p_class = P_LOCAL,
2649 .ptr = &sDefault.bPrint_ok,
2650 .special = NULL,
2651 .enum_list = NULL,
2652 .flags = FLAG_HIDE,
2655 .label = "printing",
2656 .type = P_ENUM,
2657 .p_class = P_LOCAL,
2658 .ptr = &sDefault.iPrinting,
2659 .special = handle_printing,
2660 .enum_list = enum_printing,
2661 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2664 .label = "cups options",
2665 .type = P_STRING,
2666 .p_class = P_LOCAL,
2667 .ptr = &sDefault.szCupsOptions,
2668 .special = NULL,
2669 .enum_list = NULL,
2670 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2673 .label = "cups server",
2674 .type = P_STRING,
2675 .p_class = P_GLOBAL,
2676 .ptr = &Globals.szCupsServer,
2677 .special = NULL,
2678 .enum_list = NULL,
2679 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2682 .label = "cups encrypt",
2683 .type = P_ENUM,
2684 .p_class = P_GLOBAL,
2685 .ptr = &Globals.CupsEncrypt,
2686 .special = NULL,
2687 .enum_list = enum_bool_auto,
2688 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2692 .label = "cups connection timeout",
2693 .type = P_INTEGER,
2694 .p_class = P_GLOBAL,
2695 .ptr = &Globals.cups_connection_timeout,
2696 .special = NULL,
2697 .enum_list = NULL,
2698 .flags = FLAG_ADVANCED,
2701 .label = "iprint server",
2702 .type = P_STRING,
2703 .p_class = P_GLOBAL,
2704 .ptr = &Globals.szIPrintServer,
2705 .special = NULL,
2706 .enum_list = NULL,
2707 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2710 .label = "print command",
2711 .type = P_STRING,
2712 .p_class = P_LOCAL,
2713 .ptr = &sDefault.szPrintcommand,
2714 .special = NULL,
2715 .enum_list = NULL,
2716 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2719 .label = "disable spoolss",
2720 .type = P_BOOL,
2721 .p_class = P_GLOBAL,
2722 .ptr = &Globals.bDisableSpoolss,
2723 .special = NULL,
2724 .enum_list = NULL,
2725 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2728 .label = "enable spoolss",
2729 .type = P_BOOLREV,
2730 .p_class = P_GLOBAL,
2731 .ptr = &Globals.bDisableSpoolss,
2732 .special = NULL,
2733 .enum_list = NULL,
2734 .flags = FLAG_HIDE,
2737 .label = "lpq command",
2738 .type = P_STRING,
2739 .p_class = P_LOCAL,
2740 .ptr = &sDefault.szLpqcommand,
2741 .special = NULL,
2742 .enum_list = NULL,
2743 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2746 .label = "lprm command",
2747 .type = P_STRING,
2748 .p_class = P_LOCAL,
2749 .ptr = &sDefault.szLprmcommand,
2750 .special = NULL,
2751 .enum_list = NULL,
2752 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2755 .label = "lppause command",
2756 .type = P_STRING,
2757 .p_class = P_LOCAL,
2758 .ptr = &sDefault.szLppausecommand,
2759 .special = NULL,
2760 .enum_list = NULL,
2761 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2764 .label = "lpresume command",
2765 .type = P_STRING,
2766 .p_class = P_LOCAL,
2767 .ptr = &sDefault.szLpresumecommand,
2768 .special = NULL,
2769 .enum_list = NULL,
2770 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2773 .label = "queuepause command",
2774 .type = P_STRING,
2775 .p_class = P_LOCAL,
2776 .ptr = &sDefault.szQueuepausecommand,
2777 .special = NULL,
2778 .enum_list = NULL,
2779 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2782 .label = "queueresume command",
2783 .type = P_STRING,
2784 .p_class = P_LOCAL,
2785 .ptr = &sDefault.szQueueresumecommand,
2786 .special = NULL,
2787 .enum_list = NULL,
2788 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2791 .label = "addport command",
2792 .type = P_STRING,
2793 .p_class = P_GLOBAL,
2794 .ptr = &Globals.szAddPortCommand,
2795 .special = NULL,
2796 .enum_list = NULL,
2797 .flags = FLAG_ADVANCED,
2800 .label = "enumports command",
2801 .type = P_STRING,
2802 .p_class = P_GLOBAL,
2803 .ptr = &Globals.szEnumPortsCommand,
2804 .special = NULL,
2805 .enum_list = NULL,
2806 .flags = FLAG_ADVANCED,
2809 .label = "addprinter command",
2810 .type = P_STRING,
2811 .p_class = P_GLOBAL,
2812 .ptr = &Globals.szAddPrinterCommand,
2813 .special = NULL,
2814 .enum_list = NULL,
2815 .flags = FLAG_ADVANCED,
2818 .label = "deleteprinter command",
2819 .type = P_STRING,
2820 .p_class = P_GLOBAL,
2821 .ptr = &Globals.szDeletePrinterCommand,
2822 .special = NULL,
2823 .enum_list = NULL,
2824 .flags = FLAG_ADVANCED,
2827 .label = "show add printer wizard",
2828 .type = P_BOOL,
2829 .p_class = P_GLOBAL,
2830 .ptr = &Globals.bMsAddPrinterWizard,
2831 .special = NULL,
2832 .enum_list = NULL,
2833 .flags = FLAG_ADVANCED,
2836 .label = "os2 driver map",
2837 .type = P_STRING,
2838 .p_class = P_GLOBAL,
2839 .ptr = &Globals.szOs2DriverMap,
2840 .special = NULL,
2841 .enum_list = NULL,
2842 .flags = FLAG_ADVANCED,
2846 .label = "printer name",
2847 .type = P_STRING,
2848 .p_class = P_LOCAL,
2849 .ptr = &sDefault.szPrintername,
2850 .special = NULL,
2851 .enum_list = NULL,
2852 .flags = FLAG_ADVANCED | FLAG_PRINT,
2855 .label = "printer",
2856 .type = P_STRING,
2857 .p_class = P_LOCAL,
2858 .ptr = &sDefault.szPrintername,
2859 .special = NULL,
2860 .enum_list = NULL,
2861 .flags = FLAG_HIDE,
2864 .label = "use client driver",
2865 .type = P_BOOL,
2866 .p_class = P_LOCAL,
2867 .ptr = &sDefault.bUseClientDriver,
2868 .special = NULL,
2869 .enum_list = NULL,
2870 .flags = FLAG_ADVANCED | FLAG_PRINT,
2873 .label = "default devmode",
2874 .type = P_BOOL,
2875 .p_class = P_LOCAL,
2876 .ptr = &sDefault.bDefaultDevmode,
2877 .special = NULL,
2878 .enum_list = NULL,
2879 .flags = FLAG_ADVANCED | FLAG_PRINT,
2882 .label = "force printername",
2883 .type = P_BOOL,
2884 .p_class = P_LOCAL,
2885 .ptr = &sDefault.bForcePrintername,
2886 .special = NULL,
2887 .enum_list = NULL,
2888 .flags = FLAG_ADVANCED | FLAG_PRINT,
2891 .label = "printjob username",
2892 .type = P_STRING,
2893 .p_class = P_LOCAL,
2894 .ptr = &sDefault.szPrintjobUsername,
2895 .special = NULL,
2896 .enum_list = NULL,
2897 .flags = FLAG_ADVANCED | FLAG_PRINT,
2900 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2903 .label = "mangling method",
2904 .type = P_STRING,
2905 .p_class = P_GLOBAL,
2906 .ptr = &Globals.szManglingMethod,
2907 .special = NULL,
2908 .enum_list = NULL,
2909 .flags = FLAG_ADVANCED,
2912 .label = "mangle prefix",
2913 .type = P_INTEGER,
2914 .p_class = P_GLOBAL,
2915 .ptr = &Globals.mangle_prefix,
2916 .special = NULL,
2917 .enum_list = NULL,
2918 .flags = FLAG_ADVANCED,
2922 .label = "default case",
2923 .type = P_ENUM,
2924 .p_class = P_LOCAL,
2925 .ptr = &sDefault.iDefaultCase,
2926 .special = NULL,
2927 .enum_list = enum_case,
2928 .flags = FLAG_ADVANCED | FLAG_SHARE,
2931 .label = "case sensitive",
2932 .type = P_ENUM,
2933 .p_class = P_LOCAL,
2934 .ptr = &sDefault.iCaseSensitive,
2935 .special = NULL,
2936 .enum_list = enum_bool_auto,
2937 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2940 .label = "casesignames",
2941 .type = P_ENUM,
2942 .p_class = P_LOCAL,
2943 .ptr = &sDefault.iCaseSensitive,
2944 .special = NULL,
2945 .enum_list = enum_bool_auto,
2946 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2949 .label = "preserve case",
2950 .type = P_BOOL,
2951 .p_class = P_LOCAL,
2952 .ptr = &sDefault.bCasePreserve,
2953 .special = NULL,
2954 .enum_list = NULL,
2955 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2958 .label = "short preserve case",
2959 .type = P_BOOL,
2960 .p_class = P_LOCAL,
2961 .ptr = &sDefault.bShortCasePreserve,
2962 .special = NULL,
2963 .enum_list = NULL,
2964 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2967 .label = "mangling char",
2968 .type = P_CHAR,
2969 .p_class = P_LOCAL,
2970 .ptr = &sDefault.magic_char,
2971 .special = NULL,
2972 .enum_list = NULL,
2973 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2976 .label = "hide dot files",
2977 .type = P_BOOL,
2978 .p_class = P_LOCAL,
2979 .ptr = &sDefault.bHideDotFiles,
2980 .special = NULL,
2981 .enum_list = NULL,
2982 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2985 .label = "hide special files",
2986 .type = P_BOOL,
2987 .p_class = P_LOCAL,
2988 .ptr = &sDefault.bHideSpecialFiles,
2989 .special = NULL,
2990 .enum_list = NULL,
2991 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2994 .label = "hide unreadable",
2995 .type = P_BOOL,
2996 .p_class = P_LOCAL,
2997 .ptr = &sDefault.bHideUnReadable,
2998 .special = NULL,
2999 .enum_list = NULL,
3000 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3003 .label = "hide unwriteable files",
3004 .type = P_BOOL,
3005 .p_class = P_LOCAL,
3006 .ptr = &sDefault.bHideUnWriteableFiles,
3007 .special = NULL,
3008 .enum_list = NULL,
3009 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3012 .label = "delete veto files",
3013 .type = P_BOOL,
3014 .p_class = P_LOCAL,
3015 .ptr = &sDefault.bDeleteVetoFiles,
3016 .special = NULL,
3017 .enum_list = NULL,
3018 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3021 .label = "veto files",
3022 .type = P_STRING,
3023 .p_class = P_LOCAL,
3024 .ptr = &sDefault.szVetoFiles,
3025 .special = NULL,
3026 .enum_list = NULL,
3027 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3030 .label = "hide files",
3031 .type = P_STRING,
3032 .p_class = P_LOCAL,
3033 .ptr = &sDefault.szHideFiles,
3034 .special = NULL,
3035 .enum_list = NULL,
3036 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3039 .label = "veto oplock files",
3040 .type = P_STRING,
3041 .p_class = P_LOCAL,
3042 .ptr = &sDefault.szVetoOplockFiles,
3043 .special = NULL,
3044 .enum_list = NULL,
3045 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3048 .label = "map archive",
3049 .type = P_BOOL,
3050 .p_class = P_LOCAL,
3051 .ptr = &sDefault.bMap_archive,
3052 .special = NULL,
3053 .enum_list = NULL,
3054 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3057 .label = "map hidden",
3058 .type = P_BOOL,
3059 .p_class = P_LOCAL,
3060 .ptr = &sDefault.bMap_hidden,
3061 .special = NULL,
3062 .enum_list = NULL,
3063 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3066 .label = "map system",
3067 .type = P_BOOL,
3068 .p_class = P_LOCAL,
3069 .ptr = &sDefault.bMap_system,
3070 .special = NULL,
3071 .enum_list = NULL,
3072 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3075 .label = "map readonly",
3076 .type = P_ENUM,
3077 .p_class = P_LOCAL,
3078 .ptr = &sDefault.iMap_readonly,
3079 .special = NULL,
3080 .enum_list = enum_map_readonly,
3081 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3084 .label = "mangled names",
3085 .type = P_BOOL,
3086 .p_class = P_LOCAL,
3087 .ptr = &sDefault.bMangledNames,
3088 .special = NULL,
3089 .enum_list = NULL,
3090 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3093 .label = "max stat cache size",
3094 .type = P_INTEGER,
3095 .p_class = P_GLOBAL,
3096 .ptr = &Globals.iMaxStatCacheSize,
3097 .special = NULL,
3098 .enum_list = NULL,
3099 .flags = FLAG_ADVANCED,
3102 .label = "stat cache",
3103 .type = P_BOOL,
3104 .p_class = P_GLOBAL,
3105 .ptr = &Globals.bStatCache,
3106 .special = NULL,
3107 .enum_list = NULL,
3108 .flags = FLAG_ADVANCED,
3111 .label = "store dos attributes",
3112 .type = P_BOOL,
3113 .p_class = P_LOCAL,
3114 .ptr = &sDefault.bStoreDosAttributes,
3115 .special = NULL,
3116 .enum_list = NULL,
3117 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3120 .label = "dmapi support",
3121 .type = P_BOOL,
3122 .p_class = P_LOCAL,
3123 .ptr = &sDefault.bDmapiSupport,
3124 .special = NULL,
3125 .enum_list = NULL,
3126 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3130 {N_("Domain Options"), P_SEP, P_SEPARATOR},
3133 .label = "machine password timeout",
3134 .type = P_INTEGER,
3135 .p_class = P_GLOBAL,
3136 .ptr = &Globals.machine_password_timeout,
3137 .special = NULL,
3138 .enum_list = NULL,
3139 .flags = FLAG_ADVANCED | FLAG_WIZARD,
3142 {N_("Logon Options"), P_SEP, P_SEPARATOR},
3145 .label = "add user script",
3146 .type = P_STRING,
3147 .p_class = P_GLOBAL,
3148 .ptr = &Globals.szAddUserScript,
3149 .special = NULL,
3150 .enum_list = NULL,
3151 .flags = FLAG_ADVANCED,
3154 .label = "rename user script",
3155 .type = P_STRING,
3156 .p_class = P_GLOBAL,
3157 .ptr = &Globals.szRenameUserScript,
3158 .special = NULL,
3159 .enum_list = NULL,
3160 .flags = FLAG_ADVANCED,
3163 .label = "delete user script",
3164 .type = P_STRING,
3165 .p_class = P_GLOBAL,
3166 .ptr = &Globals.szDelUserScript,
3167 .special = NULL,
3168 .enum_list = NULL,
3169 .flags = FLAG_ADVANCED,
3172 .label = "add group script",
3173 .type = P_STRING,
3174 .p_class = P_GLOBAL,
3175 .ptr = &Globals.szAddGroupScript,
3176 .special = NULL,
3177 .enum_list = NULL,
3178 .flags = FLAG_ADVANCED,
3181 .label = "delete group script",
3182 .type = P_STRING,
3183 .p_class = P_GLOBAL,
3184 .ptr = &Globals.szDelGroupScript,
3185 .special = NULL,
3186 .enum_list = NULL,
3187 .flags = FLAG_ADVANCED,
3190 .label = "add user to group script",
3191 .type = P_STRING,
3192 .p_class = P_GLOBAL,
3193 .ptr = &Globals.szAddUserToGroupScript,
3194 .special = NULL,
3195 .enum_list = NULL,
3196 .flags = FLAG_ADVANCED,
3199 .label = "delete user from group script",
3200 .type = P_STRING,
3201 .p_class = P_GLOBAL,
3202 .ptr = &Globals.szDelUserFromGroupScript,
3203 .special = NULL,
3204 .enum_list = NULL,
3205 .flags = FLAG_ADVANCED,
3208 .label = "set primary group script",
3209 .type = P_STRING,
3210 .p_class = P_GLOBAL,
3211 .ptr = &Globals.szSetPrimaryGroupScript,
3212 .special = NULL,
3213 .enum_list = NULL,
3214 .flags = FLAG_ADVANCED,
3217 .label = "add machine script",
3218 .type = P_STRING,
3219 .p_class = P_GLOBAL,
3220 .ptr = &Globals.szAddMachineScript,
3221 .special = NULL,
3222 .enum_list = NULL,
3223 .flags = FLAG_ADVANCED,
3226 .label = "shutdown script",
3227 .type = P_STRING,
3228 .p_class = P_GLOBAL,
3229 .ptr = &Globals.szShutdownScript,
3230 .special = NULL,
3231 .enum_list = NULL,
3232 .flags = FLAG_ADVANCED,
3235 .label = "abort shutdown script",
3236 .type = P_STRING,
3237 .p_class = P_GLOBAL,
3238 .ptr = &Globals.szAbortShutdownScript,
3239 .special = NULL,
3240 .enum_list = NULL,
3241 .flags = FLAG_ADVANCED,
3244 .label = "username map script",
3245 .type = P_STRING,
3246 .p_class = P_GLOBAL,
3247 .ptr = &Globals.szUsernameMapScript,
3248 .special = NULL,
3249 .enum_list = NULL,
3250 .flags = FLAG_ADVANCED,
3253 .label = "logon script",
3254 .type = P_STRING,
3255 .p_class = P_GLOBAL,
3256 .ptr = &Globals.szLogonScript,
3257 .special = NULL,
3258 .enum_list = NULL,
3259 .flags = FLAG_ADVANCED,
3262 .label = "logon path",
3263 .type = P_STRING,
3264 .p_class = P_GLOBAL,
3265 .ptr = &Globals.szLogonPath,
3266 .special = NULL,
3267 .enum_list = NULL,
3268 .flags = FLAG_ADVANCED,
3271 .label = "logon drive",
3272 .type = P_STRING,
3273 .p_class = P_GLOBAL,
3274 .ptr = &Globals.szLogonDrive,
3275 .special = NULL,
3276 .enum_list = NULL,
3277 .flags = FLAG_ADVANCED,
3280 .label = "logon home",
3281 .type = P_STRING,
3282 .p_class = P_GLOBAL,
3283 .ptr = &Globals.szLogonHome,
3284 .special = NULL,
3285 .enum_list = NULL,
3286 .flags = FLAG_ADVANCED,
3289 .label = "domain logons",
3290 .type = P_BOOL,
3291 .p_class = P_GLOBAL,
3292 .ptr = &Globals.bDomainLogons,
3293 .special = NULL,
3294 .enum_list = NULL,
3295 .flags = FLAG_ADVANCED,
3299 .label = "init logon delayed hosts",
3300 .type = P_LIST,
3301 .p_class = P_GLOBAL,
3302 .ptr = &Globals.szInitLogonDelayedHosts,
3303 .special = NULL,
3304 .enum_list = NULL,
3305 .flags = FLAG_ADVANCED,
3309 .label = "init logon delay",
3310 .type = P_INTEGER,
3311 .p_class = P_GLOBAL,
3312 .ptr = &Globals.InitLogonDelay,
3313 .special = NULL,
3314 .enum_list = NULL,
3315 .flags = FLAG_ADVANCED,
3319 {N_("Browse Options"), P_SEP, P_SEPARATOR},
3322 .label = "os level",
3323 .type = P_INTEGER,
3324 .p_class = P_GLOBAL,
3325 .ptr = &Globals.os_level,
3326 .special = NULL,
3327 .enum_list = NULL,
3328 .flags = FLAG_BASIC | FLAG_ADVANCED,
3331 .label = "lm announce",
3332 .type = P_ENUM,
3333 .p_class = P_GLOBAL,
3334 .ptr = &Globals.lm_announce,
3335 .special = NULL,
3336 .enum_list = enum_bool_auto,
3337 .flags = FLAG_ADVANCED,
3340 .label = "lm interval",
3341 .type = P_INTEGER,
3342 .p_class = P_GLOBAL,
3343 .ptr = &Globals.lm_interval,
3344 .special = NULL,
3345 .enum_list = NULL,
3346 .flags = FLAG_ADVANCED,
3349 .label = "preferred master",
3350 .type = P_ENUM,
3351 .p_class = P_GLOBAL,
3352 .ptr = &Globals.iPreferredMaster,
3353 .special = NULL,
3354 .enum_list = enum_bool_auto,
3355 .flags = FLAG_BASIC | FLAG_ADVANCED,
3358 .label = "prefered master",
3359 .type = P_ENUM,
3360 .p_class = P_GLOBAL,
3361 .ptr = &Globals.iPreferredMaster,
3362 .special = NULL,
3363 .enum_list = enum_bool_auto,
3364 .flags = FLAG_HIDE,
3367 .label = "local master",
3368 .type = P_BOOL,
3369 .p_class = P_GLOBAL,
3370 .ptr = &Globals.bLocalMaster,
3371 .special = NULL,
3372 .enum_list = NULL,
3373 .flags = FLAG_BASIC | FLAG_ADVANCED,
3376 .label = "domain master",
3377 .type = P_ENUM,
3378 .p_class = P_GLOBAL,
3379 .ptr = &Globals.iDomainMaster,
3380 .special = NULL,
3381 .enum_list = enum_bool_auto,
3382 .flags = FLAG_BASIC | FLAG_ADVANCED,
3385 .label = "browse list",
3386 .type = P_BOOL,
3387 .p_class = P_GLOBAL,
3388 .ptr = &Globals.bBrowseList,
3389 .special = NULL,
3390 .enum_list = NULL,
3391 .flags = FLAG_ADVANCED,
3394 .label = "browseable",
3395 .type = P_BOOL,
3396 .p_class = P_LOCAL,
3397 .ptr = &sDefault.bBrowseable,
3398 .special = NULL,
3399 .enum_list = NULL,
3400 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3403 .label = "browsable",
3404 .type = P_BOOL,
3405 .p_class = P_LOCAL,
3406 .ptr = &sDefault.bBrowseable,
3407 .special = NULL,
3408 .enum_list = NULL,
3409 .flags = FLAG_HIDE,
3412 .label = "access based share enum",
3413 .type = P_BOOL,
3414 .p_class = P_LOCAL,
3415 .ptr = &sDefault.bAccessBasedShareEnum,
3416 .special = NULL,
3417 .enum_list = NULL,
3418 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3421 .label = "enhanced browsing",
3422 .type = P_BOOL,
3423 .p_class = P_GLOBAL,
3424 .ptr = &Globals.enhanced_browsing,
3425 .special = NULL,
3426 .enum_list = NULL,
3427 .flags = FLAG_ADVANCED,
3430 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3433 .label = "dns proxy",
3434 .type = P_BOOL,
3435 .p_class = P_GLOBAL,
3436 .ptr = &Globals.bDNSproxy,
3437 .special = NULL,
3438 .enum_list = NULL,
3439 .flags = FLAG_ADVANCED,
3442 .label = "wins proxy",
3443 .type = P_BOOL,
3444 .p_class = P_GLOBAL,
3445 .ptr = &Globals.bWINSproxy,
3446 .special = NULL,
3447 .enum_list = NULL,
3448 .flags = FLAG_ADVANCED,
3451 .label = "wins server",
3452 .type = P_LIST,
3453 .p_class = P_GLOBAL,
3454 .ptr = &Globals.szWINSservers,
3455 .special = NULL,
3456 .enum_list = NULL,
3457 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3460 .label = "wins support",
3461 .type = P_BOOL,
3462 .p_class = P_GLOBAL,
3463 .ptr = &Globals.bWINSsupport,
3464 .special = NULL,
3465 .enum_list = NULL,
3466 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3469 .label = "wins hook",
3470 .type = P_STRING,
3471 .p_class = P_GLOBAL,
3472 .ptr = &Globals.szWINSHook,
3473 .special = NULL,
3474 .enum_list = NULL,
3475 .flags = FLAG_ADVANCED,
3478 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3481 .label = "blocking locks",
3482 .type = P_BOOL,
3483 .p_class = P_LOCAL,
3484 .ptr = &sDefault.bBlockingLocks,
3485 .special = NULL,
3486 .enum_list = NULL,
3487 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3490 .label = "csc policy",
3491 .type = P_ENUM,
3492 .p_class = P_LOCAL,
3493 .ptr = &sDefault.iCSCPolicy,
3494 .special = NULL,
3495 .enum_list = enum_csc_policy,
3496 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3499 .label = "fake oplocks",
3500 .type = P_BOOL,
3501 .p_class = P_LOCAL,
3502 .ptr = &sDefault.bFakeOplocks,
3503 .special = NULL,
3504 .enum_list = NULL,
3505 .flags = FLAG_ADVANCED | FLAG_SHARE,
3508 .label = "kernel oplocks",
3509 .type = P_BOOL,
3510 .p_class = P_GLOBAL,
3511 .ptr = &Globals.bKernelOplocks,
3512 .special = NULL,
3513 .enum_list = NULL,
3514 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3517 .label = "locking",
3518 .type = P_BOOL,
3519 .p_class = P_LOCAL,
3520 .ptr = &sDefault.bLocking,
3521 .special = NULL,
3522 .enum_list = NULL,
3523 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3526 .label = "lock spin time",
3527 .type = P_INTEGER,
3528 .p_class = P_GLOBAL,
3529 .ptr = &Globals.iLockSpinTime,
3530 .special = NULL,
3531 .enum_list = NULL,
3532 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3535 .label = "oplocks",
3536 .type = P_BOOL,
3537 .p_class = P_LOCAL,
3538 .ptr = &sDefault.bOpLocks,
3539 .special = NULL,
3540 .enum_list = NULL,
3541 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3544 .label = "level2 oplocks",
3545 .type = P_BOOL,
3546 .p_class = P_LOCAL,
3547 .ptr = &sDefault.bLevel2OpLocks,
3548 .special = NULL,
3549 .enum_list = NULL,
3550 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3553 .label = "oplock break wait time",
3554 .type = P_INTEGER,
3555 .p_class = P_GLOBAL,
3556 .ptr = &Globals.oplock_break_wait_time,
3557 .special = NULL,
3558 .enum_list = NULL,
3559 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3562 .label = "oplock contention limit",
3563 .type = P_INTEGER,
3564 .p_class = P_LOCAL,
3565 .ptr = &sDefault.iOplockContentionLimit,
3566 .special = NULL,
3567 .enum_list = NULL,
3568 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3571 .label = "posix locking",
3572 .type = P_BOOL,
3573 .p_class = P_LOCAL,
3574 .ptr = &sDefault.bPosixLocking,
3575 .special = NULL,
3576 .enum_list = NULL,
3577 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3580 .label = "strict locking",
3581 .type = P_ENUM,
3582 .p_class = P_LOCAL,
3583 .ptr = &sDefault.iStrictLocking,
3584 .special = NULL,
3585 .enum_list = enum_bool_auto,
3586 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3589 .label = "share modes",
3590 .type = P_BOOL,
3591 .p_class = P_LOCAL,
3592 .ptr = &sDefault.bShareModes,
3593 .special = NULL,
3594 .enum_list = NULL,
3595 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3598 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3601 .label = "ldap admin dn",
3602 .type = P_STRING,
3603 .p_class = P_GLOBAL,
3604 .ptr = &Globals.szLdapAdminDn,
3605 .special = NULL,
3606 .enum_list = NULL,
3607 .flags = FLAG_ADVANCED,
3610 .label = "ldap delete dn",
3611 .type = P_BOOL,
3612 .p_class = P_GLOBAL,
3613 .ptr = &Globals.ldap_delete_dn,
3614 .special = NULL,
3615 .enum_list = NULL,
3616 .flags = FLAG_ADVANCED,
3619 .label = "ldap group suffix",
3620 .type = P_STRING,
3621 .p_class = P_GLOBAL,
3622 .ptr = &Globals.szLdapGroupSuffix,
3623 .special = NULL,
3624 .enum_list = NULL,
3625 .flags = FLAG_ADVANCED,
3628 .label = "ldap idmap suffix",
3629 .type = P_STRING,
3630 .p_class = P_GLOBAL,
3631 .ptr = &Globals.szLdapIdmapSuffix,
3632 .special = NULL,
3633 .enum_list = NULL,
3634 .flags = FLAG_ADVANCED,
3637 .label = "ldap machine suffix",
3638 .type = P_STRING,
3639 .p_class = P_GLOBAL,
3640 .ptr = &Globals.szLdapMachineSuffix,
3641 .special = NULL,
3642 .enum_list = NULL,
3643 .flags = FLAG_ADVANCED,
3646 .label = "ldap passwd sync",
3647 .type = P_ENUM,
3648 .p_class = P_GLOBAL,
3649 .ptr = &Globals.ldap_passwd_sync,
3650 .special = NULL,
3651 .enum_list = enum_ldap_passwd_sync,
3652 .flags = FLAG_ADVANCED,
3655 .label = "ldap password sync",
3656 .type = P_ENUM,
3657 .p_class = P_GLOBAL,
3658 .ptr = &Globals.ldap_passwd_sync,
3659 .special = NULL,
3660 .enum_list = enum_ldap_passwd_sync,
3661 .flags = FLAG_HIDE,
3664 .label = "ldap replication sleep",
3665 .type = P_INTEGER,
3666 .p_class = P_GLOBAL,
3667 .ptr = &Globals.ldap_replication_sleep,
3668 .special = NULL,
3669 .enum_list = NULL,
3670 .flags = FLAG_ADVANCED,
3673 .label = "ldap suffix",
3674 .type = P_STRING,
3675 .p_class = P_GLOBAL,
3676 .ptr = &Globals.szLdapSuffix,
3677 .special = NULL,
3678 .enum_list = NULL,
3679 .flags = FLAG_ADVANCED,
3682 .label = "ldap ssl",
3683 .type = P_ENUM,
3684 .p_class = P_GLOBAL,
3685 .ptr = &Globals.ldap_ssl,
3686 .special = NULL,
3687 .enum_list = enum_ldap_ssl,
3688 .flags = FLAG_ADVANCED,
3691 .label = "ldap ssl ads",
3692 .type = P_BOOL,
3693 .p_class = P_GLOBAL,
3694 .ptr = &Globals.ldap_ssl_ads,
3695 .special = NULL,
3696 .enum_list = NULL,
3697 .flags = FLAG_ADVANCED,
3700 .label = "ldap deref",
3701 .type = P_ENUM,
3702 .p_class = P_GLOBAL,
3703 .ptr = &Globals.ldap_deref,
3704 .special = NULL,
3705 .enum_list = enum_ldap_deref,
3706 .flags = FLAG_ADVANCED,
3709 .label = "ldap follow referral",
3710 .type = P_ENUM,
3711 .p_class = P_GLOBAL,
3712 .ptr = &Globals.ldap_follow_referral,
3713 .special = NULL,
3714 .enum_list = enum_bool_auto,
3715 .flags = FLAG_ADVANCED,
3718 .label = "ldap timeout",
3719 .type = P_INTEGER,
3720 .p_class = P_GLOBAL,
3721 .ptr = &Globals.ldap_timeout,
3722 .special = NULL,
3723 .enum_list = NULL,
3724 .flags = FLAG_ADVANCED,
3727 .label = "ldap connection timeout",
3728 .type = P_INTEGER,
3729 .p_class = P_GLOBAL,
3730 .ptr = &Globals.ldap_connection_timeout,
3731 .special = NULL,
3732 .enum_list = NULL,
3733 .flags = FLAG_ADVANCED,
3736 .label = "ldap page size",
3737 .type = P_INTEGER,
3738 .p_class = P_GLOBAL,
3739 .ptr = &Globals.ldap_page_size,
3740 .special = NULL,
3741 .enum_list = NULL,
3742 .flags = FLAG_ADVANCED,
3745 .label = "ldap user suffix",
3746 .type = P_STRING,
3747 .p_class = P_GLOBAL,
3748 .ptr = &Globals.szLdapUserSuffix,
3749 .special = NULL,
3750 .enum_list = NULL,
3751 .flags = FLAG_ADVANCED,
3754 .label = "ldap debug level",
3755 .type = P_INTEGER,
3756 .p_class = P_GLOBAL,
3757 .ptr = &Globals.ldap_debug_level,
3758 .special = handle_ldap_debug_level,
3759 .enum_list = NULL,
3760 .flags = FLAG_ADVANCED,
3763 .label = "ldap debug threshold",
3764 .type = P_INTEGER,
3765 .p_class = P_GLOBAL,
3766 .ptr = &Globals.ldap_debug_threshold,
3767 .special = NULL,
3768 .enum_list = NULL,
3769 .flags = FLAG_ADVANCED,
3772 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3775 .label = "eventlog list",
3776 .type = P_LIST,
3777 .p_class = P_GLOBAL,
3778 .ptr = &Globals.szEventLogs,
3779 .special = NULL,
3780 .enum_list = NULL,
3781 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3784 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3787 .label = "add share command",
3788 .type = P_STRING,
3789 .p_class = P_GLOBAL,
3790 .ptr = &Globals.szAddShareCommand,
3791 .special = NULL,
3792 .enum_list = NULL,
3793 .flags = FLAG_ADVANCED,
3796 .label = "change share command",
3797 .type = P_STRING,
3798 .p_class = P_GLOBAL,
3799 .ptr = &Globals.szChangeShareCommand,
3800 .special = NULL,
3801 .enum_list = NULL,
3802 .flags = FLAG_ADVANCED,
3805 .label = "delete share command",
3806 .type = P_STRING,
3807 .p_class = P_GLOBAL,
3808 .ptr = &Globals.szDeleteShareCommand,
3809 .special = NULL,
3810 .enum_list = NULL,
3811 .flags = FLAG_ADVANCED,
3814 .label = "config file",
3815 .type = P_STRING,
3816 .p_class = P_GLOBAL,
3817 .ptr = &Globals.szConfigFile,
3818 .special = NULL,
3819 .enum_list = NULL,
3820 .flags = FLAG_HIDE|FLAG_META,
3823 .label = "preload",
3824 .type = P_STRING,
3825 .p_class = P_GLOBAL,
3826 .ptr = &Globals.szAutoServices,
3827 .special = NULL,
3828 .enum_list = NULL,
3829 .flags = FLAG_ADVANCED,
3832 .label = "auto services",
3833 .type = P_STRING,
3834 .p_class = P_GLOBAL,
3835 .ptr = &Globals.szAutoServices,
3836 .special = NULL,
3837 .enum_list = NULL,
3838 .flags = FLAG_ADVANCED,
3841 .label = "lock directory",
3842 .type = P_STRING,
3843 .p_class = P_GLOBAL,
3844 .ptr = &Globals.szLockDir,
3845 .special = NULL,
3846 .enum_list = NULL,
3847 .flags = FLAG_ADVANCED,
3850 .label = "lock dir",
3851 .type = P_STRING,
3852 .p_class = P_GLOBAL,
3853 .ptr = &Globals.szLockDir,
3854 .special = NULL,
3855 .enum_list = NULL,
3856 .flags = FLAG_HIDE,
3859 .label = "state directory",
3860 .type = P_STRING,
3861 .p_class = P_GLOBAL,
3862 .ptr = &Globals.szStateDir,
3863 .special = NULL,
3864 .enum_list = NULL,
3865 .flags = FLAG_ADVANCED,
3868 .label = "cache directory",
3869 .type = P_STRING,
3870 .p_class = P_GLOBAL,
3871 .ptr = &Globals.szCacheDir,
3872 .special = NULL,
3873 .enum_list = NULL,
3874 .flags = FLAG_ADVANCED,
3877 .label = "pid directory",
3878 .type = P_STRING,
3879 .p_class = P_GLOBAL,
3880 .ptr = &Globals.szPidDir,
3881 .special = NULL,
3882 .enum_list = NULL,
3883 .flags = FLAG_ADVANCED,
3885 #ifdef WITH_UTMP
3887 .label = "utmp directory",
3888 .type = P_STRING,
3889 .p_class = P_GLOBAL,
3890 .ptr = &Globals.szUtmpDir,
3891 .special = NULL,
3892 .enum_list = NULL,
3893 .flags = FLAG_ADVANCED,
3896 .label = "wtmp directory",
3897 .type = P_STRING,
3898 .p_class = P_GLOBAL,
3899 .ptr = &Globals.szWtmpDir,
3900 .special = NULL,
3901 .enum_list = NULL,
3902 .flags = FLAG_ADVANCED,
3905 .label = "utmp",
3906 .type = P_BOOL,
3907 .p_class = P_GLOBAL,
3908 .ptr = &Globals.bUtmp,
3909 .special = NULL,
3910 .enum_list = NULL,
3911 .flags = FLAG_ADVANCED,
3913 #endif
3915 .label = "default service",
3916 .type = P_STRING,
3917 .p_class = P_GLOBAL,
3918 .ptr = &Globals.szDefaultService,
3919 .special = NULL,
3920 .enum_list = NULL,
3921 .flags = FLAG_ADVANCED,
3924 .label = "default",
3925 .type = P_STRING,
3926 .p_class = P_GLOBAL,
3927 .ptr = &Globals.szDefaultService,
3928 .special = NULL,
3929 .enum_list = NULL,
3930 .flags = FLAG_ADVANCED,
3933 .label = "message command",
3934 .type = P_STRING,
3935 .p_class = P_GLOBAL,
3936 .ptr = &Globals.szMsgCommand,
3937 .special = NULL,
3938 .enum_list = NULL,
3939 .flags = FLAG_ADVANCED,
3942 .label = "dfree cache time",
3943 .type = P_INTEGER,
3944 .p_class = P_LOCAL,
3945 .ptr = &sDefault.iDfreeCacheTime,
3946 .special = NULL,
3947 .enum_list = NULL,
3948 .flags = FLAG_ADVANCED,
3951 .label = "dfree command",
3952 .type = P_STRING,
3953 .p_class = P_LOCAL,
3954 .ptr = &sDefault.szDfree,
3955 .special = NULL,
3956 .enum_list = NULL,
3957 .flags = FLAG_ADVANCED,
3960 .label = "get quota command",
3961 .type = P_STRING,
3962 .p_class = P_GLOBAL,
3963 .ptr = &Globals.szGetQuota,
3964 .special = NULL,
3965 .enum_list = NULL,
3966 .flags = FLAG_ADVANCED,
3969 .label = "set quota command",
3970 .type = P_STRING,
3971 .p_class = P_GLOBAL,
3972 .ptr = &Globals.szSetQuota,
3973 .special = NULL,
3974 .enum_list = NULL,
3975 .flags = FLAG_ADVANCED,
3978 .label = "remote announce",
3979 .type = P_STRING,
3980 .p_class = P_GLOBAL,
3981 .ptr = &Globals.szRemoteAnnounce,
3982 .special = NULL,
3983 .enum_list = NULL,
3984 .flags = FLAG_ADVANCED,
3987 .label = "remote browse sync",
3988 .type = P_STRING,
3989 .p_class = P_GLOBAL,
3990 .ptr = &Globals.szRemoteBrowseSync,
3991 .special = NULL,
3992 .enum_list = NULL,
3993 .flags = FLAG_ADVANCED,
3996 .label = "socket address",
3997 .type = P_STRING,
3998 .p_class = P_GLOBAL,
3999 .ptr = &Globals.szSocketAddress,
4000 .special = NULL,
4001 .enum_list = NULL,
4002 .flags = FLAG_ADVANCED,
4005 .label = "nmbd bind explicit broadcast",
4006 .type = P_BOOL,
4007 .p_class = P_GLOBAL,
4008 .ptr = &Globals.bNmbdBindExplicitBroadcast,
4009 .special = NULL,
4010 .enum_list = NULL,
4011 .flags = FLAG_ADVANCED,
4014 .label = "homedir map",
4015 .type = P_STRING,
4016 .p_class = P_GLOBAL,
4017 .ptr = &Globals.szNISHomeMapName,
4018 .special = NULL,
4019 .enum_list = NULL,
4020 .flags = FLAG_ADVANCED,
4023 .label = "afs username map",
4024 .type = P_STRING,
4025 .p_class = P_GLOBAL,
4026 .ptr = &Globals.szAfsUsernameMap,
4027 .special = NULL,
4028 .enum_list = NULL,
4029 .flags = FLAG_ADVANCED,
4032 .label = "afs token lifetime",
4033 .type = P_INTEGER,
4034 .p_class = P_GLOBAL,
4035 .ptr = &Globals.iAfsTokenLifetime,
4036 .special = NULL,
4037 .enum_list = NULL,
4038 .flags = FLAG_ADVANCED,
4041 .label = "log nt token command",
4042 .type = P_STRING,
4043 .p_class = P_GLOBAL,
4044 .ptr = &Globals.szLogNtTokenCommand,
4045 .special = NULL,
4046 .enum_list = NULL,
4047 .flags = FLAG_ADVANCED,
4050 .label = "time offset",
4051 .type = P_INTEGER,
4052 .p_class = P_GLOBAL,
4053 .ptr = &extra_time_offset,
4054 .special = NULL,
4055 .enum_list = NULL,
4056 .flags = FLAG_ADVANCED,
4059 .label = "NIS homedir",
4060 .type = P_BOOL,
4061 .p_class = P_GLOBAL,
4062 .ptr = &Globals.bNISHomeMap,
4063 .special = NULL,
4064 .enum_list = NULL,
4065 .flags = FLAG_ADVANCED,
4068 .label = "-valid",
4069 .type = P_BOOL,
4070 .p_class = P_LOCAL,
4071 .ptr = &sDefault.valid,
4072 .special = NULL,
4073 .enum_list = NULL,
4074 .flags = FLAG_HIDE,
4077 .label = "copy",
4078 .type = P_STRING,
4079 .p_class = P_LOCAL,
4080 .ptr = &sDefault.szCopy,
4081 .special = handle_copy,
4082 .enum_list = NULL,
4083 .flags = FLAG_HIDE,
4086 .label = "include",
4087 .type = P_STRING,
4088 .p_class = P_LOCAL,
4089 .ptr = &sDefault.szInclude,
4090 .special = handle_include,
4091 .enum_list = NULL,
4092 .flags = FLAG_HIDE|FLAG_META,
4095 .label = "preexec",
4096 .type = P_STRING,
4097 .p_class = P_LOCAL,
4098 .ptr = &sDefault.szPreExec,
4099 .special = NULL,
4100 .enum_list = NULL,
4101 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4104 .label = "exec",
4105 .type = P_STRING,
4106 .p_class = P_LOCAL,
4107 .ptr = &sDefault.szPreExec,
4108 .special = NULL,
4109 .enum_list = NULL,
4110 .flags = FLAG_ADVANCED,
4113 .label = "preexec close",
4114 .type = P_BOOL,
4115 .p_class = P_LOCAL,
4116 .ptr = &sDefault.bPreexecClose,
4117 .special = NULL,
4118 .enum_list = NULL,
4119 .flags = FLAG_ADVANCED | FLAG_SHARE,
4122 .label = "postexec",
4123 .type = P_STRING,
4124 .p_class = P_LOCAL,
4125 .ptr = &sDefault.szPostExec,
4126 .special = NULL,
4127 .enum_list = NULL,
4128 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4131 .label = "root preexec",
4132 .type = P_STRING,
4133 .p_class = P_LOCAL,
4134 .ptr = &sDefault.szRootPreExec,
4135 .special = NULL,
4136 .enum_list = NULL,
4137 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4140 .label = "root preexec close",
4141 .type = P_BOOL,
4142 .p_class = P_LOCAL,
4143 .ptr = &sDefault.bRootpreexecClose,
4144 .special = NULL,
4145 .enum_list = NULL,
4146 .flags = FLAG_ADVANCED | FLAG_SHARE,
4149 .label = "root postexec",
4150 .type = P_STRING,
4151 .p_class = P_LOCAL,
4152 .ptr = &sDefault.szRootPostExec,
4153 .special = NULL,
4154 .enum_list = NULL,
4155 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4158 .label = "available",
4159 .type = P_BOOL,
4160 .p_class = P_LOCAL,
4161 .ptr = &sDefault.bAvailable,
4162 .special = NULL,
4163 .enum_list = NULL,
4164 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4167 .label = "registry shares",
4168 .type = P_BOOL,
4169 .p_class = P_GLOBAL,
4170 .ptr = &Globals.bRegistryShares,
4171 .special = NULL,
4172 .enum_list = NULL,
4173 .flags = FLAG_ADVANCED,
4176 .label = "usershare allow guests",
4177 .type = P_BOOL,
4178 .p_class = P_GLOBAL,
4179 .ptr = &Globals.bUsershareAllowGuests,
4180 .special = NULL,
4181 .enum_list = NULL,
4182 .flags = FLAG_ADVANCED,
4185 .label = "usershare max shares",
4186 .type = P_INTEGER,
4187 .p_class = P_GLOBAL,
4188 .ptr = &Globals.iUsershareMaxShares,
4189 .special = NULL,
4190 .enum_list = NULL,
4191 .flags = FLAG_ADVANCED,
4194 .label = "usershare owner only",
4195 .type = P_BOOL,
4196 .p_class = P_GLOBAL,
4197 .ptr = &Globals.bUsershareOwnerOnly,
4198 .special = NULL,
4199 .enum_list = NULL,
4200 .flags = FLAG_ADVANCED,
4203 .label = "usershare path",
4204 .type = P_STRING,
4205 .p_class = P_GLOBAL,
4206 .ptr = &Globals.szUsersharePath,
4207 .special = NULL,
4208 .enum_list = NULL,
4209 .flags = FLAG_ADVANCED,
4212 .label = "usershare prefix allow list",
4213 .type = P_LIST,
4214 .p_class = P_GLOBAL,
4215 .ptr = &Globals.szUsersharePrefixAllowList,
4216 .special = NULL,
4217 .enum_list = NULL,
4218 .flags = FLAG_ADVANCED,
4221 .label = "usershare prefix deny list",
4222 .type = P_LIST,
4223 .p_class = P_GLOBAL,
4224 .ptr = &Globals.szUsersharePrefixDenyList,
4225 .special = NULL,
4226 .enum_list = NULL,
4227 .flags = FLAG_ADVANCED,
4230 .label = "usershare template share",
4231 .type = P_STRING,
4232 .p_class = P_GLOBAL,
4233 .ptr = &Globals.szUsershareTemplateShare,
4234 .special = NULL,
4235 .enum_list = NULL,
4236 .flags = FLAG_ADVANCED,
4239 .label = "volume",
4240 .type = P_STRING,
4241 .p_class = P_LOCAL,
4242 .ptr = &sDefault.volume,
4243 .special = NULL,
4244 .enum_list = NULL,
4245 .flags = FLAG_ADVANCED | FLAG_SHARE,
4248 .label = "fstype",
4249 .type = P_STRING,
4250 .p_class = P_LOCAL,
4251 .ptr = &sDefault.fstype,
4252 .special = NULL,
4253 .enum_list = NULL,
4254 .flags = FLAG_ADVANCED | FLAG_SHARE,
4257 .label = "set directory",
4258 .type = P_BOOLREV,
4259 .p_class = P_LOCAL,
4260 .ptr = &sDefault.bNo_set_dir,
4261 .special = NULL,
4262 .enum_list = NULL,
4263 .flags = FLAG_ADVANCED | FLAG_SHARE,
4266 .label = "wide links",
4267 .type = P_BOOL,
4268 .p_class = P_LOCAL,
4269 .ptr = &sDefault.bWidelinks,
4270 .special = NULL,
4271 .enum_list = NULL,
4272 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4275 .label = "follow symlinks",
4276 .type = P_BOOL,
4277 .p_class = P_LOCAL,
4278 .ptr = &sDefault.bSymlinks,
4279 .special = NULL,
4280 .enum_list = NULL,
4281 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4284 .label = "dont descend",
4285 .type = P_STRING,
4286 .p_class = P_LOCAL,
4287 .ptr = &sDefault.szDontdescend,
4288 .special = NULL,
4289 .enum_list = NULL,
4290 .flags = FLAG_ADVANCED | FLAG_SHARE,
4293 .label = "magic script",
4294 .type = P_STRING,
4295 .p_class = P_LOCAL,
4296 .ptr = &sDefault.szMagicScript,
4297 .special = NULL,
4298 .enum_list = NULL,
4299 .flags = FLAG_ADVANCED | FLAG_SHARE,
4302 .label = "magic output",
4303 .type = P_STRING,
4304 .p_class = P_LOCAL,
4305 .ptr = &sDefault.szMagicOutput,
4306 .special = NULL,
4307 .enum_list = NULL,
4308 .flags = FLAG_ADVANCED | FLAG_SHARE,
4311 .label = "delete readonly",
4312 .type = P_BOOL,
4313 .p_class = P_LOCAL,
4314 .ptr = &sDefault.bDeleteReadonly,
4315 .special = NULL,
4316 .enum_list = NULL,
4317 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4320 .label = "dos filemode",
4321 .type = P_BOOL,
4322 .p_class = P_LOCAL,
4323 .ptr = &sDefault.bDosFilemode,
4324 .special = NULL,
4325 .enum_list = NULL,
4326 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4329 .label = "dos filetimes",
4330 .type = P_BOOL,
4331 .p_class = P_LOCAL,
4332 .ptr = &sDefault.bDosFiletimes,
4333 .special = NULL,
4334 .enum_list = NULL,
4335 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4338 .label = "dos filetime resolution",
4339 .type = P_BOOL,
4340 .p_class = P_LOCAL,
4341 .ptr = &sDefault.bDosFiletimeResolution,
4342 .special = NULL,
4343 .enum_list = NULL,
4344 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4347 .label = "fake directory create times",
4348 .type = P_BOOL,
4349 .p_class = P_LOCAL,
4350 .ptr = &sDefault.bFakeDirCreateTimes,
4351 .special = NULL,
4352 .enum_list = NULL,
4353 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4356 .label = "panic action",
4357 .type = P_STRING,
4358 .p_class = P_GLOBAL,
4359 .ptr = &Globals.szPanicAction,
4360 .special = NULL,
4361 .enum_list = NULL,
4362 .flags = FLAG_ADVANCED,
4365 .label = "perfcount module",
4366 .type = P_STRING,
4367 .p_class = P_GLOBAL,
4368 .ptr = &Globals.szSMBPerfcountModule,
4369 .special = NULL,
4370 .enum_list = NULL,
4371 .flags = FLAG_ADVANCED,
4374 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4377 .label = "vfs objects",
4378 .type = P_LIST,
4379 .p_class = P_LOCAL,
4380 .ptr = &sDefault.szVfsObjects,
4381 .special = NULL,
4382 .enum_list = NULL,
4383 .flags = FLAG_ADVANCED | FLAG_SHARE,
4386 .label = "vfs object",
4387 .type = P_LIST,
4388 .p_class = P_LOCAL,
4389 .ptr = &sDefault.szVfsObjects,
4390 .special = NULL,
4391 .enum_list = NULL,
4392 .flags = FLAG_HIDE,
4396 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4399 .label = "msdfs root",
4400 .type = P_BOOL,
4401 .p_class = P_LOCAL,
4402 .ptr = &sDefault.bMSDfsRoot,
4403 .special = NULL,
4404 .enum_list = NULL,
4405 .flags = FLAG_ADVANCED | FLAG_SHARE,
4408 .label = "msdfs proxy",
4409 .type = P_STRING,
4410 .p_class = P_LOCAL,
4411 .ptr = &sDefault.szMSDfsProxy,
4412 .special = NULL,
4413 .enum_list = NULL,
4414 .flags = FLAG_ADVANCED | FLAG_SHARE,
4417 .label = "host msdfs",
4418 .type = P_BOOL,
4419 .p_class = P_GLOBAL,
4420 .ptr = &Globals.bHostMSDfs,
4421 .special = NULL,
4422 .enum_list = NULL,
4423 .flags = FLAG_ADVANCED,
4426 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4429 .label = "passdb expand explicit",
4430 .type = P_BOOL,
4431 .p_class = P_GLOBAL,
4432 .ptr = &Globals.bPassdbExpandExplicit,
4433 .special = NULL,
4434 .enum_list = NULL,
4435 .flags = FLAG_ADVANCED,
4438 .label = "idmap backend",
4439 .type = P_STRING,
4440 .p_class = P_GLOBAL,
4441 .ptr = &Globals.szIdmapBackend,
4442 .special = NULL,
4443 .enum_list = NULL,
4444 .flags = FLAG_ADVANCED,
4447 .label = "idmap alloc backend",
4448 .type = P_STRING,
4449 .p_class = P_GLOBAL,
4450 .ptr = &Globals.szIdmapAllocBackend,
4451 .special = NULL,
4452 .enum_list = NULL,
4453 .flags = FLAG_ADVANCED,
4456 .label = "idmap cache time",
4457 .type = P_INTEGER,
4458 .p_class = P_GLOBAL,
4459 .ptr = &Globals.iIdmapCacheTime,
4460 .special = NULL,
4461 .enum_list = NULL,
4462 .flags = FLAG_ADVANCED,
4465 .label = "idmap negative cache time",
4466 .type = P_INTEGER,
4467 .p_class = P_GLOBAL,
4468 .ptr = &Globals.iIdmapNegativeCacheTime,
4469 .special = NULL,
4470 .enum_list = NULL,
4471 .flags = FLAG_ADVANCED,
4474 .label = "idmap uid",
4475 .type = P_STRING,
4476 .p_class = P_GLOBAL,
4477 .ptr = &Globals.szIdmapUID,
4478 .special = handle_idmap_uid,
4479 .enum_list = NULL,
4480 .flags = FLAG_ADVANCED,
4483 .label = "winbind uid",
4484 .type = P_STRING,
4485 .p_class = P_GLOBAL,
4486 .ptr = &Globals.szIdmapUID,
4487 .special = handle_idmap_uid,
4488 .enum_list = NULL,
4489 .flags = FLAG_HIDE,
4492 .label = "idmap gid",
4493 .type = P_STRING,
4494 .p_class = P_GLOBAL,
4495 .ptr = &Globals.szIdmapGID,
4496 .special = handle_idmap_gid,
4497 .enum_list = NULL,
4498 .flags = FLAG_ADVANCED,
4501 .label = "winbind gid",
4502 .type = P_STRING,
4503 .p_class = P_GLOBAL,
4504 .ptr = &Globals.szIdmapGID,
4505 .special = handle_idmap_gid,
4506 .enum_list = NULL,
4507 .flags = FLAG_HIDE,
4510 .label = "template homedir",
4511 .type = P_STRING,
4512 .p_class = P_GLOBAL,
4513 .ptr = &Globals.szTemplateHomedir,
4514 .special = NULL,
4515 .enum_list = NULL,
4516 .flags = FLAG_ADVANCED,
4519 .label = "template shell",
4520 .type = P_STRING,
4521 .p_class = P_GLOBAL,
4522 .ptr = &Globals.szTemplateShell,
4523 .special = NULL,
4524 .enum_list = NULL,
4525 .flags = FLAG_ADVANCED,
4528 .label = "winbind separator",
4529 .type = P_STRING,
4530 .p_class = P_GLOBAL,
4531 .ptr = &Globals.szWinbindSeparator,
4532 .special = NULL,
4533 .enum_list = NULL,
4534 .flags = FLAG_ADVANCED,
4537 .label = "winbind cache time",
4538 .type = P_INTEGER,
4539 .p_class = P_GLOBAL,
4540 .ptr = &Globals.winbind_cache_time,
4541 .special = NULL,
4542 .enum_list = NULL,
4543 .flags = FLAG_ADVANCED,
4546 .label = "winbind reconnect delay",
4547 .type = P_INTEGER,
4548 .p_class = P_GLOBAL,
4549 .ptr = &Globals.winbind_reconnect_delay,
4550 .special = NULL,
4551 .enum_list = NULL,
4552 .flags = FLAG_ADVANCED,
4555 .label = "winbind max clients",
4556 .type = P_INTEGER,
4557 .p_class = P_GLOBAL,
4558 .ptr = &Globals.winbind_max_clients,
4559 .special = NULL,
4560 .enum_list = NULL,
4561 .flags = FLAG_ADVANCED,
4564 .label = "winbind enum users",
4565 .type = P_BOOL,
4566 .p_class = P_GLOBAL,
4567 .ptr = &Globals.bWinbindEnumUsers,
4568 .special = NULL,
4569 .enum_list = NULL,
4570 .flags = FLAG_ADVANCED,
4573 .label = "winbind enum groups",
4574 .type = P_BOOL,
4575 .p_class = P_GLOBAL,
4576 .ptr = &Globals.bWinbindEnumGroups,
4577 .special = NULL,
4578 .enum_list = NULL,
4579 .flags = FLAG_ADVANCED,
4582 .label = "winbind use default domain",
4583 .type = P_BOOL,
4584 .p_class = P_GLOBAL,
4585 .ptr = &Globals.bWinbindUseDefaultDomain,
4586 .special = NULL,
4587 .enum_list = NULL,
4588 .flags = FLAG_ADVANCED,
4591 .label = "winbind trusted domains only",
4592 .type = P_BOOL,
4593 .p_class = P_GLOBAL,
4594 .ptr = &Globals.bWinbindTrustedDomainsOnly,
4595 .special = NULL,
4596 .enum_list = NULL,
4597 .flags = FLAG_ADVANCED,
4600 .label = "winbind nested groups",
4601 .type = P_BOOL,
4602 .p_class = P_GLOBAL,
4603 .ptr = &Globals.bWinbindNestedGroups,
4604 .special = NULL,
4605 .enum_list = NULL,
4606 .flags = FLAG_ADVANCED,
4609 .label = "winbind expand groups",
4610 .type = P_INTEGER,
4611 .p_class = P_GLOBAL,
4612 .ptr = &Globals.winbind_expand_groups,
4613 .special = NULL,
4614 .enum_list = NULL,
4615 .flags = FLAG_ADVANCED,
4618 .label = "winbind nss info",
4619 .type = P_LIST,
4620 .p_class = P_GLOBAL,
4621 .ptr = &Globals.szWinbindNssInfo,
4622 .special = NULL,
4623 .enum_list = NULL,
4624 .flags = FLAG_ADVANCED,
4627 .label = "winbind refresh tickets",
4628 .type = P_BOOL,
4629 .p_class = P_GLOBAL,
4630 .ptr = &Globals.bWinbindRefreshTickets,
4631 .special = NULL,
4632 .enum_list = NULL,
4633 .flags = FLAG_ADVANCED,
4636 .label = "winbind offline logon",
4637 .type = P_BOOL,
4638 .p_class = P_GLOBAL,
4639 .ptr = &Globals.bWinbindOfflineLogon,
4640 .special = NULL,
4641 .enum_list = NULL,
4642 .flags = FLAG_ADVANCED,
4645 .label = "winbind normalize names",
4646 .type = P_BOOL,
4647 .p_class = P_GLOBAL,
4648 .ptr = &Globals.bWinbindNormalizeNames,
4649 .special = NULL,
4650 .enum_list = NULL,
4651 .flags = FLAG_ADVANCED,
4654 .label = "winbind rpc only",
4655 .type = P_BOOL,
4656 .p_class = P_GLOBAL,
4657 .ptr = &Globals.bWinbindRpcOnly,
4658 .special = NULL,
4659 .enum_list = NULL,
4660 .flags = FLAG_ADVANCED,
4663 .label = "create krb5 conf",
4664 .type = P_BOOL,
4665 .p_class = P_GLOBAL,
4666 .ptr = &Globals.bCreateKrb5Conf,
4667 .special = NULL,
4668 .enum_list = NULL,
4669 .flags = FLAG_ADVANCED,
4672 {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
4675 /***************************************************************************
4676 Initialise the sDefault parameter structure for the printer values.
4677 ***************************************************************************/
4679 static void init_printer_values(struct service *pService)
4681 /* choose defaults depending on the type of printing */
4682 switch (pService->iPrinting) {
4683 case PRINT_BSD:
4684 case PRINT_AIX:
4685 case PRINT_LPRNT:
4686 case PRINT_LPROS2:
4687 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4688 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4689 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4690 break;
4692 case PRINT_LPRNG:
4693 case PRINT_PLP:
4694 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4695 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4696 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4697 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4698 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4699 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4700 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4701 break;
4703 case PRINT_CUPS:
4704 case PRINT_IPRINT:
4705 #ifdef HAVE_CUPS
4706 /* set the lpq command to contain the destination printer
4707 name only. This is used by cups_queue_get() */
4708 string_set(&pService->szLpqcommand, "%p");
4709 string_set(&pService->szLprmcommand, "");
4710 string_set(&pService->szPrintcommand, "");
4711 string_set(&pService->szLppausecommand, "");
4712 string_set(&pService->szLpresumecommand, "");
4713 string_set(&pService->szQueuepausecommand, "");
4714 string_set(&pService->szQueueresumecommand, "");
4715 #else
4716 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4717 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4718 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4719 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4720 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4721 string_set(&pService->szQueuepausecommand, "disable '%p'");
4722 string_set(&pService->szQueueresumecommand, "enable '%p'");
4723 #endif /* HAVE_CUPS */
4724 break;
4726 case PRINT_SYSV:
4727 case PRINT_HPUX:
4728 string_set(&pService->szLpqcommand, "lpstat -o%p");
4729 string_set(&pService->szLprmcommand, "cancel %p-%j");
4730 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4731 string_set(&pService->szQueuepausecommand, "disable %p");
4732 string_set(&pService->szQueueresumecommand, "enable %p");
4733 #ifndef HPUX
4734 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4735 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4736 #endif /* HPUX */
4737 break;
4739 case PRINT_QNX:
4740 string_set(&pService->szLpqcommand, "lpq -P%p");
4741 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4742 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4743 break;
4745 #ifdef DEVELOPER
4746 case PRINT_TEST:
4747 case PRINT_VLP:
4748 string_set(&pService->szPrintcommand, "vlp print %p %s");
4749 string_set(&pService->szLpqcommand, "vlp lpq %p");
4750 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
4751 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
4752 string_set(&pService->szLpresumecommand, "vlp lpresume %p %j");
4753 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
4754 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
4755 break;
4756 #endif /* DEVELOPER */
4761 * Function to return the default value for the maximum number of open
4762 * file descriptors permitted. This function tries to consult the
4763 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4764 * the smaller of those.
4766 static int max_open_files(void)
4768 int sysctl_max = MAX_OPEN_FILES;
4769 int rlimit_max = MAX_OPEN_FILES;
4771 #ifdef HAVE_SYSCTLBYNAME
4773 size_t size = sizeof(sysctl_max);
4774 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4777 #endif
4779 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4781 struct rlimit rl;
4783 ZERO_STRUCT(rl);
4785 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4786 rlimit_max = rl.rlim_cur;
4788 #if defined(RLIM_INFINITY)
4789 if(rl.rlim_cur == RLIM_INFINITY)
4790 rlimit_max = MAX_OPEN_FILES;
4792 #endif
4793 #endif
4795 if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
4796 DEBUG(2,("max_open_files: increasing sysctl_max (%d) to "
4797 "minimum Windows limit (%d)\n",
4798 sysctl_max,
4799 MIN_OPEN_FILES_WINDOWS));
4800 sysctl_max = MIN_OPEN_FILES_WINDOWS;
4803 if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
4804 DEBUG(2,("rlimit_max: increasing rlimit_max (%d) to "
4805 "minimum Windows limit (%d)\n",
4806 rlimit_max,
4807 MIN_OPEN_FILES_WINDOWS));
4808 rlimit_max = MIN_OPEN_FILES_WINDOWS;
4811 return MIN(sysctl_max, rlimit_max);
4815 * Common part of freeing allocated data for one parameter.
4817 static void free_one_parameter_common(void *parm_ptr,
4818 struct parm_struct parm)
4820 if ((parm.type == P_STRING) ||
4821 (parm.type == P_USTRING))
4823 string_free((char**)parm_ptr);
4824 } else if (parm.type == P_LIST) {
4825 TALLOC_FREE(*((char***)parm_ptr));
4830 * Free the allocated data for one parameter for a share
4831 * given as a service struct.
4833 static void free_one_parameter(struct service *service,
4834 struct parm_struct parm)
4836 void *parm_ptr;
4838 if (parm.p_class != P_LOCAL) {
4839 return;
4842 parm_ptr = lp_local_ptr(service, parm.ptr);
4844 free_one_parameter_common(parm_ptr, parm);
4848 * Free the allocated parameter data of a share given
4849 * as a service struct.
4851 static void free_parameters(struct service *service)
4853 uint32_t i;
4855 for (i=0; parm_table[i].label; i++) {
4856 free_one_parameter(service, parm_table[i]);
4861 * Free the allocated data for one parameter for a given share
4862 * specified by an snum.
4864 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4866 void *parm_ptr;
4868 if (parm.ptr == NULL) {
4869 return;
4872 if (snum < 0) {
4873 parm_ptr = parm.ptr;
4874 } else if (parm.p_class != P_LOCAL) {
4875 return;
4876 } else {
4877 parm_ptr = lp_local_ptr_by_snum(snum, parm.ptr);
4880 free_one_parameter_common(parm_ptr, parm);
4884 * Free the allocated parameter data for a share specified
4885 * by an snum.
4887 static void free_parameters_by_snum(int snum)
4889 uint32_t i;
4891 for (i=0; parm_table[i].label; i++) {
4892 free_one_parameter_by_snum(snum, parm_table[i]);
4897 * Free the allocated global parameters.
4899 static void free_global_parameters(void)
4901 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4904 /***************************************************************************
4905 Initialise the global parameter structure.
4906 ***************************************************************************/
4908 static void init_globals(bool first_time_only)
4910 static bool done_init = False;
4911 char *s = NULL;
4912 int i;
4914 /* If requested to initialize only once and we've already done it... */
4915 if (first_time_only && done_init) {
4916 /* ... then we have nothing more to do */
4917 return;
4920 if (!done_init) {
4921 /* The logfile can be set before this is invoked. Free it if so. */
4922 if (Globals.szLogFile != NULL) {
4923 string_free(&Globals.szLogFile);
4924 Globals.szLogFile = NULL;
4926 done_init = True;
4927 } else {
4928 free_global_parameters();
4931 memset((void *)&Globals, '\0', sizeof(Globals));
4933 for (i = 0; parm_table[i].label; i++) {
4934 if ((parm_table[i].type == P_STRING ||
4935 parm_table[i].type == P_USTRING) &&
4936 parm_table[i].ptr)
4938 string_set((char **)parm_table[i].ptr, "");
4942 string_set(&sDefault.fstype, FSTYPE_STRING);
4943 string_set(&sDefault.szPrintjobUsername, "%U");
4945 init_printer_values(&sDefault);
4948 DEBUG(3, ("Initialising global parameters\n"));
4950 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4951 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4953 /* use the new 'hash2' method by default, with a prefix of 1 */
4954 string_set(&Globals.szManglingMethod, "hash2");
4955 Globals.mangle_prefix = 1;
4957 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4959 /* using UTF8 by default allows us to support all chars */
4960 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4962 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
4963 /* If the system supports nl_langinfo(), try to grab the value
4964 from the user's locale */
4965 string_set(&Globals.display_charset, "LOCALE");
4966 #else
4967 string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
4968 #endif
4970 /* Use codepage 850 as a default for the dos character set */
4971 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4974 * Allow the default PASSWD_CHAT to be overridden in local.h.
4976 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4978 set_global_myname(myhostname());
4979 string_set(&Globals.szNetbiosName,global_myname());
4981 set_global_myworkgroup(WORKGROUP);
4982 string_set(&Globals.szWorkgroup, lp_workgroup());
4984 string_set(&Globals.szPasswdProgram, "");
4985 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4986 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4987 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4988 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4989 string_set(&Globals.szSocketAddress, "0.0.0.0");
4991 * By default support explicit binding to broadcast
4992 * addresses.
4994 Globals.bNmbdBindExplicitBroadcast = true;
4996 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4997 smb_panic("init_globals: ENOMEM");
4999 string_set(&Globals.szServerString, s);
5000 SAFE_FREE(s);
5001 if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
5002 DEFAULT_MINOR_VERSION) < 0) {
5003 smb_panic("init_globals: ENOMEM");
5005 string_set(&Globals.szAnnounceVersion, s);
5006 SAFE_FREE(s);
5007 #ifdef DEVELOPER
5008 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
5009 #endif
5011 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
5013 string_set(&Globals.szLogonDrive, "");
5014 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
5015 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
5016 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
5018 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
5019 string_set(&Globals.szPasswordServer, "*");
5021 Globals.AlgorithmicRidBase = BASE_RID;
5023 Globals.bLoadPrinters = True;
5024 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
5026 Globals.ConfigBackend = config_backend;
5028 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
5029 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
5030 Globals.max_xmit = 0x4104;
5031 Globals.max_mux = 50; /* This is *needed* for profile support. */
5032 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
5033 Globals.bDisableSpoolss = False;
5034 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
5035 Globals.pwordlevel = 0;
5036 Globals.unamelevel = 0;
5037 Globals.deadtime = 0;
5038 Globals.getwd_cache = true;
5039 Globals.bLargeReadwrite = True;
5040 Globals.max_log_size = 5000;
5041 Globals.max_open_files = max_open_files();
5042 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
5043 Globals.maxprotocol = PROTOCOL_NT1;
5044 Globals.minprotocol = PROTOCOL_CORE;
5045 Globals.security = SEC_USER;
5046 Globals.paranoid_server_security = True;
5047 Globals.bEncryptPasswords = True;
5048 Globals.bUpdateEncrypt = False;
5049 Globals.clientSchannel = Auto;
5050 Globals.serverSchannel = Auto;
5051 Globals.bReadRaw = True;
5052 Globals.bWriteRaw = True;
5053 Globals.bNullPasswords = False;
5054 Globals.bObeyPamRestrictions = False;
5055 Globals.syslog = 1;
5056 Globals.bSyslogOnly = False;
5057 Globals.bTimestampLogs = True;
5058 string_set(&Globals.szLogLevel, "0");
5059 Globals.bDebugPrefixTimestamp = False;
5060 Globals.bDebugHiresTimestamp = true;
5061 Globals.bDebugPid = False;
5062 Globals.bDebugUid = False;
5063 Globals.bDebugClass = False;
5064 Globals.bEnableCoreFiles = True;
5065 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
5066 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
5067 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
5068 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
5069 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
5070 Globals.lm_interval = 60;
5071 Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
5072 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
5073 Globals.bNISHomeMap = False;
5074 #ifdef WITH_NISPLUS_HOME
5075 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
5076 #else
5077 string_set(&Globals.szNISHomeMapName, "auto.home");
5078 #endif
5079 #endif
5080 Globals.bTimeServer = False;
5081 Globals.bBindInterfacesOnly = False;
5082 Globals.bUnixPasswdSync = False;
5083 Globals.bPamPasswordChange = False;
5084 Globals.bPasswdChatDebug = False;
5085 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
5086 Globals.bNTPipeSupport = True; /* Do NT pipes by default. */
5087 Globals.bNTStatusSupport = True; /* Use NT status by default. */
5088 Globals.bStatCache = True; /* use stat cache by default */
5089 Globals.iMaxStatCacheSize = 256; /* 256k by default */
5090 Globals.restrict_anonymous = 0;
5091 Globals.bClientLanManAuth = False; /* Do NOT use the LanMan hash if it is available */
5092 Globals.bClientPlaintextAuth = False; /* Do NOT use a plaintext password even if is requested by the server */
5093 Globals.bLanmanAuth = False; /* Do NOT use the LanMan hash, even if it is supplied */
5094 Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
5095 Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
5096 /* Note, that we will use NTLM2 session security (which is different), if it is available */
5098 Globals.map_to_guest = 0; /* By Default, "Never" */
5099 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
5100 Globals.enhanced_browsing = true;
5101 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
5102 #ifdef MMAP_BLACKLIST
5103 Globals.bUseMmap = False;
5104 #else
5105 Globals.bUseMmap = True;
5106 #endif
5107 Globals.bUnixExtensions = True;
5108 Globals.bResetOnZeroVC = False;
5109 Globals.bCreateKrb5Conf = true;
5111 /* hostname lookups can be very expensive and are broken on
5112 a large number of sites (tridge) */
5113 Globals.bHostnameLookups = False;
5115 string_set(&Globals.szPassdbBackend, "tdbsam");
5116 string_set(&Globals.szLdapSuffix, "");
5117 string_set(&Globals.szLdapMachineSuffix, "");
5118 string_set(&Globals.szLdapUserSuffix, "");
5119 string_set(&Globals.szLdapGroupSuffix, "");
5120 string_set(&Globals.szLdapIdmapSuffix, "");
5122 string_set(&Globals.szLdapAdminDn, "");
5123 Globals.ldap_ssl = LDAP_SSL_START_TLS;
5124 Globals.ldap_ssl_ads = False;
5125 Globals.ldap_deref = -1;
5126 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
5127 Globals.ldap_delete_dn = False;
5128 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
5129 Globals.ldap_follow_referral = Auto;
5130 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
5131 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
5132 Globals.ldap_page_size = LDAP_PAGE_SIZE;
5134 Globals.ldap_debug_level = 0;
5135 Globals.ldap_debug_threshold = 10;
5137 /* This is what we tell the afs client. in reality we set the token
5138 * to never expire, though, when this runs out the afs client will
5139 * forget the token. Set to 0 to get NEVERDATE.*/
5140 Globals.iAfsTokenLifetime = 604800;
5141 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
5143 /* these parameters are set to defaults that are more appropriate
5144 for the increasing samba install base:
5146 as a member of the workgroup, that will possibly become a
5147 _local_ master browser (lm = True). this is opposed to a forced
5148 local master browser startup (pm = True).
5150 doesn't provide WINS server service by default (wsupp = False),
5151 and doesn't provide domain master browser services by default, either.
5155 Globals.bMsAddPrinterWizard = True;
5156 Globals.os_level = 20;
5157 Globals.bLocalMaster = True;
5158 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
5159 Globals.bDomainLogons = False;
5160 Globals.bBrowseList = True;
5161 Globals.bWINSsupport = False;
5162 Globals.bWINSproxy = False;
5164 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
5165 Globals.InitLogonDelay = 100; /* 100 ms default delay */
5167 Globals.bDNSproxy = True;
5169 /* this just means to use them if they exist */
5170 Globals.bKernelOplocks = True;
5172 Globals.bAllowTrustedDomains = True;
5173 string_set(&Globals.szIdmapBackend, "tdb");
5175 string_set(&Globals.szTemplateShell, "/bin/false");
5176 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
5177 string_set(&Globals.szWinbindSeparator, "\\");
5179 string_set(&Globals.szCupsServer, "");
5180 string_set(&Globals.szIPrintServer, "");
5182 string_set(&Globals.ctdbdSocket, "");
5183 Globals.szClusterAddresses = NULL;
5184 Globals.clustering = False;
5185 Globals.ctdb_timeout = 0;
5187 Globals.winbind_cache_time = 300; /* 5 minutes */
5188 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
5189 Globals.winbind_max_clients = 200;
5190 Globals.bWinbindEnumUsers = False;
5191 Globals.bWinbindEnumGroups = False;
5192 Globals.bWinbindUseDefaultDomain = False;
5193 Globals.bWinbindTrustedDomainsOnly = False;
5194 Globals.bWinbindNestedGroups = True;
5195 Globals.winbind_expand_groups = 1;
5196 Globals.szWinbindNssInfo = str_list_make_v3(talloc_autofree_context(), "template", NULL);
5197 Globals.bWinbindRefreshTickets = False;
5198 Globals.bWinbindOfflineLogon = False;
5200 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
5201 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
5203 Globals.bPassdbExpandExplicit = False;
5205 Globals.name_cache_timeout = 660; /* In seconds */
5207 Globals.bUseSpnego = True;
5208 Globals.bClientUseSpnego = True;
5210 Globals.client_signing = Auto;
5211 Globals.server_signing = False;
5213 Globals.bDeferSharingViolations = True;
5214 string_set(&Globals.smb_ports, SMB_PORTS);
5216 Globals.bEnablePrivileges = True;
5217 Globals.bHostMSDfs = True;
5218 Globals.bASUSupport = False;
5220 /* User defined shares. */
5221 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5222 smb_panic("init_globals: ENOMEM");
5224 string_set(&Globals.szUsersharePath, s);
5225 SAFE_FREE(s);
5226 string_set(&Globals.szUsershareTemplateShare, "");
5227 Globals.iUsershareMaxShares = 0;
5228 /* By default disallow sharing of directories not owned by the sharer. */
5229 Globals.bUsershareOwnerOnly = True;
5230 /* By default disallow guest access to usershares. */
5231 Globals.bUsershareAllowGuests = False;
5233 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5235 /* By default no shares out of the registry */
5236 Globals.bRegistryShares = False;
5238 Globals.iminreceivefile = 0;
5240 Globals.bMapUntrustedToDomain = false;
5243 /*******************************************************************
5244 Convenience routine to grab string parameters into temporary memory
5245 and run standard_sub_basic on them. The buffers can be written to by
5246 callers without affecting the source string.
5247 ********************************************************************/
5249 static char *lp_string(const char *s)
5251 char *ret;
5252 TALLOC_CTX *ctx = talloc_tos();
5254 /* The follow debug is useful for tracking down memory problems
5255 especially if you have an inner loop that is calling a lp_*()
5256 function that returns a string. Perhaps this debug should be
5257 present all the time? */
5259 #if 0
5260 DEBUG(10, ("lp_string(%s)\n", s));
5261 #endif
5262 if (!s) {
5263 return NULL;
5266 ret = talloc_sub_basic(ctx,
5267 get_current_username(),
5268 current_user_info.domain,
5270 if (trim_char(ret, '\"', '\"')) {
5271 if (strchr(ret,'\"') != NULL) {
5272 TALLOC_FREE(ret);
5273 ret = talloc_sub_basic(ctx,
5274 get_current_username(),
5275 current_user_info.domain,
5279 return ret;
5283 In this section all the functions that are used to access the
5284 parameters from the rest of the program are defined
5287 #define FN_GLOBAL_STRING(fn_name,ptr) \
5288 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
5289 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5290 const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
5291 #define FN_GLOBAL_LIST(fn_name,ptr) \
5292 const char **fn_name(void) {return(*(const char ***)(ptr));}
5293 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5294 bool fn_name(void) {return(*(bool *)(ptr));}
5295 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5296 char fn_name(void) {return(*(char *)(ptr));}
5297 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5298 int fn_name(void) {return(*(int *)(ptr));}
5300 #define FN_LOCAL_STRING(fn_name,val) \
5301 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5302 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5303 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5304 #define FN_LOCAL_LIST(fn_name,val) \
5305 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5306 #define FN_LOCAL_BOOL(fn_name,val) \
5307 bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5308 #define FN_LOCAL_INTEGER(fn_name,val) \
5309 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5311 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5312 bool fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5313 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5314 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5315 #define FN_LOCAL_PARM_STRING(fn_name,val) \
5316 char *fn_name(const struct share_params *p) {return(lp_string((LP_SNUM_OK(p->service) && ServicePtrs[(p->service)]->val) ? ServicePtrs[(p->service)]->val : sDefault.val));}
5317 #define FN_LOCAL_CHAR(fn_name,val) \
5318 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5320 FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
5321 FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
5322 FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
5323 FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
5324 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
5325 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
5326 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
5327 FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
5328 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
5329 FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
5330 FN_GLOBAL_STRING(lp_addport_cmd, &Globals.szAddPortCommand)
5331 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
5332 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
5333 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
5334 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
5335 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
5336 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5337 * build process or in smb.conf, we use that value. Otherwise they
5338 * default to the value of lp_lockdir(). */
5339 char *lp_statedir(void) {
5340 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5341 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5342 return(lp_string(*(char **)(&Globals.szStateDir) ?
5343 *(char **)(&Globals.szStateDir) : ""));
5344 else
5345 return(lp_string(*(char **)(&Globals.szLockDir) ?
5346 *(char **)(&Globals.szLockDir) : ""));
5348 char *lp_cachedir(void) {
5349 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5350 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5351 return(lp_string(*(char **)(&Globals.szCacheDir) ?
5352 *(char **)(&Globals.szCacheDir) : ""));
5353 else
5354 return(lp_string(*(char **)(&Globals.szLockDir) ?
5355 *(char **)(&Globals.szLockDir) : ""));
5357 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
5358 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
5359 FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
5360 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
5361 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
5362 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
5363 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
5364 FN_GLOBAL_STRING(lp_perfcount_module, &Globals.szSMBPerfcountModule)
5365 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
5366 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
5367 FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
5368 FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
5369 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
5370 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
5371 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
5372 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
5373 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
5374 FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
5375 FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
5376 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
5377 FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
5378 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
5379 FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
5380 FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
5381 FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
5382 FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
5383 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
5384 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
5385 FN_GLOBAL_BOOL(lp_nmbd_bind_explicit_broadcast, &Globals.bNmbdBindExplicitBroadcast)
5386 FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
5387 FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
5388 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
5389 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
5390 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
5391 /* FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
5392 * lp_passdb_backend() should be replace by the this macro again after
5393 * some releases.
5394 * */
5395 const char *lp_passdb_backend(void)
5397 char *delim, *quote;
5399 delim = strchr( Globals.szPassdbBackend, ' ');
5400 /* no space at all */
5401 if (delim == NULL) {
5402 goto out;
5405 quote = strchr(Globals.szPassdbBackend, '"');
5406 /* no quote char or non in the first part */
5407 if (quote == NULL || quote > delim) {
5408 *delim = '\0';
5409 goto warn;
5412 quote = strchr(quote+1, '"');
5413 if (quote == NULL) {
5414 DEBUG(0, ("WARNING: Your 'passdb backend' configuration is invalid due to a missing second \" char.\n"));
5415 goto out;
5416 } else if (*(quote+1) == '\0') {
5417 /* space, fitting quote char, and one backend only */
5418 goto out;
5419 } else {
5420 /* terminate string after the fitting quote char */
5421 *(quote+1) = '\0';
5424 warn:
5425 DEBUG(0, ("WARNING: Your 'passdb backend' configuration includes multiple backends. This\n"
5426 "is deprecated since Samba 3.0.23. Please check WHATSNEW.txt or the section 'Passdb\n"
5427 "Changes' from the ChangeNotes as part of the Samba HOWTO collection. Only the first\n"
5428 "backend (%s) is used. The rest is ignored.\n", Globals.szPassdbBackend));
5430 out:
5431 return Globals.szPassdbBackend;
5433 FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
5434 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
5435 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
5436 FN_GLOBAL_STRING(lp_renameuser_script, &Globals.szRenameUserScript)
5437 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
5439 FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
5440 FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
5441 FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
5442 FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
5443 FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
5444 FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
5446 FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
5448 FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
5449 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
5450 FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
5452 FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
5454 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
5455 FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
5456 FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
5457 FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
5458 FN_GLOBAL_INTEGER(lp_acl_compatibility, &Globals.iAclCompat)
5459 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
5460 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
5461 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
5462 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
5463 FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
5464 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups)
5465 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets)
5466 FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon)
5467 FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames)
5468 FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
5469 FN_GLOBAL_BOOL(lp_create_krb5_conf, &Globals.bCreateKrb5Conf)
5471 FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
5472 FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)
5473 FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
5474 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
5475 FN_GLOBAL_INTEGER(lp_keepalive, &Globals.iKeepalive)
5476 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit)
5478 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
5479 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
5480 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
5481 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, &Globals.ldap_ssl_ads)
5482 FN_GLOBAL_INTEGER(lp_ldap_deref, &Globals.ldap_deref)
5483 FN_GLOBAL_INTEGER(lp_ldap_follow_referral, &Globals.ldap_follow_referral)
5484 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
5485 FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
5486 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
5487 FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
5488 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, &Globals.ldap_connection_timeout)
5489 FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
5490 FN_GLOBAL_INTEGER(lp_ldap_debug_level, &Globals.ldap_debug_level)
5491 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, &Globals.ldap_debug_threshold)
5492 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
5493 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
5494 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
5495 FN_GLOBAL_STRING(lp_usershare_path, &Globals.szUsersharePath)
5496 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, &Globals.szUsersharePrefixAllowList)
5497 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, &Globals.szUsersharePrefixDenyList)
5499 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
5501 FN_GLOBAL_BOOL(lp_registry_shares, &Globals.bRegistryShares)
5502 FN_GLOBAL_BOOL(lp_usershare_allow_guests, &Globals.bUsershareAllowGuests)
5503 FN_GLOBAL_BOOL(lp_usershare_owner_only, &Globals.bUsershareOwnerOnly)
5504 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
5505 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
5506 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
5507 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
5508 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
5509 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
5510 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
5511 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
5512 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
5513 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, &Globals.szInitLogonDelayedHosts)
5514 FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
5515 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
5516 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
5517 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
5518 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
5519 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
5520 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
5521 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
5522 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
5523 FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
5524 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
5525 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
5526 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
5527 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
5528 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
5529 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
5530 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
5531 FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
5532 FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
5533 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
5534 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
5535 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
5536 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
5537 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
5538 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
5539 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
5540 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
5541 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
5542 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
5543 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
5544 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
5545 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
5546 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, &Globals.bMapUntrustedToDomain)
5547 FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
5548 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
5549 FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
5550 FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
5551 FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
5552 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
5553 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
5554 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
5555 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
5556 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
5557 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
5558 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
5559 FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
5560 FN_GLOBAL_BOOL(lp_client_use_spnego_principal, &Globals.client_use_spnego_principal)
5561 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
5562 FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
5563 FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
5564 FN_GLOBAL_STRING(lp_dedicated_keytab_file, &Globals.szDedicatedKeytabFile)
5565 FN_GLOBAL_INTEGER(lp_kerberos_method, &Globals.iKerberosMethod)
5566 FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
5567 FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
5568 FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport)
5569 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
5570 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
5571 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
5572 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
5573 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
5574 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
5575 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, &Globals.open_files_db_hash_size)
5576 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
5577 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
5578 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
5579 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
5580 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
5581 FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
5582 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
5583 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
5584 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
5585 FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
5586 FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
5587 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
5588 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
5589 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
5590 FN_GLOBAL_BOOL(_lp_disable_spoolss, &Globals.bDisableSpoolss)
5591 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
5592 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
5593 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
5594 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
5595 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
5596 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
5597 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
5598 FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
5599 FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
5600 FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
5601 FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
5603 FN_LOCAL_STRING(lp_preexec, szPreExec)
5604 FN_LOCAL_STRING(lp_postexec, szPostExec)
5605 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
5606 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
5607 FN_LOCAL_STRING(lp_servicename, szService)
5608 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
5609 FN_LOCAL_STRING(lp_pathname, szPath)
5610 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
5611 FN_LOCAL_STRING(lp_username, szUsername)
5612 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
5613 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
5614 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
5615 FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
5616 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
5617 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
5618 int lp_cups_encrypt(void)
5620 int result = 0;
5621 #ifdef HAVE_HTTPCONNECTENCRYPT
5622 switch (Globals.CupsEncrypt) {
5623 case Auto:
5624 result = HTTP_ENCRYPT_REQUIRED;
5625 break;
5626 case True:
5627 result = HTTP_ENCRYPT_ALWAYS;
5628 break;
5629 case False:
5630 result = HTTP_ENCRYPT_NEVER;
5631 break;
5633 #endif
5634 return result;
5636 FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
5637 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
5638 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
5639 FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
5640 FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
5641 FN_GLOBAL_INTEGER(lp_ctdb_timeout, &Globals.ctdb_timeout)
5642 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
5643 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
5644 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
5645 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
5646 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
5647 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
5648 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
5649 static FN_LOCAL_STRING(_lp_printername, szPrintername)
5650 FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
5651 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
5652 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
5653 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
5654 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
5655 FN_LOCAL_STRING(lp_comment, comment)
5656 FN_LOCAL_STRING(lp_force_user, force_user)
5657 FN_LOCAL_STRING(lp_force_group, force_group)
5658 FN_LOCAL_LIST(lp_readlist, readlist)
5659 FN_LOCAL_LIST(lp_writelist, writelist)
5660 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
5661 FN_LOCAL_STRING(lp_fstype, fstype)
5662 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
5663 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
5664 static FN_LOCAL_STRING(lp_volume, volume)
5665 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
5666 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
5667 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
5668 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
5669 FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
5670 FN_LOCAL_STRING(lp_dfree_command, szDfree)
5671 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
5672 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
5673 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
5674 FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
5675 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
5676 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
5677 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
5678 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
5679 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
5680 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
5681 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
5682 FN_LOCAL_BOOL(lp_access_based_share_enum, bAccessBasedShareEnum)
5683 FN_LOCAL_BOOL(lp_readonly, bRead_only)
5684 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
5685 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
5686 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
5687 FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
5688 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
5689 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
5690 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
5691 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
5692 FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
5693 FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
5694 FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
5695 FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
5696 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
5697 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
5698 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
5699 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
5700 FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames)
5701 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
5702 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
5703 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
5704 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
5705 FN_LOCAL_BOOL(lp_map_system, bMap_system)
5706 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
5707 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
5708 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
5709 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
5710 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
5711 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
5712 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
5713 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
5714 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
5715 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
5716 FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
5717 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
5718 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
5719 FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
5720 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
5721 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
5722 FN_LOCAL_BOOL(lp_ea_support, bEASupport)
5723 FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
5724 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
5725 FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
5726 FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
5727 FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
5728 FN_LOCAL_BOOL(lp_acl_group_control, bAclGroupControl)
5729 FN_LOCAL_BOOL(lp_acl_map_full_control, bAclMapFullControl)
5730 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
5731 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
5732 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
5733 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
5734 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
5735 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
5736 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
5737 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
5738 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
5739 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
5740 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
5741 FN_LOCAL_INTEGER(lp_printing, iPrinting)
5742 FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
5743 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
5744 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
5745 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
5746 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
5747 FN_LOCAL_INTEGER(lp_dfree_cache_time, iDfreeCacheTime)
5748 FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
5749 FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
5750 FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
5751 FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
5752 FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
5753 FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
5754 FN_LOCAL_CHAR(lp_magicchar, magic_char)
5755 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
5756 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
5757 FN_GLOBAL_INTEGER(lp_winbind_max_clients, &Globals.winbind_max_clients)
5758 FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
5759 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
5760 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
5761 FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
5762 FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
5763 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
5765 /* local prototypes */
5767 static int map_parameter(const char *pszParmName);
5768 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5769 static const char *get_boolean(bool bool_value);
5770 static int getservicebyname(const char *pszServiceName,
5771 struct service *pserviceDest);
5772 static void copy_service(struct service *pserviceDest,
5773 struct service *pserviceSource,
5774 struct bitmap *pcopymapDest);
5775 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5776 void *userdata);
5777 static bool do_section(const char *pszSectionName, void *userdata);
5778 static void init_copymap(struct service *pservice);
5779 static bool hash_a_service(const char *name, int number);
5780 static void free_service_byindex(int iService);
5781 static void free_param_opts(struct param_opt_struct **popts);
5782 static char * canonicalize_servicename(const char *name);
5783 static void show_parameter(int parmIndex);
5784 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5787 * This is a helper function for parametrical options support. It returns a
5788 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5789 * parametrical functions are quite simple
5791 static struct param_opt_struct *get_parametrics(int snum, const char *type,
5792 const char *option)
5794 bool global_section = False;
5795 char* param_key;
5796 struct param_opt_struct *data;
5798 if (snum >= iNumServices) return NULL;
5800 if (snum < 0) {
5801 data = Globals.param_opt;
5802 global_section = True;
5803 } else {
5804 data = ServicePtrs[snum]->param_opt;
5807 if (asprintf(&param_key, "%s:%s", type, option) == -1) {
5808 DEBUG(0,("asprintf failed!\n"));
5809 return NULL;
5812 while (data) {
5813 if (strwicmp(data->key, param_key) == 0) {
5814 string_free(&param_key);
5815 return data;
5817 data = data->next;
5820 if (!global_section) {
5821 /* Try to fetch the same option but from globals */
5822 /* but only if we are not already working with Globals */
5823 data = Globals.param_opt;
5824 while (data) {
5825 if (strwicmp(data->key, param_key) == 0) {
5826 string_free(&param_key);
5827 return data;
5829 data = data->next;
5833 string_free(&param_key);
5835 return NULL;
5839 #define MISSING_PARAMETER(name) \
5840 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5842 /*******************************************************************
5843 convenience routine to return int parameters.
5844 ********************************************************************/
5845 static int lp_int(const char *s)
5848 if (!s || !*s) {
5849 MISSING_PARAMETER(lp_int);
5850 return (-1);
5853 return (int)strtol(s, NULL, 0);
5856 /*******************************************************************
5857 convenience routine to return unsigned long parameters.
5858 ********************************************************************/
5859 static unsigned long lp_ulong(const char *s)
5862 if (!s || !*s) {
5863 MISSING_PARAMETER(lp_ulong);
5864 return (0);
5867 return strtoul(s, NULL, 0);
5870 /*******************************************************************
5871 convenience routine to return boolean parameters.
5872 ********************************************************************/
5873 static bool lp_bool(const char *s)
5875 bool ret = False;
5877 if (!s || !*s) {
5878 MISSING_PARAMETER(lp_bool);
5879 return False;
5882 if (!set_boolean(s, &ret)) {
5883 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5884 return False;
5887 return ret;
5890 /*******************************************************************
5891 convenience routine to return enum parameters.
5892 ********************************************************************/
5893 static int lp_enum(const char *s,const struct enum_list *_enum)
5895 int i;
5897 if (!s || !*s || !_enum) {
5898 MISSING_PARAMETER(lp_enum);
5899 return (-1);
5902 for (i=0; _enum[i].name; i++) {
5903 if (strequal(_enum[i].name,s))
5904 return _enum[i].value;
5907 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5908 return (-1);
5911 #undef MISSING_PARAMETER
5913 /* DO NOT USE lp_parm_string ANYMORE!!!!
5914 * use lp_parm_const_string or lp_parm_talloc_string
5916 * lp_parm_string is only used to let old modules find this symbol
5918 #undef lp_parm_string
5919 char *lp_parm_string(const char *servicename, const char *type, const char *option);
5920 char *lp_parm_string(const char *servicename, const char *type, const char *option)
5922 return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
5925 /* Return parametric option from a given service. Type is a part of option before ':' */
5926 /* Parametric option has following syntax: 'Type: option = value' */
5927 /* the returned value is talloced on the talloc_tos() */
5928 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5930 struct param_opt_struct *data = get_parametrics(snum, type, option);
5932 if (data == NULL||data->value==NULL) {
5933 if (def) {
5934 return lp_string(def);
5935 } else {
5936 return NULL;
5940 return lp_string(data->value);
5943 /* Return parametric option from a given service. Type is a part of option before ':' */
5944 /* Parametric option has following syntax: 'Type: option = value' */
5945 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5947 struct param_opt_struct *data = get_parametrics(snum, type, option);
5949 if (data == NULL||data->value==NULL)
5950 return def;
5952 return data->value;
5955 /* Return parametric option from a given service. Type is a part of option before ':' */
5956 /* Parametric option has following syntax: 'Type: option = value' */
5958 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5960 struct param_opt_struct *data = get_parametrics(snum, type, option);
5962 if (data == NULL||data->value==NULL)
5963 return (const char **)def;
5965 if (data->list==NULL) {
5966 data->list = str_list_make_v3(talloc_autofree_context(), data->value, NULL);
5969 return (const char **)data->list;
5972 /* Return parametric option from a given service. Type is a part of option before ':' */
5973 /* Parametric option has following syntax: 'Type: option = value' */
5975 int lp_parm_int(int snum, const char *type, const char *option, int def)
5977 struct param_opt_struct *data = get_parametrics(snum, type, option);
5979 if (data && data->value && *data->value)
5980 return lp_int(data->value);
5982 return def;
5985 /* Return parametric option from a given service. Type is a part of option before ':' */
5986 /* Parametric option has following syntax: 'Type: option = value' */
5988 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5990 struct param_opt_struct *data = get_parametrics(snum, type, option);
5992 if (data && data->value && *data->value)
5993 return lp_ulong(data->value);
5995 return def;
5998 /* Return parametric option from a given service. Type is a part of option before ':' */
5999 /* Parametric option has following syntax: 'Type: option = value' */
6001 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
6003 struct param_opt_struct *data = get_parametrics(snum, type, option);
6005 if (data && data->value && *data->value)
6006 return lp_bool(data->value);
6008 return def;
6011 /* Return parametric option from a given service. Type is a part of option before ':' */
6012 /* Parametric option has following syntax: 'Type: option = value' */
6014 int lp_parm_enum(int snum, const char *type, const char *option,
6015 const struct enum_list *_enum, int def)
6017 struct param_opt_struct *data = get_parametrics(snum, type, option);
6019 if (data && data->value && *data->value && _enum)
6020 return lp_enum(data->value, _enum);
6022 return def;
6026 /***************************************************************************
6027 Initialise a service to the defaults.
6028 ***************************************************************************/
6030 static void init_service(struct service *pservice)
6032 memset((char *)pservice, '\0', sizeof(struct service));
6033 copy_service(pservice, &sDefault, NULL);
6038 * free a param_opts structure.
6039 * param_opts handling should be moved to talloc;
6040 * then this whole functions reduces to a TALLOC_FREE().
6043 static void free_param_opts(struct param_opt_struct **popts)
6045 struct param_opt_struct *opt, *next_opt;
6047 if (popts == NULL) {
6048 return;
6051 if (*popts != NULL) {
6052 DEBUG(5, ("Freeing parametrics:\n"));
6054 opt = *popts;
6055 while (opt != NULL) {
6056 string_free(&opt->key);
6057 string_free(&opt->value);
6058 TALLOC_FREE(opt->list);
6059 next_opt = opt->next;
6060 SAFE_FREE(opt);
6061 opt = next_opt;
6063 *popts = NULL;
6066 /***************************************************************************
6067 Free the dynamically allocated parts of a service struct.
6068 ***************************************************************************/
6070 static void free_service(struct service *pservice)
6072 if (!pservice)
6073 return;
6075 if (pservice->szService)
6076 DEBUG(5, ("free_service: Freeing service %s\n",
6077 pservice->szService));
6079 free_parameters(pservice);
6081 string_free(&pservice->szService);
6082 bitmap_free(pservice->copymap);
6084 free_param_opts(&pservice->param_opt);
6086 ZERO_STRUCTP(pservice);
6090 /***************************************************************************
6091 remove a service indexed in the ServicePtrs array from the ServiceHash
6092 and free the dynamically allocated parts
6093 ***************************************************************************/
6095 static void free_service_byindex(int idx)
6097 if ( !LP_SNUM_OK(idx) )
6098 return;
6100 ServicePtrs[idx]->valid = False;
6101 invalid_services[num_invalid_services++] = idx;
6103 /* we have to cleanup the hash record */
6105 if (ServicePtrs[idx]->szService) {
6106 char *canon_name = canonicalize_servicename(
6107 ServicePtrs[idx]->szService );
6109 dbwrap_delete_bystring(ServiceHash, canon_name );
6110 TALLOC_FREE(canon_name);
6113 free_service(ServicePtrs[idx]);
6116 /***************************************************************************
6117 Add a new service to the services array initialising it with the given
6118 service.
6119 ***************************************************************************/
6121 static int add_a_service(const struct service *pservice, const char *name)
6123 int i;
6124 struct service tservice;
6125 int num_to_alloc = iNumServices + 1;
6127 tservice = *pservice;
6129 /* it might already exist */
6130 if (name) {
6131 i = getservicebyname(name, NULL);
6132 if (i >= 0) {
6133 /* Clean all parametric options for service */
6134 /* They will be added during parsing again */
6135 free_param_opts(&ServicePtrs[i]->param_opt);
6136 return (i);
6140 /* find an invalid one */
6141 i = iNumServices;
6142 if (num_invalid_services > 0) {
6143 i = invalid_services[--num_invalid_services];
6146 /* if not, then create one */
6147 if (i == iNumServices) {
6148 struct service **tsp;
6149 int *tinvalid;
6151 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
6152 if (tsp == NULL) {
6153 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
6154 return (-1);
6156 ServicePtrs = tsp;
6157 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct service);
6158 if (!ServicePtrs[iNumServices]) {
6159 DEBUG(0,("add_a_service: out of memory!\n"));
6160 return (-1);
6162 iNumServices++;
6164 /* enlarge invalid_services here for now... */
6165 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
6166 num_to_alloc);
6167 if (tinvalid == NULL) {
6168 DEBUG(0,("add_a_service: failed to enlarge "
6169 "invalid_services!\n"));
6170 return (-1);
6172 invalid_services = tinvalid;
6173 } else {
6174 free_service_byindex(i);
6177 ServicePtrs[i]->valid = True;
6179 init_service(ServicePtrs[i]);
6180 copy_service(ServicePtrs[i], &tservice, NULL);
6181 if (name)
6182 string_set(&ServicePtrs[i]->szService, name);
6184 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
6185 i, ServicePtrs[i]->szService));
6187 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
6188 return (-1);
6191 return (i);
6194 /***************************************************************************
6195 Convert a string to uppercase and remove whitespaces.
6196 ***************************************************************************/
6198 static char *canonicalize_servicename(const char *src)
6200 char *result;
6202 if ( !src ) {
6203 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
6204 return NULL;
6207 result = talloc_strdup(talloc_tos(), src);
6208 SMB_ASSERT(result != NULL);
6210 strlower_m(result);
6211 return result;
6214 /***************************************************************************
6215 Add a name/index pair for the services array to the hash table.
6216 ***************************************************************************/
6218 static bool hash_a_service(const char *name, int idx)
6220 char *canon_name;
6222 if ( !ServiceHash ) {
6223 DEBUG(10,("hash_a_service: creating servicehash\n"));
6224 ServiceHash = db_open_rbt(NULL);
6225 if ( !ServiceHash ) {
6226 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
6227 return False;
6231 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
6232 idx, name));
6234 canon_name = canonicalize_servicename( name );
6236 dbwrap_store_bystring(ServiceHash, canon_name,
6237 make_tdb_data((uint8 *)&idx, sizeof(idx)),
6238 TDB_REPLACE);
6240 TALLOC_FREE(canon_name);
6242 return True;
6245 /***************************************************************************
6246 Add a new home service, with the specified home directory, defaults coming
6247 from service ifrom.
6248 ***************************************************************************/
6250 bool lp_add_home(const char *pszHomename, int iDefaultService,
6251 const char *user, const char *pszHomedir)
6253 int i;
6255 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
6256 pszHomedir[0] == '\0') {
6257 return false;
6260 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
6262 if (i < 0)
6263 return (False);
6265 if (!(*(ServicePtrs[iDefaultService]->szPath))
6266 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
6267 string_set(&ServicePtrs[i]->szPath, pszHomedir);
6270 if (!(*(ServicePtrs[i]->comment))) {
6271 char *comment = NULL;
6272 if (asprintf(&comment, "Home directory of %s", user) < 0) {
6273 return false;
6275 string_set(&ServicePtrs[i]->comment, comment);
6276 SAFE_FREE(comment);
6279 /* set the browseable flag from the global default */
6281 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6282 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
6284 ServicePtrs[i]->autoloaded = True;
6286 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
6287 user, ServicePtrs[i]->szPath ));
6289 return (True);
6292 /***************************************************************************
6293 Add a new service, based on an old one.
6294 ***************************************************************************/
6296 int lp_add_service(const char *pszService, int iDefaultService)
6298 if (iDefaultService < 0) {
6299 return add_a_service(&sDefault, pszService);
6302 return (add_a_service(ServicePtrs[iDefaultService], pszService));
6305 /***************************************************************************
6306 Add the IPC service.
6307 ***************************************************************************/
6309 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
6311 char *comment = NULL;
6312 int i = add_a_service(&sDefault, ipc_name);
6314 if (i < 0)
6315 return (False);
6317 if (asprintf(&comment, "IPC Service (%s)",
6318 Globals.szServerString) < 0) {
6319 return (False);
6322 string_set(&ServicePtrs[i]->szPath, tmpdir());
6323 string_set(&ServicePtrs[i]->szUsername, "");
6324 string_set(&ServicePtrs[i]->comment, comment);
6325 string_set(&ServicePtrs[i]->fstype, "IPC");
6326 ServicePtrs[i]->iMaxConnections = 0;
6327 ServicePtrs[i]->bAvailable = True;
6328 ServicePtrs[i]->bRead_only = True;
6329 ServicePtrs[i]->bGuest_only = False;
6330 ServicePtrs[i]->bAdministrative_share = True;
6331 ServicePtrs[i]->bGuest_ok = guest_ok;
6332 ServicePtrs[i]->bPrint_ok = False;
6333 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6335 DEBUG(3, ("adding IPC service\n"));
6337 SAFE_FREE(comment);
6338 return (True);
6341 /***************************************************************************
6342 Add a new printer service, with defaults coming from service iFrom.
6343 ***************************************************************************/
6345 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
6347 const char *comment = "From Printcap";
6348 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6350 if (i < 0)
6351 return (False);
6353 /* note that we do NOT default the availability flag to True - */
6354 /* we take it from the default service passed. This allows all */
6355 /* dynamic printers to be disabled by disabling the [printers] */
6356 /* entry (if/when the 'available' keyword is implemented!). */
6358 /* the printer name is set to the service name. */
6359 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6360 string_set(&ServicePtrs[i]->comment, comment);
6362 /* set the browseable flag from the gloabl default */
6363 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6365 /* Printers cannot be read_only. */
6366 ServicePtrs[i]->bRead_only = False;
6367 /* No share modes on printer services. */
6368 ServicePtrs[i]->bShareModes = False;
6369 /* No oplocks on printer services. */
6370 ServicePtrs[i]->bOpLocks = False;
6371 /* Printer services must be printable. */
6372 ServicePtrs[i]->bPrint_ok = True;
6374 DEBUG(3, ("adding printer service %s\n", pszPrintername));
6376 return (True);
6380 /***************************************************************************
6381 Check whether the given parameter name is valid.
6382 Parametric options (names containing a colon) are considered valid.
6383 ***************************************************************************/
6385 bool lp_parameter_is_valid(const char *pszParmName)
6387 return ((map_parameter(pszParmName) != -1) ||
6388 (strchr(pszParmName, ':') != NULL));
6391 /***************************************************************************
6392 Check whether the given name is the name of a global parameter.
6393 Returns True for strings belonging to parameters of class
6394 P_GLOBAL, False for all other strings, also for parametric options
6395 and strings not belonging to any option.
6396 ***************************************************************************/
6398 bool lp_parameter_is_global(const char *pszParmName)
6400 int num = map_parameter(pszParmName);
6402 if (num >= 0) {
6403 return (parm_table[num].p_class == P_GLOBAL);
6406 return False;
6409 /**************************************************************************
6410 Check whether the given name is the canonical name of a parameter.
6411 Returns False if it is not a valid parameter Name.
6412 For parametric options, True is returned.
6413 **************************************************************************/
6415 bool lp_parameter_is_canonical(const char *parm_name)
6417 if (!lp_parameter_is_valid(parm_name)) {
6418 return False;
6421 return (map_parameter(parm_name) ==
6422 map_parameter_canonical(parm_name, NULL));
6425 /**************************************************************************
6426 Determine the canonical name for a parameter.
6427 Indicate when it is an inverse (boolean) synonym instead of a
6428 "usual" synonym.
6429 **************************************************************************/
6431 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6432 bool *inverse)
6434 int num;
6436 if (!lp_parameter_is_valid(parm_name)) {
6437 *canon_parm = NULL;
6438 return False;
6441 num = map_parameter_canonical(parm_name, inverse);
6442 if (num < 0) {
6443 /* parametric option */
6444 *canon_parm = parm_name;
6445 } else {
6446 *canon_parm = parm_table[num].label;
6449 return True;
6453 /**************************************************************************
6454 Determine the canonical name for a parameter.
6455 Turn the value given into the inverse boolean expression when
6456 the synonym is an invers boolean synonym.
6458 Return True if parm_name is a valid parameter name and
6459 in case it is an invers boolean synonym, if the val string could
6460 successfully be converted to the reverse bool.
6461 Return false in all other cases.
6462 **************************************************************************/
6464 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6465 const char *val,
6466 const char **canon_parm,
6467 const char **canon_val)
6469 int num;
6470 bool inverse;
6472 if (!lp_parameter_is_valid(parm_name)) {
6473 *canon_parm = NULL;
6474 *canon_val = NULL;
6475 return False;
6478 num = map_parameter_canonical(parm_name, &inverse);
6479 if (num < 0) {
6480 /* parametric option */
6481 *canon_parm = parm_name;
6482 *canon_val = val;
6483 } else {
6484 *canon_parm = parm_table[num].label;
6485 if (inverse) {
6486 if (!lp_invert_boolean(val, canon_val)) {
6487 *canon_val = NULL;
6488 return False;
6490 } else {
6491 *canon_val = val;
6495 return True;
6498 /***************************************************************************
6499 Map a parameter's string representation to something we can use.
6500 Returns False if the parameter string is not recognised, else TRUE.
6501 ***************************************************************************/
6503 static int map_parameter(const char *pszParmName)
6505 int iIndex;
6507 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6508 return (-1);
6510 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6511 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6512 return (iIndex);
6514 /* Warn only if it isn't parametric option */
6515 if (strchr(pszParmName, ':') == NULL)
6516 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6517 /* We do return 'fail' for parametric options as well because they are
6518 stored in different storage
6520 return (-1);
6523 /***************************************************************************
6524 Map a parameter's string representation to the index of the canonical
6525 form of the parameter (it might be a synonym).
6526 Returns -1 if the parameter string is not recognised.
6527 ***************************************************************************/
6529 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6531 int parm_num, canon_num;
6532 bool loc_inverse = False;
6534 parm_num = map_parameter(pszParmName);
6535 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6536 /* invalid, parametric or no canidate for synonyms ... */
6537 goto done;
6540 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6541 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6542 parm_num = canon_num;
6543 goto done;
6547 done:
6548 if (inverse != NULL) {
6549 *inverse = loc_inverse;
6551 return parm_num;
6554 /***************************************************************************
6555 return true if parameter number parm1 is a synonym of parameter
6556 number parm2 (parm2 being the principal name).
6557 set inverse to True if parm1 is P_BOOLREV and parm2 is P_BOOL,
6558 False otherwise.
6559 ***************************************************************************/
6561 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6563 if ((parm_table[parm1].ptr == parm_table[parm2].ptr) &&
6564 (parm_table[parm1].flags & FLAG_HIDE) &&
6565 !(parm_table[parm2].flags & FLAG_HIDE))
6567 if (inverse != NULL) {
6568 if ((parm_table[parm1].type == P_BOOLREV) &&
6569 (parm_table[parm2].type == P_BOOL))
6571 *inverse = True;
6572 } else {
6573 *inverse = False;
6576 return True;
6578 return False;
6581 /***************************************************************************
6582 Show one parameter's name, type, [values,] and flags.
6583 (helper functions for show_parameter_list)
6584 ***************************************************************************/
6586 static void show_parameter(int parmIndex)
6588 int enumIndex, flagIndex;
6589 int parmIndex2;
6590 bool hadFlag;
6591 bool hadSyn;
6592 bool inverse;
6593 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6594 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6595 "P_ENUM", "P_SEP"};
6596 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6597 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6598 FLAG_HIDE, FLAG_DOS_STRING};
6599 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6600 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6601 "FLAG_DEPRECATED", "FLAG_HIDE", "FLAG_DOS_STRING", NULL};
6603 printf("%s=%s", parm_table[parmIndex].label,
6604 type[parm_table[parmIndex].type]);
6605 if (parm_table[parmIndex].type == P_ENUM) {
6606 printf(",");
6607 for (enumIndex=0;
6608 parm_table[parmIndex].enum_list[enumIndex].name;
6609 enumIndex++)
6611 printf("%s%s",
6612 enumIndex ? "|" : "",
6613 parm_table[parmIndex].enum_list[enumIndex].name);
6616 printf(",");
6617 hadFlag = False;
6618 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6619 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6620 printf("%s%s",
6621 hadFlag ? "|" : "",
6622 flag_names[flagIndex]);
6623 hadFlag = True;
6627 /* output synonyms */
6628 hadSyn = False;
6629 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6630 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6631 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6632 parm_table[parmIndex2].label);
6633 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6634 if (!hadSyn) {
6635 printf(" (synonyms: ");
6636 hadSyn = True;
6637 } else {
6638 printf(", ");
6640 printf("%s%s", parm_table[parmIndex2].label,
6641 inverse ? "[i]" : "");
6644 if (hadSyn) {
6645 printf(")");
6648 printf("\n");
6651 /***************************************************************************
6652 Show all parameter's name, type, [values,] and flags.
6653 ***************************************************************************/
6655 void show_parameter_list(void)
6657 int classIndex, parmIndex;
6658 const char *section_names[] = { "local", "global", NULL};
6660 for (classIndex=0; section_names[classIndex]; classIndex++) {
6661 printf("[%s]\n", section_names[classIndex]);
6662 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6663 if (parm_table[parmIndex].p_class == classIndex) {
6664 show_parameter(parmIndex);
6670 /***************************************************************************
6671 Check if a given string correctly represents a boolean value.
6672 ***************************************************************************/
6674 bool lp_string_is_valid_boolean(const char *parm_value)
6676 return set_boolean(parm_value, NULL);
6679 /***************************************************************************
6680 Get the standard string representation of a boolean value ("yes" or "no")
6681 ***************************************************************************/
6683 static const char *get_boolean(bool bool_value)
6685 static const char *yes_str = "yes";
6686 static const char *no_str = "no";
6688 return (bool_value ? yes_str : no_str);
6691 /***************************************************************************
6692 Provide the string of the negated boolean value associated to the boolean
6693 given as a string. Returns False if the passed string does not correctly
6694 represent a boolean.
6695 ***************************************************************************/
6697 bool lp_invert_boolean(const char *str, const char **inverse_str)
6699 bool val;
6701 if (!set_boolean(str, &val)) {
6702 return False;
6705 *inverse_str = get_boolean(!val);
6706 return True;
6709 /***************************************************************************
6710 Provide the canonical string representation of a boolean value given
6711 as a string. Return True on success, False if the string given does
6712 not correctly represent a boolean.
6713 ***************************************************************************/
6715 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6717 bool val;
6719 if (!set_boolean(str, &val)) {
6720 return False;
6723 *canon_str = get_boolean(val);
6724 return True;
6727 /***************************************************************************
6728 Find a service by name. Otherwise works like get_service.
6729 ***************************************************************************/
6731 static int getservicebyname(const char *pszServiceName, struct service *pserviceDest)
6733 int iService = -1;
6734 char *canon_name;
6735 TDB_DATA data;
6737 if (ServiceHash == NULL) {
6738 return -1;
6741 canon_name = canonicalize_servicename(pszServiceName);
6743 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
6745 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
6746 iService = *(int *)data.dptr;
6749 TALLOC_FREE(canon_name);
6751 if ((iService != -1) && (LP_SNUM_OK(iService))
6752 && (pserviceDest != NULL)) {
6753 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6756 return (iService);
6759 /***************************************************************************
6760 Copy a service structure to another.
6761 If pcopymapDest is NULL then copy all fields
6762 ***************************************************************************/
6765 * Add a parametric option to a param_opt_struct,
6766 * replacing old value, if already present.
6768 static void set_param_opt(struct param_opt_struct **opt_list,
6769 const char *opt_name,
6770 const char *opt_value)
6772 struct param_opt_struct *new_opt, *opt;
6773 bool not_added;
6775 if (opt_list == NULL) {
6776 return;
6779 opt = *opt_list;
6780 not_added = true;
6782 /* Traverse destination */
6783 while (opt) {
6784 /* If we already have same option, override it */
6785 if (strwicmp(opt->key, opt_name) == 0) {
6786 string_free(&opt->value);
6787 TALLOC_FREE(opt->list);
6788 opt->value = SMB_STRDUP(opt_value);
6789 not_added = false;
6790 break;
6792 opt = opt->next;
6794 if (not_added) {
6795 new_opt = SMB_XMALLOC_P(struct param_opt_struct);
6796 new_opt->key = SMB_STRDUP(opt_name);
6797 new_opt->value = SMB_STRDUP(opt_value);
6798 new_opt->list = NULL;
6799 DLIST_ADD(*opt_list, new_opt);
6803 static void copy_service(struct service *pserviceDest, struct service *pserviceSource,
6804 struct bitmap *pcopymapDest)
6806 int i;
6807 bool bcopyall = (pcopymapDest == NULL);
6808 struct param_opt_struct *data;
6810 for (i = 0; parm_table[i].label; i++)
6811 if (parm_table[i].ptr && parm_table[i].p_class == P_LOCAL &&
6812 (bcopyall || bitmap_query(pcopymapDest,i))) {
6813 void *def_ptr = parm_table[i].ptr;
6814 void *src_ptr =
6815 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
6816 &sDefault);
6817 void *dest_ptr =
6818 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
6819 &sDefault);
6821 switch (parm_table[i].type) {
6822 case P_BOOL:
6823 case P_BOOLREV:
6824 *(bool *)dest_ptr = *(bool *)src_ptr;
6825 break;
6827 case P_INTEGER:
6828 case P_ENUM:
6829 case P_OCTAL:
6830 *(int *)dest_ptr = *(int *)src_ptr;
6831 break;
6833 case P_CHAR:
6834 *(char *)dest_ptr = *(char *)src_ptr;
6835 break;
6837 case P_STRING:
6838 string_set((char **)dest_ptr,
6839 *(char **)src_ptr);
6840 break;
6842 case P_USTRING:
6843 string_set((char **)dest_ptr,
6844 *(char **)src_ptr);
6845 strupper_m(*(char **)dest_ptr);
6846 break;
6847 case P_LIST:
6848 TALLOC_FREE(*((char ***)dest_ptr));
6849 *((char ***)dest_ptr) = str_list_copy(NULL,
6850 *(const char ***)src_ptr);
6851 break;
6852 default:
6853 break;
6857 if (bcopyall) {
6858 init_copymap(pserviceDest);
6859 if (pserviceSource->copymap)
6860 bitmap_copy(pserviceDest->copymap,
6861 pserviceSource->copymap);
6864 data = pserviceSource->param_opt;
6865 while (data) {
6866 set_param_opt(&pserviceDest->param_opt, data->key, data->value);
6867 data = data->next;
6871 /***************************************************************************
6872 Check a service for consistency. Return False if the service is in any way
6873 incomplete or faulty, else True.
6874 ***************************************************************************/
6876 bool service_ok(int iService)
6878 bool bRetval;
6880 bRetval = True;
6881 if (ServicePtrs[iService]->szService[0] == '\0') {
6882 DEBUG(0, ("The following message indicates an internal error:\n"));
6883 DEBUG(0, ("No service name in service entry.\n"));
6884 bRetval = False;
6887 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6888 /* I can't see why you'd want a non-printable printer service... */
6889 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6890 if (!ServicePtrs[iService]->bPrint_ok) {
6891 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6892 ServicePtrs[iService]->szService));
6893 ServicePtrs[iService]->bPrint_ok = True;
6895 /* [printers] service must also be non-browsable. */
6896 if (ServicePtrs[iService]->bBrowseable)
6897 ServicePtrs[iService]->bBrowseable = False;
6900 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6901 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6902 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6904 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6905 ServicePtrs[iService]->szService));
6906 ServicePtrs[iService]->bAvailable = False;
6909 /* If a service is flagged unavailable, log the fact at level 1. */
6910 if (!ServicePtrs[iService]->bAvailable)
6911 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6912 ServicePtrs[iService]->szService));
6914 return (bRetval);
6917 static struct smbconf_ctx *lp_smbconf_ctx(void)
6919 WERROR werr;
6920 static struct smbconf_ctx *conf_ctx = NULL;
6922 if (conf_ctx == NULL) {
6923 werr = smbconf_init(NULL, &conf_ctx, "registry:");
6924 if (!W_ERROR_IS_OK(werr)) {
6925 DEBUG(1, ("error initializing registry configuration: "
6926 "%s\n", win_errstr(werr)));
6927 conf_ctx = NULL;
6931 return conf_ctx;
6934 static bool process_smbconf_service(struct smbconf_service *service)
6936 uint32_t count;
6937 bool ret;
6939 if (service == NULL) {
6940 return false;
6943 ret = do_section(service->name, NULL);
6944 if (ret != true) {
6945 return false;
6947 for (count = 0; count < service->num_params; count++) {
6948 ret = do_parameter(service->param_names[count],
6949 service->param_values[count],
6950 NULL);
6951 if (ret != true) {
6952 return false;
6955 if (iServiceIndex >= 0) {
6956 return service_ok(iServiceIndex);
6958 return true;
6962 * load a service from registry and activate it
6964 bool process_registry_service(const char *service_name)
6966 WERROR werr;
6967 struct smbconf_service *service = NULL;
6968 TALLOC_CTX *mem_ctx = talloc_stackframe();
6969 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6970 bool ret = false;
6972 if (conf_ctx == NULL) {
6973 goto done;
6976 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6978 if (!smbconf_share_exists(conf_ctx, service_name)) {
6980 * Registry does not contain data for this service (yet),
6981 * but make sure lp_load doesn't return false.
6983 ret = true;
6984 goto done;
6987 werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6988 if (!W_ERROR_IS_OK(werr)) {
6989 goto done;
6992 ret = process_smbconf_service(service);
6993 if (!ret) {
6994 goto done;
6997 /* store the csn */
6998 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
7000 done:
7001 TALLOC_FREE(mem_ctx);
7002 return ret;
7006 * process_registry_globals
7008 static bool process_registry_globals(void)
7010 bool ret;
7012 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
7014 ret = do_parameter("registry shares", "yes", NULL);
7015 if (!ret) {
7016 return ret;
7019 return process_registry_service(GLOBAL_NAME);
7022 bool process_registry_shares(void)
7024 WERROR werr;
7025 uint32_t count;
7026 struct smbconf_service **service = NULL;
7027 uint32_t num_shares = 0;
7028 TALLOC_CTX *mem_ctx = talloc_stackframe();
7029 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7030 bool ret = false;
7032 if (conf_ctx == NULL) {
7033 goto done;
7036 werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
7037 if (!W_ERROR_IS_OK(werr)) {
7038 goto done;
7041 ret = true;
7043 for (count = 0; count < num_shares; count++) {
7044 if (strequal(service[count]->name, GLOBAL_NAME)) {
7045 continue;
7047 ret = process_smbconf_service(service[count]);
7048 if (!ret) {
7049 goto done;
7053 /* store the csn */
7054 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
7056 done:
7057 TALLOC_FREE(mem_ctx);
7058 return ret;
7061 #define MAX_INCLUDE_DEPTH 100
7063 static uint8_t include_depth;
7065 static struct file_lists {
7066 struct file_lists *next;
7067 char *name;
7068 char *subfname;
7069 time_t modtime;
7070 } *file_lists = NULL;
7072 /*******************************************************************
7073 Keep a linked list of all config files so we know when one has changed
7074 it's date and needs to be reloaded.
7075 ********************************************************************/
7077 static void add_to_file_list(const char *fname, const char *subfname)
7079 struct file_lists *f = file_lists;
7081 while (f) {
7082 if (f->name && !strcmp(f->name, fname))
7083 break;
7084 f = f->next;
7087 if (!f) {
7088 f = SMB_MALLOC_P(struct file_lists);
7089 if (!f)
7090 return;
7091 f->next = file_lists;
7092 f->name = SMB_STRDUP(fname);
7093 if (!f->name) {
7094 SAFE_FREE(f);
7095 return;
7097 f->subfname = SMB_STRDUP(subfname);
7098 if (!f->subfname) {
7099 SAFE_FREE(f);
7100 return;
7102 file_lists = f;
7103 f->modtime = file_modtime(subfname);
7104 } else {
7105 time_t t = file_modtime(subfname);
7106 if (t)
7107 f->modtime = t;
7112 * Free the file lists
7114 static void free_file_list(void)
7116 struct file_lists *f;
7117 struct file_lists *next;
7119 f = file_lists;
7120 while( f ) {
7121 next = f->next;
7122 SAFE_FREE( f->name );
7123 SAFE_FREE( f->subfname );
7124 SAFE_FREE( f );
7125 f = next;
7127 file_lists = NULL;
7132 * Utility function for outsiders to check if we're running on registry.
7134 bool lp_config_backend_is_registry(void)
7136 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
7140 * Utility function to check if the config backend is FILE.
7142 bool lp_config_backend_is_file(void)
7144 return (lp_config_backend() == CONFIG_BACKEND_FILE);
7147 /*******************************************************************
7148 Check if a config file has changed date.
7149 ********************************************************************/
7151 bool lp_file_list_changed(void)
7153 struct file_lists *f = file_lists;
7155 DEBUG(6, ("lp_file_list_changed()\n"));
7157 while (f) {
7158 char *n2 = NULL;
7159 time_t mod_time;
7161 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
7162 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7164 if (conf_ctx == NULL) {
7165 return false;
7167 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
7168 NULL))
7170 DEBUGADD(6, ("registry config changed\n"));
7171 return true;
7173 } else {
7174 n2 = alloc_sub_basic(get_current_username(),
7175 current_user_info.domain,
7176 f->name);
7177 if (!n2) {
7178 return false;
7180 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
7181 f->name, n2, ctime(&f->modtime)));
7183 mod_time = file_modtime(n2);
7185 if (mod_time &&
7186 ((f->modtime != mod_time) ||
7187 (f->subfname == NULL) ||
7188 (strcmp(n2, f->subfname) != 0)))
7190 DEBUGADD(6,
7191 ("file %s modified: %s\n", n2,
7192 ctime(&mod_time)));
7193 f->modtime = mod_time;
7194 SAFE_FREE(f->subfname);
7195 f->subfname = n2; /* Passing ownership of
7196 return from alloc_sub_basic
7197 above. */
7198 return true;
7200 SAFE_FREE(n2);
7202 f = f->next;
7204 return (False);
7208 /***************************************************************************
7209 Run standard_sub_basic on netbios name... needed because global_myname
7210 is not accessed through any lp_ macro.
7211 Note: We must *NOT* use string_set() here as ptr points to global_myname.
7212 ***************************************************************************/
7214 static bool handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
7216 bool ret;
7217 char *netbios_name = alloc_sub_basic(get_current_username(),
7218 current_user_info.domain,
7219 pszParmValue);
7221 ret = set_global_myname(netbios_name);
7222 SAFE_FREE(netbios_name);
7223 string_set(&Globals.szNetbiosName,global_myname());
7225 DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
7226 global_myname()));
7228 return ret;
7231 static bool handle_charset(int snum, const char *pszParmValue, char **ptr)
7233 if (strcmp(*ptr, pszParmValue) != 0) {
7234 string_set(ptr, pszParmValue);
7235 init_iconv();
7237 return True;
7242 static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
7244 bool ret;
7246 ret = set_global_myworkgroup(pszParmValue);
7247 string_set(&Globals.szWorkgroup,lp_workgroup());
7249 return ret;
7252 static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
7254 bool ret;
7256 ret = set_global_scope(pszParmValue);
7257 string_set(&Globals.szNetbiosScope,global_scope());
7259 return ret;
7262 static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
7264 TALLOC_FREE(Globals.szNetbiosAliases);
7265 Globals.szNetbiosAliases = str_list_make_v3(talloc_autofree_context(), pszParmValue, NULL);
7266 return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
7269 /***************************************************************************
7270 Handle the include operation.
7271 ***************************************************************************/
7272 static bool bAllowIncludeRegistry = true;
7274 static bool handle_include(int snum, const char *pszParmValue, char **ptr)
7276 char *fname;
7278 if (include_depth >= MAX_INCLUDE_DEPTH) {
7279 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
7280 include_depth));
7281 return false;
7284 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
7285 if (!bAllowIncludeRegistry) {
7286 return true;
7288 if (bInGlobalSection) {
7289 bool ret;
7290 include_depth++;
7291 ret = process_registry_globals();
7292 include_depth--;
7293 return ret;
7294 } else {
7295 DEBUG(1, ("\"include = registry\" only effective "
7296 "in %s section\n", GLOBAL_NAME));
7297 return false;
7301 fname = alloc_sub_basic(get_current_username(),
7302 current_user_info.domain,
7303 pszParmValue);
7305 add_to_file_list(pszParmValue, fname);
7307 string_set(ptr, fname);
7309 if (file_exist(fname)) {
7310 bool ret;
7311 include_depth++;
7312 ret = pm_process(fname, do_section, do_parameter, NULL);
7313 include_depth--;
7314 SAFE_FREE(fname);
7315 return ret;
7318 DEBUG(2, ("Can't find include file %s\n", fname));
7319 SAFE_FREE(fname);
7320 return true;
7323 /***************************************************************************
7324 Handle the interpretation of the copy parameter.
7325 ***************************************************************************/
7327 static bool handle_copy(int snum, const char *pszParmValue, char **ptr)
7329 bool bRetval;
7330 int iTemp;
7331 struct service serviceTemp;
7333 string_set(ptr, pszParmValue);
7335 init_service(&serviceTemp);
7337 bRetval = False;
7339 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7341 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7342 if (iTemp == iServiceIndex) {
7343 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7344 } else {
7345 copy_service(ServicePtrs[iServiceIndex],
7346 &serviceTemp,
7347 ServicePtrs[iServiceIndex]->copymap);
7348 bRetval = True;
7350 } else {
7351 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7352 bRetval = False;
7355 free_service(&serviceTemp);
7356 return (bRetval);
7359 static bool handle_ldap_debug_level(int snum, const char *pszParmValue, char **ptr)
7361 Globals.ldap_debug_level = lp_int(pszParmValue);
7362 init_ldap_debugging();
7363 return true;
7366 /***************************************************************************
7367 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7368 parameters is:
7370 [global]
7372 idmap uid = 1000-1999
7373 idmap gid = 700-899
7375 We only do simple parsing checks here. The strings are parsed into useful
7376 structures in the idmap daemon code.
7378 ***************************************************************************/
7380 /* Some lp_ routines to return idmap [ug]id information */
7382 static uid_t idmap_uid_low, idmap_uid_high;
7383 static gid_t idmap_gid_low, idmap_gid_high;
7385 bool lp_idmap_uid(uid_t *low, uid_t *high)
7387 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7388 return False;
7390 if (low)
7391 *low = idmap_uid_low;
7393 if (high)
7394 *high = idmap_uid_high;
7396 return True;
7399 bool lp_idmap_gid(gid_t *low, gid_t *high)
7401 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7402 return False;
7404 if (low)
7405 *low = idmap_gid_low;
7407 if (high)
7408 *high = idmap_gid_high;
7410 return True;
7413 /* Do some simple checks on "idmap [ug]id" parameter values */
7415 static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
7417 uint32 low, high;
7419 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7420 return False;
7422 /* Parse OK */
7424 string_set(ptr, pszParmValue);
7426 idmap_uid_low = low;
7427 idmap_uid_high = high;
7429 return True;
7432 static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
7434 uint32 low, high;
7436 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7437 return False;
7439 /* Parse OK */
7441 string_set(ptr, pszParmValue);
7443 idmap_gid_low = low;
7444 idmap_gid_high = high;
7446 return True;
7449 /***************************************************************************
7450 Handle the DEBUG level list.
7451 ***************************************************************************/
7453 static bool handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
7455 string_set(ptr, pszParmValueIn);
7456 return debug_parse_levels(pszParmValueIn);
7459 /***************************************************************************
7460 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7461 ***************************************************************************/
7463 static const char *append_ldap_suffix( const char *str )
7465 const char *suffix_string;
7468 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7469 Globals.szLdapSuffix );
7470 if ( !suffix_string ) {
7471 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7472 return "";
7475 return suffix_string;
7478 const char *lp_ldap_machine_suffix(void)
7480 if (Globals.szLdapMachineSuffix[0])
7481 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7483 return lp_string(Globals.szLdapSuffix);
7486 const char *lp_ldap_user_suffix(void)
7488 if (Globals.szLdapUserSuffix[0])
7489 return append_ldap_suffix(Globals.szLdapUserSuffix);
7491 return lp_string(Globals.szLdapSuffix);
7494 const char *lp_ldap_group_suffix(void)
7496 if (Globals.szLdapGroupSuffix[0])
7497 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7499 return lp_string(Globals.szLdapSuffix);
7502 const char *lp_ldap_idmap_suffix(void)
7504 if (Globals.szLdapIdmapSuffix[0])
7505 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7507 return lp_string(Globals.szLdapSuffix);
7510 /****************************************************************************
7511 set the value for a P_ENUM
7512 ***************************************************************************/
7514 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7515 int *ptr )
7517 int i;
7519 for (i = 0; parm->enum_list[i].name; i++) {
7520 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7521 *ptr = parm->enum_list[i].value;
7522 return;
7525 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7526 pszParmValue, parm->label));
7529 /***************************************************************************
7530 ***************************************************************************/
7532 static bool handle_printing(int snum, const char *pszParmValue, char **ptr)
7534 static int parm_num = -1;
7535 struct service *s;
7537 if ( parm_num == -1 )
7538 parm_num = map_parameter( "printing" );
7540 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7542 if ( snum < 0 )
7543 s = &sDefault;
7544 else
7545 s = ServicePtrs[snum];
7547 init_printer_values( s );
7549 return True;
7553 /***************************************************************************
7554 Initialise a copymap.
7555 ***************************************************************************/
7557 static void init_copymap(struct service *pservice)
7559 int i;
7560 if (pservice->copymap) {
7561 bitmap_free(pservice->copymap);
7563 pservice->copymap = bitmap_allocate(NUMPARAMETERS);
7564 if (!pservice->copymap)
7565 DEBUG(0,
7566 ("Couldn't allocate copymap!! (size %d)\n",
7567 (int)NUMPARAMETERS));
7568 else
7569 for (i = 0; i < NUMPARAMETERS; i++)
7570 bitmap_set(pservice->copymap, i);
7573 /***************************************************************************
7574 Return the local pointer to a parameter given a service struct and the
7575 pointer into the default structure.
7576 ***************************************************************************/
7578 static void *lp_local_ptr(struct service *service, void *ptr)
7580 return (void *)(((char *)service) + PTR_DIFF(ptr, &sDefault));
7583 /***************************************************************************
7584 Return the local pointer to a parameter given the service number and the
7585 pointer into the default structure.
7586 ***************************************************************************/
7588 void *lp_local_ptr_by_snum(int snum, void *ptr)
7590 return lp_local_ptr(ServicePtrs[snum], ptr);
7593 /***************************************************************************
7594 Process a parameter for a particular service number. If snum < 0
7595 then assume we are in the globals.
7596 ***************************************************************************/
7598 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7600 int parmnum, i;
7601 void *parm_ptr = NULL; /* where we are going to store the result */
7602 void *def_ptr = NULL;
7603 struct param_opt_struct **opt_list;
7605 parmnum = map_parameter(pszParmName);
7607 if (parmnum < 0) {
7608 if (strchr(pszParmName, ':') == NULL) {
7609 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7610 pszParmName));
7611 return (True);
7615 * We've got a parametric option
7618 opt_list = (snum < 0)
7619 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7620 set_param_opt(opt_list, pszParmName, pszParmValue);
7622 return (True);
7625 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7626 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7627 pszParmName));
7630 def_ptr = parm_table[parmnum].ptr;
7632 /* we might point at a service, the default service or a global */
7633 if (snum < 0) {
7634 parm_ptr = def_ptr;
7635 } else {
7636 if (parm_table[parmnum].p_class == P_GLOBAL) {
7637 DEBUG(0,
7638 ("Global parameter %s found in service section!\n",
7639 pszParmName));
7640 return (True);
7642 parm_ptr = lp_local_ptr_by_snum(snum, def_ptr);
7645 if (snum >= 0) {
7646 if (!ServicePtrs[snum]->copymap)
7647 init_copymap(ServicePtrs[snum]);
7649 /* this handles the aliases - set the copymap for other entries with
7650 the same data pointer */
7651 for (i = 0; parm_table[i].label; i++)
7652 if (parm_table[i].ptr == parm_table[parmnum].ptr)
7653 bitmap_clear(ServicePtrs[snum]->copymap, i);
7656 /* if it is a special case then go ahead */
7657 if (parm_table[parmnum].special) {
7658 return parm_table[parmnum].special(snum, pszParmValue,
7659 (char **)parm_ptr);
7662 /* now switch on the type of variable it is */
7663 switch (parm_table[parmnum].type)
7665 case P_BOOL:
7666 *(bool *)parm_ptr = lp_bool(pszParmValue);
7667 break;
7669 case P_BOOLREV:
7670 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7671 break;
7673 case P_INTEGER:
7674 *(int *)parm_ptr = lp_int(pszParmValue);
7675 break;
7677 case P_CHAR:
7678 *(char *)parm_ptr = *pszParmValue;
7679 break;
7681 case P_OCTAL:
7682 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7683 if ( i != 1 ) {
7684 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7686 break;
7688 case P_LIST:
7689 TALLOC_FREE(*((char ***)parm_ptr));
7690 *(char ***)parm_ptr = str_list_make_v3(
7691 talloc_autofree_context(), pszParmValue, NULL);
7692 break;
7694 case P_STRING:
7695 string_set((char **)parm_ptr, pszParmValue);
7696 break;
7698 case P_USTRING:
7699 string_set((char **)parm_ptr, pszParmValue);
7700 strupper_m(*(char **)parm_ptr);
7701 break;
7703 case P_ENUM:
7704 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7705 break;
7706 case P_SEP:
7707 break;
7710 return (True);
7713 /***************************************************************************
7714 Process a parameter.
7715 ***************************************************************************/
7717 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7718 void *userdata)
7720 if (!bInGlobalSection && bGlobalOnly)
7721 return (True);
7723 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7725 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7726 pszParmName, pszParmValue));
7729 /***************************************************************************
7730 Print a parameter of the specified type.
7731 ***************************************************************************/
7733 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7735 int i;
7736 switch (p->type)
7738 case P_ENUM:
7739 for (i = 0; p->enum_list[i].name; i++) {
7740 if (*(int *)ptr == p->enum_list[i].value) {
7741 fprintf(f, "%s",
7742 p->enum_list[i].name);
7743 break;
7746 break;
7748 case P_BOOL:
7749 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7750 break;
7752 case P_BOOLREV:
7753 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7754 break;
7756 case P_INTEGER:
7757 fprintf(f, "%d", *(int *)ptr);
7758 break;
7760 case P_CHAR:
7761 fprintf(f, "%c", *(char *)ptr);
7762 break;
7764 case P_OCTAL: {
7765 char *o = octal_string(*(int *)ptr);
7766 fprintf(f, "%s", o);
7767 TALLOC_FREE(o);
7768 break;
7771 case P_LIST:
7772 if ((char ***)ptr && *(char ***)ptr) {
7773 char **list = *(char ***)ptr;
7774 for (; *list; list++) {
7775 /* surround strings with whitespace in double quotes */
7776 if ( strchr_m( *list, ' ' ) )
7777 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
7778 else
7779 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
7782 break;
7784 case P_STRING:
7785 case P_USTRING:
7786 if (*(char **)ptr) {
7787 fprintf(f, "%s", *(char **)ptr);
7789 break;
7790 case P_SEP:
7791 break;
7795 /***************************************************************************
7796 Check if two parameters are equal.
7797 ***************************************************************************/
7799 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7801 switch (type) {
7802 case P_BOOL:
7803 case P_BOOLREV:
7804 return (*((bool *)ptr1) == *((bool *)ptr2));
7806 case P_INTEGER:
7807 case P_ENUM:
7808 case P_OCTAL:
7809 return (*((int *)ptr1) == *((int *)ptr2));
7811 case P_CHAR:
7812 return (*((char *)ptr1) == *((char *)ptr2));
7814 case P_LIST:
7815 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7817 case P_STRING:
7818 case P_USTRING:
7820 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7821 if (p1 && !*p1)
7822 p1 = NULL;
7823 if (p2 && !*p2)
7824 p2 = NULL;
7825 return (p1 == p2 || strequal(p1, p2));
7827 case P_SEP:
7828 break;
7830 return (False);
7833 /***************************************************************************
7834 Initialize any local varients in the sDefault table.
7835 ***************************************************************************/
7837 void init_locals(void)
7839 /* None as yet. */
7842 /***************************************************************************
7843 Process a new section (service). At this stage all sections are services.
7844 Later we'll have special sections that permit server parameters to be set.
7845 Returns True on success, False on failure.
7846 ***************************************************************************/
7848 static bool do_section(const char *pszSectionName, void *userdata)
7850 bool bRetval;
7851 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7852 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7853 bRetval = False;
7855 /* if we were in a global section then do the local inits */
7856 if (bInGlobalSection && !isglobal)
7857 init_locals();
7859 /* if we've just struck a global section, note the fact. */
7860 bInGlobalSection = isglobal;
7862 /* check for multiple global sections */
7863 if (bInGlobalSection) {
7864 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7865 return (True);
7868 if (!bInGlobalSection && bGlobalOnly)
7869 return (True);
7871 /* if we have a current service, tidy it up before moving on */
7872 bRetval = True;
7874 if (iServiceIndex >= 0)
7875 bRetval = service_ok(iServiceIndex);
7877 /* if all is still well, move to the next record in the services array */
7878 if (bRetval) {
7879 /* We put this here to avoid an odd message order if messages are */
7880 /* issued by the post-processing of a previous section. */
7881 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7883 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
7884 < 0) {
7885 DEBUG(0, ("Failed to add a new service\n"));
7886 return (False);
7890 return (bRetval);
7894 /***************************************************************************
7895 Determine if a partcular base parameter is currentl set to the default value.
7896 ***************************************************************************/
7898 static bool is_default(int i)
7900 if (!defaults_saved)
7901 return False;
7902 switch (parm_table[i].type) {
7903 case P_LIST:
7904 return str_list_equal((const char **)parm_table[i].def.lvalue,
7905 *(const char ***)parm_table[i].ptr);
7906 case P_STRING:
7907 case P_USTRING:
7908 return strequal(parm_table[i].def.svalue,
7909 *(char **)parm_table[i].ptr);
7910 case P_BOOL:
7911 case P_BOOLREV:
7912 return parm_table[i].def.bvalue ==
7913 *(bool *)parm_table[i].ptr;
7914 case P_CHAR:
7915 return parm_table[i].def.cvalue ==
7916 *(char *)parm_table[i].ptr;
7917 case P_INTEGER:
7918 case P_OCTAL:
7919 case P_ENUM:
7920 return parm_table[i].def.ivalue ==
7921 *(int *)parm_table[i].ptr;
7922 case P_SEP:
7923 break;
7925 return False;
7928 /***************************************************************************
7929 Display the contents of the global structure.
7930 ***************************************************************************/
7932 static void dump_globals(FILE *f)
7934 int i;
7935 struct param_opt_struct *data;
7937 fprintf(f, "[global]\n");
7939 for (i = 0; parm_table[i].label; i++)
7940 if (parm_table[i].p_class == P_GLOBAL &&
7941 !(parm_table[i].flags & FLAG_META) &&
7942 parm_table[i].ptr &&
7943 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
7944 if (defaults_saved && is_default(i))
7945 continue;
7946 fprintf(f, "\t%s = ", parm_table[i].label);
7947 print_parameter(&parm_table[i], parm_table[i].ptr, f);
7948 fprintf(f, "\n");
7950 if (Globals.param_opt != NULL) {
7951 data = Globals.param_opt;
7952 while(data) {
7953 fprintf(f, "\t%s = %s\n", data->key, data->value);
7954 data = data->next;
7960 /***************************************************************************
7961 Return True if a local parameter is currently set to the global default.
7962 ***************************************************************************/
7964 bool lp_is_default(int snum, struct parm_struct *parm)
7966 int pdiff = PTR_DIFF(parm->ptr, &sDefault);
7968 return equal_parameter(parm->type,
7969 ((char *)ServicePtrs[snum]) + pdiff,
7970 ((char *)&sDefault) + pdiff);
7973 /***************************************************************************
7974 Display the contents of a single services record.
7975 ***************************************************************************/
7977 static void dump_a_service(struct service *pService, FILE * f)
7979 int i;
7980 struct param_opt_struct *data;
7982 if (pService != &sDefault)
7983 fprintf(f, "[%s]\n", pService->szService);
7985 for (i = 0; parm_table[i].label; i++) {
7987 if (parm_table[i].p_class == P_LOCAL &&
7988 !(parm_table[i].flags & FLAG_META) &&
7989 parm_table[i].ptr &&
7990 (*parm_table[i].label != '-') &&
7991 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7994 int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
7996 if (pService == &sDefault) {
7997 if (defaults_saved && is_default(i))
7998 continue;
7999 } else {
8000 if (equal_parameter(parm_table[i].type,
8001 ((char *)pService) +
8002 pdiff,
8003 ((char *)&sDefault) +
8004 pdiff))
8005 continue;
8008 fprintf(f, "\t%s = ", parm_table[i].label);
8009 print_parameter(&parm_table[i],
8010 ((char *)pService) + pdiff, f);
8011 fprintf(f, "\n");
8015 if (pService->param_opt != NULL) {
8016 data = pService->param_opt;
8017 while(data) {
8018 fprintf(f, "\t%s = %s\n", data->key, data->value);
8019 data = data->next;
8024 /***************************************************************************
8025 Display the contents of a parameter of a single services record.
8026 ***************************************************************************/
8028 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
8030 int i;
8031 bool result = False;
8032 parm_class p_class;
8033 unsigned flag = 0;
8034 fstring local_parm_name;
8035 char *parm_opt;
8036 const char *parm_opt_value;
8038 /* check for parametrical option */
8039 fstrcpy( local_parm_name, parm_name);
8040 parm_opt = strchr( local_parm_name, ':');
8042 if (parm_opt) {
8043 *parm_opt = '\0';
8044 parm_opt++;
8045 if (strlen(parm_opt)) {
8046 parm_opt_value = lp_parm_const_string( snum,
8047 local_parm_name, parm_opt, NULL);
8048 if (parm_opt_value) {
8049 printf( "%s\n", parm_opt_value);
8050 result = True;
8053 return result;
8056 /* check for a key and print the value */
8057 if (isGlobal) {
8058 p_class = P_GLOBAL;
8059 flag = FLAG_GLOBAL;
8060 } else
8061 p_class = P_LOCAL;
8063 for (i = 0; parm_table[i].label; i++) {
8064 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
8065 !(parm_table[i].flags & FLAG_META) &&
8066 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
8067 parm_table[i].ptr &&
8068 (*parm_table[i].label != '-') &&
8069 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8071 void *ptr;
8073 if (isGlobal) {
8074 ptr = parm_table[i].ptr;
8075 } else {
8076 struct service *pService = ServicePtrs[snum];
8077 ptr = ((char *)pService) +
8078 PTR_DIFF(parm_table[i].ptr, &sDefault);
8081 print_parameter(&parm_table[i],
8082 ptr, f);
8083 fprintf(f, "\n");
8084 result = True;
8085 break;
8089 return result;
8092 /***************************************************************************
8093 Return info about the requested parameter (given as a string).
8094 Return NULL when the string is not a valid parameter name.
8095 ***************************************************************************/
8097 struct parm_struct *lp_get_parameter(const char *param_name)
8099 int num = map_parameter(param_name);
8101 if (num < 0) {
8102 return NULL;
8105 return &parm_table[num];
8108 /***************************************************************************
8109 Return info about the next parameter in a service.
8110 snum==GLOBAL_SECTION_SNUM gives the globals.
8111 Return NULL when out of parameters.
8112 ***************************************************************************/
8114 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
8116 if (snum < 0) {
8117 /* do the globals */
8118 for (; parm_table[*i].label; (*i)++) {
8119 if (parm_table[*i].p_class == P_SEPARATOR)
8120 return &parm_table[(*i)++];
8122 if (!parm_table[*i].ptr
8123 || (*parm_table[*i].label == '-'))
8124 continue;
8126 if ((*i) > 0
8127 && (parm_table[*i].ptr ==
8128 parm_table[(*i) - 1].ptr))
8129 continue;
8131 if (is_default(*i) && !allparameters)
8132 continue;
8134 return &parm_table[(*i)++];
8136 } else {
8137 struct service *pService = ServicePtrs[snum];
8139 for (; parm_table[*i].label; (*i)++) {
8140 if (parm_table[*i].p_class == P_SEPARATOR)
8141 return &parm_table[(*i)++];
8143 if (parm_table[*i].p_class == P_LOCAL &&
8144 parm_table[*i].ptr &&
8145 (*parm_table[*i].label != '-') &&
8146 ((*i) == 0 ||
8147 (parm_table[*i].ptr !=
8148 parm_table[(*i) - 1].ptr)))
8150 int pdiff =
8151 PTR_DIFF(parm_table[*i].ptr,
8152 &sDefault);
8154 if (allparameters ||
8155 !equal_parameter(parm_table[*i].type,
8156 ((char *)pService) +
8157 pdiff,
8158 ((char *)&sDefault) +
8159 pdiff))
8161 return &parm_table[(*i)++];
8167 return NULL;
8171 #if 0
8172 /***************************************************************************
8173 Display the contents of a single copy structure.
8174 ***************************************************************************/
8175 static void dump_copy_map(bool *pcopymap)
8177 int i;
8178 if (!pcopymap)
8179 return;
8181 printf("\n\tNon-Copied parameters:\n");
8183 for (i = 0; parm_table[i].label; i++)
8184 if (parm_table[i].p_class == P_LOCAL &&
8185 parm_table[i].ptr && !pcopymap[i] &&
8186 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8188 printf("\t\t%s\n", parm_table[i].label);
8191 #endif
8193 /***************************************************************************
8194 Return TRUE if the passed service number is within range.
8195 ***************************************************************************/
8197 bool lp_snum_ok(int iService)
8199 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8202 /***************************************************************************
8203 Auto-load some home services.
8204 ***************************************************************************/
8206 static void lp_add_auto_services(char *str)
8208 char *s;
8209 char *p;
8210 int homes;
8211 char *saveptr;
8213 if (!str)
8214 return;
8216 s = SMB_STRDUP(str);
8217 if (!s)
8218 return;
8220 homes = lp_servicenumber(HOMES_NAME);
8222 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8223 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8224 char *home;
8226 if (lp_servicenumber(p) >= 0)
8227 continue;
8229 home = get_user_home_dir(talloc_tos(), p);
8231 if (home && home[0] && homes >= 0)
8232 lp_add_home(p, homes, p, home);
8234 TALLOC_FREE(home);
8236 SAFE_FREE(s);
8239 /***************************************************************************
8240 Auto-load one printer.
8241 ***************************************************************************/
8243 void lp_add_one_printer(const char *name, const char *comment, void *pdata)
8245 int printers = lp_servicenumber(PRINTERS_NAME);
8246 int i;
8248 if (lp_servicenumber(name) < 0) {
8249 lp_add_printer(name, printers);
8250 if ((i = lp_servicenumber(name)) >= 0) {
8251 string_set(&ServicePtrs[i]->comment, comment);
8252 ServicePtrs[i]->autoloaded = True;
8257 /***************************************************************************
8258 Have we loaded a services file yet?
8259 ***************************************************************************/
8261 bool lp_loaded(void)
8263 return (bLoaded);
8266 /***************************************************************************
8267 Unload unused services.
8268 ***************************************************************************/
8270 void lp_killunused(bool (*snumused) (int))
8272 int i;
8273 for (i = 0; i < iNumServices; i++) {
8274 if (!VALID(i))
8275 continue;
8277 /* don't kill autoloaded or usershare services */
8278 if ( ServicePtrs[i]->autoloaded ||
8279 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8280 continue;
8283 if (!snumused || !snumused(i)) {
8284 free_service_byindex(i);
8290 * Kill all except autoloaded and usershare services - convenience wrapper
8292 void lp_kill_all_services(void)
8294 lp_killunused(NULL);
8297 /***************************************************************************
8298 Unload a service.
8299 ***************************************************************************/
8301 void lp_killservice(int iServiceIn)
8303 if (VALID(iServiceIn)) {
8304 free_service_byindex(iServiceIn);
8308 /***************************************************************************
8309 Save the curent values of all global and sDefault parameters into the
8310 defaults union. This allows swat and testparm to show only the
8311 changed (ie. non-default) parameters.
8312 ***************************************************************************/
8314 static void lp_save_defaults(void)
8316 int i;
8317 for (i = 0; parm_table[i].label; i++) {
8318 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
8319 continue;
8320 switch (parm_table[i].type) {
8321 case P_LIST:
8322 parm_table[i].def.lvalue = str_list_copy(
8323 NULL, *(const char ***)parm_table[i].ptr);
8324 break;
8325 case P_STRING:
8326 case P_USTRING:
8327 if (parm_table[i].ptr) {
8328 parm_table[i].def.svalue = SMB_STRDUP(*(char **)parm_table[i].ptr);
8329 } else {
8330 parm_table[i].def.svalue = NULL;
8332 break;
8333 case P_BOOL:
8334 case P_BOOLREV:
8335 parm_table[i].def.bvalue =
8336 *(bool *)parm_table[i].ptr;
8337 break;
8338 case P_CHAR:
8339 parm_table[i].def.cvalue =
8340 *(char *)parm_table[i].ptr;
8341 break;
8342 case P_INTEGER:
8343 case P_OCTAL:
8344 case P_ENUM:
8345 parm_table[i].def.ivalue =
8346 *(int *)parm_table[i].ptr;
8347 break;
8348 case P_SEP:
8349 break;
8352 defaults_saved = True;
8355 /*******************************************************************
8356 Set the server type we will announce as via nmbd.
8357 ********************************************************************/
8359 static const struct srv_role_tab {
8360 uint32 role;
8361 const char *role_str;
8362 } srv_role_tab [] = {
8363 { ROLE_STANDALONE, "ROLE_STANDALONE" },
8364 { ROLE_DOMAIN_MEMBER, "ROLE_DOMAIN_MEMBER" },
8365 { ROLE_DOMAIN_BDC, "ROLE_DOMAIN_BDC" },
8366 { ROLE_DOMAIN_PDC, "ROLE_DOMAIN_PDC" },
8367 { 0, NULL }
8370 const char* server_role_str(uint32 role)
8372 int i = 0;
8373 for (i=0; srv_role_tab[i].role_str; i++) {
8374 if (role == srv_role_tab[i].role) {
8375 return srv_role_tab[i].role_str;
8378 return NULL;
8381 static void set_server_role(void)
8383 server_role = ROLE_STANDALONE;
8385 switch (lp_security()) {
8386 case SEC_SHARE:
8387 if (lp_domain_logons())
8388 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
8389 break;
8390 case SEC_SERVER:
8391 if (lp_domain_logons())
8392 DEBUG(0, ("Server's Role (logon server) conflicts with server-level security\n"));
8393 /* this used to be considered ROLE_DOMAIN_MEMBER but that's just wrong */
8394 server_role = ROLE_STANDALONE;
8395 break;
8396 case SEC_DOMAIN:
8397 if (lp_domain_logons()) {
8398 DEBUG(1, ("Server's Role (logon server) NOT ADVISED with domain-level security\n"));
8399 server_role = ROLE_DOMAIN_BDC;
8400 break;
8402 server_role = ROLE_DOMAIN_MEMBER;
8403 break;
8404 case SEC_ADS:
8405 if (lp_domain_logons()) {
8406 server_role = ROLE_DOMAIN_PDC;
8407 break;
8409 server_role = ROLE_DOMAIN_MEMBER;
8410 break;
8411 case SEC_USER:
8412 if (lp_domain_logons()) {
8414 if (Globals.iDomainMaster) /* auto or yes */
8415 server_role = ROLE_DOMAIN_PDC;
8416 else
8417 server_role = ROLE_DOMAIN_BDC;
8419 break;
8420 default:
8421 DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
8422 break;
8425 DEBUG(10, ("set_server_role: role = %s\n", server_role_str(server_role)));
8428 /***********************************************************
8429 If we should send plaintext/LANMAN passwords in the clinet
8430 ************************************************************/
8432 static void set_allowed_client_auth(void)
8434 if (Globals.bClientNTLMv2Auth) {
8435 Globals.bClientLanManAuth = False;
8437 if (!Globals.bClientLanManAuth) {
8438 Globals.bClientPlaintextAuth = False;
8442 /***************************************************************************
8443 JRA.
8444 The following code allows smbd to read a user defined share file.
8445 Yes, this is my intent. Yes, I'm comfortable with that...
8447 THE FOLLOWING IS SECURITY CRITICAL CODE.
8449 It washes your clothes, it cleans your house, it guards you while you sleep...
8450 Do not f%^k with it....
8451 ***************************************************************************/
8453 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8455 /***************************************************************************
8456 Check allowed stat state of a usershare file.
8457 Ensure we print out who is dicking with us so the admin can
8458 get their sorry ass fired.
8459 ***************************************************************************/
8461 static bool check_usershare_stat(const char *fname,
8462 const SMB_STRUCT_STAT *psbuf)
8464 if (!S_ISREG(psbuf->st_ex_mode)) {
8465 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8466 "not a regular file\n",
8467 fname, (unsigned int)psbuf->st_ex_uid ));
8468 return False;
8471 /* Ensure this doesn't have the other write bit set. */
8472 if (psbuf->st_ex_mode & S_IWOTH) {
8473 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8474 "public write. Refusing to allow as a usershare file.\n",
8475 fname, (unsigned int)psbuf->st_ex_uid ));
8476 return False;
8479 /* Should be 10k or less. */
8480 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8481 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8482 "too large (%u) to be a user share file.\n",
8483 fname, (unsigned int)psbuf->st_ex_uid,
8484 (unsigned int)psbuf->st_ex_size ));
8485 return False;
8488 return True;
8491 /***************************************************************************
8492 Parse the contents of a usershare file.
8493 ***************************************************************************/
8495 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8496 SMB_STRUCT_STAT *psbuf,
8497 const char *servicename,
8498 int snum,
8499 char **lines,
8500 int numlines,
8501 char **pp_sharepath,
8502 char **pp_comment,
8503 SEC_DESC **ppsd,
8504 bool *pallow_guest)
8506 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8507 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8508 int us_vers;
8509 SMB_STRUCT_DIR *dp;
8510 SMB_STRUCT_STAT sbuf;
8511 char *sharepath = NULL;
8512 char *comment = NULL;
8514 *pp_sharepath = NULL;
8515 *pp_comment = NULL;
8517 *pallow_guest = False;
8519 if (numlines < 4) {
8520 return USERSHARE_MALFORMED_FILE;
8523 if (strcmp(lines[0], "#VERSION 1") == 0) {
8524 us_vers = 1;
8525 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8526 us_vers = 2;
8527 if (numlines < 5) {
8528 return USERSHARE_MALFORMED_FILE;
8530 } else {
8531 return USERSHARE_BAD_VERSION;
8534 if (strncmp(lines[1], "path=", 5) != 0) {
8535 return USERSHARE_MALFORMED_PATH;
8538 sharepath = talloc_strdup(ctx, &lines[1][5]);
8539 if (!sharepath) {
8540 return USERSHARE_POSIX_ERR;
8542 trim_string(sharepath, " ", " ");
8544 if (strncmp(lines[2], "comment=", 8) != 0) {
8545 return USERSHARE_MALFORMED_COMMENT_DEF;
8548 comment = talloc_strdup(ctx, &lines[2][8]);
8549 if (!comment) {
8550 return USERSHARE_POSIX_ERR;
8552 trim_string(comment, " ", " ");
8553 trim_char(comment, '"', '"');
8555 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8556 return USERSHARE_MALFORMED_ACL_DEF;
8559 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8560 return USERSHARE_ACL_ERR;
8563 if (us_vers == 2) {
8564 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8565 return USERSHARE_MALFORMED_ACL_DEF;
8567 if (lines[4][9] == 'y') {
8568 *pallow_guest = True;
8572 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8573 /* Path didn't change, no checks needed. */
8574 *pp_sharepath = sharepath;
8575 *pp_comment = comment;
8576 return USERSHARE_OK;
8579 /* The path *must* be absolute. */
8580 if (sharepath[0] != '/') {
8581 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8582 servicename, sharepath));
8583 return USERSHARE_PATH_NOT_ABSOLUTE;
8586 /* If there is a usershare prefix deny list ensure one of these paths
8587 doesn't match the start of the user given path. */
8588 if (prefixdenylist) {
8589 int i;
8590 for ( i=0; prefixdenylist[i]; i++ ) {
8591 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8592 servicename, i, prefixdenylist[i], sharepath ));
8593 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8594 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8595 "usershare prefix deny list entries.\n",
8596 servicename, sharepath));
8597 return USERSHARE_PATH_IS_DENIED;
8602 /* If there is a usershare prefix allow list ensure one of these paths
8603 does match the start of the user given path. */
8605 if (prefixallowlist) {
8606 int i;
8607 for ( i=0; prefixallowlist[i]; i++ ) {
8608 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8609 servicename, i, prefixallowlist[i], sharepath ));
8610 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8611 break;
8614 if (prefixallowlist[i] == NULL) {
8615 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8616 "usershare prefix allow list entries.\n",
8617 servicename, sharepath));
8618 return USERSHARE_PATH_NOT_ALLOWED;
8622 /* Ensure this is pointing to a directory. */
8623 dp = sys_opendir(sharepath);
8625 if (!dp) {
8626 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8627 servicename, sharepath));
8628 return USERSHARE_PATH_NOT_DIRECTORY;
8631 /* Ensure the owner of the usershare file has permission to share
8632 this directory. */
8634 if (sys_stat(sharepath, &sbuf, false) == -1) {
8635 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8636 servicename, sharepath, strerror(errno) ));
8637 sys_closedir(dp);
8638 return USERSHARE_POSIX_ERR;
8641 sys_closedir(dp);
8643 if (!S_ISDIR(sbuf.st_ex_mode)) {
8644 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8645 servicename, sharepath ));
8646 return USERSHARE_PATH_NOT_DIRECTORY;
8649 /* Check if sharing is restricted to owner-only. */
8650 /* psbuf is the stat of the usershare definition file,
8651 sbuf is the stat of the target directory to be shared. */
8653 if (lp_usershare_owner_only()) {
8654 /* root can share anything. */
8655 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8656 return USERSHARE_PATH_NOT_ALLOWED;
8660 *pp_sharepath = sharepath;
8661 *pp_comment = comment;
8662 return USERSHARE_OK;
8665 /***************************************************************************
8666 Deal with a usershare file.
8667 Returns:
8668 >= 0 - snum
8669 -1 - Bad name, invalid contents.
8670 - service name already existed and not a usershare, problem
8671 with permissions to share directory etc.
8672 ***************************************************************************/
8674 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8676 SMB_STRUCT_STAT sbuf;
8677 SMB_STRUCT_STAT lsbuf;
8678 char *fname = NULL;
8679 char *sharepath = NULL;
8680 char *comment = NULL;
8681 fstring service_name;
8682 char **lines = NULL;
8683 int numlines = 0;
8684 int fd = -1;
8685 int iService = -1;
8686 TALLOC_CTX *ctx = NULL;
8687 SEC_DESC *psd = NULL;
8688 bool guest_ok = False;
8690 /* Ensure share name doesn't contain invalid characters. */
8691 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8692 DEBUG(0,("process_usershare_file: share name %s contains "
8693 "invalid characters (any of %s)\n",
8694 file_name, INVALID_SHARENAME_CHARS ));
8695 return -1;
8698 fstrcpy(service_name, file_name);
8700 if (asprintf(&fname, "%s/%s", dir_name, file_name) < 0) {
8703 /* Minimize the race condition by doing an lstat before we
8704 open and fstat. Ensure this isn't a symlink link. */
8706 if (sys_lstat(fname, &lsbuf, false) != 0) {
8707 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8708 fname, strerror(errno) ));
8709 SAFE_FREE(fname);
8710 return -1;
8713 /* This must be a regular file, not a symlink, directory or
8714 other strange filetype. */
8715 if (!check_usershare_stat(fname, &lsbuf)) {
8716 SAFE_FREE(fname);
8717 return -1;
8721 char *canon_name = canonicalize_servicename(service_name);
8722 TDB_DATA data = dbwrap_fetch_bystring(
8723 ServiceHash, canon_name, canon_name);
8725 iService = -1;
8727 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
8728 iService = *(int *)data.dptr;
8730 TALLOC_FREE(canon_name);
8733 if (iService != -1 &&
8734 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8735 &lsbuf.st_ex_mtime) == 0) {
8736 /* Nothing changed - Mark valid and return. */
8737 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8738 service_name ));
8739 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8740 SAFE_FREE(fname);
8741 return iService;
8744 /* Try and open the file read only - no symlinks allowed. */
8745 #ifdef O_NOFOLLOW
8746 fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8747 #else
8748 fd = sys_open(fname, O_RDONLY, 0);
8749 #endif
8751 if (fd == -1) {
8752 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8753 fname, strerror(errno) ));
8754 SAFE_FREE(fname);
8755 return -1;
8758 /* Now fstat to be *SURE* it's a regular file. */
8759 if (sys_fstat(fd, &sbuf, false) != 0) {
8760 close(fd);
8761 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8762 fname, strerror(errno) ));
8763 SAFE_FREE(fname);
8764 return -1;
8767 /* Is it the same dev/inode as was lstated ? */
8768 if (lsbuf.st_ex_dev != sbuf.st_ex_dev || lsbuf.st_ex_ino != sbuf.st_ex_ino) {
8769 close(fd);
8770 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8771 "Symlink spoofing going on ?\n", fname ));
8772 SAFE_FREE(fname);
8773 return -1;
8776 /* This must be a regular file, not a symlink, directory or
8777 other strange filetype. */
8778 if (!check_usershare_stat(fname, &sbuf)) {
8779 SAFE_FREE(fname);
8780 return -1;
8783 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8785 close(fd);
8786 if (lines == NULL) {
8787 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8788 fname, (unsigned int)sbuf.st_ex_uid ));
8789 SAFE_FREE(fname);
8790 return -1;
8793 SAFE_FREE(fname);
8795 /* Should we allow printers to be shared... ? */
8796 ctx = talloc_init("usershare_sd_xctx");
8797 if (!ctx) {
8798 TALLOC_FREE(lines);
8799 return 1;
8802 if (parse_usershare_file(ctx, &sbuf, service_name,
8803 iService, lines, numlines, &sharepath,
8804 &comment, &psd, &guest_ok) != USERSHARE_OK) {
8805 talloc_destroy(ctx);
8806 TALLOC_FREE(lines);
8807 return -1;
8810 TALLOC_FREE(lines);
8812 /* Everything ok - add the service possibly using a template. */
8813 if (iService < 0) {
8814 const struct service *sp = &sDefault;
8815 if (snum_template != -1) {
8816 sp = ServicePtrs[snum_template];
8819 if ((iService = add_a_service(sp, service_name)) < 0) {
8820 DEBUG(0, ("process_usershare_file: Failed to add "
8821 "new service %s\n", service_name));
8822 talloc_destroy(ctx);
8823 return -1;
8826 /* Read only is controlled by usershare ACL below. */
8827 ServicePtrs[iService]->bRead_only = False;
8830 /* Write the ACL of the new/modified share. */
8831 if (!set_share_security(service_name, psd)) {
8832 DEBUG(0, ("process_usershare_file: Failed to set share "
8833 "security for user share %s\n",
8834 service_name ));
8835 lp_remove_service(iService);
8836 talloc_destroy(ctx);
8837 return -1;
8840 /* If from a template it may be marked invalid. */
8841 ServicePtrs[iService]->valid = True;
8843 /* Set the service as a valid usershare. */
8844 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8846 /* Set guest access. */
8847 if (lp_usershare_allow_guests()) {
8848 ServicePtrs[iService]->bGuest_ok = guest_ok;
8851 /* And note when it was loaded. */
8852 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8853 string_set(&ServicePtrs[iService]->szPath, sharepath);
8854 string_set(&ServicePtrs[iService]->comment, comment);
8856 talloc_destroy(ctx);
8858 return iService;
8861 /***************************************************************************
8862 Checks if a usershare entry has been modified since last load.
8863 ***************************************************************************/
8865 static bool usershare_exists(int iService, struct timespec *last_mod)
8867 SMB_STRUCT_STAT lsbuf;
8868 const char *usersharepath = Globals.szUsersharePath;
8869 char *fname;
8871 if (asprintf(&fname, "%s/%s",
8872 usersharepath,
8873 ServicePtrs[iService]->szService) < 0) {
8874 return false;
8877 if (sys_lstat(fname, &lsbuf, false) != 0) {
8878 SAFE_FREE(fname);
8879 return false;
8882 if (!S_ISREG(lsbuf.st_ex_mode)) {
8883 SAFE_FREE(fname);
8884 return false;
8887 SAFE_FREE(fname);
8888 *last_mod = lsbuf.st_ex_mtime;
8889 return true;
8892 /***************************************************************************
8893 Load a usershare service by name. Returns a valid servicenumber or -1.
8894 ***************************************************************************/
8896 int load_usershare_service(const char *servicename)
8898 SMB_STRUCT_STAT sbuf;
8899 const char *usersharepath = Globals.szUsersharePath;
8900 int max_user_shares = Globals.iUsershareMaxShares;
8901 int snum_template = -1;
8903 if (*usersharepath == 0 || max_user_shares == 0) {
8904 return -1;
8907 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8908 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8909 usersharepath, strerror(errno) ));
8910 return -1;
8913 if (!S_ISDIR(sbuf.st_ex_mode)) {
8914 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8915 usersharepath ));
8916 return -1;
8920 * This directory must be owned by root, and have the 't' bit set.
8921 * It also must not be writable by "other".
8924 #ifdef S_ISVTX
8925 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8926 #else
8927 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8928 #endif
8929 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8930 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8931 usersharepath ));
8932 return -1;
8935 /* Ensure the template share exists if it's set. */
8936 if (Globals.szUsershareTemplateShare[0]) {
8937 /* We can't use lp_servicenumber here as we are recommending that
8938 template shares have -valid=False set. */
8939 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8940 if (ServicePtrs[snum_template]->szService &&
8941 strequal(ServicePtrs[snum_template]->szService,
8942 Globals.szUsershareTemplateShare)) {
8943 break;
8947 if (snum_template == -1) {
8948 DEBUG(0,("load_usershare_service: usershare template share %s "
8949 "does not exist.\n",
8950 Globals.szUsershareTemplateShare ));
8951 return -1;
8955 return process_usershare_file(usersharepath, servicename, snum_template);
8958 /***************************************************************************
8959 Load all user defined shares from the user share directory.
8960 We only do this if we're enumerating the share list.
8961 This is the function that can delete usershares that have
8962 been removed.
8963 ***************************************************************************/
8965 int load_usershare_shares(void)
8967 SMB_STRUCT_DIR *dp;
8968 SMB_STRUCT_STAT sbuf;
8969 SMB_STRUCT_DIRENT *de;
8970 int num_usershares = 0;
8971 int max_user_shares = Globals.iUsershareMaxShares;
8972 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8973 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8974 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8975 int iService;
8976 int snum_template = -1;
8977 const char *usersharepath = Globals.szUsersharePath;
8978 int ret = lp_numservices();
8980 if (max_user_shares == 0 || *usersharepath == '\0') {
8981 return lp_numservices();
8984 if (sys_stat(usersharepath, &sbuf, false) != 0) {
8985 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8986 usersharepath, strerror(errno) ));
8987 return ret;
8991 * This directory must be owned by root, and have the 't' bit set.
8992 * It also must not be writable by "other".
8995 #ifdef S_ISVTX
8996 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8997 #else
8998 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8999 #endif
9000 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
9001 "or does not have the sticky bit 't' set or is writable by anyone.\n",
9002 usersharepath ));
9003 return ret;
9006 /* Ensure the template share exists if it's set. */
9007 if (Globals.szUsershareTemplateShare[0]) {
9008 /* We can't use lp_servicenumber here as we are recommending that
9009 template shares have -valid=False set. */
9010 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
9011 if (ServicePtrs[snum_template]->szService &&
9012 strequal(ServicePtrs[snum_template]->szService,
9013 Globals.szUsershareTemplateShare)) {
9014 break;
9018 if (snum_template == -1) {
9019 DEBUG(0,("load_usershare_shares: usershare template share %s "
9020 "does not exist.\n",
9021 Globals.szUsershareTemplateShare ));
9022 return ret;
9026 /* Mark all existing usershares as pending delete. */
9027 for (iService = iNumServices - 1; iService >= 0; iService--) {
9028 if (VALID(iService) && ServicePtrs[iService]->usershare) {
9029 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
9033 dp = sys_opendir(usersharepath);
9034 if (!dp) {
9035 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
9036 usersharepath, strerror(errno) ));
9037 return ret;
9040 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
9041 (de = sys_readdir(dp));
9042 num_dir_entries++ ) {
9043 int r;
9044 const char *n = de->d_name;
9046 /* Ignore . and .. */
9047 if (*n == '.') {
9048 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
9049 continue;
9053 if (n[0] == ':') {
9054 /* Temporary file used when creating a share. */
9055 num_tmp_dir_entries++;
9058 /* Allow 20% tmp entries. */
9059 if (num_tmp_dir_entries > allowed_tmp_entries) {
9060 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
9061 "in directory %s\n",
9062 num_tmp_dir_entries, usersharepath));
9063 break;
9066 r = process_usershare_file(usersharepath, n, snum_template);
9067 if (r == 0) {
9068 /* Update the services count. */
9069 num_usershares++;
9070 if (num_usershares >= max_user_shares) {
9071 DEBUG(0,("load_usershare_shares: max user shares reached "
9072 "on file %s in directory %s\n",
9073 n, usersharepath ));
9074 break;
9076 } else if (r == -1) {
9077 num_bad_dir_entries++;
9080 /* Allow 20% bad entries. */
9081 if (num_bad_dir_entries > allowed_bad_entries) {
9082 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
9083 "in directory %s\n",
9084 num_bad_dir_entries, usersharepath));
9085 break;
9088 /* Allow 20% bad entries. */
9089 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
9090 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
9091 "in directory %s\n",
9092 num_dir_entries, usersharepath));
9093 break;
9097 sys_closedir(dp);
9099 /* Sweep through and delete any non-refreshed usershares that are
9100 not currently in use. */
9101 for (iService = iNumServices - 1; iService >= 0; iService--) {
9102 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
9103 if (conn_snum_used(iService)) {
9104 continue;
9106 /* Remove from the share ACL db. */
9107 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
9108 lp_servicename(iService) ));
9109 delete_share_security(lp_servicename(iService));
9110 free_service_byindex(iService);
9114 return lp_numservices();
9117 /********************************************************
9118 Destroy global resources allocated in this file
9119 ********************************************************/
9121 void gfree_loadparm(void)
9123 int i;
9125 free_file_list();
9127 /* Free resources allocated to services */
9129 for ( i = 0; i < iNumServices; i++ ) {
9130 if ( VALID(i) ) {
9131 free_service_byindex(i);
9135 SAFE_FREE( ServicePtrs );
9136 iNumServices = 0;
9138 /* Now release all resources allocated to global
9139 parameters and the default service */
9141 free_global_parameters();
9145 /***************************************************************************
9146 Allow client apps to specify that they are a client
9147 ***************************************************************************/
9148 void lp_set_in_client(bool b)
9150 in_client = b;
9154 /***************************************************************************
9155 Determine if we're running in a client app
9156 ***************************************************************************/
9157 bool lp_is_in_client(void)
9159 return in_client;
9162 /***************************************************************************
9163 Load the services array from the services file. Return True on success,
9164 False on failure.
9165 ***************************************************************************/
9167 bool lp_load_ex(const char *pszFname,
9168 bool global_only,
9169 bool save_defaults,
9170 bool add_ipc,
9171 bool initialize_globals,
9172 bool allow_include_registry,
9173 bool allow_registry_shares)
9175 char *n2 = NULL;
9176 bool bRetval;
9178 bRetval = False;
9180 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
9182 bInGlobalSection = True;
9183 bGlobalOnly = global_only;
9184 bAllowIncludeRegistry = allow_include_registry;
9186 init_globals(! initialize_globals);
9187 debug_init();
9189 free_file_list();
9191 if (save_defaults) {
9192 init_locals();
9193 lp_save_defaults();
9196 free_param_opts(&Globals.param_opt);
9198 /* We get sections first, so have to start 'behind' to make up */
9199 iServiceIndex = -1;
9201 if (lp_config_backend_is_file()) {
9202 n2 = alloc_sub_basic(get_current_username(),
9203 current_user_info.domain,
9204 pszFname);
9205 if (!n2) {
9206 smb_panic("lp_load_ex: out of memory");
9209 add_to_file_list(pszFname, n2);
9211 bRetval = pm_process(n2, do_section, do_parameter, NULL);
9212 SAFE_FREE(n2);
9214 /* finish up the last section */
9215 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
9216 if (bRetval) {
9217 if (iServiceIndex >= 0) {
9218 bRetval = service_ok(iServiceIndex);
9222 if (lp_config_backend_is_registry()) {
9223 /* config backend changed to registry in config file */
9225 * We need to use this extra global variable here to
9226 * survive restart: init_globals uses this as a default
9227 * for ConfigBackend. Otherwise, init_globals would
9228 * send us into an endless loop here.
9230 config_backend = CONFIG_BACKEND_REGISTRY;
9231 /* start over */
9232 DEBUG(1, ("lp_load_ex: changing to config backend "
9233 "registry\n"));
9234 init_globals(false);
9235 lp_kill_all_services();
9236 return lp_load_ex(pszFname, global_only, save_defaults,
9237 add_ipc, initialize_globals,
9238 allow_include_registry,
9239 allow_registry_shares);
9241 } else if (lp_config_backend_is_registry()) {
9242 bRetval = process_registry_globals();
9243 } else {
9244 DEBUG(0, ("Illegal config backend given: %d\n",
9245 lp_config_backend()));
9246 bRetval = false;
9249 if (bRetval && lp_registry_shares() && allow_registry_shares) {
9250 bRetval = process_registry_shares();
9253 lp_add_auto_services(lp_auto_services());
9255 if (add_ipc) {
9256 /* When 'restrict anonymous = 2' guest connections to ipc$
9257 are denied */
9258 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9259 if ( lp_enable_asu_support() ) {
9260 lp_add_ipc("ADMIN$", false);
9264 set_server_role();
9265 set_default_server_announce_type();
9266 set_allowed_client_auth();
9268 bLoaded = True;
9270 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9271 /* if bWINSsupport is true and we are in the client */
9272 if (lp_is_in_client() && Globals.bWINSsupport) {
9273 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9276 init_iconv();
9278 bAllowIncludeRegistry = true;
9280 return (bRetval);
9283 bool lp_load(const char *pszFname,
9284 bool global_only,
9285 bool save_defaults,
9286 bool add_ipc,
9287 bool initialize_globals)
9289 return lp_load_ex(pszFname,
9290 global_only,
9291 save_defaults,
9292 add_ipc,
9293 initialize_globals,
9294 true, false);
9297 bool lp_load_initial_only(const char *pszFname)
9299 return lp_load_ex(pszFname,
9300 true,
9301 false,
9302 false,
9303 true,
9304 false,
9305 false);
9308 bool lp_load_with_registry_shares(const char *pszFname,
9309 bool global_only,
9310 bool save_defaults,
9311 bool add_ipc,
9312 bool initialize_globals)
9314 return lp_load_ex(pszFname,
9315 global_only,
9316 save_defaults,
9317 add_ipc,
9318 initialize_globals,
9319 true,
9320 true);
9323 /***************************************************************************
9324 Return the max number of services.
9325 ***************************************************************************/
9327 int lp_numservices(void)
9329 return (iNumServices);
9332 /***************************************************************************
9333 Display the contents of the services array in human-readable form.
9334 ***************************************************************************/
9336 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9338 int iService;
9340 if (show_defaults)
9341 defaults_saved = False;
9343 dump_globals(f);
9345 dump_a_service(&sDefault, f);
9347 for (iService = 0; iService < maxtoprint; iService++) {
9348 fprintf(f,"\n");
9349 lp_dump_one(f, show_defaults, iService);
9353 /***************************************************************************
9354 Display the contents of one service in human-readable form.
9355 ***************************************************************************/
9357 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9359 if (VALID(snum)) {
9360 if (ServicePtrs[snum]->szService[0] == '\0')
9361 return;
9362 dump_a_service(ServicePtrs[snum], f);
9366 /***************************************************************************
9367 Return the number of the service with the given name, or -1 if it doesn't
9368 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9369 getservicebyname()! This works ONLY if all services have been loaded, and
9370 does not copy the found service.
9371 ***************************************************************************/
9373 int lp_servicenumber(const char *pszServiceName)
9375 int iService;
9376 fstring serviceName;
9378 if (!pszServiceName) {
9379 return GLOBAL_SECTION_SNUM;
9382 for (iService = iNumServices - 1; iService >= 0; iService--) {
9383 if (VALID(iService) && ServicePtrs[iService]->szService) {
9385 * The substitution here is used to support %U is
9386 * service names
9388 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9389 standard_sub_basic(get_current_username(),
9390 current_user_info.domain,
9391 serviceName,sizeof(serviceName));
9392 if (strequal(serviceName, pszServiceName)) {
9393 break;
9398 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9399 struct timespec last_mod;
9401 if (!usershare_exists(iService, &last_mod)) {
9402 /* Remove the share security tdb entry for it. */
9403 delete_share_security(lp_servicename(iService));
9404 /* Remove it from the array. */
9405 free_service_byindex(iService);
9406 /* Doesn't exist anymore. */
9407 return GLOBAL_SECTION_SNUM;
9410 /* Has it been modified ? If so delete and reload. */
9411 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9412 &last_mod) < 0) {
9413 /* Remove it from the array. */
9414 free_service_byindex(iService);
9415 /* and now reload it. */
9416 iService = load_usershare_service(pszServiceName);
9420 if (iService < 0) {
9421 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9422 return GLOBAL_SECTION_SNUM;
9425 return (iService);
9428 bool share_defined(const char *service_name)
9430 return (lp_servicenumber(service_name) != -1);
9433 struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
9434 const char *sharename)
9436 struct share_params *result;
9437 char *sname;
9438 int snum;
9440 if (!(sname = SMB_STRDUP(sharename))) {
9441 return NULL;
9444 snum = find_service(sname);
9445 SAFE_FREE(sname);
9447 if (snum < 0) {
9448 return NULL;
9451 if (!(result = TALLOC_P(mem_ctx, struct share_params))) {
9452 DEBUG(0, ("talloc failed\n"));
9453 return NULL;
9456 result->service = snum;
9457 return result;
9460 struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx)
9462 struct share_iterator *result;
9464 if (!(result = TALLOC_P(mem_ctx, struct share_iterator))) {
9465 DEBUG(0, ("talloc failed\n"));
9466 return NULL;
9469 result->next_id = 0;
9470 return result;
9473 struct share_params *next_share(struct share_iterator *list)
9475 struct share_params *result;
9477 while (!lp_snum_ok(list->next_id) &&
9478 (list->next_id < lp_numservices())) {
9479 list->next_id += 1;
9482 if (list->next_id >= lp_numservices()) {
9483 return NULL;
9486 if (!(result = TALLOC_P(list, struct share_params))) {
9487 DEBUG(0, ("talloc failed\n"));
9488 return NULL;
9491 result->service = list->next_id;
9492 list->next_id += 1;
9493 return result;
9496 struct share_params *next_printer(struct share_iterator *list)
9498 struct share_params *result;
9500 while ((result = next_share(list)) != NULL) {
9501 if (lp_print_ok(result->service)) {
9502 break;
9505 return result;
9509 * This is a hack for a transition period until we transformed all code from
9510 * service numbers to struct share_params.
9513 struct share_params *snum2params_static(int snum)
9515 static struct share_params result;
9516 result.service = snum;
9517 return &result;
9520 /*******************************************************************
9521 A useful volume label function.
9522 ********************************************************************/
9524 const char *volume_label(int snum)
9526 char *ret;
9527 const char *label = lp_volume(snum);
9528 if (!*label) {
9529 label = lp_servicename(snum);
9532 /* This returns a 33 byte guarenteed null terminated string. */
9533 ret = talloc_strndup(talloc_tos(), label, 32);
9534 if (!ret) {
9535 return "";
9537 return ret;
9540 /*******************************************************************
9541 Set the server type we will announce as via nmbd.
9542 ********************************************************************/
9544 static void set_default_server_announce_type(void)
9546 default_server_announce = 0;
9547 default_server_announce |= SV_TYPE_WORKSTATION;
9548 default_server_announce |= SV_TYPE_SERVER;
9549 default_server_announce |= SV_TYPE_SERVER_UNIX;
9551 /* note that the flag should be set only if we have a
9552 printer service but nmbd doesn't actually load the
9553 services so we can't tell --jerry */
9555 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9557 switch (lp_announce_as()) {
9558 case ANNOUNCE_AS_NT_SERVER:
9559 default_server_announce |= SV_TYPE_SERVER_NT;
9560 /* fall through... */
9561 case ANNOUNCE_AS_NT_WORKSTATION:
9562 default_server_announce |= SV_TYPE_NT;
9563 break;
9564 case ANNOUNCE_AS_WIN95:
9565 default_server_announce |= SV_TYPE_WIN95_PLUS;
9566 break;
9567 case ANNOUNCE_AS_WFW:
9568 default_server_announce |= SV_TYPE_WFW;
9569 break;
9570 default:
9571 break;
9574 switch (lp_server_role()) {
9575 case ROLE_DOMAIN_MEMBER:
9576 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9577 break;
9578 case ROLE_DOMAIN_PDC:
9579 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9580 break;
9581 case ROLE_DOMAIN_BDC:
9582 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9583 break;
9584 case ROLE_STANDALONE:
9585 default:
9586 break;
9588 if (lp_time_server())
9589 default_server_announce |= SV_TYPE_TIME_SOURCE;
9591 if (lp_host_msdfs())
9592 default_server_announce |= SV_TYPE_DFS_SERVER;
9595 /***********************************************************
9596 returns role of Samba server
9597 ************************************************************/
9599 int lp_server_role(void)
9601 return server_role;
9604 /***********************************************************
9605 If we are PDC then prefer us as DMB
9606 ************************************************************/
9608 bool lp_domain_master(void)
9610 if (Globals.iDomainMaster == Auto)
9611 return (lp_server_role() == ROLE_DOMAIN_PDC);
9613 return (bool)Globals.iDomainMaster;
9616 /***********************************************************
9617 If we are DMB then prefer us as LMB
9618 ************************************************************/
9620 bool lp_preferred_master(void)
9622 if (Globals.iPreferredMaster == Auto)
9623 return (lp_local_master() && lp_domain_master());
9625 return (bool)Globals.iPreferredMaster;
9628 /*******************************************************************
9629 Remove a service.
9630 ********************************************************************/
9632 void lp_remove_service(int snum)
9634 ServicePtrs[snum]->valid = False;
9635 invalid_services[num_invalid_services++] = snum;
9638 /*******************************************************************
9639 Copy a service.
9640 ********************************************************************/
9642 void lp_copy_service(int snum, const char *new_name)
9644 do_section(new_name, NULL);
9645 if (snum >= 0) {
9646 snum = lp_servicenumber(new_name);
9647 if (snum >= 0)
9648 lp_do_parameter(snum, "copy", lp_servicename(snum));
9653 /*******************************************************************
9654 Get the default server type we will announce as via nmbd.
9655 ********************************************************************/
9657 int lp_default_server_announce(void)
9659 return default_server_announce;
9662 /*******************************************************************
9663 Split the announce version into major and minor numbers.
9664 ********************************************************************/
9666 int lp_major_announce_version(void)
9668 static bool got_major = False;
9669 static int major_version = DEFAULT_MAJOR_VERSION;
9670 char *vers;
9671 char *p;
9673 if (got_major)
9674 return major_version;
9676 got_major = True;
9677 if ((vers = lp_announce_version()) == NULL)
9678 return major_version;
9680 if ((p = strchr_m(vers, '.')) == 0)
9681 return major_version;
9683 *p = '\0';
9684 major_version = atoi(vers);
9685 return major_version;
9688 int lp_minor_announce_version(void)
9690 static bool got_minor = False;
9691 static int minor_version = DEFAULT_MINOR_VERSION;
9692 char *vers;
9693 char *p;
9695 if (got_minor)
9696 return minor_version;
9698 got_minor = True;
9699 if ((vers = lp_announce_version()) == NULL)
9700 return minor_version;
9702 if ((p = strchr_m(vers, '.')) == 0)
9703 return minor_version;
9705 p++;
9706 minor_version = atoi(p);
9707 return minor_version;
9710 /***********************************************************
9711 Set the global name resolution order (used in smbclient).
9712 ************************************************************/
9714 void lp_set_name_resolve_order(const char *new_order)
9716 string_set(&Globals.szNameResolveOrder, new_order);
9719 const char *lp_printername(int snum)
9721 const char *ret = _lp_printername(snum);
9722 if (ret == NULL || (ret != NULL && *ret == '\0'))
9723 ret = lp_const_servicename(snum);
9725 return ret;
9729 /***********************************************************
9730 Allow daemons such as winbindd to fix their logfile name.
9731 ************************************************************/
9733 void lp_set_logfile(const char *name)
9735 string_set(&Globals.szLogFile, name);
9736 debug_set_logfile(name);
9739 /*******************************************************************
9740 Return the max print jobs per queue.
9741 ********************************************************************/
9743 int lp_maxprintjobs(int snum)
9745 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9746 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9747 maxjobs = PRINT_MAX_JOBID - 1;
9749 return maxjobs;
9752 const char *lp_printcapname(void)
9754 if ((Globals.szPrintcapname != NULL) &&
9755 (Globals.szPrintcapname[0] != '\0'))
9756 return Globals.szPrintcapname;
9758 if (sDefault.iPrinting == PRINT_CUPS) {
9759 #ifdef HAVE_CUPS
9760 return "cups";
9761 #else
9762 return "lpstat";
9763 #endif
9766 if (sDefault.iPrinting == PRINT_BSD)
9767 return "/etc/printcap";
9769 return PRINTCAP_NAME;
9772 static uint32 spoolss_state;
9774 bool lp_disable_spoolss( void )
9776 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9777 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9779 return spoolss_state == SVCCTL_STOPPED ? True : False;
9782 void lp_set_spoolss_state( uint32 state )
9784 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9786 spoolss_state = state;
9789 uint32 lp_get_spoolss_state( void )
9791 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9794 /*******************************************************************
9795 Ensure we don't use sendfile if server smb signing is active.
9796 ********************************************************************/
9798 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9800 bool sign_active = false;
9802 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9803 if (get_Protocol() < PROTOCOL_NT1) {
9804 return false;
9806 if (signing_state) {
9807 sign_active = smb_signing_is_active(signing_state);
9809 return (_lp_use_sendfile(snum) &&
9810 (get_remote_arch() != RA_WIN95) &&
9811 !sign_active);
9814 /*******************************************************************
9815 Turn off sendfile if we find the underlying OS doesn't support it.
9816 ********************************************************************/
9818 void set_use_sendfile(int snum, bool val)
9820 if (LP_SNUM_OK(snum))
9821 ServicePtrs[snum]->bUseSendfile = val;
9822 else
9823 sDefault.bUseSendfile = val;
9826 /*******************************************************************
9827 Turn off storing DOS attributes if this share doesn't support it.
9828 ********************************************************************/
9830 void set_store_dos_attributes(int snum, bool val)
9832 if (!LP_SNUM_OK(snum))
9833 return;
9834 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9837 void lp_set_mangling_method(const char *new_method)
9839 string_set(&Globals.szManglingMethod, new_method);
9842 /*******************************************************************
9843 Global state for POSIX pathname processing.
9844 ********************************************************************/
9846 static bool posix_pathnames;
9848 bool lp_posix_pathnames(void)
9850 return posix_pathnames;
9853 /*******************************************************************
9854 Change everything needed to ensure POSIX pathname processing (currently
9855 not much).
9856 ********************************************************************/
9858 void lp_set_posix_pathnames(void)
9860 posix_pathnames = True;
9863 /*******************************************************************
9864 Global state for POSIX lock processing - CIFS unix extensions.
9865 ********************************************************************/
9867 bool posix_default_lock_was_set;
9868 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9870 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9872 if (posix_default_lock_was_set) {
9873 return posix_cifsx_locktype;
9874 } else {
9875 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9879 /*******************************************************************
9880 ********************************************************************/
9882 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9884 posix_default_lock_was_set = True;
9885 posix_cifsx_locktype = val;
9888 int lp_min_receive_file_size(void)
9890 if (Globals.iminreceivefile < 0) {
9891 return 0;
9893 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9896 /*******************************************************************
9897 If socket address is an empty character string, it is necessary to
9898 define it as "0.0.0.0".
9899 ********************************************************************/
9901 const char *lp_socket_address(void)
9903 char *sock_addr = Globals.szSocketAddress;
9905 if (sock_addr[0] == '\0'){
9906 string_set(&Globals.szSocketAddress, "0.0.0.0");
9908 return Globals.szSocketAddress;
9911 void lp_set_passdb_backend(const char *backend)
9913 string_set(&Globals.szPassdbBackend, backend);
9916 /*******************************************************************
9917 Safe wide links checks.
9918 This helper function always verify the validity of wide links,
9919 even after a configuration file reload.
9920 ********************************************************************/
9922 static bool lp_widelinks_internal(int snum)
9924 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9925 sDefault.bWidelinks);
9928 void widelinks_warning(int snum)
9930 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9931 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9932 "These parameters are incompatible. "
9933 "Wide links will be disabled for this share.\n",
9934 lp_servicename(snum) ));
9938 bool lp_widelinks(int snum)
9940 /* wide links is always incompatible with unix extensions */
9941 if (lp_unix_extensions()) {
9942 return false;
9945 return lp_widelinks_internal(snum);